Re: Visualization API Graphscene Settings

stephen cumminger <[email protected]> Sun, 7 May 2017 12:31:42 +0000
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Message-ID <YTXPR01MB03498BE649FB281AA29E69D783E90@YTXPR01MB0349.CANPRD01.PROD.OUTLOOK.COM>
Just a couple of suggestions for you to consider:

1. I haven't implemented gridlines yet, but if I did it would be a custom LayerWidget loaded as a Background Layer and would need to listen to zoom/pan events/actions. Do you have your GraphScene constructor starting off something like this:
public class ProjectGraphScene extends GraphScene<StructureNode, SpanNode> implements Lookup.Provider{
   private final LayerWidget backgroundLayer= new LayerWidget (this);
   private final LayerWidget mainLayer= new LayerWidget (this);
   private final LayerWidget connectionLayer= new LayerWidget (this);
   private final LayerWidget interractionLayer = new LayerWidget (this);

public ProjectGraphScene() {
      setKeyEventProcessingType (EventProcessingType.ALL_WIDGETS);
      addChild(backgroundLayer);
      addChild(mainLayer);
      addChild(connectionLayer);
      addChild (interractionLayer);
      this.getInputBindings().setZoomActionModifiers(0);
      getActions ().addAction (ActionFactory.createPanAction ());

2. When I drag a widget out of normal view, scrolling happens automatically to keep it in view. You may have something off in your custom MoveProvider such as not invalidating the widget and calling validate on the scene?
3. You should conceivably be able to create a button bar that will add additional logic to function inside a new WidgetAction.Adapter(), listening to MouseClicks/presses that will add a new node to your scene at that location. You then just need to call validate on the scene for it to show. That is how I would do it.

Possibly you could post some code examples of what you are trying, to help you better.



Stephen Cumminger

-----Original Message-----
From: laadams85 [mailto:[email protected]] 
Sent: Saturday, May 6, 2017 9:11 AM
To: [email protected]
Subject: [platform-dev] Visualization API Graphscene Settings

I have a couple of questions related to the use of a Graphscene for displaying widgets.  Right now I have a topcomponent that contains a scrollpane which has the graphscene view as it's viewport.  I have also associated the palette with the lookup of the top component.  I am trying to make a 2D modeler, think AutoCAD or similar.  I have working code using Swing but I would like to port it over to the Netbeans platform.  Any help would be appreciated.

1)  There first one is if there is a default way to include Gridlines, and if not what's the easiest way to do that.  I have considered creating a gridline widget and adding it to the scene, but that seems very clunky. 

2)  Is there a way to make the pan and zoom actions expands the graphscene if the action moves out of bounds?  So if I pan to the left past x=0 the graphscene would expand the view component.  When you drag a widget out of bounds it will automatically expand the view it just won't do it for view operations.  One way to do it is to have a fake widget in the graphscene that is not rendered but expands when you pan/zoom but again seems hokey.

3)  Is there any easy way to use a palette to be a click bar instead of drag and drop.  What i means is you click on an icon and it sets the tool and when you click on the graphscene it places a widget.  I have it now where the TopComponent associated with the palette listens for new selections and places and action in it's lookup.  Then the graphscene listens to the globalactioncontext lookup for actions that it can use, and if any are available run them.  This seems somewhat error prone if the topcomponent is not focused, there won't be anything in the global lookup.