TGT
Class TGT_BasicConnectorSprite

java.lang.Object
  extended byTGT.TGT_Sprite
      extended byTGT.TGT_DrawableSprite
          extended byTGT.TGT_BasicConnectorSprite
All Implemented Interfaces:
TGT_AbstractSprite
Direct Known Subclasses:
TGT_RtAngleConnectorSprite, TGT_UTurnConnectorSprite

public class TGT_BasicConnectorSprite
extends TGT_DrawableSprite

Sprite that acts as a connector between two TGT_NodeSprite derived sprites.


Field Summary
protected  TGT_ConnectionPoint[] endpoint
           
 
Fields inherited from class TGT.TGT_DrawableSprite
height, primary, secondary, width
 
Fields inherited from class TGT.TGT_Sprite
name, priority, rate, visible, x, y
 
Constructor Summary
TGT_BasicConnectorSprite()
           
TGT_BasicConnectorSprite(java.lang.String nm, int pri, int rt, boolean vis, int x, int y, int wide, java.awt.Color first, java.awt.Color second, int ep1x, int ep1y, int ep2x, int ep2y)
          Creates a BasicConnectorSprite with specific parameters
TGT_BasicConnectorSprite(java.lang.String nm, java.util.StringTokenizer st)
           
 
Method Summary
protected  int computeDecoratorOrientation(int endptidx)
           
 void draw(java.awt.Graphics g, java.awt.image.ImageObserver o)
          Draw this sprite's appearance.
 TGT_ConnectionPoint getEndpoint(int which)
          Returns one of the endpoints for this TGT_ConnectionPoint.
 boolean isHorizontal()
          Is this connector horizontal?
 boolean isVertical()
          Is this connector vertical?
 void setEndpoint(TGT_ConnectionPoint ep, int which)
          Change one of the endpoints of this connector.
 
Methods inherited from class TGT.TGT_DrawableSprite
colorDecoder, getHeight, getPrimaryColor, getSecondaryColor, getWidth, setColors, setHeight, setPrimaryColor, setSecondaryColor, setSize, setWidth
 
Methods inherited from class TGT.TGT_Sprite
getLocation, getName, getPriority, getRate, getVisible, setLocation, setName, setPriority, setRate, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

endpoint

protected TGT_ConnectionPoint[] endpoint
Constructor Detail

TGT_BasicConnectorSprite

public TGT_BasicConnectorSprite()

TGT_BasicConnectorSprite

public TGT_BasicConnectorSprite(java.lang.String nm,
                                java.util.StringTokenizer st)

TGT_BasicConnectorSprite

public TGT_BasicConnectorSprite(java.lang.String nm,
                                int pri,
                                int rt,
                                boolean vis,
                                int x,
                                int y,
                                int wide,
                                java.awt.Color first,
                                java.awt.Color second,
                                int ep1x,
                                int ep1y,
                                int ep2x,
                                int ep2y)
Creates a BasicConnectorSprite with specific parameters

Parameters:
nm - The name of this sprite.
pri - Drawing priority of this sprite. Higher numbers are painted on top of lower.
rt - Animation speed for this sprite.
vis - Initial visibility of this sprite.
x - x-coordinate of the position of this sprite.
y - y-coordinate of the position of this sprite.
wide - an int specifying the desired width of the sprite
first - a Color specifying the primary color of the sprite
second - a Color specifying the secondary color of the sprite
ep1x - x-coordinate for first endpoint
ep1y - y-coordinate for first endpoint
ep2x - x-coordinate for second endpoint
ep2y - y-coordinate for second endpoint
Method Detail

getEndpoint

public TGT_ConnectionPoint getEndpoint(int which)
                                throws java.util.NoSuchElementException
Returns one of the endpoints for this TGT_ConnectionPoint.

Parameters:
which - 0 or 1, for the "left" or "right" endpoint.
Returns:
the TGT_ConnectionPoint representing the requested endpoint of this connector.
Throws:
java.util.NoSuchElementException - when "which" is a value other than 0 or 1.

setEndpoint

public void setEndpoint(TGT_ConnectionPoint ep,
                        int which)
                 throws java.util.NoSuchElementException
Change one of the endpoints of this connector.

Parameters:
ep - the new endpoint
which - 0 for the "left" endpoint, 1 for the "right" endpoint.
Throws:
java.util.NoSuchElementException - when "which" is a value other than 0 or 1.

draw

public void draw(java.awt.Graphics g,
                 java.awt.image.ImageObserver o)
Description copied from class: TGT_DrawableSprite
Draw this sprite's appearance. This method is implemented by each derived class.

Specified by:
draw in interface TGT_AbstractSprite
Specified by:
draw in class TGT_DrawableSprite
Parameters:
g - The Graphics object to use for drawing.
o - The ImageObserver that this sprite belongs to.

isHorizontal

public boolean isHorizontal()
Is this connector horizontal?

Returns:
true if the connector is exactly horizontal, false otherwise.

isVertical

public boolean isVertical()
Is this connector vertical?

Returns:
true if the connector is exactly vertical, false otherwise.

computeDecoratorOrientation

protected int computeDecoratorOrientation(int endptidx)