DESY ACOP Beans Home

de.desy.acop.displayers.tools
Class AcopChartConsumer

java.lang.Object
  extended by de.desy.acop.displayers.tools.AcopChartConsumer
All Implemented Interfaces:
DataConsumer, DoubleSeqConsumer

public class AcopChartConsumer
extends java.lang.Object
implements DoubleSeqConsumer

AcopChartConsumer is an implementation of DoubleSeqConsumer which can be used in connection with AcopChart. AcopChartConsumer receives updates from the DataSource and updates the chart accordingly. One consumer can only handle connection to one specific channel.

Version:
$Id: Templates.xml,v 1.10 2004/01/13 16:17:13 jbobnar Exp $
Author:
Jaka Bobnar
See Also:
AcopChart

Field Summary
protected  AcopChart acop
           
protected  int arraySize
           
protected  java.awt.Color color
           
protected  java.lang.Object disable
           
protected  int displayHandle
           
protected  long lastTimestamp
           
protected  int maxNumber
           
protected  java.lang.String name
           
static java.lang.String[] SUPPORTED_CHARACTERISTICS
           
static java.lang.Class[] SUPPORTED_CONSUMER_TYPES
           
protected  int textHandle
           
protected  double[] xData
           
protected  java.lang.String[] xLabels
           
protected  double[] yData
           
 
Constructor Summary
AcopChartConsumer(AcopChart acop, java.lang.String name)
          Constructs new AcopChartConsumer object with the given name.
 
Method Summary
 void destroy()
          Destroys this consumer.
 double[][] dumpData()
          Returns all data from chart.
 AcopChart getAcop()
          Returns the parent chart of this consumer.
 int getArraySize()
          Returns the size of the array that this consumer shows.
 java.awt.Color getColor()
          Returns the color that shows data of this consumer in the chart.
 DataConsumer getDataConsumer(java.lang.Class type)
           Returns data consumer for requested data consumer type.
 DataConsumer getDefaultDataConsumer()
          Returns the implementation of default consumer type supported by this data consumer.
 AcopGraphParameters getDisplayerParameters()
          Returns the AcopGraphParameters associated with this consumer.
 long getLastTimestamp()
          Returns the last timestamp when value was updated.
 java.lang.String getName()
          Returns name of this data consumer.
 double getPreferredYMax()
          Returns the preferred maximum vertical value for this graph.
 double getPreferredYMin()
          Returns the preferred minimum vertical value for this graph.
 java.lang.String[] getSupportedCharacteristics()
          Resturns array with names of supported characteristics.
 java.lang.Class<DataConsumer>[] getSupportedConsumerTypes()
          Returns array of supported data consumer types, which can be used as parameter and returnned with getDataCosnumer(Class) method.
 double[] getXData()
          Returns the horizontal values.
 java.lang.String[] getXLabels()
          Returns the labels of horizontal values.
 double[] getYData()
          Returns the vertical values.
 boolean isTrendChart()
          Returns true if this consumer shows a trend graph.
 void setArraySize(int arraySize)
          Sets the size of the array that this consumer handles with.
 void setCharacteristics(java.util.Map characteristics)
          Sets new dynamic value characteristics to this data consumer.
 void setColor(java.awt.Color color)
          Sets the color that shows data of this consumer in the chart.
 void setDisplayerParameters(AcopGraphParameters displayerParameters)
          Sets the AcopGraphParameters which describes the visual appearance of the data in the chart.
 void setPreferredYMax(double preferredYMax)
          Sets the preferred maximum vertical value for this graph.
 void setPreferredYMin(double preferredYMin)
          Sets the preferred minimum vertical value for this graph.
 void setTrendChart(boolean isTrendChart)
          Sets the trend mode for this consumer.
 void setXData(double[] xdata)
          Sets the horizontal values.
 void setXLabels(java.lang.String[] labels)
          Sets the labels of horizontal values.
 void setYData(double[] data)
          Sets new vertical values.
 void updateDataState(DataState state)
          Push data state (quality) update change for dynamic value.
 void updateValue(long timestamp, double[] value)
          Notifys this consumer about new dynamic value update.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUPPORTED_CONSUMER_TYPES

public static final java.lang.Class[] SUPPORTED_CONSUMER_TYPES

SUPPORTED_CHARACTERISTICS

public static final java.lang.String[] SUPPORTED_CHARACTERISTICS

name

protected java.lang.String name

acop

protected AcopChart acop

xData

protected double[] xData

yData

protected double[] yData

displayHandle

protected int displayHandle

textHandle

protected int textHandle

lastTimestamp

protected long lastTimestamp

color

protected java.awt.Color color

xLabels

protected java.lang.String[] xLabels

disable

protected java.lang.Object disable

arraySize

protected int arraySize

maxNumber

protected int maxNumber
Constructor Detail

AcopChartConsumer

public AcopChartConsumer(AcopChart acop,
                         java.lang.String name)
Constructs new AcopChartConsumer object with the given name. The consumer belongs to the specified chart.

Parameters:
acop - parent chart
name - the name of the consumer
Method Detail

getDataConsumer

public DataConsumer getDataConsumer(java.lang.Class type)
Description copied from interface: DataConsumer

Returns data consumer for requested data consumer type. If this data consumer does not support required data consumer, null is returned.

If this data cosnumer does not support specific data consumer type, then it means, that it is not desirable to cast data of that type to any by this consumer supported data consumer types.

Specified by:
getDataConsumer in interface DataConsumer
Parameters:
type - Class of specific data consumer (e.g. DoubleConsumer)
Returns:
implementation of required data consumer or null if not supported

getDefaultDataConsumer

public DataConsumer getDefaultDataConsumer()
Description copied from interface: DataConsumer
Returns the implementation of default consumer type supported by this data consumer.

Specified by:
getDefaultDataConsumer in interface DataConsumer
Returns:
the implementation of default consumer type supported by this data consumer

updateDataState

public void updateDataState(DataState state)
Description copied from interface: DataConsumer
Push data state (quality) update change for dynamic value. Usually called by data source.

Specified by:
updateDataState in interface DataConsumer
Parameters:
state - new data state(quality) descriptor

setCharacteristics

public void setCharacteristics(java.util.Map characteristics)
Description copied from interface: DataConsumer
Sets new dynamic value characteristics to this data consumer. This is usually called only at initializaation, before first data state or value is updated. Usually carries characteristics such as value minimum or maximum. Name and meaning of atributes is defined with contract betwean data consumer and source implementation.

Specified by:
setCharacteristics in interface DataConsumer
Parameters:
characteristics - the Map with attri

getName

public java.lang.String getName()
Description copied from interface: DataConsumer
Returns name of this data consumer.

Specified by:
getName in interface DataConsumer
Returns:
the name of this data consumer

getSupportedCharacteristics

public java.lang.String[] getSupportedCharacteristics()
Description copied from interface: DataConsumer
Resturns array with names of supported characteristics. Data source can use this method to optimize setting characteristics to this data consumer. If arrray of length 0 is return, then consumer does not need or support any characteristic. If null is returned, than consumer expect all existing characteristics from data source.

Specified by:
getSupportedCharacteristics in interface DataConsumer
Returns:
array with names of supported characteristics

getSupportedConsumerTypes

public java.lang.Class<DataConsumer>[] getSupportedConsumerTypes()
Description copied from interface: DataConsumer
Returns array of supported data consumer types, which can be used as parameter and returnned with getDataCosnumer(Class) method.

Specified by:
getSupportedConsumerTypes in interface DataConsumer
Returns:
array of supported data consumer types

dumpData

public double[][] dumpData()
Returns all data from chart. First index is 0 for X data array and 1 for Y data array.

Returns:
all dat a from chart in X and Y array

destroy

public void destroy()
Destroys this consumer. Removes from the chart any data that belongs to this consumer.


updateValue

public void updateValue(long timestamp,
                        double[] value)
                 throws CommonException
Description copied from interface: DoubleSeqConsumer
Notifys this consumer about new dynamic value update.

Specified by:
updateValue in interface DoubleSeqConsumer
Parameters:
timestamp - the time of dynamic value event
value - new value
Throws:
CommonException

getXData

public double[] getXData()
Returns the horizontal values.

Returns:
x values

setXData

public void setXData(double[] xdata)
Sets the horizontal values.

Parameters:
xdata - new horizontal values

getYData

public double[] getYData()
Returns the vertical values.

Returns:
y values

setYData

public void setYData(double[] data)
Sets new vertical values.

Parameters:
data - new y values

getAcop

public AcopChart getAcop()
Returns the parent chart of this consumer.

Returns:
the acop

getLastTimestamp

public long getLastTimestamp()
Returns the last timestamp when value was updated.

Returns:
last timestamp

getColor

public java.awt.Color getColor()
Returns the color that shows data of this consumer in the chart.

Returns:
the color

setColor

public void setColor(java.awt.Color color)
Sets the color that shows data of this consumer in the chart. Color can only be set before the data was first drawn.

Parameters:
color - new color

getXLabels

public java.lang.String[] getXLabels()
Returns the labels of horizontal values.

Returns:
x labels

setXLabels

public void setXLabels(java.lang.String[] labels)
Sets the labels of horizontal values. Labels can only be set before data was first drawn.

Parameters:
labels - new labels

getArraySize

public int getArraySize()
Returns the size of the array that this consumer shows.

Returns:
the array size

setArraySize

public void setArraySize(int arraySize)
Sets the size of the array that this consumer handles with. This property can only be set before data was first drawn.

Parameters:
arraySize - new array size

getPreferredYMax

public double getPreferredYMax()
Returns the preferred maximum vertical value for this graph.

Returns:
the preferred max value

setPreferredYMax

public void setPreferredYMax(double preferredYMax)
Sets the preferred maximum vertical value for this graph.

Parameters:
preferredYMax - new preferred maximum value

getPreferredYMin

public double getPreferredYMin()
Returns the preferred minimum vertical value for this graph.

Returns:
the preferred min value

setPreferredYMin

public void setPreferredYMin(double preferredYMin)
Sets the preferred minimum vertical value for this graph.

Parameters:
preferredYMin - new preferred minimum value

getDisplayerParameters

public AcopGraphParameters getDisplayerParameters()
Returns the AcopGraphParameters associated with this consumer.

Returns:
associated parameters

setDisplayerParameters

public void setDisplayerParameters(AcopGraphParameters displayerParameters)
Sets the AcopGraphParameters which describes the visual appearance of the data in the chart. DisplayerParameters can only be set before data was first drawn.

Parameters:
displayerParameters - the displayer parameters

isTrendChart

public boolean isTrendChart()
Returns true if this consumer shows a trend graph.

Returns:
true if this is a trend graph data

setTrendChart

public void setTrendChart(boolean isTrendChart)
Sets the trend mode for this consumer. This property can only be set before the first data was drawn.

Parameters:
isTrendChart - trend mode flag


Copyright © 2010. All Rights Reserved.