From: jsimomaa Date: Wed, 16 Oct 2019 19:18:19 +0000 (+0300) Subject: Dynamic Visualisations view improvements & profile refactoring X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=74600320e9ef95377a2e0acee5d445334e1e55e5;p=simantics%2Fdistrict.git Dynamic Visualisations view improvements & profile refactoring gitlab #59 Change-Id: Ia25743a5853b9dcc38dde1b58d690e25bf71637b (cherry picked from commit 6b98761b9c2e9835629d2c0aabefe92657d6d36b) --- diff --git a/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph b/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph index b16248f2..811fd18b 100644 --- a/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph +++ b/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph @@ -237,12 +237,40 @@ DN.Diagram.Visualisations -- DN.Diagram.Visualisations.SizeBarSize @defProperty "Size Bar Size" L0.String + >-- DN.Diagram.Visualisations.HideEdges + @defProperty "Hide Edges" L0.String + >-- DN.Diagram.Visualisations.HidePoints + @defProperty "Hide Points" L0.String + >-- DN.Diagram.Visualisations.HideConsumers + @defProperty "Hide Consumers" L0.String + >-- DN.Diagram.Visualisations.HideProducers + @defProperty "Hide Producers" L0.String + >-- DN.Diagram.Visualisations.HideValves + @defProperty "Hide Valves" L0.String + >-- DN.Diagram.Visualisations.HidePumpingStations + @defProperty "Hide Pumping Stations" L0.String + >-- DN.Diagram.Visualisations.StaticPropertiesNetworkBranches + @defProperty "Static Properties Network Branches" L0.String + >-- DN.Diagram.Visualisations.StaticPropertiesPoints + @defProperty "Static Properties Points" L0.String + >-- DN.Diagram.Visualisations.StaticPropertiesConsumers + @defProperty "Static Properties Consumers" L0.String + >-- DN.Diagram.Visualisations.DynamicSymbolsShutoffValves + @defProperty "Dynamic Symbols Shutoff Valves" L0.String + >-- DN.Diagram.Visualisations.DynamicSymbolsProducers + @defProperty "Dynamic Symbols Producers" L0.String + >-- DN.Diagram.Visualisations.DynamicSymbolsValves + @defProperty "Dynamic Symbols Valves" L0.String + >-- DN.Diagram.Visualisations.DynamicSymbolsPumpingStations + @defProperty "Dynamic Symbols Pumping Stations" L0.String DN.Diagram.Visualisations.ColorContribution -- DN.Diagram.arrowLengthGain ==> "Double" -- DN.Diagram.arrowLengthBias ==> "Double" -- DN.Diagram.arrowLengthProperty --> DN.Edge.ArrowLengthProperty -- DN.Diagram.backgroundColor --> DATATYPES.RGB.Integer -- DN.Diagram.drawMapEnabled ==> "Boolean" -- DN.Diagram.profileUpdateInterval ==> "Long" Maybe Double" - -DN.Edge.ArrowLengthProperty.FlowRate : DN.Edge.ArrowLengthProperty - L0.HasLabel "Nominal Mass Flow" - DN.Edge.ArrowLengthProperty.value - DN.Functions.hasNominalMassFlowValue - DN.Edge.ArrowLengthProperty.gain 1.0 diff --git a/org.simantics.district.network.ontology/src/org/simantics/district/network/ontology/DistrictNetworkResource.java b/org.simantics.district.network.ontology/src/org/simantics/district/network/ontology/DistrictNetworkResource.java index 1dab3bd8..89087af1 100644 --- a/org.simantics.district.network.ontology/src/org/simantics/district/network/ontology/DistrictNetworkResource.java +++ b/org.simantics.district.network.ontology/src/org/simantics/district/network/ontology/DistrictNetworkResource.java @@ -27,11 +27,32 @@ public class DistrictNetworkResource { public final Resource Diagram_MappedDiagram; public final Resource Diagram_MappedFromDiagram; public final Resource Diagram_Visualisations; + public final Resource Diagram_Visualisations_ArrowContribution; public final Resource Diagram_Visualisations_ColorBarLocation; public final Resource Diagram_Visualisations_ColorBarLocation_Inverse; public final Resource Diagram_Visualisations_ColorBarSize; public final Resource Diagram_Visualisations_ColorBarSize_Inverse; public final Resource Diagram_Visualisations_ColorContribution; + public final Resource Diagram_Visualisations_DynamicSymbolsProducers; + public final Resource Diagram_Visualisations_DynamicSymbolsProducers_Inverse; + public final Resource Diagram_Visualisations_DynamicSymbolsPumpingStations; + public final Resource Diagram_Visualisations_DynamicSymbolsPumpingStations_Inverse; + public final Resource Diagram_Visualisations_DynamicSymbolsShutoffValves; + public final Resource Diagram_Visualisations_DynamicSymbolsShutoffValves_Inverse; + public final Resource Diagram_Visualisations_DynamicSymbolsValves; + public final Resource Diagram_Visualisations_DynamicSymbolsValves_Inverse; + public final Resource Diagram_Visualisations_HideConsumers; + public final Resource Diagram_Visualisations_HideConsumers_Inverse; + public final Resource Diagram_Visualisations_HideEdges; + public final Resource Diagram_Visualisations_HideEdges_Inverse; + public final Resource Diagram_Visualisations_HidePoints; + public final Resource Diagram_Visualisations_HidePoints_Inverse; + public final Resource Diagram_Visualisations_HideProducers; + public final Resource Diagram_Visualisations_HideProducers_Inverse; + public final Resource Diagram_Visualisations_HidePumpingStations; + public final Resource Diagram_Visualisations_HidePumpingStations_Inverse; + public final Resource Diagram_Visualisations_HideValves; + public final Resource Diagram_Visualisations_HideValves_Inverse; public final Resource Diagram_Visualisations_ShowColorBarTicks; public final Resource Diagram_Visualisations_ShowColorBarTicks_Inverse; public final Resource Diagram_Visualisations_ShowColorBars; @@ -45,10 +66,34 @@ public class DistrictNetworkResource { public final Resource Diagram_Visualisations_SizeBarSize; public final Resource Diagram_Visualisations_SizeBarSize_Inverse; public final Resource Diagram_Visualisations_SizeContribution; + public final Resource Diagram_Visualisations_StaticPropertiesConsumers; + public final Resource Diagram_Visualisations_StaticPropertiesConsumers_Inverse; + public final Resource Diagram_Visualisations_StaticPropertiesNetworkBranches; + public final Resource Diagram_Visualisations_StaticPropertiesNetworkBranches_Inverse; + public final Resource Diagram_Visualisations_StaticPropertiesPoints; + public final Resource Diagram_Visualisations_StaticPropertiesPoints_Inverse; public final Resource Diagram_Visualisations_UseColorBarGradients; public final Resource Diagram_Visualisations_UseColorBarGradients_Inverse; public final Resource Diagram_Visualisations_UseSizeBarGradients; public final Resource Diagram_Visualisations_UseSizeBarGradients_Inverse; + public final Resource Diagram_Visualisations_arrowContributionContributorName; + public final Resource Diagram_Visualisations_arrowContributionContributorName_Inverse; + public final Resource Diagram_Visualisations_arrowContributionLabel; + public final Resource Diagram_Visualisations_arrowContributionLabel_Inverse; + public final Resource Diagram_Visualisations_arrowContributionModuleAttribute; + public final Resource Diagram_Visualisations_arrowContributionModuleAttribute_Inverse; + public final Resource Diagram_Visualisations_arrowContributionModuleName; + public final Resource Diagram_Visualisations_arrowContributionModuleName_Inverse; + public final Resource Diagram_Visualisations_arrowContributionUseDefault; + public final Resource Diagram_Visualisations_arrowContributionUseDefault_Inverse; + public final Resource Diagram_Visualisations_arrowContributionUsed; + public final Resource Diagram_Visualisations_arrowContributionUsed_Inverse; + public final Resource Diagram_Visualisations_arrowContributionVariableBias; + public final Resource Diagram_Visualisations_arrowContributionVariableBias_Inverse; + public final Resource Diagram_Visualisations_arrowContributionVariableGain; + public final Resource Diagram_Visualisations_arrowContributionVariableGain_Inverse; + public final Resource Diagram_Visualisations_arrowContributions; + public final Resource Diagram_Visualisations_arrowContributions_Inverse; public final Resource Diagram_Visualisations_colorContributionContributorName; public final Resource Diagram_Visualisations_colorContributionContributorName_Inverse; public final Resource Diagram_Visualisations_colorContributionDefaultColorMap; @@ -101,12 +146,6 @@ public class DistrictNetworkResource { public final Resource Diagram_Visualisations_sizeContributionVariableGain_Inverse; public final Resource Diagram_Visualisations_sizeContributions; public final Resource Diagram_Visualisations_sizeContributions_Inverse; - public final Resource Diagram_arrowLengthBias; - public final Resource Diagram_arrowLengthBias_Inverse; - public final Resource Diagram_arrowLengthGain; - public final Resource Diagram_arrowLengthGain_Inverse; - public final Resource Diagram_arrowLengthProperty; - public final Resource Diagram_arrowLengthProperty_Inverse; public final Resource Diagram_backgroundColor; public final Resource Diagram_backgroundColor_Inverse; public final Resource Diagram_drawMapEnabled; @@ -130,7 +169,6 @@ public class DistrictNetworkResource { public final Resource EdgeDefaultMapping_Inverse; public final Resource EdgeMappingParameterType; public final Resource Edge_ArrowLengthProperty; - public final Resource Edge_ArrowLengthProperty_FlowRate; public final Resource Edge_ArrowLengthProperty_bias; public final Resource Edge_ArrowLengthProperty_bias_Inverse; public final Resource Edge_ArrowLengthProperty_gain; @@ -440,11 +478,32 @@ public class DistrictNetworkResource { public static final String Diagram_MappedDiagram = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/MappedDiagram"; public static final String Diagram_MappedFromDiagram = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/MappedFromDiagram"; public static final String Diagram_Visualisations = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations"; + public static final String Diagram_Visualisations_ArrowContribution = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/ArrowContribution"; public static final String Diagram_Visualisations_ColorBarLocation = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/ColorBarLocation"; public static final String Diagram_Visualisations_ColorBarLocation_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/ColorBarLocation/Inverse"; public static final String Diagram_Visualisations_ColorBarSize = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/ColorBarSize"; public static final String Diagram_Visualisations_ColorBarSize_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/ColorBarSize/Inverse"; public static final String Diagram_Visualisations_ColorContribution = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/ColorContribution"; + public static final String Diagram_Visualisations_DynamicSymbolsProducers = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/DynamicSymbolsProducers"; + public static final String Diagram_Visualisations_DynamicSymbolsProducers_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/DynamicSymbolsProducers/Inverse"; + public static final String Diagram_Visualisations_DynamicSymbolsPumpingStations = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/DynamicSymbolsPumpingStations"; + public static final String Diagram_Visualisations_DynamicSymbolsPumpingStations_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/DynamicSymbolsPumpingStations/Inverse"; + public static final String Diagram_Visualisations_DynamicSymbolsShutoffValves = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/DynamicSymbolsShutoffValves"; + public static final String Diagram_Visualisations_DynamicSymbolsShutoffValves_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/DynamicSymbolsShutoffValves/Inverse"; + public static final String Diagram_Visualisations_DynamicSymbolsValves = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/DynamicSymbolsValves"; + public static final String Diagram_Visualisations_DynamicSymbolsValves_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/DynamicSymbolsValves/Inverse"; + public static final String Diagram_Visualisations_HideConsumers = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/HideConsumers"; + public static final String Diagram_Visualisations_HideConsumers_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/HideConsumers/Inverse"; + public static final String Diagram_Visualisations_HideEdges = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/HideEdges"; + public static final String Diagram_Visualisations_HideEdges_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/HideEdges/Inverse"; + public static final String Diagram_Visualisations_HidePoints = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/HidePoints"; + public static final String Diagram_Visualisations_HidePoints_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/HidePoints/Inverse"; + public static final String Diagram_Visualisations_HideProducers = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/HideProducers"; + public static final String Diagram_Visualisations_HideProducers_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/HideProducers/Inverse"; + public static final String Diagram_Visualisations_HidePumpingStations = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/HidePumpingStations"; + public static final String Diagram_Visualisations_HidePumpingStations_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/HidePumpingStations/Inverse"; + public static final String Diagram_Visualisations_HideValves = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/HideValves"; + public static final String Diagram_Visualisations_HideValves_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/HideValves/Inverse"; public static final String Diagram_Visualisations_ShowColorBarTicks = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/ShowColorBarTicks"; public static final String Diagram_Visualisations_ShowColorBarTicks_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/ShowColorBarTicks/Inverse"; public static final String Diagram_Visualisations_ShowColorBars = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/ShowColorBars"; @@ -458,10 +517,34 @@ public class DistrictNetworkResource { public static final String Diagram_Visualisations_SizeBarSize = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/SizeBarSize"; public static final String Diagram_Visualisations_SizeBarSize_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/SizeBarSize/Inverse"; public static final String Diagram_Visualisations_SizeContribution = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/SizeContribution"; + public static final String Diagram_Visualisations_StaticPropertiesConsumers = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/StaticPropertiesConsumers"; + public static final String Diagram_Visualisations_StaticPropertiesConsumers_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/StaticPropertiesConsumers/Inverse"; + public static final String Diagram_Visualisations_StaticPropertiesNetworkBranches = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/StaticPropertiesNetworkBranches"; + public static final String Diagram_Visualisations_StaticPropertiesNetworkBranches_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/StaticPropertiesNetworkBranches/Inverse"; + public static final String Diagram_Visualisations_StaticPropertiesPoints = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/StaticPropertiesPoints"; + public static final String Diagram_Visualisations_StaticPropertiesPoints_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/StaticPropertiesPoints/Inverse"; public static final String Diagram_Visualisations_UseColorBarGradients = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/UseColorBarGradients"; public static final String Diagram_Visualisations_UseColorBarGradients_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/UseColorBarGradients/Inverse"; public static final String Diagram_Visualisations_UseSizeBarGradients = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/UseSizeBarGradients"; public static final String Diagram_Visualisations_UseSizeBarGradients_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/UseSizeBarGradients/Inverse"; + public static final String Diagram_Visualisations_arrowContributionContributorName = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/arrowContributionContributorName"; + public static final String Diagram_Visualisations_arrowContributionContributorName_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/arrowContributionContributorName/Inverse"; + public static final String Diagram_Visualisations_arrowContributionLabel = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/arrowContributionLabel"; + public static final String Diagram_Visualisations_arrowContributionLabel_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/arrowContributionLabel/Inverse"; + public static final String Diagram_Visualisations_arrowContributionModuleAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/arrowContributionModuleAttribute"; + public static final String Diagram_Visualisations_arrowContributionModuleAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/arrowContributionModuleAttribute/Inverse"; + public static final String Diagram_Visualisations_arrowContributionModuleName = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/arrowContributionModuleName"; + public static final String Diagram_Visualisations_arrowContributionModuleName_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/arrowContributionModuleName/Inverse"; + public static final String Diagram_Visualisations_arrowContributionUseDefault = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/arrowContributionUseDefault"; + public static final String Diagram_Visualisations_arrowContributionUseDefault_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/arrowContributionUseDefault/Inverse"; + public static final String Diagram_Visualisations_arrowContributionUsed = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/arrowContributionUsed"; + public static final String Diagram_Visualisations_arrowContributionUsed_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/arrowContributionUsed/Inverse"; + public static final String Diagram_Visualisations_arrowContributionVariableBias = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/arrowContributionVariableBias"; + public static final String Diagram_Visualisations_arrowContributionVariableBias_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/arrowContributionVariableBias/Inverse"; + public static final String Diagram_Visualisations_arrowContributionVariableGain = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/arrowContributionVariableGain"; + public static final String Diagram_Visualisations_arrowContributionVariableGain_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/arrowContributionVariableGain/Inverse"; + public static final String Diagram_Visualisations_arrowContributions = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/arrowContributions"; + public static final String Diagram_Visualisations_arrowContributions_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/arrowContributions/Inverse"; public static final String Diagram_Visualisations_colorContributionContributorName = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/colorContributionContributorName"; public static final String Diagram_Visualisations_colorContributionContributorName_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/colorContributionContributorName/Inverse"; public static final String Diagram_Visualisations_colorContributionDefaultColorMap = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/colorContributionDefaultColorMap"; @@ -514,12 +597,6 @@ public class DistrictNetworkResource { public static final String Diagram_Visualisations_sizeContributionVariableGain_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/sizeContributionVariableGain/Inverse"; public static final String Diagram_Visualisations_sizeContributions = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/sizeContributions"; public static final String Diagram_Visualisations_sizeContributions_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/sizeContributions/Inverse"; - public static final String Diagram_arrowLengthBias = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/arrowLengthBias"; - public static final String Diagram_arrowLengthBias_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/arrowLengthBias/Inverse"; - public static final String Diagram_arrowLengthGain = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/arrowLengthGain"; - public static final String Diagram_arrowLengthGain_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/arrowLengthGain/Inverse"; - public static final String Diagram_arrowLengthProperty = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/arrowLengthProperty"; - public static final String Diagram_arrowLengthProperty_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/arrowLengthProperty/Inverse"; public static final String Diagram_backgroundColor = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/backgroundColor"; public static final String Diagram_backgroundColor_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/backgroundColor/Inverse"; public static final String Diagram_drawMapEnabled = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/drawMapEnabled"; @@ -543,7 +620,6 @@ public class DistrictNetworkResource { public static final String EdgeDefaultMapping_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/EdgeDefaultMapping/Inverse"; public static final String EdgeMappingParameterType = "http://www.simantics.org/DistrictNetwork-1.0/EdgeMappingParameterType"; public static final String Edge_ArrowLengthProperty = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ArrowLengthProperty"; - public static final String Edge_ArrowLengthProperty_FlowRate = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ArrowLengthProperty/FlowRate"; public static final String Edge_ArrowLengthProperty_bias = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ArrowLengthProperty/bias"; public static final String Edge_ArrowLengthProperty_bias_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ArrowLengthProperty/bias/Inverse"; public static final String Edge_ArrowLengthProperty_gain = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ArrowLengthProperty/gain"; @@ -863,11 +939,32 @@ public class DistrictNetworkResource { Diagram_MappedDiagram = getResourceOrNull(graph, URIs.Diagram_MappedDiagram); Diagram_MappedFromDiagram = getResourceOrNull(graph, URIs.Diagram_MappedFromDiagram); Diagram_Visualisations = getResourceOrNull(graph, URIs.Diagram_Visualisations); + Diagram_Visualisations_ArrowContribution = getResourceOrNull(graph, URIs.Diagram_Visualisations_ArrowContribution); Diagram_Visualisations_ColorBarLocation = getResourceOrNull(graph, URIs.Diagram_Visualisations_ColorBarLocation); Diagram_Visualisations_ColorBarLocation_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_ColorBarLocation_Inverse); Diagram_Visualisations_ColorBarSize = getResourceOrNull(graph, URIs.Diagram_Visualisations_ColorBarSize); Diagram_Visualisations_ColorBarSize_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_ColorBarSize_Inverse); Diagram_Visualisations_ColorContribution = getResourceOrNull(graph, URIs.Diagram_Visualisations_ColorContribution); + Diagram_Visualisations_DynamicSymbolsProducers = getResourceOrNull(graph, URIs.Diagram_Visualisations_DynamicSymbolsProducers); + Diagram_Visualisations_DynamicSymbolsProducers_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_DynamicSymbolsProducers_Inverse); + Diagram_Visualisations_DynamicSymbolsPumpingStations = getResourceOrNull(graph, URIs.Diagram_Visualisations_DynamicSymbolsPumpingStations); + Diagram_Visualisations_DynamicSymbolsPumpingStations_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_DynamicSymbolsPumpingStations_Inverse); + Diagram_Visualisations_DynamicSymbolsShutoffValves = getResourceOrNull(graph, URIs.Diagram_Visualisations_DynamicSymbolsShutoffValves); + Diagram_Visualisations_DynamicSymbolsShutoffValves_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_DynamicSymbolsShutoffValves_Inverse); + Diagram_Visualisations_DynamicSymbolsValves = getResourceOrNull(graph, URIs.Diagram_Visualisations_DynamicSymbolsValves); + Diagram_Visualisations_DynamicSymbolsValves_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_DynamicSymbolsValves_Inverse); + Diagram_Visualisations_HideConsumers = getResourceOrNull(graph, URIs.Diagram_Visualisations_HideConsumers); + Diagram_Visualisations_HideConsumers_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_HideConsumers_Inverse); + Diagram_Visualisations_HideEdges = getResourceOrNull(graph, URIs.Diagram_Visualisations_HideEdges); + Diagram_Visualisations_HideEdges_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_HideEdges_Inverse); + Diagram_Visualisations_HidePoints = getResourceOrNull(graph, URIs.Diagram_Visualisations_HidePoints); + Diagram_Visualisations_HidePoints_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_HidePoints_Inverse); + Diagram_Visualisations_HideProducers = getResourceOrNull(graph, URIs.Diagram_Visualisations_HideProducers); + Diagram_Visualisations_HideProducers_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_HideProducers_Inverse); + Diagram_Visualisations_HidePumpingStations = getResourceOrNull(graph, URIs.Diagram_Visualisations_HidePumpingStations); + Diagram_Visualisations_HidePumpingStations_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_HidePumpingStations_Inverse); + Diagram_Visualisations_HideValves = getResourceOrNull(graph, URIs.Diagram_Visualisations_HideValves); + Diagram_Visualisations_HideValves_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_HideValves_Inverse); Diagram_Visualisations_ShowColorBarTicks = getResourceOrNull(graph, URIs.Diagram_Visualisations_ShowColorBarTicks); Diagram_Visualisations_ShowColorBarTicks_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_ShowColorBarTicks_Inverse); Diagram_Visualisations_ShowColorBars = getResourceOrNull(graph, URIs.Diagram_Visualisations_ShowColorBars); @@ -881,10 +978,34 @@ public class DistrictNetworkResource { Diagram_Visualisations_SizeBarSize = getResourceOrNull(graph, URIs.Diagram_Visualisations_SizeBarSize); Diagram_Visualisations_SizeBarSize_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_SizeBarSize_Inverse); Diagram_Visualisations_SizeContribution = getResourceOrNull(graph, URIs.Diagram_Visualisations_SizeContribution); + Diagram_Visualisations_StaticPropertiesConsumers = getResourceOrNull(graph, URIs.Diagram_Visualisations_StaticPropertiesConsumers); + Diagram_Visualisations_StaticPropertiesConsumers_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_StaticPropertiesConsumers_Inverse); + Diagram_Visualisations_StaticPropertiesNetworkBranches = getResourceOrNull(graph, URIs.Diagram_Visualisations_StaticPropertiesNetworkBranches); + Diagram_Visualisations_StaticPropertiesNetworkBranches_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_StaticPropertiesNetworkBranches_Inverse); + Diagram_Visualisations_StaticPropertiesPoints = getResourceOrNull(graph, URIs.Diagram_Visualisations_StaticPropertiesPoints); + Diagram_Visualisations_StaticPropertiesPoints_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_StaticPropertiesPoints_Inverse); Diagram_Visualisations_UseColorBarGradients = getResourceOrNull(graph, URIs.Diagram_Visualisations_UseColorBarGradients); Diagram_Visualisations_UseColorBarGradients_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_UseColorBarGradients_Inverse); Diagram_Visualisations_UseSizeBarGradients = getResourceOrNull(graph, URIs.Diagram_Visualisations_UseSizeBarGradients); Diagram_Visualisations_UseSizeBarGradients_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_UseSizeBarGradients_Inverse); + Diagram_Visualisations_arrowContributionContributorName = getResourceOrNull(graph, URIs.Diagram_Visualisations_arrowContributionContributorName); + Diagram_Visualisations_arrowContributionContributorName_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_arrowContributionContributorName_Inverse); + Diagram_Visualisations_arrowContributionLabel = getResourceOrNull(graph, URIs.Diagram_Visualisations_arrowContributionLabel); + Diagram_Visualisations_arrowContributionLabel_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_arrowContributionLabel_Inverse); + Diagram_Visualisations_arrowContributionModuleAttribute = getResourceOrNull(graph, URIs.Diagram_Visualisations_arrowContributionModuleAttribute); + Diagram_Visualisations_arrowContributionModuleAttribute_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_arrowContributionModuleAttribute_Inverse); + Diagram_Visualisations_arrowContributionModuleName = getResourceOrNull(graph, URIs.Diagram_Visualisations_arrowContributionModuleName); + Diagram_Visualisations_arrowContributionModuleName_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_arrowContributionModuleName_Inverse); + Diagram_Visualisations_arrowContributionUseDefault = getResourceOrNull(graph, URIs.Diagram_Visualisations_arrowContributionUseDefault); + Diagram_Visualisations_arrowContributionUseDefault_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_arrowContributionUseDefault_Inverse); + Diagram_Visualisations_arrowContributionUsed = getResourceOrNull(graph, URIs.Diagram_Visualisations_arrowContributionUsed); + Diagram_Visualisations_arrowContributionUsed_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_arrowContributionUsed_Inverse); + Diagram_Visualisations_arrowContributionVariableBias = getResourceOrNull(graph, URIs.Diagram_Visualisations_arrowContributionVariableBias); + Diagram_Visualisations_arrowContributionVariableBias_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_arrowContributionVariableBias_Inverse); + Diagram_Visualisations_arrowContributionVariableGain = getResourceOrNull(graph, URIs.Diagram_Visualisations_arrowContributionVariableGain); + Diagram_Visualisations_arrowContributionVariableGain_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_arrowContributionVariableGain_Inverse); + Diagram_Visualisations_arrowContributions = getResourceOrNull(graph, URIs.Diagram_Visualisations_arrowContributions); + Diagram_Visualisations_arrowContributions_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_arrowContributions_Inverse); Diagram_Visualisations_colorContributionContributorName = getResourceOrNull(graph, URIs.Diagram_Visualisations_colorContributionContributorName); Diagram_Visualisations_colorContributionContributorName_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_colorContributionContributorName_Inverse); Diagram_Visualisations_colorContributionDefaultColorMap = getResourceOrNull(graph, URIs.Diagram_Visualisations_colorContributionDefaultColorMap); @@ -937,12 +1058,6 @@ public class DistrictNetworkResource { Diagram_Visualisations_sizeContributionVariableGain_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_sizeContributionVariableGain_Inverse); Diagram_Visualisations_sizeContributions = getResourceOrNull(graph, URIs.Diagram_Visualisations_sizeContributions); Diagram_Visualisations_sizeContributions_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_sizeContributions_Inverse); - Diagram_arrowLengthBias = getResourceOrNull(graph, URIs.Diagram_arrowLengthBias); - Diagram_arrowLengthBias_Inverse = getResourceOrNull(graph, URIs.Diagram_arrowLengthBias_Inverse); - Diagram_arrowLengthGain = getResourceOrNull(graph, URIs.Diagram_arrowLengthGain); - Diagram_arrowLengthGain_Inverse = getResourceOrNull(graph, URIs.Diagram_arrowLengthGain_Inverse); - Diagram_arrowLengthProperty = getResourceOrNull(graph, URIs.Diagram_arrowLengthProperty); - Diagram_arrowLengthProperty_Inverse = getResourceOrNull(graph, URIs.Diagram_arrowLengthProperty_Inverse); Diagram_backgroundColor = getResourceOrNull(graph, URIs.Diagram_backgroundColor); Diagram_backgroundColor_Inverse = getResourceOrNull(graph, URIs.Diagram_backgroundColor_Inverse); Diagram_drawMapEnabled = getResourceOrNull(graph, URIs.Diagram_drawMapEnabled); @@ -966,7 +1081,6 @@ public class DistrictNetworkResource { EdgeDefaultMapping_Inverse = getResourceOrNull(graph, URIs.EdgeDefaultMapping_Inverse); EdgeMappingParameterType = getResourceOrNull(graph, URIs.EdgeMappingParameterType); Edge_ArrowLengthProperty = getResourceOrNull(graph, URIs.Edge_ArrowLengthProperty); - Edge_ArrowLengthProperty_FlowRate = getResourceOrNull(graph, URIs.Edge_ArrowLengthProperty_FlowRate); Edge_ArrowLengthProperty_bias = getResourceOrNull(graph, URIs.Edge_ArrowLengthProperty_bias); Edge_ArrowLengthProperty_bias_Inverse = getResourceOrNull(graph, URIs.Edge_ArrowLengthProperty_bias_Inverse); Edge_ArrowLengthProperty_gain = getResourceOrNull(graph, URIs.Edge_ArrowLengthProperty_gain); diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/DistrictDiagramViewer.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/DistrictDiagramViewer.java index d932e083..c27b090d 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/DistrictDiagramViewer.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/DistrictDiagramViewer.java @@ -4,6 +4,7 @@ import java.awt.Color; import java.awt.geom.AffineTransform; import java.util.Collections; import java.util.Map; +import java.util.Objects; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; import java.util.function.Supplier; @@ -22,6 +23,7 @@ import org.simantics.district.network.ui.participants.DNPointerInteractor; import org.simantics.district.network.ui.participants.DynamicVisualisationContributionsParticipant; import org.simantics.district.network.ui.participants.ElevationServerParticipant; import org.simantics.district.network.ui.participants.MapRulerPainter; +import org.simantics.district.network.visualisations.DynamicVisualisations; import org.simantics.district.network.visualisations.model.ColorBarOptions; import org.simantics.district.network.visualisations.model.DynamicColorContribution; import org.simantics.district.network.visualisations.model.DynamicSizeContribution; @@ -54,7 +56,6 @@ import org.slf4j.LoggerFactory; public class DistrictDiagramViewer extends DiagramViewer { - @SuppressWarnings("unused") private static final Logger LOGGER = LoggerFactory.getLogger(DistrictDiagramViewer.class); @Override @@ -75,7 +76,13 @@ public class DistrictDiagramViewer extends DiagramViewer { protected String getPopupId() { return "#DistrictDiagramPopup"; } - + + @Override + protected void fillInitialDiagramHints(Resource diagram, IHintContext initialHints) throws DatabaseException { + super.fillInitialDiagramHints(diagram, initialHints); + + } + @Override public void initializeCanvasContext(CanvasContext ctx) { super.initializeCanvasContext(ctx); @@ -227,6 +234,8 @@ public class DistrictDiagramViewer extends DiagramViewer { private Consumer callback; private Supplier isDisposed; + + private Boolean lastResult; public DrawMapEnabledListener(Consumer callback, Supplier isDisposed) { this.callback = callback; @@ -235,7 +244,11 @@ public class DistrictDiagramViewer extends DiagramViewer { @Override public void execute(Boolean result) { - callback.accept(result); + // Minor optimization + if (!Objects.equals(lastResult, result)) { + lastResult = result; + callback.accept(result); + } } @Override @@ -267,6 +280,8 @@ public class DistrictDiagramViewer extends DiagramViewer { private Consumer callback; private Supplier isDisposed; + + private RGB.Integer lastResult; public MapBackgroundColorListener(Consumer callback, Supplier isDisposed) { this.callback = callback; @@ -275,7 +290,10 @@ public class DistrictDiagramViewer extends DiagramViewer { @Override public void execute(RGB.Integer result) { - callback.accept(result); + if (!Objects.equals(lastResult, result)) { + lastResult = result; + callback.accept(result); + } } @Override @@ -299,11 +317,11 @@ public class DistrictDiagramViewer extends DiagramViewer { public ColorBarOptions perform(ReadGraph graph) throws DatabaseException { DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); Resource model = graph.syncRequest(new IndexRoot(parameter)); - Resource vf = DistrictNetworkUtil.getVisualisationFolder(graph, model); + Resource vf = DynamicVisualisations.getVisualisationFolder(graph, model); if (vf != null) { Resource activeVisualisation = graph.getPossibleObject(vf, DN.Diagram_hasActiveVisualisation); if (activeVisualisation != null) { - return DistrictNetworkUtil.colorBarOptions(graph, activeVisualisation); + return DynamicVisualisations.colorBarOptions(graph, activeVisualisation); } } else { LOGGER.debug("No visualisation folder available for model {}", model); @@ -322,11 +340,11 @@ public class DistrictDiagramViewer extends DiagramViewer { public Map perform(ReadGraph graph) throws DatabaseException { DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); Resource model = graph.syncRequest(new IndexRoot(parameter)); - Resource vf = DistrictNetworkUtil.getVisualisationFolder(graph, model); + Resource vf = DynamicVisualisations.getVisualisationFolder(graph, model); if (vf != null) { Resource activeVisualisation = graph.getPossibleObject(vf, DN.Diagram_hasActiveVisualisation); if (activeVisualisation != null) { - return DistrictNetworkUtil.colorContributions(graph, activeVisualisation); + return DynamicVisualisations.colorContributions(graph, activeVisualisation); } } else { LOGGER.debug("No visualisation folder available for model {}", model); @@ -341,6 +359,8 @@ public class DistrictDiagramViewer extends DiagramViewer { private Consumer> callback; private Supplier isDisposed; + + //private Map lastResult public ColoringObjectsListener(Consumer> callback, Supplier isDisposed) { this.callback = callback; @@ -401,11 +421,11 @@ public class DistrictDiagramViewer extends DiagramViewer { public SizeBarOptions perform(ReadGraph graph) throws DatabaseException { DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); Resource model = graph.syncRequest(new IndexRoot(parameter)); - Resource vf = DistrictNetworkUtil.getVisualisationFolder(graph, model); + Resource vf = DynamicVisualisations.getVisualisationFolder(graph, model); if (vf != null) { Resource activeVisualisation = graph.getPossibleObject(vf, DN.Diagram_hasActiveVisualisation); if (activeVisualisation != null) { - return DistrictNetworkUtil.sizeBarOptions(graph, activeVisualisation); + return DynamicVisualisations.sizeBarOptions(graph, activeVisualisation); } } else { LOGGER.debug("No visualisation folder available for model {}", model); @@ -452,11 +472,11 @@ public class DistrictDiagramViewer extends DiagramViewer { public Map perform(ReadGraph graph) throws DatabaseException { DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); Resource model = graph.syncRequest(new IndexRoot(parameter)); - Resource vf = DistrictNetworkUtil.getVisualisationFolder(graph, model); + Resource vf = DynamicVisualisations.getVisualisationFolder(graph, model); if (vf != null) { Resource activeVisualisation = graph.getPossibleObject(vf, DN.Diagram_hasActiveVisualisation); if (activeVisualisation != null) { - return DistrictNetworkUtil.sizeContributions(graph, activeVisualisation); + return DynamicVisualisations.sizeContributions(graph, activeVisualisation); } } else { LOGGER.debug("No visualisation folder available for model {}", model); diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/function/Functions.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/function/Functions.java index 617ed211..14c75030 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/function/Functions.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/function/Functions.java @@ -517,19 +517,6 @@ public class Functions { .collect(Collectors.toList()); } - @SCLValue(type = "ReadGraph -> Resource -> Variable -> b") - public static Object arrowLengthPropertyEnumerationValues(ReadGraph graph, Resource resource, Variable context) throws DatabaseException { - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - return listInstanceNames(graph, context, DN.Edge_ArrowLengthProperty); - } - - @SCLValue(type = "ReadGraph -> Resource -> Variable -> b") - public static Object arrowLengthPropertyModifier(ReadGraph graph, Resource resource, Variable context) throws DatabaseException { - Resource diagram = resolveElement(graph, context); - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - return baseMappingModifier(graph, diagram, DN.Diagram_arrowLengthProperty, DN.Edge_ArrowLengthProperty, context); - } - @SCLValue(type = "ReadGraph -> Resource -> Variable -> b") public static Function1 hasDiameterValue(ReadGraph graph, Resource resource, Variable context) throws DatabaseException { return directPropertyValueFunction(DistrictNetworkResource.getInstance(graph).Edge_HasDiameter, 0); diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/visualisations/DynamicVisualisationsUI.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/visualisations/DynamicVisualisationsUI.java index bc055152..46bea63f 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/visualisations/DynamicVisualisationsUI.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/visualisations/DynamicVisualisationsUI.java @@ -18,14 +18,15 @@ import org.eclipse.jface.dialogs.InputDialog; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.events.FocusAdapter; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; @@ -45,15 +46,17 @@ import org.simantics.db.common.request.WriteRequest; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.util.RemoverUtil; import org.simantics.db.procedure.Listener; -import org.simantics.district.network.DistrictNetworkUtil; import org.simantics.district.network.profile.ActiveDynamicVisualisationsRequest; import org.simantics.district.network.profile.DynamicVisualisationsRequest; +import org.simantics.district.network.visualisations.DynamicVisualisations; import org.simantics.district.network.visualisations.DynamicVisualisationsContributions; +import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicArrowObject; import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicColoringObject; import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicSizingObject; import org.simantics.district.network.visualisations.model.ColorBarOptions; import org.simantics.district.network.visualisations.model.ColorBarOptions.ColorBarsLocation; import org.simantics.district.network.visualisations.model.ColorBarOptions.ColorBarsSize; +import org.simantics.district.network.visualisations.model.DynamicArrowContribution; import org.simantics.district.network.visualisations.model.DynamicColorContribution; import org.simantics.district.network.visualisations.model.DynamicColorMap; import org.simantics.district.network.visualisations.model.DynamicSizeContribution; @@ -67,7 +70,7 @@ import org.simantics.utils.ui.dialogs.ShowError; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class DynamicVisualisationsUI extends Composite { +public class DynamicVisualisationsUI { private static final Logger LOGGER = LoggerFactory.getLogger(DynamicVisualisationsUI.class); @@ -92,23 +95,46 @@ public class DynamicVisualisationsUI extends Composite { private Button removeVisualisationTemplateButton; - public DynamicVisualisationsUI(Composite parent, int style) { - super(parent, style); -// ScrolledComposite scrolledComposite = new ScrolledComposite(this, SWT.V_SCROLL); -// scrolledComposite.setLayout(new GridLayout(1, false)); -// scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); -// -// Composite firstContent = new Composite(scrolledComposite, SWT.NONE); -// firstContent.setLayout(new GridLayout(1, false)); -// firstContent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - defaultInitializeUI(this); + private Composite parent; + + private Button disableUpdatesButton; + + private List>> edgeArrowSuppliers; + + private Button saveVisualisationTemplateAsButton; + + private Button hideEdgesButton; + private Button hidePointsButton; + private Button hideConsumersButton; + private Button hideProducersButton; + private Button hideValvesButton; + private Button hidePumpingStationsButton; + + private Button networkBranchesStaticPropertiesButton; + private Button pointsStaticPropertiesButton; + private Button consumersStaticPropertiesButton; + + private Button dynamicSymbolsEdgesButton; + private Button dynamicSymbolsProducersButton; + private Button dynamicSymbolsValvesButton; + private Button dynamicSymbolsPumpingStationsButton; + + public DynamicVisualisationsUI(Composite parent) { + this.parent = parent; + ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL); + scrolledComposite.setLayout(new GridLayout(1, false)); + scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + Composite firstContent = new Composite(scrolledComposite, SWT.NONE); + firstContent.setLayout(new GridLayout(1, false)); + firstContent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); -// scrolledComposite.setContent(firstContent); -// scrolledComposite.setExpandHorizontal(true); -// scrolledComposite.setExpandVertical(true); -// scrolledComposite.setMinSize(firstContent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); + defaultInitializeUI(firstContent); + scrolledComposite.setContent(firstContent); + scrolledComposite.setExpandHorizontal(true); + scrolledComposite.setExpandVertical(true); + scrolledComposite.setMinSize(firstContent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); } private void defaultInitializeUI(Composite parent) { @@ -135,8 +161,8 @@ public class DynamicVisualisationsUI extends Composite { @Override public void perform(WriteGraph graph) throws DatabaseException { - Resource vf = DistrictNetworkUtil.getVisualisationFolder(graph, parentResource); - DistrictNetworkUtil.setActiveVisualisation(graph, vf, template.getResource()); + Resource vf = DynamicVisualisations.getVisualisationFolder(graph, parentResource); + DynamicVisualisations.setActiveVisualisation(graph, vf, template.getResource()); } }); break; @@ -145,6 +171,21 @@ public class DynamicVisualisationsUI extends Composite { } }); + Composite hideElementsComposite = new Composite(parent, SWT.NONE); + GridDataFactory.fillDefaults().grab(true, false).applyTo(hideElementsComposite); + GridLayoutFactory.fillDefaults().numColumns(1).applyTo(hideElementsComposite); + initializeHideElements(hideElementsComposite); + + Composite staticPropertiesComposite = new Composite(parent, SWT.NONE); + GridDataFactory.fillDefaults().grab(true, false).applyTo(staticPropertiesComposite); + GridLayoutFactory.fillDefaults().numColumns(1).applyTo(staticPropertiesComposite); + initializeStaticProperties(staticPropertiesComposite); + + Composite dynamicSymbolsComposite = new Composite(parent, SWT.NONE); + GridDataFactory.fillDefaults().grab(true, false).applyTo(dynamicSymbolsComposite); + GridLayoutFactory.fillDefaults().numColumns(1).applyTo(dynamicSymbolsComposite); + initializeDynamicSymbols(dynamicSymbolsComposite); + Composite coloringObjectsComposite = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().grab(true, false).applyTo(coloringObjectsComposite); GridLayoutFactory.fillDefaults().numColumns(1).applyTo(coloringObjectsComposite); @@ -165,11 +206,16 @@ public class DynamicVisualisationsUI extends Composite { GridLayoutFactory.fillDefaults().numColumns(1).applyTo(sizeBarsComposite); initializeSizeBars(sizeBarsComposite); + Composite edgeArrowsComposite = new Composite(parent, SWT.NONE); + GridDataFactory.fillDefaults().grab(true, false).applyTo(edgeArrowsComposite); + GridLayoutFactory.fillDefaults().numColumns(1).applyTo(edgeArrowsComposite); + initializeEdgeArrows(edgeArrowsComposite); + Composite buttonBarsComposite = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().grab(true, false).applyTo(buttonBarsComposite); GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonBarsComposite); - Button saveVisualisationTemplateAsButton = new Button(buttonBarsComposite, SWT.NONE); + saveVisualisationTemplateAsButton = new Button(buttonBarsComposite, SWT.NONE); saveVisualisationTemplateAsButton.setText("Save as visualisation template"); saveVisualisationTemplateAsButton.addSelectionListener(new SelectionAdapter() { @@ -190,8 +236,272 @@ public class DynamicVisualisationsUI extends Composite { } }); + disableUpdatesButton = new Button(buttonBarsComposite, SWT.CHECK); + disableUpdatesButton.setText("Disable updates"); + disableUpdatesButton.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + disableUpdates(); + } + }); } + private void initializeHideElements(Composite parent) { + Group group = new Group(parent, SWT.NONE); + group.setText("Hide Elements"); + GridDataFactory.fillDefaults().grab(true, false).applyTo(group); + GridLayoutFactory.fillDefaults().numColumns(8).margins(5, 5).applyTo(group); + + createHideElements(group); + } + + private void createHideElements(Composite parent) { + + hideEdgesButton = new Button(parent, SWT.CHECK); + hideEdgesButton.setText("Edges"); + addSelectionListener(hideEdgesButton); + + hidePointsButton = new Button(parent, SWT.CHECK); + hidePointsButton.setText("Points"); + addSelectionListener(hidePointsButton); + + hideConsumersButton = new Button(parent, SWT.CHECK); + hideConsumersButton.setText("Consumers"); + addSelectionListener(hideConsumersButton); + + hideProducersButton = new Button(parent, SWT.CHECK); + hideProducersButton.setText("Producers"); + addSelectionListener(hideProducersButton); + + hideValvesButton = new Button(parent, SWT.CHECK); + hideValvesButton.setText("Valves"); + addSelectionListener(hideValvesButton); + + hidePumpingStationsButton = new Button(parent, SWT.CHECK); + hidePumpingStationsButton.setText("Pumping Stations"); + addSelectionListener(hidePumpingStationsButton); + } + + private void initializeStaticProperties(Composite parent) { + Group group = new Group(parent, SWT.NONE); + group.setText("Static Properties"); + GridDataFactory.fillDefaults().grab(true, false).applyTo(group); + GridLayoutFactory.fillDefaults().numColumns(8).margins(5, 5).applyTo(group); + + createStaticProperties(group); + } + + private void createStaticProperties(Composite parent) { + + networkBranchesStaticPropertiesButton = new Button(parent, SWT.CHECK); + networkBranchesStaticPropertiesButton.setText("Network Branches"); + addSelectionListener(networkBranchesStaticPropertiesButton); + + pointsStaticPropertiesButton = new Button(parent, SWT.CHECK); + pointsStaticPropertiesButton.setText("Points"); + addSelectionListener(pointsStaticPropertiesButton); + + consumersStaticPropertiesButton = new Button(parent, SWT.CHECK); + consumersStaticPropertiesButton.setText("Consumers"); + addSelectionListener(consumersStaticPropertiesButton); + + } + + private void initializeDynamicSymbols(Composite parent) { + Group group = new Group(parent, SWT.NONE); + group.setText("Dynamic Symbols"); + GridDataFactory.fillDefaults().grab(true, false).applyTo(group); + GridLayoutFactory.fillDefaults().numColumns(8).margins(5, 5).applyTo(group); + + createDynamicSymbols(group); + } + + private void createDynamicSymbols(Composite parent) { + + dynamicSymbolsEdgesButton = new Button(parent, SWT.CHECK); + dynamicSymbolsEdgesButton.setText("Shutoff Valves in Pipes"); + addSelectionListener(dynamicSymbolsEdgesButton); + + dynamicSymbolsProducersButton = new Button(parent, SWT.CHECK); + dynamicSymbolsProducersButton.setText("Producers"); + addSelectionListener(dynamicSymbolsProducersButton); + + dynamicSymbolsValvesButton = new Button(parent, SWT.CHECK); + dynamicSymbolsValvesButton.setText("Valves"); + addSelectionListener(dynamicSymbolsValvesButton); + + dynamicSymbolsPumpingStationsButton = new Button(parent, SWT.CHECK); + dynamicSymbolsPumpingStationsButton.setText("Pumping Stations"); + addSelectionListener(dynamicSymbolsPumpingStationsButton); + } + + private void initializeEdgeArrows(Composite parent) { + Group group = new Group(parent, SWT.NONE); + group.setText("Edge Arrows"); + GridDataFactory.fillDefaults().grab(true, false).applyTo(group); + GridLayoutFactory.fillDefaults().numColumns(6).margins(5, 5).applyTo(group); + + createEdgeArrowsHeaderRow(group); + + edgeArrowSuppliers = new ArrayList<>(); + { + try { + Collection result = Simantics.getSession().syncRequest(new UniqueRead>() { + + @Override + public Collection perform(ReadGraph graph) throws DatabaseException { + return DynamicVisualisationsContributions.dynamicEdgeArrowObjects(graph); + } + }); + + for (DynamicArrowObject object : result) { + edgeArrowSuppliers.add(createEdgeArrowRow(group, object)); + } + } catch (DatabaseException e) { + LOGGER.error("Could not create coloring objecst", e); + } + } + } + + + private void createEdgeArrowsHeaderRow(Composite parent) { + + Label label = new Label(parent, SWT.NONE); + label.setText("Label"); + GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).applyTo(label); + + label = new Label(parent, SWT.NONE); + label.setText("Used"); + GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).applyTo(label); + + label = new Label(parent, SWT.NONE); + label.setText("Variable"); + GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).applyTo(label); + + label = new Label(parent, SWT.NONE); + label.setText("Gain"); + GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).applyTo(label); + + label = new Label(parent, SWT.NONE); + label.setText("Bias"); + GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).applyTo(label); + + label = new Label(parent, SWT.NONE); + label.setText("Default"); + GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).applyTo(label); + } + + private Supplier> createEdgeArrowRow(Composite parent, DynamicArrowObject object) { + + Map arrowContributions = object.getArrowContributions(); + if (arrowContributions.isEmpty()) { + // ok, no point in showing empty combo boxes + return null; + } + + Label label = new Label(parent, SWT.NONE); + label.setText(object.getArrowObject().getName()); + GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(label); + + Button usedButton = new Button(parent, SWT.CHECK); + GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(usedButton); + addSelectionListener(usedButton); + + Combo variableCombo = new Combo(parent, SWT.READ_ONLY); + variableCombo.setItems(arrowContributions.keySet().toArray(new String[arrowContributions.size()])); + addSelectionListener(variableCombo); + + GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(variableCombo); + + Text gainText = new Text(parent, SWT.BORDER); + GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(gainText); + addSelectionListener(gainText); + + Text biasText = new Text(parent, SWT.BORDER); + GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(biasText); + addSelectionListener(biasText); + + Button defaultButton = new Button(parent, SWT.CHECK); + GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(defaultButton); + addSelectionListener(defaultButton); + defaultButton.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + int index = variableCombo.getSelectionIndex(); + if (index >= 0) { + String key = variableCombo.getItem(index); + DynamicArrowContribution cont = arrowContributions.get(key); + + gainText.setText(Double.toString(cont.getDefaultGain())); + gainText.setEnabled(!defaultButton.getSelection()); + biasText.setText(Double.toString(cont.getDefaultBias())); + biasText.setEnabled(!defaultButton.getSelection()); + + } + } + }); + + variableCombo.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + // handle update for others + String key = variableCombo.getItem(variableCombo.getSelectionIndex()); + DynamicArrowContribution cont = arrowContributions.get(key); + + if (gainText.getText().isEmpty()) { + gainText.setText(Double.toString(cont.getDefaultGain())); + } + if (biasText.getText().isEmpty()) { + biasText.setText(Double.toString(cont.getDefaultBias())); + } + + defaultButton.setSelection(true); + } + }); + + arrowRows.put(object.getArrowObject().getName(), new ArrowObjectRow(label, usedButton, variableCombo, gainText, biasText, defaultButton)); + + return new Supplier>() { + + @Override + public Pair get() { + int selectionIndex = variableCombo.getSelectionIndex(); + if (selectionIndex >= 0) { + String key = variableCombo.getItem(selectionIndex); + DynamicArrowContribution cont = arrowContributions.get(key); + if (cont != null) { + String label = variableCombo.getItem(variableCombo.getSelectionIndex()); + + double gain = cont.getDefaultGain(); + String gainS = gainText.getText(); + if (gainS != null && !gainS.isEmpty()) { + gain = Double.parseDouble(gainS); + } + double bias = cont.getDefaultBias(); + String biasS = biasText.getText(); + if (biasS != null && !biasS.isEmpty()) { + bias = Double.parseDouble(biasText.getText()); + } + + DynamicArrowContribution dsc = new DynamicArrowContribution(label, cont.getModuleName(), cont.getAttributeName(), gain, bias); + dsc.setUsed(usedButton.getSelection()); + dsc.setUseDefault(defaultButton.getSelection()); + + return Pair.make(object.getArrowObject().getName(), dsc); + } + } + return null; + } + }; + } + + protected void disableUpdates() { + + } + protected void removeVisualisationTemplate(String name, Optional of) { if (of.isPresent()) { Resource visualisation = of.get(); @@ -243,7 +553,7 @@ public class DynamicVisualisationsUI extends Composite { private void persistVisualisationTemplate(String templateName, Optional existing) throws Exception { - List> colorCollect = colorSuppliers.stream().map(s -> s.get()).filter(Objects::nonNull).collect(Collectors.toList()); + List> colorCollect = colorSuppliers.stream().filter(Objects::nonNull).map(s -> s.get()).filter(Objects::nonNull).collect(Collectors.toList()); String colorLocation = colorLocationCombo.getItem(colorLocationCombo.getSelectionIndex()); String colorSize = colorSizeCombo.getItem(colorSizeCombo.getSelectionIndex()); @@ -255,18 +565,36 @@ public class DynamicVisualisationsUI extends Composite { .withLocation(ColorBarsLocation.valueOf(colorLocation)) .withSize(ColorBarsSize.valueOf(colorSize)); - List> sizeCollect = sizeSuppliers.stream().map(s -> s.get()).filter(Objects::nonNull).collect(Collectors.toList()); + List> sizeCollect = sizeSuppliers.stream().filter(Objects::nonNull).map(s -> s.get()).filter(Objects::nonNull).collect(Collectors.toList()); String sizeLocation = sizeLocationCombo.getItem(sizeLocationCombo.getSelectionIndex()); String sizeSize = sizeSizeCombo.getItem(sizeSizeCombo.getSelectionIndex()); - SizeBarOptions sizeBarOptions = new SizeBarOptions() + final SizeBarOptions sizeBarOptions = new SizeBarOptions() .showSizeBars(showSizeButton.getSelection()) .showSizeBarsTicks(sizeTicksButton.getSelection()) .useGradients(sizeGradientButton.getSelection()) .withLocation(SizeBarsLocation.valueOf(sizeLocation)) .withSize(SizeBarsSize.valueOf(sizeSize)); + List> edgeArrowCollect = edgeArrowSuppliers.stream().filter(Objects::nonNull).map(s -> s.get()).filter(Objects::nonNull).collect(Collectors.toList()); + + boolean hideEdges = hideEdgesButton.getSelection(); + boolean hidePoints = hidePointsButton.getSelection(); + boolean hideConsumers = hideConsumersButton.getSelection(); + boolean hideProducers = hideProducersButton.getSelection(); + boolean hideValves = hideValvesButton.getSelection(); + boolean hidePumpingStations = hidePumpingStationsButton.getSelection(); + + boolean networkBranchesStaticProperties = networkBranchesStaticPropertiesButton.getSelection(); + boolean pointsStaticProperties = pointsStaticPropertiesButton.getSelection(); + boolean consumersStaticProperties = consumersStaticPropertiesButton.getSelection(); + + boolean dynamicSymbolsEdges = dynamicSymbolsEdgesButton.getSelection(); + boolean dynamicSymbolsProducers = dynamicSymbolsProducersButton.getSelection(); + boolean dynamicSymbolsValves = dynamicSymbolsValvesButton.getSelection(); + boolean dynamicSymbolsPumpingStations = dynamicSymbolsPumpingStationsButton.getSelection(); + Simantics.getSession().asyncRequest(new WriteRequest() { @Override @@ -275,14 +603,34 @@ public class DynamicVisualisationsUI extends Composite { if (existing.isPresent()) { exist = existing.get(); } else { - exist = DistrictNetworkUtil.createVisualisation(graph, parentResource, templateName); + exist = DynamicVisualisations.createVisualisation(graph, parentResource, templateName); } + DynamicVisualisations.setColorContributions(graph, exist, colorCollect); + DynamicVisualisations.setColorBarOptions(graph, exist, colorBarOptions); + DynamicVisualisations.setSizeContributions(graph, exist, sizeCollect); + DynamicVisualisations.setSizeBarOptions(graph, exist, sizeBarOptions); + DynamicVisualisations.setEdgeArrowContributions(graph, exist, edgeArrowCollect); + DynamicVisualisations.setHideElements(graph, exist, + hideEdges, + hidePoints, + hideConsumers, + hideProducers, + hideValves, + hidePumpingStations + ); - DistrictNetworkUtil.setColorContributions(graph, exist, colorCollect); + DynamicVisualisations.setStaticProperties(graph, exist, + networkBranchesStaticProperties, + pointsStaticProperties, + consumersStaticProperties + ); - DistrictNetworkUtil.setColorBarOptions(graph, exist, colorBarOptions); - DistrictNetworkUtil.setSizeContributions(graph, exist, sizeCollect); - DistrictNetworkUtil.setSizeBarOptions(graph, exist, sizeBarOptions); + DynamicVisualisations.setDynamicSymbols(graph, exist, + dynamicSymbolsEdges, + dynamicSymbolsProducers, + dynamicSymbolsValves, + dynamicSymbolsPumpingStations + ); } }); } @@ -355,6 +703,7 @@ public class DynamicVisualisationsUI extends Composite { private Map coloringRows = new HashMap<>(); private Map sizingRows = new HashMap<>(); + private Map arrowRows = new HashMap<>(); private VisualisationsListener visualisationsListener; @@ -467,6 +816,43 @@ public class DynamicVisualisationsUI extends Composite { } } + private static class ArrowObjectRow { + + private final Label label; + private final Button usedButton; + private final Combo variableCombo; + private final Text gainText; + private final Text biasText; + private final Button defaultButton; + + public ArrowObjectRow(Label label, Button usedButton, Combo variableCombo, Text gainText, Text biasText, Button defaultButton) { + this.label = label; + this.usedButton = usedButton; + this.variableCombo = variableCombo; + this.gainText = gainText; + this.biasText = biasText; + this.defaultButton = defaultButton; + } + + public void update(DynamicColorContribution colorContribution) { + String[] items = variableCombo.getItems(); + for (int i = 0; i < items.length; i++) { + if (colorContribution.getLabel().equals(items[i])) { + variableCombo.select(i); + break; + } + } + gainText.setText(Double.toString(colorContribution.getDefaultMin())); + biasText.setText(Double.toString(colorContribution.getDefaultMax())); + + usedButton.setSelection(colorContribution.isUsed()); + defaultButton.setSelection(colorContribution.isUseDefault()); + + gainText.setEnabled(!colorContribution.isUseDefault()); + biasText.setEnabled(!colorContribution.isUseDefault()); + } + } + private Supplier> createColoringObjectRow(Composite parent, DynamicColoringObject object, Map colorMaps) { Label label = new Label(parent, SWT.NONE); label.setText(object.getColoringObject().getName()); @@ -929,6 +1315,7 @@ public class DynamicVisualisationsUI extends Composite { this.parentResource = parentResource; updateListening(); } + saveVisualisationTemplateAsButton.setEnabled(parentResource != null); } private void updateListening() { @@ -966,7 +1353,7 @@ public class DynamicVisualisationsUI extends Composite { @Override public boolean isDisposed() { - return disposed || ui.isDisposed(); + return disposed || ui.getParent().isDisposed(); } public void dispose() { @@ -997,7 +1384,7 @@ public class DynamicVisualisationsUI extends Composite { @Override public boolean isDisposed() { - return disposed || ui.isDisposed(); + return disposed ||ui.getParent().isDisposed(); } public void dispose() { @@ -1107,4 +1494,8 @@ public class DynamicVisualisationsUI extends Composite { }); } + + public Composite getParent() { + return parent; + } } diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/visualisations/DynamicVisualisationsView.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/visualisations/DynamicVisualisationsView.java index 6bdf0037..a4e008ae 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/visualisations/DynamicVisualisationsView.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/visualisations/DynamicVisualisationsView.java @@ -16,14 +16,14 @@ public class DynamicVisualisationsView { @PostConstruct public void postConstruct(Composite parent) { - ui = new DynamicVisualisationsUI(parent, 0); + ui = new DynamicVisualisationsUI(parent); Simantics.getSession().asyncRequest(new PossibleActiveModel(Simantics.getProjectResource()), new AsyncListenerAdapter() { @Override public void execute(AsyncReadGraph graph, Resource result) { - if (ui != null && !ui.isDisposed()) { - ui.getDisplay().asyncExec(() -> { + if (ui != null && !ui.getParent().isDisposed()) { + ui.getParent().getDisplay().asyncExec(() -> { ui.setParentResource(result); }); } @@ -31,14 +31,14 @@ public class DynamicVisualisationsView { @Override public boolean isDisposed() { - return ui != null ? ui.isDisposed() : true; + return ui != null ? ui.getParent().isDisposed() : true; } }); } @PreDestroy public void dispose() { - ui.dispose(); + ui.getParent().dispose(); ui = null; } diff --git a/org.simantics.district.network/META-INF/MANIFEST.MF b/org.simantics.district.network/META-INF/MANIFEST.MF index 77e7c464..5ab8e0de 100644 --- a/org.simantics.district.network/META-INF/MANIFEST.MF +++ b/org.simantics.district.network/META-INF/MANIFEST.MF @@ -19,7 +19,9 @@ Require-Bundle: org.simantics.db, org.simantics.maps.elevation.server;bundle-version="1.0.0", org.simantics.modeling, org.simantics.db.indexing, - org.simantics.scl.osgi + org.simantics.scl.osgi, + org.eclipse.collections.eclipse-collections, + org.eclipse.collections.eclipse-collections-api Export-Package: org.simantics.district.network, org.simantics.district.network.changeset, org.simantics.district.network.profile, diff --git a/org.simantics.district.network/scl/Simantics/District/DynamicVisualisations/ArrowContribution.scl b/org.simantics.district.network/scl/Simantics/District/DynamicVisualisations/ArrowContribution.scl new file mode 100644 index 00000000..80ff796c --- /dev/null +++ b/org.simantics.district.network/scl/Simantics/District/DynamicVisualisations/ArrowContribution.scl @@ -0,0 +1,6 @@ + +importJava "org.simantics.district.network.visualisations.model.DynamicArrowContribution" where + data DynamicArrowContribution + + @JavaName "" + dynamicArrowContribution :: String -> String -> String -> Double -> Double -> DynamicArrowContribution \ No newline at end of file diff --git a/org.simantics.district.network/scl/Simantics/District/DynamicVisualisations/ColorContribution.scl b/org.simantics.district.network/scl/Simantics/District/DynamicVisualisations/ColorContribution.scl index 800aa2b8..b7d5ba2c 100644 --- a/org.simantics.district.network/scl/Simantics/District/DynamicVisualisations/ColorContribution.scl +++ b/org.simantics.district.network/scl/Simantics/District/DynamicVisualisations/ColorContribution.scl @@ -17,5 +17,4 @@ importJava "org.simantics.district.network.visualisations.model.DynamicColorCont data DynamicColorContribution @JavaName "" - dynamicColorContribution :: String -> String -> String -> String -> Double -> Double -> DynamicColorMap -> Double -> Double -> DynamicColorContribution - + dynamicColorContribution :: String -> String -> String -> String -> Double -> Double -> DynamicColorMap -> Double -> Double -> DynamicColorContribution \ No newline at end of file diff --git a/org.simantics.district.network/src/org/simantics/district/network/DistrictNetworkUtil.java b/org.simantics.district.network/src/org/simantics/district/network/DistrictNetworkUtil.java index e3fbac6d..0047057c 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/DistrictNetworkUtil.java +++ b/org.simantics.district.network/src/org/simantics/district/network/DistrictNetworkUtil.java @@ -3,12 +3,8 @@ package org.simantics.district.network; import java.awt.geom.Rectangle2D; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.util.Map; -import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -27,7 +23,6 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.db.exception.ManyObjectsForFunctionalRelationException; import org.simantics.db.exception.ServiceException; import org.simantics.db.indexing.IndexUtils; -import org.simantics.db.layer0.QueryIndexUtils; import org.simantics.db.layer0.request.PossibleVariable; import org.simantics.db.layer0.variable.Variable; import org.simantics.diagram.stubs.DiagramResource; @@ -35,24 +30,12 @@ import org.simantics.diagram.synchronization.graph.DiagramGraphUtil; import org.simantics.diagram.synchronization.graph.layer.GraphLayer; import org.simantics.diagram.synchronization.graph.layer.IGraphLayerUtil; import org.simantics.district.network.ontology.DistrictNetworkResource; -import org.simantics.district.network.visualisations.DynamicVisualisationsContributions; -import org.simantics.district.network.visualisations.model.ColorBarOptions; -import org.simantics.district.network.visualisations.model.ColorBarOptions.ColorBarsLocation; -import org.simantics.district.network.visualisations.model.ColorBarOptions.ColorBarsSize; -import org.simantics.district.network.visualisations.model.DynamicColorContribution; -import org.simantics.district.network.visualisations.model.DynamicColorMap; -import org.simantics.district.network.visualisations.model.DynamicSizeContribution; -import org.simantics.district.network.visualisations.model.DynamicSizeMap; -import org.simantics.district.network.visualisations.model.SizeBarOptions; -import org.simantics.district.network.visualisations.model.SizeBarOptions.SizeBarsLocation; -import org.simantics.district.network.visualisations.model.SizeBarOptions.SizeBarsSize; import org.simantics.layer0.Layer0; import org.simantics.maps.elevation.server.SingletonTiffTileInterface; import org.simantics.maps.elevation.server.prefs.MapsElevationServerPreferences; import org.simantics.modeling.ModelingResources; import org.simantics.modeling.adapters.NewCompositeActionFactory; import org.simantics.operation.Layer0X; -import org.simantics.utils.datastructures.Pair; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -404,217 +387,5 @@ public class DistrictNetworkUtil { return results; } - public static ColorBarOptions colorBarOptions(ReadGraph graph, Resource visualisation) throws DatabaseException { - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - if (visualisation != null) { - String colorBarLocation = graph.getPossibleRelatedValue(visualisation, DN.Diagram_Visualisations_ColorBarLocation, Bindings.STRING); - String colorBarSize = graph.getPossibleRelatedValue(visualisation, DN.Diagram_Visualisations_ColorBarSize, Bindings.STRING); - Boolean show = graph.getPossibleRelatedValue(visualisation, DN.Diagram_Visualisations_ShowColorBars, Bindings.BOOLEAN); - Boolean showTicks = graph.getPossibleRelatedValue(visualisation, DN.Diagram_Visualisations_ShowColorBarTicks, Bindings.BOOLEAN); - Boolean useGradients = graph.getPossibleRelatedValue(visualisation, DN.Diagram_Visualisations_UseColorBarGradients, Bindings.BOOLEAN); - if (colorBarLocation != null) { - return new ColorBarOptions() - .showColorBars(show != null ? show : false) - .showColorBarsTicks(showTicks != null ? showTicks : false) - .useGradients(useGradients != null ? useGradients : false) - .withLocation(ColorBarsLocation.valueOf(colorBarLocation)) - .withSize(ColorBarsSize.valueOf(colorBarSize)); - } - } - return ColorBarOptions.useDefault(); - } - - public static void setColorBarOptions(WriteGraph graph, Resource visualisation, ColorBarOptions options) throws DatabaseException { - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - graph.claimLiteral(visualisation, DN.Diagram_Visualisations_ColorBarLocation, options.getLocation().toString(), Bindings.STRING); - graph.claimLiteral(visualisation, DN.Diagram_Visualisations_ColorBarSize, options.getSize().toString(), Bindings.STRING); - graph.claimLiteral(visualisation, DN.Diagram_Visualisations_ShowColorBars, options.isShowColorBars(), Bindings.BOOLEAN); - graph.claimLiteral(visualisation, DN.Diagram_Visualisations_ShowColorBarTicks, options.isShowColorBarsTicks(), Bindings.BOOLEAN); - graph.claimLiteral(visualisation, DN.Diagram_Visualisations_UseColorBarGradients, options.isUseGradients(), Bindings.BOOLEAN); - } - - public static Resource createVisualisation(WriteGraph graph, Resource parent, String visualisationName) throws DatabaseException { - Resource vf = getOrCreateVisualisationsFolder(graph, parent); - Layer0 L0 = Layer0.getInstance(graph); - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - Resource visualisation = graph.newResource(); - graph.claim(visualisation, L0.InstanceOf, DN.Diagram_Visualisations); - graph.claimLiteral(visualisation, L0.HasName, visualisationName); - graph.claim(vf, DN.Diagram_hasVisualisation, visualisation); - return visualisation; - } - - public static Resource getOrCreateVisualisationsFolder(WriteGraph graph, Resource model) throws DatabaseException { - Resource rf = getVisualisationFolder(graph, model); - if (rf == null) { - Layer0 L0 = Layer0.getInstance(graph); - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - rf = graph.newResource(); - graph.claim(rf, L0.InstanceOf, null, DN.VisualisationsFolder); - graph.claimLiteral(rf, L0.HasName, L0.NameOf, L0.String, UUID.randomUUID().toString(), Bindings.STRING); - graph.claim(model, L0.ConsistsOf, L0.PartOf, rf); - } - return rf; - } - - public static Resource getVisualisationFolder(ReadGraph graph, Resource model) throws DatabaseException { - List visualisationsFolders = QueryIndexUtils.searchByType(graph, model, DistrictNetworkResource.getInstance(graph).VisualisationsFolder); - if (visualisationsFolders.size() > 0) - return visualisationsFolders.get(0); - return null; - } - - public static SizeBarOptions sizeBarOptions(ReadGraph graph, Resource visualisation) throws DatabaseException { - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - if (visualisation != null) { - String sizeBarLocation = graph.getPossibleRelatedValue(visualisation, DN.Diagram_Visualisations_SizeBarLocation, Bindings.STRING); - String sizeBarSize = graph.getPossibleRelatedValue(visualisation, DN.Diagram_Visualisations_SizeBarSize, Bindings.STRING); - Boolean show = graph.getPossibleRelatedValue(visualisation, DN.Diagram_Visualisations_ShowSizeBars, Bindings.BOOLEAN); - Boolean showTicks = graph.getPossibleRelatedValue(visualisation, DN.Diagram_Visualisations_ShowSizeBarTicks, Bindings.BOOLEAN); - Boolean useGradients = graph.getPossibleRelatedValue(visualisation, DN.Diagram_Visualisations_UseSizeBarGradients, Bindings.BOOLEAN); - if (sizeBarLocation != null) { - return new SizeBarOptions() - .showSizeBars(show != null ? show : false) - .showSizeBarsTicks(showTicks != null ? showTicks : false) - .useGradients(useGradients != null ? useGradients : false) - .withLocation(SizeBarsLocation.valueOf(sizeBarLocation)) - .withSize(SizeBarsSize.valueOf(sizeBarSize)); - } - } - return SizeBarOptions.useDefault(); - } - - public static void setSizeBarOptions(WriteGraph graph, Resource visualisation, SizeBarOptions options) throws DatabaseException { - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - graph.claimLiteral(visualisation, DN.Diagram_Visualisations_SizeBarLocation, options.getLocation().toString(), Bindings.STRING); - graph.claimLiteral(visualisation, DN.Diagram_Visualisations_SizeBarSize, options.getSize().toString(), Bindings.STRING); - graph.claimLiteral(visualisation, DN.Diagram_Visualisations_ShowSizeBars, options.isShowSizeBars(), Bindings.BOOLEAN); - graph.claimLiteral(visualisation, DN.Diagram_Visualisations_ShowSizeBarTicks, options.isShowSizeBarsTicks(), Bindings.BOOLEAN); - graph.claimLiteral(visualisation, DN.Diagram_Visualisations_UseSizeBarGradients, options.isUseGradients(), Bindings.BOOLEAN); - } - - public static Map colorContributions(ReadGraph graph, Resource visualisation) throws DatabaseException { - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - if (visualisation == null) { - return Collections.emptyMap(); - } - Map contributions = new HashMap<>(); - - Map colorMaps = DynamicVisualisationsContributions.dynamicColorMaps(graph); - - Collection colorContributions = graph.getObjects(visualisation, DN.Diagram_Visualisations_colorContributions); - for (Resource colorContribution : colorContributions) { - String ucName = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionContributorName, Bindings.STRING); - String label = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionLabel, Bindings.STRING); - String moduleName = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionModuleName, Bindings.STRING); - String attributeName = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionModuleAttribute, Bindings.STRING); - String unit = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionUnit, Bindings.STRING); - Double variableGain = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionVariableGain, Bindings.DOUBLE); - Double variableBias = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionVariableBias, Bindings.DOUBLE); - String dynamicColorMap = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionDefaultColorMap, Bindings.STRING); - Double defaultMin = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionDefaultMin, Bindings.DOUBLE); - Double defaultMax = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionDefaultMax, Bindings.DOUBLE); - Boolean used = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionUsed, Bindings.BOOLEAN); - Boolean useDefault = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionUseDefault, Bindings.BOOLEAN); - DynamicColorContribution dynamicColorContribution = new DynamicColorContribution(label, moduleName, attributeName, unit, variableGain, variableBias, colorMaps.get(dynamicColorMap), defaultMin, defaultMax); - dynamicColorContribution.setUsed(used != null ? used : false); - dynamicColorContribution.setUseDefault(useDefault != null ? useDefault : false); - contributions.put(ucName, dynamicColorContribution); - } - return contributions; - } - - public static void setColorContributions(WriteGraph graph, Resource visualisation, List> collect) throws DatabaseException { - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - Layer0 L0 = Layer0.getInstance(graph); - - graph.deny(visualisation, DN.Diagram_Visualisations_colorContributions); - for (Pair coll : collect) { - Resource colorContribution = graph.newResource(); - graph.claim(colorContribution, L0.InstanceOf, DN.Diagram_Visualisations_ColorContribution); - graph.claimLiteral(colorContribution, L0.HasName, coll.first); - - DynamicColorContribution contr = coll.second; - graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionContributorName, coll.first, Bindings.STRING); - graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionLabel, contr.getLabel(), Bindings.STRING); - graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionModuleName, contr.getModuleName(), Bindings.STRING); - graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionModuleAttribute, contr.getAttributeName(), Bindings.STRING); - graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionUnit, contr.getUnit(), Bindings.STRING); - graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionVariableGain, contr.getVariableGain(), Bindings.DOUBLE); - graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionVariableBias, contr.getVariableBias(), Bindings.DOUBLE); - graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionDefaultColorMap, contr.getDefaultColorMap().getLabel(), Bindings.STRING); - graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionDefaultMin, contr.getDefaultMin(), Bindings.DOUBLE); - graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionDefaultMax, contr.getDefaultMax(), Bindings.DOUBLE); - graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionUsed, contr.isUsed(), Bindings.BOOLEAN); - graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionUseDefault, contr.isUseDefault(), Bindings.BOOLEAN); - - graph.claim(visualisation, DN.Diagram_Visualisations_colorContributions, colorContribution); - } - } - - public static Map sizeContributions(ReadGraph graph, Resource visualisation) throws DatabaseException { - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - if (visualisation == null) { - return Collections.emptyMap(); - } - Map contributions = new HashMap<>(); - - Map sizeMaps = DynamicVisualisationsContributions.dynamicSizeMaps(graph); - - Collection sizeContributions = graph.getObjects(visualisation, DN.Diagram_Visualisations_sizeContributions); - for (Resource sizeContribution : sizeContributions) { - String ucName = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionContributorName, Bindings.STRING); - String label = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionLabel, Bindings.STRING); - String moduleName = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionModuleName, Bindings.STRING); - String attributeName = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionModuleAttribute, Bindings.STRING); - String unit = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionUnit, Bindings.STRING); - Double variableGain = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionVariableGain, Bindings.DOUBLE); - Double variableBias = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionVariableBias, Bindings.DOUBLE); - String dynamicSizeMap = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionDefaultSizeMap, Bindings.STRING); - Double defaultMin = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionDefaultMin, Bindings.DOUBLE); - Double defaultMax = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionDefaultMax, Bindings.DOUBLE); - Boolean used = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionUsed, Bindings.BOOLEAN); - Boolean useDefault = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionUseDefault, Bindings.BOOLEAN); - DynamicSizeContribution dsc = new DynamicSizeContribution(label, moduleName, attributeName, unit, variableGain, variableBias, sizeMaps.get(dynamicSizeMap), defaultMin, defaultMax); - dsc.setUsed(used != null ? used : false); - dsc.setUseDefault(useDefault != null ? useDefault : false); - contributions.put(ucName, dsc); - } - return contributions; - } - - public static void setSizeContributions(WriteGraph graph, Resource visualisation, List> collect) throws DatabaseException { - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - Layer0 L0 = Layer0.getInstance(graph); - - graph.deny(visualisation, DN.Diagram_Visualisations_sizeContributions); - for (Pair coll : collect) { - Resource sizeContribution = graph.newResource(); - graph.claim(sizeContribution, L0.InstanceOf, DN.Diagram_Visualisations_SizeContribution); - graph.claimLiteral(sizeContribution, L0.HasName, coll.first); - - DynamicSizeContribution contr = coll.second; - graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionContributorName, coll.first, Bindings.STRING); - graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionLabel, contr.getLabel(), Bindings.STRING); - graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionModuleName, contr.getModuleName(), Bindings.STRING); - graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionModuleAttribute, contr.getAttributeName(), Bindings.STRING); - graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionUnit, contr.getUnit(), Bindings.STRING); - graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionVariableGain, contr.getVariableGain(), Bindings.DOUBLE); - graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionVariableBias, contr.getVariableBias(), Bindings.DOUBLE); - graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionDefaultSizeMap, contr.getDefaultSizeMap().getLabel(), Bindings.STRING); - graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionDefaultMin, contr.getDefaultMin(), Bindings.DOUBLE); - graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionDefaultMax, contr.getDefaultMax(), Bindings.DOUBLE); - graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionUsed, contr.isUsed(), Bindings.BOOLEAN); - graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionUseDefault, contr.isUseDefault(), Bindings.BOOLEAN); - - graph.claim(visualisation, DN.Diagram_Visualisations_sizeContributions, sizeContribution); - } - } - - public static void setActiveVisualisation(WriteGraph graph, Resource diagram, Resource visualisationTemplate) throws DatabaseException { - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - graph.deny(diagram, DN.Diagram_hasActiveVisualisation); - graph.claim(diagram, DN.Diagram_hasActiveVisualisation, visualisationTemplate); - } } 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 f8f4b9aa..84bfb739 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 @@ -4,16 +4,19 @@ import java.util.Collection; import java.util.Map; import java.util.stream.Collectors; +import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.request.ResourceRead; import org.simantics.db.exception.DatabaseException; -import org.simantics.district.network.DistrictNetworkUtil; import org.simantics.district.network.ontology.DistrictNetworkResource; +import org.simantics.district.network.visualisations.DynamicVisualisations; import org.simantics.district.network.visualisations.DynamicVisualisationsContributions; +import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicArrowObject; import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicColoringObject; import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicSizingObject; import org.simantics.district.network.visualisations.model.ColorBarOptions; +import org.simantics.district.network.visualisations.model.DynamicArrowContribution; import org.simantics.district.network.visualisations.model.DynamicColorContribution; import org.simantics.district.network.visualisations.model.DynamicSizeContribution; import org.simantics.district.network.visualisations.model.DynamicVisualisation; @@ -32,7 +35,7 @@ public class ActiveDynamicVisualisationsRequest extends ResourceRead dynamicSizingObjects = DynamicVisualisationsContributions.dynamicSizingObjects(graph); Map defaultSizingObjects = dynamicSizingObjects.stream().collect(Collectors.toMap(dcc -> dcc.getSizingObject().getName(), dcc -> dcc)); - Map colorContributions = DistrictNetworkUtil.colorContributions(graph, visualisationResource); - ColorBarOptions colorBarOptions = DistrictNetworkUtil.colorBarOptions(graph, visualisationResource); - Map sizeContributions = DistrictNetworkUtil.sizeContributions(graph, visualisationResource); - SizeBarOptions sizeBarOptions = DistrictNetworkUtil.sizeBarOptions(graph, visualisationResource); - DynamicVisualisation visualisation = new DynamicVisualisation(name, visualisationResource, colorContributions, defaultColoringObjects, colorBarOptions, sizeContributions, defaultSizingObjects, sizeBarOptions); + Collection dynamicArrowObjects = DynamicVisualisationsContributions.dynamicEdgeArrowObjects(graph); + Map defaultArrowObjects = dynamicArrowObjects.stream().collect(Collectors.toMap(dac -> dac.getArrowObject().getName(), dac -> dac)); + + Map colorContributions = DynamicVisualisations.colorContributions(graph, visualisationResource); + ColorBarOptions colorBarOptions = DynamicVisualisations.colorBarOptions(graph, visualisationResource); + Map sizeContributions = DynamicVisualisations.sizeContributions(graph, visualisationResource); + SizeBarOptions sizeBarOptions = DynamicVisualisations.sizeBarOptions(graph, visualisationResource); + Map arrowContributions = DynamicVisualisations.arrowContributions(graph, visualisationResource); + + Boolean hideEdges = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_HideEdges, Bindings.BOOLEAN); + Boolean hidePoints = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_HidePoints, Bindings.BOOLEAN); + Boolean hideConsumers = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_HideConsumers, Bindings.BOOLEAN); + Boolean hideProducers = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_HideProducers, Bindings.BOOLEAN); + Boolean hideValves = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_HideValves, Bindings.BOOLEAN); + Boolean hidePumpingStations = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_HidePumpingStations, Bindings.BOOLEAN); + Boolean staticPropertiesNetworkBranch = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_StaticPropertiesNetworkBranches, Bindings.BOOLEAN); + Boolean staticProperiesPoints = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_StaticPropertiesPoints, Bindings.BOOLEAN); + Boolean staticPropertiesConsumers = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_StaticPropertiesConsumers, Bindings.BOOLEAN); + Boolean dynamicSymbolsProducers = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_DynamicSymbolsProducers, Bindings.BOOLEAN); + Boolean dynamicSymbolsShutoffValves = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_DynamicSymbolsShutoffValves, Bindings.BOOLEAN); + Boolean dynamicSymbolsValves = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_DynamicSymbolsValves, Bindings.BOOLEAN); + Boolean dynamicSymbolsPumpingStations = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_DynamicSymbolsPumpingStations, Bindings.BOOLEAN); + + DynamicVisualisation visualisation = new DynamicVisualisation(name, visualisationResource, + colorContributions, + defaultColoringObjects, + colorBarOptions, + sizeContributions, + defaultSizingObjects, + sizeBarOptions, + defaultArrowObjects, + arrowContributions, + hideEdges != null ? hideEdges : false, + hidePoints != null ? hidePoints : false, + hideConsumers != null ? hideConsumers : false, + hideProducers != null ? hideProducers : false, + hideValves != null ? hideValves : false, + hidePumpingStations != null ? hidePumpingStations : false, + staticPropertiesNetworkBranch != null ? staticPropertiesNetworkBranch : false, + staticProperiesPoints != null ? staticProperiesPoints : false, + staticPropertiesConsumers != null ? staticPropertiesConsumers : false, + dynamicSymbolsProducers != null ? dynamicSymbolsProducers : false, + dynamicSymbolsShutoffValves != null ? dynamicSymbolsShutoffValves : false, + dynamicSymbolsValves != null ? dynamicSymbolsValves : false, + dynamicSymbolsPumpingStations != null ? dynamicSymbolsPumpingStations : false + ); return visualisation; } } diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/ArrowLengthStyle.java b/org.simantics.district.network/src/org/simantics/district/network/profile/ArrowLengthStyle.java index d180d77b..bcbb06eb 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/ArrowLengthStyle.java +++ b/org.simantics.district.network/src/org/simantics/district/network/profile/ArrowLengthStyle.java @@ -1,21 +1,34 @@ package org.simantics.district.network.profile; +import java.util.Map; import java.util.Set; -import org.simantics.Simantics; +import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; +import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener; import org.simantics.db.common.procedure.adapter.TransientCacheListener; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.variable.Variable; +import org.simantics.db.layer0.variable.Variables; +import org.simantics.district.network.ontology.DistrictNetworkResource; +import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicArrowObject; +import org.simantics.district.network.visualisations.model.DynamicArrowContribution; +import org.simantics.district.network.visualisations.model.DynamicVisualisation; import org.simantics.layer0.Layer0; +import org.simantics.modeling.ModelingResources; import org.simantics.scenegraph.INode; import org.simantics.scenegraph.g2d.G2DSceneGraph; import org.simantics.scenegraph.g2d.nodes.ConnectionNode; import org.simantics.scenegraph.profile.EvaluationContext; import org.simantics.scenegraph.profile.common.ProfileVariables; +import org.simantics.scl.runtime.SCLContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ArrowLengthStyle extends ThrottledStyleBase { + private static final Logger LOGGER = LoggerFactory.getLogger(ArrowLengthStyle.class); private static final Double PENDING = Double.NaN; @Override @@ -25,22 +38,81 @@ public class ArrowLengthStyle extends ThrottledStyleBase { if (!edgesToUse.contains(groupItem)) return null; - DiagramSettings ds = graph.syncRequest(new DiagramSettingsRequest(runtimeDiagram), TransientCacheListener.instance()); + DynamicVisualisation dv = graph.syncRequest(new RuntimeDynamicVisualisationsRequest(runtimeDiagram), + TransientCacheAsyncListener.instance()); // Prevent PendingVariableExceptions from coming through boolean wasSynchronous = graph.setSynchronous(true); try { - if (ds.arrowLengthProperty.isPresent()) { - Double length = Simantics.applySCLRead(graph, ds.arrowLengthProperty.get(), groupItem); - return length != null ? length * ds.arrowLengthGain + ds.arrowLengthBias : null; - } - else { - return null; - } - } - finally { - graph.setSynchronous(wasSynchronous); - } - } + if (dv != null) { + Layer0 L0 = Layer0.getInstance(graph); + DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); + ModelingResources MOD = ModelingResources.getInstance(graph); + Resource mapping = graph.getSingleObject(groupItem, DN.HasMapping); + + Map arrowContributions = dv.getArrowContributions(); + String mappingName = graph.getRelatedValue(mapping, L0.HasName); + DynamicArrowContribution dac = arrowContributions.get(mappingName); + if (dac != null && dac.isUsed()) { + + Resource mappedComponent = graph.getPossibleObject(groupItem, DN.MappedComponent); + if (mappedComponent != null) { + + Resource component = graph.getSingleObject(mappedComponent, MOD.ElementToComponent); + Variable variable = Variables.getVariable(graph, component); + Variable possibleActiveVariable = Variables.possibleActiveVariable(graph, variable); + if (possibleActiveVariable != null) { + + Variable module = possibleActiveVariable.getPossibleChild(graph, dac.getModuleName()); + if (module != null) { + Variable attribute = module.getPossibleProperty(graph, dac.getAttributeName()); + if (attribute != null) { + Double possibleValue = attribute.getPossibleValue(graph, Bindings.DOUBLE); + if (possibleValue != null) { + + double biasValue; + double gainValue; + if (dac.isUseDefault()) { + DynamicArrowObject dynamicArrowObject = dv.getDefaultArrowContributions().get(mappingName); + + // This is required if ontology module needs to be compiled + Object currentGraph = SCLContext.getCurrent().get("graph"); + try { + SCLContext.getCurrent().put("graph", graph); + + DynamicArrowContribution ddcc = dynamicArrowObject.getArrowContributions().get(dac.getLabel()); + biasValue = ddcc.getDefaultBias(); + gainValue = ddcc.getDefaultGain(); + } finally { + SCLContext.getCurrent().put("graph", currentGraph); + } + } else { + biasValue = dac.getDefaultBias(); + gainValue = dac.getDefaultGain(); + } + // here we do the adjusting according to spec in #15038 + return possibleValue.doubleValue() * gainValue + biasValue; + } else { + LOGGER.warn("No value for {}", attribute.getURI(graph)); + } + } else { + LOGGER.warn("Wrong attribute name {} for {} !!", dac.getAttributeName(), module.getURI(graph)); + } + } else { + LOGGER.warn("Wrong modulename {} for {} !!", dac.getModuleName(), possibleActiveVariable.getURI(graph)); + } + } else { + LOGGER.debug("No active experiment for {}", variable.getURI(graph)); + } + } else { + LOGGER.debug("No mapped component for {} to calculate dynamic color style", groupItem); + } + } + } + } finally { + graph.setSynchronous(wasSynchronous); + } + return null; + } @Override public void applyThrottledStyleForNode(EvaluationContext observer, INode node, Double value) { diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettings.java b/org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettings.java deleted file mode 100644 index f76a4534..00000000 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettings.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.simantics.district.network.profile; - -import java.util.Optional; - -import org.simantics.db.Resource; -import org.simantics.scl.runtime.function.Function1; - -/** - * @author Tuukka Lehtonen - */ -public class DiagramSettings { - - public final Optional> arrowLengthProperty; - public final double arrowLengthGain; - public final double arrowLengthBias; - - public DiagramSettings( - Function1 arrowLengthProperty, double arrowLengthGain, double arrowLengthBias - ) { - this.arrowLengthProperty = Optional.ofNullable(arrowLengthProperty); - this.arrowLengthGain = arrowLengthGain; - this.arrowLengthBias = arrowLengthBias; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - //result = prime * result + edgeThicknessProperty.hashCode(); - result = prime * result + arrowLengthProperty.hashCode(); - long temp = result; - //temp = Double.doubleToLongBits(edgeThicknessGain); - result = prime * result + (int) (temp ^ (temp >>> 32)); - //temp = Double.doubleToLongBits(edgeThicknessBias); - result = prime * result + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(arrowLengthGain); - result = prime * result + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(arrowLengthBias); - result = prime * result + (int) (temp ^ (temp >>> 32)); - - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - DiagramSettings other = (DiagramSettings) obj; - - if (!arrowLengthProperty.equals(other.arrowLengthProperty)) - return false; - if (Double.doubleToLongBits(arrowLengthGain) != Double.doubleToLongBits(other.arrowLengthGain)) - return false; - if (Double.doubleToLongBits(arrowLengthBias) != Double.doubleToLongBits(other.arrowLengthBias)) - return false; - - return true; - } - - @Override - public String toString() { - return String.format("DiagramSettings[%s * %f + %f]", - arrowLengthProperty, arrowLengthGain, arrowLengthBias - ); - } - -} diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettingsRequest.java b/org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettingsRequest.java deleted file mode 100644 index eac9ce08..00000000 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettingsRequest.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.simantics.district.network.profile; - -import org.simantics.databoard.Bindings; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.request.ResourceRead; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.variable.Variable; -import org.simantics.db.layer0.variable.Variables; -import org.simantics.diagram.stubs.DiagramResource; -import org.simantics.district.network.ontology.DistrictNetworkResource; -import org.simantics.scl.runtime.function.Function1; - -/** - * @author Tuukka Lehtonen - */ -public class DiagramSettingsRequest extends ResourceRead { - - public DiagramSettingsRequest(Resource runtimeDiagram) { - super(runtimeDiagram); - } - - @SuppressWarnings("unchecked") - @Override - public DiagramSettings perform(ReadGraph graph) throws DatabaseException { - DiagramResource DIA = DiagramResource.getInstance(graph); - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - - Function1 arrowLengthProperty = null; - double arrowLengthGain = 1; - double arrowLengthBias = 0; - - Resource diagram = graph.getPossibleObject(resource, DIA.RuntimeDiagram_HasConfiguration); - if (diagram != null) { - Variable dv = Variables.getPossibleVariable(graph, diagram); - - Resource alp = graph.getPossibleObject(diagram, DN.Diagram_arrowLengthProperty); - //System.out.println("alp: " + NameUtils.getURIOrSafeNameInternal(graph, alp)); - if (alp != null) { - Variable alpv = Variables.getPossibleVariable(graph, alp); - if (alpv != null) { - //System.out.println("alpv: " + alpv.getURI(graph)); - arrowLengthProperty = alpv.getPropertyValue(graph, DN.Edge_ArrowLengthProperty_value); - } - - arrowLengthGain = - safeDoubleProperty(graph, alp, DN.Edge_ArrowLengthProperty_gain, 1) - * safeDoubleProperty(graph, diagram, DN.Diagram_arrowLengthGain, 1); - arrowLengthBias = - safeDoubleProperty(graph, alp, DN.Edge_ArrowLengthProperty_bias, 0) - + safeDoubleProperty(graph, diagram, DN.Diagram_arrowLengthBias, 0); - } - - } - - DiagramSettings ds = new DiagramSettings( arrowLengthProperty, arrowLengthGain, arrowLengthBias); - //System.out.println("new diagram settings: " + ds); - return ds; - } - - private static float safeFloatProperty(ReadGraph graph, Resource r, Resource property, float defaultValue) throws DatabaseException { - Float d = graph.getPossibleRelatedValue(r, property, Bindings.FLOAT); - return d != null ? d : defaultValue; - } - - private static double safeDoubleProperty(ReadGraph graph, Resource r, Resource property, double defaultValue) throws DatabaseException { - Double d = graph.getPossibleRelatedValue(r, property, Bindings.DOUBLE); - return d != null ? d : defaultValue; - } - - private static float limit(float min, float max, float value) { - return Math.max(min, Math.min(value, max)); - } - - @SuppressWarnings("unused") - private static double limit(double min, double max, double value) { - return Math.max(min, Math.min(value, max)); - } - -} diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/DynamicVisualisationsRequest.java b/org.simantics.district.network/src/org/simantics/district/network/profile/DynamicVisualisationsRequest.java index c2b473c5..0387029f 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/DynamicVisualisationsRequest.java +++ b/org.simantics.district.network/src/org/simantics/district/network/profile/DynamicVisualisationsRequest.java @@ -11,6 +11,7 @@ import org.simantics.db.common.request.ResourceRead; import org.simantics.db.exception.DatabaseException; import org.simantics.district.network.DistrictNetworkUtil; import org.simantics.district.network.ontology.DistrictNetworkResource; +import org.simantics.district.network.visualisations.DynamicVisualisations; import org.simantics.layer0.Layer0; /** @@ -26,7 +27,7 @@ public class DynamicVisualisationsRequest extends ResourceRead perform(ReadGraph graph) throws DatabaseException { DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); List results = new ArrayList<>(); - Resource visualisationFolder = DistrictNetworkUtil.getVisualisationFolder(graph, resource); + Resource visualisationFolder = DynamicVisualisations.getVisualisationFolder(graph, resource); if (visualisationFolder != null) { Collection visualisationResources = graph.getObjects(visualisationFolder, DN.Diagram_hasVisualisation); if (visualisationResources != null && !visualisationResources.isEmpty()) { diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/HideStyle.java b/org.simantics.district.network/src/org/simantics/district/network/profile/HideStyle.java index d5f57c82..fff5fde5 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/HideStyle.java +++ b/org.simantics.district.network/src/org/simantics/district/network/profile/HideStyle.java @@ -2,8 +2,10 @@ package org.simantics.district.network.profile; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; +import org.simantics.db.common.procedure.adapter.TransientCacheListener; import org.simantics.db.exception.DatabaseException; import org.simantics.diagram.profile.StyleBase; +import org.simantics.district.network.visualisations.model.DynamicVisualisation; import org.simantics.scenegraph.INode; import org.simantics.scenegraph.g2d.nodes.SingleElementNode; import org.simantics.scenegraph.profile.EvaluationContext; @@ -16,6 +18,10 @@ public class HideStyle extends StyleBase { @Override public Boolean calculateStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException { + + DynamicVisualisation dv = graph.syncRequest(new ActiveDynamicVisualisationsRequest(runtimeDiagram), TransientCacheListener.instance()); + + return Boolean.TRUE; } diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/RuntimeDynamicVisualisationsRequest.java b/org.simantics.district.network/src/org/simantics/district/network/profile/RuntimeDynamicVisualisationsRequest.java index 97d23147..bef2afad 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/RuntimeDynamicVisualisationsRequest.java +++ b/org.simantics.district.network/src/org/simantics/district/network/profile/RuntimeDynamicVisualisationsRequest.java @@ -24,7 +24,7 @@ public class RuntimeDynamicVisualisationsRequest extends ResourceRead visualisationsFolders = QueryIndexUtils.searchByType(graph, model, DistrictNetworkResource.getInstance(graph).VisualisationsFolder); + if (visualisationsFolders.size() > 0) + return visualisationsFolders.get(0); + return null; + } + + public static SizeBarOptions sizeBarOptions(ReadGraph graph, Resource visualisation) throws DatabaseException { + DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); + if (visualisation != null) { + String sizeBarLocation = graph.getPossibleRelatedValue(visualisation, DN.Diagram_Visualisations_SizeBarLocation, Bindings.STRING); + String sizeBarSize = graph.getPossibleRelatedValue(visualisation, DN.Diagram_Visualisations_SizeBarSize, Bindings.STRING); + Boolean show = graph.getPossibleRelatedValue(visualisation, DN.Diagram_Visualisations_ShowSizeBars, Bindings.BOOLEAN); + Boolean showTicks = graph.getPossibleRelatedValue(visualisation, DN.Diagram_Visualisations_ShowSizeBarTicks, Bindings.BOOLEAN); + Boolean useGradients = graph.getPossibleRelatedValue(visualisation, DN.Diagram_Visualisations_UseSizeBarGradients, Bindings.BOOLEAN); + if (sizeBarLocation != null) { + return new SizeBarOptions() + .showSizeBars(show != null ? show : false) + .showSizeBarsTicks(showTicks != null ? showTicks : false) + .useGradients(useGradients != null ? useGradients : false) + .withLocation(SizeBarsLocation.valueOf(sizeBarLocation)) + .withSize(SizeBarsSize.valueOf(sizeBarSize)); + } + } + return SizeBarOptions.useDefault(); + } + + public static void setSizeBarOptions(WriteGraph graph, Resource visualisation, SizeBarOptions options) throws DatabaseException { + DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); + graph.claimLiteral(visualisation, DN.Diagram_Visualisations_SizeBarLocation, options.getLocation().toString(), Bindings.STRING); + graph.claimLiteral(visualisation, DN.Diagram_Visualisations_SizeBarSize, options.getSize().toString(), Bindings.STRING); + graph.claimLiteral(visualisation, DN.Diagram_Visualisations_ShowSizeBars, options.isShowSizeBars(), Bindings.BOOLEAN); + graph.claimLiteral(visualisation, DN.Diagram_Visualisations_ShowSizeBarTicks, options.isShowSizeBarsTicks(), Bindings.BOOLEAN); + graph.claimLiteral(visualisation, DN.Diagram_Visualisations_UseSizeBarGradients, options.isUseGradients(), Bindings.BOOLEAN); + } + + public static Map colorContributions(ReadGraph graph, Resource visualisation) throws DatabaseException { + DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); + if (visualisation == null) { + return Collections.emptyMap(); + } + Map contributions = new HashMap<>(); + + Map colorMaps = DynamicVisualisationsContributions.dynamicColorMaps(graph); + + Collection colorContributions = graph.getObjects(visualisation, DN.Diagram_Visualisations_colorContributions); + for (Resource colorContribution : colorContributions) { + String ucName = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionContributorName, Bindings.STRING); + String label = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionLabel, Bindings.STRING); + String moduleName = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionModuleName, Bindings.STRING); + String attributeName = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionModuleAttribute, Bindings.STRING); + String unit = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionUnit, Bindings.STRING); + Double variableGain = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionVariableGain, Bindings.DOUBLE); + Double variableBias = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionVariableBias, Bindings.DOUBLE); + String dynamicColorMap = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionDefaultColorMap, Bindings.STRING); + Double defaultMin = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionDefaultMin, Bindings.DOUBLE); + Double defaultMax = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionDefaultMax, Bindings.DOUBLE); + Boolean used = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionUsed, Bindings.BOOLEAN); + Boolean useDefault = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_colorContributionUseDefault, Bindings.BOOLEAN); + DynamicColorContribution dynamicColorContribution = new DynamicColorContribution(label, moduleName, attributeName, unit, variableGain, variableBias, colorMaps.get(dynamicColorMap), defaultMin, defaultMax); + dynamicColorContribution.setUsed(used != null ? used : false); + dynamicColorContribution.setUseDefault(useDefault != null ? useDefault : false); + contributions.put(ucName, dynamicColorContribution); + } + return contributions; + } + + public static void setColorContributions(WriteGraph graph, Resource visualisation, List> collect) throws DatabaseException { + DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); + Layer0 L0 = Layer0.getInstance(graph); + + graph.deny(visualisation, DN.Diagram_Visualisations_colorContributions); + for (Pair coll : collect) { + Resource colorContribution = graph.newResource(); + graph.claim(colorContribution, L0.InstanceOf, DN.Diagram_Visualisations_ColorContribution); + graph.claimLiteral(colorContribution, L0.HasName, coll.first); + + DynamicColorContribution contr = coll.second; + graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionContributorName, coll.first, Bindings.STRING); + graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionLabel, contr.getLabel(), Bindings.STRING); + graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionModuleName, contr.getModuleName(), Bindings.STRING); + graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionModuleAttribute, contr.getAttributeName(), Bindings.STRING); + graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionUnit, contr.getUnit(), Bindings.STRING); + graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionVariableGain, contr.getVariableGain(), Bindings.DOUBLE); + graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionVariableBias, contr.getVariableBias(), Bindings.DOUBLE); + graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionDefaultColorMap, contr.getDefaultColorMap().getLabel(), Bindings.STRING); + graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionDefaultMin, contr.getDefaultMin(), Bindings.DOUBLE); + graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionDefaultMax, contr.getDefaultMax(), Bindings.DOUBLE); + graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionUsed, contr.isUsed(), Bindings.BOOLEAN); + graph.claimLiteral(colorContribution, DN.Diagram_Visualisations_colorContributionUseDefault, contr.isUseDefault(), Bindings.BOOLEAN); + + graph.claim(visualisation, DN.Diagram_Visualisations_colorContributions, colorContribution); + } + } + + public static void setEdgeArrowContributions(WriteGraph graph, Resource visualisation, List> edgeArrowCollect) throws DatabaseException { + DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); + Layer0 L0 = Layer0.getInstance(graph); + + graph.deny(visualisation, DN.Diagram_Visualisations_arrowContributions); + for (Pair coll : edgeArrowCollect) { + Resource arrowContribution = graph.newResource(); + graph.claim(arrowContribution, L0.InstanceOf, DN.Diagram_Visualisations_ArrowContribution); + graph.claimLiteral(arrowContribution, L0.HasName, coll.first); + + DynamicArrowContribution contr = coll.second; + graph.claimLiteral(arrowContribution, DN.Diagram_Visualisations_arrowContributionContributorName, coll.first, Bindings.STRING); + graph.claimLiteral(arrowContribution, DN.Diagram_Visualisations_arrowContributionLabel, contr.getLabel(), Bindings.STRING); + graph.claimLiteral(arrowContribution, DN.Diagram_Visualisations_arrowContributionModuleName, contr.getModuleName(), Bindings.STRING); + graph.claimLiteral(arrowContribution, DN.Diagram_Visualisations_arrowContributionModuleAttribute, contr.getAttributeName(), Bindings.STRING); + graph.claimLiteral(arrowContribution, DN.Diagram_Visualisations_arrowContributionVariableGain, contr.getDefaultGain(), Bindings.DOUBLE); + graph.claimLiteral(arrowContribution, DN.Diagram_Visualisations_arrowContributionVariableBias, contr.getDefaultBias(), Bindings.DOUBLE); + graph.claimLiteral(arrowContribution, DN.Diagram_Visualisations_arrowContributionUsed, contr.isUsed(), Bindings.BOOLEAN); + graph.claimLiteral(arrowContribution, DN.Diagram_Visualisations_arrowContributionUseDefault, contr.isUseDefault(), Bindings.BOOLEAN); + + graph.claim(visualisation, DN.Diagram_Visualisations_arrowContributions, arrowContribution); + } + } + + public static Map sizeContributions(ReadGraph graph, Resource visualisation) throws DatabaseException { + DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); + if (visualisation == null) { + return Collections.emptyMap(); + } + Map contributions = new HashMap<>(); + + Map sizeMaps = DynamicVisualisationsContributions.dynamicSizeMaps(graph); + + Collection sizeContributions = graph.getObjects(visualisation, DN.Diagram_Visualisations_sizeContributions); + for (Resource sizeContribution : sizeContributions) { + String ucName = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionContributorName, Bindings.STRING); + String label = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionLabel, Bindings.STRING); + String moduleName = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionModuleName, Bindings.STRING); + String attributeName = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionModuleAttribute, Bindings.STRING); + String unit = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionUnit, Bindings.STRING); + Double variableGain = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionVariableGain, Bindings.DOUBLE); + Double variableBias = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionVariableBias, Bindings.DOUBLE); + String dynamicSizeMap = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionDefaultSizeMap, Bindings.STRING); + Double defaultMin = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionDefaultMin, Bindings.DOUBLE); + Double defaultMax = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionDefaultMax, Bindings.DOUBLE); + Boolean used = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionUsed, Bindings.BOOLEAN); + Boolean useDefault = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_sizeContributionUseDefault, Bindings.BOOLEAN); + DynamicSizeContribution dsc = new DynamicSizeContribution(label, moduleName, attributeName, unit, variableGain, variableBias, sizeMaps.get(dynamicSizeMap), defaultMin, defaultMax); + dsc.setUsed(used != null ? used : false); + dsc.setUseDefault(useDefault != null ? useDefault : false); + contributions.put(ucName, dsc); + } + return contributions; + } + + public static Map arrowContributions(ReadGraph graph, Resource visualisation) throws DatabaseException { + DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); + if (visualisation == null) { + return Collections.emptyMap(); + } + Map contributions = new HashMap<>(); + + Collection sizeContributions = graph.getObjects(visualisation, DN.Diagram_Visualisations_arrowContributions); + for (Resource sizeContribution : sizeContributions) { + String ucName = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_arrowContributionContributorName, Bindings.STRING); + String label = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_arrowContributionLabel, Bindings.STRING); + String moduleName = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_arrowContributionModuleName, Bindings.STRING); + String attributeName = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_arrowContributionModuleAttribute, Bindings.STRING); + Double variableGain = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_arrowContributionVariableGain, Bindings.DOUBLE); + Double variableBias = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_arrowContributionVariableBias, Bindings.DOUBLE); + Boolean used = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_arrowContributionUsed, Bindings.BOOLEAN); + Boolean useDefault = graph.getRelatedValue(sizeContribution, DN.Diagram_Visualisations_arrowContributionUseDefault, Bindings.BOOLEAN); + DynamicArrowContribution dac = new DynamicArrowContribution(label, moduleName, attributeName, variableGain, variableBias); + dac.setUsed(used != null ? used : false); + dac.setUseDefault(useDefault != null ? useDefault : false); + contributions.put(ucName, dac); + } + return contributions; + } + + public static void setSizeContributions(WriteGraph graph, Resource visualisation, List> collect) throws DatabaseException { + DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); + Layer0 L0 = Layer0.getInstance(graph); + + graph.deny(visualisation, DN.Diagram_Visualisations_sizeContributions); + for (Pair coll : collect) { + Resource sizeContribution = graph.newResource(); + graph.claim(sizeContribution, L0.InstanceOf, DN.Diagram_Visualisations_SizeContribution); + graph.claimLiteral(sizeContribution, L0.HasName, coll.first); + + DynamicSizeContribution contr = coll.second; + graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionContributorName, coll.first, Bindings.STRING); + graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionLabel, contr.getLabel(), Bindings.STRING); + graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionModuleName, contr.getModuleName(), Bindings.STRING); + graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionModuleAttribute, contr.getAttributeName(), Bindings.STRING); + graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionUnit, contr.getUnit(), Bindings.STRING); + graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionVariableGain, contr.getVariableGain(), Bindings.DOUBLE); + graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionVariableBias, contr.getVariableBias(), Bindings.DOUBLE); + graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionDefaultSizeMap, contr.getDefaultSizeMap().getLabel(), Bindings.STRING); + graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionDefaultMin, contr.getDefaultMin(), Bindings.DOUBLE); + graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionDefaultMax, contr.getDefaultMax(), Bindings.DOUBLE); + graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionUsed, contr.isUsed(), Bindings.BOOLEAN); + graph.claimLiteral(sizeContribution, DN.Diagram_Visualisations_sizeContributionUseDefault, contr.isUseDefault(), Bindings.BOOLEAN); + + graph.claim(visualisation, DN.Diagram_Visualisations_sizeContributions, sizeContribution); + } + } + + public static void setActiveVisualisation(WriteGraph graph, Resource diagram, Resource visualisationTemplate) throws DatabaseException { + DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); + graph.deny(diagram, DN.Diagram_hasActiveVisualisation); + graph.claim(diagram, DN.Diagram_hasActiveVisualisation, visualisationTemplate); + } + + public static void setHideElements(WriteGraph graph, Resource visualisation, + boolean edges, + boolean points, + boolean consumers, + boolean producers, + boolean valves, + boolean pumpingStations) throws DatabaseException { + DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); + graph.claimLiteral(visualisation, DN.Diagram_Visualisations_HideEdges, edges, Bindings.BOOLEAN); + graph.claimLiteral(visualisation, DN.Diagram_Visualisations_HidePoints, points, Bindings.BOOLEAN); + graph.claimLiteral(visualisation, DN.Diagram_Visualisations_HideConsumers, consumers, Bindings.BOOLEAN); + graph.claimLiteral(visualisation, DN.Diagram_Visualisations_HideProducers, producers, Bindings.BOOLEAN); + graph.claimLiteral(visualisation, DN.Diagram_Visualisations_HideValves, valves, Bindings.BOOLEAN); + graph.claimLiteral(visualisation, DN.Diagram_Visualisations_HidePumpingStations, pumpingStations, Bindings.BOOLEAN); + } + + public static void setStaticProperties(WriteGraph graph, Resource visualisation, + boolean networkBranches, + boolean points, + boolean consumers) throws DatabaseException { + DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); + graph.claimLiteral(visualisation, DN.Diagram_Visualisations_StaticPropertiesNetworkBranches, networkBranches, Bindings.BOOLEAN); + graph.claimLiteral(visualisation, DN.Diagram_Visualisations_StaticPropertiesPoints, points, Bindings.BOOLEAN); + graph.claimLiteral(visualisation, DN.Diagram_Visualisations_StaticPropertiesConsumers, consumers, Bindings.BOOLEAN); + } + + public static void setDynamicSymbols(WriteGraph graph, Resource visualisation, + boolean edges, + boolean producers, + boolean valves, + boolean pumpingStations) throws DatabaseException { + DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); + graph.claimLiteral(visualisation, DN.Diagram_Visualisations_DynamicSymbolsProducers, producers, Bindings.BOOLEAN); + graph.claimLiteral(visualisation, DN.Diagram_Visualisations_DynamicSymbolsShutoffValves, edges, Bindings.BOOLEAN); + graph.claimLiteral(visualisation, DN.Diagram_Visualisations_DynamicSymbolsValves, valves, Bindings.BOOLEAN); + graph.claimLiteral(visualisation, DN.Diagram_Visualisations_DynamicSymbolsPumpingStations, pumpingStations, Bindings.BOOLEAN); + } +} diff --git a/org.simantics.district.network/src/org/simantics/district/network/visualisations/DynamicVisualisationsContributions.java b/org.simantics.district.network/src/org/simantics/district/network/visualisations/DynamicVisualisationsContributions.java index 45e52fb5..6c25d237 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/visualisations/DynamicVisualisationsContributions.java +++ b/org.simantics.district.network/src/org/simantics/district/network/visualisations/DynamicVisualisationsContributions.java @@ -17,6 +17,7 @@ import org.simantics.db.common.NamedResource; import org.simantics.db.common.request.ObjectsWithSupertype; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.util.Layer0Utils; +import org.simantics.district.network.visualisations.model.DynamicArrowContribution; import org.simantics.district.network.visualisations.model.DynamicColorContribution; import org.simantics.district.network.visualisations.model.DynamicColorMap; import org.simantics.district.network.visualisations.model.DynamicSizeContribution; @@ -41,6 +42,7 @@ public class DynamicVisualisationsContributions { private static final String DYNAMIC_VISUALISATIONS_CONTRIBUTION_MODULE = "DynamicVisualisationsContribution"; private static final String COLOR_CONTRIBUTION = "colorContribution"; private static final String SIZE_CONTRIBUTION = "sizeContribution"; + private static final String ARROW_CONTRIBUTION = "arrowContribution"; public static Map dynamicColorMaps(ReadGraph graph) throws DatabaseException { List sharedOntologies = Simantics.applySCL("Simantics/SharedOntologies", "getSharedOntologies", graph, Tuple0.INSTANCE); @@ -168,6 +170,35 @@ public class DynamicVisualisationsContributions { return null; } + public static Collection dynamicEdgeArrowObjects(ReadGraph graph) throws DatabaseException { + + List sharedOntologies = Simantics.applySCL("Simantics/SharedOntologies", "getSharedOntologies", graph, Tuple0.INSTANCE); + + List results = new ArrayList<>(); + + for (Resource sharedOntology : sharedOntologies) { + Collection findByType = graph.syncRequest(new ObjectsWithSupertype(sharedOntology, Layer0.getInstance(graph).ConsistsOf, StructuralResource2.getInstance(graph).Component)); + //Collection findByType = QueryIndexUtils.searchByType(graph, sharedOntology, ); + for (Resource find : findByType) { + NamedResource moduleType = new NamedResource(NameLabelUtil.modalName(graph, find), find); + DynamicArrowObject dynamicarrowObject = dynamicEdgeArrowObject(graph, moduleType); + if (dynamicarrowObject != null) + results.add(dynamicarrowObject); + } + } + return results; + } + + private static DynamicArrowObject dynamicEdgeArrowObject(ReadGraph graph, NamedResource moduleType) throws DatabaseException { + Layer0 L0 = Layer0.getInstance(graph); + Resource sclModule = Layer0Utils.getPossibleChild(graph, moduleType.getResource(), L0.SCLModule, DYNAMIC_VISUALISATIONS_CONTRIBUTION_MODULE); + if (sclModule != null) { + String moduleURI = graph.getURI(sclModule); + return new DynamicArrowObject(moduleType, getDynamicEdgeArrowContributionSupplier(moduleURI, ARROW_CONTRIBUTION)); + } + return null; + } + private static Supplier> getDynamicColorMapSupplier(String uri, String expressionText) { return () -> { try { @@ -196,6 +227,20 @@ public class DynamicVisualisationsContributions { }; } + private static Supplier> getDynamicEdgeArrowContributionSupplier(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> getDynamicSizeContributionSupplier(String uri, String expressionText) { return () -> { try { @@ -210,6 +255,28 @@ public class DynamicVisualisationsContributions { }; } + public static class DynamicArrowObject { + + private final NamedResource arrowObject; + private final Supplier> arrowContributionSupplier; + private Map arrowContributions; + + public DynamicArrowObject(NamedResource coloringObject, Supplier> arrowContributionSupplier) { + this.arrowObject = coloringObject; + this.arrowContributionSupplier = arrowContributionSupplier; + } + + public NamedResource getArrowObject() { + return arrowObject; + } + + public Map getArrowContributions() { + if (arrowContributions == null) + arrowContributions = arrowContributionSupplier.get().collect(Collectors.toMap(c -> c.getLabel(), c -> c)); + return arrowContributions; + } + } + public static class DynamicColoringObject { private final NamedResource coloringObject; diff --git a/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicArrowContribution.java b/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicArrowContribution.java new file mode 100644 index 00000000..6e05a999 --- /dev/null +++ b/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicArrowContribution.java @@ -0,0 +1,58 @@ +package org.simantics.district.network.visualisations.model; + +public class DynamicArrowContribution { + + private String label; + private String moduleName; + private String attributeName; + private double variableGain; + private double variableBias; + + // for graph persistence only + private boolean used; + private boolean useDefault; + + public DynamicArrowContribution(String label, String moduleName, String attributeName, double variableGain, double variableBias) { + this.label = label; + this.moduleName = moduleName; + this.attributeName = attributeName; + this.variableGain = variableGain; + this.variableBias = variableBias; + } + + public String getLabel() { + return label; + } + + public String getModuleName() { + return moduleName; + } + + public String getAttributeName() { + return attributeName; + } + + public double getDefaultGain() { + return variableGain; + } + + public double getDefaultBias() { + return variableBias; + } + + public void setUsed(boolean used) { + this.used = used; + } + + public boolean isUsed() { + return used; + } + + public void setUseDefault(boolean useDefault) { + this.useDefault = useDefault; + } + + public boolean isUseDefault() { + return useDefault; + } +} \ No newline at end of file diff --git a/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicColorContribution.java b/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicColorContribution.java index 2839bcc3..db8f1b3d 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicColorContribution.java +++ b/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicColorContribution.java @@ -80,4 +80,9 @@ public class DynamicColorContribution { public boolean isUseDefault() { return useDefault; } + + public double adjustedValue(double value) { + // here we do the adjusting according to spec in #15038 + return value * getVariableGain() + getVariableBias(); + } } \ No newline at end of file diff --git a/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicSizeContribution.java b/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicSizeContribution.java index 009c8c43..9adc4ddd 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicSizeContribution.java +++ b/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicSizeContribution.java @@ -1,5 +1,8 @@ package org.simantics.district.network.visualisations.model; +import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicSizingObject; +import org.simantics.scl.runtime.SCLContext; + public class DynamicSizeContribution { private String label; @@ -80,4 +83,9 @@ public class DynamicSizeContribution { public void setUseDefault(boolean useDefault) { this.useDefault = useDefault; } + + public double adjustedValue(double value) { + // here we do the adjusting according to spec in #15038 + return value * getVariableGain() + getVariableBias(); + } } \ No newline at end of file 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 fa329b86..3903b554 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 @@ -3,22 +3,61 @@ package org.simantics.district.network.visualisations.model; import java.util.Map; import org.simantics.db.Resource; +import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicArrowObject; import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicColoringObject; import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicSizingObject; public class DynamicVisualisation { - private String name; - private Resource visualisationResource; + private final String name; + private final Resource visualisationResource; - private Map colorContributions; - private Map defaultColorContributions; - private ColorBarOptions colorBarOptions; - private Map sizeContributions; - private Map defaultSizeContributions; - private SizeBarOptions sizeBarOptions; + private final Map colorContributions; + private final Map defaultColorContributions; + private final ColorBarOptions colorBarOptions; + private final Map sizeContributions; + private final Map defaultSizeContributions; + private final SizeBarOptions sizeBarOptions; + private final Map defaultArrowContributions; + private final Map arrowContributions; - public DynamicVisualisation(String name, Resource visualisationResource, Map colorContributions, Map defaultColoringObjects, ColorBarOptions colorBarOptions, Map sizeContributions, Map defaultSizingObjects, SizeBarOptions sizeBarOptions) { + private final boolean hideEdges; + private final boolean hidePoints; + private final boolean hideConsumers; + private final boolean hideProducers; + private final boolean hideValves; + private final boolean hidePumpingStations; + + private final boolean staticPropertiesNetworkBranches; + private final boolean staticPropertiesPoints; + private final boolean staticPropertiesConsumers; + + private final boolean dynamicSymbolsProducers; + private final boolean dynamicSymbolsShutoffValves; + private final boolean dynamicSymbolsValves; + private final boolean dynamicSymbolsPumpingStations; + + public DynamicVisualisation(String name, Resource visualisationResource, + Map colorContributions, + Map defaultColoringObjects, ColorBarOptions colorBarOptions, + Map sizeContributions, + Map defaultSizingObjects, SizeBarOptions sizeBarOptions, + Map defaultArrowContributions, + Map arrowContributions, + boolean hideEdges, + boolean hidePoints, + boolean hideConsumers, + boolean hideProducers, + boolean hideValves, + boolean hidePumpingStations, + boolean staticPropertiesNetworkBranch, + boolean staticProperiesPoints, + boolean staticPropertiesConsumers, + boolean dynamicSymbolsProducers, + boolean dynamicSymbolsShutoffValves, + boolean dynamicSymbolsValves, + boolean dynamicSymbolsPumpingStations + ) { this.name = name; this.visualisationResource = visualisationResource; this.colorContributions = colorContributions; @@ -27,6 +66,23 @@ public class DynamicVisualisation { this.sizeContributions = sizeContributions; this.defaultSizeContributions = defaultSizingObjects; this.sizeBarOptions = sizeBarOptions; + this.defaultArrowContributions = defaultArrowContributions; + this.arrowContributions = arrowContributions; + + this.hidePoints = hidePoints; + this.hideConsumers = hideConsumers; + this.hideEdges = hideEdges; + this.hideProducers = hideProducers; + this.hideValves = hideValves; + this.hidePumpingStations = hidePumpingStations; + + this.staticPropertiesConsumers = staticPropertiesConsumers; + this.staticPropertiesNetworkBranches = staticPropertiesNetworkBranch; + this.staticPropertiesPoints = staticProperiesPoints; + this.dynamicSymbolsProducers = dynamicSymbolsProducers; + this.dynamicSymbolsPumpingStations = dynamicSymbolsPumpingStations; + this.dynamicSymbolsShutoffValves = dynamicSymbolsShutoffValves; + this.dynamicSymbolsValves = dynamicSymbolsValves; } public String getName() { @@ -40,7 +96,7 @@ public class DynamicVisualisation { public Map getColorContributions() { return colorContributions; } - + public Map getDefaultColorContributions() { return defaultColorContributions; } @@ -52,7 +108,7 @@ public class DynamicVisualisation { public Map getSizeContributions() { return sizeContributions; } - + public Map getDefaultSizeContributions() { return defaultSizeContributions; } @@ -60,4 +116,64 @@ public class DynamicVisualisation { public SizeBarOptions getSizeBarOptions() { return sizeBarOptions; } + + public Map getDefaultArrowContributions() { + return defaultArrowContributions; + } + + public Map getArrowContributions() { + return arrowContributions; + } + + public boolean isHideEdges() { + return hideEdges; + } + + public boolean isHidePoints() { + return hidePoints; + } + + public boolean isHideConsumers() { + return hideConsumers; + } + + public boolean isHideProducers() { + return hideProducers; + } + + public boolean isHideValves() { + return hideValves; + } + + public boolean isHidePumpingStations() { + return hidePumpingStations; + } + + public boolean isStaticPropertiesNetworkBranches() { + return staticPropertiesNetworkBranches; + } + + public boolean isStaticPropertiesPoints() { + return staticPropertiesPoints; + } + + public boolean isStaticPropertiesConsumers() { + return staticPropertiesConsumers; + } + + public boolean isDynamicSymbolsProducers() { + return dynamicSymbolsProducers; + } + + public boolean isDynamicSymbolsPumpingStations() { + return dynamicSymbolsPumpingStations; + } + + public boolean isDynamicSymbolsShutoffValves() { + return dynamicSymbolsShutoffValves; + } + + public boolean isDynamicSymbolsValves() { + return dynamicSymbolsValves; + } }