X

Geertjan's Blog

  • August 30, 2006

Alignment and Satellite View in Visual Library 2.0

Geertjan Wielenga
Product Manager
Creating a satellite view (the small view on the left side of the screenshot below, which always shows the current status of the main view, including movement) in an implementation of the Visual Library is easy. First, look at the screenshot:

Then, look at how easy it is to create the above two views, using a NetBeans TopComponent:

SimpsonTopComponent simpsonTopComponent = new SimpsonTopComponent(this.createView());
simpsonTopComponent.add(this.createSateliteView(), BorderLayout.WEST);
simpsonTopComponent.open();
simpsonTopComponent.requestActive();

So, here we send the content of the current GraphScene.StringGraph implementation class to the TopComponent, for populating the JScrollPane in the TopComponent and for creating a small satellite view, in this case on the left side of the main view. Note that the satellite view could be created in a whole separate TopComponent, which could be floating over the main TopComponent above.

But I added something else as well—alignment functionality. Above you can see "Nixon" (who, along with most/all American presidents is a regular reference point in the Simpsons, as explained by someone with a lot of time here) being dragged. Automatically, guidelines appear, advising me where to place Nixon in relation to the other widgets (i.e., Simpson characters). The widget even "snaps" into place, which is very cool. And it is almost as simple to implement as the satellite view—declare a move action, specify that the move action should include alignment, and then attach the move action to each widget that needs it. It is all purely declarative—you just state what you want the Visual Library to provide and then specify where you want it to be provided.

By the way, both of these features, satellite view and alignment, are well described in the samples that accompany the Visual Library.

Join the discussion

Comments ( 3 )
  • Ahmed Mohombe Wednesday, August 30, 2006
    Very nice :).

    Please continue the series about the graph library.

    Also a few things that would be IMHO very interesting but also very useful (to make with the graph lib):
    • autolayouting nodes and vertices with different algorithms.
    • Printing diagrams (with print preview and page selections for bigger diagrams)
    • exporting to image (e.g. PNG), but no "in memory solution" since it doesn't work for bigger diagrams.
    • how to enable "drop shadows" and "antialiasing", to beautify the look of the diagrams to look a little a la Omnigraffle.



    Thanks in advance,



    Ahmed.
  • David Kaspar Thursday, August 31, 2006
    Hi Ahmed,

    Autolayouting nodes and vertices is supported but unfortunately there is no implementation of graph-layout algorithm. It will come in the future.

    There is only a trivial support for printing and exporting: use Scene.paint(Graphics2D). See "Printing and Exporting Scene" section in documentation. Do you know, how to implement no-in-memory-solution of export-to-png? Is there some PNGWriterGraphics2D class?

    Enabling antialiasing and drop shadows is not supported directly right now. It will be implemented later and I am going to describe it in "Effects" section in documentation.

    Re: Omnigraffle: It is really pretty graphics and it takes some time to make VisualLib to look like Omnigraffle. I will try to do something with the graphics in the future.

    Regards, David

  • Ahmed Mohombe Thursday, August 31, 2006
    Autolayouting nodes and vertices is supported but unfortunately there is no implementation of graph-layout algorithm. It will come in the future

    Than maybe just take the best algoritms from JUNG :). They have may there, and are "rendering" independent.



    Do you know, how to implement no-in-memory-solution of export-to-png?</br/>


    No :(. This is why I was asking. For real use cases, it must be not-in-memory, since useful diagrams (not toys) get a little bigger.



    It will be implemented later

    Please make it ASAP, and with a higher priority :). IMHO this is very important, cause there are many Graph libraries out there, and these effects are the those who capture the most of attention and convince users to use the library :) (people are superficial :) ).

    AFAIK Java2D is extremly powerful :). Romain Guy has in his blog many of such cool effects (especially in the archive).


    and it takes some time to make VisualLib to look like Omnigraffle

    Maybe it's not theat complicated :). There's nothing spectacular in Omnigraffle style. Only simplicity (simple workflow), good defaults and those effects everywhere (but everywhere :) ).




    Thanks in advance,




    Ahmed.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.