View | Details | Raw Unified | Return to bug 522342 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.gef/src/org/eclipse/gef/internal/ui/rulers/RulerFigure.java (-14 / +25 lines)
Lines 10-23 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.gef.internal.ui.rulers;
11
package org.eclipse.gef.internal.ui.rulers;
12
12
13
import org.eclipse.swt.graphics.Image;
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.widgets.Display;
14
import org.eclipse.swt.widgets.Display;
15
15
16
import org.eclipse.draw2d.ColorConstants;
16
import org.eclipse.draw2d.ColorConstants;
17
import org.eclipse.draw2d.Figure;
17
import org.eclipse.draw2d.Figure;
18
import org.eclipse.draw2d.FigureUtilities;
18
import org.eclipse.draw2d.FigureUtilities;
19
import org.eclipse.draw2d.Graphics;
19
import org.eclipse.draw2d.Graphics;
20
import org.eclipse.draw2d.ImageUtilities;
21
import org.eclipse.draw2d.geometry.Dimension;
20
import org.eclipse.draw2d.geometry.Dimension;
22
import org.eclipse.draw2d.geometry.Point;
21
import org.eclipse.draw2d.geometry.Point;
23
import org.eclipse.draw2d.geometry.Rectangle;
22
import org.eclipse.draw2d.geometry.Rectangle;
Lines 295-300 Link Here
295
		int endMark = (int) (((clippedBounds.y + clippedBounds.height) / dotsPerDivision)) + 1;
294
		int endMark = (int) (((clippedBounds.y + clippedBounds.height) / dotsPerDivision)) + 1;
296
		int leading = FigureUtilities.getFontMetrics(getFont()).getLeading();
295
		int leading = FigureUtilities.getFontMetrics(getFont()).getLeading();
297
		Rectangle forbiddenZone = new Rectangle();
296
		Rectangle forbiddenZone = new Rectangle();
297
		// Antialias is required for vertical text on Windows
298
		graphics.setAntialias(SWT.ON);
299
		graphics.setTextAntialias(SWT.ON);
298
		for (int div = startMark; div <= endMark; div++) {
300
		for (int div = startMark; div <= endMark; div++) {
299
			// y is the vertical position of the mark
301
			// y is the vertical position of the mark
300
			int y = (int) (div * dotsPerDivision);
302
			int y = (int) (div * dotsPerDivision);
Lines 324-343 Link Here
324
					// + clippedBounds.width);
326
					// + clippedBounds.width);
325
					graphics.drawText(num, textLocation);
327
					graphics.drawText(num, textLocation);
326
				} else {
328
				} else {
327
					Image numImage = ImageUtilities.createRotatedImageOfString(
329
					Dimension numSize = FigureUtilities.getStringExtents(num,
328
							num, getFont(), getForegroundColor(),
330
							getFont());
329
							getBackgroundColor());
331
					/*
332
					 * If the width is even, we want to increase it by 1. This
333
					 * will ensure that when marks are erased because they are
334
					 * too close to the number, they are erased from both sides
335
					 * of that number.
336
					 */
337
					if (numSize.width % 2 == 0)
338
						numSize.width++;
330
					Point textLocation = new Point(
339
					Point textLocation = new Point(
331
							clippedBounds.x + textMargin, y
340
							clippedBounds.x + textMargin - leading,
332
									- (numImage.getBounds().height / 2));
341
							y - (numSize.width / 2));
333
					forbiddenZone.setLocation(textLocation);
342
					forbiddenZone.setLocation(0, 0);
334
					forbiddenZone.setSize(numImage.getBounds().width,
343
					forbiddenZone.setSize(numSize);
335
							numImage.getBounds().height);
344
					forbiddenZone.expand(1, 1);
336
					forbiddenZone.expand(1,
345
					graphics.pushState();
337
							1 + (numImage.getBounds().height % 2 == 0 ? 1 : 0));
346
					graphics.translate(textLocation);
347
					graphics.rotate(-90);
348
					graphics.translate(-numSize.width, 0);
338
					graphics.fillRectangle(forbiddenZone);
349
					graphics.fillRectangle(forbiddenZone);
339
					graphics.drawImage(numImage, textLocation);
350
					graphics.drawText(num, 0, 0);
340
					numImage.dispose();
351
					graphics.popState();
341
				}
352
				}
342
			} else if ((div % divsPerMajorMark) % mediumMarkerDivNum == 0) {
353
			} else if ((div % divsPerMajorMark) % mediumMarkerDivNum == 0) {
343
				// this is a medium mark, so its length should be longer than
354
				// this is a medium mark, so its length should be longer than

Return to bug 522342