You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by tv...@apache.org on 2009/05/01 00:29:59 UTC
svn commit: r770473 - in /incubator/pivot/trunk/wtk/src/pivot/wtk/media:
Drawing.java Movie.java drawing/Path.java drawing/Shape.java
Author: tvolkert
Date: Thu Apr 30 22:29:59 2009
New Revision: 770473
URL: http://svn.apache.org/viewvc?rev=770473&view=rev
Log:
Fixed numerous issues in the drawing implementation classes
Modified:
incubator/pivot/trunk/wtk/src/pivot/wtk/media/Drawing.java
incubator/pivot/trunk/wtk/src/pivot/wtk/media/Movie.java
incubator/pivot/trunk/wtk/src/pivot/wtk/media/drawing/Path.java
incubator/pivot/trunk/wtk/src/pivot/wtk/media/drawing/Shape.java
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/media/Drawing.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/media/Drawing.java?rev=770473&r1=770472&r2=770473&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/media/Drawing.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/media/Drawing.java Thu Apr 30 22:29:59 2009
@@ -145,16 +145,16 @@
public void paint(Graphics2D graphics) {
graphics.clipRect(0, 0, width, height);
- graphics.setPaint(background);
- graphics.fillRect(0, 0, width, height);
+ if (background != null) {
+ graphics.setPaint(background);
+ graphics.fillRect(0, 0, width, height);
+ }
if (canvas != null) {
// TODO Make this configurable?
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
- Bounds bounds = canvas.getBounds();
- graphics.translate(bounds.x, bounds.y);
canvas.draw(graphics);
}
}
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/media/Movie.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/media/Movie.java?rev=770473&r1=770472&r2=770473&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/media/Movie.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/media/Movie.java Thu Apr 30 22:29:59 2009
@@ -28,7 +28,7 @@
* @author tvolkert
*/
public abstract class Movie implements Visual {
- private static class MovieListenerList extends ListenerList<MovieListener>
+ protected static class MovieListenerList extends ListenerList<MovieListener>
implements MovieListener {
public void currentFrameChanged(Movie movie, int previousFrame) {
for (MovieListener listener : this) {
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/media/drawing/Path.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/media/drawing/Path.java?rev=770473&r1=770472&r2=770473&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/media/drawing/Path.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/media/drawing/Path.java Thu Apr 30 22:29:59 2009
@@ -40,7 +40,7 @@
* @author tvolkert
*/
public static abstract class Operation {
- Path path = null;
+ private Path path = null;
/**
* Private constructor to prevent others from extending this class.
@@ -131,6 +131,7 @@
if (this.x != x) {
this.x = x;
+ Path path = getPath();
if (path != null) {
path.invalidate();
path.pathListeners.operationUpdated(this);
@@ -152,6 +153,7 @@
if (this.y != y) {
this.y = y;
+ Path path = getPath();
if (path != null) {
path.invalidate();
path.pathListeners.operationUpdated(this);
@@ -194,6 +196,7 @@
if (this.x != x) {
this.x = x;
+ Path path = getPath();
if (path != null) {
path.invalidate();
path.pathListeners.operationUpdated(this);
@@ -209,6 +212,7 @@
if (this.y != y) {
this.y = y;
+ Path path = getPath();
if (path != null) {
path.invalidate();
path.pathListeners.operationUpdated(this);
@@ -262,6 +266,7 @@
if (this.x1 != x1) {
this.x1 = x1;
+ Path path = getPath();
if (path != null) {
path.invalidate();
path.pathListeners.operationUpdated(this);
@@ -277,6 +282,7 @@
if (this.y1 != y1) {
this.y1 = y1;
+ Path path = getPath();
if (path != null) {
path.invalidate();
path.pathListeners.operationUpdated(this);
@@ -292,6 +298,7 @@
if (this.x2 != x2) {
this.x2 = x2;
+ Path path = getPath();
if (path != null) {
path.invalidate();
path.pathListeners.operationUpdated(this);
@@ -307,6 +314,7 @@
if (this.y2 != y2) {
this.y2 = y2;
+ Path path = getPath();
if (path != null) {
path.invalidate();
path.pathListeners.operationUpdated(this);
@@ -322,6 +330,7 @@
if (this.x3 != x3) {
this.x3 = x3;
+ Path path = getPath();
if (path != null) {
path.pathListeners.operationUpdated(this);
path.invalidate();
@@ -337,6 +346,7 @@
if (this.y3 != y3) {
this.y3 = y3;
+ Path path = getPath();
if (path != null) {
path.invalidate();
path.pathListeners.operationUpdated(this);
@@ -386,6 +396,7 @@
if (this.x1 != x1) {
this.x1 = x1;
+ Path path = getPath();
if (path != null) {
path.pathListeners.operationUpdated(this);
path.invalidate();
@@ -401,6 +412,7 @@
if (this.y1 != y1) {
this.y1 = y1;
+ Path path = getPath();
if (path != null) {
path.invalidate();
path.pathListeners.operationUpdated(this);
@@ -416,6 +428,7 @@
if (this.x2 != x2) {
this.x2 = x2;
+ Path path = getPath();
if (path != null) {
path.invalidate();
path.pathListeners.operationUpdated(this);
@@ -431,6 +444,7 @@
if (this.y2 != y2) {
this.y2 = y2;
+ Path path = getPath();
if (path != null) {
path.invalidate();
path.pathListeners.operationUpdated(this);
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/media/drawing/Shape.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/media/drawing/Shape.java?rev=770473&r1=770472&r2=770473&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/media/drawing/Shape.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/media/drawing/Shape.java Thu Apr 30 22:29:59 2009
@@ -67,9 +67,21 @@
* @author gbrown
*/
public static final class Rotate extends Transform {
- private double angle = 0;
+ private double angle;
+ private double anchorX;
+ private double anchorY;
private AffineTransform affineTransform = null;
+ public Rotate() {
+ this(0, 0, 0);
+ }
+
+ public Rotate(double angle, double anchorX, double anchorY) {
+ this.angle = angle;
+ this.anchorX = anchorX;
+ this.anchorY = anchorY;
+ }
+
public double getAngle() {
return angle;
}
@@ -82,6 +94,37 @@
Shape shape = getShape();
if (shape != null) {
shape.invalidate();
+ shape.transformSequence.affineTransform = null;
+ shape.shapeTransformListeners.transformUpdated(this);
+ }
+ }
+ }
+
+ public double getAnchorX() {
+ return anchorX;
+ }
+
+ public void setAnchorX(double anchorX) {
+ setAnchor(anchorX, anchorY);
+ }
+
+ public double getAnchorY() {
+ return anchorY;
+ }
+
+ public void setAnchorY(double anchorY) {
+ setAnchor(anchorX, anchorY);
+ }
+
+ public void setAnchor(double anchorX, double anchorY) {
+ if (this.anchorY != anchorY) {
+ this.anchorY = anchorY;
+ affineTransform = null;
+
+ Shape shape = getShape();
+ if (shape != null) {
+ shape.invalidate();
+ shape.transformSequence.affineTransform = null;
shape.shapeTransformListeners.transformUpdated(this);
}
}
@@ -90,7 +133,7 @@
public AffineTransform getAffineTransform() {
if (affineTransform == null) {
double radians = (2 * Math.PI) / 360 * angle;
- affineTransform = AffineTransform.getRotateInstance(radians);
+ affineTransform = AffineTransform.getRotateInstance(radians, anchorX, anchorY);
}
return affineTransform;
@@ -133,6 +176,7 @@
Shape shape = getShape();
if (shape != null) {
shape.invalidate();
+ shape.transformSequence.affineTransform = null;
shape.shapeTransformListeners.transformUpdated(this);
}
}
@@ -183,6 +227,7 @@
Shape shape = getShape();
if (shape != null) {
shape.invalidate();
+ shape.transformSequence.affineTransform = null;
shape.shapeTransformListeners.transformUpdated(this);
}
}
@@ -207,8 +252,8 @@
private AffineTransform affineTransform = null;
public int add(Transform transform) {
- int index = transforms.getLength();
- transforms.insert(transform, index);
+ int index = getLength();
+ insert(transform, index);
return index;
}
@@ -218,7 +263,8 @@
}
public void insert(Transform transform, int index) {
- if (transform.getShape() != null) {
+ if (transform == null
+ || transform.getShape() != null) {
throw new IllegalArgumentException();
}
@@ -232,9 +278,9 @@
}
public int remove(Transform transform) {
- int index = transforms.indexOf(transform);
+ int index = indexOf(transform);
if (index != -1) {
- transforms.remove(index, 1);
+ remove(index, 1);
}
return index;