simtools.shapes
Class AbstractShape

java.lang.Object
  extended by simtools.shapes.AbstractShape
All Implemented Interfaces:
java.awt.Shape, java.io.Serializable, java.lang.Cloneable, NamedProperties
Direct Known Subclasses:
Abstract1DShape, AutomatonShape, AxisShape, BasicShape, ChartShape, CompoundShape, HistoryTextShape, LabelShape, PlotShape, TestSVGShape, TextArrayShape, View3DShape

public abstract class AbstractShape
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable, java.awt.Shape, NamedProperties

This base class is used for shapes with a specific bounds computation based on anchor definition. The derived classes can be serialized.

Version:
1.0 2001
Author:
Claude Cazenave
See Also:
Serialized Form

Nested Class Summary
static class AbstractShape.AbstractShapePropertiesNames
          A delegate class that provides the list of properties names related to its mother class
 
Field Summary
protected  int _h
           
protected  int _ox
          anchor location on x
protected  int _oy
          anchor location on y
protected  java.lang.String[] _propertyNames
          The list of properties managed by this panel
protected  int _w
           
protected  int _x
           
protected  int _y
           
static boolean ANTI_ALIASING
          Use anti aliasing
static AbstractShapePropertiesDialogBox currentDialogBox
          Only one shape properties dialog box can be displayed at once When user opens a dialog box properties while another one is still displayed: this last dislaog box is closed
static java.lang.String[] FONT_NAMES
          Available font list
protected  ListenerManager listeners
           
static int REFRESH_PERIOD
          Refresh at no more than 100 ms
 
Constructor Summary
AbstractShape()
          Initializes this abstract shape, anchored at 0,0
AbstractShape(int ox, int oy)
          Initializes this abstract shape
 
Method Summary
 void addListener(ShapeListener sl)
           
protected  AbstractShape cloneShape()
          Performs a copy of the shape This method has to be overriden to deal with concrete shapes
 boolean contains(double x, double y)
           
 boolean contains(double x, double y, double w, double h)
           
 boolean contains(java.awt.geom.Point2D p)
           
 boolean contains(java.awt.geom.Rectangle2D r)
           
abstract  void draw(java.awt.Graphics2D g)
          Draws the shape
 java.awt.Point getAnchor()
          Gets shape anchor
 java.awt.Rectangle getBounds()
           
 java.awt.geom.Rectangle2D getBounds2D()
           
 java.util.Collection getInnerProperties()
          Get the properties of inner objects or null if none
 void getMax(java.awt.Point p)
          Compare shape right/down coordinates with a point If the shape coordiantes are lowered then replace the point coordinates with the maximum value of the coordinates
 void getMaxTranslated(java.awt.Point p, int dx, int dy)
          Compares shape right/down coordinates with a transalted point If the shape coordiantes are lowered then replace the point coordinates with the maximum value of the coordinates
 void getMin(java.awt.Point p)
          Compares shape left/top origin with a point If the shape origin is lowered then replace the point coordinates with the minimum corrdinates
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at)
           
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at, double flatness)
           
 java.lang.String[] getPropertyNames()
          Get the list of property names
 java.lang.Object getPropertyValue(java.lang.String name)
          Get the value of the property named name
 boolean intersects(double x, double y, double w, double h)
           
 boolean intersects(java.awt.geom.Rectangle2D r)
           
protected  void notifyChange()
          Notify listeners that this shape has changed.
protected  void notifyChange(java.awt.Rectangle changedArea)
           
 void refresh()
          Reload all shape properties.
 void removeListener(ShapeListener sl)
           
 void setAnchor(int ox, int oy)
           
 void setAnchor(java.awt.Point p)
          Sets shape anchor
 boolean setProperties(NamedProperties properties, javax.swing.undo.CompoundEdit ce)
           
 void setPropertyValue(java.lang.String name, java.lang.Object value)
          Assigns value to the property named name
 void translate(int dx, int dy)
          Translates the shape
 void wipeOff()
          Wipe-off all all buffered resources in order to refresh shape.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_x

protected int _x

_y

protected int _y

_w

protected int _w

_h

protected int _h

_ox

protected int _ox
anchor location on x


_oy

protected int _oy
anchor location on y


_propertyNames

protected transient java.lang.String[] _propertyNames
The list of properties managed by this panel


listeners

protected transient ListenerManager listeners

REFRESH_PERIOD

public static int REFRESH_PERIOD
Refresh at no more than 100 ms


ANTI_ALIASING

public static boolean ANTI_ALIASING
Use anti aliasing


FONT_NAMES

public static java.lang.String[] FONT_NAMES
Available font list


currentDialogBox

public static transient AbstractShapePropertiesDialogBox currentDialogBox
Only one shape properties dialog box can be displayed at once When user opens a dialog box properties while another one is still displayed: this last dislaog box is closed

Constructor Detail

AbstractShape

public AbstractShape()
Initializes this abstract shape, anchored at 0,0


AbstractShape

public AbstractShape(int ox,
                     int oy)
Initializes this abstract shape

Parameters:
ox - the anchor x position
oy - the anchor y position
Method Detail

cloneShape

protected AbstractShape cloneShape()
Performs a copy of the shape This method has to be overriden to deal with concrete shapes

Returns:
a copy of the shape

getMin

public void getMin(java.awt.Point p)
Compares shape left/top origin with a point If the shape origin is lowered then replace the point coordinates with the minimum corrdinates

Parameters:
p - the point
pa - the anchor origin

getAnchor

public java.awt.Point getAnchor()
Gets shape anchor

Returns:
the origin

setAnchor

public void setAnchor(java.awt.Point p)
Sets shape anchor

Parameters:
p - the origin

setAnchor

public void setAnchor(int ox,
                      int oy)

getMax

public void getMax(java.awt.Point p)
Compare shape right/down coordinates with a point If the shape coordiantes are lowered then replace the point coordinates with the maximum value of the coordinates

Parameters:
p - the point

getMaxTranslated

public void getMaxTranslated(java.awt.Point p,
                             int dx,
                             int dy)
Compares shape right/down coordinates with a transalted point If the shape coordiantes are lowered then replace the point coordinates with the maximum value of the coordinates

Parameters:
p - the point
pa - the anchor origin
dx - translation along X axis
dy - translation along Y axis

translate

public void translate(int dx,
                      int dy)
Translates the shape


draw

public abstract void draw(java.awt.Graphics2D g)
Draws the shape

Parameters:
g - the graphics context

contains

public boolean contains(double x,
                        double y)
Specified by:
contains in interface java.awt.Shape

contains

public boolean contains(double x,
                        double y,
                        double w,
                        double h)
Specified by:
contains in interface java.awt.Shape

contains

public boolean contains(java.awt.geom.Point2D p)
Specified by:
contains in interface java.awt.Shape

contains

public boolean contains(java.awt.geom.Rectangle2D r)
Specified by:
contains in interface java.awt.Shape

intersects

public boolean intersects(double x,
                          double y,
                          double w,
                          double h)
Specified by:
intersects in interface java.awt.Shape

intersects

public boolean intersects(java.awt.geom.Rectangle2D r)
Specified by:
intersects in interface java.awt.Shape

getBounds

public java.awt.Rectangle getBounds()
Specified by:
getBounds in interface java.awt.Shape

getBounds2D

public java.awt.geom.Rectangle2D getBounds2D()
Specified by:
getBounds2D in interface java.awt.Shape

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at)
Specified by:
getPathIterator in interface java.awt.Shape

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at,
                                                  double flatness)
Specified by:
getPathIterator in interface java.awt.Shape

addListener

public void addListener(ShapeListener sl)

removeListener

public void removeListener(ShapeListener sl)

notifyChange

protected void notifyChange()
Notify listeners that this shape has changed. This is called by the various subclasses when necessary. For example, when connected to dynamic data sources.


notifyChange

protected void notifyChange(java.awt.Rectangle changedArea)

setPropertyValue

public void setPropertyValue(java.lang.String name,
                             java.lang.Object value)
Assigns value to the property named name

Specified by:
setPropertyValue in interface NamedProperties
Parameters:
name -
value -
See Also:
setPropertyValue(String, Object)

getPropertyValue

public java.lang.Object getPropertyValue(java.lang.String name)
Get the value of the property named name

Specified by:
getPropertyValue in interface NamedProperties
Parameters:
name -
Returns:
the property value
See Also:
getPropertyValue(String)

getInnerProperties

public java.util.Collection getInnerProperties()
Description copied from interface: NamedProperties
Get the properties of inner objects or null if none

Specified by:
getInnerProperties in interface NamedProperties
Returns:
the collection of NamedProperties or null

getPropertyNames

public java.lang.String[] getPropertyNames()
Description copied from interface: NamedProperties
Get the list of property names

Specified by:
getPropertyNames in interface NamedProperties

setProperties

public boolean setProperties(NamedProperties properties,
                             javax.swing.undo.CompoundEdit ce)

wipeOff

public void wipeOff()
Wipe-off all all buffered resources in order to refresh shape. This is overloaded by the various subclasses when necessary. For example, a image shape shall wipe-off all its buffered images


refresh

public void refresh()
Reload all shape properties.