jsynoptic.builtin
Class Abstract1DShape

java.lang.Object
  extended by simtools.shapes.AbstractShape
      extended by jsynoptic.builtin.Abstract1DShape
All Implemented Interfaces:
java.awt.Shape, java.io.Serializable, java.lang.Cloneable, ContextualActionProvider, Linkable, SelectionContextualActionProvider, AffineTransformData.Listener, DataSourceListener, EndNotificationListener, Resizable, NamedProperties
Direct Known Subclasses:
Abstract2DShape, ConnectionShape, ImageShape, Java3dShape, LinesShape

public abstract class Abstract1DShape
extends AbstractShape
implements Resizable, DataSourceListener, EndNotificationListener, Linkable, AffineTransformData.Listener, SelectionContextualActionProvider

Base class for Lines and the 2D shapes (Polygons and Ellipses)

See Also:
Serialized Form

Nested Class Summary
static class Abstract1DShape.Abstract1DShapePropertiesNames
           
 
Nested classes/interfaces inherited from class simtools.shapes.AbstractShape
AbstractShape.AbstractShapePropertiesNames
 
Field Summary
protected  boolean allowResize
           
protected  java.awt.geom.Rectangle2D.Double bounds2D
           
protected  EndNotificationListener delegateEndNotificationListener
           
protected  boolean dirty
           
protected  boolean dirtyDrawColor
           
protected  java.awt.Rectangle dirtyRectangle
           
protected  java.awt.Color drawColor
           
protected  java.awt.Color drawDynamicColor
           
protected  ColorMapper drawMapper
           
protected  long drawMapperIndex
           
protected  DataSource drawMapperSource
           
protected  boolean fixedRatio
           
protected  java.lang.String link
           
static int MIN_SIZE
           
protected  double ratio
           
static MenuResourceBundle resources
           
protected  java.awt.Stroke stroke
           
protected  StrokeParameters strokeParams
           
protected  AffineTransformData transform
           
 
Fields inherited from class simtools.shapes.AbstractShape
_h, _ox, _oy, _propertyNames, _w, _x, _y, ANTI_ALIASING, currentDialogBox, FONT_NAMES, listeners, REFRESH_PERIOD
 
Fields inherited from interface jsynoptic.base.ContextualActionProvider
EDITOR_CONTEXT, MOUSE_OUT_CONTEXT, MOUSE_OVER_CONTEXT, MOUSE_PRESSED_CONTEXT, SHAPELIST_CONTEXT, SOURCELIST_CONTEXT
 
Constructor Summary
Abstract1DShape(int ox, int oy, int width, int height)
           
 
Method Summary
 boolean canDoAction(double x, double y, java.lang.Object o, java.lang.String action, int context)
          Returns true if, and only if, it is possible to do the action right now
protected  boolean canResize()
          Allow resize: it is possible to forbid shape resizing even the allow resize property has been set to true by user.
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)
           
 JPropertiesPanel createPanel()
           
 JPropertiesPanel createPanel(java.lang.String name)
           
 void DataSourceIndexRangeChanged(DataSource ds, long startIndex, long lastIndex)
          Called when the range of valid index changed
 void DataSourceInfoChanged(DataSource ds, DataInfo newInfo)
          Called when the information about the data source changed
 void DataSourceOrderChanged(DataSource ds, int newOrder)
          If defined, called when the order of the source changed.
 void DataSourceReplaced(DataSource oldData, DataSource newData)
          Called when a data source is replaced by another one
 void DataSourceValueChanged(DataSource ds, long minIndex, long maxIndex)
          Called when at least a value changed in the data source.
 void DataSourceValueRangeChanged(DataSource ds)
          Called when the range of possible values changed, if defined.
 boolean doAction(double x, double y, java.lang.Object o, java.lang.String action, javax.swing.undo.CompoundEdit undoableEdit)
          Do one of the actions previously declared by getAction.
 boolean doCollectiveAction(DiagramSelection sel, double x, double y, java.lang.Object o, java.lang.String action, javax.swing.undo.CompoundEdit undoableEdit)
          Do one of the collective actions previously declared by getCollectiveActions.
 void draw(java.awt.Graphics2D g)
          Draws the shape
protected  void drawHook(java.awt.Graphics2D g, boolean shapeDrawn)
          For subclasses, called before restoring original graphics properties, after the delegate shape is drawn if shapeDrawn is true, or after saving the current context, before the delegate shape is drawn if shapeDrawn is false
 java.lang.String[] getActions(double x, double y, java.lang.Object o, int context)
          Return list of possible actions the contect information may be used, or not.
 java.awt.Rectangle getBounds()
           
 java.awt.geom.Rectangle2D getBounds2D()
           
 java.util.LinkedHashMap getCollectiveActions(DiagramSelection sel, double x, double y, java.lang.Object o, int context)
          Return list of possible collective actions
 EndNotificationListener getDelegateEndNotificationListener()
          This is useful if this shape belongs to an array of multiple text shapes, in which cas it is better to register the delegate si is is notified only once at each notification end Note1 : take care of read Objects too Note2 : don't forget to use this shape default handler if necessary
protected abstract  java.awt.Shape getDelegateShape()
           
 java.awt.Color getDrawColor()
           
 int getDx(int dx)
           
 int getDy(int dy)
           
 java.lang.String getLink()
           
 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)
           
 void notificationEnd(java.lang.Object referer)
          This callback is called after all notifications were processed.
 void resize(int dx, int dy)
          Resize the component
 void setAnchor(int ox, int oy)
           
 void setDelegateEndNotificationListener(EndNotificationListener denl)
          This is useful if this shape belongs to an array of multiple text shapes, in which cas it is better to register the delegate if is is notified only once at each notification end Note1 : take care of read Objects too Note2 : don't forget to use this shape default handler if necessary
 void setLink(java.lang.String link)
           
 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
protected  void updateBounds()
           
 void updateTransform()
          The transformation input paramters have changed it has to be updated according to transformation reference frame coordinates.
 
Methods inherited from class simtools.shapes.AbstractShape
addListener, getAnchor, getInnerProperties, getMax, getMaxTranslated, getMin, notifyChange, notifyChange, refresh, removeListener, setAnchor, setProperties, wipeOff
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resources

public static MenuResourceBundle resources

MIN_SIZE

public static int MIN_SIZE

drawColor

protected java.awt.Color drawColor

drawDynamicColor

protected transient java.awt.Color drawDynamicColor

drawMapper

protected ColorMapper drawMapper

drawMapperSource

protected transient DataSource drawMapperSource

drawMapperIndex

protected transient long drawMapperIndex

allowResize

protected boolean allowResize

fixedRatio

protected boolean fixedRatio

ratio

protected double ratio

link

protected java.lang.String link

dirtyDrawColor

protected transient boolean dirtyDrawColor

dirty

protected transient boolean dirty

dirtyRectangle

protected transient java.awt.Rectangle dirtyRectangle

stroke

protected transient java.awt.Stroke stroke

strokeParams

protected StrokeParameters strokeParams

transform

protected AffineTransformData transform

bounds2D

protected transient java.awt.geom.Rectangle2D.Double bounds2D

delegateEndNotificationListener

protected transient EndNotificationListener delegateEndNotificationListener
Constructor Detail

Abstract1DShape

public Abstract1DShape(int ox,
                       int oy,
                       int width,
                       int height)
Method Detail

getLink

public java.lang.String getLink()
Specified by:
getLink in interface Linkable

setLink

public void setLink(java.lang.String link)
Specified by:
setLink in interface Linkable

setAnchor

public void setAnchor(int ox,
                      int oy)
Overrides:
setAnchor in class AbstractShape

translate

public void translate(int dx,
                      int dy)
Description copied from class: AbstractShape
Translates the shape

Overrides:
translate in class AbstractShape

updateTransform

public void updateTransform()
Description copied from interface: AffineTransformData.Listener
The transformation input paramters have changed it has to be updated according to transformation reference frame coordinates. Thus, the implementation has to call AffineTransformData.updateTransform(cx,cy) to perform this update before using the transform in the rendering process

Specified by:
updateTransform in interface AffineTransformData.Listener

updateBounds

protected void updateBounds()

cloneShape

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

Overrides:
cloneShape in class AbstractShape
Returns:
a copy of the shape

getDelegateShape

protected abstract java.awt.Shape getDelegateShape()

contains

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

contains

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

contains

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

contains

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

intersects

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

intersects

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

getBounds

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

getBounds2D

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

getPathIterator

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

getPathIterator

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

drawHook

protected void drawHook(java.awt.Graphics2D g,
                        boolean shapeDrawn)
For subclasses, called before restoring original graphics properties, after the delegate shape is drawn if shapeDrawn is true, or after saving the current context, before the delegate shape is drawn if shapeDrawn is false


draw

public void draw(java.awt.Graphics2D g)
Description copied from class: AbstractShape
Draws the shape

Specified by:
draw in class AbstractShape
Parameters:
g - the graphics context

getActions

public java.lang.String[] getActions(double x,
                                     double y,
                                     java.lang.Object o,
                                     int context)
Description copied from interface: ContextualActionProvider
Return list of possible actions the contect information may be used, or not.

Specified by:
getActions in interface ContextualActionProvider
Parameters:
x - Coordinate, mouse position in the same unit as contains(x,y)
y - Coordinate, mouse position in the same unit as contains(x,y)
o - Object the actions should work on. Possibly null => default or all actions
context - one of the context defined in the ContextualActionProvider class
Returns:
The list of possible actions, possibly null or an empty array

getCollectiveActions

public java.util.LinkedHashMap getCollectiveActions(DiagramSelection sel,
                                                    double x,
                                                    double y,
                                                    java.lang.Object o,
                                                    int context)
Description copied from interface: SelectionContextualActionProvider
Return list of possible collective actions

Specified by:
getCollectiveActions in interface SelectionContextualActionProvider
Parameters:
sel - the current selection
x - Coordinate, mouse position in the same unit as contains(x,y)
y - Coordinate, mouse position in the same unit as contains(x,y)
o - Object the collective actions should work on. Possibly null => default or all actions
context - one of the context defined in the ContextualActionProvider class
Returns:
The list of possible actions, possibly empty.The map values contains when applicable parent sub menus and icons

doCollectiveAction

public boolean doCollectiveAction(DiagramSelection sel,
                                  double x,
                                  double y,
                                  java.lang.Object o,
                                  java.lang.String action,
                                  javax.swing.undo.CompoundEdit undoableEdit)
Description copied from interface: SelectionContextualActionProvider
Do one of the collective actions previously declared by getCollectiveActions.

Specified by:
doCollectiveAction in interface SelectionContextualActionProvider
Parameters:
sel - sel the current selection
x - Coordinate, for example mouse position
y - Coordinate, for example mouse position
o - Object the action should work on.
action - action An action returned by a previous getCollectiveActions call with the same x, y, o parameters
undoableEdit - undoableEdit The current compound edit for undo/redo operation. If the action is undoable, the required edits shall be added to this current compound edit.
Returns:
true if the collectiveaction could be performed

doAction

public boolean doAction(double x,
                        double y,
                        java.lang.Object o,
                        java.lang.String action,
                        javax.swing.undo.CompoundEdit undoableEdit)
Description copied from interface: ContextualActionProvider
Do one of the actions previously declared by getAction.

Specified by:
doAction in interface ContextualActionProvider
Parameters:
x - Coordinate, for example mouse position
y - Coordinate, for example mouse position
o - Object the action should work on.
action - An action returned by a previous getActions call with the same x, y, o parameters It may be null, in which case the default action is requested for this x,y,o.
undoableEdit - current edit for undo/redo operation If not null, this action is undoable.
Returns:
true if the action could be performed

canDoAction

public boolean canDoAction(double x,
                           double y,
                           java.lang.Object o,
                           java.lang.String action,
                           int context)
Description copied from interface: ContextualActionProvider
Returns true if, and only if, it is possible to do the action right now

Specified by:
canDoAction in interface ContextualActionProvider
Parameters:
x - Coordinate, for example mouse position
y - Coordinate, for example mouse position
o - Object the action should work on.
action - An action returned by a previous getActions call with the same x, y, o parameters It may be null, in which case the default action is requested for this x,y,o.
context - one of the context defined in the ContextualActionProvider class
Returns:
true if the action can be performed

createPanel

public JPropertiesPanel createPanel()

createPanel

public JPropertiesPanel createPanel(java.lang.String name)

getDrawColor

public java.awt.Color getDrawColor()

getDelegateEndNotificationListener

public EndNotificationListener getDelegateEndNotificationListener()
This is useful if this shape belongs to an array of multiple text shapes, in which cas it is better to register the delegate si is is notified only once at each notification end Note1 : take care of read Objects too Note2 : don't forget to use this shape default handler if necessary

Returns:
Returns the delegateEndNotificationListener.

setDelegateEndNotificationListener

public void setDelegateEndNotificationListener(EndNotificationListener denl)
This is useful if this shape belongs to an array of multiple text shapes, in which cas it is better to register the delegate if is is notified only once at each notification end Note1 : take care of read Objects too Note2 : don't forget to use this shape default handler if necessary

Parameters:
delegateEndNotificationListener - The delegateEndNotificationListener to set.

notificationEnd

public void notificationEnd(java.lang.Object referer)
Description copied from interface: EndNotificationListener
This callback is called after all notifications were processed. The referer object is the one to decide what the end means. For example, it may be a single data source notifying both a range change and a value change. Or it could be a collection notifying all its sources.

Specified by:
notificationEnd in interface EndNotificationListener

DataSourceIndexRangeChanged

public void DataSourceIndexRangeChanged(DataSource ds,
                                        long startIndex,
                                        long lastIndex)
Description copied from interface: DataSourceListener
Called when the range of valid index changed

Specified by:
DataSourceIndexRangeChanged in interface DataSourceListener
Parameters:
ds - The data source that changed
startIndex - The new start Index
lastIndex - The new last index

DataSourceInfoChanged

public void DataSourceInfoChanged(DataSource ds,
                                  DataInfo newInfo)
Description copied from interface: DataSourceListener
Called when the information about the data source changed

Specified by:
DataSourceInfoChanged in interface DataSourceListener
Parameters:
ds - The data source that changed

DataSourceOrderChanged

public void DataSourceOrderChanged(DataSource ds,
                                   int newOrder)
Description copied from interface: DataSourceListener
If defined, called when the order of the source changed. See the sortedOrder() in the Datasource class for more information.

Specified by:
DataSourceOrderChanged in interface DataSourceListener
Parameters:
ds - The data source that changed

DataSourceValueChanged

public void DataSourceValueChanged(DataSource ds,
                                   long minIndex,
                                   long maxIndex)
Description copied from interface: DataSourceListener
Called when at least a value changed in the data source. The listener shall then get the values in the given range again, if it is interested by the values in that range.

Specified by:
DataSourceValueChanged in interface DataSourceListener
Parameters:
ds - The data source that changed
minIndex - Lower bound of the range where values changed
maxIndex - Higher bound of the range where values changed

DataSourceReplaced

public void DataSourceReplaced(DataSource oldData,
                               DataSource newData)
Description copied from interface: DataSourceListener
Called when a data source is replaced by another one

Specified by:
DataSourceReplaced in interface DataSourceListener

DataSourceValueRangeChanged

public void DataSourceValueRangeChanged(DataSource ds)
Description copied from interface: DataSourceListener
Called when the range of possible values changed, if defined.

Specified by:
DataSourceValueRangeChanged in interface DataSourceListener
Parameters:
ds - The data source that changed

canResize

protected boolean canResize()
Allow resize: it is possible to forbid shape resizing even the allow resize property has been set to true by user. For instance, resizing is not allowed when a rotation has been applied to the shape Overload canResize method in sub classes if needed.

Returns:
true if shape can be resized.

resize

public void resize(int dx,
                   int dy)
Description copied from interface: Resizable
Resize the component

Specified by:
resize in interface Resizable
Parameters:
dx - value on x axis
dy - value on y axis

getDx

public int getDx(int dx)

getDy

public int getDy(int dy)

setPropertyValue

public void setPropertyValue(java.lang.String name,
                             java.lang.Object value)
Description copied from class: AbstractShape
Assigns value to the property named name

Specified by:
setPropertyValue in interface NamedProperties
Overrides:
setPropertyValue in class AbstractShape
Parameters:
name - the name of the property to get
value - its new value
See Also:
AbstractShape.setPropertyValue(String, Object)

getPropertyNames

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

Specified by:
getPropertyNames in interface NamedProperties
Overrides:
getPropertyNames in class AbstractShape

getPropertyValue

public java.lang.Object getPropertyValue(java.lang.String name)
Description copied from class: AbstractShape
Get the value of the property named name

Specified by:
getPropertyValue in interface NamedProperties
Overrides:
getPropertyValue in class AbstractShape
Parameters:
name - the name of the property to get
Returns:
the property value
See Also:
AbstractShape.getPropertyValue(String)