From 2de54d0f65ace8c56d27a5a1191e4420b96e22c2 Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Wed, 6 Nov 2019 14:20:08 +0200 Subject: [PATCH] Updates for dynamic visualisations * Do not print ValueNotFoundExceptions * Add support for resetting visualisations gitlab #59 Change-Id: I5d54194463dae5755e433abea1a06ec81ba40a50 --- .../graph/DistrictNetwork.pgraph | 36 ++++++---- .../ontology/DistrictNetworkResource.java | 30 ++++++-- .../DynamicVisualisationsUI.java | 2 +- .../ActiveDynamicVisualisationsRequest.java | 13 +++- .../RuntimeDynamicVisualisationsRequest.java | 1 - .../visualisations/DynamicVisualisations.java | 2 +- .../DynamicVisualisationsContributions.java | 72 +++---------------- .../model/DynamicVisualisation.java | 33 +++++++-- 8 files changed, 95 insertions(+), 94 deletions(-) diff --git a/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph b/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph index 00dc3d08..8516608a 100644 --- a/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph +++ b/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph @@ -219,8 +219,10 @@ DN.VisualisationsFolder -- DN.Diagram.Visualisations.Interval @defProperty "Interval" L0.Long - >-- DN.Diagram.Visualisations.Disabled - @defProperty "Disabled" L0.Boolean + >-- DN.Diagram.Visualisations.DisabledUpdates + @defProperty "Disabled Updates" L0.Boolean + >-- DN.Diagram.Visualisations.ResetVisualisation + @defProperty "Reset Visualisations" L0.Boolean >-- DN.Diagram.Visualisations.ShowColorBars @defProperty "Show Color Bars" L0.Boolean >-- DN.Diagram.Visualisations.ShowColorBarTicks @@ -242,31 +244,35 @@ DN.Diagram.Visualisations -- DN.Diagram.Visualisations.SizeBarSize @defProperty "Size Bar Size" L0.String >-- DN.Diagram.Visualisations.HideEdges - @defProperty "Hide Edges" L0.String + @defProperty "Hide Edges" L0.Boolean >-- DN.Diagram.Visualisations.HidePoints - @defProperty "Hide Points" L0.String + @defProperty "Hide Points" L0.Boolean >-- DN.Diagram.Visualisations.HideConsumers - @defProperty "Hide Consumers" L0.String + @defProperty "Hide Consumers" L0.Boolean >-- DN.Diagram.Visualisations.HideProducers - @defProperty "Hide Producers" L0.String + @defProperty "Hide Producers" L0.Boolean >-- DN.Diagram.Visualisations.HideValves - @defProperty "Hide Valves" L0.String + @defProperty "Hide Valves" L0.Boolean >-- DN.Diagram.Visualisations.HidePumpingStations - @defProperty "Hide Pumping Stations" L0.String + @defProperty "Hide Pumping Stations" L0.Boolean >-- DN.Diagram.Visualisations.StaticPropertiesNetworkBranches - @defProperty "Static Properties Network Branches" L0.String + @defProperty "Static Properties Network Branches" L0.Boolean >-- DN.Diagram.Visualisations.StaticPropertiesPoints - @defProperty "Static Properties Points" L0.String + @defProperty "Static Properties Points" L0.Boolean >-- DN.Diagram.Visualisations.StaticPropertiesConsumers - @defProperty "Static Properties Consumers" L0.String + @defProperty "Static Properties Consumers" L0.Boolean >-- DN.Diagram.Visualisations.DynamicSymbolsShutoffValves - @defProperty "Dynamic Symbols Shutoff Valves" L0.String + @defProperty "Dynamic Symbols Shutoff Valves" L0.Boolean >-- DN.Diagram.Visualisations.DynamicSymbolsProducers - @defProperty "Dynamic Symbols Producers" L0.String + @defProperty "Dynamic Symbols Producers" L0.Boolean >-- DN.Diagram.Visualisations.DynamicSymbolsValves - @defProperty "Dynamic Symbols Valves" L0.String + @defProperty "Dynamic Symbols Valves" L0.Boolean >-- DN.Diagram.Visualisations.DynamicSymbolsPumpingStations - @defProperty "Dynamic Symbols Pumping Stations" L0.String + @defProperty "Dynamic Symbols Pumping Stations" L0.Boolean + >-- DN.Diagram.Visualisations.KeyVariableVertexHover + @defProperty "Key Variables for Vertices on Hover" L0.Boolean + >-- DN.Diagram.Visualisations.KeyVariableEdgeHover + @defProperty "Key Variables for Edges on Hover" L0.Boolean DN.Diagram.Visualisations.ColorContribution colorContributions = visualisation.getColorContributions(); for (Entry entry : colorContributions.entrySet()) { diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/ActiveDynamicVisualisationsRequest.java b/org.simantics.district.network/src/org/simantics/district/network/profile/ActiveDynamicVisualisationsRequest.java index 565227d9..7bff718e 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/ActiveDynamicVisualisationsRequest.java +++ b/org.simantics.district.network/src/org/simantics/district/network/profile/ActiveDynamicVisualisationsRequest.java @@ -42,7 +42,8 @@ public class ActiveDynamicVisualisationsRequest extends ResourceRead dynamicColoringObjects = DynamicVisualisationsContributions.dynamicColoringObjects(graph); Map defaultColoringObjects = dynamicColoringObjects.stream().collect(Collectors.toMap(dcc -> dcc.getColoringObject().getName(), dcc -> dcc)); @@ -72,10 +73,14 @@ public class ActiveDynamicVisualisationsRequest extends ResourceRead> getDynamicColorMapSupplier(String uri, String expressionText) { - return () -> { - try { - @SuppressWarnings("unchecked") - List result = (List) SCLOsgi.MODULE_REPOSITORY.getValue(uri, expressionText); - return result.stream();//result.stream().map(DynamicColorContribution::fromTuple9); - } catch (ValueNotFound e) { - LOGGER.error("Could not find contributions", e); - //throw new RuntimeException(e); - return Stream.empty(); - } - }; - } - - private static Supplier> getDynamicColorContributionSupplier(String uri, String expressionText) { - return () -> { - try { - @SuppressWarnings("unchecked") - List result = (List) SCLOsgi.MODULE_REPOSITORY.getValue(uri, expressionText); - return result.stream();//result.stream().map(DynamicColorContribution::fromTuple9); - } catch (ValueNotFound e) { - LOGGER.error("Could not find contributions", e); - //throw new RuntimeException(e); - return Stream.empty(); - } - }; - } - private static Supplier> getDynamicEdgeArrowContributionSupplier(String uri, String expressionText) { + private static Supplier> getContributionSupplier(String uri, String expressionText) { return () -> { try { @SuppressWarnings("unchecked") - List result = (List) SCLOsgi.MODULE_REPOSITORY.getValue(uri, expressionText); + List result = (List) SCLOsgi.MODULE_REPOSITORY.getValue(uri, expressionText); return result.stream();//result.stream().map(DynamicColorContribution::fromTuple9); } catch (ValueNotFound e) { - LOGGER.error("Could not find contributions", e); + LOGGER.trace("Could not find contributions for module {} and expression {}", uri, expressionText, e); //throw new RuntimeException(e); return Stream.empty(); } }; } - private static Supplier> getDynamicSizeContributionSupplier(String uri, String expressionText) { - return () -> { - try { - @SuppressWarnings("unchecked") - List result = (List) SCLOsgi.MODULE_REPOSITORY.getValue(uri, expressionText); - return result.stream();//result.stream().map(DynamicColorContribution::fromTuple9); - } catch (ValueNotFound e) { - LOGGER.error("Could not find contributions", e); - //throw new RuntimeException(e); - return Stream.empty(); - } - }; - } - public static class DynamicArrowObject { private final NamedResource arrowObject; diff --git a/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicVisualisation.java b/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicVisualisation.java index 6202e2de..ca577323 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicVisualisation.java +++ b/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicVisualisation.java @@ -13,7 +13,7 @@ public class DynamicVisualisation { private final Resource visualisationResource; private final long interval; - private final boolean disabled; + private final boolean disabledUpdates; private final Map colorContributions; private final Map defaultColorContributions; @@ -39,9 +39,12 @@ public class DynamicVisualisation { private final boolean dynamicSymbolsShutoffValves; private final boolean dynamicSymbolsValves; private final boolean dynamicSymbolsPumpingStations; + private boolean keyVariablesVertexHover; + private boolean keyVariablesEdgesHover; + private boolean resetVisualisation; public DynamicVisualisation(String name, Resource visualisationResource, long interval, boolean disabled, - Map colorContributions, + boolean resetVisualisation, Map colorContributions, Map defaultColoringObjects, ColorBarOptions colorBarOptions, Map sizeContributions, Map defaultSizingObjects, SizeBarOptions sizeBarOptions, @@ -59,12 +62,15 @@ public class DynamicVisualisation { boolean dynamicSymbolsProducers, boolean dynamicSymbolsShutoffValves, boolean dynamicSymbolsValves, - boolean dynamicSymbolsPumpingStations + boolean dynamicSymbolsPumpingStations, + boolean keyVariablesVertexHover, + boolean keyVariablesEdgesHover ) { this.name = name; this.visualisationResource = visualisationResource; this.interval = interval; - this.disabled = disabled; + this.disabledUpdates = disabled; + this.resetVisualisation = resetVisualisation; this.colorContributions = colorContributions; this.defaultColorContributions = defaultColoringObjects; this.colorBarOptions = colorBarOptions; @@ -88,6 +94,9 @@ public class DynamicVisualisation { this.dynamicSymbolsPumpingStations = dynamicSymbolsPumpingStations; this.dynamicSymbolsShutoffValves = dynamicSymbolsShutoffValves; this.dynamicSymbolsValves = dynamicSymbolsValves; + + this.keyVariablesVertexHover = keyVariablesVertexHover; + this.keyVariablesEdgesHover = keyVariablesEdgesHover; } public String getName() { @@ -186,7 +195,19 @@ public class DynamicVisualisation { return interval; } - public boolean disabled() { - return disabled; + public boolean disabledUpdates() { + return disabledUpdates; + } + + public boolean isKeyVariablesVertexHover() { + return keyVariablesVertexHover; + } + + public boolean isKeyVariablesEdgesHover() { + return keyVariablesEdgesHover; + } + + public boolean isResetVisualisation() { + return resetVisualisation; } } -- 2.45.2