Commit 46ac8b4a authored by Nico Mack's avatar Nico Mack

Implemented reverse mode

parent f91bd55b
......@@ -65,6 +65,7 @@ public class CoxcombSlice extends ValueCorona implements InformationProvider<Obj
protected String label;
protected boolean radialLayout;
protected boolean centered;
protected boolean reversed;
protected boolean blinkOnOutOfRange;
protected boolean faceIsTouchable;
protected boolean wrapToFit;
......@@ -93,7 +94,7 @@ public class CoxcombSlice extends ValueCorona implements InformationProvider<Obj
private double normalizedValue;
private double correctedAngle;
private Area inner;
private Area stencil;
private Area slice;
private Area face;
private Shape labelShape;
......@@ -119,9 +120,12 @@ public class CoxcombSlice extends ValueCorona implements InformationProvider<Obj
this.label = builder.label;
this.radialLayout = builder.radialLayout;
this.centered = builder.centered;
this.reversed = builder.reversed;
this.innerRadius = builder.innerRadius;
this.lowerBoundRadius = Math.min(builder.lowerBoundRadius, builder.upperBoundRadius);
this.upperBoundRadius = Math.max(builder.lowerBoundRadius, builder.upperBoundRadius);
// this.lowerBoundRadius = Math.min(builder.lowerBoundRadius, builder.upperBoundRadius);
// this.upperBoundRadius = Math.max(builder.lowerBoundRadius, builder.upperBoundRadius);
this.lowerBoundRadius = builder.lowerBoundRadius;
this.upperBoundRadius = builder.upperBoundRadius;
this.startAngle = builder.startAngle;
this.arcSpan = builder.arcSpan;
this.labelAngle = builder.labelAngle;
......@@ -156,6 +160,7 @@ public class CoxcombSlice extends ValueCorona implements InformationProvider<Obj
this.label = original.label;
this.radialLayout = original.radialLayout;
this.centered = original.centered;
this.reversed = original.reversed;
this.innerRadius = original.innerRadius;
this.lowerBoundRadius = original.lowerBoundRadius;
this.upperBoundRadius = original.upperBoundRadius;
......@@ -269,7 +274,6 @@ public class CoxcombSlice extends ValueCorona implements InformationProvider<Obj
FontRenderContext renderingContext = new FontRenderContext(null, true, true);
metrics = textFont.getLineMetrics(label, renderingContext);
List<String> lines;
// 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
......@@ -286,10 +290,9 @@ public class CoxcombSlice extends ValueCorona implements InformationProvider<Obj
// ---------------------------------------------------------------------------
private Shape buildSector(double radius, double diameter) {
Shape sector = (arcSpan < AngleUtils.THREE_SIXTY)
return (arcSpan < AngleUtils.THREE_SIXTY)
? new Arc2D.Double(-radius, -radius, diameter, diameter, correctedAngle, arcSpan, Arc2D.PIE)
: new Ellipse2D.Double(-radius, -radius, diameter, diameter);
return sector;
}
// ---------------------------------------------------------------------------
......@@ -301,24 +304,31 @@ public class CoxcombSlice extends ValueCorona implements InformationProvider<Obj
correctedAngle = AngleUtils.moduloThreeSixty(AngleUtils.THREE_SIXTY - startAngle - arcSpan);
diameter = 2 * innerRadius;
inner = new Area(new Ellipse2D.Double(-innerRadius, -innerRadius, diameter, diameter));
stencil = new Area(new Ellipse2D.Double(-innerRadius, -innerRadius, diameter, diameter));
Shape sector = buildSector(lowerBoundRadius, diameter);
Area sectorArea = new Area(sector);
// Shape sector = (arcSpan < AngleUtils.THREE_SIXTY) ? new Arc2D.Double(-lowerBoundRadius,
// -lowerBoundRadius, diameter, diameter, correctedAngle, arcSpan, Arc2D.PIE);
// : new Ellipse2D.Double(-lowerBoundRadius, -lowerBoundRadius, diameter, diameter);
Area initial = new Area(sector);
initial.subtract(inner);
shape = initial;
if (reversed) {
Area initial = new Area(stencil);
initial.subtract(sectorArea);
shape = initial;
} else {
sectorArea.subtract(stencil);
shape = sectorArea;
}
diameter = 2 * upperBoundRadius;
// sector = new Arc2D.Double(-upperBoundRadius, -upperBoundRadius, diameter, diameter,
// correctedAngle, arcSpan, Arc2D.PIE);
sector = buildSector(upperBoundRadius, diameter);
face = new Area(sector);
face.subtract(inner);
sectorArea = new Area(sector);
if (reversed) {
face = new Area(stencil);
face.subtract(sectorArea);
} else {
face = sectorArea;
face.subtract(stencil);
}
int availableWidth;
......@@ -411,10 +421,13 @@ public class CoxcombSlice extends ValueCorona implements InformationProvider<Obj
// ---------------------------------------------------------------------------
public void setNormalizedValue(double value) {
normalizedValue = value;
normalizedValue = Math.abs(value);
if (variable != null) {
double radius = lowerBoundRadius + ((upperBoundRadius - lowerBoundRadius) * normalizedValue);
double radius = (reversed)
? lowerBoundRadius - ((lowerBoundRadius - upperBoundRadius) * normalizedValue)
: lowerBoundRadius + ((upperBoundRadius - lowerBoundRadius) * normalizedValue);
double epsilon = this.variable.getEpsilon();
if (this.blinkOnOutOfRange) {
......@@ -425,12 +438,21 @@ public class CoxcombSlice extends ValueCorona implements InformationProvider<Obj
}
double diameter = 2 * radius;
// Shape sector = new Arc2D.Double(-radius, -radius, diameter, diameter, correctedAngle,
// arcSpan, Arc2D.PIE);
Shape sector = buildSector(radius, diameter);
slice = new Area(sector);
slice.subtract(inner);
shape = slice;
if (reversed) {
Area initial = new Area(stencil);
initial.subtract(slice);
shape = initial;
slice = initial;
} else {
slice.subtract(stencil);
shape = slice;
}
}
}
......
......@@ -43,6 +43,7 @@ public abstract class BaseCoxcombSliceBuilder<B extends BaseCoxcombSliceBuilder<
public String label;
public boolean radialLayout;
public boolean centered;
public boolean reversed;
public boolean blinkOnOutOfRange;
public boolean faceIsTouchable;
public boolean wrapToFit;
......@@ -132,6 +133,7 @@ public abstract class BaseCoxcombSliceBuilder<B extends BaseCoxcombSliceBuilder<
radialLayout = BootstrappingUtils.getContentAsBoolean(rootElement, Externalization.RADIAL_LAYOUT_NODE, BootstrappingUtils.OPTIONAL, Boolean.FALSE, context);
centered = BootstrappingUtils.getContentAsBoolean(rootElement, Externalization.CENTRED_NODE, BootstrappingUtils.OPTIONAL, Boolean.TRUE, context);
reversed = BootstrappingUtils.getContentAsBoolean(rootElement, CpsNamespace.REVERSED_NODE, BootstrappingUtils.OPTIONAL, Boolean.FALSE, context);
cappedDisplay = BootstrappingUtils.getContentAsBoolean(rootElement, CpsNamespace.CAPPED_DISPLAY_NODE, BootstrappingUtils.OPTIONAL, Boolean.FALSE, context);
blinkOnOutOfRange = BootstrappingUtils.getContentAsBoolean(rootElement, CpsNamespace.BLINK_ON_OUT_OF_RANGE_NODE, BootstrappingUtils.OPTIONAL, Boolean.FALSE, context);
faceIsTouchable = BootstrappingUtils.getContentAsBoolean(rootElement, CpsNamespace.FACE_IS_TOUCHABLE_NODE, BootstrappingUtils.OPTIONAL, Boolean.FALSE, context);
......
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