Visualization API Graphscene Settings

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Visualization API Graphscene Settings

laadams85
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.




Reply | Threaded
Open this post in threaded view
|

Visualization API Graphscene Settings

bruehlicke
Uf many questions ...  for the number 3) have you looked at using your own "central lookup" Wade Chandler wrote a brilliant blog about this which now has 10 years anniversary !  See under http://wadechandler.blogspot.com/2007/12/central-lookup-creating-central.html

Try it out and tweak it if needed. It might fit your situation.

Welcome to the forum by the way !




Reply | Threaded
Open this post in threaded view
|

Re: Visualization API Graphscene Settings

stephen cumminger
In reply to this post by laadams85
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:[hidden email]]
Sent: Saturday, May 6, 2017 9:11 AM
To: [hidden email]
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.




Reply | Threaded
Open this post in threaded view
|

Visualization API Graphscene Settings

laadams85
In reply to this post by laadams85
Thanks for the welcome.   I've always enjoyed using java and I hope to use the flexibility of the netbeans platform to make my programs more powerful.  It has been painful for sure but that's ok.

That looks like not a bad solution.  A global singleton isn't the worst thing in the work.  I was hoping for something more standard but that's not necessary.

I'm thinking for the gridlines I may just add a background widget that draws the lines and also tie it into a custom pan and zoom action.  These actions would expand the gridline widget if necessary as well as the scroll pane portions.  The scene would then automatically expand the view component to accommodate the grid lines.  It's not my favorite solution, but I don't think I can spend any more time digging through the api code.