simtools.ui
Class ColorMapper

java.lang.Object
  extended by simtools.ui.GenericMapper
      extended by simtools.ui.ColorMapper
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class ColorMapper
extends GenericMapper

This class maps data sources and index to colors. The mapping is user defined, and based for example on the value of the data source For example, green value < 10, red above. Useful for making plots with "alarm" colors The data source shall not be saved into the object. Rather, this class goal is to implement a mapping independent of the data source given.

See Also:
Serialized Form

Nested Class Summary
protected static class ColorMapper.ColorEditor
           
protected  class ColorMapper.ColorMapperTableModel
           
protected  class ColorMapper.ColorMappingTable
           
protected static class ColorMapper.ColorRenderer
           
 
Nested classes/interfaces inherited from class simtools.ui.GenericMapper
GenericMapper.Expression, GenericMapper.ExpressionDialog, GenericMapper.ExpressionEditor, GenericMapper.ExpressionMappingTable, GenericMapper.Interval, GenericMapper.MapperTableModel
 
Field Summary
static int BRIGHTNESS_CYCLE
           
static int COLOR_CYCLE
          The default colors cycle between COLOR_CYCLE different hues, and SATURATION_CYCLE different SATURATION levels.
static java.util.Vector colorMappers
          The color mappers are application global
protected static int defaultColorIndex
           
static java.util.ResourceBundle resources
           
static int SATURATION_CYCLE
           
 
Fields inherited from class simtools.ui.GenericMapper
defaultValue, intervals, listeners, map, name
 
Constructor Summary
ColorMapper()
           
ColorMapper(java.lang.String name)
           
 
Method Summary
static ColorMapper createColorMapperDialog(javax.swing.JDialog owner)
           
 GenericMapper.MapperTableModel createModel()
           
protected  java.lang.Object createNewValue()
          For subclasses to specialize, create a new object of the specialized type
protected  GenericMapper.ExpressionMappingTable createTable(javax.swing.JDialog parent)
          For subclasses to specialize
static ColorMapper getColorMapper(java.lang.String id)
           
 java.awt.Paint getDefaultPaint()
           
 java.awt.Paint getPaint(DataSource ds)
          Realizes the mapping, and returns a Paint object for this data source and index
 java.awt.Paint getPaint(DataSource ds, long index)
          Realizes the mapping, and returns a Paint object for this data source and index
 java.awt.Paint getPaint(java.lang.Object value)
           
static void main(java.lang.String[] args)
           
 void setDefaultPaint(java.awt.Paint defaultValue)
           
 void setPaint(boolean isMore, double value, boolean boundIncluded, java.awt.Paint paint)
          Associate a paint with a double value infinite range.
 void setPaint(boolean isMore, double value, java.awt.Paint paint)
          Associate a paint with a double value infinite range (bound included).
 void setPaint(boolean isMore, long value, boolean boundIncluded, java.awt.Paint paint)
          Associate a paint with a long value infinite range.
 void setPaint(boolean isMore, long value, java.awt.Paint paint)
          Associate a paint with a long value infinite range (bound included).
 void setPaint(boolean isMore, java.lang.String value, boolean boundIncluded, java.awt.Paint paint)
          Associate a paint with a String value infinite range.
 void setPaint(boolean isMore, java.lang.String value, java.awt.Paint paint)
          Associate a paint with a String value infinite range (bound included).
 void setPaint(double minvalue, boolean boundedMin, double maxvalue, boolean boundedMax, java.awt.Paint paint)
          Associate a paint with a double value interval.
 void setPaint(double minvalue, double maxvalue, java.awt.Paint paint)
          Associate a paint with a double value interval (bounds included)
 void setPaint(long minvalue, boolean boundedMin, long maxvalue, boolean boundedMax, java.awt.Paint paint)
          Associate a paint with a long value interval.
 void setPaint(long minvalue, long maxvalue, java.awt.Paint paint)
          Associate a paint with a long value interval (bounds included)
 void setPaint(java.lang.Object value, java.awt.Paint paint)
          Associate a paint with a value
 void setPaint(java.lang.String minvalue, boolean boundedMin, java.lang.String maxvalue, boolean boundedMax, java.awt.Paint paint)
          Associate a paint with a String value interval.
 void setPaint(java.lang.String minvalue, java.lang.String maxvalue, java.awt.Paint paint)
          Associate a paint with a String value interval (bounds included)
static ColorMapper updateColorMapper(ColorMapper m)
          If the mapper already exists in the list, update its values Otherwise add it to the list of existing mappers
 
Methods inherited from class simtools.ui.GenericMapper
addListener, clone, createMapperDialog, createPanel, editDialog, equals, getAllMapperValues, getDefaultValue, getIntervals, getMap, getMapping, getMapping, getMapping, notifyListeners, removeListener, setDefaultValue, setMapperValues, setMapping, setMapping, setMapping, setMapping, setMapping, setMapping, setMapping, setMapping, setMapping, setMapping, setMapping, setMapping, setMapping, setName, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

resources

public static java.util.ResourceBundle resources

COLOR_CYCLE

public static final int COLOR_CYCLE
The default colors cycle between COLOR_CYCLE different hues, and SATURATION_CYCLE different SATURATION levels.

See Also:
Constant Field Values

SATURATION_CYCLE

public static final int SATURATION_CYCLE
See Also:
Constant Field Values

BRIGHTNESS_CYCLE

public static final int BRIGHTNESS_CYCLE
See Also:
Constant Field Values

defaultColorIndex

protected static int defaultColorIndex

colorMappers

public static java.util.Vector colorMappers
The color mappers are application global

Constructor Detail

ColorMapper

public ColorMapper()

ColorMapper

public ColorMapper(java.lang.String name)
Method Detail

updateColorMapper

public static ColorMapper updateColorMapper(ColorMapper m)
If the mapper already exists in the list, update its values Otherwise add it to the list of existing mappers

Parameters:
m, - the mapper to update
Returns:

getColorMapper

public static ColorMapper getColorMapper(java.lang.String id)
Parameters:
name -
Returns:
returns mapper related to name, or null if no mapper were found

getPaint

public java.awt.Paint getPaint(DataSource ds,
                               long index)
Realizes the mapping, and returns a Paint object for this data source and index

Parameters:
ds - The data source to map
index - The index in the data source (may be used, or not, and defaults to the last Index if not specified).
Returns:
a Paint object

setDefaultPaint

public void setDefaultPaint(java.awt.Paint defaultValue)

getDefaultPaint

public java.awt.Paint getDefaultPaint()

getPaint

public java.awt.Paint getPaint(DataSource ds)
Realizes the mapping, and returns a Paint object for this data source and index

Parameters:
ds - The data source to map
Returns:
a Paint object

getPaint

public java.awt.Paint getPaint(java.lang.Object value)

setPaint

public void setPaint(java.lang.Object value,
                     java.awt.Paint paint)
Associate a paint with a value


setPaint

public void setPaint(double minvalue,
                     double maxvalue,
                     java.awt.Paint paint)
Associate a paint with a double value interval (bounds included)


setPaint

public void setPaint(double minvalue,
                     boolean boundedMin,
                     double maxvalue,
                     boolean boundedMax,
                     java.awt.Paint paint)
Associate a paint with a double value interval. Interval bounds are specified


setPaint

public void setPaint(boolean isMore,
                     double value,
                     java.awt.Paint paint)
Associate a paint with a double value infinite range (bound included).

Parameters:
isMore - if true, the interval is x >= value, else it is x <= value

setPaint

public void setPaint(boolean isMore,
                     double value,
                     boolean boundIncluded,
                     java.awt.Paint paint)
Associate a paint with a double value infinite range.

Parameters:
isMore - if true, the interval is x >= value, else it is x <= value

setPaint

public void setPaint(long minvalue,
                     long maxvalue,
                     java.awt.Paint paint)
Associate a paint with a long value interval (bounds included)


setPaint

public void setPaint(long minvalue,
                     boolean boundedMin,
                     long maxvalue,
                     boolean boundedMax,
                     java.awt.Paint paint)
Associate a paint with a long value interval. Interval bounds are specified


setPaint

public void setPaint(boolean isMore,
                     long value,
                     java.awt.Paint paint)
Associate a paint with a long value infinite range (bound included).

Parameters:
isMore - if true, the interval is x >= value, else it is x <= value

setPaint

public void setPaint(boolean isMore,
                     long value,
                     boolean boundIncluded,
                     java.awt.Paint paint)
Associate a paint with a long value infinite range.

Parameters:
isMore - if true, the interval is x >= value, else it is x <= value

setPaint

public void setPaint(java.lang.String minvalue,
                     java.lang.String maxvalue,
                     java.awt.Paint paint)
Associate a paint with a String value interval (bounds included)


setPaint

public void setPaint(java.lang.String minvalue,
                     boolean boundedMin,
                     java.lang.String maxvalue,
                     boolean boundedMax,
                     java.awt.Paint paint)
Associate a paint with a String value interval. Interval bounds are specified


setPaint

public void setPaint(boolean isMore,
                     java.lang.String value,
                     java.awt.Paint paint)
Associate a paint with a String value infinite range (bound included).

Parameters:
isMore - if true, the interval is x >= value, else it is x <= value

setPaint

public void setPaint(boolean isMore,
                     java.lang.String value,
                     boolean boundIncluded,
                     java.awt.Paint paint)
Associate a paint with a String value infinite range.

Parameters:
isMore - if true, the interval is x >= value, else it is x <= value

createModel

public GenericMapper.MapperTableModel createModel()
Overrides:
createModel in class GenericMapper

createTable

protected GenericMapper.ExpressionMappingTable createTable(javax.swing.JDialog parent)
Description copied from class: GenericMapper
For subclasses to specialize

Overrides:
createTable in class GenericMapper

createNewValue

protected java.lang.Object createNewValue()
Description copied from class: GenericMapper
For subclasses to specialize, create a new object of the specialized type

Overrides:
createNewValue in class GenericMapper

createColorMapperDialog

public static ColorMapper createColorMapperDialog(javax.swing.JDialog owner)

main

public static void main(java.lang.String[] args)