5.2.4 Axis Layouters

All axis of Axis2D type use classes that implement label layout strategy. Layouters are configured with axis parameters that give a possibility to filter and arrange a list of labels. They might be added to axis LabelSettings, using setLabelLayouter method, for instance axisX.getLabelSettings().setLabelLayouter().

Label filtering depends on type of label layouter.

Layouter Description
SimpleLinearLabelLayouterIt only removes labels that intersect or are out of axis bounds.
MultiLevelLabelLayouterThis layouter is used to layout labels of multiple levels.

Table 5.2.4.1 Axis Layouters

MultiLevelLabelLayouter

MultiLevelLabelLayouter is used to layout labels of multiple levels. This layouter might be used for DateAxisMapper, GroupedLabelsAxisMapper, and DateListAxisMapper. DateFormats must be set for appropriate mappers.

1
2
3
4
5
6
7
8
9
10
11
12
13
// sets MultiLevelLabelLayouter object named lay
MultiLevelLabelLayouter lay = new MultiLevelLabelLayouter();
// setting which parts of mappers should be heightened
lay.setLayoutConstraints(1, MultiLevelLabel.RAISE);
lay.setLayoutConstraints(2, MultiLevelLabel.RAISE);
lay.setLayoutConstraints(3, MultiLevelLabel.RAISE);
lay.setLayoutConstraints(4, MultiLevelLabel.RAISE);
 
// ....
 
// adding layouter to x-axis which contains mapper
// instance of DateAxisMapper or DateListAxisMapper
axisX.getLabelSettings().setLabelLayouter(lay);

MultiLevelLayouter Demonstration

Figure 5.2.4.1 MultiLevelLayouter Demonstration

View Source

Creating MultiLevelLabelLayouter with grouped labels:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// creating grouped labels
LabelsGroup g21 = new LabelsGroup("Software");
g21.add(new LabelsGroup("OS"));
g21.add(new LabelsGroup("Contacts"));
// ...
LabelsGroup g22 = new LabelsGroup("Hardware");
g22.add(new LabelsGroup("Screen"));
g22.add(new LabelsGroup("Keybard"));
// ...
LabelsGroup allLabels = new LabelsGroup(null);
allLabels.add(g22);
allLabels.add(g21);
// ...
// creating grouped mapper
GroupedLabelsAxisMapper xMapper = new (allLabels);
 
//setting multi level label layouter
MultiLevelLabelLayouter layouter = new MultiLevelLabelLayouter();
layouter.setEliminateOverlappingRowsLabels(false);
layouter.setLayoutConstraints(1, MultiLevelLabel.RAISE);
layouter.setLayoutConstraints(2, MultiLevelLabel.RAISE);
 
xAxis.getLabelSettings().setLabelLayouter(layouter);

|MultiLevelLayouter Demonstration

Figure 5.2.4.2 MultiLevelLayouter (Grouped labels) Demonstration

Creating MultiLevelLabelLayouter with wrapped word labels:

Note: Words wrapping on axis labels by default is off.

1
2
3
4
5
6
7
8
9
// sets MultiLevelLabelLayouter object named lay
MultiLevelLabelLayouter lay = new MultiLevelLabelLayouter();
// sets words wrapping
lay.setDoWordWrap(true);
// setting which parts of mappers should be heightened
lay.setLayoutConstraints(1, MultiLevelLabel.RAISE);
lay.setLayoutConstraints(2, MultiLevelLabel.RAISE);
 
// ....

MultiLevelLayouter With Word Wrapping Demonstration

Figure 5.2.4.3 MultiLevelLayouter With Words Wrapping Demonstration