cz.cmc.tcgui
Class TCObjectView.TCObjectHandle

java.lang.Object
  extended bycz.cmc.tcgui.TCObjectView.TCObjectHandle
All Implemented Interfaces:
org.jgraph.graph.CellHandle
Direct Known Subclasses:
ClassView.ClassHandle, FilterEntryView.FilterEntryHandle, QDiscView.QDiscHandle
Enclosing class:
TCObjectView

public class TCObjectView.TCObjectHandle
extends Object
implements org.jgraph.graph.CellHandle

Title: Class TCObjectHandle

Description: Basic handle for TCObjectView. Size handling code is based on class VertexView.SizeHandle

Copyright: Copyright (c) 2003

Company: CMC Computers


Field Summary
protected  Rectangle cachedBounds
           
protected  int CONNECT_HANDLE
           
protected  org.jgraph.graph.GraphContext context
          Reference to the context for the specified view.
protected  org.jgraph.graph.CellView[] contextViews
           
protected  Point currentPoint
          Connection target
protected  TCPort currentPort
          Port to connect to
protected  boolean dragged
           
protected  boolean firstDrag
           
protected  boolean firstOverlayInvocation
           
protected  Point firstPoint
          Point when the connecting started
protected  TCPort firstPort
          Port being connected
protected  org.jgraph.JGraph graph
           
protected  int handle
          Value of the handle being used
protected  Rectangle initialBounds
           
protected  int MOVE_HANDLE
           
protected  int NO_HANDLE
          Indexes of the active control point.
protected  Graphics offgraphics
           
protected  Image offscreen
          Double Buffer
protected  int originOffsetX
          Offset of the origin relative to mousePressed's x
protected  int originOffsetY
          Offset of the origin relative to mousePressed's x
protected  org.jgraph.graph.CellView[] portViews
           
protected  Rectangle[] r
          Array of control points represented as rectangles.
 
Constructor Summary
TCObjectView.TCObjectHandle(org.jgraph.graph.GraphContext ctx)
          Create handle for outter classes
 
Method Summary
protected  Rectangle computeBounds(MouseEvent event)
          Computes new bounds when handling move or resize
protected  void connect(TCPort port1, TCPort port2)
          Called when the connecting is done and the connection is allowed May be overriden by subclassers.
protected  int connectionAllowed(TCPort port1, TCPort port2)
          Decide whether the connection between ports is allowed
protected  TCPort getMatchingPort(TCObject tco)
          Get matching port of the counterpart TCObject when connecting.
protected  boolean handleMove()
          Returns true if this cell view is the only one in the selection.
protected  boolean handleResize()
          Returns true if the view's auto size is off.
protected  void initOffscreen()
          Double Buffers by David Larsson
protected  void makeBoundEdit(Rectangle bounds)
          Makes standard move/resize edit.
 void mouseDragged(MouseEvent event)
          Process mouse dragged event.
 void mouseMoved(MouseEvent event)
          Invoked when the mouse pointer has been moved on a component (with no buttons down).
 void mousePressed(MouseEvent event)
          Process mouse pressed event.
 void mouseReleased(MouseEvent e)
          Handle the mouse released event
protected  Rectangle moved(Graphics g, Rectangle bounds)
          If handleMove() returns true, this is called whenever the cell view is moved.
protected  void movingDone(Rectangle bounds)
          If handleMove() is true, this is called when the cell movement is done.
 void overlay(Graphics g)
          Overlay the handle
 void paint(Graphics g)
          Paint the handle
protected  Rectangle resized(Graphics g, Rectangle bounds)
          If handleResize() is true, this is called whenever the cell view is resized.
protected  void resizingDone(Rectangle bounds)
          If handleResize() is true, this is called when the cell resizing is done.
protected  void startConnecting(TCPort port)
          Starts connecting ports Called by subclassers to connect specific ports
protected  void updateConnect(Graphics g, MouseEvent e, boolean makeNew)
          Updates the connection state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

offscreen

protected transient Image offscreen
Double Buffer


offgraphics

protected transient Graphics offgraphics

firstDrag

protected transient boolean firstDrag

graph

protected transient org.jgraph.JGraph graph

portViews

protected transient org.jgraph.graph.CellView[] portViews

cachedBounds

protected transient Rectangle cachedBounds

context

protected transient org.jgraph.graph.GraphContext context
Reference to the context for the specified view.


initialBounds

protected transient Rectangle initialBounds

originOffsetX

protected transient int originOffsetX
Offset of the origin relative to mousePressed's x


originOffsetY

protected transient int originOffsetY
Offset of the origin relative to mousePressed's x


contextViews

protected transient org.jgraph.graph.CellView[] contextViews

firstPoint

protected transient Point firstPoint
Point when the connecting started


firstPort

protected transient TCPort firstPort
Port being connected


currentPoint

protected transient Point currentPoint
Connection target


currentPort

protected transient TCPort currentPort
Port to connect to


NO_HANDLE

protected final transient int NO_HANDLE
Indexes of the active control point. Values may be: NO_HANDLE: no handle is active MOVE_HANDLE: the move handle is active 0-7: resize handles

See Also:
Constant Field Values

MOVE_HANDLE

protected final transient int MOVE_HANDLE
See Also:
Constant Field Values

CONNECT_HANDLE

protected final transient int CONNECT_HANDLE
See Also:
Constant Field Values

handle

protected transient int handle
Value of the handle being used


r

protected transient Rectangle[] r
Array of control points represented as rectangles.


firstOverlayInvocation

protected boolean firstOverlayInvocation

dragged

protected transient boolean dragged
Constructor Detail

TCObjectView.TCObjectHandle

public TCObjectView.TCObjectHandle(org.jgraph.graph.GraphContext ctx)
Create handle for outter classes

Parameters:
ctx - Current GraphContext
Method Detail

handleResize

protected boolean handleResize()
Returns true if the view's auto size is off. May be overriden by subclassers.

Returns:
whether handle user resizing

startConnecting

protected void startConnecting(TCPort port)
Starts connecting ports Called by subclassers to connect specific ports

Parameters:
port - port to be connected to a counterpart

connectionAllowed

protected int connectionAllowed(TCPort port1,
                                TCPort port2)
Decide whether the connection between ports is allowed

Parameters:
port1 - first port to connect
port2 - second port to connect
Returns:
1 if port1 is allowed to connect port2 -1 if port2 is allowed to connect port1 0 if ports are not allowed to be connected

connect

protected void connect(TCPort port1,
                       TCPort port2)
Called when the connecting is done and the connection is allowed May be overriden by subclassers.

Parameters:
port1 - first port to connect
port2 - second port to connect

handleMove

protected boolean handleMove()
Returns true if this cell view is the only one in the selection. May be overriden by subclassers.

Returns:
whether handle the move by owner's view itself

moved

protected Rectangle moved(Graphics g,
                          Rectangle bounds)
If handleMove() returns true, this is called whenever the cell view is moved. Intended for subclassers.

Parameters:
g - Graphics that may be used for painting
bounds - current bounds of the cell
Returns:
rectangle that became dirty
See Also:
handleMove()

movingDone

protected void movingDone(Rectangle bounds)
If handleMove() is true, this is called when the cell movement is done.

Parameters:
bounds - new bounds of the cell

resized

protected Rectangle resized(Graphics g,
                            Rectangle bounds)
If handleResize() is true, this is called whenever the cell view is resized. Intended for subclassers.

Parameters:
g - Graphics that may be used for painting
bounds - current bounds of the cell
Returns:
rectangle that became dirty
See Also:
handleResize()

resizingDone

protected void resizingDone(Rectangle bounds)
If handleResize() is true, this is called when the cell resizing is done.

Parameters:
bounds - new bounds of the cell

makeBoundEdit

protected void makeBoundEdit(Rectangle bounds)
Makes standard move/resize edit.


paint

public void paint(Graphics g)
Paint the handle

Specified by:
paint in interface org.jgraph.graph.CellHandle
Parameters:
g - Graphics to paint on

initOffscreen

protected void initOffscreen()
Double Buffers by David Larsson


overlay

public void overlay(Graphics g)
Overlay the handle

Specified by:
overlay in interface org.jgraph.graph.CellHandle
Parameters:
g - Graphics to do overlay on

mouseMoved

public void mouseMoved(MouseEvent event)
Invoked when the mouse pointer has been moved on a component (with no buttons down).

Specified by:
mouseMoved in interface org.jgraph.graph.CellHandle

mousePressed

public void mousePressed(MouseEvent event)
Process mouse pressed event.

Specified by:
mousePressed in interface org.jgraph.graph.CellHandle

mouseDragged

public void mouseDragged(MouseEvent event)
Process mouse dragged event.

Specified by:
mouseDragged in interface org.jgraph.graph.CellHandle

getMatchingPort

protected TCPort getMatchingPort(TCObject tco)
Get matching port of the counterpart TCObject when connecting. Intended for subclassers

Parameters:
tco - TCObject to get matching port for
Returns:
matching port or null

updateConnect

protected void updateConnect(Graphics g,
                             MouseEvent e,
                             boolean makeNew)
Updates the connection state.

Parameters:
g - graphics to draw the connection state on
e - mouse event to make the update for
makeNew - false if erasing the old connection state, true if making a new one

computeBounds

protected Rectangle computeBounds(MouseEvent event)
Computes new bounds when handling move or resize

Parameters:
event - MouseEvent to compute new bounds for
Returns:
computed bounds

mouseReleased

public void mouseReleased(MouseEvent e)
Handle the mouse released event

Specified by:
mouseReleased in interface org.jgraph.graph.CellHandle
Parameters:
e - event to be handled