aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDirk Fauth2013-07-24 11:07:38 (EDT)
committerDirk Fauth2013-07-24 11:07:38 (EDT)
commit6c33b74fbd476d56250152cc1c635425affa5eee (patch)
tree6d73a3b0bd232b53f60bf085171166ebe7cb33f2
parent21bab3a0a21b92623059cf74a31df55c305c9251 (diff)
downloadorg.eclipse.nebula-6c33b74fbd476d56250152cc1c635425affa5eee.zip
org.eclipse.nebula-6c33b74fbd476d56250152cc1c635425affa5eee.tar.gz
org.eclipse.nebula-6c33b74fbd476d56250152cc1c635425affa5eee.tar.bz2
Bug 413654 - added the shiftHorizontalCenteredEventString() method to
the ISettings interface and implemented it in the AbstractSettings to return false to be backwards compatible.
-rw-r--r--widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/AbstractPaintManager.java2
-rw-r--r--widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/AbstractSettings.java4
-rw-r--r--widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/ISettings.java11
3 files changed, 17 insertions, 0 deletions
diff --git a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/AbstractPaintManager.java b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/AbstractPaintManager.java
index 921d6e0..ff25a4f 100644
--- a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/AbstractPaintManager.java
+++ b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/AbstractPaintManager.java
@@ -402,8 +402,10 @@ public abstract class AbstractPaintManager implements IPaintManager {
textXStart = x - textSpacer - toDrawExtent.x;
break;
case SWT.CENTER:
+ if (!settings.shiftHorizontalCenteredEventString() || toDrawExtent.x < eventWidth) {
textXStart = x + (eventWidth / 2) - (toDrawExtent.x / 2);
break;
+ }
case SWT.RIGHT:
//textXStart = x + eventWidth + textSpacer;
int eventOrPictureWidth = eventWidth;
diff --git a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/AbstractSettings.java b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/AbstractSettings.java
index 1ca1ecf..235446e 100644
--- a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/AbstractSettings.java
+++ b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/AbstractSettings.java
@@ -522,4 +522,8 @@ public abstract class AbstractSettings implements ISettings {
public Calendar getPeriodEnd() {
return null;
}
+
+ public boolean shiftHorizontalCenteredEventString() {
+ return false;
+ }
}
diff --git a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/ISettings.java b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/ISettings.java
index 287f953..601a315 100644
--- a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/ISettings.java
+++ b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/ISettings.java
@@ -1095,4 +1095,15 @@ public interface ISettings {
public Calendar getPeriodStart();
public Calendar getPeriodEnd();
+
+ /**
+ * If you want to show the event String within the event rectangle by setting the horizontalTextLocation of
+ * the GanttEvent to SWT.CENTER, there are cases that break the visualization. If your event String is longer
+ * than the event in the Gantt, it will look quite strange.
+ * <p>
+ * If this method returns <code>true</code>, the AbstractPaintManager will shift the rendering of the event
+ * String to the right if the String length is greater than the event rectangle.
+ * @return <code>true</code> if the event String should be shifted, <code>false</code> if not
+ */
+ public boolean shiftHorizontalCenteredEventString();
}