diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/actions/LineColorAction.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/actions/LineColorAction.java
index 1d52b4466..e42886611 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/actions/LineColorAction.java
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/actions/LineColorAction.java
@@ -14,9 +14,7 @@
import org.eclipse.swt.graphics.RGB;
import org.eclipse.ui.IWorkbenchPart;
-import com.archimatetool.editor.ArchiPlugin;
import com.archimatetool.editor.diagram.commands.LineColorCommand;
-import com.archimatetool.editor.preferences.IPreferenceConstants;
import com.archimatetool.editor.ui.ColorFactory;
import com.archimatetool.editor.ui.components.CustomColorDialog;
import com.archimatetool.editor.ui.factory.IObjectUIProvider;
@@ -117,9 +115,9 @@ private boolean shouldEnable(Object model) {
return false;
}
- if(model instanceof IDiagramModelObject) {
+ if(model instanceof IDiagramModelObject dmo) {
// Disable if diagram model object line colours are derived from fill colours as set in Prefs
- if(ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.DERIVE_ELEMENT_LINE_COLOR)) {
+ if(dmo.getDeriveElementLineColor()) {
return false;
}
}
diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/editparts/AbstractBaseEditPart.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/editparts/AbstractBaseEditPart.java
index d9c1253b6..02b99a1f9 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/editparts/AbstractBaseEditPart.java
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/editparts/AbstractBaseEditPart.java
@@ -79,8 +79,7 @@ protected void applicationPreferencesChanged(PropertyChangeEvent event) {
// Default font or colour preferences changed
if(IPreferenceConstants.DEFAULT_VIEW_FONT.equals(event.getProperty()) ||
event.getProperty().startsWith(IPreferenceConstants.DEFAULT_FILL_COLOR_PREFIX) ||
- event.getProperty().equals(IPreferenceConstants.DEFAULT_ELEMENT_LINE_COLOR) ||
- event.getProperty().startsWith(IPreferenceConstants.DERIVE_ELEMENT_LINE_COLOR)) {
+ event.getProperty().equals(IPreferenceConstants.DEFAULT_ELEMENT_LINE_COLOR)) {
refreshFigure();
}
diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/AbstractDiagramModelObjectFigure.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/AbstractDiagramModelObjectFigure.java
index f64b5458d..1277f7f37 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/AbstractDiagramModelObjectFigure.java
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/AbstractDiagramModelObjectFigure.java
@@ -229,9 +229,8 @@ protected void setLineColor() {
public Color getLineColor() {
if(fLineColor == null) {
// User preference to derive element line colour
- if(ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.DERIVE_ELEMENT_LINE_COLOR)) {
- fLineColor = ColorFactory.getDarkerColor(getFillColor(),
- ArchiPlugin.PREFERENCES.getInt(IPreferenceConstants.DERIVE_ELEMENT_LINE_COLOR_FACTOR) / 10f);
+ if(fDiagramModelObject.getDeriveElementLineColor()) {
+ fLineColor = ColorFactory.getDerivedLineColor(getFillColor());
}
else {
fLineColor = ColorFactory.get(fDiagramModelObject.getLineColor());
diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/sketch/SketchModelFactory.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/sketch/SketchModelFactory.java
index 41941ab63..3b0adf591 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/sketch/SketchModelFactory.java
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/sketch/SketchModelFactory.java
@@ -64,20 +64,22 @@ public Object getNewObject() {
EObject object = IArchimateFactory.eINSTANCE.create(fTemplate);
// Actor
- if(object instanceof ISketchModelActor) {
- ((ISketchModelActor)object).setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
+ if(object instanceof ISketchModelActor actor) {
+ actor.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
}
// Sticky
- else if(object instanceof ISketchModelSticky) {
- ISketchModelSticky sticky = (ISketchModelSticky)object;
+ else if(object instanceof ISketchModelSticky sticky) {
sticky.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
+ // Derive element line color
+ sticky.setDeriveElementLineColor(ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.DERIVE_ELEMENT_LINE_COLOR));
+
// Gradient
sticky.setGradient(ArchiPlugin.PREFERENCES.getInt(IPreferenceConstants.DEFAULT_GRADIENT));
- if(fParam instanceof RGB) {
- String color = ColorFactory.convertRGBToString((RGB)fParam);
+ if(fParam instanceof RGB rgb) {
+ String color = ColorFactory.convertRGBToString(rgb);
sticky.setFillColor(color);
Color lineColor = ColorFactory.getDefaultLineColor(sticky);
@@ -88,8 +90,7 @@ else if(object instanceof ISketchModelSticky) {
}
// Group
- else if(object instanceof IDiagramModelGroup) {
- IDiagramModelGroup group = (IDiagramModelGroup)object;
+ else if(object instanceof IDiagramModelGroup group) {
group.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
ColorFactory.setDefaultColors(group);
// Gradient
@@ -97,11 +98,9 @@ else if(object instanceof IDiagramModelGroup) {
}
// Connection
- else if(object instanceof IDiagramModelConnection) {
- IDiagramModelConnection connection = (IDiagramModelConnection)object;
-
- if(fParam instanceof Integer) {
- connection.setType((Integer)fParam);
+ else if(object instanceof IDiagramModelConnection connection) {
+ if(fParam instanceof Integer i) {
+ connection.setType(i);
}
ColorFactory.setDefaultColors(connection);
@@ -109,18 +108,18 @@ else if(object instanceof IDiagramModelConnection) {
IGraphicalObjectUIProvider provider = (IGraphicalObjectUIProvider)ObjectUIFactory.INSTANCE.getProvider(object);
- if(object instanceof ITextAlignment) {
- ((ITextAlignment)object).setTextAlignment(provider.getDefaultTextAlignment());
+ if(object instanceof ITextAlignment ta) {
+ ta.setTextAlignment(provider.getDefaultTextAlignment());
}
- if(object instanceof ITextPosition) {
- ((ITextPosition)object).setTextPosition(provider.getDefaultTextPosition());
+ if(object instanceof ITextPosition tp) {
+ tp.setTextPosition(provider.getDefaultTextPosition());
}
// Add new bounds with a default user size
- if(object instanceof IDiagramModelObject) {
+ if(object instanceof IDiagramModelObject dmo) {
Dimension size = provider.getDefaultSize();
- ((IDiagramModelObject)object).setBounds(0, 0, size.width, size.height);
+ dmo.setBounds(0, 0, size.width, size.height);
}
return object;
diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/preferences/ColoursPreferencePage.java b/com.archimatetool.editor/src/com/archimatetool/editor/preferences/ColoursPreferencePage.java
index 33086e56d..9dc862ae4 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/preferences/ColoursPreferencePage.java
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/preferences/ColoursPreferencePage.java
@@ -40,9 +40,7 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;
@@ -87,14 +85,9 @@ public class ColoursPreferencePage
private Button fResetFillColorButton;
private Button fDeriveElementLineColorsButton;
- // Spinner
- private Spinner fElementLineColorContrastSpinner;
-
// Tree
private TreeViewer fTreeViewer;
- private Label fContrastFactorLabel;
-
private IPropertyChangeListener themeChangeListener;
private static List themeColors = List.of(VIEW_BACKGROUND_COLOR,
@@ -381,37 +374,14 @@ public void widgetSelected(SelectionEvent e) {
}
});
- Group elementColorGroup = new Group(client, SWT.NULL);
- elementColorGroup.setLayout(new GridLayout(2, false));
- elementColorGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- elementColorGroup.setText(Messages.ColoursPreferencePage_17);
-
// Derive element line colours
- fDeriveElementLineColorsButton = new Button(elementColorGroup, SWT.CHECK);
+ fDeriveElementLineColorsButton = new Button(client, SWT.CHECK);
fDeriveElementLineColorsButton.setText(Messages.ColoursPreferencePage_18);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
fDeriveElementLineColorsButton.setLayoutData(gd);
fDeriveElementLineColorsButton.setSelection(getPreferenceStore().getBoolean(DERIVE_ELEMENT_LINE_COLOR));
- fDeriveElementLineColorsButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- fElementLineColorContrastSpinner.setEnabled(fDeriveElementLineColorsButton.getSelection());
- fContrastFactorLabel.setEnabled(fDeriveElementLineColorsButton.getSelection());
- }
- });
-
- fContrastFactorLabel = new Label(elementColorGroup, SWT.NULL);
- fContrastFactorLabel.setText(Messages.ColoursPreferencePage_19);
-
- fElementLineColorContrastSpinner = new Spinner(elementColorGroup, SWT.BORDER);
- fElementLineColorContrastSpinner.setMinimum(1);
- fElementLineColorContrastSpinner.setMaximum(10);
- fElementLineColorContrastSpinner.setSelection(getPreferenceStore().getInt(DERIVE_ELEMENT_LINE_COLOR_FACTOR));
- label = new Label(elementColorGroup, SWT.NULL);
- label.setText(Messages.ColoursPreferencePage_20);
-
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
@@ -585,7 +555,6 @@ private void resetColorsCache(boolean useInbuiltDefaults) {
@Override
public boolean performOk() {
getPreferenceStore().setValue(DERIVE_ELEMENT_LINE_COLOR, fDeriveElementLineColorsButton.getSelection());
- getPreferenceStore().setValue(DERIVE_ELEMENT_LINE_COLOR_FACTOR, fElementLineColorContrastSpinner.getSelection());
getPreferenceStore().setValue(SAVE_USER_DEFAULT_COLOR, fPersistUserDefaultColors.getSelection());
saveColors(getPreferenceStore(), true);
@@ -599,8 +568,6 @@ protected void performDefaults() {
fDeriveElementLineColorsButton.setSelection(getPreferenceStore().getDefaultBoolean(DERIVE_ELEMENT_LINE_COLOR));
fPersistUserDefaultColors.setSelection(getPreferenceStore().getDefaultBoolean(SAVE_USER_DEFAULT_COLOR));
- fElementLineColorContrastSpinner.setSelection(getPreferenceStore().getDefaultInt(DERIVE_ELEMENT_LINE_COLOR_FACTOR));
-
// Set color cache to inbuilt defaults
resetColorsCache(true);
diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/preferences/IPreferenceConstants.java b/com.archimatetool.editor/src/com/archimatetool/editor/preferences/IPreferenceConstants.java
index cb9907c50..61ea97748 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/preferences/IPreferenceConstants.java
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/preferences/IPreferenceConstants.java
@@ -30,7 +30,6 @@ public interface IPreferenceConstants {
String FOLDER_COLOUR_PREFIX = "folderColour_";
String DERIVE_ELEMENT_LINE_COLOR = "deriveElementLineColor";
- String DERIVE_ELEMENT_LINE_COLOR_FACTOR = "deriveElementLineColorFactor";
String SAVE_USER_DEFAULT_COLOR = "saveUserDefaultFillColorInFile";
// Theme Color Definition IDs
diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/preferences/Messages.java b/com.archimatetool.editor/src/com/archimatetool/editor/preferences/Messages.java
index bcc2abcac..b0aed305a 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/preferences/Messages.java
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/preferences/Messages.java
@@ -39,16 +39,10 @@ public class Messages extends NLS {
public static String ColoursPreferencePage_16;
- public static String ColoursPreferencePage_17;
-
public static String ColoursPreferencePage_18;
- public static String ColoursPreferencePage_19;
-
public static String ColoursPreferencePage_2;
- public static String ColoursPreferencePage_20;
-
public static String ColoursPreferencePage_21;
public static String ColoursPreferencePage_22;
diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/preferences/PreferenceInitializer.java b/com.archimatetool.editor/src/com/archimatetool/editor/preferences/PreferenceInitializer.java
index d19f30c97..990e72c99 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/preferences/PreferenceInitializer.java
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/preferences/PreferenceInitializer.java
@@ -42,7 +42,6 @@ public void initializeDefaultPreferences() {
// Colours
store.setDefault(DERIVE_ELEMENT_LINE_COLOR, true);
- store.setDefault(DERIVE_ELEMENT_LINE_COLOR_FACTOR, 7);
store.setDefault(SAVE_USER_DEFAULT_COLOR, false);
// Fonts
diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/preferences/messages.properties b/com.archimatetool.editor/src/com/archimatetool/editor/preferences/messages.properties
index 86c330e5b..7127ed3a0 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/preferences/messages.properties
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/preferences/messages.properties
@@ -13,11 +13,8 @@ ColoursPreferencePage_13=Edit...
ColoursPreferencePage_14=Reset
ColoursPreferencePage_15=Import Scheme...
ColoursPreferencePage_16=Export Scheme...
-ColoursPreferencePage_17=Element line colour
ColoursPreferencePage_18=Derive element line colours from fill colours
-ColoursPreferencePage_19=Contrast factor:
ColoursPreferencePage_2=Business elements
-ColoursPreferencePage_20=Disabling this option will enable user element line colours
ColoursPreferencePage_21=Save the default colours for elements in the model file
ColoursPreferencePage_22=Import
ColoursPreferencePage_23=Export
diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineColorSection.java b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineColorSection.java
index f93c2729f..d36190a73 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineColorSection.java
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineColorSection.java
@@ -10,6 +10,8 @@
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
@@ -20,6 +22,7 @@
import com.archimatetool.editor.ArchiPlugin;
import com.archimatetool.editor.diagram.commands.LineColorCommand;
+import com.archimatetool.editor.model.commands.FeatureCommand;
import com.archimatetool.editor.preferences.IPreferenceConstants;
import com.archimatetool.editor.ui.ColorFactory;
import com.archimatetool.editor.ui.components.ColorChooser;
@@ -107,7 +110,6 @@ else if(event.getProperty() == ColorChooser.PROP_COLORDEFAULT) {
public void propertyChange(PropertyChangeEvent event) {
if(event.getProperty().equals(IPreferenceConstants.DEFAULT_ELEMENT_LINE_COLOR) ||
event.getProperty().equals(IPreferenceConstants.DEFAULT_CONNECTION_LINE_COLOR) ||
- event.getProperty().equals(IPreferenceConstants.DERIVE_ELEMENT_LINE_COLOR) ||
event.getProperty().equals(IPreferenceConstants.SAVE_USER_DEFAULT_COLOR)) { // This will affect the "Default" menu in color chooser
update();
}
@@ -115,6 +117,8 @@ public void propertyChange(PropertyChangeEvent event) {
};
private ColorChooser fColorChooser;
+ private Action fDeriveLineColorAction;
+
@Override
protected void createControls(Composite parent) {
@@ -131,6 +135,26 @@ private void createColorControl(Composite parent) {
fColorChooser = new ColorChooser(parent, getWidgetFactory());
fColorChooser.addListener(colorListener);
+
+ // Derive line color from fill color action
+ fDeriveLineColorAction = new Action(Messages.LineColorSection_3, IAction.AS_CHECK_BOX) {
+ @Override
+ public void run() {
+ CompoundCommand result = new CompoundCommand();
+
+ for(EObject object : getEObjects()) {
+ if(isAlive(object) && object instanceof IDiagramModelObject dmo) {
+ Command cmd = new FeatureCommand(Messages.LineColorSection_4, dmo, IDiagramModelObject.FEATURE_DERIVE_ELEMENT_LINE_COLOR,
+ fDeriveLineColorAction.isChecked(), IDiagramModelObject.FEATURE_DERIVE_ELEMENT_LINE_COLOR_DEFAULT);
+ if(cmd.canExecute()) {
+ result.add(cmd);
+ }
+ }
+ }
+
+ executeCommand(result.unwrap());
+ }
+ };
}
@Override
@@ -138,7 +162,8 @@ protected void notifyChanged(Notification msg) {
if(msg.getNotifier() == getFirstSelectedObject()) {
Object feature = msg.getFeature();
- if(feature == FEATURE || feature == IArchimatePackage.Literals.LOCKABLE__LOCKED) {
+ if(feature == FEATURE || feature == IArchimatePackage.Literals.LOCKABLE__LOCKED ||
+ isFeatureNotification(msg, IDiagramModelObject.FEATURE_DERIVE_ELEMENT_LINE_COLOR)) {
update();
}
}
@@ -172,12 +197,15 @@ protected void update() {
}
fColorChooser.setIsDefaultColor(isDefaultColor);
- // If this is an element line disable some things
- if(lineObject instanceof IDiagramModelObject) {
- boolean deriveElementLineColor = ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.DERIVE_ELEMENT_LINE_COLOR);
+ // If this is an element line enable or disable some things
+ if(lineObject instanceof IDiagramModelObject dmo) {
+ boolean deriveElementLineColor = dmo.getDeriveElementLineColor();
fColorChooser.setDoShowColorImage(!deriveElementLineColor);
fColorChooser.getColorButton().setEnabled(!deriveElementLineColor);
fColorChooser.setDoShowDefaultMenuItem(!deriveElementLineColor);
+
+ fColorChooser.addMenuAction(fDeriveLineColorAction);
+ fDeriveLineColorAction.setChecked(deriveElementLineColor);
}
else {
fColorChooser.setDoShowColorImage(true);
diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/Messages.java b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/Messages.java
index 46112a3fc..b422ce0fd 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/Messages.java
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/Messages.java
@@ -247,6 +247,10 @@ public class Messages extends NLS {
public static String LineColorSection_2;
+ public static String LineColorSection_3;
+
+ public static String LineColorSection_4;
+
public static String LineWidthSection_0;
public static String LineWidthSection_1;
diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/messages.properties b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/messages.properties
index f96f5f692..716b434b3 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/messages.properties
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/messages.properties
@@ -129,6 +129,8 @@ LabelRendererSection_2=Set expression
LineColorSection_0=Line Colour:
LineColorSection_1=Default
LineColorSection_2=Enable in Preferences
+LineColorSection_3=Derive from fill colour
+LineColorSection_4=Derive line colour
LineWidthSection_0=Line Width:
LineWidthSection_1=Normal
LineWidthSection_2=Medium
diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/ui/ColorFactory.java b/com.archimatetool.editor/src/com/archimatetool/editor/ui/ColorFactory.java
index 693509c57..a09cb6a32 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/ui/ColorFactory.java
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/ui/ColorFactory.java
@@ -69,26 +69,27 @@ public static Color get(String rgbValue) {
* Set user default colors as set in prefs for a model object
*/
public static void setDefaultColors(IDiagramModelComponent component) {
- // If user Prefs is to *not* save default colours in file
- if(!ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.SAVE_USER_DEFAULT_COLOR)) {
- return;
+ // Derived line color
+ if(component instanceof IDiagramModelObject dmo) {
+ dmo.setDeriveElementLineColor(ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.DERIVE_ELEMENT_LINE_COLOR));
}
-
- // Fill color
- if(component instanceof IDiagramModelObject) {
- IDiagramModelObject dmo = (IDiagramModelObject)component;
- Color fillColor = getDefaultFillColor(dmo);
- if(fillColor != null) {
- dmo.setFillColor(convertColorToString(fillColor));
+
+ // If user Prefs is set to save default colours in file
+ if(ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.SAVE_USER_DEFAULT_COLOR)) {
+ // Fill color
+ if(component instanceof IDiagramModelObject dmo) {
+ Color fillColor = getDefaultFillColor(dmo);
+ if(fillColor != null) {
+ dmo.setFillColor(convertColorToString(fillColor));
+ }
}
- }
-
- // Line color
- if(component instanceof ILineObject) {
- ILineObject lo = (ILineObject)component;
- Color lineColor = getDefaultLineColor(lo);
- if(lineColor != null) {
- lo.setLineColor(convertColorToString(lineColor));
+
+ // Line color
+ if(component instanceof ILineObject lo) {
+ Color lineColor = getDefaultLineColor(lo);
+ if(lineColor != null) {
+ lo.setLineColor(convertColorToString(lineColor));
+ }
}
}
}
@@ -341,4 +342,20 @@ public static Color getLighterColor(Color color, float factor) {
return get(convertRGBToString(rgb));
}
+ /**
+ * Return a color based on the suppled one for elements
+ * @param color The color to base this one on
+ * @return the new color
+ */
+ public static Color getDerivedLineColor(Color color) {
+ if(color == null) {
+ return null;
+ }
+
+ float contrastFactor = 0.7f;
+
+ RGB rgb = new RGB((int)(color.getRed() * contrastFactor), (int)(color.getGreen() * contrastFactor), (int)(color.getBlue() * contrastFactor));
+
+ return get(convertRGBToString(rgb));
+ }
}
diff --git a/com.archimatetool.help/help/Text/prefs_appearance.html b/com.archimatetool.help/help/Text/prefs_appearance.html
index 7ab2e86ee..76009e743 100644
--- a/com.archimatetool.help/help/Text/prefs_appearance.html
+++ b/com.archimatetool.help/help/Text/prefs_appearance.html
@@ -40,7 +40,7 @@ Colours
Theme colours for backgrounds can be set for each theme as set in the Appearance preference. These are for the application and are not saved in the model.
Derive element line colours from fill colours
- If this is checked a diagram element's line colour is derived as a darker shade of its fill colour. You can adjust the amount of contrast with the "Contrast factor" control. If this option is set, user line colours are ignored.
+ If this is checked a newly diagram element's line colour is derived from its fill colour. This can be changed in the element's properties tab.
Save the default fill colour for elements in the model file
If this is checked an element's default colour is saved in the model file and will then be "fixed" in the file. This ensures that if the file is shared with another user they will see these colours.
@@ -60,7 +60,7 @@ Colours
Fonts
- Sets the default font to use elements and connections in diagrams (Views) and fonts to use for various user interface controls. Clicking the "Default" button sets the default font for the selected items. The "Edit" button will allow you to set the font for the selected items.
+ Sets the default font to use for elements and connections in diagrams (Views) and fonts to use for various user interface controls. Clicking the "Default" button sets the default font for the selected items. The "Edit" button will allow you to set the font for the selected items.
diff --git a/com.archimatetool.help/help/Text/properties_element_appearance.html b/com.archimatetool.help/help/Text/properties_element_appearance.html
index 53745708f..7148aad19 100644
--- a/com.archimatetool.help/help/Text/properties_element_appearance.html
+++ b/com.archimatetool.help/help/Text/properties_element_appearance.html
@@ -30,7 +30,7 @@ Element Appearance Properties
Line colour: |
- Sets the colour of the line used to draw the selected element. The "Default" button sets the line colour to the default setting. If this is disabled it is because line colours are derived from the element's fill colour, as set in Preferences. |
+ Sets the colour of the line used to draw the selected element. The "Derive from fill colour" drop-down option sets the line colour based on the fill colour. The "Default" drop-down option sets the line colour to the default colour as set in Preferences. If the "Default" drop-down option is not visible it is because line colours are derived from the element's fill colour, as set in the "Derive from fill colour" drop-down option. |
Line Width: |
diff --git a/com.archimatetool.help/help/Text/properties_group.html b/com.archimatetool.help/help/Text/properties_group.html
index 1f470c924..e83fe546a 100644
--- a/com.archimatetool.help/help/Text/properties_group.html
+++ b/com.archimatetool.help/help/Text/properties_group.html
@@ -51,7 +51,7 @@ Group Properties
Line colour: |
- Sets the colour of the line used to draw the Group. The "Default" button sets the line colour to the default setting. If this is disabled it is because line colours are derived from the object's fill colour, as set in Preferences. |
+ >Sets the colour of the line used to draw the selected element. The "Derive from fill colour" drop-down option sets the line colour based on the fill colour. The "Default" drop-down option sets the line colour to the default colour as set in Preferences. If the "Default" drop-down option is not visible it is because line colours are derived from the element's fill colour, as set in the "Derive from fill colour" drop-down option. |
Line Width: |
diff --git a/com.archimatetool.help/help/Text/properties_note.html b/com.archimatetool.help/help/Text/properties_note.html
index 5ccbc9a5a..2ca565cb1 100644
--- a/com.archimatetool.help/help/Text/properties_note.html
+++ b/com.archimatetool.help/help/Text/properties_note.html
@@ -46,7 +46,7 @@ Note Properties
Line colour: |
- Sets the colour of the line used to draw the selected object. The "Default" button sets the line colour to the default setting. If this is disabled it is because line colours are derived from the object's fill colour, as set in Preferences. |
+ >Sets the colour of the line used to draw the selected element. The "Derive from fill colour" drop-down option sets the line colour based on the fill colour. The "Default" drop-down option sets the line colour to the default colour as set in Preferences. If the "Default" drop-down option is not visible it is because line colours are derived from the element's fill colour, as set in the "Derive from fill colour" drop-down option. |
Line Width: |
diff --git a/com.archimatetool.help/help/Text/properties_viewref.html b/com.archimatetool.help/help/Text/properties_viewref.html
index 5d2257bd9..75725b7be 100644
--- a/com.archimatetool.help/help/Text/properties_viewref.html
+++ b/com.archimatetool.help/help/Text/properties_viewref.html
@@ -52,7 +52,7 @@ View Reference Properties
Line colour: |
- Sets the colour of the line used to draw the selected object. The "Default" button sets the line colour to the default setting. If this is disabled it is because line colours are derived from the object's fill colour, as set in Preferences. |
+ >Sets the colour of the line used to draw the selected element. The "Derive from fill colour" drop-down option sets the line colour based on the fill colour. The "Default" drop-down option sets the line colour to the default colour as set in Preferences. If the "Default" drop-down option is not visible it is because line colours are derived from the element's fill colour, as set in the "Derive from fill colour" drop-down option. |
Line Width: |
diff --git a/com.archimatetool.model/src/com/archimatetool/model/IDiagramModelObject.java b/com.archimatetool.model/src/com/archimatetool/model/IDiagramModelObject.java
index 611fdfab8..f421d000e 100644
--- a/com.archimatetool.model/src/com/archimatetool/model/IDiagramModelObject.java
+++ b/com.archimatetool.model/src/com/archimatetool/model/IDiagramModelObject.java
@@ -23,23 +23,27 @@
* @model abstract="true"
* @generated
*/
+@SuppressWarnings("nls")
public interface IDiagramModelObject extends IConnectable, IFontAttribute, ILineObject, ITextAlignment {
- String FEATURE_LINE_ALPHA = "lineAlpha"; //$NON-NLS-1$
+ String FEATURE_LINE_ALPHA = "lineAlpha";
int FEATURE_LINE_ALPHA_DEFAULT = 255;
- String FEATURE_GRADIENT = "gradient"; //$NON-NLS-1$
+ String FEATURE_GRADIENT = "gradient";
int GRADIENT_NONE = -1;
int FEATURE_GRADIENT_DEFAULT = GRADIENT_NONE;
- String FEATURE_ICON_VISIBLE = "iconVisible"; //$NON-NLS-1$
+ String FEATURE_ICON_VISIBLE = "iconVisible";
int ICON_VISIBLE_IF_NO_IMAGE_DEFINED = 0;
int ICON_VISIBLE_ALWAYS = 1;
int ICON_VISIBLE_NEVER = 2;
int FEATURE_ICON_VISIBLE_DEFAULT = ICON_VISIBLE_IF_NO_IMAGE_DEFINED;
- String FEATURE_ICON_COLOR = "iconColor"; //$NON-NLS-1$
- String FEATURE_ICON_COLOR_DEFAULT = ""; //$NON-NLS-1$
+ String FEATURE_ICON_COLOR = "iconColor";
+ String FEATURE_ICON_COLOR_DEFAULT = "";
+
+ String FEATURE_DERIVE_ELEMENT_LINE_COLOR = "deriveElementLineColor";
+ boolean FEATURE_DERIVE_ELEMENT_LINE_COLOR_DEFAULT = true;
/**
* @return the value of FEATURE_LINE_ALPHA
@@ -64,7 +68,7 @@ public interface IDiagramModelObject extends IConnectable, IFontAttribute, ILine
void setGradient(int type);
/**
- * @return true if the icon is visible (if this object has an icon)
+ * @return the icon visible state
*/
int getIconVisibleState();
@@ -85,6 +89,17 @@ public interface IDiagramModelObject extends IConnectable, IFontAttribute, ILine
*/
void setIconColor(String iconColor);
+ /**
+ * @return true if this element derives its line color from its fill color
+ */
+ boolean getDeriveElementLineColor();
+
+ /**
+ * Set whether this element derives its line color from its fill color
+ * @param value value
+ */
+ void setDeriveElementLineColor(boolean value);
+
/**
* Returns the value of the 'Bounds' containment reference.
*
diff --git a/com.archimatetool.model/src/com/archimatetool/model/impl/DiagramModelObject.java b/com.archimatetool.model/src/com/archimatetool/model/impl/DiagramModelObject.java
index 168b88f89..cbf6d6183 100644
--- a/com.archimatetool.model/src/com/archimatetool/model/impl/DiagramModelObject.java
+++ b/com.archimatetool.model/src/com/archimatetool/model/impl/DiagramModelObject.java
@@ -251,6 +251,16 @@ public void setIconColor(String iconColor) {
getFeatures().putString(FEATURE_ICON_COLOR, iconColor, FEATURE_ICON_COLOR_DEFAULT);
}
+ @Override
+ public boolean getDeriveElementLineColor() {
+ return getFeatures().getBoolean(FEATURE_DERIVE_ELEMENT_LINE_COLOR, FEATURE_DERIVE_ELEMENT_LINE_COLOR_DEFAULT);
+ }
+
+ @Override
+ public void setDeriveElementLineColor(boolean value) {
+ getFeatures().putBoolean(FEATURE_DERIVE_ELEMENT_LINE_COLOR, value, FEATURE_DERIVE_ELEMENT_LINE_COLOR_DEFAULT);
+ }
+
/**
*
*
diff --git a/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/diagram/figures/AbstractDiagramModelObjectFigureTests.java b/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/diagram/figures/AbstractDiagramModelObjectFigureTests.java
index 2bab9a84b..3c027ab44 100644
--- a/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/diagram/figures/AbstractDiagramModelObjectFigureTests.java
+++ b/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/diagram/figures/AbstractDiagramModelObjectFigureTests.java
@@ -107,7 +107,7 @@ public void testSetFontColor() {
@Test
public void testSetLineColor() {
- ArchiPlugin.PREFERENCES.setValue(IPreferenceConstants.DERIVE_ELEMENT_LINE_COLOR, false);
+ diagramModelObject.setDeriveElementLineColor(false);
assertEquals(ColorFactory.getDefaultLineColor(diagramModelObject), abstractFigure.getLineColor());