Class VMDNodeWidget

java.lang.Object
org.netbeans.api.visual.widget.Widget
org.netbeans.api.visual.vmd.VMDNodeWidget
All Implemented Interfaces:
Accessible, StateModel.Listener, VMDMinimizeAbility, org.openide.util.Lookup.Provider

public class VMDNodeWidget extends Widget implements StateModel.Listener, VMDMinimizeAbility
This class represents a node widget in the VMD visualization style. It implements the minimize ability. It allows to add pin widgets into the widget using attachPinWidget method.

The node widget consists of a header (with an image, a name, secondary name and a glyph set) and the content. The content contains pin widgets. Pin widgets can be organized in pin-categories defined by calling sortPins method. The sortPins method has to be called refresh the order after adding a pin widget.

  • Constructor Details

    • VMDNodeWidget

      public VMDNodeWidget(Scene scene)
      Creates a node widget.
      Parameters:
      scene - the scene
    • VMDNodeWidget

      public VMDNodeWidget(Scene scene, VMDColorScheme scheme)
      Creates a node widget with a specific color scheme.
      Parameters:
      scene - the scene
      scheme - the color scheme
  • Method Details

    • isMinimizableWidget

      protected boolean isMinimizableWidget(Widget widget)
      Called to check whether a particular widget is minimizable. By default it returns true. The result have to be the same for whole life-time of the widget. If not, then the revalidation has to be invoked manually. An anchor (created by VMDNodeWidget.createPinAnchor is not affected by this method.
      Parameters:
      widget - the widget
      Returns:
      true, if the widget is minimizable; false, if the widget is not minimizable
    • isMinimized

      public boolean isMinimized()
      Check the minimized state.
      Returns:
      true, if minimized
    • setMinimized

      public void setMinimized(boolean minimized)
      Set the minimized state. This method will show/hide child widgets of this Widget and switches anchors between node and pin widgets.
      Parameters:
      minimized - if true, then the widget is going to be minimized
    • toggleMinimized

      public void toggleMinimized()
      Toggles the minimized state. This method will show/hide child widgets of this Widget and switches anchors between node and pin widgets.
    • stateChanged

      public void stateChanged()
      Called when a minimized state is changed. This method will show/hide child widgets of this Widget and switches anchors between node and pin widgets.
      Specified by:
      stateChanged in interface StateModel.Listener
    • notifyStateChanged

      protected void notifyStateChanged(ObjectState previousState, ObjectState state)
      Called to notify about the change of the widget state.
      Overrides:
      notifyStateChanged in class Widget
      Parameters:
      previousState - the previous state
      state - the new state
    • setNodeImage

      public void setNodeImage(Image image)
      Sets a node image.
      Parameters:
      image - the image
    • getNodeName

      public String getNodeName()
      Returns a node name.
      Returns:
      the node name
    • setNodeName

      public void setNodeName(String nodeName)
      Sets a node name.
      Parameters:
      nodeName - the node name
    • setNodeType

      public void setNodeType(String nodeType)
      Sets a node type (secondary name).
      Parameters:
      nodeType - the node type
    • attachPinWidget

      public void attachPinWidget(Widget widget)
      Attaches a pin widget to the node widget.
      Parameters:
      widget - the pin widget
    • setGlyphs

      public void setGlyphs(List<Image> glyphs)
      Sets node glyphs.
      Parameters:
      glyphs - the list of images
    • setNodeProperties

      public void setNodeProperties(Image image, String nodeName, String nodeType, List<Image> glyphs)
      Sets all node properties at once.
      Parameters:
      image - the node image
      nodeName - the node name
      nodeType - the node type (secondary name)
      glyphs - the node glyphs
    • getNodeNameWidget

      public LabelWidget getNodeNameWidget()
      Returns a node name widget.
      Returns:
      the node name widget
    • getNodeAnchor

      public Anchor getNodeAnchor()
      Returns a node anchor.
      Returns:
      the node anchor
    • createAnchorPin

      public Anchor createAnchorPin(Anchor anchor)
      Creates an extended pin anchor with an ability of reconnecting to the node anchor when the node is minimized.
      Parameters:
      anchor - the original pin anchor from which the extended anchor is created
      Returns:
      the extended pin anchor, the returned anchor is cached and returns a single extended pin anchor instance of each original pin anchor
    • sortPins

      public void sortPins(HashMap<String, List<Widget>> pinsCategories)
      Sorts and assigns pins into categories.
      Parameters:
      pinsCategories - the map of category name as key and a list of pin widgets as value
    • collapseWidget

      public void collapseWidget()
      Collapses the widget.
      Specified by:
      collapseWidget in interface VMDMinimizeAbility
    • expandWidget

      public void expandWidget()
      Expands the widget.
      Specified by:
      expandWidget in interface VMDMinimizeAbility
    • getHeader

      public Widget getHeader()
      Returns a header widget.
      Returns:
      the header widget
    • getMinimizeButton

      public Widget getMinimizeButton()
      Returns a minimize button widget.
      Returns:
      the miminize button widget
    • getPinsSeparator

      public Widget getPinsSeparator()
      Returns a pins separator.
      Returns:
      the pins separator