| NORSYS SOFTWARE © 2012 | NETICA API | JAVA VERSION 5.04

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## norsys.netica.gui
Class NodePanel

    java.lang.Object
      |
      +--java.awt.Component
            |
            +--java.awt.Container
                  |
                  +--javax.swing.JComponent
                        |
                        +--javax.swing.JPanel
                              |
                              +--norsys.netica.gui.NodePanel

All Implemented Interfaces:
  javax.accessibility.Accessible, DataDisplayer, java.awt.image.ImageObserver, java.awt.MenuContainer, NeticaListener, RecursingEventListener, java.io.Serializable

Direct Known Subclasses:
  NodePanel_BeliefBar, NodePanel_BeliefBars, NodePanel_Circle, NodePanel_LabeledBox, NodePanel_Text

public abstract class NodePanel
extends javax.swing.JPanel
implements RecursingEventListener, DataDisplayer, NeticaListener

An abstract base class used for constucting classes that are different styles of NodePanel. Several extensions of this class are supplied in this toolkit. The style that are supplied are modeled after those available in Netica Application (TM). These are as depicted in the following diagram:

>
Fig. 1. The Available NodePanels.

If you are familiar with Java SWING programming, you should find it easy to extend this class and create your own node styles. If you override any of the base methods, you will typically want to call the parent method in your overriding method so as to guarantee compatibility with the other NodePanels supplied in this toolkit.

Since:
  3.0
Version:
  5.04 - January 21, 2012
See Also:
  Serialized Form

Inner classes inherited from class javax.swing.JPanel
`javax.swing.JPanel.AccessibleJPanel`

Inner classes inherited from class javax.swing.JComponent
`javax.swing.JComponent.AccessibleJComponent`

Inner classes inherited from class java.awt.Container
`java.awt.Container.AccessibleAWTContainer`

Inner classes inherited from class java.awt.Component
`java.awt.Component.AccessibleAWTComponent`

Field Summary
`static java.awt.Color` | `defaultBackgroundColor_ConstantNode` Background Color for newly constructed Constant nodes.
`static java.awt.Color` | `defaultBackgroundColor_DecisionNode` Background Color for newly constructed Decision nodes.
`static java.awt.Color` | `defaultBackgroundColor_NatureNode` Background Color for newly constructed Nature nodes.
`static java.awt.Color` | `defaultBackgroundColor_UtilityNode` Background Color for newly constructed Utility nodes.
`static java.awt.Color` | `defaultBorderColor` The color of any border displayed by this panel upon construction.
`static java.awt.Color` | `defaultForegroundColor` The color of any foreground items, such as text.
`static javax.swing.border.Border` | `defaultTitleBorder` The Border around any title text.
`static java.awt.Font` | `defaultTitleFont` The Font of the title, if any.
`static int` | `DISPLAY_MODE_GRAYED` Used to display this NodePanel as "grayed" or "inactive".
`static int` | `DISPLAY_MODE_HILITED` Used to display this NodePanel as having been specially selected.
`static int` | `DISPLAY_MODE_NORMAL` Used to display this NodePanel in normal fashion.
`static java.awt.Color` | `grayedModeBGColor` A color to use for signaling that this NodePanel is in "grayed out" mode ( see `setDisplayMode(DISPLAY_MODE_GRAYED)`).
`static java.awt.Color` | `hilitedModeBGColor` A color to use for signaling that this NodePanel is in "hilited" mode ( see `setDisplayMode(DISPLAY_MODE_HILITED)`).
`static int` | `NODE_STYLE_ABSENT` Display the node as empty space.
`static int` | `NODE_STYLE_AUTO_SELECT` Display the node using a style that seems appropriate.
`static int` | `NODE_STYLE_BELIEF_BARS` Display the node similar to the Belief Bars Style in Netica Application.
`static int` | `NODE_STYLE_CIRCLE` Display the node as a circle or hexagon (Utility nodes).
`static int` | `NODE_STYLE_LABELED_BOX` Display the node titles only, in rounded boxes.
`static int` | `NODE_STYLE_TEXT` Display the node titles only.
`javax.swing.JLabel` | `nodeTitleJLabel` The title Component, if this NodePanel displays a title, otherwise null.
`static int` | `probabilitiesFormat` Used to control the format of any probabilities displayed by this NodePanel.
`static int` | `PROBABILITY_FORMAT_1` Used to display probabilities with no decimal place and a trailing "%" symbol.
`static int` | `PROBABILITY_FORMAT_2` Used to display probabilities as percentages, but without the "%" symbol, and with one decimal place.
`static int` | `PROBABILITY_FORMAT_3` Used to display probabilities as floats between 0.0 and 1.0, with two decimal places.
`static int` | `PROBABILITY_FORMAT_4` Used to display probabilities as floats between 0.00 and 1.00, with three decimal places.

Fields inherited from class javax.swing.JComponent
`accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW`

Fields inherited from class java.awt.Component
`BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT`

Fields inherited from interface java.awt.image.ImageObserver
`ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH`

Method Summary
`void` | `addListenerToAllComponents(java.util.EventListener eventListener)` Add the given EventListener to this object and, if it is a Container, to all RecursingEventListeners it contains.
`static NodePanel` | `createNodePanel(Node node, int style)` Returns a NodePanel associated with node, of the given style.
`void` | `eventOccurred(NeticaEvent event)` A call-back method that Netica will call to indicate an event occurred.
`int` | `getDisplayMode()` Returns whether the node is grayed, normal, or hi-lited.
`Node` | `getNode()` Returns the Node corresponding to this NodePanel.
`int` | `getStyle()` Returns the display style of this NodePanel.
`void` | `moveBy(int deltaX, int deltaY)` Move this panel by a fixed displacement.
`void` | `paintComponent(java.awt.Graphics g)` Overrides javax.swing.JComponent.paintComponent().
`void` | `refreshDataDisplayed()` Refresh all the data in this graphical Component, so that it correctly represents the current state of the Netica object it represents.
`void` | `removeListenerFromAllComponents(java.util.EventListener eventListener)` Remove the given EventListener from this object and, if it is a Container, from all RecursingEventListeners it contains.
`void` | `setDisplayMode(int displayMode)` Sets whether the node is displayed as grayed, normal, or hi-lited.
`protected void` | `setupPanel()` Create subcomponents of this NodePanel and add them to this Container.

Methods inherited from class javax.swing.JPanel
`getAccessibleContext, getUIClassID, paramString, updateUI`

Methods inherited from class javax.swing.JComponent
`addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update`

Methods inherited from class java.awt.Container
`add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree`

Methods inherited from class java.awt.Component
`action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

public static final int NODE_STYLE_AUTO_SELECT

  Display the node using a style that seems appropriate. See `NetPanel.setNodeStyle`.

public static final int NODE_STYLE_LABELED_BOX

  Display the node titles only, in rounded boxes. See `NetPanel.setNodeStyle`.

public static final int NODE_STYLE_CIRCLE

  Display the node as a circle or hexagon (Utility nodes). See `NetPanel.setNodeStyle`.

public static final int NODE_STYLE_ABSENT

  Display the node as empty space. See `NetPanel.setNodeStyle`.

public static final int NODE_STYLE_BELIEF_BARS

  Display the node similar to the Belief Bars Style in Netica Application. See `NetPanel.setNodeStyle`.

public static final int NODE_STYLE_TEXT

  Display the node titles only. See `NetPanel.setNodeStyle`.

public static final int DISPLAY_MODE_GRAYED

  Used to display this NodePanel as "grayed" or "inactive". See `setDisplayMode`.

public static final int DISPLAY_MODE_NORMAL

  Used to display this NodePanel in normal fashion. See `setDisplayMode`.

public static final int DISPLAY_MODE_HILITED

  Used to display this NodePanel as having been specially selected. See `setDisplayMode`.

public static final int PROBABILITY_FORMAT_1

  Used to display probabilities with no decimal place and a trailing "%" symbol. See `probabilitiesFormat`.

public static final int PROBABILITY_FORMAT_2

  Used to display probabilities as percentages, but without the "%" symbol, and with one decimal place. See `probabilitiesFormat`.

public static final int PROBABILITY_FORMAT_3

  Used to display probabilities as floats between 0.0 and 1.0, with two decimal places. See `probabilitiesFormat`.

public static final int PROBABILITY_FORMAT_4

  Used to display probabilities as floats between 0.00 and 1.00, with three decimal places. See `probabilitiesFormat`.

public static java.awt.Color defaultBackgroundColor_NatureNode

  Background Color for newly constructed Nature nodes. The default is a light cream color.

public static java.awt.Color defaultBackgroundColor_UtilityNode

  Background Color for newly constructed Utility nodes. The default is kakki green.

public static java.awt.Color defaultBackgroundColor_DecisionNode

  Background Color for newly constructed Decision nodes. The default is cyan blue.

public static java.awt.Color defaultBackgroundColor_ConstantNode

  Background Color for newly constructed Constant nodes. The default is null (transparent).

public static java.awt.Color defaultBorderColor

  The color of any border displayed by this panel upon construction. NodePanel subclasses typically also have a a static defaultBorderColor, which starts off being this color. The default is black.

public static java.awt.Color grayedModeBGColor

  A color to use for signaling that this NodePanel is in "grayed out" mode ( see `setDisplayMode(DISPLAY_MODE_GRAYED)`). The default is gray.

public static java.awt.Color hilitedModeBGColor

  A color to use for signaling that this NodePanel is in "hilited" mode ( see `setDisplayMode(DISPLAY_MODE_HILITED)`). The default is red.

public static java.awt.Color defaultForegroundColor

  The color of any foreground items, such as text. Child classes of NodePanel will typically also have a a static defaultForegroundColor, which will start off being this color. The default is black.

public static java.awt.Font defaultTitleFont

  The Font of the title, if any. Child classes of NodePanel will typically also have a a static defaultTitleFont, which will start off being this Font. The default is bold, sans-serif, size 14.

public static javax.swing.border.Border defaultTitleBorder

  The Border around any title text. Child classes of NodePanel will typically also have a a static defaultTitleBorder, which will start off being this Border. The default is an EmptyBorder with 2 pixels for top and bottom, and 8 pixels for left and right.

public static int probabilitiesFormat

  Used to control the format of any probabilities displayed by this NodePanel.

  Can be set to one of:

  PROBABILITY_FORMAT_1 |  | Percentage, with no decimal. Eg., 100%, 14%, 0%.
  PROBABILITY_FORMAT_2 |  | Percentage, to one decimal place, and without the "%" symbol. Eg., 100.0, 14.0, 0.0.
  PROBABILITY_FORMAT_3 |  | Real number, to two decimal places. Eg., 1.00, 0.14, 0.00.
  PROBABILITY_FORMAT_4 |  | Real number, to three decimal places. Eg., 1.000, 0.144, 0.000.

  The probabilities displayed are rounded numbers.

  For formats 2, 3, and 4, if the probability is non-zero, but would display as zero, then a "+" is appended to thedisplay. For example, with format 4, a probabibility of 0.00023 is displayed as 0.00+"

public javax.swing.JLabel nodeTitleJLabel

  The title Component, if this NodePanel displays a title, otherwise null.

Method Detail

public static NodePanel createNodePanel ( |
Node | node,
int | style
| ) throws NeticaException

  Returns a NodePanel associated with node, of the given style.

  For style, specify one of:

  NODE_STYLE_AUTO_SELECT |  | Netica-J will choose an appropriate style from amongst the following. If the node's VisualNode style (see `VisualNode.setStyle`) is set and can be sensibly mapped to one of the following styles, then that style will be used. Otherwise an appropriate default style will be used.
  NODE_STYLE_LABELED_BOX |  | Node title/name in rounded box
  NODE_STYLE_CIRCLE |  | Plain circle
  NODE_STYLE_ABSENT |  | Empty 1-pixel x 1-pixel space. Links to/from it still appear, and the space can still receive mouse events.
  NODE_STYLE_BELIEF_BARS |  | Netica (TM) style belief bars, a very popular style
  NODE_STYLE_TEXT |  | Node title/name without a border

  Each of the above is depicted in the following diagram:

  If you choose NODE_STYLE_AUTO_SELECT, then Netica will attempt to choose an appropriate style, depending on the type of node and the node's preferred display style (see `VisualNode.setStyle`). Preference is given to the node's preferred display style, but if this style is not set, is not understood, or does not make sense for this particular node, then appropriate defaults are chosen as per the following table:

  Type of Node (see `Node.getKind`) |  | Default style
  NATURE_NODE |  | NODE_STYLE_BELIEF_BARS
  DECISION_NODE |  | NODE_STYLE_BELIEF_BARS
  UTILITY_NODE |  | NODE_STYLE_LABELED_BOX
  CONSTANT_NODE |  | NODE_STYLE_TEXT
  DISCONNECTED_NODE |  | NODE_STYLE_ABSENT

  Parameters:

  Node |  | node |  | The node associated with this graphical representation.
  int |  | style |  | The style of graphic; one of , NODE_STYLE_LABELED_BOX, NODE_STYLE_AUTO_SELECT, NODE_STYLE_LABELED_BOX, , ...

  Version:
  Versions 3.0 and later have this method.
  See Also:

  `NetPanel.setNodeStyle` |  | Set the display style of all the nodes in a NetPanel.
  `NodePanel_BeliefBars.NodePanel_BeliefBars` |  | Constructor for NodePanel_BeliefBars.
  `NodePanel_Circle.NodePanel_Circle` |  | Constructor for NodePanel_Circle.
  `NodePanel_LabeledBox.NodePanel_LabeledBox` |  | Constructor for NodePanel_LabeledBox.
  `NodePanel_Text.NodePanel_Text` |  | Constructor for NodePanel_Text.

public void addListenerToAllComponents ( |
EventListener | eventListener
| )

  Description copied from interface: `RecursingEventListener`
  Add the given EventListener to this object and, if it is a Container, to all RecursingEventListeners it contains.
  Parameters:

  EventListener |  | eventListener |  | The listener to be added to this component and to any of its children that are also RecursingEventListeners.

  Version:
  Versions 3.0 and later have this method.
  See Also:

  removeListenerFromAllComponents |  | removes it instead

  Specified by:
    `addListenerToAllComponents` in interface `RecursingEventListener`

public void eventOccurred ( |
NeticaEvent | event
| )

  A call-back method that Netica will call to indicate an event occurred.
  Parameters:

  NeticaEvent |  | event |  | An object with information about the event that occurred.

  Version:
  Versions 3.0 and later have this method.
  Specified by:
    `eventOccurred` in interface `NeticaListener`

public int getDisplayMode ( )

  Returns whether the node is grayed, normal, or hi-lited.

  Returns one of DISPLAY_MODE_GRAYED, DISPLAY_MODE_NORMAL, or DISPLAY_MODE_HILITED.
  Version:

  Versions 3.0 and later have this method.
  See Also:

  setDisplayMode |  | Sets it.

public Node getNode ( ) throws NeticaException

  Returns the Node corresponding to this NodePanel.
  Version:
  Versions 3.0 and later have this method.

public int getStyle ( )

  Returns the display style of this NodePanel.

  This is one of:

  NODE_STYLE_AUTO_SELECT |  | Netica-J will choose an appropriate style for you from amongst the following.
  NODE_STYLE_LABELED_BOX |  | Node title/name in rounded box
  NODE_STYLE_CIRCLE |  | Plain circle
  NODE_STYLE_ABSENT |  | Empty rectangular space (but links to/from it still appear, and the space can receive mouse events, etc.)
  NODE_STYLE_BELIEF_BARS |  | Netica (TM) style belief bars, a very popular styl
  NODE_STYLE_TEXT |  | Node title/name without a border

  Each of the above is depicted in the following diagram:
  Version:

  Versions 3.0 and later have this method.
  See Also:

  createNodePanel |  | Creates a NodePanel of a certain style.
  `NetPanel.setNodeStyle` |  | Creates new NodePanels of a certain style for an entire net.

public void moveBy ( |
int | deltaX,
int | deltaY
| ) throws NeticaException

  Move this panel by a fixed displacement.

  deltaX is the change in the x (horizontal) direction.

  deltaY is the change in the y (vertical) direction.

  The VisualNode associated with this NodePanel is also displaced, by the same amounts.
  Parameters:

  int |  | deltaX |  | The change in the x (horizontal) direction.
  int |  | deltaY |  | The change in the y (vertical) direction.

  Version:
  Versions 3.0 and later have this method.

public void refreshDataDisplayed ( ) throws NeticaException

  Description copied from interface: `DataDisplayer`
  Refresh all the data in this graphical Component, so that it correctly represents the current state of the Netica object it represents.

  If this is a Container object, then it should arrange to invoke the refreshDataDisplayed method of all the DataDisplayer objects it contains.
  Version:

  Versions 3.0 and later have this method.
  Specified by:
    `refreshDataDisplayed` in interface `DataDisplayer`

public void removeListenerFromAllComponents ( |
EventListener | eventListener
| )

  Description copied from interface: `RecursingEventListener`
  Remove the given EventListener from this object and, if it is a Container, from all RecursingEventListeners it contains.
  Parameters:

  EventListener |  | eventListener |  | The listener to be removed from this component and from any of its children that are also RecursingEventListeners.

  Version:
  Versions 3.0 and later have this method.
  See Also:

  addListenerToAllComponents |  | adds it instead

  Specified by:
    `removeListenerFromAllComponents` in interface `RecursingEventListener`

public void setDisplayMode ( |
int | displayMode
| )

  Sets whether the node is displayed as grayed, normal, or hi-lited.
  Parameters:

  int |  | displayMode |  | One of DISPLAY_MODE_GRAYED, DISPLAY_MODE_NORMAL, or DISPLAY_MODE_HILITED.

  Version:
  Versions 3.0 and later have this method.
  See Also:

  getDisplayMode |  | Retrieves it.

protected void setupPanel ( ) throws Exception

  Create subcomponents of this NodePanel and add them to this Container.

  When you subclass NodePanel, you typically will want to override this method with your own method that builds the subcomponents of your particular NodePanel. Should you do this, we recommend that you call super.setupPanel() so that default NodePanel behavior (e.g., hi-liting logic) is retained.
  Version:

  Versions 3.0 and later have this method.

public void paintComponent ( |
java.awt.Graphics | g
| )

  Overrides javax.swing.JComponent.paintComponent().

  NOTICE:If you override this method, you probably want to call super.paintComponent() in your method to ensure that the node correctly manages display modes.
  Parameters:

  java.awt.Graphics |  | g |  | The AWT/SWING Graphics context.

  Version:
  Versions 3.0 and later have this method.
  Overrides:
    `paintComponent` in class `javax.swing.JComponent`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD