BookNBPlatformCookbookCH07

Contents

NetBeans Platform Cookbook Chapter 07

Visual Library

Introduction

The Visual Library of NetBeans Platform is powerful graphics library for visualization. It can be used without Platform modules in any swing application.

The visual scene is composed of visual elements called Widget arranged in the tree structure (like as swing components) in the root Widget (class) Scene. It enables to provide Layout, add children, actions, connections and provides a lot of predefined widgets and their supporting classes (by factories).

The Scene offers the scene view JComponent by createView() method, the satellite view and the bird view. How to retrieve them and their usage is described in the first recipe Create Application Infrastructure.

You must consider three coordinate systems:

  • view coordinate system of the JComponent (as you are used to),
  • scene coordinate system is used by Scene and can use negative coordinates too,
  • local coordinates are used by widget to set boundaries and for children layout.

Each widget has several attributes – a border (like swing Border), parent, children, state, location, bounds.

For different purpose are used more general/specialized scene classes:

  • Scene has basic behavior, manages widgets, provides visual component and actions. Can be used for basic visualization.
  • ObjectScene is Scene subclass manages mapping between domain objects and corresponding widgets. You can care about domain object selection instead of widget selection.
  • GraphScene is subclass of the ObjectScene and manages graph data – nodes and edges. The class uses generics – GraphScene<Node, Edge> - and manages the model only. The developer creates visual widgets in overridden methods attachNodeWidget(), attachEdgeWidget() and others ones. To simplify working with graphs used text only there exists the GraphScene.StringGraph subclass.
  • GraphPinScene is similar but provides pins for edge connections. It is generic too.
  • VMDGraphScene class of the NetBeans Mobility Pack (is not part of the Visual Library) is a complex implementation of GraphPinScene<String,String,String> created for Visual Mobile Designer.

We will show basic usage of the Visual Library. More information you can read in the documentation.

Knowledge received in this chapter are useful for any Visual Library usage - the library can be used in the regular swing application (u can use the Lookup library, too). You do not need create NetBeans modules.

Visual Library 2.0 - Examples are stored on this page
http://platform.netbeans.org/graph/examples.html
They are a normal swing application where the Visual Library and Lookup library JARs are linked.
Important!' Do not forget add (select) the Visual Library module to use in used Platform (Project / Properties / Libraries / Platform / check Visual Library module.


Sections by topic

Sources

Example sources media:Nbpcook_07_Visual_Library.zip

Text and sources were created under NB 6.8, 7.0, 7.1.

Navigation

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo