jsynoptic.builtin
Class ImageShape

java.lang.Object
  extended by simtools.shapes.AbstractShape
      extended by jsynoptic.builtin.Abstract1DShape
          extended by jsynoptic.builtin.ImageShape
All Implemented Interfaces:
java.awt.Shape, java.io.Serializable, java.lang.Cloneable, ContextualActionProvider, Linkable, SelectionContextualActionProvider, AffineTransformData.Listener, DataSourceListener, EndNotificationListener, Resizable, NamedProperties

public class ImageShape
extends Abstract1DShape

An image shape will draw an image (how suprising!) It can also draw a dynamic colored frame, and change the image displayed dynamically according to data values.

See Also:
Serialized Form

Nested Class Summary
static class ImageShape.ImageShapePropertiesNames
           
 
Nested classes/interfaces inherited from class jsynoptic.builtin.Abstract1DShape
Abstract1DShape.Abstract1DShapePropertiesNames
 
Nested classes/interfaces inherited from class simtools.shapes.AbstractShape
AbstractShape.AbstractShapePropertiesNames
 
Field Summary
protected  boolean autoFit
          If the image should be scaled to fit the shape size (autoFit true), else the shape will be resized
protected  java.io.File currentFile
           
protected  java.lang.String currentFileRelativePath
          The relative path to the file is serialized
protected  boolean dirtyImage
           
protected  java.awt.image.BufferedImage dynamicImage
           
protected  java.awt.image.BufferedImage image
           
protected  long index
           
protected  ImageMapper mapper
           
static BasicMessageWriter messageWriter
           
static java.util.ResourceBundle resources
           
protected  DataSource source
           
 
Fields inherited from class jsynoptic.builtin.Abstract1DShape
allowResize, bounds2D, delegateEndNotificationListener, dirty, dirtyDrawColor, dirtyRectangle, drawColor, drawDynamicColor, drawMapper, drawMapperIndex, drawMapperSource, fixedRatio, link, MIN_SIZE, ratio, stroke, strokeParams, transform
 
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
ImageShape(java.io.File f, int ox, int oy)
           
ImageShape(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
 JPropertiesPanel createPanel()
           
 void DataSourceIndexRangeChanged(DataSource ds, long startIndex, long lastIndex)
          Called when the range of valid index 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.
protected  void drawHook(java.awt.Graphics2D g, boolean shapeDrawn)
          For subclasses, called before restoring original graphics properties, after the delegate shape is drawn if shapeDrawn is true, or after saving the current context, before the delegate shape is drawn if shapeDrawn is false
protected  java.awt.Shape getDelegateShape()
           
protected  java.awt.image.BufferedImage getDynamicImage()
           
 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
protected  java.lang.Object getSourceValue()
           
 boolean isAutoFit()
          If the image should be scaled to fit the shape size (autoFit true), else the shape will be resized
 void notificationEnd(java.lang.Object referer)
          This callback is called after all notifications were processed.
protected  void resheshImage()
          Get current dynamic image and repaint shape when necessay
 void setAutoFit(boolean autoFit)
          If the image should be scaled to fit the shape size (autoFit true), else the shape will be resized
 void setPropertyValue(java.lang.String name, java.lang.Object value)
          Assigns value to the property named name
 void wipeOff()
          Wipe-off all all buffered resources in order to refresh shape.
 
Methods inherited from class jsynoptic.builtin.Abstract1DShape
canDoAction, canResize, contains, contains, contains, contains, createPanel, DataSourceInfoChanged, DataSourceOrderChanged, DataSourceValueRangeChanged, doAction, doCollectiveAction, draw, getActions, getBounds, getBounds2D, getCollectiveActions, getDelegateEndNotificationListener, getDrawColor, getDx, getDy, getLink, getPathIterator, getPathIterator, intersects, intersects, resize, setAnchor, setDelegateEndNotificationListener, setLink, translate, updateBounds, updateTransform
 
Methods inherited from class simtools.shapes.AbstractShape
addListener, getAnchor, getInnerProperties, getMax, getMaxTranslated, getMin, notifyChange, notifyChange, refresh, removeListener, setAnchor, setProperties
 
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

messageWriter

public static BasicMessageWriter messageWriter

image

protected transient java.awt.image.BufferedImage image

dynamicImage

protected transient java.awt.image.BufferedImage dynamicImage

mapper

protected ImageMapper mapper

source

protected transient DataSource source

index

protected transient long index

dirtyImage

protected transient boolean dirtyImage

currentFile

protected transient java.io.File currentFile

currentFileRelativePath

protected java.lang.String currentFileRelativePath
The relative path to the file is serialized


autoFit

protected boolean autoFit
If the image should be scaled to fit the shape size (autoFit true), else the shape will be resized

Constructor Detail

ImageShape

public ImageShape(java.io.File f,
                  int ox,
                  int oy)

ImageShape

public ImageShape(int ox,
                  int oy,
                  int width,
                  int height)
Parameters:
ox -
oy -
width -
height -
Method Detail

isAutoFit

public boolean isAutoFit()
If the image should be scaled to fit the shape size (autoFit true), else the shape will be resized


setAutoFit

public void setAutoFit(boolean autoFit)
If the image should be scaled to fit the shape size (autoFit true), else the shape will be resized


getDelegateShape

protected java.awt.Shape getDelegateShape()
Specified by:
getDelegateShape in class Abstract1DShape

cloneShape

protected AbstractShape cloneShape()
Description copied from class: Abstract1DShape
Performs a copy of the shape This method has to be overriden to deal with concrete shapes

Overrides:
cloneShape in class Abstract1DShape
Returns:
a copy of the shape

drawHook

protected void drawHook(java.awt.Graphics2D g,
                        boolean shapeDrawn)
Description copied from class: Abstract1DShape
For subclasses, called before restoring original graphics properties, after the delegate shape is drawn if shapeDrawn is true, or after saving the current context, before the delegate shape is drawn if shapeDrawn is false

Overrides:
drawHook in class Abstract1DShape

createPanel

public JPropertiesPanel createPanel()
Overrides:
createPanel in class Abstract1DShape

resheshImage

protected void resheshImage()
Get current dynamic image and repaint shape when necessay. - If dynamic image has changed and is not null -> display this dynamic image - If dynamic image is null but previous dynamic image was not null -> display default image - Otherwise no repaint is performed


getSourceValue

protected java.lang.Object getSourceValue()
                                   throws DataException
Returns:
Throws:
DataException

getDynamicImage

protected java.awt.image.BufferedImage getDynamicImage()
Returns:
a BufferedImage that matches with mapped data source value or null if not match found

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
Overrides:
notificationEnd in class Abstract1DShape

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
Overrides:
DataSourceIndexRangeChanged in class Abstract1DShape
Parameters:
ds - The data source that changed
startIndex - The new start Index
lastIndex - The new last index

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
Overrides:
DataSourceValueChanged in class Abstract1DShape
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

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
Overrides:
DataSourceReplaced in class Abstract1DShape

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 Abstract1DShape
Parameters:
name - the name of the property to get
Returns:
the property value
See Also:
AbstractShape.getPropertyValue(String)

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 Abstract1DShape
Parameters:
name - the name of the property to get
value - its new value
See Also:
AbstractShape.setPropertyValue(String, Object)

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 Abstract1DShape

wipeOff

public void wipeOff()
Description copied from class: AbstractShape
Wipe-off all all buffered resources in order to refresh shape. This is overloaded by the various subclasses when necessary. For example, a image shape shall wipe-off all its buffered images

Overrides:
wipeOff in class AbstractShape