info.monitorenter.gui.chart.errorbars
Class ErrorBarPainter

java.lang.Object
  extended by info.monitorenter.gui.chart.errorbars.ErrorBarPainter
All Implemented Interfaces:
IErrorBarPainter, Serializable
Direct Known Subclasses:
ErrorBarPainterLine

public class ErrorBarPainter
extends Object
implements IErrorBarPainter

Implementation of an error bar painter that allows configuration of the way the connection, start point and end point of an error bar is painted by the use of IPointPainter.

Property change events are fired as described in method IErrorBarPainter.addPropertyChangeListener(String, PropertyChangeListener). Note that adding property change listeners to the nested access facades of type IErrorBarPainter.ISegment accessible via getXXXSegment() methods will fire the corresponding events for listeners of this instance (as they delegate the calls) while they fire events for properties defined in IErrorBarPainter.ISegment too. If you register for events of this instance and for the retrieved segments you will receive two PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent) for the same value changed.

Version:
$Revision: 1.13 $
Author:
Achim Westermann
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface info.monitorenter.gui.chart.IErrorBarPainter
IErrorBarPainter.ISegment
 
Field Summary
protected  PropertyChangeSupport m_propertyChangeSupport
          The instance that add support for firing PropertyChangeEvents and maintaining PropertyChangeListeners.
 
Fields inherited from interface info.monitorenter.gui.chart.IErrorBarPainter
PROPERTY_CONNECTION, PROPERTY_CONNECTION_COLOR, PROPERTY_ENDPOINT, PROPERTY_ENDPOINT_COLOR, PROPERTY_STARTPOINT, PROPERTY_STARTPOINT_COLOR
 
Constructor Summary
ErrorBarPainter()
          Creates an instance that by default will not render any error bar.
 
Method Summary
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Registers a property change listener that will be informed about changes of the property identified by the given propertyName.
 Color getConnectionColor()
          Returns the color of the connection segment or null if unconfigured.
 IPointPainter getConnectionPainter()
          Returns the painter for the connection segment of the error bar.
 Color getEndPointColor()
          Returns the color of the end point or null if unconfigured.
 IPointPainter getEndPointPainter()
          Returns the painter for the end point of the error bar.
 PropertyChangeListener[] getPropertyChangeListeners(String property)
          Returns all property change listeners for the given property.
 IErrorBarPainter.ISegment getSegmentConnection()
          Returns the facade instance for accessing the connection segment of this configurable error bar painter.
 IErrorBarPainter.ISegment getSegmentEnd()
          Returns the facade instance for accessing the end segment of this configurable error bar painter.
 IErrorBarPainter.ISegment getSegmentStart()
          Returns the facade instance for accessing the start segment of this configurable error bar painter.
 Color getStartPointColor()
          Returns the color of the start point or null if unconfigured.
 IPointPainter getStartPointPainter()
          Returns the painter for the start point of the error bar.
 void paintErrorBar(int absoluteX, int absoluteY, Graphics2D g, IErrorBarPixel errorBar)
          Paint the error bar for the point given by absolute coordinates on the given graphic context.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Deregisters a property change listener that has been registerd for listening on all properties.
 void removePropertyChangeListener(String property, PropertyChangeListener listener)
          Removes a property change listener for listening on the given property.
 void setConnectionColor(Color connectionColor)
          Sets the color for the connection segment.
 void setConnectionPainter(IPointPainter connectionPainter)
          Note that the choice for the right point painter has to be taken with care: It is senseless to use an implementation that does not interconnect both coordinates given to IPointPainter.paintPoint(int, int, int, int, Graphics2D, TracePoint2D).
 void setEndPointColor(Color endPointColor)
          Sets the color for the end point.
 void setEndPointPainter(IPointPainter endPointPainter)
          Sets the painter for the end point of the error bar.
 void setStartPointColor(Color startPointColor)
          Sets the color for the start point.
 void setStartPointPainter(IPointPainter startPointPainter)
          Note that the choice for the right point painter has to be taken with care: It is senseless to use an implementation that interconnects both coordinates given to IPointPainter.paintPoint(int, int, int, int, Graphics2D, TracePoint2D).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_propertyChangeSupport

protected PropertyChangeSupport m_propertyChangeSupport
The instance that add support for firing PropertyChangeEvents and maintaining PropertyChangeListeners.

Constructor Detail

ErrorBarPainter

public ErrorBarPainter()
Creates an instance that by default will not render any error bar.

It then has to be configured with the remaining methods as desired.

See Also:
setEndPointColor(Color), setEndPointPainter(IPointPainter), setConnectionColor(Color), setConnectionPainter(IPointPainter), setStartPointColor(Color), setStartPointPainter(IPointPainter)
Method Detail

addPropertyChangeListener

public final void addPropertyChangeListener(String propertyName,
                                            PropertyChangeListener listener)
Description copied from interface: IErrorBarPainter
Registers a property change listener that will be informed about changes of the property identified by the given propertyName.

PropertyChangeEvents

PropertyChangeListener instances may be added via Container.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener). They inherit the properties to listen from Container.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener). Additionally more PropertyChangeEvents should be triggered (contract for implementation!).

Property Change events

The following PropertyChangeEvent instances will be fired to registered PropertyChangeListener instances.
getPropertyName() getSource() getOldValue() getNewValue() comment
IErrorBarPainter.PROPERTY_ENDPOINT IErrorBarPainter that changed. IPointPainter. IPointPainter. Note that null as the old value indicates a new painter. Null as the new value is valid and means that the end point rendering is turned off.
IErrorBarPainter.PROPERTY_STARTPOINT IErrorBarPainter that changed. IPointPainter. IPointPainter. Note that null as the old value indicates a new painter. Null as the new value is valid and means that the start point rendering is turned off.
IErrorBarPainter.PROPERTY_CONNECTION IErrorBarPainter that changed. IPointPainter. IPointPainter. Note that null as the old value indicates a new painter. Null as the new value is valid and means that the connection segment point rendering is turned off.
IErrorBarPainter.PROPERTY_ENDPOINT_COLOR IErrorBarPainter that changed. Color. Color. Note that null as the old value indicates a new color different from the default. Null as the new value is valid and means that the end point color is switched to default.
IErrorBarPainter.PROPERTY_STARTPOINT_COLOR IErrorBarPainter that changed. Color. Color. Note that null as the old value indicates a new color different from the default. Null as the new value is valid and means that the start point color is switched to default.
IErrorBarPainter.PROPERTY_CONNECTION_COLOR IErrorBarPainter that changed. Color. Color. Note that null as the old value indicates a new color different from the default. Null as the new value is valid and means that the connection segment color is switched to default.

Specified by:
addPropertyChangeListener in interface IErrorBarPainter
Parameters:
propertyName - the name of the property the listener is interested in
listener - a listener that will only be informed if the property identified by the argument propertyName changes
See Also:
IErrorBarPainter.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)

getEndPointColor

public final Color getEndPointColor()
Description copied from interface: IErrorBarPainter
Returns the color of the end point or null if unconfigured.

Specified by:
getEndPointColor in interface IErrorBarPainter
Returns:
the color of the end point or null if unconfigured.
See Also:
IErrorBarPainter.getEndPointColor()

getEndPointPainter

public final IPointPainter getEndPointPainter()
Description copied from interface: IErrorBarPainter
Returns the painter for the end point of the error bar.

Specified by:
getEndPointPainter in interface IErrorBarPainter
Returns:
The painter for the end point of the error bar.
See Also:
IErrorBarPainter.getEndPointPainter()

getPropertyChangeListeners

public PropertyChangeListener[] getPropertyChangeListeners(String property)
Description copied from interface: IErrorBarPainter
Returns all property change listeners for the given property.

Specified by:
getPropertyChangeListeners in interface IErrorBarPainter
Parameters:
property - one of the constants with the PROPERTY_ prefix defined in this class or subclasses.
Returns:
the property change listeners for the given property.
See Also:
IErrorBarPainter.getPropertyChangeListeners(java.lang.String)

getConnectionColor

public final Color getConnectionColor()
Description copied from interface: IErrorBarPainter
Returns the color of the connection segment or null if unconfigured.

Specified by:
getConnectionColor in interface IErrorBarPainter
Returns:
the color of the connection segment or null if unconfigured.
See Also:
IErrorBarPainter.getConnectionColor()

getSegmentConnection

public IErrorBarPainter.ISegment getSegmentConnection()
Description copied from interface: IErrorBarPainter
Returns the facade instance for accessing the connection segment of this configurable error bar painter.

Specified by:
getSegmentConnection in interface IErrorBarPainter
Returns:
the facade instance for accessing the connection segment of this configurable error bar painter.
See Also:
IErrorBarPainter.getSegmentConnection()

getSegmentEnd

public IErrorBarPainter.ISegment getSegmentEnd()
Description copied from interface: IErrorBarPainter
Returns the facade instance for accessing the end segment of this configurable error bar painter.

Specified by:
getSegmentEnd in interface IErrorBarPainter
Returns:
the facade instance for accessing the end segment of this configurable error bar painter.
See Also:
IErrorBarPainter.getSegmentEnd()

getConnectionPainter

public final IPointPainter getConnectionPainter()
Description copied from interface: IErrorBarPainter
Returns the painter for the connection segment of the error bar.

Specified by:
getConnectionPainter in interface IErrorBarPainter
Returns:
The painter for the connection segment of the error bar.
See Also:
IErrorBarPainter.getConnectionPainter()

getSegmentStart

public IErrorBarPainter.ISegment getSegmentStart()
Description copied from interface: IErrorBarPainter
Returns the facade instance for accessing the start segment of this configurable error bar painter.

Specified by:
getSegmentStart in interface IErrorBarPainter
Returns:
the facade instance for accessing the start segment of this configurable error bar painter.
See Also:
IErrorBarPainter.getSegmentStart()

getStartPointColor

public final Color getStartPointColor()
Description copied from interface: IErrorBarPainter
Returns the color of the start point or null if unconfigured.

Specified by:
getStartPointColor in interface IErrorBarPainter
Returns:
the color of the start point or null if unconfigured.
See Also:
IErrorBarPainter.getStartPointColor()

getStartPointPainter

public final IPointPainter getStartPointPainter()
Description copied from interface: IErrorBarPainter
Returns the painter for the start point of the error bar.

Specified by:
getStartPointPainter in interface IErrorBarPainter
Returns:
the painter for the start point of the error bar.
See Also:
IErrorBarPainter.getStartPointPainter()

paintErrorBar

public void paintErrorBar(int absoluteX,
                          int absoluteY,
                          Graphics2D g,
                          IErrorBarPixel errorBar)
Description copied from interface: IErrorBarPainter
Paint the error bar for the point given by absolute coordinates on the given graphic context.

Basic implementations should modularize further and allow configuration for the way of painting the connection segments, the start point (origin) and end point of the error bar with implementations of IPointPainter.

Specified by:
paintErrorBar in interface IErrorBarPainter
Parameters:
absoluteX - the ready to use x value for the point to paint.
absoluteY - the ready to use y value for the point to paint.
g - the graphic context to paint on.
errorBar - contains the data for the errors to render.
See Also:
IErrorBarPainter.paintErrorBar(int, int, java.awt.Graphics2D, info.monitorenter.gui.chart.IErrorBarPixel)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Description copied from interface: IErrorBarPainter
Deregisters a property change listener that has been registerd for listening on all properties.

Specified by:
removePropertyChangeListener in interface IErrorBarPainter
Parameters:
listener - a listener that will only be informed if the property identified by the argument propertyName changes
See Also:
IErrorBarPainter.removePropertyChangeListener(java.beans.PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(String property,
                                         PropertyChangeListener listener)
Description copied from interface: IErrorBarPainter
Removes a property change listener for listening on the given property.

Specified by:
removePropertyChangeListener in interface IErrorBarPainter
Parameters:
property - one of the constants with teh PROPERTY_ prefix defined in this class or subclasses.
listener - the listener for this property change.
See Also:
IErrorBarPainter.removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)

setConnectionColor

public final void setConnectionColor(Color connectionColor)
Description copied from interface: IErrorBarPainter
Sets the color for the connection segment.

If this is not used or null is provided, the color of the corresponding trace will be used.

Specified by:
setConnectionColor in interface IErrorBarPainter
Parameters:
connectionColor - The connection segment color to set.
See Also:
IErrorBarPainter.setConnectionColor(java.awt.Color)

setEndPointColor

public final void setEndPointColor(Color endPointColor)
Description copied from interface: IErrorBarPainter
Sets the color for the end point.

If this is not used or null is provided, the color of the corresponding trace will be used.

Specified by:
setEndPointColor in interface IErrorBarPainter
Parameters:
endPointColor - The end point color to set.
See Also:
IErrorBarPainter.setEndPointColor(java.awt.Color)

setEndPointPainter

public final void setEndPointPainter(IPointPainter endPointPainter)
Description copied from interface: IErrorBarPainter
Sets the painter for the end point of the error bar.

Note that the choice for the right point painter has to be taken with care: It is senseless to use an implementation that interconnects both coordinates given to IPointPainter.paintPoint(int, int, int, int, Graphics2D, TracePoint2D).

Choosing a PointPainterLine will have the same visual effect as setting such an instance for the connection segment painter.

Specified by:
setEndPointPainter in interface IErrorBarPainter
Parameters:
endPointPainter - The end point painter to set.
See Also:
IErrorBarPainter.setEndPointPainter(info.monitorenter.gui.chart.IPointPainter)

setConnectionPainter

public final void setConnectionPainter(IPointPainter connectionPainter)
Description copied from interface: IErrorBarPainter
Note that the choice for the right point painter has to be taken with care: It is senseless to use an implementation that does not interconnect both coordinates given to IPointPainter.paintPoint(int, int, int, int, Graphics2D, TracePoint2D).

Choosing a PointPainterLine will have the same visual effect as setting such an instance for the start point painter.

Currently the only senseful choice is the PointPainterLine or null (to make the connection segment invisible). But the interface is open enough to use implementations that would paint interpolated dots, discs, squares,... whatever you think of (contribute!).

Specified by:
setConnectionPainter in interface IErrorBarPainter
Parameters:
connectionPainter - The connection segmentPainter to set.
See Also:
IErrorBarPainter.setConnectionPainter(info.monitorenter.gui.chart.IPointPainter)

setStartPointColor

public final void setStartPointColor(Color startPointColor)
Description copied from interface: IErrorBarPainter
Sets the color for the start point.

If this is not used or null is provided, the color of the corresponding trace will be used.

Specified by:
setStartPointColor in interface IErrorBarPainter
Parameters:
startPointColor - The start point color to set.
See Also:
IErrorBarPainter.setStartPointColor(java.awt.Color)

setStartPointPainter

public final void setStartPointPainter(IPointPainter startPointPainter)
Description copied from interface: IErrorBarPainter
Note that the choice for the right point painter has to be taken with care: It is senseless to use an implementation that interconnects both coordinates given to IPointPainter.paintPoint(int, int, int, int, Graphics2D, TracePoint2D).

Choosing a PointPainterLine will have the same visual effect as setting such an instance for the connection segment painter.

Specified by:
setStartPointPainter in interface IErrorBarPainter
Parameters:
startPointPainter - The startPointPainter to set.
See Also:
IErrorBarPainter.setStartPointPainter(info.monitorenter.gui.chart.IPointPainter)


Copyright © 2001 - 2007 LGPL, All Rights Footloose.