Commit c3089f7a authored by Nico Mack's avatar Nico Mack

Alignment of angular behaviour to TULIP conventions

parent cf5a0dcd
......@@ -185,17 +185,27 @@ public class CoxcombSlice extends ValueCorona implements InformationProvider<Obj
// ---------------------------------------------------------------------------
private Shape buildCircularBaseline(double radius) {
double start = startAngle - arcSpan;
double length = arcSpan;
// double start = startAngle;
// double length = -arcSpan;
Rectangle2D bounds = new Rectangle2D.Double(centre.x - radius, centre.y - radius, (2 * radius), (2 * radius));
return new Arc2D.Double(bounds, start, length, Arc2D.OPEN);
return new Arc2D.Double(bounds, startAngle, arcSpan, Arc2D.OPEN);
}
// ---------------------------------------------------------------------------
/**
* builds the radial baseline for radial text rendering
*
* @param angle
* specifies the baseline angle expressed in radians. Positive angles will rotate the
* baseline in clockwise direction (TULIP convention).
* @param lineHeight
* @return
*/
// ---------------------------------------------------------------------------
private Shape buildRadialBaseline(double angle, double lineHeight) {
Shape centreLine = new Line2D.Double(lowerBoundRadius + insetBorder, lineHeight, upperBoundRadius - insetBorder, lineHeight);
AffineTransform rotate = AffineTransform.getRotateInstance(Math.toRadians(angle));
AffineTransform rotate = AffineTransform.getRotateInstance(AngleUtils.moduloTwoPi(AngleUtils.TWO_PI - angle));
return rotate.createTransformedShape(centreLine);
}
......@@ -203,7 +213,6 @@ public class CoxcombSlice extends ValueCorona implements InformationProvider<Obj
private Shape buildCircularText(List<String> lines, LineMetrics metrics) {
int numberOfLines = lines.size();
double labelRadius = lowerBoundRadius + metrics.getAscent() / 2;
Path2D compound = new Path2D.Float();
......@@ -224,24 +233,26 @@ public class CoxcombSlice extends ValueCorona implements InformationProvider<Obj
int numberOfLines = lines.size();
double radialAngle;
double angularOffset = (metrics.getAscent() / (Math.PI * innerRadius * (arcSpan / AngleUtils.ONE_EIGHTY))) * arcSpan;
double angularSpan = Math.toRadians(arcSpan);
double angularOffset = (metrics.getAscent() / (Math.PI * innerRadius * (angularSpan / Math.PI))) * angularSpan;
if (Double.isNaN(this.labelAngle)) {
radialAngle = (arcSpan / 2) + Math.floor((double) numberOfLines / 2) * angularOffset;
radialAngle = (angularSpan / 2) + Math.floor((double) numberOfLines / 2) * angularOffset;
} else {
radialAngle = this.labelAngle;
radialAngle = Math.toRadians(this.labelAngle);
}
angle = AngleUtils.moduloThreeSixty(angle - radialAngle);
double lineHeight = metrics.getAscent() / 2;
Path2D compound = new Path2D.Float();
double baselineAngle = AngleUtils.moduloTwoPi(Math.toRadians(angle) + radialAngle);
for (String line : lines) {
Shape labelPath = this.buildRadialBaseline(angle, lineHeight);
Shape labelPath = this.buildRadialBaseline(baselineAngle, lineHeight);
TextStroke stroke = new TextStroke(line, textFont, false, centered, false);
Shape radialText = stroke.createStrokedShape(labelPath);
compound.append(radialText, false);
angle = AngleUtils.moduloThreeSixty(angle + angularOffset);
baselineAngle = AngleUtils.moduloTwoPi(baselineAngle - angularOffset);
}
return new Area(compound);
......@@ -256,13 +267,11 @@ public class CoxcombSlice extends ValueCorona implements InformationProvider<Obj
LineMetrics metrics = textFont.getLineMetrics(label, renderingContext);
List<String> lines;
double angle = AngleUtils.moduloThreeSixty(startAngle);
// Java Arc2D start angle and extend are expressed in counter clockwise rotation. Since
// TULIP follows the clockwise TUIO convention, we need to convert both startAngle and
// extend.
angle = (AngleUtils.THREE_SIXTY - angle);
startAngle = AngleUtils.moduloThreeSixty(AngleUtils.THREE_SIXTY - startAngle - arcSpan);
diameter = 2 * innerRadius;
inner = new Area(new Ellipse2D.Double(-innerRadius, -innerRadius, diameter, diameter));
......@@ -270,7 +279,7 @@ public class CoxcombSlice extends ValueCorona implements InformationProvider<Obj
diameter = 2 * lowerBoundRadius;
outer = new Area(new Ellipse2D.Double(-lowerBoundRadius, -lowerBoundRadius, diameter, diameter));
Shape sector = new Arc2D.Double(-lowerBoundRadius, -lowerBoundRadius, diameter, diameter, angle, -arcSpan, Arc2D.PIE);
Shape sector = new Arc2D.Double(-lowerBoundRadius, -lowerBoundRadius, diameter, diameter, startAngle, arcSpan, Arc2D.PIE);
Area initial = new Area(sector);
initial.subtract(inner);
outer.subtract(inner);
......@@ -302,7 +311,7 @@ public class CoxcombSlice extends ValueCorona implements InformationProvider<Obj
if (!radialLayout) {
labelShape = this.buildCircularText(lines, metrics);
} else {
labelShape = this.buildRadialText(lines, metrics, angle);
labelShape = this.buildRadialText(lines, metrics, startAngle);
}
this.setInformation(this.variable.getValue());
......
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