jsynoptic.builtin
Class AffineTransformData

java.lang.Object
  extended by jsynoptic.builtin.AffineTransformData
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, DataSourceListener, EndNotificationListener, NamedProperties

public class AffineTransformData
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable, DataSourceListener, EndNotificationListener, NamedProperties

An AffineTransform with input values for translation and rotation coming from user defined inputs or data sources

See Also:
Serialized Form

Nested Class Summary
static class AffineTransformData.AffineTransformDataPropertiesNames
           
static interface AffineTransformData.Listener
          An interface to warn the transform owner in case of transform change
 
Field Summary
protected  java.lang.String[] _propertyNames
          The list of properties managed by this panel
protected  double angleUnitScale
          Scale used for angle value : 1 means radian, PI/180 means degree
protected  boolean dirty
          True if new values have not been yet taken into account in the affine transform
protected  AffineTransformData.Listener listener
          The listener to warn in case of new transform change
static int MAX_TRANSLATION
          Maximum translation value for both axes to avoid loosing shapes This default value can be overloaded thanks to user properties
protected  DoubleValueMapper rotationMapper
          Map rotation data source value to some rotation values
protected  boolean rotEnabled
          True if the rotation is enabled
protected  DataSource rotSource
          The data source for the rotation
protected  long rotSourceIndex
          The source value index to get the rotation value
protected  double rotValue
          The rotation value
protected  boolean transEnabled
          True if translation is activated (both axes)
protected  java.awt.geom.AffineTransform transform
          The real affine transformation
protected  double[] transformBounds
          An arry of values to apply transformation on
protected  boolean translationFirst
          True to perform affine transform computation using translation first
protected  double transUnitScale
          Translation scale factor : 1 means 1 pixel
protected  DoubleValueMapper txMapper
          Map rotation data source value to some rotation values
protected  DataSource txSource
          The X translation data source
protected  long txSourceIndex
          The X translation data source index
protected  double txValue
          The X translation value
protected  DoubleValueMapper tyMapper
          Map rotation data source value to some rotation values
protected  DataSource tySource
          The X translation data source
protected  long tySourceIndex
          The Y translation data source index
protected  double tyValue
          The Y translation value
 
Constructor Summary
AffineTransformData()
          Create a new AffineTransformData without object listening on the changes
AffineTransformData(AffineTransformData.Listener listener)
          Create a new AffineTransformData with an object listening on the changes
 
Method Summary
 void addListeners()
          Add data listners to the used data
 AffineTransformData cloneTransform()
          Clone the object
 AffineTransformData cloneTransform(boolean withDataListener)
          Clone the object
 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.
 java.util.Collection getInnerProperties()
          Get the properties of inner objects or null if none
 java.lang.String[] getPropertyNames()
          Get the list of property names
 java.lang.Object getPropertyValue(java.lang.String name)
          Get the value of one property given its name
 java.awt.geom.AffineTransform getTransform()
           
 void notificationEnd(java.lang.Object referer)
          This callback is called after all notifications were processed.
 void release()
          Remove the data sources used by this tranform : remove the notifiers and set to null the references.
 void setListener(AffineTransformData.Listener listener)
          Set the owner of the transform
 void setPropertyValue(java.lang.String name, java.lang.Object value)
          Set the value of one property given its name
 void updateBounds(int x1, int y1, int x2, int y2, java.awt.geom.Rectangle2D.Double bounds)
          Compute the new bounds according to the intial bounds and the current transformation
 void updateTransform(double cx, double cy)
          Method called by the listener of the transform to update it according to new values (rotation and translation) and reference coordinates
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_TRANSLATION

public static int MAX_TRANSLATION
Maximum translation value for both axes to avoid loosing shapes This default value can be overloaded thanks to user properties


transform

protected transient java.awt.geom.AffineTransform transform
The real affine transformation


transformBounds

protected transient double[] transformBounds
An arry of values to apply transformation on


rotSource

protected transient DataSource rotSource
The data source for the rotation


rotSourceIndex

protected transient long rotSourceIndex
The source value index to get the rotation value


rotValue

protected double rotValue
The rotation value


rotationMapper

protected DoubleValueMapper rotationMapper
Map rotation data source value to some rotation values


rotEnabled

protected boolean rotEnabled
True if the rotation is enabled


angleUnitScale

protected double angleUnitScale
Scale used for angle value : 1 means radian, PI/180 means degree


txSource

protected transient DataSource txSource
The X translation data source


txSourceIndex

protected transient long txSourceIndex
The X translation data source index


txValue

protected double txValue
The X translation value


txMapper

protected DoubleValueMapper txMapper
Map rotation data source value to some rotation values


tySource

protected transient DataSource tySource
The X translation data source


tySourceIndex

protected transient long tySourceIndex
The Y translation data source index


tyValue

protected double tyValue
The Y translation value


tyMapper

protected DoubleValueMapper tyMapper
Map rotation data source value to some rotation values


transEnabled

protected boolean transEnabled
True if translation is activated (both axes)


transUnitScale

protected double transUnitScale
Translation scale factor : 1 means 1 pixel


translationFirst

protected boolean translationFirst
True to perform affine transform computation using translation first


dirty

protected transient boolean dirty
True if new values have not been yet taken into account in the affine transform


listener

protected AffineTransformData.Listener listener
The listener to warn in case of new transform change


_propertyNames

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

Constructor Detail

AffineTransformData

public AffineTransformData(AffineTransformData.Listener listener)
Create a new AffineTransformData with an object listening on the changes

Parameters:
listener - the object to warn in case of changes

AffineTransformData

public AffineTransformData()
Create a new AffineTransformData without object listening on the changes

Method Detail

getTransform

public java.awt.geom.AffineTransform getTransform()
Returns:
the current affine transform

setListener

public void setListener(AffineTransformData.Listener listener)
Set the owner of the transform

Parameters:
listener - the object to warn when transform changes

release

public void release()
Remove the data sources used by this tranform : remove the notifiers and set to null the references. To be invoked before releasing this object


addListeners

public void addListeners()
Add data listners to the used data


cloneTransform

public AffineTransformData cloneTransform()
Clone the object

Returns:
a deep copy of the object

cloneTransform

public AffineTransformData cloneTransform(boolean withDataListener)
Clone the object

Parameters:
withDataListener - true to add the listeners to all the used data
Returns:
a deep copy of the object

updateBounds

public void updateBounds(int x1,
                         int y1,
                         int x2,
                         int y2,
                         java.awt.geom.Rectangle2D.Double bounds)
Compute the new bounds according to the intial bounds and the current transformation

Parameters:
x1 - bounds lower left corner x coordinate
y1 - bounds lower left corner y coordinate
x2 - bounds top right corner x coordinate
y2 - bounds top right corner x coordinate
bounds - intial bounds to be updated accordingly

updateTransform

public void updateTransform(double cx,
                            double cy)
Method called by the listener of the transform to update it according to new values (rotation and translation) and reference coordinates

Parameters:
cx - x reference coordinate (typically the center of a shape)
cy - y reference coordinate (typically the center of a shape)

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

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

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

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

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

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

getPropertyNames

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

Specified by:
getPropertyNames in interface NamedProperties

getPropertyValue

public java.lang.Object getPropertyValue(java.lang.String name)
Description copied from interface: NamedProperties
Get the value of one property given its name

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

setPropertyValue

public void setPropertyValue(java.lang.String name,
                             java.lang.Object value)
Description copied from interface: NamedProperties
Set the value of one property given its name

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

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