Commit 17119bca authored by Nico Mack's avatar Nico Mack

Modified scaling strategy

parent f0c73390
......@@ -45,7 +45,7 @@ public class ShapeGraph extends ValueCorona {
protected ColorPair fillColour;
protected ColorPair strokeColour;
protected int strokeWidth;
// protected Shape graphShape;
protected Shape scaledShape;
protected Timeline blinkingTimeline;
protected Timeline balisticTimeline;
......@@ -71,6 +71,7 @@ public class ShapeGraph extends ValueCorona {
this.strokeColour = builder.strokeColour;
this.strokeWidth = builder.strokeWidth;
this.shape = builder.graphShape;
this.scaledShape = builder.shape;
borderStroke = (builder.strokeWidth > 0) ? new BasicStroke(builder.strokeWidth) : null;
......@@ -95,6 +96,7 @@ public class ShapeGraph extends ValueCorona {
this.strokeColour = original.strokeColour;
this.strokeWidth = original.strokeWidth;
this.shape = original.shape;
this.scaledShape = original.shape;
borderStroke = (original.strokeWidth > 0) ? new BasicStroke(original.strokeWidth) : null;
......@@ -135,7 +137,9 @@ public class ShapeGraph extends ValueCorona {
shownValue = value;
if (variable != null) {
double size = lowerBound + (upperBound - lowerBound) * (shownValue - this.variable.getMinValue()) / (this.variable.getMaxValue() - this.variable.getMinValue());
// double size = lowerBound + (upperBound - lowerBound) * (shownValue - this.variable.getMinValue())
// / (this.variable.getMaxValue() - this.variable.getMinValue());
double size = lowerBound + ((upperBound - lowerBound) * this.variable.getNormalizedValue());
if (size == upperBound)
this.startBlinking();
......@@ -143,6 +147,9 @@ public class ShapeGraph extends ValueCorona {
this.stopBlinking();
scale = size / lowerBound;
AffineTransform scaler = AffineTransform.getScaleInstance(scale, scale);
scaledShape = scaler.createTransformedShape(this.shape);
}
}
......@@ -150,9 +157,7 @@ public class ShapeGraph extends ValueCorona {
@Override
public Shape getShape() {
AffineTransform transform = this.getTransform(null);
transform.scale(scale, scale);
return transform.createTransformedShape(super.getShape());
return this.scaledShape;
}
// ---------------------------------------------------------------------------
......@@ -164,24 +169,7 @@ public class ShapeGraph extends ValueCorona {
Graphics2D localCanvas = (Graphics2D) canvas.create();
// centre.toScreenCoordinates();
// if (initialTranslation != null)
// initialTranslation.toScreenCoordinates();
// Point drawAt = centre.add(initialTranslation);
//
// if (this.rotateWithHandle) {
// angle = (float) (drawAt.getAngle() % TWO_PI);
// }
//
// AffineTransform translation = new AffineTransform();
// translation.translate(drawAt.x, drawAt.y);
// translation.rotate(angle);
// translation.scale(scale, scale);
// localCanvas.setTransform(translation);
AffineTransform transform = this.getTransform(null);
transform.scale(scale, scale);
localCanvas.setTransform(transform);
if (this.opacity < 1.0f)
......@@ -190,14 +178,14 @@ public class ShapeGraph extends ValueCorona {
if (shape != null) {
if (fillColour != null) {
localCanvas.setPaint(fillColour.getColor());
localCanvas.fill(shape);
localCanvas.fill(scaledShape);
}
if (strokeColour != null) {
localCanvas.setPaint(strokeColour.getColor());
if (borderStroke != null) {
localCanvas.setStroke(borderStroke);
localCanvas.draw(shape);
localCanvas.draw(scaledShape);
}
}
}
......
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