org.tigris.gef.presentation
Class FigNode

java.lang.Object
  extended by org.tigris.gef.presentation.Fig
      extended by org.tigris.gef.presentation.FigGroup
          extended by org.tigris.gef.presentation.FigNode
All Implemented Interfaces:
java.awt.event.MouseListener, java.beans.PropertyChangeListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, Connecter, Highlightable, PopupGenerator
Direct Known Subclasses:
FigSampleNode, FigSampleNode3

public class FigNode
extends FigGroup
implements Connecter, java.awt.event.MouseListener

Class to present a node (such as a NetNode) in a diagram.

See Also:
Serialized Form

Field Summary
protected  boolean _blinkPorts
          True if you want ports to show when the mouse moves in and be invisible otherwise.
protected  boolean _highlight
          True when we want to draw the user's attention to this FigNode.
static double ang135
           
static double ang225
           
static double ang315
           
static double ang45
          Constants useful for determining what side (north, south, east, or west) a port is located on.
 
Fields inherited from class org.tigris.gef.presentation.Fig
_allowsSaving, _context, _dashes, _dashPeriod, _dashStyle, _filled, _h, _w, _x, _y, an, annotationOwner, annotationStatus, BORDER, MIN_SIZE
 
Constructor Summary
FigNode()
           
FigNode(java.lang.Object node)
          Constructs a new FigNode on the given node with the given owner.
FigNode(java.lang.Object node, java.util.Collection figs)
          Constructs a new FigNode on the given node with the given owner and Figs.
 
Method Summary
 void addFigEdge(FigEdge fe)
          Adds a FigEdge to the list of them that need to be rerouted when this FigNode moves.
 void bindPort(java.lang.Object port, Fig f)
          Sets the port (some object in an underlying model) for Fig f.
 void cleanUp()
           
 java.lang.Object clone()
           
 boolean contains(int x, int y)
          Returns true if any Fig in the group contains the given point.
 java.lang.Object deepHitPort(int x, int y)
          Reply a port for the topmost Fig that actually has a port.
 void deleteFromModel()
          When a FigNode is disposed, all of its edges are disposed.
 void dispose()
          Deprecated. 0.11 use deleteFromModel()
 void endTrans()
          When a FigNode is damaged, all of its edges may need repainting.
 java.util.List getFigEdges()
           
 java.util.Collection getFigEdges(java.util.Collection c)
           
 boolean getHighlight()
           
 Fig getPortFig(java.lang.Object np)
          Reply the Fig that displays the given NetPort.
 java.util.List getPortFigs()
          Get all the figs that have some port as their owner
 int getPortSector(Fig portFig)
          Reply the port's sector within the current view.
 void hidePorts()
          Make the port Figs invisible.
 boolean hit(java.awt.Rectangle r)
          Returns true if any Fig in the group hits the given rect.
 java.lang.Object hitPort(int x, int y)
          Reply the port that "owns" the topmost Fig under the given point, or null if none.
 java.lang.Object hitPort(java.awt.Point p)
          Reply the NetPort associated with the topmost Fig under the mouse, or null if there is none.
 boolean isBlinkPorts()
          Determine if ports are set to appear only on mouseover.
 boolean isDragConnectable()
          Returns true if dragging from a port on this fig should automatically go to mode ModeCreateEdge
 void mouseClicked(java.awt.event.MouseEvent me)
          Do nothing when mouse is clicked in FigNode.
 void mouseEntered(java.awt.event.MouseEvent me)
          If the mouse enters this FigNode's bbox and the _blinkPorts flag is set, then show ports.
 void mouseExited(java.awt.event.MouseEvent me)
          If the mouse exits this FigNode's bbox and the _blinkPorts flag is set, then hide ports.
 void mousePressed(java.awt.event.MouseEvent me)
          Do nothing when mouse is pressed in FigNode.
 void mouseReleased(java.awt.event.MouseEvent me)
          Do nothing when mouse is released in FigNode.
 void paint(java.awt.Graphics g)
          Paints the FigNode to the given Graphics.
 void postLoad()
          After the file is loaded, re-establish any connections from the model to the Figs
 void propertyChange(java.beans.PropertyChangeEvent pce)
          The node object that this FigNode is presenting has changed state, or been disposed or highlighted.
 void removeFigEdge(FigEdge fe)
          removes a FigEdge from the list of them that need to be rerouted when this FigNode moves.
 void removeFromDiagram()
          When a FigNode is removed, all of its edges are removed.
 void removePort(Fig rep)
          Removes a port from the current FigNode.
 void setBlinkPorts(boolean b)
          Set the property of highlighting ports when the user moves the mouse over this FigNode.
 void setBounds(int x, int y, int w, int h)
          Set the bounding box to the given rect.
 void setEnclosingFig(Fig f)
          USED BY PGML.tee
 void setHighlight(boolean b)
           
 void setOwner(java.lang.Object node)
          Sets the owner (a node in some underlying model).
 void showPorts()
          Make the port Figs visible.
 void superTranslate(int dx, int dy)
           
 void translate(int dx, int dy)
          Translate all the Fig in the list by the given offset.
 void updateEdges()
           
 
Methods inherited from class org.tigris.gef.presentation.FigGroup
addFig, addFigs, calcBounds, deepSelect, elements, getDisplayedFigs, getExtraFrameSpace, getFigAt, getFigs, getFont, getFontFamily, getFontSize, getPrivateData, getSize, getSubFigBounds, getTextColor, getTextFillColor, getTextFilled, hitFig, isReshapable, isRotatable, iterator, parseDynObjects, removeAll, removeFig, setExtraFrameSpace, setFigs, setFigs, setFillColor, setFilled, setFont, setFontFamily, setFontSize, setLineColor, setLineWidth, setPrivateData, setTextColor, setTextFillColor, setTextFilled
 
Methods inherited from class org.tigris.gef.presentation.Fig
addAnnotation, addPoint, addPropertyChangeListener, align, center, classNameAndBounds, connectionPoint, contains, contains, countCornersContained, createDrag, damage, drawDashedLine, drawDashedPerimeter, firePropChange, firePropChange, firePropChange, getAnnotationOwner, getAnnotationStrategy, getBounds, getBounds, getClosestPoint, getContext, getDashed, getDashed01, getDashedString, getEnclosedFigs, getEnclosingFig, getFillColor, getFilled, getFilled01, getFirstPoint, getGravityPoints, getGroup, getHalfHeight, getHalfWidth, getHandleBox, getHeight, getId, getLastPoint, getLayer, getLineColor, getLineWidth, getLocation, getLocked, getMinimumSize, getNumPoints, getOwner, getPerimeterLength, getPoint, getPoints, getPopUpActions, getPreferredSize, getResource, getSingle, getTipString, getTrapRect, getUseTrapRect, getVisState, getWidth, getX, getXs, getY, getYs, hasFillColor, hasLineColor, initAnnotations, insertPoint, intersects, intersectsPerimeter, isAnnotation, isCopyable, isCutable, isLowerRightResizable, isMovable, isResizable, isSelected, isVisible, makeSelection, OK, pointAlongPerimeter, postSave, preSave, print, redraw, removeAnnotation, removeAnnotation, removePoint, removePropertyChangeListener, reorder, routingRect, savingAllowed, setAnnotationOwner, setAnnotationStatus, setAnnotationStrategy, setBounds, setCenter, setContext, setDashed, setDashedString, setGroup, setHandleBox, setHeight, setLayer, setLocation, setLocation, setLocked, setMovable, setNumPoints, setPoint, setPoint, setPoint, setPoint, setPoints, setResizable, setResource, setSavingAllowed, setSingle, setSize, setSize, setVisible, setVisState, setWidth, setX, setXs, setY, setYs, stuffBounds, stuffPointAlongPerimeter, translateAnnotations, unsetAnnotationOwner, updateAnnotationPositions, updateVisState, within
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.tigris.gef.ui.Highlightable
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

ang45

public static final double ang45
Constants useful for determining what side (north, south, east, or west) a port is located on.

See Also:
Constant Field Values

ang135

public static final double ang135
See Also:
Constant Field Values

ang225

public static final double ang225
See Also:
Constant Field Values

ang315

public static final double ang315
See Also:
Constant Field Values

_blinkPorts

protected boolean _blinkPorts
True if you want ports to show when the mouse moves in and be invisible otherwise.


_highlight

protected boolean _highlight
True when we want to draw the user's attention to this FigNode.

Constructor Detail

FigNode

public FigNode()

FigNode

public FigNode(java.lang.Object node)
Constructs a new FigNode on the given node with the given owner.

Parameters:
node - The model item that this node represents

FigNode

public FigNode(java.lang.Object node,
               java.util.Collection figs)
Constructs a new FigNode on the given node with the given owner and Figs.

Parameters:
node - the model item that this node represents
figs - the figs to be contained as a group by this FigNode
Method Detail

isDragConnectable

public boolean isDragConnectable()
Returns true if dragging from a port on this fig should automatically go to mode ModeCreateEdge

Returns:
the drag connectable property

clone

public java.lang.Object clone()
Overrides:
clone in class FigGroup

setBlinkPorts

public void setBlinkPorts(boolean b)
Set the property of highlighting ports when the user moves the mouse over this FigNode.


isBlinkPorts

public boolean isBlinkPorts()
Determine if ports are set to appear only on mouseover.

Returns:
true if ports are set to appear only on mouseover.

addFigEdge

public void addFigEdge(FigEdge fe)
Adds a FigEdge to the list of them that need to be rerouted when this FigNode moves.


removeFigEdge

public void removeFigEdge(FigEdge fe)
removes a FigEdge from the list of them that need to be rerouted when this FigNode moves.


getFigEdges

public java.util.Collection getFigEdges(java.util.Collection c)

getFigEdges

public java.util.List getFigEdges()

setOwner

public void setOwner(java.lang.Object node)
Sets the owner (a node in some underlying model). If the given node implements GraphNodeHooks, then the FigNode will register itself as a listener on the node.

Overrides:
setOwner in class Fig

hit

public boolean hit(java.awt.Rectangle r)
Returns true if any Fig in the group hits the given rect.

Overrides:
hit in class FigGroup
Parameters:
r - the rectangular hit area
Returns:
true if the hit rectangle strikes this fig

contains

public boolean contains(int x,
                        int y)
Description copied from class: FigGroup
Returns true if any Fig in the group contains the given point.

Overrides:
contains in class FigGroup
See Also:
FigCircle, FigEdge

setEnclosingFig

public void setEnclosingFig(Fig f)
Description copied from class: Fig
USED BY PGML.tee

Overrides:
setEnclosingFig in class Fig

endTrans

public void endTrans()
When a FigNode is damaged, all of its edges may need repainting.

Overrides:
endTrans in class Fig

removeFromDiagram

public void removeFromDiagram()
When a FigNode is removed, all of its edges are removed.

Overrides:
removeFromDiagram in class Fig

deleteFromModel

public void deleteFromModel()
When a FigNode is disposed, all of its edges are disposed.

Overrides:
deleteFromModel in class Fig

dispose

public void dispose()
Deprecated. 0.11 use deleteFromModel()

When a FigNode is disposed, all of its edges are disposed.


bindPort

public void bindPort(java.lang.Object port,
                     Fig f)
Sets the port (some object in an underlying model) for Fig f. f must already be contained in the FigNode. f will now represent the given port.


removePort

public void removePort(Fig rep)
Removes a port from the current FigNode.


hitPort

public final java.lang.Object hitPort(java.awt.Point p)
Reply the NetPort associated with the topmost Fig under the mouse, or null if there is none.


hitPort

public java.lang.Object hitPort(int x,
                                int y)
Reply the port that "owns" the topmost Fig under the given point, or null if none.


deepHitPort

public java.lang.Object deepHitPort(int x,
                                    int y)
Reply a port for the topmost Fig that actually has a port. This allows users to drag edges to or from ports that are hidden by other Figs.


getPortFig

public Fig getPortFig(java.lang.Object np)
Reply the Fig that displays the given NetPort.


getPortFigs

public java.util.List getPortFigs()
Get all the figs that have some port as their owner

Returns:
the List of figs

getPortSector

public int getPortSector(Fig portFig)
Reply the port's sector within the current view. This version works precisely with square FigNodes the angxx constants should be removed and calculated by the port if non-square FigNodes will be used.
Sectors
                      \  1   /
                       \    /
                        \  /
                     2   \/   -2
                         /\
                        /  \
                       /    \
                      /  -1  \ 


paint

public void paint(java.awt.Graphics g)
Paints the FigNode to the given Graphics. Calls super.paint to paint all the Figs contained in the FigNode. Also can draw a highlighting rectangle around the FigNode. Needs-more-work: maybe I should implement LayerHighlight instead.

Overrides:
paint in class FigGroup

setHighlight

public void setHighlight(boolean b)
Specified by:
setHighlight in interface Highlightable

getHighlight

public boolean getHighlight()
Specified by:
getHighlight in interface Highlightable

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent pce)
The node object that this FigNode is presenting has changed state, or been disposed or highlighted.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Overrides:
propertyChange in class Fig

showPorts

public void showPorts()
Make the port Figs visible. Used when blinkingPorts is true.


hidePorts

public void hidePorts()
Make the port Figs invisible. Used when blinkingPorts is true.


mouseEntered

public void mouseEntered(java.awt.event.MouseEvent me)
If the mouse enters this FigNode's bbox and the _blinkPorts flag is set, then show ports.

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent me)
If the mouse exits this FigNode's bbox and the _blinkPorts flag is set, then hide ports.

Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
Do nothing when mouse is pressed in FigNode.

Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent me)
Do nothing when mouse is released in FigNode.

Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent me)
Do nothing when mouse is clicked in FigNode.

Specified by:
mouseClicked in interface java.awt.event.MouseListener

translate

public void translate(int dx,
                      int dy)
Description copied from class: FigGroup
Translate all the Fig in the list by the given offset.

Overrides:
translate in class FigGroup

superTranslate

public void superTranslate(int dx,
                           int dy)

setBounds

public void setBounds(int x,
                      int y,
                      int w,
                      int h)
Description copied from class: FigGroup
Set the bounding box to the given rect. Figs in the group are scaled to fit. Fires PropertyChange with "bounds"

Overrides:
setBounds in class FigGroup
Parameters:
x - new X co ordinate for fig
y - new Y co ordinate for fig
w - new width for fig
h - new height for fig

updateEdges

public void updateEdges()

postLoad

public void postLoad()
After the file is loaded, re-establish any connections from the model to the Figs

Overrides:
postLoad in class Fig

cleanUp

public void cleanUp()
Overrides:
cleanUp in class Fig