Upgrade to GEF 3.10
diff --git a/bundles/org.eclipse.rap.draw2d.compatibility/src/org/eclipse/draw2d/rap/swt/graphics/LineAttributes.java b/bundles/org.eclipse.rap.draw2d.compatibility/src/org/eclipse/draw2d/rap/swt/graphics/LineAttributes.java
index 76bf199..1ab0ddd 100644
--- a/bundles/org.eclipse.rap.draw2d.compatibility/src/org/eclipse/draw2d/rap/swt/graphics/LineAttributes.java
+++ b/bundles/org.eclipse.rap.draw2d.compatibility/src/org/eclipse/draw2d/rap/swt/graphics/LineAttributes.java
@@ -119,5 +119,23 @@
public LineAttributes( final float width, final int cap, final int join ) {
super(width,cap,join);
}
-
+
+ /**
+ * Create a new line attributes with the specified arguments.
+ * @param width
+ * @param cap
+ * @param join
+ * @param style
+ * @param dash
+ * @param dashOffset
+ * @param miterLimit
+ */
+ public LineAttributes(float width, int cap, int join, int style, float[] dash, float dashOffset, float miterLimit) {
+ this(width,cap,join);
+ this.style = style;
+ this.dash = dash;
+ this.dashOffset = dashOffset;
+ this.miterLimit = miterLimit;
+ }
+
}
diff --git a/bundles/org.eclipse.rap.draw2d/readme.txt b/bundles/org.eclipse.rap.draw2d/readme.txt
index fd7a66e..ce93b3c 100644
--- a/bundles/org.eclipse.rap.draw2d/readme.txt
+++ b/bundles/org.eclipse.rap.draw2d/readme.txt
@@ -1 +1 @@
-The source version of this port is: 3.9.200.qualifier
\ No newline at end of file
+The source version of this port is: 3.10.0.qualifier
\ No newline at end of file
diff --git a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/BorderLayout.java b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/BorderLayout.java
index f28ddb3..62ac062 100644
--- a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/BorderLayout.java
+++ b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/BorderLayout.java
@@ -110,7 +110,7 @@
/**
* @see AbstractLayout#calculatePreferredSize(IFigure, int, int)
*/
- protected Dimension calculatePreferredSize(IFigure container, int wHint,
+ protected Dimension calculatePreferredSize(IFigure figure, int wHint,
int hHint) {
int minWHint = 0, minHHint = 0;
if (wHint < 0)
@@ -119,7 +119,7 @@
if (hHint < 0)
minHHint = -1;
- Insets border = container.getInsets();
+ Insets border = figure.getInsets();
wHint = Math.max(minWHint, wHint - border.getWidth());
hHint = Math.max(minHHint, hHint - border.getHeight());
Dimension prefSize = new Dimension();
@@ -167,6 +167,7 @@
prefSize.width = Math.max(prefSize.width, middleRowWidth)
+ border.getWidth() + ((columns - 1) * hGap);
+ prefSize.union(getBorderPreferredSize(figure));
return prefSize;
}
diff --git a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/ButtonModel.java b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/ButtonModel.java
index 7597cfd..bccaf90 100644
--- a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/ButtonModel.java
+++ b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/ButtonModel.java
@@ -451,7 +451,6 @@
// RAPEND: [am]
}
-
/**
* Sets the pressed property of this button.
*
diff --git a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/DeferredUpdateManager.java b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/DeferredUpdateManager.java
index 2775b5c..664ef26 100644
--- a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/DeferredUpdateManager.java
+++ b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/DeferredUpdateManager.java
@@ -16,12 +16,12 @@
import java.util.List;
import java.util.Map;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Display;
import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.swt.SWT;
/**
* An UpdateManager that asynchronously updates the affected figures.
@@ -147,7 +147,10 @@
return graphicsSource.getGraphics(region);
}
- void paint(GC gc) {
+ /**
+ * @since 3.10
+ */
+ protected void paint(GC gc) {
if (!validating) {
SWTGraphics graphics = new SWTGraphics(gc);
if (!updating) {
diff --git a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/GhostImageFigure.java b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/GhostImageFigure.java
index e39d597..2b6a820 100644
--- a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/GhostImageFigure.java
+++ b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/GhostImageFigure.java
@@ -93,4 +93,4 @@
getBounds().width, getBounds().height);
feedbackImage.dispose();
}
-}
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/GridLayout.java b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/GridLayout.java
index 36aa063..1bab20e 100644
--- a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/GridLayout.java
+++ b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/GridLayout.java
@@ -22,13 +22,13 @@
/**
* Lays out children into a Grid arrangement in which overall aligment and
- * spacing can be configured, as well as specfic layout requirements for the
+ * spacing can be configured, as well as specific layout requirements for the
* each individual member of the GridLayout. This layout is a Draw2D port of the
* swt GridLayout.
*
* <code>GridLayout</code> has a number of configuration fields, and the Figures
* it lays out can have an associated layout data object, called
- * <code>GridData</code> (similar to the swt GridData object). The power of
+ * <code>GridData</code> (similar to the SWT GridData object). The power of
* <code>GridLayout</code> lies in the ability to configure
* <code>GridData</code> for each Figure in the layout.
* <p>
@@ -225,7 +225,7 @@
// initChildren( container);
Rectangle rect = container.getClientArea();
layout(container, true, rect.x, rect.y, rect.width, rect.height, /* flushCache */
- true);
+ true);
}
diff --git a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/PopUpHelper.java b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/PopUpHelper.java
index 31e0822..acb2bfa 100644
--- a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/PopUpHelper.java
+++ b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/PopUpHelper.java
@@ -10,13 +10,13 @@
*******************************************************************************/
package org.eclipse.draw2d;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.swt.SWT;
/**
* Provides abstract support for classes that manage popups. Popups in Draw2d
diff --git a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/PrintFigureOperation.java b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/PrintFigureOperation.java
index 68b12dc..d745f15 100644
--- a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/PrintFigureOperation.java
+++ b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/PrintFigureOperation.java
@@ -7,23 +7,23 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- * Sven M�ller - Added tiling support
+ * Sven Müller - Added tiling support
*******************************************************************************/
package org.eclipse.draw2d;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.printing.Printer;
import org.eclipse.swt.widgets.Display;
import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.swt.SWT;
/**
* Class responsible for printing Figures.
*
* @author Dan Lee
* @author Eric Bordeau
- * @author Sven M�ller
+ * @author Sven Müller
*/
public class PrintFigureOperation extends PrintOperation {
diff --git a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/PrintOperation.java b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/PrintOperation.java
index 8cc91e0..6b27580 100644
--- a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/PrintOperation.java
+++ b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/PrintOperation.java
@@ -10,12 +10,12 @@
*******************************************************************************/
package org.eclipse.draw2d;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.printing.Printer;
import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.swt.SWT;
/**
* Implementation of draw2d's printing capabilities.
diff --git a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/Shape.java b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/Shape.java
index afcd0f1..2031839 100644
--- a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/Shape.java
+++ b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/Shape.java
@@ -363,7 +363,7 @@
// synchronize line style which may have been assigned
// to lineStyle field for backwards compatibility
if (lineStyle != lastLineStyle) {
- lineAttributes.style = lineStyle;
+ lineAttributes.style = lineStyle;
lastLineStyle = lineStyle;
}
diff --git a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/TitleBarBorder.java b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/TitleBarBorder.java
index a258985..e6ddc76 100644
--- a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/TitleBarBorder.java
+++ b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/TitleBarBorder.java
@@ -12,6 +12,7 @@
package org.eclipse.draw2d;
import org.eclipse.swt.graphics.Color;
+
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.draw2d.geometry.Rectangle;
diff --git a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/ToolTipHelper.java b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/ToolTipHelper.java
index 98305f7..b4bbeb9 100644
--- a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/ToolTipHelper.java
+++ b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/ToolTipHelper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,11 +13,12 @@
import java.util.Timer;
import java.util.TimerTask;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseTrackAdapter;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;
import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.swt.SWT;
/**
* This class is used by SWTEventDispatcher as support to display Figure
@@ -31,6 +32,7 @@
private Timer timer;
private IFigure currentTipSource;
+ private int hideDelay = 5000;
/**
* Constructs a ToolTipHelper to be associated with Control <i>c</i>.
@@ -70,6 +72,18 @@
}
/**
+ * Sets the tooltip hide delay, which is the amount in ms, after which the
+ * tooltip will disappear again.
+ *
+ * @param hideDelay
+ * The delay after which the tooltip is hidden again, in ms.
+ * @since 3.10
+ */
+ public void setHideDelay(int hideDelay) {
+ this.hideDelay = hideDelay;
+ }
+
+ /**
* Sets the LightWeightSystem's contents to the passed tooltip, and displays
* the tip. The tip will be displayed only if the tip source is different
* than the previously viewed tip source. (i.e. The cursor has moved off of
@@ -105,11 +119,10 @@
Display.getDefault().asyncExec(new Runnable() {
public void run() {
hide();
- timer.cancel();
}
});
}
- }, 5000);
+ }, hideDelay);
}
}
@@ -120,27 +133,30 @@
*/
public void dispose() {
if (isShowing()) {
- timer.cancel();
hide();
}
getShell().dispose();
}
+ protected void hide() {
+ if (timer != null) {
+ timer.cancel();
+ }
+ super.hide();
+ }
+
/**
* @see PopUpHelper#hookShellListeners()
*/
protected void hookShellListeners() {
// Close the tooltip window if the mouse enters the tooltip
- // UNSUPPORTED - api not implemented in RAP
- // getShell().addMouseTrackListener(new MouseTrackAdapter() {
- // public void mouseEnter(org.eclipse.swt.events.MouseEvent e) {
- // hide();
- // currentTipSource = null;
- // if (timer != null) {
- // timer.cancel();
- // }
- // }
- // });
+ // UNSUPPORTED - api not implemented in RAP
+// getShell().addMouseTrackListener(new MouseTrackAdapter() {
+// public void mouseEnter(org.eclipse.swt.events.MouseEvent e) {
+// hide();
+// currentTipSource = null;
+// }
+// });
}
/**
@@ -166,14 +182,12 @@
if (figureUnderMouse == null) {
if (isShowing()) {
hide();
- timer.cancel();
}
}
// Makes tooltip appear without a hover event if a tip is currently
// being displayed
if (isShowing() && figureUnderMouse != currentTipSource) {
hide();
- timer.cancel();
displayToolTipNear(figureUnderMouse, tip, eventX, eventY);
} else if (!isShowing() && figureUnderMouse != currentTipSource)
currentTipSource = null;
diff --git a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/ViewportAwareConnectionLayerClippingStrategy.java b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/ViewportAwareConnectionLayerClippingStrategy.java
index 455c262..56c4620 100644
--- a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/ViewportAwareConnectionLayerClippingStrategy.java
+++ b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/ViewportAwareConnectionLayerClippingStrategy.java
@@ -105,14 +105,14 @@
// compute if source and target anchor are visible
// within the nearest common enclosing viewport (which may
// itself be nested in other viewports).
- Rectangle sourceClipRect = getAbsoluteBoundsAsCopy(sourceFigure);
+ Rectangle sourceClipRect = clipRect.getCopy();
if (nearestEnclosingSourceViewport != nearestEnclosingCommonViewport) {
clipAtViewports(sourceClipRect,
ViewportUtilities.getViewportsPath(
nearestEnclosingSourceViewport,
nearestEnclosingCommonViewport, false));
}
- Rectangle targetClipRect = getAbsoluteBoundsAsCopy(targetFigure);
+ Rectangle targetClipRect = clipRect.getCopy();
if (nearestEnclosingTargetViewport != nearestEnclosingCommonViewport) {
clipAtViewports(targetClipRect,
ViewportUtilities.getViewportsPath(
diff --git a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/parts/Thumbnail.java b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/parts/Thumbnail.java
index cfbec60..8246378 100644
--- a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/parts/Thumbnail.java
+++ b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/parts/Thumbnail.java
@@ -6,20 +6,13 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM Corporation - initial API and implementation
+ * IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.draw2d.parts;
import java.util.Iterator;
import java.util.Map;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.PaletteData;
-import org.eclipse.swt.widgets.Display;
-
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.IFigure;
@@ -29,6 +22,10 @@
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
/**
* A Thumbnail is a Figure that displays an image of its source Figure at a
@@ -47,12 +44,18 @@
static final int MAX_BUFFER_SIZE = 256;
private int currentHTile, currentVTile;
private int hTiles, vTiles;
+ private Dimension tileSize;
private boolean isActive = true;
private boolean isRunning = false;
+ private Image tileImage;
+ private Dimension tileImageSize;
+ // GC and Graphics to let the source figure paint on the tile image
+ private GC tileGC;
+ private SWTGraphics tileGCGraphics;
+ private ScaledGraphics tileGraphics;
+ // GC used to copy from the tile image into the thumbnail image
private GC thumbnailGC;
- private ScaledGraphics thumbnailGraphics;
- private Dimension tileSize;
/**
* Stops the updater and disposes of any resources.
@@ -146,7 +149,7 @@
* required, {@link #stop()} is called.
*/
public void run() {
- if (!isActive() || !isRunning() || thumbnailGraphics == null)
+ if (!isActive() || !isRunning() || tileGraphics == null)
return;
int v = getCurrentVTile();
int sy1 = v * tileSize.height;
@@ -157,16 +160,29 @@
int sx1 = h * tileSize.width;
int sx2 = Math.min((h + 1) * tileSize.width,
getSourceRectangle().width);
+
+ tileGraphics.pushState();
+ // clear the background (by filling with the background color)
+ Rectangle rect = new Rectangle(0, 0, sx2 - sx1, sy2 - sy1);
+ tileGraphics.fillRectangle(rect);
+
+ // let the source figure paint into the tile image
+ // IMPORTANT (fix for bug #309912): we do not let the source figure
+ // paint directly into the thumbnail image, because we cannot ensure
+ // that it paints completely inside the current tile area (it may
+ // set its own clip inside paint(Graphics) and overwrite areas of
+ // tile that have already been rendered. By providing an own tile
+ // image and copying from it into the thumbnail image, we are safe.
org.eclipse.draw2d.geometry.Point p = getSourceRectangle()
.getLocation();
+ tileGraphics.translate(-p.x - sx1, -p.y - sy1);
+ tileGraphics.scale(getScaleX());
+ sourceFigure.paint(tileGraphics);
+ tileGraphics.popState();
- Rectangle rect = new Rectangle(sx1 + p.x, sy1 + p.y, sx2 - sx1, sy2
- - sy1);
- thumbnailGraphics.pushState();
- thumbnailGraphics.setClip(rect);
- thumbnailGraphics.fillRectangle(rect);
- sourceFigure.paint(thumbnailGraphics);
- thumbnailGraphics.popState();
+ // copy the painted tile image into the thumbnail image
+ thumbnailGC.drawImage(tileImage, 0, 0, sx2 - sx1, sy2 - sy1, sx1,
+ sy1, sx2 - sx1, sy2 - sy1);
if (getCurrentHTile() < (hTiles - 1))
setCurrentHTile(getCurrentHTile() + 1);
@@ -232,6 +248,7 @@
isRunning = true;
setDirty(false);
+
resetTileValues();
if (!targetSize.equals(thumbnailImageSize)) {
@@ -240,23 +257,28 @@
if (targetSize.isEmpty())
return;
+
// UNSUPPORTED - image constructor not implemented in RAP
- // thumbnailGC = new GC(thumbnailImage,
- // sourceFigure.isMirrored() ? SWT.RIGHT_TO_LEFT : SWT.NONE);
- thumbnailGC = new GC(thumbnailImage.getDevice(),
+ // thumbnailGC = new GC(thumbnailImage, SWT.NONE);
+ thumbnailGC = new GC(thumbnailImage.getDevice(),SWT.NONE);
+
+ if (!tileSize.equals(tileImageSize)) {
+ resetTileImage();
+ }
+
+ //tileGC = new GC(tileImage,
+ tileGC = new GC(tileImage.getDevice(),
sourceFigure.isMirrored() ? org.eclipse.draw2d.rap.swt.SWT.RIGHT_TO_LEFT : SWT.NONE);
- thumbnailGraphics = new ScaledGraphics(new SWTGraphics(thumbnailGC));
- thumbnailGraphics.scale(getScaleX());
- thumbnailGraphics.translate(getSourceRectangle().getLocation()
- .negate());
+ tileGCGraphics = new SWTGraphics(tileGC);
+ tileGraphics = new ScaledGraphics(tileGCGraphics);
Color color = sourceFigure.getForegroundColor();
if (color != null)
- thumbnailGraphics.setForegroundColor(color);
+ tileGraphics.setForegroundColor(color);
color = sourceFigure.getBackgroundColor();
if (color != null)
- thumbnailGraphics.setBackgroundColor(color);
- thumbnailGraphics.setFont(sourceFigure.getFont());
+ tileGraphics.setBackgroundColor(color);
+ tileGraphics.setFont(sourceFigure.getFont());
setScales(targetSize.width / (float) getSourceRectangle().width,
targetSize.height / (float) getSourceRectangle().height);
@@ -264,10 +286,6 @@
Display.getCurrent().asyncExec(this);
}
- /**
- *
- * @since 3.2
- */
private void resetThumbnailImage() {
if (thumbnailImage != null)
thumbnailImage.dispose();
@@ -282,23 +300,49 @@
}
}
+ private void resetTileImage() {
+ if (tileImage != null)
+ tileImage.dispose();
+
+ if (!tileSize.isEmpty()) {
+ tileImage = new Image(Display.getDefault(), tileSize.width,
+ tileSize.height);
+ tileImageSize = new Dimension(tileSize);
+ } else {
+ tileImage = null;
+ tileImageSize = new Dimension(0, 0);
+ }
+ }
+
/**
* Stops this updater. Also disposes of resources (except the thumbnail
* image which is still needed for painting).
*/
public void stop() {
isRunning = false;
- if (thumbnailGraphics != null) {
- thumbnailGraphics.dispose();
- thumbnailGraphics = null;
+ if (tileGraphics != null) {
+ tileGraphics.dispose();
+ tileGraphics = null;
+ }
+ if (tileGCGraphics != null) {
+ tileGCGraphics.dispose();
+ tileGCGraphics = null;
+ }
+ if (tileGC != null) {
+ tileGC.dispose();
+ tileGC = null;
}
if (thumbnailGC != null) {
thumbnailGC.dispose();
thumbnailGC = null;
}
+ if (tileImage != null) {
+ tileImage.dispose();
+ tileImage = null;
+ tileImageSize = null;
+ }
// Don't dispose of the thumbnail image since it is needed to paint
- // the
- // figure when the source is not dirty (i.e. showing/hiding the
+ // the figure when the source is not dirty (i.e. showing/hiding the
// dock).
}
}
@@ -310,6 +354,7 @@
private IFigure sourceFigure;
Dimension targetSize = new Dimension(0, 0);
private Image thumbnailImage;
+
private Dimension thumbnailImageSize;
private ThumbnailUpdater updater = new ThumbnailUpdater();
diff --git a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/text/BlockFlowLayout.java b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/text/BlockFlowLayout.java
index 093892e..640a14c 100644
--- a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/text/BlockFlowLayout.java
+++ b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/text/BlockFlowLayout.java
@@ -12,11 +12,11 @@
import java.util.List;
+import org.eclipse.swt.SWT;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Insets;
-import org.eclipse.swt.SWT;
/**
* The layout for {@link BlockFlow} figures.
diff --git a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/text/InlineFlow.java b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/text/InlineFlow.java
index 4457c75..85705da 100644
--- a/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/text/InlineFlow.java
+++ b/bundles/org.eclipse.rap.draw2d/src/org/eclipse/draw2d/text/InlineFlow.java
@@ -14,12 +14,12 @@
import java.util.Iterator;
import java.util.List;
+import org.eclipse.swt.SWT;
import org.eclipse.draw2d.Border;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.swt.SWT;
/**
* A <code>FlowFigure</code> represented by multiple <code>LineBox</code>
diff --git a/bundles/org.eclipse.rap.gef/plugin.xml b/bundles/org.eclipse.rap.gef/plugin.xml
index 2025010..61e0c7e 100644
--- a/bundles/org.eclipse.rap.gef/plugin.xml
+++ b/bundles/org.eclipse.rap.gef/plugin.xml
Binary files differ
diff --git a/bundles/org.eclipse.rap.gef/readme.txt b/bundles/org.eclipse.rap.gef/readme.txt
index b347ccc..ce93b3c 100644
--- a/bundles/org.eclipse.rap.gef/readme.txt
+++ b/bundles/org.eclipse.rap.gef/readme.txt
@@ -1 +1 @@
-The source version of this port is: 3.9.100.qualifier
\ No newline at end of file
+The source version of this port is: 3.10.0.qualifier
\ No newline at end of file
diff --git a/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/commands/Command.java b/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/commands/Command.java
index 7789847..e4bb3d5 100644
--- a/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/commands/Command.java
+++ b/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/commands/Command.java
@@ -39,6 +39,15 @@
}
/**
+ * @return <code>true</code> if the command can be redone. This method
+ * should only be called after <code>undo()</code> has been called.
+ * @since 3.10
+ */
+ public boolean canRedo() {
+ return canExecute();
+ }
+
+ /**
* @return <code>true</code> if the command can be executed
*/
public boolean canExecute() {
@@ -90,7 +99,7 @@
}
/**
- * executes the Command. This method should not be called if the Command is
+ * Executes the Command. This method should not be called if the Command is
* not executable.
*/
public void execute() {
diff --git a/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/commands/CommandStack.java b/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/commands/CommandStack.java
index e49f4fe..a9efcce 100644
--- a/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/commands/CommandStack.java
+++ b/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/commands/CommandStack.java
@@ -153,7 +153,9 @@
* @return <code>true</code> if it is appropriate to call {@link #redo()}.
*/
public boolean canRedo() {
- return !redoable.isEmpty();
+ if (redoable.size() == 0)
+ return false;
+ return ((Command) redoable.peek()).canRedo();
}
/**
@@ -162,7 +164,7 @@
public boolean canUndo() {
if (undoable.size() == 0)
return false;
- return ((Command) undoable.lastElement()).canUndo();
+ return ((Command) undoable.peek()).canUndo();
}
/**
@@ -388,6 +390,8 @@
* should only be called when {@link #canUndo()} returns <code>true</code>.
*/
public void undo() {
+ if (!canUndo())
+ return;
// Assert.isTrue(canUndo());
Command command = (Command) undoable.pop();
notifyListeners(command, PRE_UNDO);
diff --git a/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/commands/CompoundCommand.java b/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/commands/CompoundCommand.java
index 2ce00bc..e3c11fc 100644
--- a/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/commands/CompoundCommand.java
+++ b/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/commands/CompoundCommand.java
@@ -60,6 +60,24 @@
}
/**
+ * @see org.eclipse.gef.commands.Command#canRedo()
+ *
+ * @since 3.10
+ */
+ public boolean canRedo() {
+ if (commandList.size() == 0)
+ return false;
+ for (int i = 0; i < commandList.size(); i++) {
+ Command cmd = (Command) commandList.get(i);
+ if (cmd == null)
+ return false;
+ if (!cmd.canRedo())
+ return false;
+ }
+ return true;
+ }
+
+ /**
* @see org.eclipse.gef.commands.Command#canExecute()
*/
public boolean canExecute() {
diff --git a/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/editparts/ScalableFreeformRootEditPart.java b/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/editparts/ScalableFreeformRootEditPart.java
index 8dbcd02..8ce3bc0 100644
--- a/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/editparts/ScalableFreeformRootEditPart.java
+++ b/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/editparts/ScalableFreeformRootEditPart.java
@@ -92,6 +92,19 @@
}
/**
+ * Responsible of creating a {@link ZoomManager} to be used by this
+ * {@link ScalableRootEditPart}.
+ *
+ * @return A new {@link ZoomManager} bound to the given
+ * {@link ScalableFigure} and {@link Viewport}.
+ * @since 3.10
+ */
+ protected ZoomManager createZoomManager(ScalableFigure scalableFigure,
+ Viewport viewport) {
+ return new ZoomManager(scalableFigure, viewport);
+ }
+
+ /**
* @see FreeformGraphicalRootEditPart#createLayers(LayeredPane)
*/
protected void createLayers(LayeredPane layeredPane) {
diff --git a/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/requests/GroupRequest.java b/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/requests/GroupRequest.java
index 68226a2..5b70ee0 100644
--- a/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/requests/GroupRequest.java
+++ b/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/requests/GroupRequest.java
@@ -64,7 +64,7 @@
* The EditPart making the request.
*/
public void setEditParts(EditPart part) {
- parts = new ArrayList();
+ parts = new ArrayList(1);
parts.add(part);
}
diff --git a/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/tools/ResizeTracker.java b/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/tools/ResizeTracker.java
index 343d154..504773e 100644
--- a/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/tools/ResizeTracker.java
+++ b/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/tools/ResizeTracker.java
@@ -49,7 +49,7 @@
* Key modifier for centered resizing. It's ALT on the Mac and MOD1 on all
* other platforms.
*/
- static final int MODIFIER_CENTERED_RESIZE = SWT.ALT;
+ static final int MODIFIER_CENTERED_RESIZE = SWT.MOD1;
/**
* Key modifier for constrained resizing. It's SHIFT on all platforms.
diff --git a/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/ui/parts/SelectionSynchronizer.java b/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/ui/parts/SelectionSynchronizer.java
index f7c551c..f3186c0 100644
--- a/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/ui/parts/SelectionSynchronizer.java
+++ b/bundles/org.eclipse.rap.gef/src/org/eclipse/gef/ui/parts/SelectionSynchronizer.java
@@ -103,12 +103,24 @@
}
}
- private void syncSelection(EditPartViewer source, ISelection selection) {
+ /**
+ * Synchronizes the given selection to all registered viewers except the one
+ * serving as selectionSource, by delegating to
+ * {@link #applySelection(EditPartViewer, ISelection)}.
+ *
+ * @param selectionSource
+ * The viewer from which the selection originated.
+ * @param selection
+ * The selection to apply to the other viewers.
+ * @since 3.10
+ */
+ protected void syncSelection(EditPartViewer selectionSource,
+ ISelection selection) {
isDispatching = true;
for (int i = 0; i < viewers.size(); i++) {
- if (viewers.get(i) != source) {
+ if (viewers.get(i) != selectionSource) {
EditPartViewer viewer = (EditPartViewer) viewers.get(i);
- setViewerSelection(viewer, selection);
+ applySelection(viewer, selection);
}
}
isDispatching = false;
@@ -130,7 +142,23 @@
}
}
- private void setViewerSelection(EditPartViewer viewer, ISelection selection) {
+ /**
+ * Applies the given EditPart selection from another viewer to the given
+ * viewer. It will first compute a new selection of {@link EditPart}s for
+ * the given viewer by searching those that control the same model elements
+ * as the {@link EditPart}s in the given selection (via
+ * {@link #convert(EditPartViewer, EditPart)}), apply this new selection to
+ * the given viewer, and reveal the last part in the new selection.
+ *
+ * @param viewer
+ * The viewer to apply the given selection to.
+ * @param selection
+ * The selection to apply, which has to be an
+ * {@link IStructuredSelection} of {@link EditPart}s of another
+ * viewer.
+ * @since 3.10
+ */
+ protected void applySelection(EditPartViewer viewer, ISelection selection) {
ArrayList result = new ArrayList();
Iterator iter = ((IStructuredSelection) selection).iterator();
while (iter.hasNext()) {
diff --git a/bundles/org.eclipse.rap.zest.core/readme.txt b/bundles/org.eclipse.rap.zest.core/readme.txt
index c8582cc..82168f0 100644
--- a/bundles/org.eclipse.rap.zest.core/readme.txt
+++ b/bundles/org.eclipse.rap.zest.core/readme.txt
@@ -1 +1 @@
-The source version of this port is: 1.5.100.qualifier
\ No newline at end of file
+The source version of this port is: 1.5.200.qualifier
\ No newline at end of file
diff --git a/bundles/org.eclipse.rap.zest.core/src/org/eclipse/zest/core/viewers/GraphViewer.java b/bundles/org.eclipse.rap.zest.core/src/org/eclipse/zest/core/viewers/GraphViewer.java
index 242406a..27a5769 100644
--- a/bundles/org.eclipse.rap.zest.core/src/org/eclipse/zest/core/viewers/GraphViewer.java
+++ b/bundles/org.eclipse.rap.zest.core/src/org/eclipse/zest/core/viewers/GraphViewer.java
@@ -35,7 +35,6 @@
import org.eclipse.zest.core.viewers.internal.ZoomManager;
import org.eclipse.zest.core.widgets.Graph;
import org.eclipse.zest.core.widgets.GraphItem;
-import org.eclipse.zest.core.widgets.ZestStyles;
import org.eclipse.zest.layouts.LayoutAlgorithm;
/*
@@ -46,7 +45,8 @@
*
* @author Chris Callendar
*/
-public class GraphViewer extends AbstractStructuredGraphViewer implements ISelectionProvider {
+public class GraphViewer extends AbstractStructuredGraphViewer implements
+ ISelectionProvider {
protected Graph graph = null;
private IStylingGraphModelFactory modelFactory = null;
@@ -57,14 +57,9 @@
* Initializes the viewer.
*
* @param composite
+ * The parent composite.
* @param style
- * the style for the viewer and for the layout algorithm
- * @see ZestStyles#LAYOUT_GRID
- * @see ZestStyles#LAYOUT_TREE
- * @see ZestStyles#LAYOUT_RADIAL
- * @see ZestStyles#LAYOUT_SPRING
- * @see ZestStyles#NO_OVERLAPPING_NODES
- * @see ZestStyles#NODES_HIGHLIGHT_ADJACENT
+ * The style for the viewer and the related Graph.
* @see SWT#V_SCROLL
* @see SWT#H_SCROLL
*/
@@ -89,10 +84,12 @@
Iterator iterator = selectionChangedListeners.iterator();
ISelection structuredSelection = getSelection();
- SelectionChangedEvent event = new SelectionChangedEvent(GraphViewer.this, structuredSelection);
+ SelectionChangedEvent event = new SelectionChangedEvent(
+ GraphViewer.this, structuredSelection);
while (iterator.hasNext()) {
- ISelectionChangedListener listener = (ISelectionChangedListener) iterator.next();
+ ISelectionChangedListener listener = (ISelectionChangedListener) iterator
+ .next();
listener.selectionChanged(event);
}
firePostSelectionChanged(event);
@@ -103,7 +100,8 @@
control.addMouseListener(new MouseListener() {
public void mouseDoubleClick(MouseEvent e) {
- DoubleClickEvent doubleClickEvent = new DoubleClickEvent(GraphViewer.this, getSelection());
+ DoubleClickEvent doubleClickEvent = new DoubleClickEvent(
+ GraphViewer.this, getSelection());
fireDoubleClick(doubleClickEvent);
}
@@ -130,7 +128,8 @@
/*
* (non-Javadoc)
*
- * @see org.eclipse.zest.core.viewer.internal.AbstractStructuredGraphViewer#getGraphControl()
+ * @see org.eclipse.zest.core.viewer.internal.AbstractStructuredGraphViewer#
+ * getGraphControl()
*/
public Graph getGraphControl() {
return super.getGraphControl();
@@ -151,7 +150,8 @@
/*
* (non-Javadoc)
*
- * @see org.eclipse.zest.core.viewer.internal.AbstractStructuredGraphViewer#setLayoutAlgorithm(org.eclipse.zest.layouts.LayoutAlgorithm)
+ * @see org.eclipse.zest.core.viewer.internal.AbstractStructuredGraphViewer#
+ * setLayoutAlgorithm(org.eclipse.zest.layouts.LayoutAlgorithm)
*/
public void setLayoutAlgorithm(LayoutAlgorithm algorithm) {
super.setLayoutAlgorithm(algorithm);
@@ -160,7 +160,9 @@
/*
* (non-Javadoc)
*
- * @see org.eclipse.zest.core.viewers.AbstractStructuredGraphViewer#setNodeStyle(int)
+ * @see
+ * org.eclipse.zest.core.viewers.AbstractStructuredGraphViewer#setNodeStyle
+ * (int)
*/
public void setNodeStyle(int nodeStyle) {
super.setNodeStyle(nodeStyle);
@@ -178,7 +180,8 @@
modelFactory = null;
super.setContentProvider(contentProvider);
} else {
- throw new IllegalArgumentException("Invalid content provider, only IGraphContentProvider, IGraphEntityContentProvider, or IGraphEntityRelationshipContentProvider are supported.");
+ throw new IllegalArgumentException(
+ "Invalid content provider, only IGraphContentProvider, IGraphEntityContentProvider, or IGraphEntityRelationshipContentProvider are supported.");
}
}
@@ -198,7 +201,8 @@
*/
public GraphItem findGraphItem(Object element) {
Widget[] result = findItems(element);
- return (result.length == 0 || !(result[0] instanceof GraphItem)) ? null : (GraphItem) result[0];
+ return (result.length == 0 || !(result[0] instanceof GraphItem)) ? null
+ : (GraphItem) result[0];
}
/**
@@ -228,7 +232,9 @@
/*
* (non-Javadoc)
*
- * @see org.eclipse.zest.core.viewer.internal.AbstractStructuredGraphViewer#reveal(java.lang.Object)
+ * @see
+ * org.eclipse.zest.core.viewer.internal.AbstractStructuredGraphViewer#reveal
+ * (java.lang.Object)
*/
public void reveal(Object element) {
super.reveal(element);
@@ -237,7 +243,8 @@
/*
* (non-Javadoc)
*
- * @see org.eclipse.zest.core.viewer.internal.AbstractStructuredGraphViewer#setConnectionStyle(int)
+ * @see org.eclipse.zest.core.viewer.internal.AbstractStructuredGraphViewer#
+ * setConnectionStyle(int)
*/
public void setConnectionStyle(int connectionStyle) {
super.setConnectionStyle(connectionStyle);
@@ -246,7 +253,9 @@
/*
* (non-Javadoc)
*
- * @see org.eclipse.zest.core.viewer.internal.AbstractStructuredGraphViewer#unReveal(java.lang.Object)
+ * @see
+ * org.eclipse.zest.core.viewer.internal.AbstractStructuredGraphViewer#unReveal
+ * (java.lang.Object)
*/
public void unReveal(Object element) {
super.unReveal(element);
@@ -258,7 +267,8 @@
}
}
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
if (selectionChangedListeners.contains(listener)) {
selectionChangedListeners.remove(listener);
}
@@ -268,7 +278,8 @@
// for new actions.
protected ZoomManager getZoomManager() {
if (zoomManager == null) {
- zoomManager = new ZoomManager(getGraphControl().getRootLayer(), getGraphControl().getViewport());
+ zoomManager = new ZoomManager(getGraphControl().getRootLayer(),
+ getGraphControl().getViewport());
}
return zoomManager;
}
@@ -276,7 +287,8 @@
/*
* (non-Javadoc)
*
- * @see org.eclipse.zest.core.viewers.AbstractStructuredGraphViewer#getFactory()
+ * @see
+ * org.eclipse.zest.core.viewers.AbstractStructuredGraphViewer#getFactory()
*/
protected IStylingGraphModelFactory getFactory() {
if (modelFactory == null) {
@@ -294,7 +306,8 @@
/*
* (non-Javadoc)
*
- * @see org.eclipse.zest.core.viewers.AbstractStructuredGraphViewer#getLayoutAlgorithm()
+ * @see org.eclipse.zest.core.viewers.AbstractStructuredGraphViewer#
+ * getLayoutAlgorithm()
*/
protected LayoutAlgorithm getLayoutAlgorithm() {
return graph.getLayoutAlgorithm();
diff --git a/bundles/org.eclipse.rap.zest.core/src/org/eclipse/zest/core/widgets/internal/XYScaledGraphics.java b/bundles/org.eclipse.rap.zest.core/src/org/eclipse/zest/core/widgets/internal/XYScaledGraphics.java
index ca7c3ac..8c057a5 100644
--- a/bundles/org.eclipse.rap.zest.core/src/org/eclipse/zest/core/widgets/internal/XYScaledGraphics.java
+++ b/bundles/org.eclipse.rap.zest.core/src/org/eclipse/zest/core/widgets/internal/XYScaledGraphics.java
@@ -40,7 +40,8 @@
*/
public class XYScaledGraphics extends ScaledGraphics {
- public static final double MAX_TEXT_SIZE = 0.45; // MAX size, when to stop zooming text
+ public static final double MAX_TEXT_SIZE = 0.45; // MAX size, when to stop
+ // zooming text
private static class FontHeightCache {
Font font;
@@ -81,7 +82,7 @@
private double appliedY;
private Font font;
private int lineWidth;
- //private double zoom; // This has been replaced with xZoom and yZoom
+ // private double zoom; // This has been replaced with xZoom and yZoom
private double xZoom;
private double yZoom;
@@ -106,7 +107,8 @@
* @param lineWidth
* the line width
*/
- protected State(double xZoom, double yZoom, double x, double y, Font font, int lineWidth) {
+ protected State(double xZoom, double yZoom, double x, double y,
+ Font font, int lineWidth) {
this.xZoom = xZoom;
this.yZoom = yZoom;
this.appliedX = x;
@@ -129,7 +131,8 @@
* @param lineWidth
* the line width
*/
- protected void setValues(double xZoom, double yZoom, double x, double y, Font font, int lineWidth) {
+ protected void setValues(double xZoom, double yZoom, double x,
+ double y, Font font, int lineWidth) {
this.xZoom = xZoom;
this.yZoom = yZoom;
this.appliedX = x;
@@ -149,7 +152,7 @@
}
private boolean allowText = true;
- // private static final Point PT = new Point();
+ // private static final Point PT = new Point();
private Map fontCache = new HashMap();
private Map fontDataCache = new HashMap();
private FontKey fontKey = new FontKey();
@@ -190,12 +193,12 @@
/** @see Graphics#dispose() */
public void dispose() {
- //Remove all states from the stack
+ // Remove all states from the stack
while (stackPointer > 0) {
popState();
}
- //Dispose fonts
+ // Dispose fonts
Iterator iter = fontCache.values().iterator();
while (iter.hasNext()) {
Font font = ((Font) iter.next());
@@ -222,22 +225,31 @@
public void drawImage(Image srcImage, int x, int y) {
org.eclipse.swt.graphics.Rectangle size = srcImage.getBounds();
double imageZoom = Math.min(xZoom, yZoom);
- graphics.drawImage(srcImage, 0, 0, size.width, size.height, (int) (Math.floor((x * xZoom + fractionalX))), (int) (Math.floor((y * yZoom + fractionalY))), (int) (Math.floor((size.width * imageZoom + fractionalX))), (int) (Math.floor((size.height * imageZoom + fractionalY))));
+ graphics.drawImage(srcImage, 0, 0, size.width, size.height,
+ (int) (Math.floor((x * xZoom + fractionalX))),
+ (int) (Math.floor((y * yZoom + fractionalY))),
+ (int) (Math.floor((size.width * imageZoom + fractionalX))),
+ (int) (Math.floor((size.height * imageZoom + fractionalY))));
}
/** @see Graphics#drawImage(Image, int, int, int, int, int, int, int, int) */
- public void drawImage(Image srcImage, int sx, int sy, int sw, int sh, int tx, int ty, int tw, int th) {
- //"t" == target rectangle, "s" = source
+ public void drawImage(Image srcImage, int sx, int sy, int sw, int sh,
+ int tx, int ty, int tw, int th) {
+ // "t" == target rectangle, "s" = source
Rectangle t = zoomRect(tx, ty, tw, th);
if (!t.isEmpty()) {
- graphics.drawImage(srcImage, sx, sy, sw, sh, t.x, t.y, t.width, t.height);
+ graphics.drawImage(srcImage, sx, sy, sw, sh, t.x, t.y, t.width,
+ t.height);
}
}
/** @see Graphics#drawLine(int, int, int, int) */
public void drawLine(int x1, int y1, int x2, int y2) {
- graphics.drawLine((int) (Math.floor((x1 * xZoom + fractionalX))), (int) (Math.floor((y1 * yZoom + fractionalY))), (int) (Math.floor((x2 * xZoom + fractionalX))), (int) (Math.floor((y2 * yZoom + fractionalY))));
+ graphics.drawLine((int) (Math.floor((x1 * xZoom + fractionalX))),
+ (int) (Math.floor((y1 * yZoom + fractionalY))),
+ (int) (Math.floor((x2 * xZoom + fractionalX))),
+ (int) (Math.floor((y2 * yZoom + fractionalY))));
}
/** @see Graphics#drawOval(int, int, int, int) */
@@ -247,7 +259,8 @@
/** @see Graphics#drawPoint(int, int) */
public void drawPoint(int x, int y) {
- graphics.drawPoint((int) Math.floor(x * xZoom + fractionalX), (int) Math.floor(y * yZoom + fractionalY));
+ graphics.drawPoint((int) Math.floor(x * xZoom + fractionalX),
+ (int) Math.floor(y * yZoom + fractionalY));
}
/**
@@ -281,7 +294,8 @@
/** @see Graphics#drawRoundRectangle(Rectangle, int, int) */
public void drawRoundRectangle(Rectangle r, int arcWidth, int arcHeight) {
- graphics.drawRoundRectangle(zoomRect(r.x, r.y, r.width, r.height), (int) (arcWidth * xZoom), (int) (arcHeight * yZoom));
+ graphics.drawRoundRectangle(zoomRect(r.x, r.y, r.width, r.height),
+ (int) (arcWidth * xZoom), (int) (arcHeight * yZoom));
}
/** @see Graphics#drawString(String, int, int) */
@@ -311,9 +325,14 @@
* @see Graphics#drawTextLayout(TextLayout, int, int, int, int, Color,
* Color)
*/
- public void drawTextLayout(TextLayout layout, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) {
+ public void drawTextLayout(TextLayout layout, int x, int y,
+ int selectionStart, int selectionEnd, Color selectionForeground,
+ Color selectionBackground) {
TextLayout scaled = zoomTextLayout(layout);
- graphics.drawTextLayout(scaled, (int) Math.floor(x * xZoom + fractionalX), (int) Math.floor(y * yZoom + fractionalY), selectionStart, selectionEnd, selectionBackground, selectionForeground);
+ graphics.drawTextLayout(scaled,
+ (int) Math.floor(x * xZoom + fractionalX),
+ (int) Math.floor(y * yZoom + fractionalY), selectionStart,
+ selectionEnd, selectionForeground, selectionBackground);
scaled.dispose();
}
@@ -355,7 +374,8 @@
/** @see Graphics#fillRoundRectangle(Rectangle, int, int) */
public void fillRoundRectangle(Rectangle r, int arcWidth, int arcHeight) {
- graphics.fillRoundRectangle(zoomFillRect(r.x, r.y, r.width, r.height), (int) (arcWidth * xZoom), (int) (arcHeight * yZoom));
+ graphics.fillRoundRectangle(zoomFillRect(r.x, r.y, r.width, r.height),
+ (int) (arcWidth * xZoom), (int) (arcHeight * yZoom));
}
/** @see Graphics#fillString(String, int, int) */
@@ -525,9 +545,11 @@
State s;
if (stack.size() > stackPointer) {
s = (State) stack.get(stackPointer);
- s.setValues(xZoom, yZoom, fractionalX, fractionalY, getLocalFont(), localLineWidth);
+ s.setValues(xZoom, yZoom, fractionalX, fractionalY, getLocalFont(),
+ localLineWidth);
} else {
- stack.add(new State(xZoom, yZoom, fractionalX, fractionalY, getLocalFont(), localLineWidth));
+ stack.add(new State(xZoom, yZoom, fractionalX, fractionalY,
+ getLocalFont(), localLineWidth));
}
stackPointer++;
@@ -555,7 +577,7 @@
/** @see Graphics#scale(double) */
public void scale(double amount) {
- //setScale(zoom * amount);
+ // setScale(zoom * amount);
throw new RuntimeException("Operation not supported, use scale(x, y)");
}
@@ -682,7 +704,7 @@
/** @see Graphics#translate(int, int) */
public void translate(int dx, int dy) {
- // fractionalX/Y is the fractional part left over from previous
+ // fractionalX/Y is the fractional part left over from previous
// translates that gets lost in the integer approximation.
double dxFloat = dx * xZoom + fractionalX;
double dyFloat = dy * yZoom + fractionalY;
@@ -694,16 +716,20 @@
private Rectangle zoomClipRect(Rectangle r) {
tempRECT.x = (int) (Math.floor(r.x * xZoom + fractionalX));
tempRECT.y = (int) (Math.floor(r.y * yZoom + fractionalY));
- tempRECT.width = (int) (Math.ceil(((r.x + r.width) * xZoom + fractionalX))) - tempRECT.x;
- tempRECT.height = (int) (Math.ceil(((r.y + r.height) * yZoom + fractionalY))) - tempRECT.y;
+ tempRECT.width = (int) (Math
+ .ceil(((r.x + r.width) * xZoom + fractionalX))) - tempRECT.x;
+ tempRECT.height = (int) (Math
+ .ceil(((r.y + r.height) * yZoom + fractionalY))) - tempRECT.y;
return tempRECT;
}
private Rectangle zoomFillRect(int x, int y, int w, int h) {
tempRECT.x = (int) (Math.floor((x * xZoom + fractionalX)));
tempRECT.y = (int) (Math.floor((y * yZoom + fractionalY)));
- tempRECT.width = (int) (Math.floor(((x + w - 1) * xZoom + fractionalX))) - tempRECT.x + 1;
- tempRECT.height = (int) (Math.floor(((y + h - 1) * yZoom + fractionalY))) - tempRECT.y + 1;
+ tempRECT.width = (int) (Math.floor(((x + w - 1) * xZoom + fractionalX)))
+ - tempRECT.x + 1;
+ tempRECT.height = (int) (Math
+ .floor(((y + h - 1) * yZoom + fractionalY))) - tempRECT.y + 1;
return tempRECT;
}
@@ -757,7 +783,8 @@
// Scale the points
for (int i = 0; (i + 1) < points.length; i += 2) {
scaled[i] = (int) (Math.floor((points[i] * xZoom + fractionalX)));
- scaled[i + 1] = (int) (Math.floor((points[i + 1] * yZoom + fractionalY)));
+ scaled[i + 1] = (int) (Math
+ .floor((points[i + 1] * yZoom + fractionalY)));
}
return scaled;
}
@@ -765,8 +792,10 @@
private Rectangle zoomRect(int x, int y, int w, int h) {
tempRECT.x = (int) (Math.floor(x * xZoom + fractionalX));
tempRECT.y = (int) (Math.floor(y * yZoom + fractionalY));
- tempRECT.width = (int) (Math.floor(((x + w) * xZoom + fractionalX))) - tempRECT.x;
- tempRECT.height = (int) (Math.floor(((y + h) * yZoom + fractionalY))) - tempRECT.y;
+ tempRECT.width = (int) (Math.floor(((x + w) * xZoom + fractionalX)))
+ - tempRECT.x;
+ tempRECT.height = (int) (Math.floor(((y + h) * yZoom + fractionalY)))
+ - tempRECT.y;
return tempRECT;
}
@@ -799,13 +828,16 @@
int start = 0, offset = 1;
TextStyle style = null, lastStyle = layout.getStyle(0);
for (; offset <= length; offset++) {
- if (offset != length && (style = layout.getStyle(offset)) == lastStyle) {
+ if (offset != length
+ && (style = layout.getStyle(offset)) == lastStyle) {
continue;
}
int end = offset - 1;
if (lastStyle != null) {
- TextStyle zoomedStyle = new TextStyle(zoomFont(lastStyle.font), lastStyle.foreground, lastStyle.background);
+ TextStyle zoomedStyle = new TextStyle(
+ zoomFont(lastStyle.font), lastStyle.foreground,
+ lastStyle.background);
zoomed.setStyle(zoomedStyle, start, end);
}
lastStyle = style;
@@ -817,7 +849,7 @@
private Point zoomTextPoint(int x, int y) {
if (localCache.font != localFont) {
- //Font is different, re-calculate its height
+ // Font is different, re-calculate its height
FontMetrics metric = FigureUtilities.getFontMetrics(localFont);
// UNSUPPORTED - getDescent() not implemented in RAP
// localCache.height = metric.getHeight() - metric.getDescent();
@@ -831,7 +863,9 @@
// targetCache.height = metric.getHeight() - metric.getDescent();
targetCache.height = metric.getHeight();
}
- return new Point(((int) (Math.floor((x * xZoom) + fractionalX))), (int) (Math.floor((y + localCache.height - 1) * yZoom - targetCache.height + 1 + fractionalY)));
+ return new Point(((int) (Math.floor((x * xZoom) + fractionalX))),
+ (int) (Math.floor((y + localCache.height - 1) * yZoom
+ - targetCache.height + 1 + fractionalY)));
}
}
diff --git a/bundles/org.eclipse.rap.zest.layouts/readme.txt b/bundles/org.eclipse.rap.zest.layouts/readme.txt
index f7d6424..c45857f 100644
--- a/bundles/org.eclipse.rap.zest.layouts/readme.txt
+++ b/bundles/org.eclipse.rap.zest.layouts/readme.txt
@@ -1 +1 @@
-The source version of this port is: 1.1.100.qualifier
\ No newline at end of file
+The source version of this port is: 1.1.200.qualifier
\ No newline at end of file
diff --git a/tests/org.eclipse.draw2d.test/src/org/eclipse/draw2d/test/AdvancedGraphicsTests.java b/tests/org.eclipse.draw2d.test/src/org/eclipse/draw2d/test/AdvancedGraphicsTests.java
new file mode 100644
index 0000000..7a415f4
--- /dev/null
+++ b/tests/org.eclipse.draw2d.test/src/org/eclipse/draw2d/test/AdvancedGraphicsTests.java
@@ -0,0 +1,457 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.draw2d.test;
+
+import java.util.Stack;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.SWTGraphics;
+import org.eclipse.draw2d.rap.swt.graphics.LineAttributes;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.PaletteData;
+import org.eclipse.swt.graphics.Path;
+import org.eclipse.swt.graphics.Pattern;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Resource;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class AdvancedGraphicsTests extends AbstractFixtureTestCase {
+
+ static final int LINE[] = new int[] { 5, 5, 20, 20, 35, 5, 50, 5 };
+ static final int POLY[] = new int[] { 5, 5, 45, 15, 20, 30, 20, 20, 45, 35,
+ 5, 45 };
+ private static final int PREVIEW_DELAY = 250;
+ private SWTGraphics g;
+
+ private Image image;
+ private GC imageGC;
+ private Path path1;
+ private Path path2;
+ private Stack resources = new Stack();
+
+ private void assertImageEquality(int width, int height) {
+ ImageData data = image.getImageData();
+ int src, dst;
+ PaletteData palette = data.palette;
+ for (int y = 0; y < height; y++)
+ for (int x = 0; x < width; x++) {
+ src = data.getPixel(x, y);
+ dst = data.getPixel(x, y + height);
+
+ if (src != dst) {
+ RGB rgb1 = palette.getRGB(src);
+ RGB rgb2 = palette.getRGB(dst);
+ // HACK, image operations seem to differ by as much as 4
+ if (Math.abs(rgb1.red - rgb2.red) > 4
+ || Math.abs(rgb1.green - rgb2.green) > 4
+ || Math.abs(rgb1.blue - rgb2.blue) > 4)
+ assertEquals("Discrepancy at coordinates <" + x + ", "
+ + y + ">", rgb1, rgb2);
+ }
+ }
+ }
+
+ private void displayImage() {
+ final Shell shell = new Shell(SWT.DIALOG_TRIM);
+ shell.addPaintListener(new PaintListener() {
+ public void paintControl(PaintEvent e) {
+ e.gc.drawImage(image, 0, 0);
+ }
+ });
+ shell.setBounds(100, 100, 800, 600);
+ shell.open();
+ Display d = shell.getDisplay();
+ d.timerExec(PREVIEW_DELAY, new Runnable() {
+ public void run() {
+ if (!shell.isDisposed())
+ shell.close();
+ }
+ });
+ while (!shell.isDisposed())
+ while (!d.readAndDispatch())
+ d.sleep();
+
+ }
+
+ private void performTestcase(Runnable painter, Runnable tests[]) {
+ g.pushState();
+ painter.run();
+ for (int i = 0; i < tests.length; i++) {
+ g.translate(100, 0);
+ tests[i].run();
+ g.pushState();
+ painter.run();
+ }
+
+ for (int i = 0; i <= tests.length; i++) {
+ g.popState();
+ g.translate(0, 100);
+ painter.run();
+ }
+
+ displayImage();
+ assertImageEquality(100 * tests.length, 100);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ path1 = new Path(null);
+ path1.moveTo(20, 5);
+ path1.quadTo(40, 5, 50, 25);
+ path1.quadTo(20, 25, 20, 45);
+ path1.lineTo(0, 25);
+ path1.close();
+
+ path2 = new Path(null);
+ path2.moveTo(15, 30);
+ path2.cubicTo(50, 0, 50, 30, 20, 60);
+ path2.close();
+
+ image = new Image(Display.getDefault(), 800, 600);
+ imageGC = new GC(image.getDevice(), SWT.NONE);
+ g = new SWTGraphics(imageGC);
+
+ resources.push(path1);
+ resources.push(path2);
+ resources.push(image);
+ resources.push(imageGC);
+ }
+
+ protected void tearDown() throws Exception {
+ g.dispose();
+ while (!resources.isEmpty())
+ ((Resource) resources.pop()).dispose();
+ super.tearDown();
+ }
+
+ public void testAntialias() {
+ class AntialiasSettings implements Runnable {
+ private final Color color;
+ private final int normal;
+ private final int text;
+
+ AntialiasSettings(int text, int normal, Color color) {
+ this.text = text;
+ this.normal = normal;
+ this.color = color;
+ }
+
+ public void run() {
+ g.setAntialias(normal);
+ g.setTextAntialias(text);
+ g.setForegroundColor(color);
+ }
+ }
+
+ g.setLineWidthFloat(9);
+ g.pushState();
+
+ Runnable tests[] = new Runnable[4];
+ tests[0] = new AntialiasSettings(SWT.ON, SWT.ON, ColorConstants.red);
+ tests[1] = new AntialiasSettings(SWT.OFF, SWT.OFF, ColorConstants.blue);
+ tests[2] = new AntialiasSettings(SWT.DEFAULT, SWT.ON,
+ ColorConstants.black);
+ tests[3] = new AntialiasSettings(SWT.ON, SWT.DEFAULT,
+ ColorConstants.darkGreen);
+ performTestcase(new Runnable() {
+ public void run() {
+ g.drawPolyline(LINE);
+ g.drawString("OWVO", 35, 20);
+ }
+ }, tests);
+ }
+
+ public void testFillRules() {
+
+ class FillRules implements Runnable {
+ private final int aa;
+ private final int rule;
+
+ FillRules(int rule, int aa) {
+ this.rule = rule;
+ this.aa = aa;
+ }
+
+ public void run() {
+ g.setFillRule(rule);
+ // $TODO
+ g.setAntialias(aa);
+ }
+ }
+ g.setBackgroundColor(ColorConstants.red);
+ g.pushState();
+
+ Runnable tests[] = new Runnable[3];
+ tests[0] = new FillRules(org.eclipse.draw2d.rap.swt.SWT.FILL_EVEN_ODD,
+ SWT.ON);
+ tests[1] = new FillRules(org.eclipse.draw2d.rap.swt.SWT.FILL_WINDING,
+ SWT.OFF);
+ tests[2] = new FillRules(org.eclipse.draw2d.rap.swt.SWT.FILL_EVEN_ODD,
+ SWT.DEFAULT);
+ performTestcase(new Runnable() {
+ public void run() {
+ g.fillPolygon(POLY);
+ }
+ }, tests);
+ }
+
+ // public void testInterpolation() {
+ // class InterpolationSettings implements Runnable {
+ // private final int level;
+ // InterpolationSettings (int level) {
+ // this.level = level;
+ // }
+ // public void run() {
+ // g.setInterpolation(level);
+ // }
+ // }
+ //
+ // g.pushState();
+ //
+ // Runnable tests[] = new Runnable[4];
+ // tests[0] = new InterpolationSettings(SWT.HIGH);
+ // tests[1] = new InterpolationSettings(SWT.LOW);
+ // tests[2] = new InterpolationSettings(SWT.NONE);
+ // tests[3] = new InterpolationSettings(SWT.DEFAULT);
+ // performTestcase(new Runnable() {
+ // public void run() {
+ // g.drawImage(TestImages.depth_24, 0, 0, 400, 400, 0, 0, 75, 75);
+ // }
+ // }, tests);
+ // }
+
+ public void testLineJoinCap() {
+
+ class LineSettings implements Runnable {
+ private final int cap;
+ private final int style;
+ private final int join;
+
+ LineSettings(int join, int cap, int style) {
+ this.join = join;
+ this.cap = cap;
+ this.style = style;
+ }
+
+ public void run() {
+ g.setLineCap(cap);
+ g.setLineJoin(join);
+ g.setLineStyle(style);
+ }
+ }
+
+ g.setLineWidthFloat(9);
+ g.pushState();
+
+ Runnable[] tests = new Runnable[] {
+ new LineSettings(SWT.JOIN_ROUND, SWT.CAP_ROUND,
+ org.eclipse.draw2d.rap.swt.SWT.LINE_DASH),
+ new LineSettings(SWT.JOIN_BEVEL, SWT.CAP_FLAT,
+ org.eclipse.draw2d.rap.swt.SWT.LINE_DOT),
+ new LineSettings(SWT.JOIN_ROUND, SWT.CAP_SQUARE,
+ org.eclipse.draw2d.rap.swt.SWT.LINE_SOLID) };
+
+ performTestcase(new Runnable() {
+ public void run() {
+ g.drawPolyline(LINE);
+ }
+ }, tests);
+ }
+
+ public void testLineJoinCapAA() {
+ g.setAntialias(SWT.ON);
+ testLineJoinCap();
+ }
+
+ public void testLineAttributes() {
+ class LineSettings implements Runnable {
+ private LineAttributes attributes;
+
+ public LineSettings(LineAttributes attributes) {
+ this.attributes = attributes;
+ }
+
+ public void run() {
+ g.setLineAttributes(attributes);
+ }
+ }
+
+ float[] dash = new float[] { 2.5f, 3, 8 };
+
+ Runnable[] tests = new Runnable[] {
+ new LineSettings(new LineAttributes(0.0f, SWT.CAP_FLAT,
+ SWT.JOIN_MITER,
+ org.eclipse.draw2d.rap.swt.SWT.LINE_SOLID, null, 0, 10)),
+ new LineSettings(new LineAttributes(1.0f, SWT.CAP_FLAT,
+ SWT.JOIN_MITER,
+ org.eclipse.draw2d.rap.swt.SWT.LINE_SOLID, null, 0, 10)),
+ new LineSettings(new LineAttributes(2.5f, SWT.CAP_FLAT,
+ SWT.JOIN_MITER,
+ org.eclipse.draw2d.rap.swt.SWT.LINE_SOLID, null, 0, 10)),
+ new LineSettings(new LineAttributes(5.0f, SWT.CAP_FLAT,
+ SWT.JOIN_MITER,
+ org.eclipse.draw2d.rap.swt.SWT.LINE_DASH, null, 0, 10)),
+ new LineSettings(new LineAttributes(5.0f, SWT.CAP_FLAT,
+ SWT.JOIN_ROUND,
+ org.eclipse.draw2d.rap.swt.SWT.LINE_DASHDOTDOT, null,
+ 0, 10)),
+ new LineSettings(new LineAttributes(4.5f, SWT.CAP_FLAT,
+ SWT.JOIN_MITER,
+ org.eclipse.draw2d.rap.swt.SWT.LINE_SOLID, null, 0, 10)),
+ new LineSettings(
+ new LineAttributes(9.0f, SWT.CAP_FLAT, SWT.JOIN_ROUND,
+ org.eclipse.draw2d.rap.swt.SWT.LINE_CUSTOM,
+ dash, 0, 10)),
+ new LineSettings(
+ new LineAttributes(9.5f, SWT.CAP_FLAT, SWT.JOIN_ROUND,
+ org.eclipse.draw2d.rap.swt.SWT.LINE_CUSTOM,
+ dash, 5, 10)), };
+
+ performTestcase(new Runnable() {
+ public void run() {
+ g.drawPolyline(LINE);
+ }
+ }, tests);
+ }
+
+ public void testLineAttributesAA() {
+ g.setAntialias(SWT.ON);
+ testLineAttributes();
+ }
+
+ // public void testPathDraw() {
+ //
+ // class PathSettings implements Runnable {
+ // private final int antialias;
+ // private final Color color;
+ // private final int style;
+ // private final int width;
+ // PathSettings(int antialias, int width, int style, Color color) {
+ // this.antialias = antialias;
+ // this.width = width;
+ // this.style = style;
+ // this.color = color;
+ // }
+ // public void run() {
+ // g.setAntialias(antialias);
+ // g.setLineWidth(width);
+ // g.setLineStyle(style);
+ // g.setForegroundColor(color);
+ // }
+ // }
+ //
+ // g.setBackgroundColor(ColorConstants.darkBlue);
+ //
+ // Runnable tests[] = new Runnable[5];
+ // tests[0] = new PathSettings(SWT.ON, 3, SWT.LINE_SOLID,
+ // ColorConstants.darkBlue);
+ // tests[1] = new PathSettings(SWT.OFF, 0, SWT.LINE_DOT,
+ // ColorConstants.red);
+ // tests[2] = new PathSettings(SWT.DEFAULT, 1, SWT.LINE_DOT,
+ // ColorConstants.darkBlue);
+ // tests[3] = new PathSettings(SWT.DEFAULT, 2, SWT.LINE_DOT,
+ // ColorConstants.darkGreen);
+ // tests[4] = new PathSettings(SWT.ON, 2, SWT.LINE_DASHDOTDOT,
+ // ColorConstants.black);
+ // performTestcase(new Runnable() {
+ // public void run() {
+ // g.drawPath(path1);
+ // g.drawPath(path2);
+ // }
+ // }, tests);
+ //
+ // path1.dispose();
+ // }
+
+ // public void testPathFill() {
+ //
+ // class PathSettings implements Runnable {
+ // private final int antialias;
+ // private final int alpha;
+ // PathSettings(int antialias, int alpha) {
+ // this.antialias = antialias;
+ // this.alpha = alpha;
+ // }
+ // public void run() {
+ // g.setAntialias(antialias);
+ // g.setAlpha(alpha);
+ // }
+ // }
+ //
+ // g.setBackgroundColor(ColorConstants.darkBlue);
+ //
+ // Runnable tests[] = new Runnable[4];
+ // tests[0] = new PathSettings(SWT.ON, 200);
+ // tests[1] = new PathSettings(SWT.OFF, 100);
+ // tests[2] = new PathSettings(SWT.DEFAULT, 200);
+ // tests[3] = new PathSettings(SWT.ON, 150);
+ // performTestcase(new Runnable() {
+ // public void run() {
+ // g.setFillRule(SWT.FILL_EVEN_ODD);
+ // g.fillPath(path1);
+ // g.fillPath(path2);
+ // }
+ // }, tests);
+ //
+ // path1.dispose();
+ // }
+
+ public void testPatterns() {
+
+ class SetPattern implements Runnable {
+ private final Pattern bg;
+ private final Pattern fg;
+
+ SetPattern(Pattern bg, Pattern fg) {
+ this.bg = bg;
+ this.fg = fg;
+ }
+
+ public void run() {
+ g.setBackgroundPattern(bg);
+ g.setForegroundPattern(fg);
+ }
+ }
+
+ // Initial state
+ Font f = new Font(null, "Helvetica", 50, SWT.BOLD);
+ resources.push(f);
+ g.setFont(f);
+ g.setBackgroundColor(ColorConstants.yellow);
+ g.pushState();
+
+ Pattern gradient = new Pattern(null, 0, 0, 80, 40, ColorConstants.gray,
+ ColorConstants.black);
+ Pattern image = new Pattern(null, TestImages.depth_24);
+
+ resources.push(gradient);
+ resources.push(image);
+
+ Runnable tests[] = new Runnable[1];
+ tests[0] = new SetPattern(image, gradient);
+ performTestcase(new Runnable() {
+ public void run() {
+ g.fillText("W", 0, 0);
+ }
+ }, tests);
+
+ }
+
+}
\ No newline at end of file
diff --git a/tests/org.eclipse.draw2d.test/src/org/eclipse/draw2d/test/TextualTests.java b/tests/org.eclipse.draw2d.test/src/org/eclipse/draw2d/test/TextualTests.java
index 915aa1f..83d2c5a 100644
--- a/tests/org.eclipse.draw2d.test/src/org/eclipse/draw2d/test/TextualTests.java
+++ b/tests/org.eclipse.draw2d.test/src/org/eclipse/draw2d/test/TextualTests.java
@@ -48,7 +48,7 @@
// TODO enhance verification
List boldFragments = bold.getFragments();
- assertEquals(3, boldFragments.size());
+ assertTrue(boldFragments.size() == 3);
List italicFragments = italics.getFragments();
assertTrue(italicFragments.size() == 2);
}
diff --git a/tests/org.eclipse.zest.tests/src/org/eclipse/zest/tests/IFigureProviderTests.java b/tests/org.eclipse.zest.tests/src/org/eclipse/zest/tests/IFigureProviderTests.java
index 4ffd985..8885006 100644
--- a/tests/org.eclipse.zest.tests/src/org/eclipse/zest/tests/IFigureProviderTests.java
+++ b/tests/org.eclipse.zest.tests/src/org/eclipse/zest/tests/IFigureProviderTests.java
@@ -78,9 +78,12 @@
.getText());
}
String string = buffer.toString();
- assertTrue("Label 1 should be in figure labels", string.contains("1"));
- assertTrue("Label 2 should be in figure labels", string.contains("2"));
- assertTrue("Label 3 should be in figure labels", string.contains("3"));
+ assertTrue("Label 1 should be in figure labels",
+ string.indexOf("1") >= 0);
+ assertTrue("Label 2 should be in figure labels",
+ string.indexOf("2") >= 0);
+ assertTrue("Label 3 should be in figure labels",
+ string.indexOf("3") >= 0);
}
private class DestinationContentProvider implements IGraphContentProvider {