Skip to content

Commit

Permalink
Enabled graphics antialiasing for Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpikl committed Feb 1, 2013
1 parent be715b9 commit 9fa5685
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 9fa5685

Please sign in to comment.