uk.ac.starlink.ast.gui
Class AbstractPlotControlsModel

java.lang.Object
  extended by uk.ac.starlink.ast.gui.AbstractPlotControlsModel
All Implemented Interfaces:
XMLEncodeDecode
Direct Known Subclasses:
AstAxes, AstAxisLabels, AstBorder, AstGrid, AstNumberLabels, AstStrings, AstTicks, AstTitle, ColourStore, GraphicsEdges, GraphicsHints

public abstract class AbstractPlotControlsModel
extends Object
implements XMLEncodeDecode

This abstract class provides a default implementation for a XMLEncodeDecode. An AbstractPlotControlsModel provides backing store for the state of some controls that define properties that are related to a Plot. The state of the model can be saved and restored from an XML description.

This implementation also provides default implementations of Changelistener methods that allow the model to register, respond and issue ChangeEvents. It also forces any sub-classes to provide methods for encoding and decoding their internal configurations as XML Elements so that they can be written-to and restored-from permanent store.

Version:
$Id$
Author:
Peter W. Draper
See Also:
XMLEncodeDecode, ChangeEvent, ChangeListener

Field Summary
protected  EventListenerList listeners
           
 
Constructor Summary
AbstractPlotControlsModel()
           
 
Method Summary
 void addChangeListener(ChangeListener l)
          Registers a listener who wants to be informed about changes.
protected  void addChildElement(Element rootElement, String name, boolean value)
          Add an element with boolean value as a child of another element.
protected  void addChildElement(Element rootElement, String name, Color value)
          Add an element with Color value as a child of another element.
protected  void addChildElement(Element rootElement, String name, double value)
          Add an element with double value as a child of another element.
protected  void addChildElement(Element rootElement, String name, Font value)
          Add an element with Font value as a child of another element.
protected  void addChildElement(Element rootElement, String name, int value)
          Add an element with integer value as a child of another element.
protected  void addChildElement(Element rootElement, String name, String value)
          Add an element with String value as a child of another element.
protected  boolean booleanFromString(String value)
          Convert a String back to a boolean.
protected  String booleanToString(boolean value)
          Convert a boolean to a String.
protected  Color colorFromString(String value)
          Convert a String object back to a Color object.
protected  String colorToString(Color value)
          Convert a Color object to a string.
 void decode(Element rootElement)
          Decode (ie, restore) the internal state of this object from an Element.
protected  double doubleFromString(String value)
          Convert a String back to a double.
protected  String doubleToString(double value)
          Convert a double to a String.
abstract  void encode(Element rootElement)
          Encode the internal state of this object so that it is rooted in the given Element.
protected  void fireChanged()
          Send ChangeEvent event to all listeners, if listening.
protected  Font fontFromString(String value)
          Convert a String back to a Font.
protected  String fontToString(Font value)
          Convert a Font to a string.
protected  NodeList getChildren(Element rootElement)
          Return a List of all children.
protected  String getElementName(Element element)
          Get the name of an element.
protected  String getElementValue(Element element)
          Get the "value" of an element (really the content).
protected  int intFromString(String value)
          Convert a String back to an integer.
protected  String intToString(int value)
          Convert an integer to a String.
protected  long longFromString(String value)
          Convert a String back to a long.
protected  String longToString(long value)
          Convert a long to a String.
 void removeChangeListener(ChangeListener l)
          De-registers a listener for changes.
abstract  void setFromString(String name, String value)
          Set the value of a object field using string representation of the field name and its value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface uk.ac.starlink.util.XMLEncodeDecode
getTagName
 

Field Detail

listeners

protected EventListenerList listeners
Constructor Detail

AbstractPlotControlsModel

public AbstractPlotControlsModel()
Method Detail

addChangeListener

public void addChangeListener(ChangeListener l)
Registers a listener who wants to be informed about changes.

Parameters:
l - the ChangeListener listener.

removeChangeListener

public void removeChangeListener(ChangeListener l)
De-registers a listener for changes.

Parameters:
l - the ChangeListener listener.

fireChanged

protected void fireChanged()
Send ChangeEvent event to all listeners, if listening.


encode

public abstract 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.

setFromString

public abstract void setFromString(String name,
                                   String value)
Set the value of a object field using string representation of the field name and its value. Users of the default decode implementation must re-implement this method.


addChildElement

protected void addChildElement(Element rootElement,
                               String name,
                               String value)
Add an element with String value as a child of another element. The String is stored as CDATA.


addChildElement

protected void addChildElement(Element rootElement,
                               String name,
                               boolean value)
Add an element with boolean value as a child of another element.


addChildElement

protected void addChildElement(Element rootElement,
                               String name,
                               int value)
Add an element with integer value as a child of another element.


addChildElement

protected void addChildElement(Element rootElement,
                               String name,
                               double value)
Add an element with double value as a child of another element.


addChildElement

protected void addChildElement(Element rootElement,
                               String name,
                               Color value)
Add an element with Color value as a child of another element.


addChildElement

protected void addChildElement(Element rootElement,
                               String name,
                               Font value)
Add an element with Font value as a child of another element.


getChildren

protected NodeList getChildren(Element rootElement)
Return a List of all children. Use the List interface to step through these.


getElementName

protected String getElementName(Element element)
Get the name of an element.


getElementValue

protected String getElementValue(Element element)
Get the "value" of an element (really the content).


fontToString

protected String fontToString(Font value)
Convert a Font to a string.


fontFromString

protected Font fontFromString(String value)
Convert a String back to a Font.


doubleToString

protected String doubleToString(double value)
Convert a double to a String.


doubleFromString

protected double doubleFromString(String value)
Convert a String back to a double.


booleanToString

protected String booleanToString(boolean value)
Convert a boolean to a String.


booleanFromString

protected boolean booleanFromString(String value)
Convert a String back to a boolean.


intToString

protected String intToString(int value)
Convert an integer to a String.


intFromString

protected int intFromString(String value)
Convert a String back to an integer.


longToString

protected String longToString(long value)
Convert a long to a String.


longFromString

protected long longFromString(String value)
Convert a String back to a long.


colorToString

protected String colorToString(Color value)
Convert a Color object to a string.


colorFromString

protected Color colorFromString(String value)
Convert a String object back to a Color object.



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