Lines 7-23
Link Here
|
7 |
* |
7 |
* |
8 |
* Contributors: |
8 |
* Contributors: |
9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
|
|
10 |
* Peter Severin <peter@wireframesketcher.com> - Bug 522342 |
10 |
*******************************************************************************/ |
11 |
*******************************************************************************/ |
11 |
package org.eclipse.gef.internal.ui.rulers; |
12 |
package org.eclipse.gef.internal.ui.rulers; |
12 |
|
13 |
|
13 |
import org.eclipse.swt.graphics.Image; |
14 |
import org.eclipse.swt.SWT; |
14 |
import org.eclipse.swt.widgets.Display; |
15 |
import org.eclipse.swt.widgets.Display; |
15 |
|
16 |
|
16 |
import org.eclipse.draw2d.ColorConstants; |
17 |
import org.eclipse.draw2d.ColorConstants; |
17 |
import org.eclipse.draw2d.Figure; |
18 |
import org.eclipse.draw2d.Figure; |
18 |
import org.eclipse.draw2d.FigureUtilities; |
19 |
import org.eclipse.draw2d.FigureUtilities; |
19 |
import org.eclipse.draw2d.Graphics; |
20 |
import org.eclipse.draw2d.Graphics; |
20 |
import org.eclipse.draw2d.ImageUtilities; |
|
|
21 |
import org.eclipse.draw2d.geometry.Dimension; |
21 |
import org.eclipse.draw2d.geometry.Dimension; |
22 |
import org.eclipse.draw2d.geometry.Point; |
22 |
import org.eclipse.draw2d.geometry.Point; |
23 |
import org.eclipse.draw2d.geometry.Rectangle; |
23 |
import org.eclipse.draw2d.geometry.Rectangle; |
Lines 300-316
Link Here
|
300 |
int y = (int) (div * dotsPerDivision); |
300 |
int y = (int) (div * dotsPerDivision); |
301 |
if (div % divsPerMajorMark == 0) { |
301 |
if (div % divsPerMajorMark == 0) { |
302 |
String num = "" + (div / divsPerMajorMark) * unitsPerMajorMark; //$NON-NLS-1$ |
302 |
String num = "" + (div / divsPerMajorMark) * unitsPerMajorMark; //$NON-NLS-1$ |
|
|
303 |
Dimension numSize = FigureUtilities.getStringExtents(num, |
304 |
getFont()); |
305 |
/* |
306 |
* If the width is even, we want to increase it by 1. This |
307 |
* will ensure that when marks are erased because they are |
308 |
* too close to the number, they are erased from both sides |
309 |
* of that number. |
310 |
*/ |
311 |
if (numSize.width % 2 == 0) |
312 |
numSize.width++; |
313 |
|
303 |
if (isHorizontal()) { |
314 |
if (isHorizontal()) { |
304 |
Dimension numSize = FigureUtilities.getStringExtents(num, |
|
|
305 |
getFont()); |
306 |
/* |
307 |
* If the width is even, we want to increase it by 1. This |
308 |
* will ensure that when marks are erased because they are |
309 |
* too close to the number, they are erased from both sides |
310 |
* of that number. |
311 |
*/ |
312 |
if (numSize.width % 2 == 0) |
313 |
numSize.width++; |
314 |
Point textLocation = new Point(y - (numSize.width / 2), |
315 |
Point textLocation = new Point(y - (numSize.width / 2), |
315 |
clippedBounds.x + textMargin - leading); |
316 |
clippedBounds.x + textMargin - leading); |
316 |
forbiddenZone.setLocation(textLocation); |
317 |
forbiddenZone.setLocation(textLocation); |
Lines 324-343
Link Here
|
324 |
// + clippedBounds.width); |
325 |
// + clippedBounds.width); |
325 |
graphics.drawText(num, textLocation); |
326 |
graphics.drawText(num, textLocation); |
326 |
} else { |
327 |
} else { |
327 |
Image numImage = ImageUtilities.createRotatedImageOfString( |
|
|
328 |
num, getFont(), getForegroundColor(), |
329 |
getBackgroundColor()); |
330 |
Point textLocation = new Point( |
328 |
Point textLocation = new Point( |
331 |
clippedBounds.x + textMargin, y |
329 |
clippedBounds.x + textMargin - leading, |
332 |
- (numImage.getBounds().height / 2)); |
330 |
y - (numSize.width / 2)); |
333 |
forbiddenZone.setLocation(textLocation); |
331 |
forbiddenZone.setLocation(0, 0); |
334 |
forbiddenZone.setSize(numImage.getBounds().width, |
332 |
forbiddenZone.setSize(numSize); |
335 |
numImage.getBounds().height); |
333 |
forbiddenZone.expand(1, 1); |
336 |
forbiddenZone.expand(1, |
334 |
graphics.pushState(); |
337 |
1 + (numImage.getBounds().height % 2 == 0 ? 1 : 0)); |
335 |
graphics.translate(textLocation); |
|
|
336 |
graphics.rotate(-90); |
337 |
graphics.translate(-numSize.width, 0); |
338 |
graphics.fillRectangle(forbiddenZone); |
338 |
graphics.fillRectangle(forbiddenZone); |
339 |
graphics.drawImage(numImage, textLocation); |
339 |
graphics.drawText(num, 0, 0); |
340 |
numImage.dispose(); |
340 |
graphics.popState(); |
341 |
} |
341 |
} |
342 |
} else if ((div % divsPerMajorMark) % mediumMarkerDivNum == 0) { |
342 |
} else if ((div % divsPerMajorMark) % mediumMarkerDivNum == 0) { |
343 |
// this is a medium mark, so its length should be longer than |
343 |
// this is a medium mark, so its length should be longer than |