]> gerrit.simantics Code Review - simantics/district.git/commitdiff
Selection of highlight color for District Finder queries 68/4068/1
authorReino Ruusu <reino.ruusu@semantum.fi>
Fri, 3 Apr 2020 16:40:45 +0000 (19:40 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 6 Apr 2020 08:13:05 +0000 (08:13 +0000)
gitlab #85

TODO: Element size controls

Change-Id: Ifadc9f72a7efe6e7ace930b2d4c09b3133f1b9df
(cherry picked from commit 6e5f34e9a8fa2dd0c83745e25285dc4c5e0a9ce5)

org.simantics.district.selection.ui/META-INF/MANIFEST.MF
org.simantics.district.selection.ui/src/org/simantics/district/selection/ui/ElementSelectionTools.java
org.simantics.district.selection.ui/src/org/simantics/district/selection/ui/ElementSelectorTableUI.java
org.simantics.district.selection.ui/src/org/simantics/district/selection/ui/parts/EditSelectorDialog.java
org.simantics.district.selection.ui/src/org/simantics/district/selection/ui/parts/ElementSelectionView.java
org.simantics.district.selection/META-INF/MANIFEST.MF
org.simantics.district.selection/graph/DiagramElementSelection.pgraph
org.simantics.district.selection/src/org/simantics/district/selection/ElementSelectionResource.java
org.simantics.district.selection/src/org/simantics/district/selection/ElementSelector.java

index 86962fc5f8a3e5317708444c10b553c38ee15954..523958b1377650c917fc74adfb8e6f742b2f0df8 100644 (file)
@@ -31,7 +31,8 @@ Require-Bundle: javax.inject,
  org.simantics.diagram.ontology,
  org.eclipse.e4.core.services,
  org.simantics.district.network.ontology;bundle-version="1.0.0",
- org.simantics.layer0.utils
+ org.simantics.layer0.utils,
+ org.eclipse.nebula.widgets.tablecombo
 Bundle-ManifestVersion: 2
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Bundle-Vendor: Semantum oy
index 33a428f41e71fddb25a729aed13b5467aa8f2fed..06622b82baa73c8125556067a0c39782f30dcb0e 100644 (file)
@@ -22,6 +22,7 @@ import org.simantics.layer0.Layer0;
 import org.simantics.ui.selection.AnyResource;
 import org.simantics.ui.selection.AnyVariable;
 import org.simantics.ui.selection.WorkbenchSelectionContentType;
+import org.simantics.utils.ui.color.Color;
 
 public class ElementSelectionTools {
 
@@ -82,4 +83,19 @@ public class ElementSelectionTools {
                }
        }
 
+       public static float[] colorToLiteral(Color color) {
+               // BGRA float values out
+               return new float[] {
+                               (float)color.getB() / 255,
+                               (float)color.getG() / 255,
+                               (float)color.getR() / 255,
+                               1.f,
+                       };
+       }
+
+       public static Color literalToColor(float[] color) {
+               // BGRA float values in
+               return new Color((int) (color[2] * 255), (int) (color[1] * 255), (int) (color[0] * 255));
+       }
+
 }
index cdddd928bedd2f081321c2147c8592c1246170aa..4603eb8eb58ee6dbc2ee45e4627bfe20e95c4687 100644 (file)
@@ -2,22 +2,27 @@ package org.simantics.district.selection.ui;
 
 import java.util.Collection;
 
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.resource.LocalResourceManager;
+import org.eclipse.jface.resource.ResourceManager;
 import org.eclipse.jface.viewers.ColumnLabelProvider;
 import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
 import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.TreeViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.PaletteData;
+import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.Table;
 import org.simantics.Simantics;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.common.procedure.adapter.SyncListenerAdapter;
@@ -31,12 +36,17 @@ public class ElementSelectorTableUI extends Composite {
 
        private static final Logger LOGGER = LoggerFactory.getLogger(ElementSelectorTableUI.class);
 
-       private TreeViewer viewer;
+       private TableViewer viewer;
 
        private ElementSelectionView view;
 
+       private ResourceManager resourceManager;
+
        public ElementSelectorTableUI(Composite parent, int style, ElementSelectionView view) {
                super(parent, style);
+               
+               resourceManager = new LocalResourceManager(JFaceResources.getResources(), this);
+               
                this.view = view;
                
                parent.setLayout(new FillLayout());
@@ -52,8 +62,8 @@ public class ElementSelectorTableUI extends Composite {
                configureTable();
        }
 
-       public Tree getTree() {
-               return viewer.getTree();
+       public Table getTable() {
+               return viewer.getTable();
        }
 
        public ElementSelector getSelectedItem() {
@@ -61,12 +71,12 @@ public class ElementSelectorTableUI extends Composite {
                return selection != null ? (ElementSelector) selection.getFirstElement() : null;
        }
 
-       private TreeViewer createViewer() {
-               return new TreeViewer(this, SWT.FULL_SELECTION);
+       private TableViewer createViewer() {
+               return new TableViewer(this, SWT.FULL_SELECTION | SWT.SINGLE);
        }
 
        private void configureTable() {
-               Tree table = viewer.getTree();
+               Table table = viewer.getTable();
                table.setHeaderVisible(true);
                table.setLinesVisible(true);
 
@@ -79,17 +89,7 @@ public class ElementSelectorTableUI extends Composite {
        }
 
        private void setContentProvider() {
-               viewer.setContentProvider(new ITreeContentProvider() {
-                       @Override
-                       public boolean hasChildren(Object element) {
-                               return false;
-                       }
-       
-                       @Override
-                       public Object getParent(Object element) {
-                               return null;
-                       }
-       
+               viewer.setContentProvider(new IStructuredContentProvider() {
                        @Override
                        public Object[] getElements(Object inputElement) {
                                if (inputElement == null || !(inputElement instanceof Collection))
@@ -97,21 +97,11 @@ public class ElementSelectorTableUI extends Composite {
                                
                                return ((Collection<?>)inputElement).toArray();
                        }
-       
-                       @Override
-                       public Object[] getChildren(Object parentElement) {
-                               return null;
-                       }
-       
-                       @Override
-                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-                               ITreeContentProvider.super.inputChanged(viewer, oldInput, newInput);
-                       }
                });
        }
 
-       private TreeViewerColumn createNameColumn() {
-               TreeViewerColumn column = new TreeViewerColumn(viewer, SWT.NONE);
+       private TableViewerColumn createNameColumn() {
+               TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
                column.getColumn().setText("Name");
                column.getColumn().setWidth(200);
                column.getColumn().setResizable(true);
@@ -119,19 +109,43 @@ public class ElementSelectorTableUI extends Composite {
                        @Override
                        public String getText(Object element) {
                                ElementSelector selector = (ElementSelector) element;
-                               return selector.getName();
+                               return " " + selector.getName();
                        }
                        
                        @Override
                        public Image getImage(Object element) {
-                               return null;
+                               ElementSelector selector = (ElementSelector) element;
+                               float[] color = selector.getColor();
+                               if (color == null)
+                                       return null;
+                               
+                               RGB rgb = ElementSelectionTools.literalToColor(color).getRgb();
+                               
+                               PaletteData paletteData = new PaletteData(new RGB[] { new RGB(255, 255, 255), rgb });
+                               
+                               // Create image with a colored horizontal bar
+                               // TODO: Indicate line width
+                               Image image = resourceManager.createImage(ImageDescriptor.createFromImageDataProvider(zoom -> {
+                                       int height = 8 * zoom / 100;
+                                       int width = 40 * zoom / 100;
+                                       ImageData imageData = new ImageData(width, height, 1, paletteData);
+                                       for (int x = 0; x < width; x++) {
+                                               for (int y = 0; y < height; y++) {
+                                                       imageData.setPixel(x, y, 1);
+                                               }
+                                       }
+                                       
+                                       return imageData;
+                               }));
+                               
+                               return image;
                        }
                });
                return column;
        }
 
-       private TreeViewerColumn createQueryColumn() {
-               TreeViewerColumn column = new TreeViewerColumn(viewer, SWT.NONE);
+       private TableViewerColumn createQueryColumn() {
+               TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
                column.getColumn().setText("Query");
                column.getColumn().setWidth(600);
                column.getColumn().setResizable(true);
@@ -141,11 +155,6 @@ public class ElementSelectorTableUI extends Composite {
                                ElementSelector selector = (ElementSelector) element;
                                return selector.getExpression();
                        }
-                       
-                       @Override
-                       public Image getImage(Object element) {
-                               return null;
-                       }
                });
                return column;
        }
@@ -177,7 +186,7 @@ public class ElementSelectorTableUI extends Composite {
        private final class DoubleClickListener implements IDoubleClickListener {
                @Override
                public void doubleClick(DoubleClickEvent event) {
-                       TreeSelection selection = (TreeSelection) event.getViewer().getSelection();
+                       IStructuredSelection selection = (IStructuredSelection) event.getViewer().getSelection();
                        Display display = event.getViewer().getControl().getDisplay();
                        ElementSelector query = (ElementSelector) selection.getFirstElement();
                        
index 623f0f847921137f08f1f953d2179b5df56edd8e..387afa7c9827fdb8490167eba6723cdef0aaaff8 100644 (file)
@@ -24,6 +24,8 @@ import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.jface.resource.LocalResourceManager;
 import org.eclipse.jface.resource.ResourceLocator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.nebula.widgets.tablecombo.TableCombo;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
@@ -31,11 +33,15 @@ import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.swt.widgets.Widget;
 import org.simantics.Simantics;
+import org.simantics.databoard.Bindings;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -50,6 +56,7 @@ import org.simantics.db.layer0.request.PropertyInfo;
 import org.simantics.db.layer0.request.PropertyInfoRequest;
 import org.simantics.db.layer0.util.Layer0Utils;
 import org.simantics.diagram.stubs.DiagramResource;
+import org.simantics.diagram.stubs.G2DResource;
 import org.simantics.district.network.ontology.DistrictNetworkResource;
 import org.simantics.district.region.ontology.DiagramRegionsResource;
 import org.simantics.district.route.ontology.RouteResource;
@@ -69,12 +76,14 @@ import org.simantics.district.selection.ElementSelector.PropertySelector;
 import org.simantics.district.selection.ElementSelector.RegionCondition;
 import org.simantics.district.selection.ElementSelector.RouteCondition;
 import org.simantics.district.selection.ElementSelector.Selector;
+import org.simantics.district.selection.ui.ElementSelectionTools;
 import org.simantics.layer0.Layer0;
 import org.simantics.layer0.utils.direct.GraphUtils;
 import org.simantics.modeling.ModelingResources;
 import org.simantics.structural.stubs.StructuralResource2;
 import org.simantics.utils.datastructures.Arrays;
 import org.simantics.utils.datastructures.Pair;
+import org.simantics.utils.ui.color.Color;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -116,6 +125,9 @@ public class EditSelectorDialog extends Dialog {
        private String name;
        private Text nameField;
 
+       private Color color;
+       private TableCombo colorCombo;
+       
        private Resource diagram;
        private Combo diagramField;
 
@@ -158,7 +170,6 @@ public class EditSelectorDialog extends Dialog {
        
        // Called to read values from controls into conditions
        Updater updater = NULL_UPDATE;
-
        @Inject
        public EditSelectorDialog(Shell shell, ElementSelector elementSelector, Collection<Resource> currentSelection) {
                super(shell);
@@ -200,6 +211,11 @@ public class EditSelectorDialog extends Dialog {
                condition = null;
                
                if (elementSelector != null) {
+                       float[] color = elementSelector.getColor();
+                       if (color != null) {
+                               this.color = ElementSelectionTools.literalToColor(color);
+                       }
+                       
                        Generator generator = elementSelector.getGenerator();
                        if (generator instanceof ModelGenerator) {
                                generatorIndex = 0;
@@ -357,6 +373,13 @@ public class EditSelectorDialog extends Dialog {
                                throw new ValidationException("Please enter a name");
                        }
                        
+                       {
+                               int index = colorCombo.getSelectionIndex();
+                               if (index >= 0) {
+                                       color = new Color(colorCombo.getTable().getItem(index).getBackground().getRGB());
+                               }
+                       }
+                       
                        componentType = componentTypes.get(componentTypeField.getSelectionIndex());
                        
                        selectorIndex = selectorField.getSelectionIndex();
@@ -424,6 +447,11 @@ public class EditSelectorDialog extends Dialog {
                                graph.claimLiteral(selection, L0.HasLabel, L0.String, name);
                                graph.claim(selection, L0.PartOf, lib);
                                
+                               if (color != null) {
+                                       float[] value = ElementSelectionTools.colorToLiteral(color);
+                                       graph.claimLiteral(selection, ES.Selection_HasHighlightColor, G2DResource.getInstance(graph).Color, value, Bindings.FLOAT_ARRAY);
+                               }
+                               
                                // Generator
                                Resource generator = graph.newResource();
                                Resource generatorType;
@@ -516,6 +544,58 @@ public class EditSelectorDialog extends Dialog {
                nameField.setText(name);
                GridDataFactory.swtDefaults().hint(200, SWT.DEFAULT).applyTo(nameField);
                
+               // Highlight style
+               Label label = new Label(content, SWT.NONE);
+               GridDataFactory.swtDefaults().applyTo(label);
+               label.setText("Highlight color");
+               
+               colorCombo = new TableCombo(content, SWT.BORDER | SWT.READ_ONLY);
+               GridDataFactory.swtDefaults().hint(80, SWT.DEFAULT).applyTo(colorCombo);
+               Table colorTable = colorCombo.getTable();
+               colorCombo.getTextControl().setEnabled(false);
+               Display display = getShell().getDisplay();
+               colorTable.setFont(display.getSystemFont());
+               createColorItem(colorTable, "Red", SWT.COLOR_RED);
+               createColorItem(colorTable, "Green", SWT.COLOR_GREEN);
+               createColorItem(colorTable, "Blue", SWT.COLOR_BLUE);
+               createColorItem(colorTable, "Yellow", SWT.COLOR_YELLOW);
+               createColorItem(colorTable, "Cyan", SWT.COLOR_CYAN);
+               createColorItem(colorTable, "Magenta", SWT.COLOR_MAGENTA);
+               TableItem other = new TableItem(colorTable, SWT.NONE);
+               other.setText("Other...");
+
+               if (color != null) {
+                       int i;
+                       for (i = 0; i < 6; i++) {
+                               if (colorTable.getItem(i).getBackground().getRGB().equals(color.getRgb())) {
+                                       colorCombo.select(i);
+                                       break;
+                               }
+                       }
+                       
+                       if (i == 6) {
+                               other.setBackground(resourceManager.createColor(color.getRgb()));
+                               colorCombo.select(6);
+                       }
+               }
+               
+               colorCombo.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               int index = colorCombo.getSelectionIndex();
+                               if (index == 6) {
+                                       org.simantics.utils.ui.color.ColorDialog colorDialog = new org.simantics.utils.ui.workbench.dialogs.ColorDialog(getParentShell());
+                                       int result = colorDialog.open();
+                                       if (result == Window.OK) {
+                                               other.setBackground(resourceManager.createColor(colorDialog.getColor().getRgb()));
+                                               colorCombo.clearSelection();
+                                               colorCombo.select(6);
+                                               colorTable.redraw();
+                                       }
+                               }
+                       }
+               });
+               
                // Selector
                Label selectorLabel = new Label(content, SWT.NONE);
                selectorLabel.setText("Select");
@@ -632,18 +712,25 @@ public class EditSelectorDialog extends Dialog {
                sourceField.select(generatorIndex);
                
                // Condition
-               Label label = new Label(content, SWT.NONE);
+               label = new Label(content, SWT.NONE);
                GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.CENTER).applyTo(label);
                label.setText("where");
                
                conditionPanel = new Composite(content, SWT.NONE);
-               GridDataFactory.swtDefaults().span(1, 2).minSize(400, SWT.DEFAULT).grab(true, false).applyTo(conditionPanel);
+               GridDataFactory.swtDefaults().minSize(400, SWT.DEFAULT).grab(true, false).applyTo(conditionPanel);
                GridLayoutFactory.fillDefaults().numColumns(2).applyTo(conditionPanel);
                
                updater = updateConditionPanel();
                
                return content;
        }
+
+       private TableItem createColorItem(Table colorTable, String name, int color) {
+               TableItem item = new TableItem(colorTable, SWT.BORDER);
+               item.setText(name);
+               item.setBackground(colorTable.getDisplay().getSystemColor(color));
+               return item;
+       }
        
        private Updater updateConditionPanel() {
                // Erase contents
index dfc53328a959885f0ec326e60e1c83be16f9a20e..16e6bb159ed2938a0a1281602b3628b7b08dab94 100644 (file)
@@ -115,7 +115,7 @@ public class ElementSelectionView {
        @PostConstruct
        public void createPartControl(Composite parent, EMenuService menuService) {
                table = new ElementSelectorTableUI(parent, SWT.BORDER, this);
-               if (!(menuService.registerContextMenu(this.table.getTree(), POPUP_ID)))
+               if (!(menuService.registerContextMenu(this.table.getTable(), POPUP_ID)))
                        LOGGER.warn("Could not register context menu {}", POPUP_ID);
        }
 
index 14fe8e0fb68080575508b04664f8ef33e6a31222..fae2f723a425fc723ab0a6529e747896730ae7bd 100644 (file)
@@ -17,5 +17,6 @@ Require-Bundle: org.simantics.district.route;bundle-version="1.0.0",
  org.junit,
  org.simantics,
  org.simantics.structural.ontology,
- org.simantics.modeling.ontology
+ org.simantics.modeling.ontology,
+ org.simantics.g2d.ontology;bundle-version="1.1.0"
 Export-Package: org.simantics.district.selection
index 220714032395b21f609ddeb9a3ba36706adc78ee..324268a200b7e91d087c7b303150038dbf30a27e 100644 (file)
@@ -2,6 +2,7 @@ L0 = <http://www.simantics.org/Layer0-1.1>
 DIA = <http://www.simantics.org/Diagram-2.2>
 DNR = <http://www.simantics.org/DistrictNetworkRoutes-1.0>
 REG = <http://www.simantics.org/DistrictDiagramRegions-1.0>
+G2D = <http://www.simantics.org/G2D-1.1>
 
 ES = <http://www.simantics.org/ElementSelection-1.0> : L0.Ontology
     @L0.new
@@ -14,9 +15,16 @@ ES.Selection <T L0.Entity
     >-- ES.Selection.HasGenerator --> ES.Generator <R L0.HasProperty : L0.FunctionalRelation
     >-- ES.Selection.HasCondition --> ES.Condition <R L0.HasProperty : L0.FunctionalRelation
     >-- ES.Selection.HasSelector --> ES.Selector <R L0.HasProperty : L0.FunctionalRelation
+    
+    >-- ES.Selection.HasHighlightColor --> G2D.Color <R G2D.HasColor : L0.FunctionalRelation
+    >-- ES.Selection.HasLineWidth --> L0.Float <R G2D.HasStrokeWidth : L0.FunctionalRelation
+    
     @L0.singleProperty ES.Selection.HasGenerator
     @L0.singleProperty ES.Selection.HasCondition
     @L0.singleProperty ES.Selection.HasSelector
+    
+    @L0.optionalProperty ES.Selection.HasHighlightColor
+    @L0.optionalProperty ES.Selection.HasLineWidth
 
 ES.Generator <T L0.Entity
 ES.Condition <T L0.Entity
index 913076ddcc694fa0531ba5fa3e56faf50eea84f9..8690c81cb6df6f64846c84b974024ab1837833f0 100644 (file)
@@ -52,6 +52,10 @@ public class ElementSelectionResource {
     public final Resource Selection_HasCondition_Inverse;
     public final Resource Selection_HasGenerator;
     public final Resource Selection_HasGenerator_Inverse;
+    public final Resource Selection_HasHighlightColor;
+    public final Resource Selection_HasHighlightColor_Inverse;
+    public final Resource Selection_HasLineWidth;
+    public final Resource Selection_HasLineWidth_Inverse;
     public final Resource Selection_HasSelector;
     public final Resource Selection_HasSelector_Inverse;
     public final Resource Selector;
@@ -103,6 +107,10 @@ public class ElementSelectionResource {
         public static final String Selection_HasCondition_Inverse = "http://www.simantics.org/ElementSelection-1.0/Selection/HasCondition/Inverse";
         public static final String Selection_HasGenerator = "http://www.simantics.org/ElementSelection-1.0/Selection/HasGenerator";
         public static final String Selection_HasGenerator_Inverse = "http://www.simantics.org/ElementSelection-1.0/Selection/HasGenerator/Inverse";
+        public static final String Selection_HasHighlightColor = "http://www.simantics.org/ElementSelection-1.0/Selection/HasHighlightColor";
+        public static final String Selection_HasHighlightColor_Inverse = "http://www.simantics.org/ElementSelection-1.0/Selection/HasHighlightColor/Inverse";
+        public static final String Selection_HasLineWidth = "http://www.simantics.org/ElementSelection-1.0/Selection/HasLineWidth";
+        public static final String Selection_HasLineWidth_Inverse = "http://www.simantics.org/ElementSelection-1.0/Selection/HasLineWidth/Inverse";
         public static final String Selection_HasSelector = "http://www.simantics.org/ElementSelection-1.0/Selection/HasSelector";
         public static final String Selection_HasSelector_Inverse = "http://www.simantics.org/ElementSelection-1.0/Selection/HasSelector/Inverse";
         public static final String Selector = "http://www.simantics.org/ElementSelection-1.0/Selector";
@@ -164,6 +172,10 @@ public class ElementSelectionResource {
         Selection_HasCondition_Inverse = getResourceOrNull(graph, URIs.Selection_HasCondition_Inverse);
         Selection_HasGenerator = getResourceOrNull(graph, URIs.Selection_HasGenerator);
         Selection_HasGenerator_Inverse = getResourceOrNull(graph, URIs.Selection_HasGenerator_Inverse);
+        Selection_HasHighlightColor = getResourceOrNull(graph, URIs.Selection_HasHighlightColor);
+        Selection_HasHighlightColor_Inverse = getResourceOrNull(graph, URIs.Selection_HasHighlightColor_Inverse);
+        Selection_HasLineWidth = getResourceOrNull(graph, URIs.Selection_HasLineWidth);
+        Selection_HasLineWidth_Inverse = getResourceOrNull(graph, URIs.Selection_HasLineWidth_Inverse);
         Selection_HasSelector = getResourceOrNull(graph, URIs.Selection_HasSelector);
         Selection_HasSelector_Inverse = getResourceOrNull(graph, URIs.Selection_HasSelector_Inverse);
         Selector = getResourceOrNull(graph, URIs.Selector);
index 9015b7117605674dd56bcaa9385e3116ccaedf43..ff978059dab381aaf86d651fede0f3815613f181 100644 (file)
@@ -56,6 +56,8 @@ public class ElementSelector {
        Selector selector;
        Condition condition;
        
+       private float[] color;
+       
        static Logger LOG = LoggerFactory.getLogger(ElementSelector.class);
        
        static ElementSelectionResource ES;
@@ -81,6 +83,9 @@ public class ElementSelector {
                try {
                        this.name = graph.getRelatedValue(resource, L0.HasLabel);
                        this.expression = getExpression(graph, resource);
+                       
+                       float[] color = graph.getPossibleRelatedValue(resource, ES.Selection_HasHighlightColor);
+                       this.color = color;
                } catch (DatabaseException e) {
                        LOG.error("Error reading element selector", e);
                        throw e;
@@ -149,6 +154,13 @@ public class ElementSelector {
        public Condition getCondition() {
                return condition;
        }
+       
+       /**
+        * Get the selection highlight color as a four element BGRA array.
+        */
+       public float[] getColor() {
+               return color;
+       }
 
        /**
         *