uk.ac.starlink.diva
Class FigureProps

java.lang.Object
  extended by uk.ac.starlink.diva.FigureProps
All Implemented Interfaces:
XMLEncodeDecode
Direct Known Subclasses:
AstFigureProps

public class FigureProps
extends Object
implements XMLEncodeDecode

A container class for storing the configuration properties of Figures created by DrawFigureFactory. Also provides facilities for creating a serialized version of the properties (so that the Figure can be re-created) in XML.

Version:
$Id$
Author:
Peter W. Draper
See Also:
Draw, DrawFigureFactory, DrawActions

Field Summary
protected  InterpolatorFactory interpolatorFactory
          The InterpolatorFactory reference.
 
Constructor Summary
FigureProps()
          Default constructor.
FigureProps(double x1, double y1, double width, double height)
          Constructor that provides enough information to describe a rectangle.
FigureProps(double x1, double y1, double width, double height, double x2, double y2, Paint outline, Paint fill)
          Constructor that provides enough information to describe a rectangle, with other colour.
FigureProps(double x1, double y1, double width, double height, Paint outline)
          Constructor that provides enough information to describe a rectangle.
FigureProps(double x1, double y1, String text, Font font, Paint outline)
          Constructor that provides enough information to describe a text String.
FigureProps(FigureProps props)
          Copy constructor.
FigureProps(Interpolator interpolator, double x1, double y1, Paint outline, double thickness)
          Constructor that provides enough information to describe an interpolated curve.
 
Method Summary
 void copy(FigureProps props)
          Copy all items from another instance.
 void decode(Element rootElement)
          Decode (ie, restore) the internal state of this object from an Element.
protected  double[] decodeBase64DoubleArray(int size, String base64)
          Decode an array of double stored in a base64 string.
 void encode(Element rootElement)
          Encode the internal state of this object so that it is rooted in the given Element.
protected  String encodeBase64DoubleArray(double[] array)
          Encode an array of doubles as a base64 string.
 AlphaComposite getComposite()
          Get the AlphaComposite.
 Paint getFill()
          Get the value of fill
 Font getFont()
          Get the Font.
 double getHeight()
          Get the value of height
 Interpolator getInterpolator()
          Get the value of interpolator.
 Paint getOutline()
          Get the value of outline
 String getTagName()
          Return a name for the Element that will be the parent of any contents that can be encoded and decoded (ie, name of rootElement);
 String getText()
          Get the Text.
 double getThickness()
          Get the value of thickness.
 int getType()
          Get the type of figure.
 double getWidth()
          Get the value of width
 double getX1()
          Get the value of x1
 double getX2()
          Get the value of x2.
 double[] getXArray()
          Get the array of X coordinates.
 double getY1()
          Get the value of y1
 double getY2()
          Get the value of y2.
 double[] getYArray()
          Get the array of Y coordinates.
protected  void readInterpolator(Element element)
          Read a stored interpolator from the given Element.
 void reset()
          Reset all items to their defaults.
 void setComposite(AlphaComposite composite)
          Set the AlphaComposite to use when drawing the figure.
 void setFill(Paint fill)
          Set the value of fill
 void setFont(Font font)
          Set the Font use together with the text String.
 void setFromString(String name, String value, Element element)
          Set the value of a member variable by matching its name to a known local property string.
 void setHeight(double height)
          Set the value of height
 void setInterpolator(Interpolator interpolator)
          Set the value of interpolator.
 void setOutline(Paint outline)
          Set the value of outline
 void setText(String text)
          Set the text Text.
 void setThickness(double thickness)
          Set the value of thickness.
 void setType(int type)
          Set the type of figure.
 void setType(String type)
          Set the type of figure using a symbolic name.
 void setWidth(double width)
          Set the value of width
 void setX1(double x1)
          Set the value of x1.
 void setX2(double x2)
          Set the value of x2.
 void setXArray(double[] xa)
          Set the array of X coordinates.
 void setY1(double y1)
          Set the value of y1.
 void setY2(double y2)
          Set the value of y2.
 void setYArray(double[] ya)
          Set the array of Y coordinates.
 String toString()
           
protected  void writeInterpolator(Element element)
          Write description of the interpolator to the given Element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

interpolatorFactory

protected InterpolatorFactory interpolatorFactory
The InterpolatorFactory reference.

Constructor Detail

FigureProps

public FigureProps()
Default constructor. All items keep their default values.


FigureProps

public FigureProps(FigureProps props)
Copy constructor.


FigureProps

public FigureProps(double x1,
                   double y1,
                   double width,
                   double height)
Constructor that provides enough information to describe a rectangle.


FigureProps

public FigureProps(double x1,
                   double y1,
                   double width,
                   double height,
                   Paint outline)
Constructor that provides enough information to describe a rectangle.


FigureProps

public FigureProps(double x1,
                   double y1,
                   double width,
                   double height,
                   double x2,
                   double y2,
                   Paint outline,
                   Paint fill)
Constructor that provides enough information to describe a rectangle, with other colour.


FigureProps

public FigureProps(Interpolator interpolator,
                   double x1,
                   double y1,
                   Paint outline,
                   double thickness)
Constructor that provides enough information to describe an interpolated curve.


FigureProps

public FigureProps(double x1,
                   double y1,
                   String text,
                   Font font,
                   Paint outline)
Constructor that provides enough information to describe a text String.

Method Detail

reset

public void reset()
Reset all items to their defaults.


copy

public void copy(FigureProps props)
Copy all items from another instance.


getType

public int getType()
Get the type of figure.

Returns:
the type of figure, -1 if not set, otherwise a constant from DrawFigureFactory.

setType

public void setType(int type)
Set the type of figure.

Parameters:
type - the type of figure, one of the constants from DrawFigureFactory.

setType

public void setType(String type)
Set the type of figure using a symbolic name.

Parameters:
type - the type of figure, one of the values from shortName of DrawFigureFactory.

getX1

public double getX1()
Get the value of x1

Returns:
value of x1.

setX1

public void setX1(double x1)
Set the value of x1.

Parameters:
x1 - Value to assign to x1.

getY1

public double getY1()
Get the value of y1

Returns:
value of y1

setY1

public void setY1(double y1)
Set the value of y1.

Parameters:
y1 - Value to assign to y1.

getX2

public double getX2()
Get the value of x2.

Returns:
value of x2.

setX2

public void setX2(double x2)
Set the value of x2.

Parameters:
x2 - Value to assign to x2.

getY2

public double getY2()
Get the value of y2.

Returns:
value of y2.

setY2

public void setY2(double y2)
Set the value of y2.

Parameters:
y2 - Value to assign to y2.

getXArray

public double[] getXArray()
Get the array of X coordinates.

Returns:
array of X coordinates.

setXArray

public void setXArray(double[] xa)
Set the array of X coordinates.


getYArray

public double[] getYArray()
Get the array of Y coordinates.

Returns:
array of Y coordinates.

setYArray

public void setYArray(double[] ya)
Set the array of Y coordinates.


getWidth

public double getWidth()
Get the value of width

Returns:
value of width.

setWidth

public void setWidth(double width)
Set the value of width

Parameters:
width - Value to assign to xLength.

getHeight

public double getHeight()
Get the value of height

Returns:
value of height.

setHeight

public void setHeight(double height)
Set the value of height

Parameters:
height - Value to assign to height

getOutline

public Paint getOutline()
Get the value of outline

Returns:
value of outline.

setOutline

public void setOutline(Paint outline)
Set the value of outline

Parameters:
outline - Value to assign to outline

getFill

public Paint getFill()
Get the value of fill

Returns:
value of fill

setFill

public void setFill(Paint fill)
Set the value of fill

Parameters:
fill - Value to assign to fill

getInterpolator

public Interpolator getInterpolator()
Get the value of interpolator.

Returns:
value of interpolator.

setInterpolator

public void setInterpolator(Interpolator interpolator)
Set the value of interpolator.

Parameters:
interpolator - Value to assign to interpolator.

getThickness

public double getThickness()
Get the value of thickness.

Returns:
value of thickness

setThickness

public void setThickness(double thickness)
Set the value of thickness.

Parameters:
thickness - Value to assign to thickness.

getText

public String getText()
Get the Text.

Returns:
value of text

setText

public void setText(String text)
Set the text Text.

Parameters:
text - Value to assign to text.

getFont

public Font getFont()
Get the Font.

Returns:
value of font

setFont

public void setFont(Font font)
Set the Font use together with the text String.

Parameters:
font - Value to assign to font.

getComposite

public AlphaComposite getComposite()
Get the AlphaComposite.

Returns:
value of composite

setComposite

public void setComposite(AlphaComposite composite)
Set the AlphaComposite to use when drawing the figure.

Parameters:
composite - Value to assign to composite.

toString

public String toString()
Overrides:
toString in class Object

encode

public void encode(Element rootElement)
Description copied from interface: XMLEncodeDecode
Encode the internal state of this object so that it is rooted in the given Element.

Specified by:
encode in interface XMLEncodeDecode
Parameters:
rootElement - the Element within which the object should store its configuration.

decode

public void decode(Element rootElement)
Description copied from interface: XMLEncodeDecode
Decode (ie, restore) the internal state of this object from an Element.

Specified by:
decode in interface XMLEncodeDecode
Parameters:
rootElement - the element to which a previous object this this type has attached its configuration.

getTagName

public String getTagName()
Description copied from interface: XMLEncodeDecode
Return a name for the Element that will be the parent of any contents that can be encoded and decoded (ie, name of rootElement);

Specified by:
getTagName in interface XMLEncodeDecode
Returns:
the name of the root element.

setFromString

public void setFromString(String name,
                          String value,
                          Element element)
Set the value of a member variable by matching its name to a known local property string.


readInterpolator

protected void readInterpolator(Element element)
Read a stored interpolator from the given Element. base64enc base64enc


writeInterpolator

protected void writeInterpolator(Element element)
Write description of the interpolator to the given Element. base64enc base64enc


decodeBase64DoubleArray

protected double[] decodeBase64DoubleArray(int size,
                                           String base64)
Decode an array of double stored in a base64 string.


encodeBase64DoubleArray

protected String encodeBase64DoubleArray(double[] array)
Encode an array of doubles as a base64 string.



Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.