Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Raynaud2014-04-01 08:16:42 +0000
committerMarc Dumais2014-04-01 16:46:13 +0000
commitf65493131c5b846e3ba18ece3ef9886adeff988a (patch)
tree97de2ecad791793f750d311811b2f9e239983788 /visualizer
parentaf6a81e33d2da1c102f9230f3565308e4eef47e0 (diff)
downloadorg.eclipse.cdt-f65493131c5b846e3ba18ece3ef9886adeff988a.tar.gz
org.eclipse.cdt-f65493131c5b846e3ba18ece3ef9886adeff988a.tar.xz
org.eclipse.cdt-f65493131c5b846e3ba18ece3ef9886adeff988a.zip
Bug 431690 - [visualizer] Use clipping when drawing strings
Change-Id: I342b1a430da450b45d62cea1469fbb62a3e9bc94 Signed-off-by: Xavier Raynaud <xavier.raynaud@kalray.eu> Reviewed-on: https://git.eclipse.org/r/24201 Tested-by: Hudson CI IP-Clean: Marc Dumais <marc.dumais@ericsson.com> Tested-by: Marc Dumais <marc.dumais@ericsson.com> Reviewed-by: William Swanson <traveler@tilera.com> Reviewed-by: Marc Dumais <marc.dumais@ericsson.com>
Diffstat (limited to 'visualizer')
-rw-r--r--visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/problemvisualizer/BarGraphicObject.java5
-rwxr-xr-xvisualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/GUIUtils.java36
2 files changed, 35 insertions, 6 deletions
diff --git a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/problemvisualizer/BarGraphicObject.java b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/problemvisualizer/BarGraphicObject.java
index 5013b849aec..a8d98c06a63 100644
--- a/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/problemvisualizer/BarGraphicObject.java
+++ b/visualizer/org.eclipse.cdt.visualizer.examples/src/org/eclipse/cdt/visualizer/examples/problemvisualizer/BarGraphicObject.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Ericsson and others.
+ * Copyright (c) 2012, 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Marc Khouzam (Ericsson) - initial API and implementation
+ * Xavier Raynaud (Kalray) - Bug 431690
*******************************************************************************/
package org.eclipse.cdt.visualizer.examples.problemvisualizer;
@@ -75,7 +76,7 @@ public class BarGraphicObject extends GraphicObject {
int text_indent = 6;
int tx = m_bounds.x + m_bounds.width - text_indent;
int ty = m_bounds.y + m_bounds.height - text_indent;
- GUIUtils.drawTextAligned(gc, m_label, tx, ty, false, false);
+ GUIUtils.drawTextAligned(gc, m_label, m_bounds, tx, ty, false, false);
}
}
diff --git a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/GUIUtils.java b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/GUIUtils.java
index c778ccd83c6..138ad4fd1fd 100755
--- a/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/GUIUtils.java
+++ b/visualizer/org.eclipse.cdt.visualizer.ui/src/org/eclipse/cdt/visualizer/ui/util/GUIUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Tilera Corporation and others.
+ * Copyright (c) 2012, 2014 Tilera Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* William R. Swanson (Tilera Corporation)
+ * Xavier Raynaud (Kalray) - Bug 431690
*******************************************************************************/
package org.eclipse.cdt.visualizer.ui.util;
@@ -88,6 +89,15 @@ public class GUIUtils {
gc.drawText(text, x, y, SWT.DRAW_TRANSPARENT);
}
+ /** Draws transparent text, with the default alignment (top/left). */
+ static public void drawText(GC gc, String text, Rectangle clip, int x, int y)
+ {
+ Rectangle oldClip = gc.getClipping();
+ gc.setClipping(clip);
+ drawText(gc, text, x, y);
+ gc.setClipping(oldClip);
+ }
+
/** Draws transparent text, with the specified alignments. */
static public void drawTextAligned(GC gc, String text, int x, int y, boolean left, boolean top)
{
@@ -101,7 +111,16 @@ public class GUIUtils {
gc.drawText(text, x - dx, y - dy, SWT.DRAW_TRANSPARENT);
}
}
-
+
+ /** Draws transparent text, with the specified alignments. */
+ static public void drawTextAligned(GC gc, String text, Rectangle clip, int x, int y, boolean left, boolean top)
+ {
+ Rectangle oldClip = gc.getClipping();
+ gc.setClipping(clip);
+ drawTextAligned(gc, text, x, y, left, top);
+ gc.setClipping(oldClip);
+ }
+
/** Draws transparent text, centered on the specified point. */
static public void drawTextCentered(GC gc, String text, int x, int y)
{
@@ -110,8 +129,17 @@ public class GUIUtils {
gc.drawText(text, x - (int) Math.round(te.x / 2.0),
y - (int) Math.round(te.y / 2.0), SWT.DRAW_TRANSPARENT);
}
-
-
+
+ /** Draws transparent text, centered on the specified point. */
+ static public void drawTextCentered(GC gc, String text, Rectangle clip, int x, int y)
+ {
+ Rectangle oldClip = gc.getClipping();
+ gc.setClipping(clip);
+ drawTextCentered(gc, text, x, y);
+ gc.setClipping(oldClip);
+ }
+
+
// --- graphic methods ---
/** Shrinks rectangle by specified margin on all edges. */

Back to the top