|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectlt.monarch.chart.chart2D.axis.layouters.SimpleLinearLabelLayouter
lt.monarch.chart.chart2D.axis.layouters.DefaultLinearLabelLayouter
lt.monarch.chart.chart2D.axis.layouters.MultiLevelLabelLayouter
public class MultiLevelLabelLayouter extends DefaultLinearLabelLayouter
This layouter is used to layout labels of multiple levels.
When mapper producing labels of multiple levels is used for axis, e.g.
DateAxisMapper, this is situation where
MultiLevelLabelLayouter could be applied. Layout constraints
could be set for each level of labels indicating necessity to raise and
possibly center labels of desired level (see API description of public
constants - possible constraints values).
Raising constraint allows separate labels into rows. Layout algorithm
traverses label levels from highest to lowest (from level of finest scale
labels to level of start scale labels in case of DateAxisMapper)
and, when it founds level with assigned constraint value indicating raising,
the new label row is added. All labels of current and lower levels go into
new row.
Labels are not rised if there are no visible labels of higher level.
Centering allows to have labels placed not at their axis ticks but rather
center them between current label tick and next label tick; e.g. you can have
months names placed at about 15th day of month rather than having them
sticked on ticks at the beginning of the 1st day of month.
Centering in floating mode allows to have visible at least one label of
scales of larger time units even when zooming in by large factors.
Limitation:
MultiLevelLabelLayouter can be used for Axis2DX and Axis2DY only.
Example:
Assume that DateAxisMapper is used for Axis2DX or
Axis2DY and its starting scale units are set to
Calendar.YEAR, finest - to Calendar.DAY_OF_MONTH
(see DateAxisMapper#setStartingScaleUnits (int) and
DateAxisMapper#setFinestScaleUnits (int)). So, we have labels of
3 levels. Year labels are the 1st level labels, month labels - the 2nd, and
day labels - the 3th level. We want to have month labels to be moved to next
row below day labels and center them at about 15th day of month. We use code:
((MultiLevelLabelLayouter) layouter).setLayoutConstraints (2,
MultiLevelLabelLayouter.RAISE_AND_CENTER_FIXED_ON_RIGHT_RANGE);
Year labels will also go in the same row as month labels. If we want, we can move year labels further into next row using this line of code:
((MultiLevelLabelLayouter) layouter).setLayoutConstraints (1,
MultiLevelLabelLayouter.RAISE);
Note that label level numbering in DateAxisMapper starts from
labels of scale of starting (largest) time unit, i.e. if
Calendar.MONTH is starting time unit then month labels are 1st
level labels.
2007.02.21 Changes suggested by Robert Dunaj.
| Modifier and Type | Field and Description |
|---|
| Fields inherited from class lt.monarch.chart.chart2D.axis.layouters.SimpleLinearLabelLayouter |
|---|
calculatePreferredDimensions, levels, prefferedHeight, prefferedWidth, sparseMode, start, stop, titleArea |
| Constructor and Description |
|---|
MultiLevelLabelLayouter()
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
eliminateOutbound(AbstractAxisLabel[] labels)
Eliminates labels, falling outside the visible axis range. |
int |
getBottomPos(int level)
Returns bottom position of labels of given level, if level is raised and -1 otherwise. |
boolean |
getDoWordWrap()
Return weather word wrapping is enabled |
MultiLevelLabel |
getLayoutConstraints(int labelLevel)
Returns layout constraints for given label level. |
double |
getMaxLevelLabelSize()
Non-API method. Returns labels max level height for X axis and width for Y axis. |
double |
getRowSpacing()
Number of pixels that separate rows of layouted labels. |
int |
getTopPos(int level)
Returns top position of labels of given level, if level is raised and -1 otherwise. |
boolean |
isDynamicLabels()
Reuse space of empty labels.. |
boolean |
isEliminateOverlappingRowsLabels()
Return is set eliminate lower low labels when exists upper row labels. |
void |
layout(AbstractAxisLabel[] labels)
Layouts the specified labels. |
void |
prepare(AbstractAxisLabel[] labels)
Non-API method. Calculates preferred size of all visible labels (maximum size of all labels). |
protected void |
rowLayout(AxisLabel[] rowLabels)
Layout one rowLabels in multilevel layouter |
protected void |
rowPrepare(AxisLabel[] prepareLabels)
Prepares one prepareLabels in multilevel layouter |
void |
setAxisParams(Alignment axisPosition,
double maxLabelDimension)
Deprecated. not usable changed to setAxisParams(Orientation, Alignment) |
void |
setAxisParams(boolean axisTopOrientated,
double maxLabelHeigth)
Deprecated. use setAxisParams(Alignment, double) |
void |
setAxisParams(Orientation axisOrientation,
Alignment axisPosition)
Sets axis parameters for level calculating. |
void |
setDoWordWrap(boolean doWordWrap)
set word wrapping status |
void |
setDynamicLabels(boolean dynamicLabels)
Sets capability reuse empty labels space. |
void |
setEliminateOverlappingRowsLabels(boolean eliminateOverlappingRowsLabels)
Set eliminate lower low labels when exists upper row labels. |
void |
setLayoutConstraints(int labelLevel,
MultiLevelLabel constraint)
Sets layout constraints for desired label level. |
void |
setRowSpacing(int rowSpacing)
Sets number of pixels that should separate rows of layouted labels. |
| Methods inherited from class lt.monarch.chart.chart2D.axis.layouters.DefaultLinearLabelLayouter |
|---|
eliminateLevelsFrom, getMinimumLabelSpacing, setMinimumLabelSpacing |
| Methods inherited from class lt.monarch.chart.chart2D.axis.layouters.SimpleLinearLabelLayouter |
|---|
clone, compareLabels, dispose, findMaxLevel, getMaxLevel, getPreferredHeight, getPreferredWidth, setSparseMode, setTitleArea, setVisibleRange, sort |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MultiLevelLabelLayouter()
| Method Detail |
|---|
public boolean getDoWordWrap()
public void setDoWordWrap(boolean doWordWrap)
doWordWrap - is word wrapping enabledpublic void layout(AbstractAxisLabel[] labels)
layout in interface LinearLabelLayouterlayout in class DefaultLinearLabelLayouterlabels - the labels to layoutprotected void rowLayout(AxisLabel[] rowLabels)
rowLabels - row label arrayprotected void eliminateOutbound(AbstractAxisLabel[] labels)
SimpleLinearLabelLayouter
eliminateOutbound in class DefaultLinearLabelLayouterlabels - labels to layoutpublic int getTopPos(int level)
level - label levelpublic int getBottomPos(int level)
level - label level
public void setLayoutConstraints(int labelLevel,
MultiLevelLabel constraint)
labelLevel - level of labels to which constraints should be applied. Level
numbering starts at 1.constraints - constraints to apply. Valid values are:
MultiLevelLabelLayouter.NULL MultiLevelLabelLayouter.RAISE,
MultiLevelLabelLayouter.RAISE_AND_CENTER_FIXED_ON_RIGHT_RANGE,
MultiLevelLabelLayouter
.RAISE_AND_CENTER_FLOATING_ON_RIGHT_RANGE.public MultiLevelLabel getLayoutConstraints(int labelLevel)
labelLevel - label level which constraints should be returned. Level
numbering starts at 1.public void setRowSpacing(int rowSpacing)
spacing - desired gap between two label rows in pixelspublic double getRowSpacing()
public void setAxisParams(boolean axisTopOrientated,
double maxLabelHeigth)
axisTopOrientated - the axisTopOrientated to setmaxLabelHeigth - maximum label height
public void setAxisParams(Alignment axisPosition,
double maxLabelDimension)
axisPosition - the axisPosition to setmaxLabelDimension - maximum label height (if axis is oriented TOP or BOTTOM) or width (if axis is on the LEFT or RIGHT)
public void setAxisParams(Orientation axisOrientation,
Alignment axisPosition)
axisOrientation - the axisOrientation to setaxisPosition - the axisPosition to setpublic void setDynamicLabels(boolean dynamicLabels)
dynamicLabels - the dynamicLabels to setpublic boolean isDynamicLabels()
public void setEliminateOverlappingRowsLabels(boolean eliminateOverlappingRowsLabels)
eliminateOverlappingRowsLabels - the eliminate overlapping rows labels to setpublic boolean isEliminateOverlappingRowsLabels()
public void prepare(AbstractAxisLabel[] labels)
LinearLabelLayouter
prepare in interface LinearLabelLayouterprepare in class DefaultLinearLabelLayouterlabels - label arrayprotected void rowPrepare(AxisLabel[] prepareLabels)
prepareLabels - row label arraypublic double getMaxLevelLabelSize()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||