lt.monarch.chart.chart2D.series
Class BarSeries

java.lang.Object
  extended by lt.monarch.chart.engine.AbstractChartObject<Tags>
      extended by lt.monarch.chart.AbstractChartSeries<Tags,ChartProjector>
          extended by lt.monarch.chart.chart2D.series.MarkerDecorableSeries<SeriesPaintTags,Projector2D>
              extended by lt.monarch.chart.chart2D.series.BarSeries
All Implemented Interfaces:
java.io.Serializable, AbstractBarSeries<Projector2D>, AbstractMarkerSeries, ChartEntity, ChartObject, ChartSeries, StyleEditorEntity

public class BarSeries
extends MarkerDecorableSeries<SeriesPaintTags,Projector2D>
implements AbstractBarSeries<Projector2D>

Bar series. This series draws various types of bars. In order, to change the drawing strategy,you must set different strategy. The strategies included are BAR_STRATEGY, ERROR_BAR_STRATEGY, EVENT_STRATEGY, FLOATING_BAR_STRATEGY, WATERFALL_STRATEGY Stylesheet constants setObject, "primitive" - sets the bar shape primitive.

See Also:
Serialized Form

Nested Class Summary
Modifier and Type Class and Description
 
Nested classes/interfaces inherited from class lt.monarch.chart.chart2D.series.MarkerDecorableSeries
MarkerDecorableSeries.MarkerEntity
 
Field Summary
Modifier and Type Field and Description
protected static java.util.Hashtable<AxisMapper,java.lang.Float> barSpacings
          Hashtable that maps axis mapper to bar spacing
protected  double barWidth
          Custom bar width
protected  PlaneMapper mapper
          the plane mapper
protected  ArrayDataModel model
          Chart data model
protected  int seriesCount
          Series count on the mapper.
protected  int seriesIndex
          Series index on the mapper.
protected static java.util.Hashtable<AxisMapper,java.lang.Float> seriesSpacings
          Hashtable that maps axis mapper to bar spacing
 
Fields inherited from class lt.monarch.chart.chart2D.series.MarkerDecorableSeries
baseValue, colorMapper, markerPainter, markers, minMaxValues, pseudoModel
 
Fields inherited from class lt.monarch.chart.AbstractChartSeries
metaModel, modelValidator, seriesName, seriesTransform, showLegend, showNullValues, symbol, xMapper, yMapper, zMapper
 
Fields inherited from class lt.monarch.chart.engine.AbstractChartObject
AXIS_SORT_POSITION, BREAK_LINE_POSITION, DEFAULT_SORT_POSITION, GRID_SORT_POSITION, MARKER_SERIES_SORT_POSITION, MARKERS_SORT_POSITION, paintStyle, SERIES_SORT_POSITION, sortPosition, style
 
Constructor Summary
Constructor and Description
BarSeries(ArrayDataModel model, AxisMapper xMapper, AxisMapper yMapper)
          Bar series constructor without a meta data model and default plane mapper is for Cartesian coordinates.
BarSeries(ArrayDataModel model, AxisMapper xMapper, AxisMapper yMapper, PlaneMapper mapper)
          Constructs a new BarSeries object
BarSeries(ArrayDataModel model, MetaDataModel metaModel, AxisMapper xMapper, AxisMapper yMapper)
          Constructs a new bar series.
BarSeries(ArrayDataModel model, MetaDataModel metaModel, AxisMapper xMapper, AxisMapper yMapper, PlaneMapper mapper)
          Constructs a new BarSeries object
 
Method Summary
Modifier and Type Method and Description
 LegendSymbol createLegendSymbol(int bar)
          Create a legend symbol for the specified bar.
 void dispose()
          Cleans this bar series object.
 void draw(AbstractGraphics g)
          Renders chart object on the Graphics context.
static float getBarSpacing(AxisMapper mapper)
          Returns spacing between bars.
 AxisMapper getGroupKey()
          Gets grouping key for bar layout.
 java.lang.Object getMaxValue(DataColumnType valType)
          Note: internal use only! Gets maximum value that is used by series to fit into the chart
 java.lang.Object getMinValue(DataColumnType valType)
          Note: internal use only! Gets minimum value that is used by series to fit into the chart
 Orientation getOrientation()
          Gets bar orientation
protected  GeneralPoint getPointForConstraint(ArrayDataModel model, int index)
           
static float getSeriesSpacing(AxisMapper mapper)
          Returns spacing between different bar series.
 AbstractBarStrategy getStrategy()
          Gets bar drawing strategy object
protected  void handleDataModelChangeEvent(DataModelChangeEvent ev)
          Handles data model change event.
protected  void initLegendSymbol()
          Initializes a new BarSeriesLegendSymbol used for representing bar series in legend.
 void invalidate()
          Invalidates the bar series.
 void layout(int seriesCount, int index)
          Layout bar series (series layouting)
static void removeBarSpacing(AxisMapper mapper)
          Removes bar spacing from the hashtable according to the specified axis mapper
static void removeSeriesSpacing(AxisMapper mapper)
          Removes series spacing from the hashtable according to the specified axis mapper
static void setBarSpacing(AxisMapper mapper, float space)
          Sets spacing between bars for all series in a chart.
 void setBaseValue(java.lang.Object baseValue)
          Sets the base value of the series
 void setOrientation(Orientation orientation)
          Sets bar orientation
 void setPrimitive(Shapes primitive)
          Sets primitive of the bar shape
static void setSeriesSpacing(AxisMapper mapper, float space)
          Sets spacing between different bar series.
 void setStrategy(BarStrategies strategy)
          Sets bar drawing strategy, i.e.
 
Methods inherited from class lt.monarch.chart.chart2D.series.MarkerDecorableSeries
addMarker, addMarker, addMarker, calculateNullValue, copy, dataConstraintExtraction, drawMarkers, drawMarkers, generateConstaint, getBaseValue, getColorMapper, getKeyType, getMarkerConstraints, getMarkers, getMarkerStyle, getPaintMode, getSortPosition, layout, mapMinMaxValue, removeMarker, setColorMapper, setPaintMode
 
Methods inherited from class lt.monarch.chart.AbstractChartSeries
activate, checkDataModelRequirements, createLegendEntries, createLegendEntry, createLegendSymbol, deactivate, fillEntitySheet, getChartObjectBounds, getDataModel, getDescription, getMetaDataModel, getModelValidator, getName, getNearestChildEntity, getParentEntity, getProjector, getSeriesColor, getShortDescription, getShowNullValues, getXMapper, getYMapper, getZMapper, setLegendSymbol, setName, setShowNullValues, setValidateData, showLegend, updateClippingToProjector
 
Methods inherited from class lt.monarch.chart.engine.AbstractChartObject
chart, copy, finalize, getChart, getPaintStyle, getParent, getStyle, getStyle, isVisible, repaint, repaint, setChart, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface lt.monarch.chart.AbstractBarSeries
getDataModel, getKeyType, getMetaDataModel, getModelValidator, getPaintMode, getProjector, getXMapper, getYMapper, getZMapper
 
Methods inherited from interface lt.monarch.chart.engine.ChartSeries
createLegendEntries, createLegendEntry, getName, setName
 
Methods inherited from interface lt.monarch.chart.engine.ChartObject
getChart, getSortPosition, getStyle, getStyle, isVisible, layout, repaint, repaint, setChart
 
Methods inherited from interface lt.monarch.chart.engine.ChartEntity
fillEntitySheet, getDescription, getParentEntity, getShortDescription
 
Methods inherited from interface lt.monarch.chart.engine.StyleEditorEntity
getChartObjectBounds, getParent, getStyle
 

Field Detail

model

protected ArrayDataModel model
Chart data model


mapper

protected PlaneMapper mapper
the plane mapper


seriesCount

protected int seriesCount
Series count on the mapper. Use this attribute indirectly through method.


seriesIndex

protected int seriesIndex
Series index on the mapper. Use this attribute indirectly through method.


barSpacings

protected static final java.util.Hashtable<AxisMapper,java.lang.Float> barSpacings
Hashtable that maps axis mapper to bar spacing


seriesSpacings

protected static final java.util.Hashtable<AxisMapper,java.lang.Float> seriesSpacings
Hashtable that maps axis mapper to bar spacing


barWidth

protected double barWidth
Custom bar width

Constructor Detail

BarSeries

public BarSeries(ArrayDataModel model,
                 MetaDataModel metaModel,
                 AxisMapper xMapper,
                 AxisMapper yMapper,
                 PlaneMapper mapper)
Constructs a new BarSeries object

Parameters:
model - chart data model
metaModel - meta data model
xMapper - x axis mapper
yMapper - y axis mapper
mapper - mapper, used to map output to a plane in a n-dimensional space

BarSeries

public BarSeries(ArrayDataModel model,
                 AxisMapper xMapper,
                 AxisMapper yMapper,
                 PlaneMapper mapper)
Constructs a new BarSeries object

Parameters:
model - chart data model
xMapper - x axis mapper
yMapper - y axis mapper
mapper - mapper, used to map output to a plane in a n-dimensional space

BarSeries

public BarSeries(ArrayDataModel model,
                 AxisMapper xMapper,
                 AxisMapper yMapper)
Bar series constructor without a meta data model and default plane mapper is for Cartesian coordinates.

Parameters:
model - chart data model
xMapper - x axis mapper
yMapper - y axis mapper

BarSeries

public BarSeries(ArrayDataModel model,
                 MetaDataModel metaModel,
                 AxisMapper xMapper,
                 AxisMapper yMapper)
Constructs a new bar series. The default plane mapper is used for Cartesian coordinate system.

Parameters:
model - chart data model
metaModel - meta data model
xMapper - x axis mapper
yMapper - y axis mapper
Method Detail

handleDataModelChangeEvent

protected void handleDataModelChangeEvent(DataModelChangeEvent ev)
Description copied from class: AbstractChartSeries
Handles data model change event. Called when DataModelChangeEvent is received. Calls repaint() method.

Overrides:
handleDataModelChangeEvent in class AbstractChartSeries<SeriesPaintTags,Projector2D>
Parameters:
ev - the chart data model change event
See Also:
DataModelChangeEvent

createLegendSymbol

public LegendSymbol createLegendSymbol(int bar)
Create a legend symbol for the specified bar. Each bar can have different style attributes. This method creates a specific legend symbol for a given bar in a series.

Parameters:
bar - bar index
Returns:
a legend symbol for the specified bar

initLegendSymbol

protected void initLegendSymbol()
Initializes a new BarSeriesLegendSymbol used for representing bar series in legend.


draw

public void draw(AbstractGraphics g)
Description copied from interface: ChartObject
Renders chart object on the Graphics context.

Specified by:
draw in interface ChartObject
Overrides:
draw in class MarkerDecorableSeries<SeriesPaintTags,Projector2D>
Parameters:
g - graphics context

layout

public void layout(int seriesCount,
                   int index)
Description copied from interface: AbstractBarSeries
Layout bar series (series layouting)

Specified by:
layout in interface AbstractBarSeries<Projector2D>
Parameters:
seriesCount - series count in the chart
index - index of the bar

dispose

public void dispose()
Cleans this bar series object. After this series object is unusable and can be garbage collected.

Specified by:
dispose in interface ChartObject
Overrides:
dispose in class AbstractChartObject<SeriesPaintTags>

invalidate

public void invalidate()
Invalidates the bar series.

Specified by:
invalidate in interface ChartObject
Overrides:
invalidate in class AbstractChartObject<SeriesPaintTags>
See Also:
ChartObject.invalidate()

setBarSpacing

public static void setBarSpacing(AxisMapper mapper,
                                 float space)
Sets spacing between bars for all series in a chart.

Parameters:
mapper - Axis mapper for which bar spacing is specified. It is the mapper of the axis, where the bar key values are specified.
space - Space between different bars relative to bar width. Must be in interval [0.0 .. 1.0]. Passing negative space value allows the neighbouring bars to overlap.

getBarSpacing

public static float getBarSpacing(AxisMapper mapper)
Returns spacing between bars.

Parameters:
mapper - Axis mapper for which bar spacing is specified. It is the mapper of the axis, where the bar key values are specified.
Returns:
space between different bars relative to bar width in interval [0.0 .. 1.0].

getSeriesSpacing

public static float getSeriesSpacing(AxisMapper mapper)
Returns spacing between different bar series.

Parameters:
mapper - Axis mapper for which bar spacing is returned.
Returns:
space between different bar series relative to bar width in interval [0.0 .. 1.0].

setSeriesSpacing

public static void setSeriesSpacing(AxisMapper mapper,
                                    float space)
Sets spacing between different bar series.

Parameters:
mapper - Axis mapper for which bar spacing is specified.
space - Space between different bar series relative to bar width. Must be in interval [0.0 .. 1.0]. Passing negative space value allows the series to overlap.

removeBarSpacing

public static void removeBarSpacing(AxisMapper mapper)
Removes bar spacing from the hashtable according to the specified axis mapper

Parameters:
mapper - axis mapper, that specifies the bar spacing

removeSeriesSpacing

public static void removeSeriesSpacing(AxisMapper mapper)
Removes series spacing from the hashtable according to the specified axis mapper

Parameters:
mapper - axis mapper, that specifies the series spacing

getPointForConstraint

protected GeneralPoint getPointForConstraint(ArrayDataModel model,
                                             int index)
Overrides:
getPointForConstraint in class MarkerDecorableSeries<SeriesPaintTags,Projector2D>

getOrientation

public Orientation getOrientation()
Description copied from interface: AbstractBarSeries
Gets bar orientation

Specified by:
getOrientation in interface AbstractBarSeries<Projector2D>
Returns:
bar orientation

setOrientation

public void setOrientation(Orientation orientation)
Description copied from interface: AbstractBarSeries
Sets bar orientation

Specified by:
setOrientation in interface AbstractBarSeries<Projector2D>
Parameters:
orientation - bar orientation

setStrategy

public void setStrategy(BarStrategies strategy)
Sets bar drawing strategy, i.e. chooses the bar type. use enumeration BarStrategies to choose the appropriate bar drawing strategy. If you want to set your own custom strategy set it directly to the stylesheet, using tag "strategy", e.g. style.setObject("strategy", new MyStrategy());

Parameters:
strategy - the bar drawing strategy to set

getStrategy

public AbstractBarStrategy getStrategy()
Gets bar drawing strategy object


setPrimitive

public void setPrimitive(Shapes primitive)
Sets primitive of the bar shape

Parameters:
primitive - bar shape primitive

getGroupKey

public AxisMapper getGroupKey()
Description copied from interface: AbstractBarSeries
Gets grouping key for bar layout. Override this method in order to get custom layout.
Default layout for vertical bars is according to X axis, for horizontal according to Y axis.

Specified by:
getGroupKey in interface AbstractBarSeries<Projector2D>
Returns:
grouping key for bar layout.

setBaseValue

public void setBaseValue(java.lang.Object baseValue)
Description copied from class: MarkerDecorableSeries
Sets the base value of the series

Overrides:
setBaseValue in class MarkerDecorableSeries<SeriesPaintTags,Projector2D>
Parameters:
baseValue - the baseValue to set

getMaxValue

public java.lang.Object getMaxValue(DataColumnType valType)
Description copied from class: AbstractChartSeries
Note: internal use only! Gets maximum value that is used by series to fit into the chart

Overrides:
getMaxValue in class MarkerDecorableSeries<SeriesPaintTags,Projector2D>
Parameters:
valType - data value column
Returns:
maximum value needed

getMinValue

public java.lang.Object getMinValue(DataColumnType valType)
Description copied from class: AbstractChartSeries
Note: internal use only! Gets minimum value that is used by series to fit into the chart

Overrides:
getMinValue in class MarkerDecorableSeries<SeriesPaintTags,Projector2D>
Parameters:
valType - data value column
Returns:
minimum value needed