simtools.shapes
Class CurveShape

java.lang.Object
  extended by simtools.shapes.CurveShape
All Implemented Interfaces:
java.awt.Shape, java.io.Serializable, java.lang.Cloneable, DataSourceListener

public class CurveShape
extends java.lang.Object
implements java.awt.Shape, java.lang.Cloneable, java.io.Serializable, DataSourceListener

See Also:
Serialized Form

Nested Class Summary
 class CurveShape.CurveIterator
           
 class CurveShape.CurvePoint
          A curve point representing a location in (x, y) coordinate space, specified in double precision.
static class CurveShape.CurveShapePropertiesNames
           
 class CurveShape.NoDrawIterator
           
 
Field Summary
protected  java.awt.geom.AffineTransform _aff
           
protected  CurveShape.CurvePoint currentPoint
           
protected  boolean drawNewOnly
           
protected  long iteratorMaxIndex
           
protected  long iteratorMinIndex
           
protected  long lastDrawnIndex
           
protected  ListenerManager listeners
           
protected  long localMaxIndex
           
protected  long localMinIndex
           
protected  double localRangeDeviation
          Local standard deviation:
protected  double localRangeIntegral
          Local integral:
protected  CurveShape.CurvePoint localRangeMaxPoint
           
protected  double localRangeMean
          Local mean:
protected  CurveShape.CurvePoint localRangeMinPoint
           
protected  long localRangeNbPoints
           
static double LOG_MIN
          Smallest arbitrarily-close-to-zero value allowed.
static double LOG10_VALUE
          The value of ln(10), used to compute LOG10_VALUE
protected  boolean logx
           
protected  boolean logy
           
protected  long max
           
protected  double maxx
           
protected  double maxy
           
protected  long min
           
protected  double orgx
           
protected  double orgy
           
protected  CurveShape.CurvePoint referencePoint
           
protected  double scalex
           
protected  double scaley
           
static int SLOP_LENGTH
           
protected  boolean useCache
           
protected  double[] xCache
           
protected  DataSource xSource
           
protected  boolean xSourceChanged
           
protected  long xSourceNewLastIndex
           
protected  long xSourceNewStartIndex
           
protected  double[] yCache
           
protected  DataSource ySource
           
protected  double[] ySourceCache
           
protected  boolean ySourceChanged
           
protected  long ySourceNewLastIndex
           
protected  long ySourceNewStartIndex
           
 
Constructor Summary
CurveShape()
           
CurveShape(DataSource xSource, DataSource ySource)
           
 
Method Summary
 void addListener(CurveShapeListener csl)
           
 java.lang.Object clone()
           
protected  void computeLocalRangeIndex(double xmin, double xmax)
           
 void computeStatistics(double xmin, double xmax)
          Method computeCurveStatisticsAndIntegral Compute min, max, mean, and integral for a function y=f(x) in a specified interval [xmin, xmax] Data source attached to X values must be sorted, otherwise no compute is performed.
 void computeYLocalRange(double xmin, double xmax)
           
 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)
           
 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.
 void draw(java.awt.Graphics2D g2, double ox, double oy, double mx, double my, double sx, double sy, boolean showPoints, boolean drawBars, int barHeight)
          Draws it
 void drawMagnetizedPoint(java.awt.Graphics2D g2, double ox, double oy, double sx, double sy)
          Draws the computed magnetized point into the graphic
 void drawReferencePoint(java.awt.Graphics2D g2, double ox, double oy, double sx, double sy)
           
 java.awt.Rectangle getBounds()
           
 java.awt.geom.Rectangle2D getBounds2D()
           
 CurveShape.CurvePoint getCurrentPoint()
           
 java.lang.String getCurveInformation(double xmin, double xmax)
           
 java.awt.geom.Rectangle2D getDrawNewOnlyArea()
           
 double getLocalDeviationValue()
           
 double getLocalIntegralValue()
           
 long getLocalNbPoints()
           
 CurveShape.CurvePoint getLocalRangeMaxPoint()
           
 double getLocalRangeMean()
           
 CurveShape.CurvePoint getLocalRangeMinPoint()
           
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at)
           
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at, double flatness)
           
 CurveShape.CurvePoint getReferencePoint()
           
 DataSource getXSource()
           
 DataSource getYSource()
           
 boolean intersects(double x, double y, double w, double h)
           
 boolean intersects(java.awt.geom.Rectangle2D r)
           
 boolean isDrawNewOnly()
           
protected  void notifyChange()
           
 void removeListener(CurveShapeListener csl)
           
 void setCurrentPoint(double pos_x)
          Get curve point the closest to X mouse position Set this point as current point.
 void setData(DataSource xSource, DataSource ySource)
           
 void setLogsProperties(boolean _logx, boolean _logy)
          Method setLogsProperties
Summary:
Use this method to set logarithmic modes on curve axis.
 void setReferencePoint(CurveShape.CurvePoint curvePoint)
           
 void setSlice(long min, long max)
           
 boolean tryDrawNewOnly()
          Sets the drawNewOnly.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xSource

protected transient DataSource xSource

ySource

protected transient DataSource ySource

min

protected long min

max

protected long max

orgx

protected transient double orgx

orgy

protected transient double orgy

maxx

protected transient double maxx

maxy

protected transient double maxy

scalex

protected transient double scalex

scaley

protected transient double scaley

useCache

protected transient boolean useCache

xCache

protected transient double[] xCache

yCache

protected transient double[] yCache

ySourceCache

protected transient double[] ySourceCache

listeners

protected transient ListenerManager listeners

drawNewOnly

protected boolean drawNewOnly

iteratorMinIndex

protected transient long iteratorMinIndex

iteratorMaxIndex

protected transient long iteratorMaxIndex

xSourceChanged

protected transient boolean xSourceChanged

ySourceChanged

protected transient boolean ySourceChanged

xSourceNewStartIndex

protected transient long xSourceNewStartIndex

xSourceNewLastIndex

protected transient long xSourceNewLastIndex

ySourceNewStartIndex

protected transient long ySourceNewStartIndex

ySourceNewLastIndex

protected transient long ySourceNewLastIndex

lastDrawnIndex

protected transient long lastDrawnIndex

logx

protected transient boolean logx

logy

protected transient boolean logy

LOG10_VALUE

public static final double LOG10_VALUE
The value of ln(10), used to compute LOG10_VALUE


LOG_MIN

public static final double LOG_MIN
Smallest arbitrarily-close-to-zero value allowed.

See Also:
Constant Field Values

SLOP_LENGTH

public static final int SLOP_LENGTH
See Also:
Constant Field Values

localRangeNbPoints

protected transient long localRangeNbPoints

localRangeMaxPoint

protected transient CurveShape.CurvePoint localRangeMaxPoint

localRangeMinPoint

protected transient CurveShape.CurvePoint localRangeMinPoint

localMinIndex

protected transient long localMinIndex

localMaxIndex

protected transient long localMaxIndex

localRangeMean

protected transient double localRangeMean
Local mean:


localRangeIntegral

protected transient double localRangeIntegral
Local integral:


localRangeDeviation

protected transient double localRangeDeviation
Local standard deviation:


currentPoint

protected transient CurveShape.CurvePoint currentPoint

referencePoint

protected transient CurveShape.CurvePoint referencePoint

_aff

protected java.awt.geom.AffineTransform _aff
Constructor Detail

CurveShape

public CurveShape()

CurveShape

public CurveShape(DataSource xSource,
                  DataSource ySource)
Method Detail

setData

public void setData(DataSource xSource,
                    DataSource ySource)

getXSource

public DataSource getXSource()
                      throws DataException
Throws:
DataException

getYSource

public DataSource getYSource()
                      throws DataException
Throws:
DataException

setSlice

public void setSlice(long min,
                     long max)

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

drawReferencePoint

public void drawReferencePoint(java.awt.Graphics2D g2,
                               double ox,
                               double oy,
                               double sx,
                               double sy)
Parameters:
g2 - - the current graphics
ox -
oy -
sx -
sy -

drawMagnetizedPoint

public void drawMagnetizedPoint(java.awt.Graphics2D g2,
                                double ox,
                                double oy,
                                double sx,
                                double sy)
Draws the computed magnetized point into the graphic

Parameters:
g2 - the current graphics

setLogsProperties

public void setLogsProperties(boolean _logx,
                              boolean _logy)
Method setLogsProperties
Summary:
Use this method to set logarithmic modes on curve axis. Parameters:

Parameters:
_logx - True to use logarithmic mode on x axis. False otherwise.
_logy - True to use logarithmic mode on y axis. False otherwise.

draw

public void draw(java.awt.Graphics2D g2,
                 double ox,
                 double oy,
                 double mx,
                 double my,
                 double sx,
                 double sy,
                 boolean showPoints,
                 boolean drawBars,
                 int barHeight)
Draws it

Parameters:
g2 - the current graphics

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

clone

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

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

addListener

public void addListener(CurveShapeListener csl)

removeListener

public void removeListener(CurveShapeListener csl)

notifyChange

protected void notifyChange()

isDrawNewOnly

public boolean isDrawNewOnly()
Returns:
boolean

tryDrawNewOnly

public boolean tryDrawNewOnly()
Sets the drawNewOnly.

Parameters:
drawNewOnly - The drawNewOnly to set

getDrawNewOnlyArea

public java.awt.geom.Rectangle2D getDrawNewOnlyArea()

computeLocalRangeIndex

protected void computeLocalRangeIndex(double xmin,
                                      double xmax)
                               throws DataException
Throws:
DataException

computeYLocalRange

public void computeYLocalRange(double xmin,
                               double xmax)
                        throws DataException
Throws:
DataException

computeStatistics

public void computeStatistics(double xmin,
                              double xmax)
                       throws DataException
Method computeCurveStatisticsAndIntegral Compute min, max, mean, and integral for a function y=f(x) in a specified interval [xmin, xmax] Data source attached to X values must be sorted, otherwise no compute is performed.

Parameters:
xmin - fisrt bound of interval in which compute is performed
xmax - last bound of interval in which compute is performed
Throws:
DataException

setReferencePoint

public void setReferencePoint(CurveShape.CurvePoint curvePoint)

setCurrentPoint

public void setCurrentPoint(double pos_x)
                     throws DataException
Get curve point the closest to X mouse position Set this point as current point. x data source values must sorted in descending or ascending order. y data source indexes must fit with x indexes If x and y data sources are not compliant with these contraints, an exception is thrown - Compute magnetized point slope with next point (or previous point if it is the last point)

Throws:
DataException

getLocalRangeMaxPoint

public CurveShape.CurvePoint getLocalRangeMaxPoint()

getLocalRangeMinPoint

public CurveShape.CurvePoint getLocalRangeMinPoint()

getLocalNbPoints

public long getLocalNbPoints()

getLocalRangeMean

public double getLocalRangeMean()

getCurrentPoint

public CurveShape.CurvePoint getCurrentPoint()

getReferencePoint

public CurveShape.CurvePoint getReferencePoint()

getLocalIntegralValue

public double getLocalIntegralValue()

getLocalDeviationValue

public double getLocalDeviationValue()

getCurveInformation

public java.lang.String getCurveInformation(double xmin,
                                            double xmax)
Returns:
a list of information about the curve.