diff --git a/org.eclipse.gef/src/org/eclipse/gef/internal/ui/rulers/RulerFigure.java b/org.eclipse.gef/src/org/eclipse/gef/internal/ui/rulers/RulerFigure.java index 181fd8f..3014472 100644 --- a/org.eclipse.gef/src/org/eclipse/gef/internal/ui/rulers/RulerFigure.java +++ b/org.eclipse.gef/src/org/eclipse/gef/internal/ui/rulers/RulerFigure.java @@ -10,14 +10,13 @@ *******************************************************************************/ package org.eclipse.gef.internal.ui.rulers; -import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.Figure; import org.eclipse.draw2d.FigureUtilities; import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.ImageUtilities; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; @@ -295,6 +294,9 @@ int endMark = (int) (((clippedBounds.y + clippedBounds.height) / dotsPerDivision)) + 1; int leading = FigureUtilities.getFontMetrics(getFont()).getLeading(); Rectangle forbiddenZone = new Rectangle(); + // Antialias is required for vertical text on Windows + graphics.setAntialias(SWT.ON); + graphics.setTextAntialias(SWT.ON); for (int div = startMark; div <= endMark; div++) { // y is the vertical position of the mark int y = (int) (div * dotsPerDivision); @@ -324,20 +326,29 @@ // + clippedBounds.width); graphics.drawText(num, textLocation); } else { - Image numImage = ImageUtilities.createRotatedImageOfString( - num, getFont(), getForegroundColor(), - getBackgroundColor()); + Dimension numSize = FigureUtilities.getStringExtents(num, + getFont()); + /* + * If the width is even, we want to increase it by 1. This + * will ensure that when marks are erased because they are + * too close to the number, they are erased from both sides + * of that number. + */ + if (numSize.width % 2 == 0) + numSize.width++; Point textLocation = new Point( - clippedBounds.x + textMargin, y - - (numImage.getBounds().height / 2)); - forbiddenZone.setLocation(textLocation); - forbiddenZone.setSize(numImage.getBounds().width, - numImage.getBounds().height); - forbiddenZone.expand(1, - 1 + (numImage.getBounds().height % 2 == 0 ? 1 : 0)); + clippedBounds.x + textMargin - leading, + y - (numSize.width / 2)); + forbiddenZone.setLocation(0, 0); + forbiddenZone.setSize(numSize); + forbiddenZone.expand(1, 1); + graphics.pushState(); + graphics.translate(textLocation); + graphics.rotate(-90); + graphics.translate(-numSize.width, 0); graphics.fillRectangle(forbiddenZone); - graphics.drawImage(numImage, textLocation); - numImage.dispose(); + graphics.drawText(num, 0, 0); + graphics.popState(); } } else if ((div % divsPerMajorMark) % mediumMarkerDivNum == 0) { // this is a medium mark, so its length should be longer than