Commit 22136e1c authored by Nico Mack's avatar Nico Mack

Fixed a minor bug in buildFromProperties method

parent 9ade8ff7
......@@ -57,6 +57,7 @@ public class Sector extends SelectableCorona {
protected boolean radialLayout;
protected TouchManager touchManager;
protected FontRenderContext renderingContext = new FontRenderContext(null, true, true);
// ***************************************************************************
// * Constants *
......@@ -141,11 +142,17 @@ public class Sector extends SelectableCorona {
// ---------------------------------------------------------------------------
private int getSpan() {
return arcSpan - gap;
}
// ---------------------------------------------------------------------------
private void buildSectorFromProperties() {
size = 2 * outerRadius;
double angle = this.getAngle();
arcSpan -= gap;
int span = getSpan();
// Java Arc3D start angle and extend are expressed in counter clockwise rotation. Since
// TULIP follows the clockwise TUIO convention, we need to convert both startAngle and
......@@ -153,7 +160,7 @@ public class Sector extends SelectableCorona {
angle = (AngleUtils.THREE_SIXTY - angle);
Area pie = new Area(new Arc2D.Double(-outerRadius, -outerRadius, size, size, angle, -arcSpan, Arc2D.PIE));
Area pie = new Area(new Arc2D.Double(-outerRadius, -outerRadius, size, size, angle, -span, Arc2D.PIE));
Area background = new Area(new Ellipse2D.Double(-outerRadius, -outerRadius, size, size));
Area hole = new Area(new Ellipse2D.Double(-innerRadius, -innerRadius, innerRadius * 2, innerRadius * 2));
......@@ -173,29 +180,29 @@ public class Sector extends SelectableCorona {
if ((newLabel != null) && (newLabel.length() > 0)) {
boolean flipped = false;
double angle = this.getAngle();
int span = getSpan();
int quadrant = AngleUtils.getQuadrant(Math.toRadians(angle));
angle = AngleUtils.THREE_SIXTY - angle;
FontRenderContext renderingContext = new FontRenderContext(null, true, true);
LineMetrics metrics = textFont.getLineMetrics(newLabel, renderingContext);
Shape labelPath;
if (!radialLayout) {
flipped = (quadrant == 2) || (quadrant == 3);
double labelRadius = outerRadius - metrics.getAscent() / 2;
double start = (!flipped) ? angle - arcSpan : angle;
int length = (!flipped) ? arcSpan : -arcSpan;
double start = (!flipped) ? angle - span : angle;
int length = (!flipped) ? span : -span;
Rectangle2D bounds = new Rectangle2D.Double(centre.x - labelRadius,
centre.y - labelRadius,
Rectangle2D bounds = new Rectangle2D.Double(-labelRadius,
-labelRadius,
(2 * labelRadius),
(2 * labelRadius));
labelPath = new Arc2D.Double(bounds, start, length, Arc2D.OPEN);
} else {
angle = AngleUtils.moduloThreeSixty(startAngle + ((double) arcSpan / 2));
angle = AngleUtils.moduloThreeSixty(startAngle + ((double) span / 2));
flipped = (quadrant == 1) || (quadrant == 2);
double lineHeight = metrics.getAscent() / 2;
......
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