Synergy Home Page

au.edu.swin.synergy.plugin.diagram
Class BDrawable

java.lang.Object
  |
  +--au.edu.swin.synergy.plugin.diagram.BDrawable
Direct Known Subclasses:
BLine, BModelElement, BPackageArc, BPackageNode, BPackageTerminator, BPolygon, BProperty, BRectShape

public abstract class BDrawable
extends Object
implements Icon, BSaveable, Serializable

See Also:
Serialized Form

Field Summary
protected  BScalarRect bounds
           
protected  BScalar iconOOZ
           
static int kBackward
           
protected static String kDefaultName
           
protected static String kDefaultStatus
           
static int kEmptyFlag
           
static int kForward
           
static int kHighlightFlag
           
static int kHitBounds
           
static int kHitSizer
           
protected static String kKeyName
           
protected static String kKeyStatus
           
static int kNotHit
           
static int kSelectedFlag
           
protected static int kSizerCtrlPoint1
           
protected static int kSizerCtrlPoint2
           
protected static int kSizerEndArc
           
protected static int kSizerHalfH
           
protected static int kSizerHalfW
           
protected static int kSizerNorthEast
           
protected static int kSizerNorthWest
           
protected static int kSizerSouthEast
           
protected static int kSizerSouthWest
           
protected static int kSizerStartArc
           
protected  int lastFrame
           
protected  String name
           
protected  int paintCount
           
protected  BScalarPoint pos
           
protected  Color sizerColour
           
protected  int statusFlag
           
protected  BScalarRect tmpBounds
           
 
Constructor Summary
protected BDrawable()
           
 
Method Summary
 int checkSizerHit(Point pt)
          Checks to see if a sizer has been hit by a point Works on xformed values.
 int checkXFormBounds(Point pt)
          Checks to see if a point has hit the transformed bounds of this object
 int checkXFormHit(Point pt)
          Checks to see if a point has hit the transformed values of this object
 boolean contains(BScalarPoint pt)
          Tests to see if a point is contained within the bounds of this drawable object The bounds are assumed to be in model space.
 void continueAdd(BScalarPoint pt)
          continue adding this drawable...
 void copy(BDrawable src)
          copies the data from the src BDrawable into this one.
 void delete()
          called before the drawable is about to be deleted so that it has time to clean itself up if need be.
 void doPasted(BDiagram diagram)
          Called when a drawable is pasted onto a diagram.
 void dragAdd(BScalarPoint deltaXY)
          Called as the drawable is being added
 void dragMove(BScalarPoint deltaXY)
          Called as the drawable is being moved
 void dragResize(BScalarPoint deltaXY)
          Called as the drawable is being resized
 BasicStroke getBasicStroke()
          gets the basic stroke of the drawable.
 BScalarRect getBounds()
           
 Color getColour()
          gets the outline colour of this drawable.
 int getIconHeight()
          gets the local height of the drawable
 int getIconWidth()
          gets the local width of the drawable
 String getName()
          Returns the name of this drawable object
 BScalarPoint getPos()
           
 BPropPanel getPropertyPanel()
          Returns the associated property panel with this drawable.
 void incPos(BScalarPoint deltaXY)
          increments the position of the object.
 boolean intersects(BScalarRect bounds)
          Tests to see if the bounds of this drawable object intersect with a given rectangle.
 String isDeletable()
           
 boolean isHighlighted()
           
 boolean isInside(BScalarRect bounds)
           
 boolean isSelected()
           
 boolean isStatusFlag(int flag)
           
 boolean isTransformed(int frameCounter)
           
 boolean load(BDataFile file)
          Loads the BDrawable from a file
abstract  BDrawable newInstance()
          Creates and returns a new instance of the BDrawable object
 void paintIcon(Component c, Graphics g, int x, int y)
           
abstract  void render(Graphics2D g2)
          Renders the transformed coordinates of the drawable object to a Graphics2D
 boolean save(BDataFile file)
          Saves the BDrawable to a file
 void setFlag(int flag, boolean on)
          sets a flag on or off
 void setHighlighted(boolean on)
           
 void setName(String name)
           
 void setPos(BScalarPoint pos)
          Sets the position of the object.
 void setPos(Point pos)
          Sets the position of the object.
 void setSelected(boolean on)
           
 void snapToGrid(int spacing)
          Snaps the position of a drawable to the grid.
 void startAdd()
          called when the drawable is about to be added..
 void startMove()
          called when the drawable is about to be moved..
 void startResize(int sizerNum)
          called when the drawable is about to be resized..
 void stopAdd()
          called when the drawable has finished being added..
 void stopMove()
          called when the drawable has finished being moved..
 void stopResize()
          Called as the drawable is stopped being resized
 String toString()
          toString - currently just prints the name of the object.
abstract  void transform(BView viewport, BScalarPoint parentPos, int frameCounter)
          Transforms the coordinates of the drawable object to a new coordinate space, as defined by the viewport and parent pos.
abstract  void updateBounds()
          updates the bounding region of the drawable Called when something requires the bounds of the drawable to be updated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

kEmptyFlag

public static final int kEmptyFlag

kHighlightFlag

public static final int kHighlightFlag

kSelectedFlag

public static final int kSelectedFlag

kNotHit

public static final int kNotHit

kHitBounds

public static final int kHitBounds

kHitSizer

public static final int kHitSizer

sizerColour

protected Color sizerColour

kSizerHalfW

protected static final int kSizerHalfW

kSizerHalfH

protected static final int kSizerHalfH

kSizerNorthWest

protected static final int kSizerNorthWest

kSizerNorthEast

protected static final int kSizerNorthEast

kSizerSouthEast

protected static final int kSizerSouthEast

kSizerSouthWest

protected static final int kSizerSouthWest

kSizerStartArc

protected static final int kSizerStartArc

kSizerEndArc

protected static final int kSizerEndArc

kSizerCtrlPoint1

protected static final int kSizerCtrlPoint1

kSizerCtrlPoint2

protected static final int kSizerCtrlPoint2

kForward

public static final int kForward

kBackward

public static final int kBackward

paintCount

protected int paintCount

kKeyName

protected static final String kKeyName

kDefaultName

protected static final String kDefaultName

kKeyStatus

protected static final String kKeyStatus

kDefaultStatus

protected static final String kDefaultStatus

pos

protected BScalarPoint pos

name

protected String name

bounds

protected BScalarRect bounds

tmpBounds

protected BScalarRect tmpBounds

statusFlag

protected int statusFlag

lastFrame

protected int lastFrame

iconOOZ

protected BScalar iconOOZ
Constructor Detail

BDrawable

protected BDrawable()
Method Detail

isTransformed

public final boolean isTransformed(int frameCounter)

isDeletable

public String isDeletable()
Returns:
true if this drawable is able to be deleted at this point in time

delete

public void delete()
called before the drawable is about to be deleted so that it has time to clean itself up if need be.

transform

public abstract void transform(BView viewport,
                               BScalarPoint parentPos,
                               int frameCounter)
Transforms the coordinates of the drawable object to a new coordinate space, as defined by the viewport and parent pos. Subclasses should follow the following equation for tranforming relevant points etc. Subclasses should also update the lastFrame variable, to the frame counter that is passed in. xformPt.x = ((localPt.x + parentPos.x + pos.x - viewport.x) * viewport.zoom ) + viewport.halfx;
Parameters:
BView - viewport - the viewport that this object is going to be drawn in
Point - parentPos - coordinates of any parent object

render

public abstract void render(Graphics2D g2)
Renders the transformed coordinates of the drawable object to a Graphics2D
Parameters:
Graphics2D - g2 - the place to render the object to.

getPropertyPanel

public BPropPanel getPropertyPanel()
Returns the associated property panel with this drawable. Panel will allow user to change specific attributes of this instance, if implemented.

newInstance

public abstract BDrawable newInstance()
Creates and returns a new instance of the BDrawable object
Returns:
a new instance of this BDrawable object.

load

public boolean load(BDataFile file)
Loads the BDrawable from a file
Specified by:
load in interface BSaveable
Parameters:
BDataFile - file - the file to load from
Returns:
boolean - true on success, false on failure.

save

public boolean save(BDataFile file)
Saves the BDrawable to a file
Specified by:
save in interface BSaveable
Parameters:
BDataFile - file - the file to save to
Returns:
boolean - true on success, false on failure.

updateBounds

public abstract void updateBounds()
updates the bounding region of the drawable Called when something requires the bounds of the drawable to be updated. Subclasses should determine a suitable way to update themselves.

intersects

public boolean intersects(BScalarRect bounds)
Tests to see if the bounds of this drawable object intersect with a given rectangle. The bounds are assumed to be in model space.
Parameters:
Rectangle - bounds - the bounds to test against
Returns:
boolean - true if it does intersect, false otherwise

isInside

public boolean isInside(BScalarRect bounds)

contains

public boolean contains(BScalarPoint pt)
Tests to see if a point is contained within the bounds of this drawable object The bounds are assumed to be in model space.
Parameters:
int - x - the x coordinate of the point
int - y - the y coordinate of the point
Returns:
boolean - true if it does intersect, false otherwise

checkXFormHit

public int checkXFormHit(Point pt)
Checks to see if a point has hit the transformed values of this object
Parameters:
Point - pt - the point to check the hit against..
Returns:
kNotHit - not hit

checkXFormBounds

public int checkXFormBounds(Point pt)
Checks to see if a point has hit the transformed bounds of this object
Parameters:
Point - pt - the point to check the hit against..
Returns:
kNotHit - not hit

checkSizerHit

public int checkSizerHit(Point pt)
Checks to see if a sizer has been hit by a point Works on xformed values. Subclasses should determine appropriate places for the sizer..
Parameters:
Point - pt - the point to check the hit against
Returns:
kNotHit - not hit

startResize

public void startResize(int sizerNum)
called when the drawable is about to be resized..
Parameters:
int - sizerNum - a sizerNum returned from checkSizerHit

dragResize

public void dragResize(BScalarPoint deltaXY)
Called as the drawable is being resized

stopResize

public void stopResize()
Called as the drawable is stopped being resized

startMove

public void startMove()
called when the drawable is about to be moved..

dragMove

public void dragMove(BScalarPoint deltaXY)
Called as the drawable is being moved

stopMove

public void stopMove()
called when the drawable has finished being moved..

startAdd

public void startAdd()
called when the drawable is about to be added..

dragAdd

public void dragAdd(BScalarPoint deltaXY)
Called as the drawable is being added

stopAdd

public void stopAdd()
called when the drawable has finished being added..

continueAdd

public void continueAdd(BScalarPoint pt)
continue adding this drawable...

paintIcon

public void paintIcon(Component c,
                      Graphics g,
                      int x,
                      int y)
Specified by:
paintIcon in interface Icon

getBounds

public BScalarRect getBounds()

getIconWidth

public int getIconWidth()
gets the local width of the drawable
Specified by:
getIconWidth in interface Icon

getIconHeight

public int getIconHeight()
gets the local height of the drawable
Specified by:
getIconHeight in interface Icon

setHighlighted

public void setHighlighted(boolean on)

setSelected

public void setSelected(boolean on)

setFlag

public void setFlag(int flag,
                    boolean on)
sets a flag on or off

isStatusFlag

public boolean isStatusFlag(int flag)

isHighlighted

public boolean isHighlighted()

isSelected

public boolean isSelected()

getColour

public Color getColour()
gets the outline colour of this drawable.

getBasicStroke

public BasicStroke getBasicStroke()
gets the basic stroke of the drawable.

setPos

public void setPos(BScalarPoint pos)
Sets the position of the object.

setPos

public void setPos(Point pos)
Sets the position of the object.

snapToGrid

public void snapToGrid(int spacing)
Snaps the position of a drawable to the grid.
Parameters:
int - spacing - the spacing of the grid

incPos

public void incPos(BScalarPoint deltaXY)
increments the position of the object.

getPos

public BScalarPoint getPos()

toString

public String toString()
toString - currently just prints the name of the object.
Overrides:
toString in class Object

copy

public void copy(BDrawable src)
copies the data from the src BDrawable into this one.
Parameters:
BDrawable - src - the source BDrawable..

getName

public String getName()
Returns the name of this drawable object
Returns:
String - the name of the object..

setName

public void setName(String name)

doPasted

public void doPasted(BDiagram diagram)
Called when a drawable is pasted onto a diagram. When things like model elements are pasted they need to change their package

Synergy Home Page