Commit 37938622 authored by Tiziano Munaro's avatar Tiziano Munaro

Improve readability of labels

Issue-Ref: 3452
Issue-Url: https://af3-developer.fortiss.org/issues/3452Signed-off-by: Tiziano Munaro's avatarTiziano Munaro <munaro@fortiss.org>
parent be33ad7f
SpiderChartCanvas.java fd348bdd520fbab08b4c910ec0b76fc6512ea408 YELLOW SpiderChartCanvas.java fd348bdd520fbab08b4c910ec0b76fc6512ea408 YELLOW
SpiderChartControl.java 40459f05b754423a6017dcc1769ba85b6f5ede6a YELLOW SpiderChartControl.java e74c5015dbe19de93169ff9484ad8f37feda3242 YELLOW
SpiderChartControlBase.java 12e98b77abfe0eeb6de22964b33bdfce056f157d YELLOW SpiderChartControlBase.java 12e98b77abfe0eeb6de22964b33bdfce056f157d YELLOW
SpiderChartLegendControl.java 5e8b47a4433ae5ce2da6b7cd613f5059f5bc9589 YELLOW SpiderChartLegendControl.java 5e8b47a4433ae5ce2da6b7cd613f5059f5bc9589 YELLOW
SpiderChartTitleControl.java 64f026ea79a39c0e82d840e1920f1873a367e6ce YELLOW SpiderChartTitleControl.java 64f026ea79a39c0e82d840e1920f1873a367e6ce YELLOW
......
...@@ -182,12 +182,13 @@ public final class SpiderChartControl extends SpiderChartControlBase { ...@@ -182,12 +182,13 @@ public final class SpiderChartControl extends SpiderChartControlBase {
String label = dStyle.getFormattedLabel(axis, value); String label = dStyle.getFormattedLabel(axis, value);
Dimension2D textExtent = fontStyle.getTextBounds(label); Dimension2D textExtent = fontStyle.getTextBounds(label);
// data series indicator labels are always to the right of the point // data series indicator labels are always to the right of the point
double x = p.getX() + 4; int offset = 5;
double x = p.getX() + offset;
double y = p.getY(); double y = p.getY();
if(y > center.getY()) { if(y > center.getY()) {
y = y + 4; y = y + offset + textExtent.getHeight() / 2;
} else if(y < center.getY()) { } else if(y < center.getY()) {
y = y - 4 - textExtent.getHeight(); y = y - offset;
} else { } else {
y = y - textExtent.getHeight() / 2; y = y - textExtent.getHeight() / 2;
} }
...@@ -292,20 +293,18 @@ public final class SpiderChartControl extends SpiderChartControlBase { ...@@ -292,20 +293,18 @@ public final class SpiderChartControl extends SpiderChartControlBase {
String axisLabel = axis.getName(); String axisLabel = axis.getName();
FontStyle labelStyle = style.getLabelStyle(); FontStyle labelStyle = style.getLabelStyle();
Dimension2D tb = labelStyle.getTextBounds(axisLabel); Dimension2D tb = labelStyle.getTextBounds(axisLabel);
double textExtent = tb.getWidth(); int offset = 20;
if(outerX > centerX) { if(outerX > centerX) {
outerX += 5; outerX += offset;
} else if(outerX < centerX) { } else if(outerX < centerX) {
outerX = outerX - 5 - textExtent; outerX = outerX - offset - tb.getWidth();
} else { } else {
outerX = outerX - textExtent / 2; outerX = outerX - tb.getWidth() / 2;
} }
if(outerY > centerY) { if(outerY > centerY) {
outerY = outerY + 5; outerY = outerY + offset + tb.getHeight() / 2;
} else if(outerY < centerY) { } else if(outerY < centerY) {
outerY = outerY - 5 - tb.getHeight(); outerY = outerY - offset;
} else {
outerY = outerY - tb.getHeight() / 2;
} }
labelStyle.drawText(gc, axisLabel, outerX, outerY); labelStyle.drawText(gc, axisLabel, outerX, outerY);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment