com.davisor.graphics.chart
Class ChartAxes

java.lang.Object
  extended bycom.davisor.graphics.chart.AxisAttributes
      extended bycom.davisor.graphics.chart.ChartAxes
All Implemented Interfaces:
com.davisor.core.Dupable, java.io.Serializable

public class ChartAxes
extends AxisAttributes

ChartAxes represents a set of ChartAxis that define the coordinate space of a chart. Each axis in axis set will have a number of attributes of it's own, and all those attributes will default to corresponding axes group default attributes, except for those attributes for which there can be no meaningfull common axis set wide default values.

Axes group inherits all attributes it is capable of giving a meaningfull default value for from it's super-class AxisAttributes. An axis group has also the following attributes of it's own:

The above attributes are needed in particular with chart factories that may draw more than one chart into one chart image.

Since:
JDK1.2
See Also:
setRender(com.davisor.graphics.chart.AxisRenderAttributes), AxisFactory, ChartAxis, Serialized Form

Field Summary
static int CATEGORY
          Category axis index (0).
static java.lang.String[] LOGICALDIMENSIONS
          Names for logical dimensions.
protected  java.util.Map M_axes
          Axes beloning to this axes group, keyed to their 'dim' attribute.
protected  java.lang.String M_chartType
          The chart type drawn into this axis group.
protected  java.lang.String M_dataGroup
          The chart data group drawn into this axis group.
protected  java.util.Map M_dims
          Custom axis dimension mapping.
protected  PlotRenderAttributes M_plot
          Axis render attributes.
protected  java.lang.String[] M_viewport
          Viewport shape namespace and id.
static java.lang.String[] PHYSICALDIMENSIONS
          Names for dimensions.
static int SERIES
          Series axis index (2).
static int VALUE
          Value axis index (1).
static int X
          X-axis index (0).
static int Y
          Y-axis index (1).
static int Z
          Z-axis index (2).
 
Fields inherited from class com.davisor.graphics.chart.AxisAttributes
AFTER_KEYWORD, AFTER_VALUE, BEFORE_KEYWORD, BEFORE_VALUE, M_gap, M_gridLines, M_labelFormat, M_labelOffset, M_labelRotation, M_level, M_markerOffset, M_opposite, M_positionStringValue, M_render, M_reversed, M_silent, M_tic, M_titleOffset, M_titleRotation, MAX_KEYWORD, MAX_VALUE, MIN_KEYWORD, MIN_VALUE
 
Constructor Summary
ChartAxes()
          Default constructor.
ChartAxes(AxisRenderAttributes render, PlotRenderAttributes plot, java.lang.String type, java.lang.Number gap, java.awt.Shape tic, java.lang.Integer level, java.lang.Boolean gridLines, java.lang.Float titleRotation, java.lang.Float titleOffset, java.lang.Float markerOffset, java.lang.Float labelRotation, java.lang.Float labelOffset, java.lang.Boolean opposite, java.lang.Boolean reversed, java.lang.Boolean silent, java.lang.String position)
          Creates new axes.
ChartAxes(ChartAxes ca)
          Deep copy constructor.
 
Method Summary
 void addAxis(ChartAxis axis)
          Adds an axis to this axis group.
 void computeValues(DataValue[][] limitValues)
          Computes axis minimum, maximum, step, and zero data values.
 com.davisor.core.Dupable dup()
          Duplicates this object.
 boolean equals(java.lang.Object object)
          Test if these axes equal to given axes.
 ChartAxis getAxis(int dim)
          Gets specific axis.
 java.lang.String getChartType()
          Gets axes specific chart factory type.
 java.lang.String getDataGroup()
          Gets axes specific chart data group.
 java.lang.String getDim(int dim)
          Gets a conseptual dimension associated to given physical dimension.
 PlotRenderAttributes getPlot()
          Gets axis specific plot render attributes.
 java.awt.Shape getViewport()
          Returns viewport shape or null.
 boolean isIsometric()
          Tests if axes define isometric projection.
 boolean isShared(int dim)
          Tests if given axis is shared with another axis group.
 ChartAxis removeAxis(java.lang.String dim)
          Removes the given dimension axis from this group.
 void setCategoryAxis(int dim)
          This utility method configures this axis group category and value axis conceptual dimensions.
 void setChartType(java.lang.String chartType)
          Sets axes specific chart factory type.
 void setDataGroup(java.lang.String dataGroup)
          Sets axes specific chart data group.
 void setDim(int dim, java.lang.String conceptualDim)
          Associates a conceptual dimension to given physical dimension.
 void setPlot(PlotRenderAttributes plot)
          Sets axis specific plot render attributes.
 void setRender(AxisRenderAttributes render)
          Sets axes render attributes.
 void setViewport(java.lang.String namespace, java.lang.String shapeId)
          Sets the viewport using a shape.
 java.lang.String toString()
          Gets axes XML representation.
 
Methods inherited from class com.davisor.graphics.chart.AxisAttributes
getGap, getLabelFormat, getLabelOffset, getLabelOffset, getLabelRotation, getLevel, getMarkerOffset, getMarkerOffset, getPositionStringValue, getRender, getTic, getTitleOffset, getTitleOffset, getTitleRotation, hasGridLines, hashCode, isOpposite, isOppositeDefault, isReversed, isReversedDefault, isSilent, isSilentDefault, setGap, setGap, setGridLines, setGridLines, setLabelFormat, setLabelOffset, setLabelOffset, setLabelRotation, setLabelRotation, setLevel, setMarkerOffset, setMarkerOffset, setOpposite, setOpposite, setPositionStringValue, setReversed, setReversed, setSilent, setSilent, setTic, setTitleOffset, setTitleOffset, setTitleRotation, setTitleRotation
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

X

public static final int X
X-axis index (0).

See Also:
Constant Field Values

Y

public static final int Y
Y-axis index (1).

See Also:
Constant Field Values

Z

public static final int Z
Z-axis index (2).

See Also:
Constant Field Values

CATEGORY

public static final int CATEGORY
Category axis index (0).

See Also:
Constant Field Values

VALUE

public static final int VALUE
Value axis index (1).

See Also:
Constant Field Values

SERIES

public static final int SERIES
Series axis index (2).

See Also:
Constant Field Values

PHYSICALDIMENSIONS

public static final java.lang.String[] PHYSICALDIMENSIONS
Names for dimensions.


LOGICALDIMENSIONS

public static final java.lang.String[] LOGICALDIMENSIONS
Names for logical dimensions.


M_axes

protected java.util.Map M_axes
Axes beloning to this axes group, keyed to their 'dim' attribute.


M_dims

protected java.util.Map M_dims
Custom axis dimension mapping.


M_chartType

protected java.lang.String M_chartType
The chart type drawn into this axis group.


M_dataGroup

protected java.lang.String M_dataGroup
The chart data group drawn into this axis group.


M_plot

protected PlotRenderAttributes M_plot
Axis render attributes.


M_viewport

protected java.lang.String[] M_viewport
Viewport shape namespace and id.

Constructor Detail

ChartAxes

public ChartAxes()
Default constructor.


ChartAxes

public ChartAxes(ChartAxes ca)
Deep copy constructor.

See Also:
dup()

ChartAxes

public ChartAxes(AxisRenderAttributes render,
                 PlotRenderAttributes plot,
                 java.lang.String type,
                 java.lang.Number gap,
                 java.awt.Shape tic,
                 java.lang.Integer level,
                 java.lang.Boolean gridLines,
                 java.lang.Float titleRotation,
                 java.lang.Float titleOffset,
                 java.lang.Float markerOffset,
                 java.lang.Float labelRotation,
                 java.lang.Float labelOffset,
                 java.lang.Boolean opposite,
                 java.lang.Boolean reversed,
                 java.lang.Boolean silent,
                 java.lang.String position)
Creates new axes.

Parameters:
render - axis render attributes (may be null)
plot - axis group specific plot render attributes (may be null)
type - label type (may be null)
gap - gap (percents, may be null)
tic - tic mark shape (may be null)
level - tic mark recursion level
gridLines - enable or disable grid lines (may be null)
titleRotation - title rotation (may be null)
titleOffset - axis title offset (may be null)
markerOffset - axis marker offset (may be null)
labelRotation - axis label rotation (may be null)
labelOffset - axis label offset (may be null)
opposite - axis side (may be null)
reversed - axis growth direction (may be null)
silent - suppress axis labels (may be null)
position - axis position (may be null)
Method Detail

dup

public com.davisor.core.Dupable dup()
Duplicates this object.

Specified by:
dup in interface com.davisor.core.Dupable
Overrides:
dup in class AxisAttributes

equals

public boolean equals(java.lang.Object object)
Test if these axes equal to given axes. Two axis groups are equal if the axes they contain are, and if the mappings from physical dimension to conceptual dimensions are equal, too.

Overrides:
equals in class AxisAttributes

toString

public java.lang.String toString()
Gets axes XML representation.

Overrides:
toString in class AxisAttributes
See Also:
AxisAttributes.toString(), Strings.toXML(String,Object)

isShared

public boolean isShared(int dim)
Tests if given axis is shared with another axis group. An axis is shared (with respect of this axis group) only if the axis refers to some other axes group than this. For example, if an axis belongs to two axis groups, and the axis refers one of them, the axis is considered shared only with respect on the other axis group it does not refer to.

If the given argument refers to an axis that does not yet axis, a new axis for that dimension is created as a side-effect, as describe in the getAxis(int) method documentation. New axes are however never shared, so the result for this method in those cases will always be false.

Parameters:
dim - axis dimension
See Also:
getAxis(int), ChartAxis.isShared()

addAxis

public void addAxis(ChartAxis axis)
Adds an axis to this axis group. The dimension of the new axis is taken from the value given by the axis object ChartAxis.getDim() method. The axis is also joined to this axis group with a call to axis object ChartAxis.setAxes(com.davisor.graphics.chart.ChartAxes) method.

If this axis group already contains an axis keyed to the new axis dimension, the new axis replaces the old axis. If the new axis dimension is null, the first still unused integer dimension ("0", "1", ...) is assigned to the new axis.

Please see getAxis(int) for what kind of axis dimension strings are expected, and setDim(int, java.lang.String) for how to configure the axis group to support custom dimension values.

Parameters:
axis - new axis (may be null)
See Also:
getAxis(int), setDim(int, java.lang.String), removeAxis(java.lang.String)

computeValues

public void computeValues(DataValue[][] limitValues)
                   throws InvalidDataException
Computes axis minimum, maximum, step, and zero data values. The values are computed from axis specific minimum and maximum data values, given as parameters, and axis attributes, already defined for each axis object.

This method distributes the given limit values to each axis belonging to this axis group. The axes will then compute their own values with ChartAxis.computeValues(com.davisor.data.DataValue[]) method.

Parameters:
limitValues - array of axis minimum, maximum, and unit data values ([x,y,...][min,max,unit])
Throws:
InvalidDataException - if data limit value computation fails
See Also:
AxisFactory.resolveLimits(com.davisor.graphics.chart.ChartDataSummary), ChartAxis.computeValues(com.davisor.data.DataValue[]), ChartFactory.createSummary(com.davisor.graphics.chart.ChartData, com.davisor.graphics.chart.ChartAttributes, com.davisor.graphics.chart.ChartAxes, com.davisor.graphics.chart.PlotRenderAttributes, com.davisor.data.EnumType, int[], boolean, int[])

getAxis

public ChartAxis getAxis(int dim)
Gets specific axis. Axes are keyed to their dimension values, which may be: This method searches for an axis using all these different dimension in the given order. The first dimension value that actually matches an axis is then returned. Please note, that the searches are case sensitive, and therefore for example a dimension name "X" will not be interpreted as a physical dimension.

The given integer dimension argument is mapped to the different dimension value types as follows:

If all of the above methods fail to match an axis, a new default axis is created, stored under corresponding integer key, and returned.

Parameters:
dim - axis dimension
Returns:
axis object (never null)
See Also:
addAxis(com.davisor.graphics.chart.ChartAxis), getDim(int), removeAxis(java.lang.String)

getChartType

public java.lang.String getChartType()
Gets axes specific chart factory type.


getDataGroup

public java.lang.String getDataGroup()
Gets axes specific chart data group.


getDim

public java.lang.String getDim(int dim)
Gets a conseptual dimension associated to given physical dimension. The dimension is first searched from current custom dimension mapping table, defined by calls to setDim(int, java.lang.String) method. If that gives no result, the following default mapping is attempted:

If none of these methods give any result, null is returned.

Parameters:
dim - physical dimension
Returns:
corresponding conseptual dimension (may be null)
See Also:
getAxis(int), setDim(int, java.lang.String)

getPlot

public PlotRenderAttributes getPlot()
Gets axis specific plot render attributes. If these axes did not already define plot attributes instance, a new default instance is created now, saved for later use, and returned.

Chart initializers are expected to arrange default value dependency relations between axes specific plot attributes and general ChartAttributes.getPlot() attributes. This allows chart factories to always use only axes specific plot attributes, returned by this method, as they can now rely on that any plot attributes not defined separately for a specific axes will default back to the global plot attributes, common to all axis groups. In practice this all means that chart initializers are expected to apply PlotRenderAttributes.setDefaults(com.davisor.graphics.chart.PlotRenderAttributes) method to the plot render attributes instance returned by this method at some point before this object is used for chart generation.

Returns:
axis specific plot render attributes
See Also:
setPlot(com.davisor.graphics.chart.PlotRenderAttributes), ChartAttributes.getAxes(), ChartAttributes.getPlot()

getViewport

public java.awt.Shape getViewport()
Returns viewport shape or null. Viewport shape defines how shape coordinates (especially in map chart) are translated and scaled into chart image pixels.

See Also:
setViewport(java.lang.String, java.lang.String)

isIsometric

public boolean isIsometric()
Tests if axes define isometric projection. If even one axis angle has non-zero value, they do.


removeAxis

public ChartAxis removeAxis(java.lang.String dim)
Removes the given dimension axis from this group. The current axis group of the removed axis is also set to null with a call to ChartAxis.setAxes(com.davisor.graphics.chart.ChartAxes) method.

Parameters:
dim - axis dimension (may be null)
Returns:
the removed axis (may be null)
See Also:
addAxis(com.davisor.graphics.chart.ChartAxis), getAxis(int)

setCategoryAxis

public void setCategoryAxis(int dim)
This utility method configures this axis group category and value axis conceptual dimensions. First, the given axis dimension is expected to be 0 or 1, corresponding to physical axes x or y, respectively. The given physical axis dimension will then be mapped to category conceptual axis, and the other X or Y axis is mapped to value conceptual axis.

For more elaborate custom axis dimension configuration, use setDim(int, java.lang.String) method.  @param dim physical dimension to be mapped to category dimension (0 or 1)

See Also:
setDim(int, java.lang.String)

setChartType

public void setChartType(java.lang.String chartType)
Sets axes specific chart factory type.


setDataGroup

public void setDataGroup(java.lang.String dataGroup)
Sets axes specific chart data group.


setDim

public void setDim(int dim,
                   java.lang.String conceptualDim)
Associates a conceptual dimension to given physical dimension.

Parameters:
dim - physical dimension
conceptualDim - conceptual dimension
See Also:
getAxis(int), getDim(int)

setPlot

public void setPlot(PlotRenderAttributes plot)
Sets axis specific plot render attributes.

Parameters:
plot - axis group specific plot render attributes (may be null)
See Also:
getPlot()

setRender

public void setRender(AxisRenderAttributes render)
Sets axes render attributes. The new render attributes will become the default render attribute values for all current axis group axes.

If the given render attributes are null, a fresh copy of the chart factory default render attributes will be installed.

Overrides:
setRender in class AxisAttributes
Parameters:
render - new render default attributes (may be null)
See Also:
AxisAttributes.getRender()

setViewport

public void setViewport(java.lang.String namespace,
                        java.lang.String shapeId)
Sets the viewport using a shape. The shape will be evaluated when it will be asked by getViewport().

See Also:
getViewport()


Copyright © 2001-2004 Davisor Oy. All Rights Reserved.