jsynoptic.builtin
Class TextArrayShape

java.lang.Object
  extended by simtools.shapes.AbstractShape
      extended by jsynoptic.builtin.TextArrayShape
All Implemented Interfaces:
java.awt.Shape, java.io.Serializable, java.lang.Cloneable, ContextualActionProvider, DataSourceConsumer, Linkable, EndNotificationListener, Resizable, NamedProperties
Direct Known Subclasses:
HistoryShape

public class TextArrayShape
extends AbstractShape
implements Resizable, ContextualActionProvider, Linkable, EndNotificationListener, DataSourceConsumer

An array of text shapes

See Also:
Serialized Form

Nested Class Summary
static class TextArrayShape.TextArrayShapePropertiesNames
           
 
Nested classes/interfaces inherited from class simtools.shapes.AbstractShape
AbstractShape.AbstractShapePropertiesNames
 
Field Summary
protected  java.util.Vector cells
          The array cells are of type TextShape
protected  boolean forceSameFont
           
protected  java.lang.String link
           
static java.util.ResourceBundle resources
           
 
Fields inherited from class simtools.shapes.AbstractShape
_h, _ox, _oy, _propertyNames, _w, _x, _y, ANTI_ALIASING, currentDialogBox, FONT_NAMES, listeners, REFRESH_PERIOD
 
Fields inherited from interface jsynoptic.base.ContextualActionProvider
EDITOR_CONTEXT, MOUSE_OUT_CONTEXT, MOUSE_OVER_CONTEXT, MOUSE_PRESSED_CONTEXT, SHAPELIST_CONTEXT, SOURCELIST_CONTEXT
 
Constructor Summary
protected TextArrayShape()
          For subclasses to override.
  TextArrayShape(java.lang.String text, int width, int height)
           
  TextArrayShape(java.lang.String text, int ox, int oy, int width, int height)
          Construct a new text array with the given size, and only one cell with the given text.
 
Method Summary
 boolean addDataSource(DataSource d)
           
 boolean canAddDataSource(DataSource d)
           
 boolean canDoAction(double x, double y, java.lang.Object o, java.lang.String action, int context)
          Returns true if, and only if, it is possible to do the action right now
protected  AbstractShape cloneShape()
          Performs a copy of the shape This method has to be overriden to deal with concrete shapes
 JPropertiesPanel createPanel()
           
protected  TextShape createTextShape(java.lang.String name, int width, int height)
          By overwriting this method, it is possible to create different kind of text cells
 boolean doAction(double x, double y, java.lang.Object o, java.lang.String action, javax.swing.undo.CompoundEdit undoableEdit)
          Do one of the actions previously declared by getAction.
 void draw(java.awt.Graphics2D g)
          Draws the shape
 java.lang.String[] getActions(double x, double y, java.lang.Object o, int context)
          Return list of possible actions the contect information may be used, or not.
 java.util.Vector getCells()
           
 java.lang.String getLink()
           
 java.lang.String[] getPropertyNames()
          Get the list of property names
 java.lang.Object getPropertyValue(java.lang.String name)
          Get the value of the property named name
 void notificationEnd(java.lang.Object referer)
          This callback is called after all notifications were processed.
protected  void positionCells()
          This function supposes dimensions are correct, it will not check that Also, it does not notify changes.
 void resize(int dx, int dy)
          Resize the component
 void setAnchor(int ox, int oy)
           
 void setCells(java.util.Vector cellsProperties)
           
 void setLink(java.lang.String link)
           
 void setPropertyValue(java.lang.String name, java.lang.Object value)
          Assigns value to the property named name
 void translate(int dx, int dy)
          Translates the shape
 void unifyFonts()
          Unify the fonts of all the text shapes, so they have a common font.
 
Methods inherited from class simtools.shapes.AbstractShape
addListener, contains, contains, contains, contains, getAnchor, getBounds, getBounds2D, getInnerProperties, getMax, getMaxTranslated, getMin, getPathIterator, getPathIterator, intersects, intersects, notifyChange, notifyChange, refresh, removeListener, setAnchor, setProperties, wipeOff
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resources

public static java.util.ResourceBundle resources

link

protected java.lang.String link

cells

protected java.util.Vector cells
The array cells are of type TextShape


forceSameFont

protected boolean forceSameFont
Constructor Detail

TextArrayShape

protected TextArrayShape()
For subclasses to override. Does nothing


TextArrayShape

public TextArrayShape(java.lang.String text,
                      int width,
                      int height)

TextArrayShape

public TextArrayShape(java.lang.String text,
                      int ox,
                      int oy,
                      int width,
                      int height)
Construct a new text array with the given size, and only one cell with the given text.

Method Detail

getLink

public java.lang.String getLink()
Specified by:
getLink in interface Linkable

setLink

public void setLink(java.lang.String link)
Specified by:
setLink in interface Linkable

getCells

public java.util.Vector getCells()
Returns:
Returns the cells.

translate

public void translate(int dx,
                      int dy)
Description copied from class: AbstractShape
Translates the shape

Overrides:
translate in class AbstractShape

setAnchor

public void setAnchor(int ox,
                      int oy)
Overrides:
setAnchor in class AbstractShape

draw

public void draw(java.awt.Graphics2D g)
Description copied from class: AbstractShape
Draws the shape

Specified by:
draw in class AbstractShape
Parameters:
g - the graphics context

unifyFonts

public void unifyFonts()
Unify the fonts of all the text shapes, so they have a common font.


positionCells

protected void positionCells()
This function supposes dimensions are correct, it will not check that Also, it does not notify changes.


resize

public void resize(int dx,
                   int dy)
Description copied from interface: Resizable
Resize the component

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

getActions

public java.lang.String[] getActions(double x,
                                     double y,
                                     java.lang.Object o,
                                     int context)
Description copied from interface: ContextualActionProvider
Return list of possible actions the contect information may be used, or not.

Specified by:
getActions in interface ContextualActionProvider
Parameters:
x - Coordinate, mouse position in the same unit as contains(x,y)
y - Coordinate, mouse position in the same unit as contains(x,y)
o - Object the actions should work on. Possibly null => default or all actions
context - one of the context defined in the ContextualActionProvider class
Returns:
The list of possible actions, possibly null or an empty array

doAction

public boolean doAction(double x,
                        double y,
                        java.lang.Object o,
                        java.lang.String action,
                        javax.swing.undo.CompoundEdit undoableEdit)
Description copied from interface: ContextualActionProvider
Do one of the actions previously declared by getAction.

Specified by:
doAction in interface ContextualActionProvider
Parameters:
x - Coordinate, for example mouse position
y - Coordinate, for example mouse position
o - Object the action should work on.
action - An action returned by a previous getActions call with the same x, y, o parameters It may be null, in which case the default action is requested for this x,y,o.
undoableEdit - current edit for undo/redo operation If not null, this action is undoable.
Returns:
true if the action could be performed

createPanel

public JPropertiesPanel createPanel()

canDoAction

public boolean canDoAction(double x,
                           double y,
                           java.lang.Object o,
                           java.lang.String action,
                           int context)
Description copied from interface: ContextualActionProvider
Returns true if, and only if, it is possible to do the action right now

Specified by:
canDoAction in interface ContextualActionProvider
Parameters:
x - Coordinate, for example mouse position
y - Coordinate, for example mouse position
o - Object the action should work on.
action - An action returned by a previous getActions call with the same x, y, o parameters It may be null, in which case the default action is requested for this x,y,o.
context - one of the context defined in the ContextualActionProvider class
Returns:
true if the action can be performed

createTextShape

protected TextShape createTextShape(java.lang.String name,
                                    int width,
                                    int height)
By overwriting this method, it is possible to create different kind of text cells

Parameters:
name -
width -
height -
Returns:
a text shape belonging to text array

addDataSource

public boolean addDataSource(DataSource d)
Specified by:
addDataSource in interface DataSourceConsumer
Parameters:
d - the data source to be added
Returns:
true if operation succeeds

setCells

public void setCells(java.util.Vector cellsProperties)

canAddDataSource

public boolean canAddDataSource(DataSource d)
Specified by:
canAddDataSource in interface DataSourceConsumer
Parameters:
d - the data source to be added
Returns:
true if operation can be be performed

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

setPropertyValue

public void setPropertyValue(java.lang.String name,
                             java.lang.Object value)
Description copied from class: AbstractShape
Assigns value to the property named name

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

getPropertyValue

public java.lang.Object getPropertyValue(java.lang.String name)
Description copied from class: AbstractShape
Get the value of the property named name

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

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
Overrides:
getPropertyNames in class AbstractShape