Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2014-05-08 21:58:04 +0000
committerTom Schindl2014-05-08 21:58:04 +0000
commit8e04b4386f4ed909c0a5ab3868e6e9239c7c56e4 (patch)
treebe147d5dd69c384c784fa5701ea2a3a7ed194fdc
parent9814fb60824a68eac793b4a2057729ce1d54e89e (diff)
parent63c18e69023ac0a866ad45dfecbf1a6463245634 (diff)
downloadorg.eclipse.efxclipse-8e04b4386f4ed909c0a5ab3868e6e9239c7c56e4.tar.gz
org.eclipse.efxclipse-8e04b4386f4ed909c0a5ab3868e6e9239c7c56e4.tar.xz
org.eclipse.efxclipse-8e04b4386f4ed909c0a5ab3868e6e9239c7c56e4.zip
Merge branch 'master' of ssh://tschindl@git.eclipse.org:29418/efxclipse/org.eclipse.efxclipse
-rw-r--r--experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/graphics/Device.java5
-rw-r--r--experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/graphics/Drawable.java1
-rw-r--r--experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/graphics/GC.java14
-rw-r--r--experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/graphics/Path.java92
-rw-r--r--experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/internal/CanvasGC.java17
-rw-r--r--experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/internal/MeasureGC.java5
6 files changed, 78 insertions, 56 deletions
diff --git a/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/graphics/Device.java b/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/graphics/Device.java
index 05d96ec84..6bcac5a9f 100644
--- a/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/graphics/Device.java
+++ b/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/graphics/Device.java
@@ -146,6 +146,11 @@ public abstract class Device implements Drawable {
}
@Override
+ public void getTransform(Transform transform) {
+ Util.logNotImplemented();
+ }
+
+ @Override
public void setForeground(Color color) {
Util.logNotImplemented();
}
diff --git a/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/graphics/Drawable.java b/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/graphics/Drawable.java
index 4a2640dc1..fcbe88057 100644
--- a/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/graphics/Drawable.java
+++ b/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/graphics/Drawable.java
@@ -65,6 +65,7 @@ public interface Drawable {
public void setBackgroundPattern(Pattern pattern);
public void setForegroundPattern(Pattern pattern);
public void drawOval(int x, int y, int width, int height);
+ public void getTransform(Transform transform);
}
public DrawableGC internal_new_GC();
diff --git a/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/graphics/GC.java b/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/graphics/GC.java
index 10135d44b..5d7daf4b1 100644
--- a/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/graphics/GC.java
+++ b/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/graphics/GC.java
@@ -319,9 +319,9 @@ public class GC extends Resource {
//
// }
//
-// public void getTransform (Transform transform) {
-//
-// }
+ public void getTransform (Transform transform) {
+ gc.getTransform(transform);
+ }
//
// public boolean getXORMode() {
//
@@ -430,10 +430,10 @@ public class GC extends Resource {
//
// }
//
-// public void setTextAntialias(int antialias) {
-//
-// }
-//
+ public void setTextAntialias(int antialias) {
+ // keep the API method, but JavaFX will always antialias text
+ }
+
public void setTransform(Transform transform) {
gc.setTransform(transform);
}
diff --git a/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/graphics/Path.java b/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/graphics/Path.java
index 2a791b8ef..5e533cea9 100644
--- a/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/graphics/Path.java
+++ b/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/graphics/Path.java
@@ -11,9 +11,13 @@
*******************************************************************************/
package org.eclipse.swt.graphics;
-import org.eclipse.swt.internal.Util;
+import javafx.scene.shape.Rectangle;
+import com.sun.javafx.geom.Arc2D;
import com.sun.javafx.geom.Path2D;
+import com.sun.javafx.geom.RectBounds;
+import com.sun.javafx.geom.RoundRectangle2D;
+import com.sun.javafx.geom.Shape;
import com.sun.javafx.scene.text.TextLayout;
import com.sun.javafx.scene.text.TextLayoutFactory;
import com.sun.javafx.tk.Toolkit;
@@ -30,18 +34,20 @@ public class Path extends Resource {
return path;
}
-// public void addArc(float x, float y, float width, float height, float startAngle, float arcAngle) {
-//
-// }
-//
-// public void addPath(Path path) {
-//
-// }
-//
-// public void addRectangle(float x, float y, float width, float height) {
-//
-// }
-//
+ public void addArc(float x, float y, float width, float height, float startAngle, float arcAngle) {
+ Arc2D arc2d = new Arc2D(x, y, width, height, startAngle, arcAngle, Arc2D.OPEN);
+ path.append(arc2d, false);
+ }
+
+ public void addPath(Path path) {
+ this.path.append(path.internal_getNativeObject().getPathIterator(null), false);
+ }
+
+ public void addRectangle(float x, float y, float width, float height) {
+ RoundRectangle2D rect = new RoundRectangle2D(x, y, width, height, 0, 0);
+ path.append((Shape)rect, false);
+ }
+
public void addString(String string, float x, float y, Font font) {
int type = TextLayout.TYPE_TEXT | TextLayout.TYPE_TOP;
TextLayoutFactory factory = Toolkit.getToolkit().getTextLayoutFactory();
@@ -51,51 +57,55 @@ public class Path extends Resource {
}
public void close() {
-
+ path.closePath();
}
-// public boolean contains(float x, float y, GC gc, boolean outline) {
-//
-// }
+ public boolean contains(float x, float y, GC gc, boolean outline) {
+ // FIXME what are gc and outline used for?
+ return path.contains(x, y);
+ }
//
// public void cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) {
//
// }
-//
-// public void getBounds(float[] bounds) {
-//
-// }
-//
-// public void getCurrentPoint(float[] point) {
-//
-// }
-//
+
+ public void getBounds(float[] bounds) {
+ RectBounds pathBounds = path.getBounds();
+ bounds[0] = pathBounds.getMinX();
+ bounds[1] = pathBounds.getMinY();
+ bounds[2] = pathBounds.getWidth();
+ bounds[3] = pathBounds.getHeight();
+ }
+
+ public void getCurrentPoint(float[] point) {
+ point[0] = path.getCurrentX();
+ point[1] = path.getCurrentY();
+ }
+
// public PathData getPathData() {
//
// }
//
-// public void lineTo(float x, float y) {
-//
-// }
-//
-// public void moveTo(float x, float y) {
-//
-// }
-//
-// public void quadTo(float cx, float cy, float x, float y) {
-//
-// }
+ public void lineTo(float x, float y) {
+ path.lineTo(x, y);
+ }
+
+ public void moveTo(float x, float y) {
+ path.moveTo(x, y);
+ }
+
+ public void quadTo(float cx, float cy, float x, float y) {
+ path.quadTo(cx, cy, x, y);
+ }
@Override
public void dispose() {
- // TODO Auto-generated method stub
-
+ path = null;
}
@Override
public boolean isDisposed() {
- // TODO Auto-generated method stub
- return false;
+ return path == null;
}
}
diff --git a/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/internal/CanvasGC.java b/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/internal/CanvasGC.java
index 8b9ef669c..9aba71a3b 100644
--- a/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/internal/CanvasGC.java
+++ b/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/internal/CanvasGC.java
@@ -27,7 +27,6 @@ import javafx.scene.shape.StrokeLineCap;
import javafx.scene.shape.StrokeLineJoin;
import javafx.scene.text.TextAlignment;
import javafx.scene.transform.Affine;
-import javafx.scene.transform.Translate;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
@@ -56,7 +55,6 @@ public class CanvasGC implements DrawableGC {
private javafx.scene.paint.Color defaultBackground = javafx.scene.paint.Color.BLACK;
private javafx.scene.paint.Color defaultForeground = javafx.scene.paint.Color.BLACK;
- private Affine defaultTransform = new Affine();
//TODO Need to pass those values
private Font receiverFont;
@@ -141,6 +139,11 @@ public class CanvasGC implements DrawableGC {
}
@Override
+ public void getTransform(Transform transform) {
+ canvas.getGraphicsContext2D().getTransform(transform.internal_getNativeObject());
+ }
+
+ @Override
public void setForeground(Color color) {
this.foregroundColor = color;
canvas.getGraphicsContext2D().setStroke(color != null ? color.internal_getNativeObject() : defaultForeground );
@@ -580,15 +583,13 @@ public class CanvasGC implements DrawableGC {
@Override
public void drawShape(int xDelta, int yDelta, Shape shape) {
+ Affine oldTransform = canvas.getGraphicsContext2D().getTransform();
Affine transform = canvas.getGraphicsContext2D().getTransform();
- Translate translate = Affine.translate(xDelta, yDelta);
+ transform.appendTranslation(xDelta, yDelta);
- canvas.getGraphicsContext2D().setTransform(
- translate.getMxx(),translate.getMyx(),
- translate.getMxy(),translate.getMyy(),
- translate.getTx(),translate.getTy());
- path(shape.getPathIterator(null), true);
canvas.getGraphicsContext2D().setTransform(transform);
+ path(shape.getPathIterator(null), true);
+ canvas.getGraphicsContext2D().setTransform(oldTransform);
}
@Override
diff --git a/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/internal/MeasureGC.java b/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/internal/MeasureGC.java
index efc90d619..282c68c34 100644
--- a/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/internal/MeasureGC.java
+++ b/experimental/swt/org.eclipse.fx.runtime.swt/src/org/eclipse/swt/internal/MeasureGC.java
@@ -65,6 +65,11 @@ public class MeasureGC implements DrawableGC {
public void setTransform(Transform transform) {
// Not applicable
}
+
+ @Override
+ public void getTransform(Transform transform) {
+ // Not applicable
+ }
@Override
public void setForeground(Color color) {

Back to the top