simtools.shapes
Class PlotShape

java.lang.Object
  extended by simtools.shapes.AbstractShape
      extended by simtools.shapes.PlotShape
All Implemented Interfaces:
java.awt.Shape, java.io.Serializable, java.lang.Cloneable, EndNotificationListener, Resizable, CurveShapeListener, ShapeListener, NamedProperties
Direct Known Subclasses:
Plot

public class PlotShape
extends AbstractShape
implements java.io.Serializable, java.lang.Cloneable, CurveShapeListener, EndNotificationListener, ShapeListener, Resizable

See Also:
Serialized Form

Nested Class Summary
 class PlotShape.Curve
          A class to put the curveShape, its label and the used axes
 class PlotShape.Limit
          A class to put the curveShape, its label and the used axes
 
Nested classes/interfaces inherited from class simtools.shapes.AbstractShape
AbstractShape.AbstractShapePropertiesNames
 
Field Summary
protected  AxisShape _asx1
           
protected  AxisShape _asx2
           
protected  AxisShape _asy1
           
protected  AxisShape _asy2
           
protected  java.awt.Color _color
           
protected  java.util.Vector _curves
           
protected  java.awt.Font _font
           
protected  java.util.ArrayList _limits
           
protected  PlotShape.Curve _magnetizedCurve
          The current magnetized curve
protected  java.awt.Font curveInformationFont
           
protected  java.util.ArrayList curveInformationLabel
           
protected  boolean dirty
           
protected  java.lang.Boolean displayCurveInformation
          When hasCurveInformation is true, display information about plot curves below the shape
protected  boolean hasLegend
           
protected  java.awt.image.BufferedImage image
           
protected  java.awt.Graphics2D imageGraphics
           
protected  java.awt.Rectangle legendBounds
           
protected  boolean logpx
          The 4 booleans wich indicate if axes are under logarithmic mode.
protected  boolean logpy
          The 4 booleans wich indicate if axes are under logarithmic mode.
protected  boolean logsx
          The 4 booleans wich indicate if axes are under logarithmic mode.
protected  boolean logsy
          The 4 booleans wich indicate if axes are under logarithmic mode.
protected  boolean optimize
           
protected  int optimizeMode
           
protected  java.text.ChoiceFormat pyformat
           
protected  java.text.ChoiceFormat syformat
           
protected  LabelShape title
           
protected  java.awt.Font titleFont
           
 
Fields inherited from class simtools.shapes.AbstractShape
_h, _ox, _oy, _propertyNames, _w, _x, _y, ANTI_ALIASING, currentDialogBox, FONT_NAMES, listeners, REFRESH_PERIOD
 
Constructor Summary
PlotShape(int ox, int oy, int width, int height)
           
 
Method Summary
protected  AbstractShape cloneShape()
          Performs a copy of the shape This method has to be overriden to deal with concrete shapes
protected  void computeBounds()
           
 void computeLegendBounds()
           
 void draw(java.awt.Graphics2D g2)
          Draws it
protected  void drawCurves(java.awt.Graphics2D g2)
           
 void drawLegend(java.awt.Graphics2D g2)
           
protected  java.awt.Rectangle drawLegendAndGetBounds(java.awt.Graphics2D g2, java.awt.Rectangle reference)
           
protected  void drawLimits(java.awt.Graphics2D g2)
           
protected  void drawMagnetizedCurve(java.awt.Graphics2D g2)
          Allow the magnetized curve to display some graphical information
 PlotShape.Curve getCurve(CurveShape cs)
           
 PlotShape.Curve getCurve(int i)
           
 int getCurveNumber()
           
protected  java.util.ArrayList getCurvesInformation()
           
 PlotShape.Limit getLimit(int i)
           
 PlotShape.Limit getLimit(LimitShape cs)
           
 int getLimitNumber()
           
 AxisShape getPrimaryXAxis()
          Method getPrimaryXAxis
Summary:
Get primary X axis
 AxisShape getSecondaryXAxis()
          Method getSecondaryXAxis
Summary:
Get secondary X axis
 java.lang.String getTitle()
           
 void insertCurve(CurveShape cs)
           
 void insertCurve(CurveShape cs, boolean secondaryXAxis)
           
 void insertCurve(CurveShape cs, boolean secondaryXAxis, boolean secondaryYAxis)
           
 void insertCurve(CurveShape cs, boolean secondaryXAxis, boolean secondaryYAxis, int index)
          Add a new curve to this plot
 void insertLimit(LimitShape cs)
           
 void insertLimit(LimitShape cs, boolean secondaryAxis)
           
 void insertLimit(LimitShape cs, boolean secondaryAxis, int index)
          Add a new limit to this plot
 java.lang.Boolean isCurveInformationVisible()
           
 boolean isLegendVisible()
           
 boolean isOptimize()
           
 boolean isSecondaryAxis(boolean onX)
           
 void notificationEnd(java.lang.Object referer)
          This callback is called after all notifications were processed.
 void removeCurve(CurveShape cs)
           
 void removeLimit(LimitShape cs)
           
 void resize(int dx, int dy)
          Resizes the shape
 void set(double min, double max, double step, boolean onX, boolean secondary)
          Set axis coordinates
 void setAnchor(int ox, int oy)
          Sets the anchor
 void setAnchor(java.awt.Point p)
          Sets shape anchor
 void setColor(java.awt.Color c)
           
 void setCurveColor(CurveShape cs, java.awt.Color color)
           
 void setCurveInformationVisible(java.lang.Boolean state)
           
 void setCurveLabel(CurveShape cs, java.lang.String s)
           
 void setFont(java.awt.Font f)
           
 void setFormat(java.text.Format f, boolean onX, boolean secondary)
           
 void setLabel(java.lang.String s, boolean onX, boolean secondary)
          Sets a label for an axis
 void setLegendVisible(boolean state)
           
 void setLimitColor(LimitShape cs, java.awt.Color color)
           
 void setLimitLabel(LimitShape cs, java.lang.String s)
           
 void setOptimize(boolean optimize)
          Sets the optimize.
 void setSecondaryAxis(boolean onX, boolean enabled)
           
 void setSecondaryX(double min, double max, double step)
           
 void setSecondaryY(double min, double max, double step)
           
 void setTitle(java.lang.String s)
           
 void setTitleFont(java.awt.Font f)
           
 void setX(double min, double max, double step)
           
 void setXLabel(java.lang.String s)
           
 void setXLabel(java.lang.String s, boolean secondary)
          Sets a label for an axis
 void setY(double min, double max, double step)
           
 void setYLabel(java.lang.String s)
           
 void setYLabel(java.lang.String s, boolean secondary)
           
 void shapeChanged(AbstractShape shape, java.awt.Rectangle changedArea)
           
 void shapeChanged(CurveShape cs)
          This function is called when the shape changed.
 void shapeDataChanged(CurveShape cs, DataSource oldData, DataSource newData, boolean onX)
          This function is called when one of the data displayed by the curve is replaced
 void translate(int dx, int dy)
          Translates the shape
protected  void updateBounds()
           
 void updateCurveInformation()
           
 
Methods inherited from class simtools.shapes.AbstractShape
addListener, contains, contains, contains, contains, getAnchor, getBounds, getBounds2D, getInnerProperties, getMax, getMaxTranslated, getMin, getPathIterator, getPathIterator, getPropertyNames, getPropertyValue, intersects, intersects, notifyChange, notifyChange, refresh, removeListener, setProperties, setPropertyValue, wipeOff
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_font

protected java.awt.Font _font

titleFont

protected java.awt.Font titleFont

curveInformationFont

protected java.awt.Font curveInformationFont

_color

protected java.awt.Color _color

_asx1

protected AxisShape _asx1

_asy1

protected AxisShape _asy1

_asx2

protected AxisShape _asx2

_asy2

protected AxisShape _asy2

hasLegend

protected boolean hasLegend

title

protected LabelShape title

displayCurveInformation

protected java.lang.Boolean displayCurveInformation
When hasCurveInformation is true, display information about plot curves below the shape


curveInformationLabel

protected java.util.ArrayList curveInformationLabel

_curves

protected java.util.Vector _curves

_limits

protected java.util.ArrayList _limits

optimize

protected transient boolean optimize

optimizeMode

protected transient int optimizeMode

image

protected transient java.awt.image.BufferedImage image

imageGraphics

protected transient java.awt.Graphics2D imageGraphics

dirty

protected transient boolean dirty

legendBounds

protected transient java.awt.Rectangle legendBounds

logpx

protected boolean logpx
The 4 booleans wich indicate if axes are under logarithmic mode.


logpy

protected boolean logpy
The 4 booleans wich indicate if axes are under logarithmic mode.


logsx

protected boolean logsx
The 4 booleans wich indicate if axes are under logarithmic mode.


logsy

protected boolean logsy
The 4 booleans wich indicate if axes are under logarithmic mode.


pyformat

protected transient java.text.ChoiceFormat pyformat

syformat

protected transient java.text.ChoiceFormat syformat

_magnetizedCurve

protected transient PlotShape.Curve _magnetizedCurve
The current magnetized curve

Constructor Detail

PlotShape

public PlotShape(int ox,
                 int oy,
                 int width,
                 int height)
Parameters:
ox - the anchor x position
oy - the anchor y position
length - the axis length excluding the space to display label and gridlines values
Method Detail

cloneShape

protected AbstractShape cloneShape()
Description copied from class: AbstractShape
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

setSecondaryAxis

public void setSecondaryAxis(boolean onX,
                             boolean enabled)

isSecondaryAxis

public boolean isSecondaryAxis(boolean onX)

getPrimaryXAxis

public AxisShape getPrimaryXAxis()
Method getPrimaryXAxis
Summary:
Get primary X axis

Returns:
(AxisShape) A AxisShape.

getSecondaryXAxis

public AxisShape getSecondaryXAxis()
Method getSecondaryXAxis
Summary:
Get secondary X axis

Returns:
(AxisShape) A AxisShape.

getCurve

public PlotShape.Curve getCurve(int i)

getCurveNumber

public int getCurveNumber()

getCurve

public PlotShape.Curve getCurve(CurveShape cs)

insertCurve

public void insertCurve(CurveShape cs,
                        boolean secondaryXAxis,
                        boolean secondaryYAxis,
                        int index)
Add a new curve to this plot

Parameters:
cs - the curve (it can be shared with other plots)
secondaryXAxis - plot using secondary X axis if true
secondaryYAxis - plot using secondary Y axis if true
index - curve index among the other curves to plot or -1 if latest

insertCurve

public void insertCurve(CurveShape cs)

insertCurve

public void insertCurve(CurveShape cs,
                        boolean secondaryXAxis)

insertCurve

public void insertCurve(CurveShape cs,
                        boolean secondaryXAxis,
                        boolean secondaryYAxis)

removeCurve

public void removeCurve(CurveShape cs)

setCurveColor

public void setCurveColor(CurveShape cs,
                          java.awt.Color color)

setCurveLabel

public void setCurveLabel(CurveShape cs,
                          java.lang.String s)

getLimit

public PlotShape.Limit getLimit(int i)

getLimitNumber

public int getLimitNumber()

getLimit

public PlotShape.Limit getLimit(LimitShape cs)

insertLimit

public void insertLimit(LimitShape cs,
                        boolean secondaryAxis,
                        int index)
Add a new limit to this plot

Parameters:
cs - the limit (it can be shared with other plots)
secondaryXAxis - plot using secondary X axis if true
secondaryYAxis - plot using secondary Y axis if true
index - limit index among the other limits to plot or -1 if latest

insertLimit

public void insertLimit(LimitShape cs)

insertLimit

public void insertLimit(LimitShape cs,
                        boolean secondaryAxis)

removeLimit

public void removeLimit(LimitShape cs)

setLimitColor

public void setLimitColor(LimitShape cs,
                          java.awt.Color color)

setLimitLabel

public void setLimitLabel(LimitShape cs,
                          java.lang.String s)

setFont

public void setFont(java.awt.Font f)

setTitleFont

public void setTitleFont(java.awt.Font f)

isLegendVisible

public boolean isLegendVisible()

setLegendVisible

public void setLegendVisible(boolean state)

setCurveInformationVisible

public void setCurveInformationVisible(java.lang.Boolean state)

isCurveInformationVisible

public java.lang.Boolean isCurveInformationVisible()

getTitle

public java.lang.String getTitle()

setTitle

public void setTitle(java.lang.String s)

getCurvesInformation

protected java.util.ArrayList getCurvesInformation()

set

public void set(double min,
                double max,
                double step,
                boolean onX,
                boolean secondary)
Set axis coordinates


setX

public void setX(double min,
                 double max,
                 double step)

setSecondaryX

public void setSecondaryX(double min,
                          double max,
                          double step)

setY

public void setY(double min,
                 double max,
                 double step)

setSecondaryY

public void setSecondaryY(double min,
                          double max,
                          double step)

setLabel

public void setLabel(java.lang.String s,
                     boolean onX,
                     boolean secondary)
Sets a label for an axis

Parameters:
s - The string to display as the label
onX - Axis selector: true => x, false => y
secondary - Axis selector: true => secondary, false => primary

setXLabel

public void setXLabel(java.lang.String s,
                      boolean secondary)
Sets a label for an axis


setXLabel

public void setXLabel(java.lang.String s)

setYLabel

public void setYLabel(java.lang.String s,
                      boolean secondary)

setYLabel

public void setYLabel(java.lang.String s)

setFormat

public void setFormat(java.text.Format f,
                      boolean onX,
                      boolean secondary)

setColor

public void setColor(java.awt.Color c)

setAnchor

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

Overrides:
setAnchor in class AbstractShape
Parameters:
p - the origin

resize

public void resize(int dx,
                   int dy)
Resizes the shape

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

translate

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

Overrides:
translate in class AbstractShape

setAnchor

public void setAnchor(int ox,
                      int oy)
Sets the anchor

Overrides:
setAnchor in class AbstractShape

draw

public void draw(java.awt.Graphics2D g2)
Draws it

Specified by:
draw in class AbstractShape
Parameters:
g2 - the current graphics

drawLegendAndGetBounds

protected java.awt.Rectangle drawLegendAndGetBounds(java.awt.Graphics2D g2,
                                                    java.awt.Rectangle reference)

drawLegend

public void drawLegend(java.awt.Graphics2D g2)

computeLegendBounds

public void computeLegendBounds()

drawMagnetizedCurve

protected void drawMagnetizedCurve(java.awt.Graphics2D g2)
Allow the magnetized curve to display some graphical information

Parameters:
g2 -

drawCurves

protected void drawCurves(java.awt.Graphics2D g2)

drawLimits

protected void drawLimits(java.awt.Graphics2D g2)

computeBounds

protected void computeBounds()

updateBounds

protected void updateBounds()

shapeChanged

public void shapeChanged(CurveShape cs)
Description copied from interface: CurveShapeListener
This function is called when the shape changed.

Specified by:
shapeChanged in interface CurveShapeListener
Parameters:
cs - the curve

shapeDataChanged

public void shapeDataChanged(CurveShape cs,
                             DataSource oldData,
                             DataSource newData,
                             boolean onX)
Description copied from interface: CurveShapeListener
This function is called when one of the data displayed by the curve is replaced

Specified by:
shapeDataChanged in interface CurveShapeListener
Parameters:
cs - the curve
oldData - the old data
newData - the new data

shapeChanged

public void shapeChanged(AbstractShape shape,
                         java.awt.Rectangle changedArea)
Specified by:
shapeChanged in interface ShapeListener

updateCurveInformation

public void updateCurveInformation()

isOptimize

public boolean isOptimize()
Returns:
boolean

setOptimize

public void setOptimize(boolean optimize)
Sets the optimize.

Parameters:
optimize - The optimize 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