NORSYS SOFTWARE © 2012 | NETICA API | JAVA   VERSION   5.04  |
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--norsys.netica.gui.LinkGraphic
A java.awt.Component for displaying a link (arrow) between two NodePanels. By default the links are drawn in a fashion similar to that in Netica Application (TM). Using the setStroke
method you have full access to the way the body of the link is drawn (color, thickness, solid/dashed, etc.).
There are also methods for controlling the width and length of the arrowhead. In the following figure, there are two styles of link shown. Countless other styles and colors are possible.
Event Handling: LinkGraphic objects will respond only to mouse press, release, and click events. To listen for these events, create a java.awt.event.MouseListener and attach it to the LinkGraphic using addMouseListener, just as you would any other java.awt.Component. Although LinkGraphic objects ignore enter, leave, and drag events, you can handle these events yourself by extending the LinkGraphic class and providing your own handler methods in the child class.
NetPanel objects will construct one LinkGraphic object for each link that exists in the Net they represent. Unlike NodePanel objects, these LinkGraphic objects do not correspond to any VisualObject display properties of links within the Netica Net. Thus, there is currently no way to save or restore link properties when Nets are saved and restored.
You may access the LinkGraphic objects owned by a NetPanel using NetPanel.getLinkGraphics
, and you may
conveniently attach a single MouseListener to all the NetPanel's LinkGraphic objects with a single call to
NetPanel.addListenerToAllComponents
.
The Netica distribution includes a sample program, /examples/NetViewer.java, that illustrates how to work with LinkGraphic objects.
Inner classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent |
Field Summary | |
static java.awt.Color |
defaultForegroundColor
The color of this LinkGraphic upon construction. |
static int |
defaultLineWidth
The width of this LinkGraphic upon construction. |
static java.awt.Stroke |
defaultStroke
The java.awt.Stroke used when initially constructing LinkGraphic objects. |
static int |
DISPLAY_MODE_GRAYED
Used to display this LinkGraphic as "grayed" or "inactive". |
static int |
DISPLAY_MODE_HILITED
Used to display this LinkGraphic as having been specially selected. |
static int |
DISPLAY_MODE_NORMAL
Used to display this LinkGraphic in normal fashion. |
static java.awt.Color |
grayedModeColor
A color to use for signaling that this LinkGraphic is in "grayed out" mode ( see |
static java.awt.Color |
hilitedModeColor
A color to use for signaling that this LinkGraphic is in "hilited" mode ( see |
static double |
LINK_CLICK_DISTANCE_TOLERANCE
Controls the threshold used by isNear. |
static int |
LINK_DEFAULT_ARROW_HEAD_LENGTH
Used to set the length of the triangle forming a link arrow's head. |
static int |
LINK_DEFAULT_ARROW_HEAD_WIDTH
Used to set the width of the triangle forming a link arrow's head. |
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 |
Constructor Summary | |
LinkGraphic(java.awt.Container parentContainer,
NodePanel childNodePanel,
NodePanel parentNodePanel)
public constructors |
Method Summary | |
int |
getArrowHeadLength()
Gets the length of the arrow head. |
int |
getArrowHeadWidth()
Gets the width of the arrow head. |
java.awt.Point |
getCenterPoint()
Gets the center point of the link. |
NodePanel |
getChildNodePanel()
Return the NodePanel that is nearest to the arrow end of this link. |
int |
getDisplayMode()
Returns whether the link is grayed, normal, or hi-lited. |
java.awt.Point |
getEndPoint()
Gets the endpoint (arrowhead end) of the link. |
NodePanel |
getParentNodePanel()
Return the NodePanel that is nearest to the start end of this link. |
java.awt.Point |
getStartPoint()
Gets the startpoint (non-arrowhead end) of the link. |
java.awt.Stroke |
getStroke()
Returns the java.awt.Stroke used for drawing the line portion (body) of the link. |
boolean |
isNear(java.awt.Point point)
Returns true if point is within LINK_CLICK_DISTANCE_TOLERANCE pixels of the nearest point on this LinkGraphic. |
void |
mouseClicked(java.awt.event.MouseEvent event)
Informs all listeners of the click (press and release) event, provided this LinkGraphic is enabled and the mouse was pressed sufficiently near to the link. |
void |
mouseEntered(java.awt.event.MouseEvent event)
Satisfies MouseListener interface; does nothing (has empty implementation body). |
void |
mouseExited(java.awt.event.MouseEvent event)
Satisfies MouseListener interface; does nothing (has empty implementation body). |
void |
mousePressed(java.awt.event.MouseEvent event)
Informs all listeners of the press event, provided this LinkGraphic is enabled and the mouse was pressed sufficiently near to the link. |
void |
mouseReleased(java.awt.event.MouseEvent event)
Informs all listeners of the release event, provided this LinkGraphic is enabled and the mouse was pressed sufficiently near to the link. |
void |
paint(java.awt.Graphics g)
|
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 |
setArrowHeadLength(int newLength)
Sets the length of the arrow head. |
void |
setArrowHeadWidth(int newWidth)
Sets the width of the arrow head. |
void |
setDisplayMode(int displayMode)
Sets whether the link is displayed as grayed, normal, or hi-lited. |
void |
setEndPoint(java.awt.Point endPoint)
Sets the endpoint (arrowhead end) of the link, using Graphics coordinates. |
void |
setStartPoint(java.awt.Point startPoint)
Sets the startpoint (non-arrowhead end) of the link, using Graphics coordinates. |
void |
setStroke(java.awt.Stroke stroke)
Sets the java.awt.Stroke used for drawing the line portion (body) of the link. |
java.lang.String |
toString()
Returns a compact description of the link. |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, transferFocus, update, validate |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static double LINK_CLICK_DISTANCE_TOLERANCE |
public static int LINK_DEFAULT_ARROW_HEAD_LENGTH |
public static int LINK_DEFAULT_ARROW_HEAD_WIDTH |
public static java.awt.Stroke defaultStroke |
public static final int DISPLAY_MODE_GRAYED |
setDisplayMode
.public static final int DISPLAY_MODE_NORMAL |
setDisplayMode
.public static final int DISPLAY_MODE_HILITED |
setDisplayMode
.public static java.awt.Color defaultForegroundColor |
public static int defaultLineWidth |
public static java.awt.Color grayedModeColor |
setDisplayMode(DISPLAY_MODE_GRAYED)
). The default is gray.public static java.awt.Color hilitedModeColor |
setDisplayMode(DISPLAY_MODE_HILITED)
). The default is red.Constructor Detail |
public LinkGraphic ( |
| ) throws NeticaException |
Method Detail |
public int getArrowHeadLength ( ) |
LINK_DEFAULT_ARROW_HEAD_LENGTH | Initial length upon construction | |
setArrowHeadLength | Sets it | |
getArrowHeadWidth | Get the width instead |
public int getArrowHeadWidth ( ) |
LINK_DEFAULT_ARROW_HEAD_WIDTH | Initial width upon construction | |
setArrowHeadWidth | Sets it | |
getArrowHeadLength | Get the length instead |
public NodePanel getChildNodePanel ( ) |
getParentNodePanel | Retrieve the NodePanel at the other end |
public java.awt.Point getCenterPoint ( ) |
getStartPoint | Gets the start point | |
getEndPoint | Gets the end point |
public int getDisplayMode ( ) |
Returns one of DISPLAY_MODE_GRAYED, DISPLAY_MODE_NORMAL, or DISPLAY_MODE_HILITED.
Version:
setDisplayMode | Sets it. |
public java.awt.Point getEndPoint ( ) |
getStartPoint | Gets the start point instead | |
setEndPoint | Sets it |
public NodePanel getParentNodePanel ( ) |
getChildNodePanel | Retrieve the NodePanel at the other end. |
public java.awt.Point getStartPoint ( ) |
getEndPoint | Gets the end point instead | |
getCenterPoint | Gets the center point instead | |
setStartPoint | Sets i. |
public java.awt.Stroke getStroke ( ) |
setStroke | Sets it |
public boolean isNear ( |
| ) |
java.awt.Point | point | A point to test |
LINK_CLICK_DISTANCE_TOLERANCE | Controls the threshold of the distance measurement. |
public void paint ( |
| ) |
paint
in class java.awt.Component
public void setArrowHeadLength ( |
| ) |
int | newLength |
LINK_DEFAULT_ARROW_HEAD_LENGTH | Initial length upon construction | |
getArrowHeadLength | Retrieves it | |
setArrowHeadWidth | Set the width instead |
public void setArrowHeadWidth ( |
| ) |
int | newWidth |
LINK_DEFAULT_ARROW_HEAD_WIDTH | Initial width upon construction | |
getArrowHeadWidth | Retrieves it | |
setArrowHeadLength | Set the length instead |
public void setDisplayMode ( |
| ) |
For normal mode, this Component's foreground Color is used.
Parameters:
int | displayMode | One of DISPLAY_MODE_GRAYED, DISPLAY_MODE_NORMAL, or DISPLAY_MODE_HILITED. |
getDisplayMode | Retrieves it. |
public void setEndPoint ( |
| ) |
java.awt.Point | endPoint | The arrowhead (Node child) end of the link |
setStartPoint | Sets the start point instead | |
getEndPoint | Retrieves it |
public void setStartPoint ( |
| ) |
java.awt.Point | startPoint | The start (Node parent) end of the link |
setEndPoint | Sets the end point instead | |
getStartPoint | Retrieves it |
public void setStroke ( |
| ) |
Stroke | stroke | The new stroke to use |
getStroke | Retrieves it |
public String toString ( ) |
For instance for a link between the Smoking (parent) to the Bronchitis (child) node, it might be:
LinkGraphic: [parent=Smoking at (544,83), child=Bronchitis at (602,128)]
Version:
toString
in class java.awt.Component
public void refreshDataDisplayed ( ) throws NeticaException |
DataDisplayer
If this is a Container object, then it should arrange to invoke the refreshDataDisplayed method of all the DataDisplayer objects it contains.
Version:
refreshDataDisplayed
in interface DataDisplayer
public void mouseClicked ( |
| ) |
This link is enabled iff java.awt.Component.isEnabled() returns true.
The mouse is sufficiently near iff isNear returns true.
Parameters:
MouseEvent | event | The mouseClicked event. |
LINK_CLICK_DISTANCE_TOLERANCE | controls proximity sensitivity | |
mousePressed | receives mousePressed events instead | |
mouseClicked | receives mouseClicked events instead |
mouseClicked
in interface java.awt.event.MouseListener
public void mouseEntered ( |
| ) |
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited ( |
| ) |
mouseExited
in interface java.awt.event.MouseListener
public void mousePressed ( |
| ) |
This link is enabled iff java.awt.Component.isEnabled() returns true.
The mouse is sufficiently near iff isNear returns true.
Parameters:
MouseEvent | event | The mousePressed event. |
LINK_CLICK_DISTANCE_TOLERANCE | controls proximity sensitivity | |
mouseReleased | receives mouseReleased events instead | |
mouseClicked | receives mouseClicked events instead |
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased ( |
| ) |
This link is enabled iff java.awt.Component.isEnabled() returns true.
The mouse is sufficiently near iff isNear returns true.
Parameters:
MouseEvent | event | The mouseReleased event. |
LINK_CLICK_DISTANCE_TOLERANCE | controls proximity sensitivity | |
mousePressed | receives mousePressed events instead | |
mouseClicked | receives mouseClicked events instead |
mouseReleased
in interface java.awt.event.MouseListener
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |