Commit 8b553454 authored by Nico Mack's avatar Nico Mack

Minor code change to handle scripting of arc properties

parent 77bb9823
......@@ -167,29 +167,14 @@ public class ArcGraph extends ValueCorona {
// ---------------------------------------------------------------------------
private void buildFromProperties() {
double diameter;
if ((this.label == null) || this.label.isEmpty()) {
this.label = this.variable.getDisplayName();
}
diameter = 2 * innerRadius;
inner = new Area(new Ellipse2D.Double(-innerRadius, -innerRadius, diameter, diameter));
diameter = 2 * outerRadius;
outer = new Area(new Ellipse2D.Double(-outerRadius, -outerRadius, diameter, diameter));
// 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
// extend.
startAngle = ((int) AngleUtils.THREE_SIXTY - startAngle);
arcSpan = -arcSpan;
this.startAngle = ((int) AngleUtils.THREE_SIXTY - startAngle);
this.arcSpan = -this.arcSpan;
Shape sector = new Arc2D.Double(-outerRadius, -outerRadius, diameter, diameter, startAngle, arcSpan, Arc2D.PIE);
face = new Area(sector);
face.subtract(inner);
outer.subtract(inner);
this.updateArc();
if ((this.labelFormat != null) && (!this.labelFormat.isEmpty())) {
this.variableFormat = new VariableFormat(this.labelFormat);
......@@ -220,6 +205,28 @@ public class ArcGraph extends ValueCorona {
// ---------------------------------------------------------------------------
private void updateArc() {
double angle;
double span;
double diameter = 2 * innerRadius;
inner = new Area(new Ellipse2D.Double(-innerRadius, -innerRadius, diameter, diameter));
diameter = 2 * outerRadius;
outer = new Area(new Ellipse2D.Double(-outerRadius, -outerRadius, diameter, diameter));
// 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
// extend.
Shape sector = new Arc2D.Double(-outerRadius, -outerRadius, diameter, diameter, startAngle, arcSpan, Arc2D.PIE);
face = new Area(sector);
face.subtract(inner);
outer.subtract(inner);
}
// ---------------------------------------------------------------------------
private Point getOffsetFromCenter() {
double alpha = Math.toRadians(this.startAngle);
boolean clockwise = (this.arcSpan < 0);
......@@ -338,6 +345,11 @@ public class ArcGraph extends ValueCorona {
if (!active)
return;
if (this.readAndResetPropertyChanged()) {
this.updateArc();
}
Graphics2D localCanvas = (Graphics2D) canvas.create();
AffineTransform translation = this.getTransform(null);
......
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