sm
Class SMShape

java.lang.Object
  extended bysm.SMShape
All Implemented Interfaces:
java.lang.Cloneable, InteractiveObject
Direct Known Subclasses:
SMImage, SMPolyLine, SMRectangularShape, SMText, SMWidget

public class SMShape
extends java.lang.Object
implements java.lang.Cloneable, InteractiveObject

A shape to be added to an SMCanvas. The shape is defined by a geometry and some grahical attributes, and it can have tags. A shape can be marked as drawable or not, and pickable or not. When a shape is not drawable, it is not displayed by the enclosing canvas. When a shape is not pickable, it is ignored by the enclosing canvas for pick operations.

The geometry of a shape is defined by an arbitrary Java2D Shape. Subclasses of SMShape define specific geometries, namely rectangle, ellipse, polyline, text, and image. The geometry of a shape is transformed by an affine transformation that combines a scale, a rotation and a translation. The default transformation is the identity. The rotation, scale and translateTo operations occur around the shape's reference point, which by default is at the center of the shape's bounding box. The reference point can be changed. It is defined relatively to the shape's bounding box, i.e (0, 0) means the top left corner of the shape, (1,1) the bottom right corner, (0.5, 0.5) the center, etc.

By default, the geometry of the shape is relative to the enclosing canvas's coordinate system. However a shape can have a parent, which is another shape in the canvas. In this case the shape's coordinates are relative to the transformation of its parent. This means that changing the transform of the parent shape will affect its children. A shape can be the parent of an arbitrary number of shapes, and can itself have a parent.

The last element that affects the shape's geometry is the clipping shape. A shape can be clipped by another shape of the canvas. The clipped shape is only visible within the interior of the clipping shape.

The graphical attributes of a shape consists of a fill paint, an outline paint and a stroke style. The fill paint is used if the shape is filled to paint the interior of the shape. The outline paint and stroke style are used if the shape is outlined to paint the border of the shape. Paints and stroke styles can be any Java2D objects that implement the Paint and Stroke interfaces respectively. Graphical attributes affect picking. For example, if a shape is not filled, only the border stroke is taken into account for picking.

Tags can be attached to a shape. See SMTag for details. It is important to remember that tags cannot be added to a shape until the shape is added to a canvas. This is because each canvas manages its own set of tags.

Author:
Caroline Appert
See Also:
SMCanvas, SMTag

Field Summary
static int cptId
           
 
Constructor Summary
SMShape()
           
SMShape(java.awt.Shape s)
          Builds an SMShape from a Java2D shape.
SMShape(java.awt.Shape s, java.awt.Paint p)
          Builds an SMShape from a Java2D shape and a fill paint.
SMShape(java.awt.Shape s, java.awt.Paint p, java.awt.Paint o)
          Builds an SMShape from a Java2D shape, a fill paint and an outline paint.
SMShape(java.awt.Shape s, java.awt.Paint p, java.awt.Paint o, java.awt.Stroke str)
          Builds an SMShape from a Java2D shape, a fill paint, an outline paint and a stroke style.
SMShape(java.awt.Shape s, java.awt.Paint p, java.awt.Stroke str)
          Builds an SMShape from a Java2D shape, a fill paint and a stroke style.
SMShape(java.awt.Shape s, java.awt.Stroke str)
          Builds an SMShape from a Java2D shape and a stroke style.
 
Method Summary
 SMShape above(SMShape before)
          Moves this shape in the canvas's display list so that it is right above a given shape in the display list.
 SMShape aboveAll()
          Moves this shape in the canvas's display list so that it is above all other shapes.
 SMShape addChild(SMShape c)
          Adds a child to this shape.
 SMShape addGhost()
          Builds the 'ghost' of this shape.
 SMShape addTag(SMExtensionalTag t)
          Adds a tag to this shape.
 SMShape addTag(SMTag t)
          Adds a tag to this shape only if the tag is a SMVolatileTag, does anything otherwise.
 SMShape addTag(java.lang.String t)
          Adds a SMNamedTag tag to this shape.
 SMShape addTo(SMCanvas c)
          Adds this shape to a canvas.
 SMEllipse asEllipse()
          Returns this shape if it is an ellipse, null otherwise
 SMImage asImage()
          Returns this shape if it is an image, null otherwise
 SMPolyLine asPolyLine()
          Returns this shape if it is a polyline, null otherwise
 SMRectangle asRectangle()
          Returns this shape if it is a rectangle, null otherwise
 SMRectangularShape asRectangularShape()
          Returns this shape if it is a rectangularShape, null otherwise
 SMText asText()
          Returns this shape if it is a text, null otherwise
 void attachSM(StateMachine sm, boolean reset)
          Attaches a state machine to this interactive object to describe its behavior.
 SMShape below(SMShape after)
          Moves this shape in the canvas's display list so that it is right below a given shape in the display list.
 SMShape belowAll()
          Moves this shape in the canvas's display list so that it is below all other shapes.
 java.awt.geom.Point2D canvasToShape(java.awt.geom.Point2D p)
          Converts a point relative to the canvas into a point relative to the shape
 java.lang.Object clone()
           
 boolean contains(double x, double y)
          Tests whether a point (x, y) is inside this shape.
 boolean contains(double x, double y, double w, double h)
          Tests whether a rectangle R is inside this shape.
 boolean contains(java.awt.geom.Point2D p)
          Tests whether a point p is inside this shape.
 boolean contains(java.awt.geom.Rectangle2D r)
          Tests whether a rectangle R is inside this shape.
 boolean containsPoint(double x, double y)
          Tests if a point is in this interactive object.
 boolean containsPoint(java.awt.geom.Point2D point)
          Tests if a point is in this interactive object.
 SMShape copyTo(SMShape sms)
          Copies this shape into a destination shape.
 void detachSM(StateMachine sm)
          Detaches a state machine from this interactive object.
 SMShape duplicate()
          Creates a new copy of this shape and returns it.
 boolean equals(java.lang.Object o)
           
 java.awt.Shape getAbsShape()
          Returns the shape in the absolute coordinate system of the canvas
 java.awt.geom.AffineTransform getAbsTransform()
          Returns the absolute affine transformation that is applied to the shape.
 SMRectangle getBoundingBox()
           
 SMCanvas getCanvas()
          Return the canvas this shape belongs to, if any.
 double getCenterX()
           
 double getCenterY()
           
 java.util.LinkedList getChildren()
          Returns the children of this shape as a linked list.
 SMShape getClip()
          Returns the shape that clips this shape, if any.
 java.awt.Paint getFillPaint()
          Returns the fill Paint, which is used to display the interior of the shape when it is filled.
 double getHeight()
           
 SMHierarchy getHierarchy()
          Returns the hierarchy of this shape.
 int getID()
           
 double getMaxX()
           
 double getMaxY()
           
 double getMinX()
           
 double getMinY()
           
 java.awt.Paint getOutlinePaint()
          Returns the outline Paint, which is used to display the boundary of the shape when it is outlined.
 SMShape getParent()
          Returns the parent of this shape, if any.
 double getReferenceX()
          Returns the x coordinate of this shape's reference point.
 double getReferenceY()
          Returns the y coordinate of this shape's reference point.
 double getRotation()
          Returns this shape's rotation angle
 double getScaleX()
          Returns the x scale value.
 double getScaleY()
          Returns the y scale value.
 java.awt.Shape getShape()
          Returns the shape.
 java.awt.Stroke getStroke()
          Returns the stroke style, which specifies the shape of the boundary of the shape when it is outlined (thickness, dash pattern, etc.).
 java.awt.geom.AffineTransform getTransform()
          Returns the affine transformation that is applied to the shape.
 double getTranslateX()
          Returns the x coordinate of this shape.
 double getTranslateY()
          Returns the y coordinate of this shape.
 float getTransparency()
          Returns the transparency, which applies to the whole shape (boundary and interior).
 double getWidth()
           
 boolean hasTag(SMTag t)
          Tests whether this shape has a given tag.
 boolean hasTag(java.lang.String t)
          Tests whether this shape has a given SMNamedTag tag.
 boolean intersects(double x, double y, double w, double h)
          Tests whether a rectangle R intersects this shape.
 boolean intersects(java.awt.geom.Rectangle2D r)
          Tests whether a rectangle r intersects this shape.
 boolean isAbove(SMShape before)
          Tests if this shape is above another shape in the display list.
 boolean isAntialiased()
          Returns true if this shape is antialiased.
 boolean isBelow(SMShape after)
          Tests if this shape is before another shape in the display list.
 boolean isDrawable()
          Returns true if this shape is to be displayed.
 boolean isEmpty()
          Determines whether or not the bounding box of this shape is empty.
 boolean isFilled()
          Returns true if this shape is filled.
 boolean isOnOutline(java.awt.geom.Point2D p)
          Tests whether a point p is on this shape's outline.
 boolean isOutlined()
          Returns true if this shape is outlined.
 boolean isPickable()
          Returns true if the shape can be picked.
 void paint(java.awt.Graphics g)
          Paints the shape.
 SMShape remove()
          Removes this shape from its canvas.
 SMShape removeChild(SMShape s)
          Removes a child from this shape.
 void removeGhost()
          Removes the 'ghost' of this shape from the canvas.
 SMShape removeTag(SMTag t)
          Removes a tag from this shape only if the tag is a SMVolatileTag.
 SMShape removeTag(java.lang.String t)
          Removes a tag from this shape.
 SMShape rotateBy(double dt)
          Rotates this shape by dt
 SMShape rotateTo(double t)
          Rotates this shape to angle t
 SMShape scaleBy(double ds)
          Scales this shape by s horizontally and vertically.
 SMShape scaleBy(double x, double y)
          Scales this shape by x horizontally and y vertically.
 SMShape scaleTo(double s)
          Sets this shape's scale to s horizontally and vertically.
 SMShape scaleTo(double x, double y)
          Sets the scale of this shape to x horizontally and y vertically.
 SMShape setAntialiased(boolean a)
          Specifies whether this shape is antialiased.
 SMShape setClip(SMShape clip)
          Sets the clipping shape of this shape.
 SMShape setDrawable(boolean d)
          Specifies whether this shape is to be displayed.
 SMShape setFilled(boolean isFilled)
          Sets the filled property of this shape.
 SMShape setFillPaint(java.awt.Paint fp)
          Sets the fill Paint, which is used to display the interior of the shape when it is filled.
 SMShape setOutlined(boolean o)
          Sets the outlined property of this shape.
 SMShape setOutlinePaint(java.awt.Paint op)
          Sets the outline Paint, which is used to display the boundary of the shape when it is outlined.
 SMShape setParent(SMShape p)
          Sets the parent of this shape (only if the parent and this ahape are in the same canvas).
 SMShape setPickable(boolean pick)
          Specifies whether this shape can be picked.
 SMShape setReferencePoint(double x, double y)
          Set this shape's reference point.
 SMShape setShape(java.awt.Shape s)
          Sets the shape.
 SMShape setStroke(java.awt.Stroke str)
          Sets the stroke style, which specifies the shape of the boundary of the shape when it is outlined (thickness, dash pattern, etc.).
 SMShape setTransparency(float alpha)
          Sets the transparency of this shape, which applies both to the boundary and interior.
 java.awt.geom.Point2D shapeToCanvas(java.awt.geom.Point2D p)
          Converts a point relative to the shape into a point relative to the canvas
 SMShape translateBy(double dx, double dy)
          Translates this shape by dx, dy.
 SMShape translateTo(double x, double y)
          Translates this shape to x, y (the point of reference of this shape will be exactly at (x, y)).
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cptId

public static int cptId
Constructor Detail

SMShape

public SMShape()

SMShape

public SMShape(java.awt.Shape s)
Builds an SMShape from a Java2D shape.

Parameters:
s - The java2D shape

SMShape

public SMShape(java.awt.Shape s,
               java.awt.Stroke str)
Builds an SMShape from a Java2D shape and a stroke style.

Parameters:
s - The java2D shape
str - The stroke style

SMShape

public SMShape(java.awt.Shape s,
               java.awt.Paint p)
Builds an SMShape from a Java2D shape and a fill paint.

Parameters:
s - The java2D shape
p - The fill paint

SMShape

public SMShape(java.awt.Shape s,
               java.awt.Paint p,
               java.awt.Paint o)
Builds an SMShape from a Java2D shape, a fill paint and an outline paint.

Parameters:
s - The java2D shape
p - The fill paint
o - The outline paint

SMShape

public SMShape(java.awt.Shape s,
               java.awt.Paint p,
               java.awt.Paint o,
               java.awt.Stroke str)
Builds an SMShape from a Java2D shape, a fill paint, an outline paint and a stroke style.

Parameters:
s - The java2D shape
p - The fill paint
o - The outline
str - The stroke style

SMShape

public SMShape(java.awt.Shape s,
               java.awt.Paint p,
               java.awt.Stroke str)
Builds an SMShape from a Java2D shape, a fill paint and a stroke style.

Parameters:
s - The java2D shape
p - The fill paint
str - The stroke style
Method Detail

getID

public int getID()

equals

public boolean equals(java.lang.Object o)

getCanvas

public SMCanvas getCanvas()
Return the canvas this shape belongs to, if any.

Specified by:
getCanvas in interface InteractiveObject
Returns:
Returns the canvas.

getShape

public java.awt.Shape getShape()
Returns the shape.

Returns:
Returns the shape.

setShape

public SMShape setShape(java.awt.Shape s)
Sets the shape.

Parameters:
s - The new Java2D shape.
Returns:
Returns this shape.

addTo

public SMShape addTo(SMCanvas c)
Adds this shape to a canvas. Note that a number of operations do nothing until the shape is added to a canvas, e.g. adding tags, setting the parent, adding children, setting a clip.

Parameters:
c - The canvas.
Returns:
Returns this shape.

remove

public SMShape remove()
Removes this shape from its canvas. Note that a number of operations do nothing when the shape is not in a canvas, e.g. adding tags, setting the parent, adding children, setting a clip.

Returns:
Returns this shape.

paint

public void paint(java.awt.Graphics g)
Paints the shape. Normally this method need not be called, since the canvas paints the display list automatically.

Parameters:
g - The graphics with which the shape must be painted.

isDrawable

public boolean isDrawable()
Returns true if this shape is to be displayed.

Returns:
Returns true if this shape is to be displayed, false otherwise.

setDrawable

public SMShape setDrawable(boolean d)
Specifies whether this shape is to be displayed.

Parameters:
d - True if the shape is to be displayed, false otherwise.
Returns:
Returns this shape.

getTransparency

public float getTransparency()
Returns the transparency, which applies to the whole shape (boundary and interior).

Returns:
Returns the transparency.

setTransparency

public SMShape setTransparency(float alpha)
Sets the transparency of this shape, which applies both to the boundary and interior.

Parameters:
alpha - The transparency level (0.0 = transparent, 1.0 = opaque).
Returns:
Returns this shape.

isFilled

public boolean isFilled()
Returns true if this shape is filled. When the shape is filled, the interior of the shape is displayed.

Returns:
Returns true if this shape is filled.

setFilled

public SMShape setFilled(boolean isFilled)
Sets the filled property of this shape. When the shape is filled, the interior of the shape must be displayed.

Parameters:
isFilled - True if the shape is filled.
Returns:
Returns this shape.

getFillPaint

public java.awt.Paint getFillPaint()
Returns the fill Paint, which is used to display the interior of the shape when it is filled.

Returns:
Returns the fill Paint style.

setFillPaint

public SMShape setFillPaint(java.awt.Paint fp)
Sets the fill Paint, which is used to display the interior of the shape when it is filled.

Parameters:
fp - The fill Paint.
Returns:
Returns this shape.

isOutlined

public boolean isOutlined()
Returns true if this shape is outlined. When the shape is outlined, the boundary of the shape must be displayed.

Returns:
Returns true if this shape is outlined.

setOutlined

public SMShape setOutlined(boolean o)
Sets the outlined property of this shape. When the shape is outlined, the boundary of the shape when it is outlined.

Parameters:
o - True if the shape is outlined.
Returns:
Returns this shape.

getStroke

public java.awt.Stroke getStroke()
Returns the stroke style, which specifies the shape of the boundary of the shape when it is outlined (thickness, dash pattern, etc.).

Returns:
Returns the stroke style.

setStroke

public SMShape setStroke(java.awt.Stroke str)
Sets the stroke style, which specifies the shape of the boundary of the shape when it is outlined (thickness, dash pattern, etc.).

Parameters:
str - The stroke style.
Returns:
Returns this shape.

getOutlinePaint

public java.awt.Paint getOutlinePaint()
Returns the outline Paint, which is used to display the boundary of the shape when it is outlined.

Returns:
Returns the outline Paint.

setOutlinePaint

public SMShape setOutlinePaint(java.awt.Paint op)
Sets the outline Paint, which is used to display the boundary of the shape when it is outlined.

Parameters:
op - The outline Paint.
Returns:
Returns this shape.

getClip

public SMShape getClip()
Returns the shape that clips this shape, if any. When a clipping shape is specified, this shape is displayed only within the interior of the clipping shape.

Returns:
Returns the clipping shape, or null if the shape is not clipped.

setClip

public SMShape setClip(SMShape clip)
Sets the clipping shape of this shape. When a clipping shape is specified, this shape is displayed only within the interior of the clipping shape.

Parameters:
clip - The clipping shape, or null to reset clipping of this shape.
Returns:
Returns this shape.

isAntialiased

public boolean isAntialiased()
Returns true if this shape is antialiased. Antialiasing improves the visual quality of the displayed shapes, at the expense of longer display times. Note that the canvas has a global antialiasing mode, which is not tested by this method.

Returns:
Returns true if this shape is antialiased.

setAntialiased

public SMShape setAntialiased(boolean a)
Specifies whether this shape is antialiased. Antialiasing improves the visual quality of the displayed shapes, at the expense of longer display times.

Parameters:
a - True if this shape is to be antialiased.
Returns:
Returns this shape.

getHierarchy

public SMHierarchy getHierarchy()
Returns the hierarchy of this shape.

Returns:
Returns the hierarchy of this shape.

getParent

public SMShape getParent()
Returns the parent of this shape, if any. When a parent is specified, the shapes transformation is relative to the parent's tranformation rather than the canvas. Changing a parent's transformation affects all its children.

Returns:
Returns the parent of this shape, or null if it has no parent.

getChildren

public java.util.LinkedList getChildren()
Returns the children of this shape as a linked list.

Returns:
Returns the children of this shape, or null if it has no parent.

setParent

public SMShape setParent(SMShape p)
Sets the parent of this shape (only if the parent and this ahape are in the same canvas). If this shape has a parent, it is detached from this parent before being attached to the new one.

Parameters:
p - The new parent, or null if the shape is to have no parent.
Returns:
Returns this shape.

addChild

public SMShape addChild(SMShape c)
Adds a child to this shape. This shape becomes the parent of the shape given as parameter.

Parameters:
c - The child shape
Returns:
Returns this shape.

removeChild

public SMShape removeChild(SMShape s)
                    throws ImpossibleOperationOnDifferentCanvasException
Removes a child from this shape. This sets the child's parent to null.

Parameters:
s - The child shape to remove
Returns:
Returns this shape.
Throws:
ImpossibleOperationOnDifferentCanvasException
ImpossibleOperationOnDifferentCanvasException

getTransform

public java.awt.geom.AffineTransform getTransform()
Returns the affine transformation that is applied to the shape. If the shape has a parent, the transformation is relative to the parent transform otherwise it is relative to the canvas's coordinate system.

Returns:
Returns the shape's affine transform.

getAbsTransform

public java.awt.geom.AffineTransform getAbsTransform()
Returns the absolute affine transformation that is applied to the shape. This is the transformation relative to the canvas's coordinate system.

Returns:
Returns the shape's affine transform.

getAbsShape

public java.awt.Shape getAbsShape()
Returns the shape in the absolute coordinate system of the canvas

Returns:
Returns the transformed shape.

getReferenceX

public double getReferenceX()
Returns the x coordinate of this shape's reference point.

Returns:
Returns the x coordinate of this shape's reference point.

getReferenceY

public double getReferenceY()
Returns the y coordinate of this shape's reference point.

Returns:
Returns the y coordinate of this shape's reference point.

setReferencePoint

public SMShape setReferencePoint(double x,
                                 double y)
Set this shape's reference point. The reference point is relative to the shape's bounding box. Hence, (0, 0) is the top-left corner, (1, 1) the bottom right corner, (0.5, 0.5) the center, etc.

Parameters:
x - The x coordinate of the new reference point.
y - The y coordinate of the new reference point.
Returns:
Returns this shape.

translateBy

public SMShape translateBy(double dx,
                           double dy)
Translates this shape by dx, dy.

Parameters:
dx - The x offset
dy - The y offset
Returns:
Returns this shape.

translateTo

public SMShape translateTo(double x,
                           double y)
Translates this shape to x, y (the point of reference of this shape will be exactly at (x, y)).

Parameters:
x - The x coordinate
y - The y coordinate
Returns:
Returns this shape.

getTranslateX

public double getTranslateX()
Returns the x coordinate of this shape.

Returns:
Returns the x coordinate of this shape.

getTranslateY

public double getTranslateY()
Returns the y coordinate of this shape.

Returns:
Returns the y coordinate of this shape.

rotateBy

public SMShape rotateBy(double dt)
Rotates this shape by dt

Parameters:
dt - The angle offset
Returns:
Returns this shape.

rotateTo

public SMShape rotateTo(double t)
Rotates this shape to angle t

Parameters:
t - The angle
Returns:
Returns this shape.

getRotation

public double getRotation()
Returns this shape's rotation angle

Returns:
Returns this shape's rotation angle

scaleBy

public SMShape scaleBy(double x,
                       double y)
Scales this shape by x horizontally and y vertically.

Parameters:
x - The x scale factor
y - The y scale factor
Returns:
Returns this shape.

scaleTo

public SMShape scaleTo(double x,
                       double y)
Sets the scale of this shape to x horizontally and y vertically.

Parameters:
x - The x scale
y - The y scale
Returns:
Returns this shape.

scaleBy

public SMShape scaleBy(double ds)
Scales this shape by s horizontally and vertically.

Parameters:
ds - The scale factor
Returns:
Returns this shape.

scaleTo

public SMShape scaleTo(double s)
Sets this shape's scale to s horizontally and vertically.

Parameters:
s - The scale value
Returns:
Returns this shape.

getScaleX

public double getScaleX()
Returns the x scale value.

Returns:
Returns the x scale value.

getScaleY

public double getScaleY()
Returns the y scale value.

Returns:
Returns the y scale value.

shapeToCanvas

public java.awt.geom.Point2D shapeToCanvas(java.awt.geom.Point2D p)
Converts a point relative to the shape into a point relative to the canvas

Parameters:
p - - The point to be converted
Returns:
Returns the converted point

canvasToShape

public java.awt.geom.Point2D canvasToShape(java.awt.geom.Point2D p)
Converts a point relative to the canvas into a point relative to the shape

Parameters:
p - - The point to be converted
Returns:
Returns the converted point

getBoundingBox

public SMRectangle getBoundingBox()
Returns:
Returns the rectangle that is the bounding box of this shape.

getHeight

public double getHeight()
Returns:
Returns the overall height of the bounding box of this shape in double precision.

getWidth

public double getWidth()
Returns:
Returns the overall width of the bounding box of this shape in double precision.

getMinX

public double getMinX()
Returns:
Returns the X coordinate of the upper left corner of the bounding box of this shape in double precision.

getMinY

public double getMinY()
Returns:
Returns the Y coordinate of the upper left corner of the bounding box of this shape in double precision.

getMaxX

public double getMaxX()
Returns:
Returns the X coordinate of the lower right corner of the bounding box of this shape in double precision.

getMaxY

public double getMaxY()
Returns:
Returns the Y coordinate of the lower right corner of the bounding box of this shape in double precision.

getCenterX

public double getCenterX()
Returns:
Returns the X coordinate of the lower right corner of the bounding box of this shape in double precision.

getCenterY

public double getCenterY()
Returns:
Returns the Y coordinate of the lower right corner of the bounding box of this shape in double precision.

isEmpty

public boolean isEmpty()
Determines whether or not the bounding box of this shape is empty.

Returns:
Returns true if this shape is empty.

isPickable

public boolean isPickable()
Returns true if the shape can be picked. Shapes that are not pickable are ignored by the canvas picking methods (pick, pickAll) and by the state machines.

Returns:
Returns true if the shape can be picked.

setPickable

public SMShape setPickable(boolean pick)
Specifies whether this shape can be picked. Shapes that are not pickable are ignored by the canvas picking methods (pick, pickAll) and by the state machines.

Parameters:
pick - True if this shape can be picked, false otherwise.
Returns:
Returns this shape.

contains

public boolean contains(double x,
                        double y)
Tests whether a point (x, y) is inside this shape.

Parameters:
x - The x coordinate
y - The y coordinate
Returns:
Returns true if the point (x, y) is inside this shape, false otherwise.
See Also:
Shape.contains(double, double)

contains

public boolean contains(java.awt.geom.Point2D p)
Tests whether a point p is inside this shape.

Parameters:
p - The point
Returns:
Returns true if the point p is inside this shape, false otherwise.
See Also:
Shape.contains(Point2D)

contains

public boolean contains(double x,
                        double y,
                        double w,
                        double h)
Tests whether a rectangle R is inside this shape.

Parameters:
x - The x coordinate of the upper left corner of R
y - The y coordinate of the upper left corner of R
w - The width of R
h - The height of R
Returns:
Returns true if the rectangle is inside this shape, false otherwise.
See Also:
Shape.contains(double, double, double, double)

contains

public boolean contains(java.awt.geom.Rectangle2D r)
Tests whether a rectangle R is inside this shape.

Parameters:
r - The rectangle
Returns:
Returns true if the rectangle is inside this shape, false otherwise.
See Also:
Shape.contains(Rectangle2D)

isOnOutline

public boolean isOnOutline(java.awt.geom.Point2D p)
Tests whether a point p is on this shape's outline.

Parameters:
p - The point
Returns:
Returns true if the point p is on this shape's outline, false otherwise.

intersects

public boolean intersects(double x,
                          double y,
                          double w,
                          double h)
Tests whether a rectangle R intersects this shape.

Parameters:
x - The x coordinate of the upper left corner of R
y - The y coordinate of the upper left corner of R
w - The width of R
h - The height of R
Returns:
Returns true if R intersects this shape, false otherwise.

intersects

public boolean intersects(java.awt.geom.Rectangle2D r)
Tests whether a rectangle r intersects this shape.

Parameters:
r - The rectangle
Returns:
Returns true if r intersects this shape, false otherwise.

isAbove

public boolean isAbove(SMShape before)
Tests if this shape is above another shape in the display list.

Parameters:
before - The shape.
Returns:
Returns true if this shape is above the shape before (false if this shape or the the shape before are not attached to a canvas).

above

public SMShape above(SMShape before)
Moves this shape in the canvas's display list so that it is right above a given shape in the display list.

Parameters:
before - The shape that must be right below this shape in the display list
Returns:
Returns this shape.

aboveAll

public SMShape aboveAll()
Moves this shape in the canvas's display list so that it is above all other shapes.

Returns:
Returns this shape.

isBelow

public boolean isBelow(SMShape after)
Tests if this shape is before another shape in the display list.

Parameters:
after - The shape.
Returns:
Returns true if this shape is before the shape after (false if this shape or the the shape after are not attached to a canvas).

below

public SMShape below(SMShape after)
Moves this shape in the canvas's display list so that it is right below a given shape in the display list.

Parameters:
after - The shape that must be right above this shape in the display list
Returns:
Returns this shape.

belowAll

public SMShape belowAll()
Moves this shape in the canvas's display list so that it is below all other shapes.

Returns:
Returns this shape.

addTag

public SMShape addTag(SMTag t)
Adds a tag to this shape only if the tag is a SMVolatileTag, does anything otherwise.

Parameters:
t - The tag to be added
Returns:
Returns this shape.

addTag

public SMShape addTag(SMExtensionalTag t)
Adds a tag to this shape.

Parameters:
t - The tag to be added
Returns:
Returns this shape.

addTag

public SMShape addTag(java.lang.String t)
Adds a SMNamedTag tag to this shape.

Parameters:
t - The name of the tag to be added
Returns:
Returns this shape.

hasTag

public boolean hasTag(SMTag t)
Tests whether this shape has a given tag.

Parameters:
t - The tag to be tested
Returns:
Returns true if t tags this shape.

hasTag

public boolean hasTag(java.lang.String t)
Tests whether this shape has a given SMNamedTag tag.

Parameters:
t - The name of the tag to be tested
Returns:
Returns true if t tags this shape.

removeTag

public SMShape removeTag(SMTag t)
Removes a tag from this shape only if the tag is a SMVolatileTag.

Parameters:
t - The tag to remove
Returns:
Returns this shape.

removeTag

public SMShape removeTag(java.lang.String t)
Removes a tag from this shape.

Parameters:
t - The name of the SMNamedTag tag to remove
Returns:
Returns this shape.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Throws:
java.lang.CloneNotSupportedException

copyTo

public SMShape copyTo(SMShape sms)
Copies this shape into a destination shape. The copy differs from the original as follows: If this shape is in a canvas, the copy is added to that canvas, on top all other objects; The copy has no children, i.e. it is not the parent of any shape, even if the original has.

Parameters:
sms - The destination shape
Returns:
Returns this shape

duplicate

public SMShape duplicate()
Creates a new copy of this shape and returns it.

Returns:
Returns the copy.

asRectangle

public SMRectangle asRectangle()
Returns this shape if it is a rectangle, null otherwise


asEllipse

public SMEllipse asEllipse()
Returns this shape if it is an ellipse, null otherwise


asPolyLine

public SMPolyLine asPolyLine()
Returns this shape if it is a polyline, null otherwise


asRectangularShape

public SMRectangularShape asRectangularShape()
Returns this shape if it is a rectangularShape, null otherwise


asText

public SMText asText()
Returns this shape if it is a text, null otherwise


asImage

public SMImage asImage()
Returns this shape if it is an image, null otherwise


addGhost

public SMShape addGhost()
Builds the 'ghost' of this shape. The 'ghost' of a shape is a copy of the shape with a greater transparency.

Returns:
The 'ghost' of this shape

removeGhost

public void removeGhost()
Removes the 'ghost' of this shape from the canvas.


attachSM

public void attachSM(StateMachine sm,
                     boolean reset)
Description copied from interface: InteractiveObject
Attaches a state machine to this interactive object to describe its behavior.

Specified by:
attachSM in interface InteractiveObject
Parameters:
sm - The State machine that describes the behavior of this interactive object.
reset - True if the machine must be reset, false otherwise.

detachSM

public void detachSM(StateMachine sm)
Description copied from interface: InteractiveObject
Detaches a state machine from this interactive object.

Specified by:
detachSM in interface InteractiveObject
Parameters:
sm - The State machine to detach.

containsPoint

public boolean containsPoint(java.awt.geom.Point2D point)
Description copied from interface: InteractiveObject
Tests if a point is in this interactive object.

Specified by:
containsPoint in interface InteractiveObject
Parameters:
point - The point to test.
Returns:
Returns true if point is in this interactive object, false otherwise.

containsPoint

public boolean containsPoint(double x,
                             double y)
Description copied from interface: InteractiveObject
Tests if a point is in this interactive object.

Specified by:
containsPoint in interface InteractiveObject
Parameters:
x - The x-coordinate of the point to test.
y - The y-coordinate of the point to test.
Returns:
Returns true if (x, y) is in this interactive object, false otherwise.