modify gradient architecture: gradient data are hold in mm now
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/PredefinedColoredAreas.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/PredefinedColoredAreas.java
new file mode 100644
index 0000000..645c0cc
--- /dev/null
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/PredefinedColoredAreas.java
@@ -0,0 +1,537 @@
+/*******************************************************************************
+ * <copyright>
+ *
+ * Copyright (c) 2005, 2010 SAP AG.
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SAP AG - initial API, implementation and documentation
+ *
+ * </copyright>
+ *
+ *******************************************************************************/
+package org.eclipse.graphiti.ui;
+
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.graphiti.mm.datatypes.DatatypesFactory;
+import org.eclipse.graphiti.mm.pictograms.AdaptedGradientColoredAreas;
+import org.eclipse.graphiti.mm.pictograms.GradientColoredArea;
+import org.eclipse.graphiti.mm.pictograms.GradientColoredAreas;
+import org.eclipse.graphiti.mm.pictograms.GradientColoredLocation;
+import org.eclipse.graphiti.mm.pictograms.LocationType;
+import org.eclipse.graphiti.mm.pictograms.PictogramsFactory;
+import org.eclipse.graphiti.ui.internal.config.IConfigurationProvider;
+import org.eclipse.graphiti.ui.internal.figures.GFFigureUtil;
+import org.eclipse.graphiti.util.IPredefinedRenderingStyle;
+import org.eclipse.graphiti.util.test;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * Predefined colored areas to be used in
+ * {@link GFFigureUtil#paintColorFlow(IConfigurationProvider, Rectangle, Graphics, GradientColoredArea, double, boolean)}
+ * .
+ *
+ */
+public class PredefinedColoredAreas implements IPredefinedRenderingStyle, test {
+
+ /**
+ * The color-areas, which are used for default elements with the ID
+ * {@link #BLUE_WHITE_GLOSS_ID}.
+ */
+ private static GradientColoredAreas getBlueWhiteGlossDefaultAreas() {
+ final GradientColoredAreas gradientColoredAreas = PictogramsFactory.eINSTANCE.createGradientColoredAreas();
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "F8FBFE", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "F8FBFE", 1, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "EDF5FC", 1, LocationType.LOCATION_TYPE_ABSOLUTE_START, "EDF5FC", 2, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "DEEDFA", 2, LocationType.LOCATION_TYPE_ABSOLUTE_START, "DEEDFA", 3, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "D4E7F8", 3, LocationType.LOCATION_TYPE_ABSOLUTE_START, "FAFBFC", 2, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ addGradientColoredArea(gcas, "E2E5E9", 2, LocationType.LOCATION_TYPE_ABSOLUTE_END, "E2E5E9", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_DEFAULT);
+ return gradientColoredAreas;
+ }
+
+ /**
+ * The color-areas, which are used for primary selected elements with the ID
+ * {@link #BLUE_WHITE_GLOSS_ID}.
+ */
+ private static GradientColoredAreas getBlueWhiteGlossPrimarySelectedAreas() {
+ final GradientColoredAreas gradientColoredAreas = PictogramsFactory.eINSTANCE.createGradientColoredAreas();
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_PRIMARY_SELECTED);
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "EEF6FD", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "EEF6FD", 1, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "D0E6F9", 1, LocationType.LOCATION_TYPE_ABSOLUTE_START, "D0E6F9", 2, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "ACD2F4", 2, LocationType.LOCATION_TYPE_ABSOLUTE_START, "ACD2F4", 3, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "81B9EA", 3, LocationType.LOCATION_TYPE_ABSOLUTE_START, "AAD0F2", 2, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ addGradientColoredArea(gcas, "9ABFE0", 2, LocationType.LOCATION_TYPE_ABSOLUTE_END, "9ABFE0", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ return gradientColoredAreas;
+ }
+
+ /**
+ * The color-areas, which are used for secondary selected elements with the
+ * ID {@link #BLUE_WHITE_GLOSS_ID}.
+ */
+ private static GradientColoredAreas getBlueWhiteGlossSecondarySelectedAreas() {
+ final GradientColoredAreas gradientColoredAreas = PictogramsFactory.eINSTANCE.createGradientColoredAreas();
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_SECONDARY_SELECTED);
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "F5F9FE", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "F5F9FE", 1, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "E2EFFC", 1, LocationType.LOCATION_TYPE_ABSOLUTE_START, "E2EFFC", 2, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "CBE3F9", 2, LocationType.LOCATION_TYPE_ABSOLUTE_START, "CBE3F9", 3, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "BBDAF7", 3, LocationType.LOCATION_TYPE_ABSOLUTE_START, "C5E0F7", 2, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ addGradientColoredArea(gcas, "B2CDE5", 2, LocationType.LOCATION_TYPE_ABSOLUTE_END, "B2CDE5", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ return gradientColoredAreas;
+ }
+
+ /**
+ * The color-areas, which are used for elements where an action is allowed
+ * with the ID {@link #BLUE_WHITE_GLOSS_ID}.
+ */
+ private static GradientColoredAreas getBlueWhiteGlossActionAllowedAreas() {
+ final GradientColoredAreas gradientColoredAreas = PictogramsFactory.eINSTANCE.createGradientColoredAreas();
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_ACTION_ALLOWED);
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "99CC00", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "339966", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ return gradientColoredAreas;
+ }
+
+ /**
+ * The color-areas, which are used for elements where an action is forbidden
+ * with the ID {@link #BLUE_WHITE_GLOSS_ID}.
+ */
+ private static GradientColoredAreas getBlueWhiteGlossActionForbiddenAreas() {
+ final GradientColoredAreas gradientColoredAreas = PictogramsFactory.eINSTANCE.createGradientColoredAreas();
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_ACTION_FORBIDDEN);
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "FFCC00", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "FF6600", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ return gradientColoredAreas;
+ }
+
+ /**
+ * @return
+ */
+ public static AdaptedGradientColoredAreas getBlueWhiteGlossAdaptions() {
+ final AdaptedGradientColoredAreas agca = PictogramsFactory.eINSTANCE.createAdaptedGradientColoredAreas();
+ agca.setDefinedStyleId(BLUE_WHITE_GLOSS_ID);
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_DEFAULT, getBlueWhiteGlossDefaultAreas());
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_PRIMARY_SELECTED,
+ getBlueWhiteGlossPrimarySelectedAreas());
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_SECONDARY_SELECTED,
+ getBlueWhiteGlossSecondarySelectedAreas());
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_ACTION_ALLOWED,
+ getBlueWhiteGlossActionAllowedAreas());
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_ACTION_FORBIDDEN,
+ getBlueWhiteGlossActionForbiddenAreas());
+ return agca;
+ }
+
+ /**
+ * The color-areas, which are used for default elements with the ID
+ * {@link #BLUE_WHITE_ID}.
+ */
+ private static GradientColoredAreas getBlueWhiteDefaultAreas() {
+ final GradientColoredAreas gradientColoredAreas = PictogramsFactory.eINSTANCE.createGradientColoredAreas();
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_DEFAULT);
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "D4E7F8", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "FAFBFC", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ return gradientColoredAreas;
+ }
+
+ /**
+ * The color-areas, which are used for primary selected elements with the ID
+ * {@link #BLUE_WHITE_ID}.
+ */
+ private static GradientColoredAreas getBlueWhitePrimarySelectedAreas() {
+ final GradientColoredAreas gradientColoredAreas = PictogramsFactory.eINSTANCE.createGradientColoredAreas();
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_PRIMARY_SELECTED);
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "81B9EA", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "AAD0F2", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ return gradientColoredAreas;
+ }
+
+ /**
+ * The color-areas, which are used for secondary selected elements with the
+ * ID {@link #BLUE_WHITE_ID}.
+ */
+ private static GradientColoredAreas getBlueWhiteSecondarySelectedAreas() {
+ final GradientColoredAreas gradientColoredAreas = PictogramsFactory.eINSTANCE.createGradientColoredAreas();
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_SECONDARY_SELECTED);
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "BBDAF7", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "C5E0F7", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ return gradientColoredAreas;
+ }
+
+ /**
+ * @return
+ */
+ public static AdaptedGradientColoredAreas getBlueWhiteAdaptions() {
+ final AdaptedGradientColoredAreas agca = PictogramsFactory.eINSTANCE.createAdaptedGradientColoredAreas();
+ agca.setDefinedStyleId(BLUE_WHITE_ID);
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_DEFAULT, getBlueWhiteDefaultAreas());
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_PRIMARY_SELECTED,
+ getBlueWhitePrimarySelectedAreas());
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_SECONDARY_SELECTED,
+ getBlueWhiteSecondarySelectedAreas());
+ return agca;
+ }
+
+ /**
+ * The color-areas, which are used for default elements with the ID
+ * {@link #LIGHT_YELLOW_ID}.
+ */
+ private static GradientColoredAreas getLightYellowDefaultAreas() {
+ final GradientColoredAreas gradientColoredAreas = PictogramsFactory.eINSTANCE.createGradientColoredAreas();
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_DEFAULT);
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "FEFEF4", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "FEFEF4", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ return gradientColoredAreas;
+ }
+
+ /**
+ * The color-areas, which are used for primary selected elements with the ID
+ * {@link #LIGHT_YELLOW_ID}.
+ */
+ private static GradientColoredAreas getLightYellowPrimarySelectedAreas() {
+ final GradientColoredAreas gradientColoredAreas = PictogramsFactory.eINSTANCE.createGradientColoredAreas();
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_PRIMARY_SELECTED);
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "E5E5C2", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "E5E5C2", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ return gradientColoredAreas;
+ }
+
+ /**
+ * The color-areas, which are used for secondary selected elements with the
+ * ID {@link #LIGHT_YELLOW_ID}.
+ */
+ private static GradientColoredAreas getLightYellowSecondarySelectedAreas() {
+ final GradientColoredAreas gradientColoredAreas = PictogramsFactory.eINSTANCE.createGradientColoredAreas();
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_SECONDARY_SELECTED);
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "FAFAD9", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "FAFAD9", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ return gradientColoredAreas;
+ }
+
+ /**
+ * @return
+ */
+ public static AdaptedGradientColoredAreas getLightYellowAdaptions() {
+ final AdaptedGradientColoredAreas agca = PictogramsFactory.eINSTANCE.createAdaptedGradientColoredAreas();
+ agca.setDefinedStyleId(LIGHT_YELLOW_ID);
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_DEFAULT, getLightYellowDefaultAreas());
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_PRIMARY_SELECTED,
+ getLightYellowPrimarySelectedAreas());
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_SECONDARY_SELECTED,
+ getLightYellowSecondarySelectedAreas());
+ return agca;
+ }
+
+ /**
+ * The color-areas, which are used for default elements with the ID
+ * {@link #LIGHT_GRAY_ID}.
+ */
+ private static GradientColoredAreas getLightGrayDefaultAreas() {
+ final GradientColoredAreas gradientColoredAreas = PictogramsFactory.eINSTANCE.createGradientColoredAreas();
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_DEFAULT);
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "F5F5ED", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "F5F5ED", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ return gradientColoredAreas;
+ }
+
+ /**
+ * The color-areas, which are used for primary selected elements with the ID
+ * {@link #LIGHT_GRAY_ID}.
+ */
+ private static GradientColoredAreas getLightGrayPrimarySelectedAreas() {
+ final GradientColoredAreas gradientColoredAreas = PictogramsFactory.eINSTANCE.createGradientColoredAreas();
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_PRIMARY_SELECTED);
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "D6D6D0", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "D6D6D0", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ return gradientColoredAreas;
+ }
+
+ /**
+ * The color-areas, which are used for secondary selected elements with the
+ * ID {@link #LIGHT_GRAY_ID}.
+ */
+ private static GradientColoredAreas getLightGraySecondarySelectedAreas() {
+ final GradientColoredAreas gradientColoredAreas = PictogramsFactory.eINSTANCE.createGradientColoredAreas();
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_SECONDARY_SELECTED);
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "E5E5Df", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "E5E5Df", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ return gradientColoredAreas;
+ }
+
+ /**
+ * @return
+ */
+ public static AdaptedGradientColoredAreas getLightGrayAdaptions() {
+ final AdaptedGradientColoredAreas agca = PictogramsFactory.eINSTANCE.createAdaptedGradientColoredAreas();
+ agca.setDefinedStyleId(LIGHT_GRAY_ID);
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_DEFAULT, getLightGrayDefaultAreas());
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_PRIMARY_SELECTED,
+ getLightGrayPrimarySelectedAreas());
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_SECONDARY_SELECTED,
+ getLightGraySecondarySelectedAreas());
+ return agca;
+ }
+
+ /**
+ * The color-areas, which are used for default elements with the ID
+ * {@link #COPPER_WHITE_GLOSS_ID}.
+ */
+ private static GradientColoredAreas getCopperWhiteGlossDefaultAreas() {
+ final GradientColoredAreas gradientColoredAreas = PictogramsFactory.eINSTANCE.createGradientColoredAreas();
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_DEFAULT);
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "F9F5F2", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "F9F5F2", 1, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "EDE0D8", 1, LocationType.LOCATION_TYPE_ABSOLUTE_START, "EDE0D8", 2, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "E4D0C4", 2, LocationType.LOCATION_TYPE_ABSOLUTE_START, "F5F0E8", 2, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ addGradientColoredArea(gcas, "E6DDD0", 2, LocationType.LOCATION_TYPE_ABSOLUTE_END, "E6DDD0", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ return gradientColoredAreas;
+ }
+
+ /**
+ * @return
+ */
+ public static AdaptedGradientColoredAreas getCopperWhiteGlossAdaptions() {
+ final AdaptedGradientColoredAreas agca = PictogramsFactory.eINSTANCE.createAdaptedGradientColoredAreas();
+ agca.setDefinedStyleId(COPPER_WHITE_GLOSS_ID);
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_DEFAULT, getCopperWhiteGlossDefaultAreas());
+ return agca;
+ }
+
+ /**
+ * The color-areas, which are used for default elements with the ID
+ * {@link #SILVER_WHITE_GLOSS_ID}.
+ */
+ private static GradientColoredAreas getSilverWhiteGlossDefaultAreas() {
+ final GradientColoredAreas gradientColoredAreas = PictogramsFactory.eINSTANCE.createGradientColoredAreas();
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_DEFAULT);
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "EEEEED", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "EEEEED", 1, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "E1E1E0", 1, LocationType.LOCATION_TYPE_ABSOLUTE_START, "E1E1E0", 2, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "D2D1CF", 2, LocationType.LOCATION_TYPE_ABSOLUTE_START, "F2F0EF", 2, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ addGradientColoredArea(gcas, "DFDEDD", 2, LocationType.LOCATION_TYPE_ABSOLUTE_END, "DFDEDD", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ return gradientColoredAreas;
+ }
+
+ /**
+ * @return
+ */
+ public static AdaptedGradientColoredAreas getSilverWhiteGlossAdaptions() {
+ final AdaptedGradientColoredAreas agca = PictogramsFactory.eINSTANCE.createAdaptedGradientColoredAreas();
+ agca.setDefinedStyleId(SILVER_WHITE_GLOSS_ID);
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_DEFAULT, getSilverWhiteGlossDefaultAreas());
+ return agca;
+ }
+
+ /**
+ * @param id
+ * @return
+ */
+ public static AdaptedGradientColoredAreas getAdaptedGradientColoredAreas(String id) {
+ if (BLUE_WHITE_GLOSS_ID.equals(id)) {
+ return getBlueWhiteGlossAdaptions();
+ } else if (BLUE_WHITE_ID.equals(id)) {
+ return getBlueWhiteAdaptions();
+ } else if (LIGHT_YELLOW_ID.equals(id)) {
+ return getLightYellowAdaptions();
+ } else if (LIGHT_GRAY_ID.equals(id)) {
+ return getLightGrayAdaptions();
+ } else if (COPPER_WHITE_GLOSS_ID.equals(id)) {
+ return getCopperWhiteGlossAdaptions();
+ } else if (SILVER_WHITE_GLOSS_ID.equals(id)) {
+ return getSilverWhiteGlossAdaptions();
+ } else {
+ return null;
+ }
+
+ }
+
+ private static void addGradientColoredArea(EList<GradientColoredArea> gcas, String colorStart, int locationValueStart,
+ LocationType locationTypeStart, String colorEnd, int locationValueEnd, LocationType locationTypeEnd) {
+ final GradientColoredArea gca = PictogramsFactory.eINSTANCE.createGradientColoredArea();
+ gcas.add(gca);
+ gca.setStart(PictogramsFactory.eINSTANCE.createGradientColoredLocation());
+ gca.getStart().setColor(DatatypesFactory.eINSTANCE.createColor());
+ final Color gca2Start = getColor(colorStart);
+ gca.getStart().getColor().setBlue(gca2Start.getBlue());
+ gca.getStart().getColor().setGreen(gca2Start.getGreen());
+ gca.getStart().getColor().setRed(gca2Start.getRed());
+ gca.getStart().setLocationType(locationTypeStart);
+ gca.getStart().setLocationValue(locationValueStart);
+ gca.setEnd(PictogramsFactory.eINSTANCE.createGradientColoredLocation());
+ gca.getEnd().setColor(DatatypesFactory.eINSTANCE.createColor());
+ final Color gca2End = getColor(colorEnd);
+ gca.getEnd().getColor().setBlue(gca2End.getBlue());
+ gca.getEnd().getColor().setGreen(gca2End.getGreen());
+ gca.getEnd().getColor().setRed(gca2End.getRed());
+ gca.getEnd().setLocationType(locationTypeEnd);
+ gca.getEnd().setLocationValue(locationValueEnd);
+ }
+
+ /**
+ * Returns the location for the given length and zoom-factor. The location
+ * is calculated from the location-value and location-type in relation to
+ * the given length and zoom-factor.
+ * <p>
+ * The idea is, that the location-type specifies how to interpret the
+ * location-value in relation to the length. For example if the
+ * location-type is "relative" and the location-value is "40", then this
+ * means, that the location is at 40% of the length. So for a length of 200
+ * the location would be 80.
+ *
+ * @param length
+ * The length, for which to calculate the location.
+ * @param zoom
+ * The zoom-factor, which to use on the location-value.
+ * @return The location for the given length and zoom-factor.
+ */
+ public static int getLocation(GradientColoredLocation gradientColoredLocation, int length, double zoom) {
+ if (gradientColoredLocation.getLocationType() == LocationType.LOCATION_TYPE_ABSOLUTE_START) {
+ return (int) Math.round(gradientColoredLocation.getLocationValue() * zoom);
+ }
+ if (gradientColoredLocation.getLocationType() == LocationType.LOCATION_TYPE_ABSOLUTE_END) {
+ return length - (int) Math.round(gradientColoredLocation.getLocationValue() * zoom);
+ }
+ if (gradientColoredLocation.getLocationType() == LocationType.LOCATION_TYPE_RELATIVE) {
+ final double ret = (double) gradientColoredLocation.getLocationValue() / 100 * length;
+ return (int) Math.round(ret);
+ }
+ throw new IllegalStateException("Unknown location type '" + gradientColoredLocation.getLocationType() + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * Returns a new Color object for a given String, which defines the RGB
+ * values in hexadecimal format. This means, that the String must have a
+ * length of 6 characters. Example: <code>getColor("FF0000")</code> returns
+ * a red color.
+ *
+ * @param hexRGBString
+ * The RGB values in hexadecimal format.
+ * @return A new Color object for a given String, which defines the RGB
+ * values in hexadecimal format.
+ */
+ public static Color getColor(final String hexRGBString) {
+ assert hexRGBString != null && hexRGBString.length() == 6;
+ final int red = 16 * hexToInt(hexRGBString.charAt(0)) + hexToInt(hexRGBString.charAt(1));
+ final int green = 16 * hexToInt(hexRGBString.charAt(2)) + hexToInt(hexRGBString.charAt(3));
+ final int blue = 16 * hexToInt(hexRGBString.charAt(4)) + hexToInt(hexRGBString.charAt(5));
+ return new Color(null, red, green, blue);
+ }
+
+ /**
+ * Returns the integer-value for the given hexadecimal character [0-9, A-F,
+ * a-f].
+ *
+ * @param hexChar
+ * The hexadecimal character, for which to return the
+ * integer-value.
+ * @return The integer-value for the given hexadecimal character.
+ * @throws NumberFormatException
+ * , if given character is not hexadecimal [0-9, A-F, a-f]
+ */
+ private static int hexToInt(char hexChar) throws NumberFormatException {
+ switch (hexChar) {
+ case '0':
+ return 0;
+ case '1':
+ return 1;
+ case '2':
+ return 2;
+ case '3':
+ return 3;
+ case '4':
+ return 4;
+ case '5':
+ return 5;
+ case '6':
+ return 6;
+ case '7':
+ return 7;
+ case '8':
+ return 8;
+ case '9':
+ return 9;
+ case 'A':
+ return 10;
+ case 'B':
+ return 11;
+ case 'C':
+ return 12;
+ case 'D':
+ return 13;
+ case 'E':
+ return 14;
+ case 'F':
+ return 15;
+ case 'a':
+ return 10;
+ case 'b':
+ return 11;
+ case 'c':
+ return 12;
+ case 'd':
+ return 13;
+ case 'e':
+ return 14;
+ case 'f':
+ return 15;
+ }
+ throw new NumberFormatException("Not a hexadecimal char: ascii-code=" + (int) hexChar); //$NON-NLS-1$
+ }
+}
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/figures/ColoredArea.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/figures/ColoredArea.java
deleted file mode 100644
index 3c4db5c..0000000
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/figures/ColoredArea.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * <copyright>
- *
- * Copyright (c) 2005, 2010 SAP AG.
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API, implementation and documentation
- *
- * </copyright>
- *
- *******************************************************************************/
-package org.eclipse.graphiti.ui.internal.figures;
-
-/**
- * This class is used to combine a start colored-location and an end
- * colored-location. It can be used to draw a color-gradient from the
- * start-location to the end-location (see
- * {@link GFFigureUtil#paintColorFlow(org.eclipse.draw2d.geometry.Rectangle, org.eclipse.draw2d.Graphics, ColoredArea, double, boolean)}
- * ).
- *
- * @noinstantiate This class is not intended to be instantiated by clients.
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class ColoredArea {
-
- /**
- * The start colored-location set in the constructor.
- */
- private ColoredLocation start;
-
- /**
- * The end colored-location set in the constructor.
- */
- private ColoredLocation end;
-
- /**
- * Creates a new ColoredArea.
- *
- * @param start
- * The start colored-location.
- * @param end
- * The end colored-location.
- */
- public ColoredArea(ColoredLocation start, ColoredLocation end) {
- this.start = start;
- this.end = end;
- }
-
- /**
- * Returns the start colored-location.
- *
- * @return The start colored-location.
- */
- public ColoredLocation getStart() {
- return start;
- }
-
- /**
- * Returns the end colored-location.
- *
- * @return The end colored-location.
- */
- public ColoredLocation getEnd() {
- return end;
- }
-
- /**
- * Returns colored-areas, which are calculated from the given
- * colored-locations. The idea is, that the end color-location and the
- * following start color-location are identical, which gives the impression
- * of a seemless color-gradient.
- *
- * @param location
- * The colored-locations, from which to calculate the
- * colored-areas.
- * @return colored-areas, which are calculated from the given
- * colored-locations.
- */
- public static ColoredArea[] getSeemlessArea(ColoredLocation location[]) {
- if (location.length <= 1) {
- return new ColoredArea[0];
- }
-
- ColoredArea ret[] = new ColoredArea[location.length - 1];
- for (int i = 0; i < ret.length; i++) {
- ret[i] = new ColoredArea(location[i], location[i + 1]);
- }
- return ret;
- }
-}
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/figures/GFAbstractShape.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/figures/GFAbstractShape.java
index 8efeaf6..00c6dce 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/figures/GFAbstractShape.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/figures/GFAbstractShape.java
@@ -15,6 +15,8 @@
*******************************************************************************/
package org.eclipse.graphiti.ui.internal.figures;
+import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.draw2d.Figure;
@@ -22,9 +24,13 @@
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Shape;
import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.gef.handles.HandleBounds;
import org.eclipse.graphiti.internal.pref.GFPreferences;
import org.eclipse.graphiti.internal.services.GraphitiInternal;
+import org.eclipse.graphiti.mm.pictograms.AdaptedGradientColoredAreas;
+import org.eclipse.graphiti.mm.pictograms.GradientColoredArea;
+import org.eclipse.graphiti.mm.pictograms.GradientColoredAreas;
import org.eclipse.graphiti.mm.pictograms.GraphicsAlgorithm;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.RenderingStyle;
@@ -40,6 +46,7 @@
import org.eclipse.graphiti.ui.internal.util.DataTypeTransformation;
import org.eclipse.graphiti.ui.internal.util.draw2d.GFColorConstants;
import org.eclipse.graphiti.util.IColorConstant;
+import org.eclipse.graphiti.util.IPredefinedRenderingStyle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Path;
@@ -314,13 +321,17 @@
if (renderingStyle != null) {
graphics.pushState();
try {
+ //do not use getZoomLevel(), which returns wrong scales
Rectangle pathBounds = GFFigureUtil.getPathBounds(path);
graphics.clipPath(path);
int styleAdaptation = getStyleAdaptation();
- String coloredAreaId = renderingStyle.getPredefinedStyleId();
- ColoredArea coloredArea[] = PredefinedColoredAreas.getColoredAreas(coloredAreaId, styleAdaptation);
- for (int i = 0; i < coloredArea.length; i++) {
- GFFigureUtil.paintColorFlow(pathBounds, graphics, coloredArea[i], getZoomLevel(graphics), true);
+ AdaptedGradientColoredAreas adaptedGradientColoredAreas = renderingStyle.getAdaptedGradientColoredAreas();
+ EList<GradientColoredAreas> gradientColoredAreas = (EList<GradientColoredAreas>) adaptedGradientColoredAreas.getAdaptedGradientColoredAreas();
+ EList<GradientColoredArea> gradienColoredAreaList = gradientColoredAreas.get(styleAdaptation).getGradientColor();
+
+ for (Iterator<GradientColoredArea> iterator = gradienColoredAreaList.iterator(); iterator.hasNext();) {
+ GradientColoredArea gradientColoredArea = (GradientColoredArea) iterator.next();
+ GFFigureUtil.paintColorFlow(getConfigurationProvider(), pathBounds, graphics, gradientColoredArea, getZoomLevel(graphics), true);
}
} finally {
graphics.popState();
@@ -331,7 +342,7 @@
}
}
}
-
+
private void setBackgroundWithoutStyle(Graphics graphics, Path path) {
// set background color depending on visual state
Color oldBackground = graphics.getBackgroundColor();
@@ -361,31 +372,31 @@
}
private int getStyleAdaptation() {
- int styleAdaptation = PredefinedColoredAreas.STYLE_ADAPTATION_DEFAULT;
+ int styleAdaptation = IPredefinedRenderingStyle.STYLE_ADAPTATION_DEFAULT;
if (getPreferences().getVisualStateRendering() == 1) {
- styleAdaptation = PredefinedColoredAreas.STYLE_ADAPTATION_DEFAULT;
+ styleAdaptation = IPredefinedRenderingStyle.STYLE_ADAPTATION_DEFAULT;
int selectionFeedback = getVisualState().getSelectionFeedback();
if (selectionFeedback == IVisualState.SELECTION_PRIMARY)
- styleAdaptation = PredefinedColoredAreas.STYLE_ADAPTATION_PRIMARY_SELECTED;
+ styleAdaptation = IPredefinedRenderingStyle.STYLE_ADAPTATION_PRIMARY_SELECTED;
else if (selectionFeedback == IVisualState.SELECTION_SECONDARY)
- styleAdaptation = PredefinedColoredAreas.STYLE_ADAPTATION_SECONDARY_SELECTED;
+ styleAdaptation = IPredefinedRenderingStyle.STYLE_ADAPTATION_SECONDARY_SELECTED;
int actionTargetFeedback = getVisualState().getActionTargetFeedback();
if (actionTargetFeedback == IVisualState.ACTION_TARGET_ALLOWED)
- styleAdaptation = PredefinedColoredAreas.STYLE_ADAPTATION_ACTION_ALLOWED;
+ styleAdaptation = IPredefinedRenderingStyle.STYLE_ADAPTATION_ACTION_ALLOWED;
else if (actionTargetFeedback == IVisualState.ACTION_TARGET_FORBIDDEN)
- styleAdaptation = PredefinedColoredAreas.STYLE_ADAPTATION_ACTION_FORBIDDEN;
+ styleAdaptation = IPredefinedRenderingStyle.STYLE_ADAPTATION_ACTION_FORBIDDEN;
} else {
- styleAdaptation = PredefinedColoredAreas.STYLE_ADAPTATION_DEFAULT;
+ styleAdaptation = IPredefinedRenderingStyle.STYLE_ADAPTATION_DEFAULT;
int selectionFeedback = getVisualState().getSelectionFeedback();
if (selectionFeedback == IVisualState.SELECTION_PRIMARY)
- styleAdaptation = PredefinedColoredAreas.STYLE_ADAPTATION_PRIMARY_SELECTED;
+ styleAdaptation = IPredefinedRenderingStyle.STYLE_ADAPTATION_PRIMARY_SELECTED;
else if (selectionFeedback == IVisualState.SELECTION_SECONDARY)
- styleAdaptation = PredefinedColoredAreas.STYLE_ADAPTATION_SECONDARY_SELECTED;
+ styleAdaptation = IPredefinedRenderingStyle.STYLE_ADAPTATION_SECONDARY_SELECTED;
int actionTargetFeedback = getVisualState().getActionTargetFeedback();
if (actionTargetFeedback == IVisualState.ACTION_TARGET_ALLOWED)
- styleAdaptation = PredefinedColoredAreas.STYLE_ADAPTATION_SECONDARY_SELECTED;
+ styleAdaptation = IPredefinedRenderingStyle.STYLE_ADAPTATION_SECONDARY_SELECTED;
}
return styleAdaptation;
}
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/figures/GFFigureUtil.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/figures/GFFigureUtil.java
index d327cb7..435550e 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/figures/GFFigureUtil.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/figures/GFFigureUtil.java
@@ -24,11 +24,12 @@
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.Ray;
import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
+import org.eclipse.graphiti.mm.pictograms.GradientColoredArea;
+import org.eclipse.graphiti.ui.PredefinedColoredAreas;
+import org.eclipse.graphiti.ui.internal.config.IConfigurationProvider;
+import org.eclipse.graphiti.ui.internal.util.DataTypeTransformation;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Path;
-import org.eclipse.swt.graphics.Pattern;
-import org.eclipse.swt.widgets.Display;
/**
* A utility class containing static helper-methods for GFW figures.
@@ -65,22 +66,26 @@
* @param vertical
* If true, fills the area vertically, otherwise horizontally
*/
- public static void paintColorFlow(Rectangle rectangle, Graphics graphics, ColoredArea coloredArea, double zoom, boolean vertical) {
+ public static void paintColorFlow(IConfigurationProvider configurationProvider, Rectangle rectangle, Graphics graphics, GradientColoredArea coloredArea, double zoom, boolean vertical) {
// calculate rectangle to fill
Rectangle fillRectangle;
if (vertical) {
- int start = coloredArea.getStart().getLocation(rectangle.height, zoom);
- int end = coloredArea.getEnd().getLocation(rectangle.height, zoom);
+ int start = PredefinedColoredAreas.getLocation(coloredArea.getStart(), rectangle.height, zoom);
+ int end = PredefinedColoredAreas.getLocation(coloredArea.getEnd(), rectangle.height, zoom);
fillRectangle = new Rectangle(rectangle.x, rectangle.y + start, rectangle.width, end - start);
} else {
- int start = coloredArea.getStart().getLocation(rectangle.width, zoom);
- int end = coloredArea.getEnd().getLocation(rectangle.width, zoom);
+ int start = PredefinedColoredAreas.getLocation(coloredArea.getStart(), rectangle.width, zoom);
+ int end = PredefinedColoredAreas.getLocation(coloredArea.getEnd(), rectangle.width, zoom);
fillRectangle = new Rectangle(rectangle.x + start, rectangle.y, end - start, rectangle.height);
}
-
// fill rectangle
- graphics.setForegroundColor(coloredArea.getStart().getColor());
- graphics.setBackgroundColor(coloredArea.getEnd().getColor());
+ org.eclipse.graphiti.mm.datatypes.Color foregroundColor = coloredArea.getStart().getColor();
+ Color foregroundColorSWT = DataTypeTransformation.toSwtColor(configurationProvider, foregroundColor);
+ org.eclipse.graphiti.mm.datatypes.Color backgroundColor = coloredArea.getEnd().getColor();
+ Color backgroundColorSWT = DataTypeTransformation.toSwtColor(configurationProvider, backgroundColor);
+
+ graphics.setForegroundColor(foregroundColorSWT);
+ graphics.setBackgroundColor(backgroundColorSWT);
graphics.fillGradient(fillRectangle.x, fillRectangle.y, fillRectangle.width, fillRectangle.height, vertical);
}
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/figures/PredefinedColoredAreas.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/figures/PredefinedColoredAreas.java
deleted file mode 100644
index 10e7137..0000000
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/figures/PredefinedColoredAreas.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*******************************************************************************
- * <copyright>
- *
- * Copyright (c) 2005, 2010 SAP AG.
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API, implementation and documentation
- *
- * </copyright>
- *
- *******************************************************************************/
-package org.eclipse.graphiti.ui.internal.figures;
-
-import org.eclipse.graphiti.util.IPredefinedRenderingStyle;
-
-/**
- * Predefined colored areas to be used in
- * {@link GFFigureUtil#paintColorFlow(Rectangle, Graphics, ColoredArea, boolean)}
- * .
- *
- * @noinstantiate This class is not intended to be instantiated by clients.
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class PredefinedColoredAreas implements IPredefinedRenderingStyle {
-
- /**
- * The style-adaptation to use for default elements.
- */
- public static final int STYLE_ADAPTATION_DEFAULT = 0;
-
- /**
- * The style-adaptation to use for primary selected elements.
- */
- public static final int STYLE_ADAPTATION_PRIMARY_SELECTED = 1;
-
- /**
- * The style-adaptation to use for secondary selected elements.
- */
- public static final int STYLE_ADAPTATION_SECONDARY_SELECTED = 2;
-
- /**
- * The style-adaptation to use to indicate that an action is allowed.
- */
- public static final int STYLE_ADAPTATION_ACTION_ALLOWED = 3;
-
- /**
- * The style-adaptation to use to indicate that an action is forbidden.
- */
- public static final int STYLE_ADAPTATION_ACTION_FORBIDDEN = 4;
-
- // just added to this class for easier access
- private static final int LOCATION_TYPE_ABSOLUTE_START = ColoredLocation.LOCATION_TYPE_ABSOLUTE_START;
-
- // just added to this class for easier access
- private static final int LOCATION_TYPE_ABSOLUTE_END = ColoredLocation.LOCATION_TYPE_ABSOLUTE_END;
-
- /**
- * The color-areas, which are used for default elements with the ID
- * {@link #BLUE_WHITE_GLOSS_ID}.
- */
- private static final ColoredArea[] BLUE_WHITE_GLOSS_DEFAULT_AREAS = new ColoredArea[] {
- getColoredArea("F8FBFE", 0, LOCATION_TYPE_ABSOLUTE_START, "F8FBFE", 1, LOCATION_TYPE_ABSOLUTE_START), //$NON-NLS-1$ //$NON-NLS-2$
- getColoredArea("EDF5FC", 1, LOCATION_TYPE_ABSOLUTE_START, "EDF5FC", 2, LOCATION_TYPE_ABSOLUTE_START), //$NON-NLS-1$ //$NON-NLS-2$
- getColoredArea("DEEDFA", 2, LOCATION_TYPE_ABSOLUTE_START, "DEEDFA", 3, LOCATION_TYPE_ABSOLUTE_START), //$NON-NLS-1$ //$NON-NLS-2$
- getColoredArea("D4E7F8", 3, LOCATION_TYPE_ABSOLUTE_START, "FAFBFC", 2, LOCATION_TYPE_ABSOLUTE_END), //$NON-NLS-1$ //$NON-NLS-2$
- getColoredArea("E2E5E9", 2, LOCATION_TYPE_ABSOLUTE_END, "E2E5E9", 0, LOCATION_TYPE_ABSOLUTE_END), }; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * The color-areas, which are used for primary selected elements with the ID
- * {@link #BLUE_WHITE_GLOSS_ID}.
- */
- private static final ColoredArea[] BLUE_WHITE_GLOSS_PRIMARY_SELECTED_AREAS = new ColoredArea[] {
- getColoredArea("EEF6FD", 0, LOCATION_TYPE_ABSOLUTE_START, "EEF6FD", 1, LOCATION_TYPE_ABSOLUTE_START), //$NON-NLS-1$ //$NON-NLS-2$
- getColoredArea("D0E6F9", 1, LOCATION_TYPE_ABSOLUTE_START, "D0E6F9", 2, LOCATION_TYPE_ABSOLUTE_START), //$NON-NLS-1$ //$NON-NLS-2$
- getColoredArea("ACD2F4", 2, LOCATION_TYPE_ABSOLUTE_START, "ACD2F4", 3, LOCATION_TYPE_ABSOLUTE_START), //$NON-NLS-1$ //$NON-NLS-2$
- getColoredArea("81B9EA", 3, LOCATION_TYPE_ABSOLUTE_START, "AAD0F2", 2, LOCATION_TYPE_ABSOLUTE_END), //$NON-NLS-1$ //$NON-NLS-2$
- getColoredArea("9ABFE0", 2, LOCATION_TYPE_ABSOLUTE_END, "9ABFE0", 0, LOCATION_TYPE_ABSOLUTE_END), }; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * The color-areas, which are used for secondary selected elements with the
- * ID {@link #BLUE_WHITE_GLOSS_ID}.
- */
- private static final ColoredArea[] BLUE_WHITE_GLOSS_SECONDARY_SELECTED_AREAS = new ColoredArea[] {
- getColoredArea("F5F9FE", 0, LOCATION_TYPE_ABSOLUTE_START, "F5F9FE", 1, LOCATION_TYPE_ABSOLUTE_START), //$NON-NLS-1$ //$NON-NLS-2$
- getColoredArea("E2EFFC", 1, LOCATION_TYPE_ABSOLUTE_START, "E2EFFC", 2, LOCATION_TYPE_ABSOLUTE_START), //$NON-NLS-1$ //$NON-NLS-2$
- getColoredArea("CBE3F9", 2, LOCATION_TYPE_ABSOLUTE_START, "CBE3F9", 3, LOCATION_TYPE_ABSOLUTE_START), //$NON-NLS-1$ //$NON-NLS-2$
- getColoredArea("BBDAF7", 3, LOCATION_TYPE_ABSOLUTE_START, "C5E0F7", 2, LOCATION_TYPE_ABSOLUTE_END), //$NON-NLS-1$ //$NON-NLS-2$
- getColoredArea("B2CDE5", 2, LOCATION_TYPE_ABSOLUTE_END, "B2CDE5", 0, LOCATION_TYPE_ABSOLUTE_END), }; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * The color-areas, which are used for elements where an action is allowed
- * with the ID {@link #BLUE_WHITE_GLOSS_ID}.
- */
- private static final ColoredArea[] BLUE_WHITE_GLOSS_ACTION_ALLOWED_AREAS = new ColoredArea[] { //
- getColoredArea("99CC00", 0, LOCATION_TYPE_ABSOLUTE_START, "339966", 0, LOCATION_TYPE_ABSOLUTE_END), }; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * The color-areas, which are used for elements where an action is forbidden
- * with the ID {@link #BLUE_WHITE_GLOSS_ID}.
- */
- private static final ColoredArea[] BLUE_WHITE_GLOSS_ACTION_FORBIDDEN_AREAS = new ColoredArea[] { //
- getColoredArea("FFCC00", 0, LOCATION_TYPE_ABSOLUTE_START, "FF6600", 0, LOCATION_TYPE_ABSOLUTE_END), }; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * The color-areas, which are used for default elements with the ID
- * {@link #BLUE_WHITE_ID}.
- */
- private static final ColoredArea[] BLUE_WHITE_DEFAULT_AREAS = new ColoredArea[] { //
- getColoredArea("D4E7F8", 0, LOCATION_TYPE_ABSOLUTE_START, "FAFBFC", 0, LOCATION_TYPE_ABSOLUTE_END), }; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * The color-areas, which are used for primary selected elements with the ID
- * {@link #BLUE_WHITE_ID}.
- */
- private static final ColoredArea[] BLUE_WHITE_PRIMARY_SELECTED_AREAS = new ColoredArea[] { //
- getColoredArea("81B9EA", 0, LOCATION_TYPE_ABSOLUTE_START, "AAD0F2", 0, LOCATION_TYPE_ABSOLUTE_END), }; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * The color-areas, which are used for secondary selected elements with the
- * ID {@link #BLUE_WHITE_ID}.
- */
- private static final ColoredArea[] BLUE_WHITE_SECONDARY_SELECTED_AREAS = new ColoredArea[] { //
- getColoredArea("BBDAF7", 0, LOCATION_TYPE_ABSOLUTE_START, "C5E0F7", 0, LOCATION_TYPE_ABSOLUTE_END) }; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * The color-areas, which are used for default elements with the ID
- * {@link #LIGHT_YELLOW_ID}.
- */
- private static final ColoredArea[] LIGHT_YELLOW_DEFAULT_AREAS = new ColoredArea[] { //
- getColoredArea("FEFEF4", 0, LOCATION_TYPE_ABSOLUTE_START, "FEFEF4", 0, LOCATION_TYPE_ABSOLUTE_END), }; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * The color-areas, which are used for primary selected elements with the ID
- * {@link #LIGHT_YELLOW_ID}.
- */
- private static final ColoredArea[] LIGHT_YELLOW_PRIMARY_SELECTED_AREAS = new ColoredArea[] { //
- getColoredArea("E5E5C2", 0, LOCATION_TYPE_ABSOLUTE_START, "E5E5C2", 0, LOCATION_TYPE_ABSOLUTE_END), }; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * The color-areas, which are used for secondary selected elements with the
- * ID {@link #LIGHT_YELLOW_ID}.
- */
- private static final ColoredArea[] LIGHT_YELLOW_SECONDARY_SELECTED_AREAS = new ColoredArea[] { //
- getColoredArea("FAFAD9", 0, LOCATION_TYPE_ABSOLUTE_START, "FAFAD9", 0, LOCATION_TYPE_ABSOLUTE_END) }; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * The color-areas, which are used for default elements with the ID
- * {@link #LIGHT_GRAY_ID}.
- */
- private static final ColoredArea[] LIGHT_GRAY_DEFAULT_AREAS = new ColoredArea[] { //
- getColoredArea("F5F5ED", 0, LOCATION_TYPE_ABSOLUTE_START, "F5F5ED", 0, LOCATION_TYPE_ABSOLUTE_END), }; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * The color-areas, which are used for primary selected elements with the ID
- * {@link #LIGHT_GRAY_ID}.
- */
- private static final ColoredArea[] LIGHT_GRAY_PRIMARY_SELECTED_AREAS = new ColoredArea[] { //
- getColoredArea("D6D6D0", 0, LOCATION_TYPE_ABSOLUTE_START, "D6D6D0", 0, LOCATION_TYPE_ABSOLUTE_END), }; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * The color-areas, which are used for secondary selected elements with the
- * ID {@link #LIGHT_GRAY_ID}.
- */
- private static final ColoredArea[] LIGHT_GRAY_SECONDARY_SELECTED_AREAS = new ColoredArea[] { //
- getColoredArea("E5E5Df", 0, LOCATION_TYPE_ABSOLUTE_START, "E5E5Df", 0, LOCATION_TYPE_ABSOLUTE_END) }; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * The color-areas, which are used for default elements with the ID
- * {@link #COPPER_WHITE_GLOSS_ID}.
- */
- private static final ColoredArea[] COPPER_WHITE_GLOSS_DEFAULT_AREAS = new ColoredArea[] {
- getColoredArea("F9F5F2", 0, LOCATION_TYPE_ABSOLUTE_START, "F9F5F2", 1, LOCATION_TYPE_ABSOLUTE_START), //$NON-NLS-1$ //$NON-NLS-2$
- getColoredArea("EDE0D8", 1, LOCATION_TYPE_ABSOLUTE_START, "EDE0D8", 2, LOCATION_TYPE_ABSOLUTE_START), //$NON-NLS-1$ //$NON-NLS-2$
- getColoredArea("E4D0C4", 2, LOCATION_TYPE_ABSOLUTE_START, "F5F0E8", 2, LOCATION_TYPE_ABSOLUTE_END), //$NON-NLS-1$ //$NON-NLS-2$
- getColoredArea("E6DDD0", 2, LOCATION_TYPE_ABSOLUTE_END, "E6DDD0", 0, LOCATION_TYPE_ABSOLUTE_END), }; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * The color-areas, which are used for default elements with the ID
- * {@link #SILVER_WHITE_GLOSS_ID}.
- */
- private static final ColoredArea[] SILVER_WHITE_GLOSS_DEFAULT_AREAS = new ColoredArea[] {
- getColoredArea("EEEEED", 0, LOCATION_TYPE_ABSOLUTE_START, "EEEEED", 1, LOCATION_TYPE_ABSOLUTE_START), //$NON-NLS-1$ //$NON-NLS-2$
- getColoredArea("E1E1E0", 1, LOCATION_TYPE_ABSOLUTE_START, "E1E1E0", 2, LOCATION_TYPE_ABSOLUTE_START), //$NON-NLS-1$ //$NON-NLS-2$
- getColoredArea("D2D1CF", 2, LOCATION_TYPE_ABSOLUTE_START, "F2F0EF", 2, LOCATION_TYPE_ABSOLUTE_END), //$NON-NLS-1$ //$NON-NLS-2$
- getColoredArea("DFDEDD", 2, LOCATION_TYPE_ABSOLUTE_END, "DFDEDD", 0, LOCATION_TYPE_ABSOLUTE_END), }; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * Returns the color-areas for the given ID. The ID must be one of those
- * defined in this class.
- *
- * @param id
- * The ID for which to return the color-areas.
- * @return The color-areas for the given ID.
- */
- public static ColoredArea[] getColoredAreas(String id, int styleAdaptation) {
- // default, needed for backward compatibility, because in old models the
- // id is null
- if (id == null) {
- id = BLUE_WHITE_GLOSS_ID;
- }
-
- if (BLUE_WHITE_GLOSS_ID.equals(id)) {
- if (styleAdaptation == STYLE_ADAPTATION_PRIMARY_SELECTED)
- return BLUE_WHITE_GLOSS_PRIMARY_SELECTED_AREAS;
- if (styleAdaptation == STYLE_ADAPTATION_SECONDARY_SELECTED)
- return BLUE_WHITE_GLOSS_SECONDARY_SELECTED_AREAS;
- if (styleAdaptation == STYLE_ADAPTATION_ACTION_ALLOWED)
- return BLUE_WHITE_GLOSS_ACTION_ALLOWED_AREAS;
- if (styleAdaptation == STYLE_ADAPTATION_ACTION_FORBIDDEN)
- return BLUE_WHITE_GLOSS_ACTION_FORBIDDEN_AREAS;
- return BLUE_WHITE_GLOSS_DEFAULT_AREAS;
- }
- if (BLUE_WHITE_ID.equals(id)) {
- if (styleAdaptation == STYLE_ADAPTATION_PRIMARY_SELECTED)
- return BLUE_WHITE_PRIMARY_SELECTED_AREAS;
- if (styleAdaptation == STYLE_ADAPTATION_SECONDARY_SELECTED)
- return BLUE_WHITE_SECONDARY_SELECTED_AREAS;
- return BLUE_WHITE_DEFAULT_AREAS;
- }
- if (LIGHT_YELLOW_ID.equals(id)) {
- if (styleAdaptation == STYLE_ADAPTATION_PRIMARY_SELECTED)
- return LIGHT_YELLOW_PRIMARY_SELECTED_AREAS;
- if (styleAdaptation == STYLE_ADAPTATION_SECONDARY_SELECTED)
- return LIGHT_YELLOW_SECONDARY_SELECTED_AREAS;
- return LIGHT_YELLOW_DEFAULT_AREAS;
- }
- if (LIGHT_GRAY_ID.equals(id)) {
- if (styleAdaptation == STYLE_ADAPTATION_PRIMARY_SELECTED)
- return LIGHT_GRAY_PRIMARY_SELECTED_AREAS;
- if (styleAdaptation == STYLE_ADAPTATION_SECONDARY_SELECTED)
- return LIGHT_GRAY_SECONDARY_SELECTED_AREAS;
- return LIGHT_GRAY_DEFAULT_AREAS;
- }
- if (COPPER_WHITE_GLOSS_ID.equals(id)) {
- return COPPER_WHITE_GLOSS_DEFAULT_AREAS;
- }
- if (SILVER_WHITE_GLOSS_ID.equals(id)) {
- return SILVER_WHITE_GLOSS_DEFAULT_AREAS;
- }
- throw new IllegalArgumentException("Unsupported ID '" + id + "'"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Returns a new colored-area for the given parameters. Have a look at
- * {@link ColoredLocation} for a further explanation of the parameters.
- *
- * @return A new colored-area for the given parameters.
- */
- private static ColoredArea getColoredArea(String startColor, int startLocation, int startType, String endColor, int endLocation,
- int endType) {
- ColoredLocation startColoredLocation = new ColoredLocation(startColor, startLocation, startType);
- ColoredLocation endColoredLocation = new ColoredLocation(endColor, endLocation, endType);
- return new ColoredArea(startColoredLocation, endColoredLocation);
- }
-}