From 9fa5685ffad22aafa4a19ef4602c1a4ff6115db4 Mon Sep 17 00:00:00 2001 From: Jan Pikl Date: Fri, 1 Feb 2013 23:52:23 +0100 Subject: [PATCH] Enabled graphics antialiasing for Windows. --- .../yafmt/ui/editors/fm/figures/CircleDecoration.java | 6 ++++++ .../ui/editors/fm/figures/FeatureModelFigure.java | 10 ++++++++++ .../jpikl/yafmt/ui/editors/fm/figures/GroupFigure.java | 5 ++++- .../ui/editors/fm/parts/FeatureModelEditPart.java | 10 ++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/cz.jpikl.yafmt.ui.editors.fm/src/cz/jpikl/yafmt/ui/editors/fm/figures/CircleDecoration.java b/cz.jpikl.yafmt.ui.editors.fm/src/cz/jpikl/yafmt/ui/editors/fm/figures/CircleDecoration.java index a319218..f82d28a 100644 --- a/cz.jpikl.yafmt.ui.editors.fm/src/cz/jpikl/yafmt/ui/editors/fm/figures/CircleDecoration.java +++ b/cz.jpikl.yafmt.ui.editors.fm/src/cz/jpikl/yafmt/ui/editors/fm/figures/CircleDecoration.java @@ -2,6 +2,7 @@ import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.Ellipse; +import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.RotatableDecoration; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PrecisionPoint; @@ -19,6 +20,11 @@ public void setFilled(boolean filled) { setBackgroundColor(filled ? ColorConstants.black : ColorConstants.white); } + @Override + protected void fillShape(Graphics graphics) { + graphics.fillOval(getBounds()); + } + @Override public void setReferencePoint(Point ref) { Point a = getLocation().getCopy(); diff --git a/cz.jpikl.yafmt.ui.editors.fm/src/cz/jpikl/yafmt/ui/editors/fm/figures/FeatureModelFigure.java b/cz.jpikl.yafmt.ui.editors.fm/src/cz/jpikl/yafmt/ui/editors/fm/figures/FeatureModelFigure.java index 3c206a0..f1334b2 100644 --- a/cz.jpikl.yafmt.ui.editors.fm/src/cz/jpikl/yafmt/ui/editors/fm/figures/FeatureModelFigure.java +++ b/cz.jpikl.yafmt.ui.editors.fm/src/cz/jpikl/yafmt/ui/editors/fm/figures/FeatureModelFigure.java @@ -2,7 +2,9 @@ import org.eclipse.draw2d.FreeformLayer; import org.eclipse.draw2d.FreeformLayout; +import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.MarginBorder; +import org.eclipse.swt.SWT; public class FeatureModelFigure extends FreeformLayer { @@ -11,4 +13,12 @@ public FeatureModelFigure() { setLayoutManager(new FreeformLayout()); } + @Override + public void paint(Graphics graphics) { + // Enable antialiasing. + // Antialiasing for connection layer is enabled in FeatureModelEditPart.refreshVisuals. + graphics.setAntialias(SWT.ON); + super.paint(graphics); + } + } diff --git a/cz.jpikl.yafmt.ui.editors.fm/src/cz/jpikl/yafmt/ui/editors/fm/figures/GroupFigure.java b/cz.jpikl.yafmt.ui.editors.fm/src/cz/jpikl/yafmt/ui/editors/fm/figures/GroupFigure.java index 458cb4b..6e3c131 100644 --- a/cz.jpikl.yafmt.ui.editors.fm/src/cz/jpikl/yafmt/ui/editors/fm/figures/GroupFigure.java +++ b/cz.jpikl.yafmt.ui.editors.fm/src/cz/jpikl/yafmt/ui/editors/fm/figures/GroupFigure.java @@ -55,7 +55,10 @@ public void paintFigure(Graphics graphics) { @Override protected void fillShape(Graphics graphics) { - graphics.fillArc(arcBounds.getTranslated(1, 1), arcOffset, arcLength); + Rectangle fillBounds = arcBounds.getCopy(); + fillBounds.width++; + fillBounds.height++; + graphics.fillArc(fillBounds, arcOffset, arcLength); } @Override diff --git a/cz.jpikl.yafmt.ui.editors.fm/src/cz/jpikl/yafmt/ui/editors/fm/parts/FeatureModelEditPart.java b/cz.jpikl.yafmt.ui.editors.fm/src/cz/jpikl/yafmt/ui/editors/fm/parts/FeatureModelEditPart.java index 5f7c4d1..cda4c55 100644 --- a/cz.jpikl.yafmt.ui.editors.fm/src/cz/jpikl/yafmt/ui/editors/fm/parts/FeatureModelEditPart.java +++ b/cz.jpikl.yafmt.ui.editors.fm/src/cz/jpikl/yafmt/ui/editors/fm/parts/FeatureModelEditPart.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Map; +import org.eclipse.draw2d.ConnectionLayer; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.emf.common.notify.Adapter; @@ -15,7 +16,9 @@ import org.eclipse.gef.EditPart; import org.eclipse.gef.EditPolicy; import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.LayerConstants; import org.eclipse.gef.editparts.AbstractGraphicalEditPart; +import org.eclipse.swt.SWT; import cz.jpikl.yafmt.model.fm.Feature; import cz.jpikl.yafmt.model.fm.FeatureModel; @@ -61,6 +64,13 @@ protected IFigure createFigure() { return new FeatureModelFigure(); } + @Override + protected void refreshVisuals() { + // Enable antialiasing for connection layer. + // Antialiasing for other layers is enabled in FeatureModelFigure. + ((ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER)).setAntialias(SWT.ON); + } + @Override protected void createEditPolicies() { installEditPolicy(EditPolicy.LAYOUT_ROLE, new FeatureModelLayoutPolicy());