From 0249f20bb127e61c58db4432b8609ff0cb441480 Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Wed, 18 Sep 2019 15:33:32 +0300 Subject: [PATCH] DynamicVisualisations enhancements & deprecate old profiles & settings gitlab #59 Change-Id: I98119002af7a031779688c5fb192424c4f9411a4 --- .../graph/DistrictNetwork.pgraph | 4 +- .../DistrictNetworkDiagramSettings.pgraph | 118 +------------- .../graph/DistrictNetworkProfiles.pgraph | 5 +- .../ontology/DistrictNetworkResource.java | 153 ------------------ .../network/ui/function/Functions.java | 28 +--- ...DynamicVisualisationContributionsNode.java | 108 +++++++------ .../DynamicVisualisationsUI.java | 77 ++++++--- org.simantics.district.network/adapters.xml | 6 - .../district/network/DistrictNetworkUtil.java | 28 ++-- .../network/profile/DNElementColorStyle.java | 16 -- .../network/profile/DNElementSizeStyle.java | 2 +- .../network/profile/DiagramSettings.java | 76 ++------- .../profile/DiagramSettingsRequest.java | 59 +------ .../network/profile/EdgeThicknessStyle.java | 66 -------- .../network/profile/ThrottledStyleBase.java | 4 +- .../network/profile/VertexSizeStyle.java | 66 -------- .../visualisations/model/ColorBarOptions.java | 10 ++ .../visualisations/model/SizeBarOptions.java | 10 ++ 18 files changed, 170 insertions(+), 666 deletions(-) delete mode 100644 org.simantics.district.network/src/org/simantics/district/network/profile/EdgeThicknessStyle.java delete mode 100644 org.simantics.district.network/src/org/simantics/district/network/profile/VertexSizeStyle.java diff --git a/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph b/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph index bb3130eb..592053e5 100644 --- a/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph +++ b/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph @@ -139,8 +139,8 @@ DN.Edge -- DN.Edge.HasTGround @defProperty "T Ground" L0.Double - @L0.assert DN.Edge.HasDiameter 0.1 - @L0.assert DN.Edge.HasOuterDiameter 0.11 + @L0.assert DN.Edge.HasDiameter 100 + @L0.assert DN.Edge.HasOuterDiameter 125 // ---------------------------------------------------------------------------- diff --git a/org.simantics.district.network.ontology/graph/DistrictNetworkDiagramSettings.pgraph b/org.simantics.district.network.ontology/graph/DistrictNetworkDiagramSettings.pgraph index 2e259ef7..c3d7cdfe 100644 --- a/org.simantics.district.network.ontology/graph/DistrictNetworkDiagramSettings.pgraph +++ b/org.simantics.district.network.ontology/graph/DistrictNetworkDiagramSettings.pgraph @@ -13,35 +13,12 @@ DATATYPES = // ---------------------------------------------------------------------------- -DN.EdgeThicknessPropertyParameterType -- DN.Edge.ThicknessProperty.value ==> "Resource -> Maybe Double" -- DN.Edge.ThicknessProperty.gain --> L0.Double -- DN.Edge.ThicknessProperty.bias --> L0.Double -- DN.Edge.ArrowLengthProperty.value ==> "Resource -> Maybe Double" -- DN.Vertex.ScaleProperty.value ==> "Resource -> Maybe Double" -- DN.Vertex.ScaleProperty.gain ==> "Double" -- DN.Vertex.ScaleProperty.bias ==> "Double" -- DN.Diagram.elementColoringGradientHue ==> "Float" -- DN.Diagram.elementColoringGradientSaturation ==> "Float" -- DN.Diagram.elementColoringFunction --> L0.String ==> "Resource -> Double" -- DN.Diagram.edgeThicknessGain ==> "Double" -- DN.Diagram.edgeThicknessBias ==> "Double" -- DN.Diagram.edgeThicknessProperty --> DN.Edge.ThicknessProperty -- DN.Diagram.arrowLengthGain ==> "Double" -- DN.Diagram.arrowLengthBias ==> "Double" -- DN.Diagram.arrowLengthProperty --> DN.Edge.ArrowLengthProperty -- DN.Diagram.nodeScaleGain ==> "Double" -- DN.Diagram.nodeScaleBias ==> "Double" -- DN.Diagram.nodeScaleProperty --> DN.Vertex.ScaleProperty -- DN.Diagram.backgroundColor --> DATATYPES.RGB.Integer -- DN.Diagram.drawMapEnabled ==> "Boolean" -- DN.Diagram.hasActiveVisualisation --> DN.Diagram.Visualisations -- DN.Diagram.profileUpdateInterval ==> "Long" 1.0" "Resource -> Double" - @L0.assert DN.Diagram.edgeThicknessGain 1.0 - @L0.assert DN.Diagram.edgeThicknessBias 0.0 - @L0.assert DN.Diagram.edgeThicknessProperty DN.Edge.ThicknessProperty.Diameter + @L0.assert DN.Diagram.arrowLengthGain 1.0 @L0.assert DN.Diagram.arrowLengthBias 0.0 @L0.assert DN.Diagram.arrowLengthProperty DN.Edge.ArrowLengthProperty.FlowRate - @L0.assert DN.Diagram.nodeScaleGain 1.0 - @L0.assert DN.Diagram.nodeScaleBias 0.0 - @L0.assert DN.Diagram.nodeScaleProperty DN.Vertex.ScaleProperty.NominalSupplyPressure @L0.assert DN.Diagram.drawMapEnabled true @L0.assert DN.Diagram.profileUpdateInterval 2000 : L0.Long @@ -141,46 +67,8 @@ DN.Functions.constantOne : L0.Function DN.Functions.hasNominalMassFlowValue : L0.Function L0.HasValueType "Resource -> Maybe Double" -DN.Edge.ThicknessProperty.OnlyGainAndBias: DN.Edge.ThicknessProperty - L0.HasLabel "Only Gain and Bias" - DN.Edge.ThicknessProperty.value - DN.Functions.constantOne - -DN.Edge.ThicknessProperty.Diameter : DN.Edge.ThicknessProperty - L0.HasLabel "Diameter" - DN.Edge.ThicknessProperty.value - DN.Functions.hasDiameterValue : L0.Function - L0.HasValueType "Resource -> Maybe Double" - DN.Edge.ThicknessProperty.gain 0.001 - -DN.Edge.ThicknessProperty.FlowRate : DN.Edge.ThicknessProperty - L0.HasLabel "Nominal Mass Flow" - DN.Edge.ThicknessProperty.value - DN.Functions.hasNominalMassFlowValue - DN.Edge.ThicknessProperty.gain 0.1 - 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 - -DN.Vertex.ScaleProperty.OnlyGainAndBias: DN.Vertex.ScaleProperty - L0.HasLabel "Only Gain and Bias" - DN.Vertex.ScaleProperty.value - DN.Functions.constantOne - -DN.Vertex.ScaleProperty.NominalSupplyPressure : DN.Vertex.ScaleProperty - L0.HasLabel "Nominal Supply Pressure" - DN.Vertex.ScaleProperty.value - DN.Functions.hasNominalSupplyPressure : L0.Function - L0.HasValueType "Resource -> Maybe Double" - DN.Vertex.ScaleProperty.gain 0.001 - -DN.Vertex.ScaleProperty.Elevation : DN.Vertex.ScaleProperty - L0.HasLabel "Elevation" - DN.Vertex.ScaleProperty.value - DN.Functions.hasElevation : L0.Function - L0.HasValueType "Resource -> Maybe Double" - DN.Vertex.ScaleProperty.gain 0.1 - DN.Vertex.ScaleProperty.bias 0.001 diff --git a/org.simantics.district.network.ontology/graph/DistrictNetworkProfiles.pgraph b/org.simantics.district.network.ontology/graph/DistrictNetworkProfiles.pgraph index ecb82311..496c9c58 100644 --- a/org.simantics.district.network.ontology/graph/DistrictNetworkProfiles.pgraph +++ b/org.simantics.district.network.ontology/graph/DistrictNetworkProfiles.pgraph @@ -21,8 +21,9 @@ DN.Groups.EdgeGroup : DIA.TypeGroup DN.ElementColoringStyle : DIA.Style DN.ElementSizingStyle : DIA.Style -DN.VertexSizeStyle : DIA.Style -DN.EdgeThicknessStyle : DIA.Style +// These are deprecated in favor of new dynamic visualisations +//DN.VertexSizeStyle : DIA.Style +//DN.EdgeThicknessStyle : DIA.Style DN.ArrowLengthStyle : DIA.Style DN.HideStyle : DIA.Style DN.VertexSymbolStyle : DIA.Style 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 e27aef7c..39305f14 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 @@ -107,28 +107,10 @@ public class DistrictNetworkResource { public final Resource Diagram_backgroundColor_Inverse; public final Resource Diagram_drawMapEnabled; public final Resource Diagram_drawMapEnabled_Inverse; - public final Resource Diagram_edgeThicknessBias; - public final Resource Diagram_edgeThicknessBias_Inverse; - public final Resource Diagram_edgeThicknessGain; - public final Resource Diagram_edgeThicknessGain_Inverse; - public final Resource Diagram_edgeThicknessProperty; - public final Resource Diagram_edgeThicknessProperty_Inverse; - public final Resource Diagram_elementColoringFunction; - public final Resource Diagram_elementColoringFunction_Inverse; - public final Resource Diagram_elementColoringGradientHue; - public final Resource Diagram_elementColoringGradientHue_Inverse; - public final Resource Diagram_elementColoringGradientSaturation; - public final Resource Diagram_elementColoringGradientSaturation_Inverse; public final Resource Diagram_hasActiveVisualisation; public final Resource Diagram_hasActiveVisualisation_Inverse; public final Resource Diagram_hasVisualisation; public final Resource Diagram_hasVisualisation_Inverse; - public final Resource Diagram_nodeScaleBias; - public final Resource Diagram_nodeScaleBias_Inverse; - public final Resource Diagram_nodeScaleGain; - public final Resource Diagram_nodeScaleGain_Inverse; - public final Resource Diagram_nodeScaleProperty; - public final Resource Diagram_nodeScaleProperty_Inverse; public final Resource Diagram_profileUpdateInterval; public final Resource Diagram_profileUpdateInterval_Inverse; public final Resource Diagram_splitToMultipleEnabled; @@ -145,8 +127,6 @@ public class DistrictNetworkResource { public final Resource EdgeDefaultMapping; public final Resource EdgeDefaultMapping_Inverse; public final Resource EdgeMappingParameterType; - public final Resource EdgeThicknessPropertyParameterType; - public final Resource EdgeThicknessStyle; public final Resource Edge_ArrowLengthProperty; public final Resource Edge_ArrowLengthProperty_FlowRate; public final Resource Edge_ArrowLengthProperty_bias; @@ -176,15 +156,6 @@ public class DistrictNetworkResource { public final Resource Edge_HasTGround; public final Resource Edge_HasTGround_Inverse; public final Resource Edge_ThicknessProperty; - public final Resource Edge_ThicknessProperty_Diameter; - public final Resource Edge_ThicknessProperty_FlowRate; - public final Resource Edge_ThicknessProperty_OnlyGainAndBias; - public final Resource Edge_ThicknessProperty_bias; - public final Resource Edge_ThicknessProperty_bias_Inverse; - public final Resource Edge_ThicknessProperty_gain; - public final Resource Edge_ThicknessProperty_gain_Inverse; - public final Resource Edge_ThicknessProperty_value; - public final Resource Edge_ThicknessProperty_value_Inverse; public final Resource Element; public final Resource ElementColoringStyle; public final Resource ElementSizingStyle; @@ -192,24 +163,14 @@ public class DistrictNetworkResource { public final Resource Functions; public final Resource Functions_arrowLengthPropertyEnumerationValues; public final Resource Functions_arrowLengthPropertyModifier; - public final Resource Functions_brightnessValidator; public final Resource Functions_compositeInstantiator; public final Resource Functions_constantOne; public final Resource Functions_convertToValue; public final Resource Functions_defaultEdgeMappingModifier; public final Resource Functions_defaultVertexMappingModifier; - public final Resource Functions_edgeThicknessPropertyEnumerationValues; - public final Resource Functions_edgeThicknessPropertyModifier; public final Resource Functions_enumerationValues; - public final Resource Functions_hasDiameterValue; - public final Resource Functions_hasElevation; public final Resource Functions_hasNominalMassFlowValue; - public final Resource Functions_hasNominalSupplyPressure; - public final Resource Functions_hueValidator; public final Resource Functions_mappingModifier; - public final Resource Functions_nodeScalePropertyEnumerationValues; - public final Resource Functions_nodeScalePropertyModifier; - public final Resource Functions_saturationValidator; public final Resource Groups; public final Resource Groups_EdgeGroup; public final Resource Groups_VertexGroup; @@ -377,8 +338,6 @@ public class DistrictNetworkResource { public final Resource VertexDefaultMapping; public final Resource VertexDefaultMapping_Inverse; public final Resource VertexMappingParameterType; - public final Resource VertexScalePropertyParameterType; - public final Resource VertexSizeStyle; public final Resource VertexSymbolStyle; public final Resource Vertex_HasAddress; public final Resource Vertex_HasAddress_Inverse; @@ -458,16 +417,6 @@ public class DistrictNetworkResource { public final Resource Vertex_HasVelocity_Inverse; public final Resource Vertex_HasVolFlow; public final Resource Vertex_HasVolFlow_Inverse; - public final Resource Vertex_ScaleProperty; - public final Resource Vertex_ScaleProperty_Elevation; - public final Resource Vertex_ScaleProperty_NominalSupplyPressure; - public final Resource Vertex_ScaleProperty_OnlyGainAndBias; - public final Resource Vertex_ScaleProperty_bias; - public final Resource Vertex_ScaleProperty_bias_Inverse; - public final Resource Vertex_ScaleProperty_gain; - public final Resource Vertex_ScaleProperty_gain_Inverse; - public final Resource Vertex_ScaleProperty_value; - public final Resource Vertex_ScaleProperty_value_Inverse; public static class URIs { public static final String ActionContext = "http://www.simantics.org/DistrictNetwork-1.0/ActionContext"; @@ -567,28 +516,10 @@ public class DistrictNetworkResource { 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"; public static final String Diagram_drawMapEnabled_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/drawMapEnabled/Inverse"; - public static final String Diagram_edgeThicknessBias = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/edgeThicknessBias"; - public static final String Diagram_edgeThicknessBias_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/edgeThicknessBias/Inverse"; - public static final String Diagram_edgeThicknessGain = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/edgeThicknessGain"; - public static final String Diagram_edgeThicknessGain_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/edgeThicknessGain/Inverse"; - public static final String Diagram_edgeThicknessProperty = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/edgeThicknessProperty"; - public static final String Diagram_edgeThicknessProperty_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/edgeThicknessProperty/Inverse"; - public static final String Diagram_elementColoringFunction = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/elementColoringFunction"; - public static final String Diagram_elementColoringFunction_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/elementColoringFunction/Inverse"; - public static final String Diagram_elementColoringGradientHue = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/elementColoringGradientHue"; - public static final String Diagram_elementColoringGradientHue_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/elementColoringGradientHue/Inverse"; - public static final String Diagram_elementColoringGradientSaturation = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/elementColoringGradientSaturation"; - public static final String Diagram_elementColoringGradientSaturation_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/elementColoringGradientSaturation/Inverse"; public static final String Diagram_hasActiveVisualisation = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/hasActiveVisualisation"; public static final String Diagram_hasActiveVisualisation_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/hasActiveVisualisation/Inverse"; public static final String Diagram_hasVisualisation = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/hasVisualisation"; public static final String Diagram_hasVisualisation_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/hasVisualisation/Inverse"; - public static final String Diagram_nodeScaleBias = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/nodeScaleBias"; - public static final String Diagram_nodeScaleBias_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/nodeScaleBias/Inverse"; - public static final String Diagram_nodeScaleGain = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/nodeScaleGain"; - public static final String Diagram_nodeScaleGain_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/nodeScaleGain/Inverse"; - public static final String Diagram_nodeScaleProperty = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/nodeScaleProperty"; - public static final String Diagram_nodeScaleProperty_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/nodeScaleProperty/Inverse"; public static final String Diagram_profileUpdateInterval = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/profileUpdateInterval"; public static final String Diagram_profileUpdateInterval_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/profileUpdateInterval/Inverse"; public static final String Diagram_splitToMultipleEnabled = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/splitToMultipleEnabled"; @@ -605,8 +536,6 @@ public class DistrictNetworkResource { public static final String EdgeDefaultMapping = "http://www.simantics.org/DistrictNetwork-1.0/EdgeDefaultMapping"; 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 EdgeThicknessPropertyParameterType = "http://www.simantics.org/DistrictNetwork-1.0/EdgeThicknessPropertyParameterType"; - public static final String EdgeThicknessStyle = "http://www.simantics.org/DistrictNetwork-1.0/EdgeThicknessStyle"; 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"; @@ -636,15 +565,6 @@ public class DistrictNetworkResource { public static final String Edge_HasTGround = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasTGround"; public static final String Edge_HasTGround_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasTGround/Inverse"; public static final String Edge_ThicknessProperty = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ThicknessProperty"; - public static final String Edge_ThicknessProperty_Diameter = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ThicknessProperty/Diameter"; - public static final String Edge_ThicknessProperty_FlowRate = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ThicknessProperty/FlowRate"; - public static final String Edge_ThicknessProperty_OnlyGainAndBias = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ThicknessProperty/OnlyGainAndBias"; - public static final String Edge_ThicknessProperty_bias = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ThicknessProperty/bias"; - public static final String Edge_ThicknessProperty_bias_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ThicknessProperty/bias/Inverse"; - public static final String Edge_ThicknessProperty_gain = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ThicknessProperty/gain"; - public static final String Edge_ThicknessProperty_gain_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ThicknessProperty/gain/Inverse"; - public static final String Edge_ThicknessProperty_value = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ThicknessProperty/value"; - public static final String Edge_ThicknessProperty_value_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ThicknessProperty/value/Inverse"; public static final String Element = "http://www.simantics.org/DistrictNetwork-1.0/Element"; public static final String ElementColoringStyle = "http://www.simantics.org/DistrictNetwork-1.0/ElementColoringStyle"; public static final String ElementSizingStyle = "http://www.simantics.org/DistrictNetwork-1.0/ElementSizingStyle"; @@ -652,24 +572,14 @@ public class DistrictNetworkResource { public static final String Functions = "http://www.simantics.org/DistrictNetwork-1.0/Functions"; public static final String Functions_arrowLengthPropertyEnumerationValues = "http://www.simantics.org/DistrictNetwork-1.0/Functions/arrowLengthPropertyEnumerationValues"; public static final String Functions_arrowLengthPropertyModifier = "http://www.simantics.org/DistrictNetwork-1.0/Functions/arrowLengthPropertyModifier"; - public static final String Functions_brightnessValidator = "http://www.simantics.org/DistrictNetwork-1.0/Functions/brightnessValidator"; public static final String Functions_compositeInstantiator = "http://www.simantics.org/DistrictNetwork-1.0/Functions/compositeInstantiator"; public static final String Functions_constantOne = "http://www.simantics.org/DistrictNetwork-1.0/Functions/constantOne"; public static final String Functions_convertToValue = "http://www.simantics.org/DistrictNetwork-1.0/Functions/convertToValue"; public static final String Functions_defaultEdgeMappingModifier = "http://www.simantics.org/DistrictNetwork-1.0/Functions/defaultEdgeMappingModifier"; public static final String Functions_defaultVertexMappingModifier = "http://www.simantics.org/DistrictNetwork-1.0/Functions/defaultVertexMappingModifier"; - public static final String Functions_edgeThicknessPropertyEnumerationValues = "http://www.simantics.org/DistrictNetwork-1.0/Functions/edgeThicknessPropertyEnumerationValues"; - public static final String Functions_edgeThicknessPropertyModifier = "http://www.simantics.org/DistrictNetwork-1.0/Functions/edgeThicknessPropertyModifier"; public static final String Functions_enumerationValues = "http://www.simantics.org/DistrictNetwork-1.0/Functions/enumerationValues"; - public static final String Functions_hasDiameterValue = "http://www.simantics.org/DistrictNetwork-1.0/Functions/hasDiameterValue"; - public static final String Functions_hasElevation = "http://www.simantics.org/DistrictNetwork-1.0/Functions/hasElevation"; public static final String Functions_hasNominalMassFlowValue = "http://www.simantics.org/DistrictNetwork-1.0/Functions/hasNominalMassFlowValue"; - public static final String Functions_hasNominalSupplyPressure = "http://www.simantics.org/DistrictNetwork-1.0/Functions/hasNominalSupplyPressure"; - public static final String Functions_hueValidator = "http://www.simantics.org/DistrictNetwork-1.0/Functions/hueValidator"; public static final String Functions_mappingModifier = "http://www.simantics.org/DistrictNetwork-1.0/Functions/mappingModifier"; - public static final String Functions_nodeScalePropertyEnumerationValues = "http://www.simantics.org/DistrictNetwork-1.0/Functions/nodeScalePropertyEnumerationValues"; - public static final String Functions_nodeScalePropertyModifier = "http://www.simantics.org/DistrictNetwork-1.0/Functions/nodeScalePropertyModifier"; - public static final String Functions_saturationValidator = "http://www.simantics.org/DistrictNetwork-1.0/Functions/saturationValidator"; public static final String Groups = "http://www.simantics.org/DistrictNetwork-1.0/Groups"; public static final String Groups_EdgeGroup = "http://www.simantics.org/DistrictNetwork-1.0/Groups/EdgeGroup"; public static final String Groups_VertexGroup = "http://www.simantics.org/DistrictNetwork-1.0/Groups/VertexGroup"; @@ -837,8 +747,6 @@ public class DistrictNetworkResource { public static final String VertexDefaultMapping = "http://www.simantics.org/DistrictNetwork-1.0/VertexDefaultMapping"; public static final String VertexDefaultMapping_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/VertexDefaultMapping/Inverse"; public static final String VertexMappingParameterType = "http://www.simantics.org/DistrictNetwork-1.0/VertexMappingParameterType"; - public static final String VertexScalePropertyParameterType = "http://www.simantics.org/DistrictNetwork-1.0/VertexScalePropertyParameterType"; - public static final String VertexSizeStyle = "http://www.simantics.org/DistrictNetwork-1.0/VertexSizeStyle"; public static final String VertexSymbolStyle = "http://www.simantics.org/DistrictNetwork-1.0/VertexSymbolStyle"; public static final String Vertex_HasAddress = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasAddress"; public static final String Vertex_HasAddress_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasAddress/Inverse"; @@ -918,16 +826,6 @@ public class DistrictNetworkResource { public static final String Vertex_HasVelocity_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasVelocity/Inverse"; public static final String Vertex_HasVolFlow = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasVolFlow"; public static final String Vertex_HasVolFlow_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasVolFlow/Inverse"; - public static final String Vertex_ScaleProperty = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/ScaleProperty"; - public static final String Vertex_ScaleProperty_Elevation = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/ScaleProperty/Elevation"; - public static final String Vertex_ScaleProperty_NominalSupplyPressure = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/ScaleProperty/NominalSupplyPressure"; - public static final String Vertex_ScaleProperty_OnlyGainAndBias = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/ScaleProperty/OnlyGainAndBias"; - public static final String Vertex_ScaleProperty_bias = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/ScaleProperty/bias"; - public static final String Vertex_ScaleProperty_bias_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/ScaleProperty/bias/Inverse"; - public static final String Vertex_ScaleProperty_gain = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/ScaleProperty/gain"; - public static final String Vertex_ScaleProperty_gain_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/ScaleProperty/gain/Inverse"; - public static final String Vertex_ScaleProperty_value = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/ScaleProperty/value"; - public static final String Vertex_ScaleProperty_value_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/ScaleProperty/value/Inverse"; } public static Resource getResourceOrNull(ReadGraph graph, String uri) { @@ -1037,28 +935,10 @@ public class DistrictNetworkResource { Diagram_backgroundColor_Inverse = getResourceOrNull(graph, URIs.Diagram_backgroundColor_Inverse); Diagram_drawMapEnabled = getResourceOrNull(graph, URIs.Diagram_drawMapEnabled); Diagram_drawMapEnabled_Inverse = getResourceOrNull(graph, URIs.Diagram_drawMapEnabled_Inverse); - Diagram_edgeThicknessBias = getResourceOrNull(graph, URIs.Diagram_edgeThicknessBias); - Diagram_edgeThicknessBias_Inverse = getResourceOrNull(graph, URIs.Diagram_edgeThicknessBias_Inverse); - Diagram_edgeThicknessGain = getResourceOrNull(graph, URIs.Diagram_edgeThicknessGain); - Diagram_edgeThicknessGain_Inverse = getResourceOrNull(graph, URIs.Diagram_edgeThicknessGain_Inverse); - Diagram_edgeThicknessProperty = getResourceOrNull(graph, URIs.Diagram_edgeThicknessProperty); - Diagram_edgeThicknessProperty_Inverse = getResourceOrNull(graph, URIs.Diagram_edgeThicknessProperty_Inverse); - Diagram_elementColoringFunction = getResourceOrNull(graph, URIs.Diagram_elementColoringFunction); - Diagram_elementColoringFunction_Inverse = getResourceOrNull(graph, URIs.Diagram_elementColoringFunction_Inverse); - Diagram_elementColoringGradientHue = getResourceOrNull(graph, URIs.Diagram_elementColoringGradientHue); - Diagram_elementColoringGradientHue_Inverse = getResourceOrNull(graph, URIs.Diagram_elementColoringGradientHue_Inverse); - Diagram_elementColoringGradientSaturation = getResourceOrNull(graph, URIs.Diagram_elementColoringGradientSaturation); - Diagram_elementColoringGradientSaturation_Inverse = getResourceOrNull(graph, URIs.Diagram_elementColoringGradientSaturation_Inverse); Diagram_hasActiveVisualisation = getResourceOrNull(graph, URIs.Diagram_hasActiveVisualisation); Diagram_hasActiveVisualisation_Inverse = getResourceOrNull(graph, URIs.Diagram_hasActiveVisualisation_Inverse); Diagram_hasVisualisation = getResourceOrNull(graph, URIs.Diagram_hasVisualisation); Diagram_hasVisualisation_Inverse = getResourceOrNull(graph, URIs.Diagram_hasVisualisation_Inverse); - Diagram_nodeScaleBias = getResourceOrNull(graph, URIs.Diagram_nodeScaleBias); - Diagram_nodeScaleBias_Inverse = getResourceOrNull(graph, URIs.Diagram_nodeScaleBias_Inverse); - Diagram_nodeScaleGain = getResourceOrNull(graph, URIs.Diagram_nodeScaleGain); - Diagram_nodeScaleGain_Inverse = getResourceOrNull(graph, URIs.Diagram_nodeScaleGain_Inverse); - Diagram_nodeScaleProperty = getResourceOrNull(graph, URIs.Diagram_nodeScaleProperty); - Diagram_nodeScaleProperty_Inverse = getResourceOrNull(graph, URIs.Diagram_nodeScaleProperty_Inverse); Diagram_profileUpdateInterval = getResourceOrNull(graph, URIs.Diagram_profileUpdateInterval); Diagram_profileUpdateInterval_Inverse = getResourceOrNull(graph, URIs.Diagram_profileUpdateInterval_Inverse); Diagram_splitToMultipleEnabled = getResourceOrNull(graph, URIs.Diagram_splitToMultipleEnabled); @@ -1075,8 +955,6 @@ public class DistrictNetworkResource { EdgeDefaultMapping = getResourceOrNull(graph, URIs.EdgeDefaultMapping); EdgeDefaultMapping_Inverse = getResourceOrNull(graph, URIs.EdgeDefaultMapping_Inverse); EdgeMappingParameterType = getResourceOrNull(graph, URIs.EdgeMappingParameterType); - EdgeThicknessPropertyParameterType = getResourceOrNull(graph, URIs.EdgeThicknessPropertyParameterType); - EdgeThicknessStyle = getResourceOrNull(graph, URIs.EdgeThicknessStyle); 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); @@ -1106,15 +984,6 @@ public class DistrictNetworkResource { Edge_HasTGround = getResourceOrNull(graph, URIs.Edge_HasTGround); Edge_HasTGround_Inverse = getResourceOrNull(graph, URIs.Edge_HasTGround_Inverse); Edge_ThicknessProperty = getResourceOrNull(graph, URIs.Edge_ThicknessProperty); - Edge_ThicknessProperty_Diameter = getResourceOrNull(graph, URIs.Edge_ThicknessProperty_Diameter); - Edge_ThicknessProperty_FlowRate = getResourceOrNull(graph, URIs.Edge_ThicknessProperty_FlowRate); - Edge_ThicknessProperty_OnlyGainAndBias = getResourceOrNull(graph, URIs.Edge_ThicknessProperty_OnlyGainAndBias); - Edge_ThicknessProperty_bias = getResourceOrNull(graph, URIs.Edge_ThicknessProperty_bias); - Edge_ThicknessProperty_bias_Inverse = getResourceOrNull(graph, URIs.Edge_ThicknessProperty_bias_Inverse); - Edge_ThicknessProperty_gain = getResourceOrNull(graph, URIs.Edge_ThicknessProperty_gain); - Edge_ThicknessProperty_gain_Inverse = getResourceOrNull(graph, URIs.Edge_ThicknessProperty_gain_Inverse); - Edge_ThicknessProperty_value = getResourceOrNull(graph, URIs.Edge_ThicknessProperty_value); - Edge_ThicknessProperty_value_Inverse = getResourceOrNull(graph, URIs.Edge_ThicknessProperty_value_Inverse); Element = getResourceOrNull(graph, URIs.Element); ElementColoringStyle = getResourceOrNull(graph, URIs.ElementColoringStyle); ElementSizingStyle = getResourceOrNull(graph, URIs.ElementSizingStyle); @@ -1122,24 +991,14 @@ public class DistrictNetworkResource { Functions = getResourceOrNull(graph, URIs.Functions); Functions_arrowLengthPropertyEnumerationValues = getResourceOrNull(graph, URIs.Functions_arrowLengthPropertyEnumerationValues); Functions_arrowLengthPropertyModifier = getResourceOrNull(graph, URIs.Functions_arrowLengthPropertyModifier); - Functions_brightnessValidator = getResourceOrNull(graph, URIs.Functions_brightnessValidator); Functions_compositeInstantiator = getResourceOrNull(graph, URIs.Functions_compositeInstantiator); Functions_constantOne = getResourceOrNull(graph, URIs.Functions_constantOne); Functions_convertToValue = getResourceOrNull(graph, URIs.Functions_convertToValue); Functions_defaultEdgeMappingModifier = getResourceOrNull(graph, URIs.Functions_defaultEdgeMappingModifier); Functions_defaultVertexMappingModifier = getResourceOrNull(graph, URIs.Functions_defaultVertexMappingModifier); - Functions_edgeThicknessPropertyEnumerationValues = getResourceOrNull(graph, URIs.Functions_edgeThicknessPropertyEnumerationValues); - Functions_edgeThicknessPropertyModifier = getResourceOrNull(graph, URIs.Functions_edgeThicknessPropertyModifier); Functions_enumerationValues = getResourceOrNull(graph, URIs.Functions_enumerationValues); - Functions_hasDiameterValue = getResourceOrNull(graph, URIs.Functions_hasDiameterValue); - Functions_hasElevation = getResourceOrNull(graph, URIs.Functions_hasElevation); Functions_hasNominalMassFlowValue = getResourceOrNull(graph, URIs.Functions_hasNominalMassFlowValue); - Functions_hasNominalSupplyPressure = getResourceOrNull(graph, URIs.Functions_hasNominalSupplyPressure); - Functions_hueValidator = getResourceOrNull(graph, URIs.Functions_hueValidator); Functions_mappingModifier = getResourceOrNull(graph, URIs.Functions_mappingModifier); - Functions_nodeScalePropertyEnumerationValues = getResourceOrNull(graph, URIs.Functions_nodeScalePropertyEnumerationValues); - Functions_nodeScalePropertyModifier = getResourceOrNull(graph, URIs.Functions_nodeScalePropertyModifier); - Functions_saturationValidator = getResourceOrNull(graph, URIs.Functions_saturationValidator); Groups = getResourceOrNull(graph, URIs.Groups); Groups_EdgeGroup = getResourceOrNull(graph, URIs.Groups_EdgeGroup); Groups_VertexGroup = getResourceOrNull(graph, URIs.Groups_VertexGroup); @@ -1307,8 +1166,6 @@ public class DistrictNetworkResource { VertexDefaultMapping = getResourceOrNull(graph, URIs.VertexDefaultMapping); VertexDefaultMapping_Inverse = getResourceOrNull(graph, URIs.VertexDefaultMapping_Inverse); VertexMappingParameterType = getResourceOrNull(graph, URIs.VertexMappingParameterType); - VertexScalePropertyParameterType = getResourceOrNull(graph, URIs.VertexScalePropertyParameterType); - VertexSizeStyle = getResourceOrNull(graph, URIs.VertexSizeStyle); VertexSymbolStyle = getResourceOrNull(graph, URIs.VertexSymbolStyle); Vertex_HasAddress = getResourceOrNull(graph, URIs.Vertex_HasAddress); Vertex_HasAddress_Inverse = getResourceOrNull(graph, URIs.Vertex_HasAddress_Inverse); @@ -1388,16 +1245,6 @@ public class DistrictNetworkResource { Vertex_HasVelocity_Inverse = getResourceOrNull(graph, URIs.Vertex_HasVelocity_Inverse); Vertex_HasVolFlow = getResourceOrNull(graph, URIs.Vertex_HasVolFlow); Vertex_HasVolFlow_Inverse = getResourceOrNull(graph, URIs.Vertex_HasVolFlow_Inverse); - Vertex_ScaleProperty = getResourceOrNull(graph, URIs.Vertex_ScaleProperty); - Vertex_ScaleProperty_Elevation = getResourceOrNull(graph, URIs.Vertex_ScaleProperty_Elevation); - Vertex_ScaleProperty_NominalSupplyPressure = getResourceOrNull(graph, URIs.Vertex_ScaleProperty_NominalSupplyPressure); - Vertex_ScaleProperty_OnlyGainAndBias = getResourceOrNull(graph, URIs.Vertex_ScaleProperty_OnlyGainAndBias); - Vertex_ScaleProperty_bias = getResourceOrNull(graph, URIs.Vertex_ScaleProperty_bias); - Vertex_ScaleProperty_bias_Inverse = getResourceOrNull(graph, URIs.Vertex_ScaleProperty_bias_Inverse); - Vertex_ScaleProperty_gain = getResourceOrNull(graph, URIs.Vertex_ScaleProperty_gain); - Vertex_ScaleProperty_gain_Inverse = getResourceOrNull(graph, URIs.Vertex_ScaleProperty_gain_Inverse); - Vertex_ScaleProperty_value = getResourceOrNull(graph, URIs.Vertex_ScaleProperty_value); - Vertex_ScaleProperty_value_Inverse = getResourceOrNull(graph, URIs.Vertex_ScaleProperty_value_Inverse); } public static DistrictNetworkResource getInstance(ReadGraph graph) { 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 cc05a173..617ed211 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 @@ -510,37 +510,18 @@ public class Functions { private static List listInstanceNames(ReadGraph graph, Variable context, Resource type) throws DatabaseException { Resource indexRoot = Variables.getIndexRoot(graph, context); DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - List properties = QueryIndexUtils.searchByType(graph, indexRoot, DN.Vertex_ScaleProperty); + List properties = Collections.emptyList();//QueryIndexUtils.searchByType(graph, indexRoot, DN.Vertex_ScaleProperty); return properties.stream() .map(m -> createEnumeratedValue(graph, m)) .map(EnumeratedValue::getName) .collect(Collectors.toList()); } - @SCLValue(type = "ReadGraph -> Resource -> Variable -> b") - public static Object edgeThicknessPropertyEnumerationValues(ReadGraph graph, Resource resource, Variable context) throws DatabaseException { - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - return listInstanceNames(graph, context, DN.Edge_ThicknessProperty); - } - @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 nodeScalePropertyEnumerationValues(ReadGraph graph, Resource resource, Variable context) throws DatabaseException { - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - return listInstanceNames(graph, context, DN.Vertex_ScaleProperty); - } - - @SCLValue(type = "ReadGraph -> Resource -> Variable -> b") - public static Object edgeThicknessPropertyModifier(ReadGraph graph, Resource resource, Variable context) throws DatabaseException { - Resource diagram = resolveElement(graph, context); - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - return baseMappingModifier(graph, diagram, DN.Diagram_edgeThicknessProperty, DN.Edge_ThicknessProperty, context); - } @SCLValue(type = "ReadGraph -> Resource -> Variable -> b") public static Object arrowLengthPropertyModifier(ReadGraph graph, Resource resource, Variable context) throws DatabaseException { @@ -548,13 +529,6 @@ public class Functions { DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); return baseMappingModifier(graph, diagram, DN.Diagram_arrowLengthProperty, DN.Edge_ArrowLengthProperty, context); } - - @SCLValue(type = "ReadGraph -> Resource -> Variable -> b") - public static Object nodeScalePropertyModifier(ReadGraph graph, Resource resource, Variable context) throws DatabaseException { - Resource diagram = resolveElement(graph, context); - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - return baseMappingModifier(graph, diagram, DN.Diagram_nodeScaleProperty, DN.Vertex_ScaleProperty, context); - } @SCLValue(type = "ReadGraph -> Resource -> Variable -> b") public static Function1 hasDiameterValue(ReadGraph graph, Resource resource, Variable context) throws DatabaseException { diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DynamicVisualisationContributionsNode.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DynamicVisualisationContributionsNode.java index 7705a201..b3149324 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DynamicVisualisationContributionsNode.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DynamicVisualisationContributionsNode.java @@ -5,7 +5,6 @@ import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.geom.AffineTransform; -import java.awt.geom.Ellipse2D; import java.awt.geom.Rectangle2D; import java.util.List; import java.util.Map; @@ -217,64 +216,69 @@ public class DynamicVisualisationContributionsNode extends G2DNode { int i = 0; - for (Entry object : dynamicSizingContributions.entrySet()) { - DynamicSizeContribution cc = object.getValue(); - - double min = cc.getDefaultMin(); - double max = cc.getDefaultMax(); - String unit = cc.getUnit(); - String label = cc.getLabel(); - - DynamicSizeMap map = cc.getDefaultSizeMap(); - - List sizes = map.getSizes(); - - double sizeBarBoxTop = (sizeBarBoxTopInitial + (colorBarBoxHeight * i)); - i++; - - g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f)); - g2d.setColor(new Color(0.9f, 0.9f, 0.9f, 0.95f)); - - Rectangle2D vertical = new Rectangle2D.Double(sizeBarBoxLeft, sizeBarBoxTop, colorBarBoxWidth, colorBarBoxHeight); - g2d.fill(vertical); - - double sizeVerticalLeft = sizeBarBoxLeft + 5; - double sizeVerticalTop = sizeBarBoxTop + 15; - double sizeVerticalHeigth = colorBarBoxHeight - 30; - - double sizeVerticalWidth = (sizeBarBoxWidth - 10) / sizes.size(); - - Font rulerFont = new Font("Tahoma", Font.PLAIN, DPIUtil.upscale(9)); - g2d.setFont(rulerFont); - - double interval = (max - min) / sizes.size(); - - for (int j = 0; j < sizes.size(); j++) { + if (dynamicSizingContributions != null) { + for (Entry object : dynamicSizingContributions.entrySet()) { + DynamicSizeContribution cc = object.getValue(); + + if (!cc.isUsed()) + continue; + + double min = cc.getDefaultMin(); + double max = cc.getDefaultMax(); + String unit = cc.getUnit(); + String label = cc.getLabel(); + + DynamicSizeMap map = cc.getDefaultSizeMap(); + + List sizes = map.getSizes(); + + double sizeBarBoxTop = (sizeBarBoxTopInitial + (colorBarBoxHeight * i)); + i++; + + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f)); + g2d.setColor(new Color(0.9f, 0.9f, 0.9f, 0.95f)); + + Rectangle2D vertical = new Rectangle2D.Double(sizeBarBoxLeft, sizeBarBoxTop, colorBarBoxWidth, colorBarBoxHeight); + g2d.fill(vertical); - Double size = sizes.get(j); + double sizeVerticalLeft = sizeBarBoxLeft + 5; + double sizeVerticalTop = sizeBarBoxTop + 15; + double sizeVerticalHeigth = colorBarBoxHeight - 30; + + double sizeVerticalWidth = (sizeBarBoxWidth - 10) / sizes.size(); - g2d.setColor(new Color((float)0, (float)0, (float)0.8, 0.8f)); - double sizedWidth = (size / 5) * sizeVerticalHeigth; - Rectangle2D rect = new Rectangle2D.Double(sizeVerticalLeft, (sizeVerticalTop), sizedWidth, sizeVerticalHeigth); - g2d.fill(rect); + Font rulerFont = new Font("Tahoma", Font.PLAIN, DPIUtil.upscale(9)); + g2d.setFont(rulerFont); + + double interval = (max - min) / sizes.size(); - double value = min + j * interval; - String str = Double.toString(value); - if (str.length() > 4) { - str = str.substring(0, 3); + for (int j = 0; j < sizes.size(); j++) { + + Double size = sizes.get(j); + + g2d.setColor(new Color((float)0, (float)0, (float)0.8, 0.8f)); + double sizedWidth = (size / 5) * sizeVerticalHeigth; + Rectangle2D rect = new Rectangle2D.Double(sizeVerticalLeft, (sizeVerticalTop), sizedWidth, sizeVerticalHeigth); + g2d.fill(rect); + + double value = min + j * interval; + String str = Double.toString(value); + if (str.length() > 4) { + str = str.substring(0, 3); + } + g2d.setColor(Color.BLACK); + g2d.drawString(str, (float)(sizeVerticalLeft - 8), (float)(sizeBarBoxTop + sizeBarBoxHeight)); + + sizeVerticalLeft = sizeVerticalLeft + sizeVerticalWidth; } g2d.setColor(Color.BLACK); - g2d.drawString(str, (float)(sizeVerticalLeft - 8), (float)(sizeBarBoxTop + sizeBarBoxHeight)); - sizeVerticalLeft = sizeVerticalLeft + sizeVerticalWidth; + String str = Double.toString(max); + g2d.drawString(str, (int)(sizeBarBoxLeft + sizeBarBoxWidth - 30), (int)(sizeBarBoxTop + sizeBarBoxHeight)); + + str = object.getKey() + " - " + label + " [" + unit + "]"; + g2d.drawString(str, (int)sizeBarBoxLeft + 5, (int)sizeBarBoxTop + 10); } - g2d.setColor(Color.BLACK); - - String str = Double.toString(max); - g2d.drawString(str, (int)(sizeBarBoxLeft + sizeBarBoxWidth - 30), (int)(sizeBarBoxTop + sizeBarBoxHeight)); - - str = object.getKey() + " - " + label + " [" + unit + "]"; - g2d.drawString(str, (int)sizeBarBoxLeft + 5, (int)sizeBarBoxTop + 10); } } 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 8ed98fad..5cb80a15 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 @@ -57,6 +57,7 @@ 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.utils.datastructures.Pair; +import org.simantics.utils.ui.dialogs.ShowError; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -70,10 +71,12 @@ public class DynamicVisualisationsUI extends Composite { private Button showSizeButton; private Button sizeTicksButton; + private Button sizeGradientButton; private Combo sizeLocationCombo; private Combo sizeSizeCombo; private Button showColorButton; private Button colorTicksButton; + private Button colorGradientButton; private Combo colorLocationCombo; private Combo colorSizeCombo; @@ -178,7 +181,12 @@ public class DynamicVisualisationsUI extends Composite { @Override public void widgetSelected(SelectionEvent e) { - persistVisualisationTemplate(visualisation.getName(), Optional.of(visualisation.getVisualisationResource())); + try { + persistVisualisationTemplate(visualisation.getName(), Optional.of(visualisation.getVisualisationResource())); + } catch (Exception e1) { + LOGGER.error("Could not persist visualisation template", e1); + ShowError.showError("Could not persist visualisation template", e1.getMessage(), e1); + } } }); @@ -222,11 +230,16 @@ public class DynamicVisualisationsUI extends Composite { if (dialog.open() == Dialog.OK) { String name = dialog.getValue(); - persistVisualisationTemplate(name, Optional.empty()); + try { + persistVisualisationTemplate(name, Optional.empty()); + } catch (Exception e) { + LOGGER.error("Could not persist visualisation template", e); + ShowError.showError("Could not persist visualisation template", e.getMessage(), e); + } } } - private void persistVisualisationTemplate(String templateName, Optional existing) { + private void persistVisualisationTemplate(String templateName, Optional existing) throws Exception { List> colorCollect = colorSuppliers.stream().map(s -> s.get()).filter(Objects::nonNull).collect(Collectors.toList()); @@ -236,6 +249,7 @@ public class DynamicVisualisationsUI extends Composite { ColorBarOptions colorBarOptions = new ColorBarOptions() .showColorBars(showColorButton.getSelection()) .showColorBarsTicks(colorTicksButton.getSelection()) + .useGradients(colorGradientButton.getSelection()) .withLocation(ColorBarsLocation.valueOf(colorLocation)) .withSize(ColorBarsSize.valueOf(colorSize)); @@ -247,6 +261,7 @@ public class DynamicVisualisationsUI extends Composite { SizeBarOptions sizeBarOptions = new SizeBarOptions() .showSizeBars(showSizeButton.getSelection()) .showSizeBarsTicks(sizeTicksButton.getSelection()) + .useGradients(sizeGradientButton.getSelection()) .withLocation(SizeBarsLocation.valueOf(sizeLocation)) .withSize(SizeBarsSize.valueOf(sizeSize)); @@ -704,7 +719,7 @@ public class DynamicVisualisationsUI extends Composite { Group group = new Group(parent, SWT.NONE); group.setText("Color Bars"); GridDataFactory.fillDefaults().grab(true, false).applyTo(group); - GridLayoutFactory.fillDefaults().numColumns(6).margins(5, 5).applyTo(group); + GridLayoutFactory.fillDefaults().numColumns(8).margins(5, 5).applyTo(group); createColorBars(group); } @@ -717,15 +732,26 @@ public class DynamicVisualisationsUI extends Composite { colorTicksButton = new Button(parent, SWT.CHECK); colorTicksButton.setText("Ticks"); + colorGradientButton = new Button(parent, SWT.CHECK); + colorGradientButton.setText("Gradients"); + Label label = new Label(parent, SWT.NONE); label.setText("Location"); colorLocationCombo = new Combo(parent, SWT.READ_ONLY); - colorLocationCombo.setItems(Stream.of(ColorBarsLocation.values()).map(size -> size.toString()).toArray(String[]::new)); + String[] colorLocationItems = Stream.of(ColorBarsLocation.values()).map(size -> size.toString()).toArray(String[]::new); + colorLocationCombo.setItems(colorLocationItems); + if (colorLocationItems.length > 0) { + colorLocationCombo.select(0); + } label = new Label(parent, SWT.NONE); label.setText("Size"); colorSizeCombo = new Combo(parent, SWT.READ_ONLY); - colorSizeCombo.setItems(Stream.of(ColorBarsSize.values()).map(size -> size.toString()).toArray(String[]::new)); + String[] colorSizeItems = Stream.of(ColorBarsSize.values()).map(size -> size.toString()).toArray(String[]::new); + colorSizeCombo.setItems(colorSizeItems); + if (colorSizeItems.length > 0) { + colorSizeCombo.select(0); + } } private void initializeObjectSizes(Composite parent) { @@ -764,7 +790,7 @@ public class DynamicVisualisationsUI extends Composite { Group group = new Group(parent, SWT.NONE); group.setText("Size Bars"); GridDataFactory.fillDefaults().grab(true, false).applyTo(group); - GridLayoutFactory.fillDefaults().numColumns(6).margins(5, 5).applyTo(group); + GridLayoutFactory.fillDefaults().numColumns(8).margins(5, 5).applyTo(group); createSizeBars(group); } @@ -776,15 +802,26 @@ public class DynamicVisualisationsUI extends Composite { sizeTicksButton = new Button(parent, SWT.CHECK); sizeTicksButton.setText("Ticks"); + sizeGradientButton = new Button(parent, SWT.CHECK); + sizeGradientButton.setText("Gradient"); + Label label = new Label(parent, SWT.NONE); label.setText("Location"); sizeLocationCombo = new Combo(parent, SWT.READ_ONLY); - sizeLocationCombo.setItems(Stream.of(SizeBarsLocation.values()).map(size -> size.toString()).toArray(String[]::new)); + String[] sizeLocationItems = Stream.of(SizeBarsLocation.values()).map(size -> size.toString()).toArray(String[]::new); + sizeLocationCombo.setItems(sizeLocationItems); + if (sizeLocationItems.length > 0) { + sizeLocationCombo.select(0); + } label = new Label(parent, SWT.NONE); label.setText("Size"); sizeSizeCombo = new Combo(parent, SWT.READ_ONLY); - sizeSizeCombo.setItems(Stream.of(SizeBarsSize.values()).map(size -> size.toString()).toArray(String[]::new)); + String[] sizeSizeItems = Stream.of(SizeBarsSize.values()).map(size -> size.toString()).toArray(String[]::new); + sizeSizeCombo.setItems(sizeSizeItems); + if (sizeSizeItems.length > 0) { + sizeSizeCombo.select(0); + } } public void setDiagramResource(Resource diagramResource) { @@ -870,13 +907,14 @@ public class DynamicVisualisationsUI extends Composite { public void updateVisualisation(DynamicVisualisation result) { this.visualisation = result; - if (visualisation != null) { - Display.getDefault().asyncExec(() -> { - if (getParent().isDisposed()) - return; - - applyButton.setEnabled(visualisation != null); - + Display.getDefault().asyncExec(() -> { + if (getParent().isDisposed()) + return; + + applyButton.setEnabled(visualisation != null && visualisation.getVisualisationResource() != null); + removeVisualisationTemplateButton.setEnabled(visualisation != null && visualisation.getVisualisationResource() != null); + + if (visualisation != null) { String[] items = templateSelectionCombo.getItems(); for (int i = 0; i < items.length; i++) { if (visualisation.getName().equals(items[i])) { @@ -944,11 +982,8 @@ public class DynamicVisualisationsUI extends Composite { break; } } - - - removeVisualisationTemplateButton.setEnabled(visualisation != null && visualisation.getVisualisationResource() != null); - }); - } + } + }); } public void updateVisualisations(Collection result) { diff --git a/org.simantics.district.network/adapters.xml b/org.simantics.district.network/adapters.xml index dc464c88..997bed16 100644 --- a/org.simantics.district.network/adapters.xml +++ b/org.simantics.district.network/adapters.xml @@ -15,12 +15,6 @@ - - - - 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 6a7b4537..596ac044 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 @@ -532,20 +532,20 @@ public class DistrictNetworkUtil { Map sizeMaps = DynamicVisualisationsContributions.dynamicSizeMaps(graph); - Collection colorContributions = graph.getObjects(visualisation, DN.Diagram_Visualisations_sizeContributions); - for (Resource colorContribution : colorContributions) { - String ucName = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_sizeContributionContributorName, Bindings.STRING); - String label = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_sizeContributionLabel, Bindings.STRING); - String moduleName = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_sizeContributionModuleName, Bindings.STRING); - String attributeName = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_sizeContributionModuleAttribute, Bindings.STRING); - String unit = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_sizeContributionUnit, Bindings.STRING); - Double variableGain = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_sizeContributionVariableGain, Bindings.DOUBLE); - Double variableBias = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_sizeContributionVariableBias, Bindings.DOUBLE); - String dynamicSizeMap = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_sizeContributionDefaultSizeMap, Bindings.STRING); - Double defaultMin = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_sizeContributionDefaultMin, Bindings.DOUBLE); - Double defaultMax = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_sizeContributionDefaultMax, Bindings.DOUBLE); - Boolean used = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_sizeContributionUsed, Bindings.BOOLEAN); - Boolean useDefault = graph.getRelatedValue(colorContribution, DN.Diagram_Visualisations_sizeContributionUseDefault, Bindings.BOOLEAN); + 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); diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/DNElementColorStyle.java b/org.simantics.district.network/src/org/simantics/district/network/profile/DNElementColorStyle.java index fe0a1fe7..7ebff91e 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/DNElementColorStyle.java +++ b/org.simantics.district.network/src/org/simantics/district/network/profile/DNElementColorStyle.java @@ -3,7 +3,6 @@ package org.simantics.district.network.profile; import java.awt.Color; import java.util.Map; -import org.simantics.Simantics; import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; @@ -40,7 +39,6 @@ public class DNElementColorStyle extends ThrottledStyleBase { DynamicVisualisation dv = graph.syncRequest(new RuntimeDynamicVisualisationsRequest(runtimeDiagram), TransientCacheAsyncListener.instance()); - DiagramSettings ds = graph.syncRequest(new DiagramSettingsRequest(runtimeDiagram), TransientCacheAsyncListener.instance()); // Prevent PendingVariableExceptions from coming through boolean wasSynchronous = graph.setSynchronous(true); try { @@ -91,20 +89,6 @@ public class DNElementColorStyle extends ThrottledStyleBase { } } } - - // the old implementation here - if (ds.elementColoringFunction.isPresent()) { - if (DEBUG) - System.out.print("elementColoringFunction: " + ds.elementColoringFunction + "(" + groupItem + "): "); - Double t = Simantics.applySCLRead(graph, ds.elementColoringFunction.get(), groupItem); - if (DEBUG) - System.out.print(t); - if (t != null) { - Color result = ds.coloringGradient.get(t); - //System.out.println("color(" + t + "): " + result); - return result; - } - } } finally { graph.setSynchronous(wasSynchronous); diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/DNElementSizeStyle.java b/org.simantics.district.network/src/org/simantics/district/network/profile/DNElementSizeStyle.java index 990aa4d2..5963954f 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/DNElementSizeStyle.java +++ b/org.simantics.district.network/src/org/simantics/district/network/profile/DNElementSizeStyle.java @@ -94,7 +94,7 @@ public class DNElementSizeStyle extends ThrottledStyleBase { finally { graph.setSynchronous(wasSynchronous); } - return null; + return 1.0; } @Override 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 index a0dcd40f..f76a4534 100644 --- 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 @@ -10,70 +10,34 @@ import org.simantics.scl.runtime.function.Function1; */ public class DiagramSettings { - public final Optional> vertexScaleProperty; - public final double vertexScaleGain; - public final double vertexScaleBias; - public final Optional> edgeThicknessProperty; - public final double edgeThicknessGain; - public final double edgeThicknessBias; public final Optional> arrowLengthProperty; public final double arrowLengthGain; public final double arrowLengthBias; - public final Optional> elementColoringFunction; - public final float elementColoringGradientHue; - public final float elementColoringGradientSaturation; - public final transient ColorGradient coloringGradient; public DiagramSettings( - Function1 vertexScaleProperty, double vertexScaleGain, double vertexScaleBias, - Function1 edgeThicknessProperty, double edgeThicknessGain, double edgeThicknessBias, - Function1 arrowLengthProperty, double arrowLengthGain, double arrowLengthBias, - Function1 elementColoringFunction, - float elementColoringGradientHue, - float elementColoringGradientSaturation + Function1 arrowLengthProperty, double arrowLengthGain, double arrowLengthBias ) { - this.vertexScaleProperty = Optional.ofNullable(vertexScaleProperty); - this.vertexScaleGain = vertexScaleGain; - this.vertexScaleBias = vertexScaleBias; - this.edgeThicknessProperty = Optional.ofNullable(edgeThicknessProperty); - this.edgeThicknessGain = edgeThicknessGain; - this.edgeThicknessBias = edgeThicknessBias; this.arrowLengthProperty = Optional.ofNullable(arrowLengthProperty); this.arrowLengthGain = arrowLengthGain; this.arrowLengthBias = arrowLengthBias; - this.elementColoringFunction = Optional.ofNullable(elementColoringFunction); - this.elementColoringGradientHue = elementColoringGradientHue; - this.elementColoringGradientSaturation = elementColoringGradientSaturation; - this.coloringGradient = Colors.cached( - Colors.hsvGradient( - elementColoringGradientHue, - elementColoringGradientSaturation) - ); } @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + edgeThicknessProperty.hashCode(); + //result = prime * result + edgeThicknessProperty.hashCode(); result = prime * result + arrowLengthProperty.hashCode(); - long temp; - temp = Double.doubleToLongBits(edgeThicknessGain); + long temp = result; + //temp = Double.doubleToLongBits(edgeThicknessGain); result = prime * result + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(edgeThicknessBias); + //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)); - result = prime * result + vertexScaleProperty.hashCode(); - temp = Double.doubleToLongBits(vertexScaleGain); - result = prime * result + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(vertexScaleBias); - result = prime * result + (int) (temp ^ (temp >>> 32)); - result = prime * result + elementColoringFunction.hashCode(); - result = prime * result + Float.floatToIntBits(elementColoringGradientHue); - result = prime * result + Float.floatToIntBits(elementColoringGradientSaturation); + return result; } @@ -86,41 +50,21 @@ public class DiagramSettings { if (getClass() != obj.getClass()) return false; DiagramSettings other = (DiagramSettings) obj; - if (!edgeThicknessProperty.equals(other.edgeThicknessProperty)) - return false; - if (Double.doubleToLongBits(edgeThicknessGain) != Double.doubleToLongBits(other.edgeThicknessGain)) - return false; - if (Double.doubleToLongBits(edgeThicknessBias) != Double.doubleToLongBits(other.edgeThicknessBias)) - return false; + 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; - if (!vertexScaleProperty.equals(other.vertexScaleProperty)) - return false; - if (Double.doubleToLongBits(vertexScaleGain) != Double.doubleToLongBits(other.vertexScaleGain)) - return false; - if (Double.doubleToLongBits(vertexScaleBias) != Double.doubleToLongBits(other.vertexScaleBias)) - return false; - if (!elementColoringFunction.equals(other.elementColoringFunction)) - return false; - if (Float.floatToIntBits(elementColoringGradientHue) != Float.floatToIntBits(other.elementColoringGradientHue)) - return false; - if (Float.floatToIntBits(elementColoringGradientSaturation) != Float.floatToIntBits(other.elementColoringGradientSaturation)) - return false; + return true; } @Override public String toString() { - return String.format("DiagramSettings[%s * %f + %f - %s * %f + %f - %s * %f + %f - coloringFunction: %s, hue: %f, saturation: %f]", - vertexScaleProperty.toString(), vertexScaleGain, vertexScaleBias, - edgeThicknessProperty, edgeThicknessGain, edgeThicknessBias, - arrowLengthProperty, arrowLengthGain, arrowLengthBias, - elementColoringFunction.toString(), - elementColoringGradientHue, elementColoringGradientSaturation + 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 index 2254b305..eac9ce08 100644 --- 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 @@ -26,51 +26,14 @@ public class DiagramSettingsRequest extends ResourceRead { DiagramResource DIA = DiagramResource.getInstance(graph); DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - Function1 elementColoringFunction = null; - float elementColoringGradientHue = 0; - float elementColoringGradientSaturation = 1; - Function1 edgeThicknessProperty = null; Function1 arrowLengthProperty = null; - Function1 nodeScaleProperty = null; - double edgeThicknessGain = 1; - double edgeThicknessBias = 0; double arrowLengthGain = 1; double arrowLengthBias = 0; - double nodeScaleGain = 1; - double nodeScaleBias = 0; Resource diagram = graph.getPossibleObject(resource, DIA.RuntimeDiagram_HasConfiguration); if (diagram != null) { Variable dv = Variables.getPossibleVariable(graph, diagram); - if (dv != null) { - Object obj = dv.getPossiblePropertyValue(graph, DN.Diagram_elementColoringFunction); - if (obj instanceof Function1) { - elementColoringFunction = (Function1) obj; - } - } - elementColoringGradientHue = - limit(0, 360, safeFloatProperty(graph, diagram, DN.Diagram_elementColoringGradientHue, 0.0f)) - / 360.0f; - elementColoringGradientSaturation = - limit(0, 100, safeFloatProperty(graph, diagram, DN.Diagram_elementColoringGradientSaturation, 0.0f)) - / 100.0f; - - Resource etp = graph.getPossibleObject(diagram, DN.Diagram_edgeThicknessProperty); - //System.out.println("etp: " + NameUtils.getURIOrSafeNameInternal(graph, etp)); - if (etp != null) { - Variable etpv = Variables.getPossibleVariable(graph, etp); - if (etpv != null) { - //System.out.println("etpv: " + etpv.getURI(graph)); - edgeThicknessProperty = etpv.getPropertyValue(graph, DN.Edge_ThicknessProperty_value); - } - edgeThicknessGain = - safeDoubleProperty(graph, etp, DN.Edge_ThicknessProperty_gain, 1) - * safeDoubleProperty(graph, diagram, DN.Diagram_edgeThicknessGain, 1); - edgeThicknessBias = - safeDoubleProperty(graph, etp, DN.Edge_ThicknessProperty_bias, 0) - + safeDoubleProperty(graph, diagram, DN.Diagram_edgeThicknessBias, 0); - } Resource alp = graph.getPossibleObject(diagram, DN.Diagram_arrowLengthProperty); //System.out.println("alp: " + NameUtils.getURIOrSafeNameInternal(graph, alp)); if (alp != null) { @@ -87,30 +50,10 @@ public class DiagramSettingsRequest extends ResourceRead { safeDoubleProperty(graph, alp, DN.Edge_ArrowLengthProperty_bias, 0) + safeDoubleProperty(graph, diagram, DN.Diagram_arrowLengthBias, 0); } - Resource nsp = graph.getPossibleObject(diagram, DN.Diagram_nodeScaleProperty); - if (nsp != null) { - Variable nspv = Variables.getPossibleVariable(graph, nsp); - if (nspv != null) { - //System.out.println("nspv: " + nspv.getURI(graph)); - nodeScaleProperty = nspv.getPropertyValue(graph, DN.Vertex_ScaleProperty_value); - } - nodeScaleGain = - safeDoubleProperty(graph, nsp, DN.Vertex_ScaleProperty_gain, 1) - * safeDoubleProperty(graph, diagram, DN.Diagram_nodeScaleGain, 1); - nodeScaleBias = - safeDoubleProperty(graph, nsp, DN.Vertex_ScaleProperty_bias, 0) - + safeDoubleProperty(graph, diagram, DN.Diagram_nodeScaleBias, 0); - } } - DiagramSettings ds = new DiagramSettings( - nodeScaleProperty, nodeScaleGain, nodeScaleBias, - edgeThicknessProperty, edgeThicknessGain, edgeThicknessBias, - arrowLengthProperty, arrowLengthGain, arrowLengthBias, - elementColoringFunction, - elementColoringGradientHue, - elementColoringGradientSaturation); + DiagramSettings ds = new DiagramSettings( arrowLengthProperty, arrowLengthGain, arrowLengthBias); //System.out.println("new diagram settings: " + ds); return ds; } diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/EdgeThicknessStyle.java b/org.simantics.district.network/src/org/simantics/district/network/profile/EdgeThicknessStyle.java deleted file mode 100644 index b305c391..00000000 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/EdgeThicknessStyle.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.simantics.district.network.profile; - -import org.simantics.Simantics; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener; -import org.simantics.db.exception.DatabaseException; -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; - -public class EdgeThicknessStyle extends ThrottledStyleBase { - - private static final Double PENDING = Double.NaN; - private static final Double ONE = 1.0; - - @Override - public Double calculateThrottledStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException { - DiagramSettings ds = graph.syncRequest(new DiagramSettingsRequest(runtimeDiagram), TransientCacheAsyncListener.instance()); - // Prevent PendingVariableExceptions from coming through - boolean wasSynchronous = graph.setSynchronous(true); - try { - Double thickness = ONE; - if (ds.edgeThicknessProperty.isPresent()) { - thickness = Simantics.applySCLRead(graph, ds.edgeThicknessProperty.get(), groupItem); - // System.out.println("read thickness: " + thickness + " : " + ds.edgeThicknessProperty); - if (thickness == null) { - thickness = ONE; - } else { - thickness = thickness * ds.edgeThicknessGain + ds.edgeThicknessBias; - } - } - - return thickness; - } - finally { - graph.setSynchronous(wasSynchronous); - } - } - - @Override - public void applyThrottledStyleForNode(EvaluationContext observer, INode node, Double value) { -// System.out.println("apply: " + node + " : " + value); - ConnectionNode n = (ConnectionNode) node; - if (value == PENDING) { - ((G2DSceneGraph)node.getRootNode()).setPending(node); - } else { - ((G2DSceneGraph)node.getRootNode()).clearPending(node); - } - if (value == null) - value = ONE; - for (INode nn : n.getNodes()) - ProfileVariables.claimNodeProperty(nn, "stroke", value, observer); - } - - @Override - protected void cleanupStyleForNode(EvaluationContext evaluationContext, INode node) { - ((G2DSceneGraph)node.getRootNode()).clearPending(node); - ConnectionNode n = (ConnectionNode) node; - for (INode nn : n.getNodes()) - ProfileVariables.claimNodeProperty(nn, "stroke", ONE, evaluationContext); - } - -} diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/ThrottledStyleBase.java b/org.simantics.district.network/src/org/simantics/district/network/profile/ThrottledStyleBase.java index f820c922..40779e20 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/ThrottledStyleBase.java +++ b/org.simantics.district.network/src/org/simantics/district/network/profile/ThrottledStyleBase.java @@ -72,10 +72,12 @@ public abstract class ThrottledStyleBase extends StyleBase result) { - if (!result.equals(Optional.empty())) { + if (!Optional.empty().equals(result)) { applyThrottledStyleForNode(evaluationContext, node, result.get()); } else { LOGGER.debug("Do not apply as results are unchanged for {} {} {}", evaluationContext, node, result); + // TODO: fix this duplicate method invocation with null + applyThrottledStyleForNode(evaluationContext, node, null); } } diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/VertexSizeStyle.java b/org.simantics.district.network/src/org/simantics/district/network/profile/VertexSizeStyle.java deleted file mode 100644 index b59590b6..00000000 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/VertexSizeStyle.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.simantics.district.network.profile; - -import org.simantics.Simantics; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener; -import org.simantics.db.exception.DatabaseException; -import org.simantics.scenegraph.INode; -import org.simantics.scenegraph.g2d.G2DSceneGraph; -import org.simantics.scenegraph.g2d.nodes.SingleElementNode; -import org.simantics.scenegraph.profile.EvaluationContext; -import org.simantics.scenegraph.profile.common.ProfileVariables; - -public class VertexSizeStyle extends ThrottledStyleBase { - - private static final Double PENDING = Double.NaN; - private static final Double ONE = 1.0; - - @Override - public Double calculateThrottledStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException { - DiagramSettings ds = graph.syncRequest(new DiagramSettingsRequest(runtimeDiagram), TransientCacheAsyncListener.instance()); - Double scaling = ONE; - // Prevent PendingVariableExceptions from coming through - boolean wasSynchronous = graph.setSynchronous(true); - try { - if (ds.vertexScaleProperty.isPresent()) { - scaling = Simantics.applySCLRead(graph, ds.vertexScaleProperty.get(), groupItem); - if (scaling == null) { - scaling = ONE; - } else { - // System.out.println("read vertex scaling: " + scaling + " : " + ds.vertexScaleProperty); - scaling = scaling * ds.vertexScaleGain + ds.vertexScaleBias; - // System.out.println("RESULT: " + scaling); - } - } - return scaling; - } - finally { - graph.setSynchronous(wasSynchronous); - } - } - - @Override - public void applyThrottledStyleForNode(EvaluationContext observer, INode node, Double value) { - //System.out.println("apply: " + node + " : " + value); - SingleElementNode n = (SingleElementNode) node; - if (value == PENDING) { - ((G2DSceneGraph)node.getRootNode()).setPending(node); - } else { - ((G2DSceneGraph)node.getRootNode()).clearPending(node); - } - if (value == null) - value = ONE; - for (INode nn : n.getNodes()) - ProfileVariables.claimNodeProperty(nn, "size", value, observer); - } - - @Override - protected void cleanupStyleForNode(EvaluationContext evaluationContext, INode node) { - ((G2DSceneGraph)node.getRootNode()).clearPending(node); - SingleElementNode n = (SingleElementNode) node; - for (INode nn : n.getNodes()) - ProfileVariables.claimNodeProperty(nn, "size", ONE, evaluationContext); - } - -} diff --git a/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/ColorBarOptions.java b/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/ColorBarOptions.java index a57ad913..81711087 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/ColorBarOptions.java +++ b/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/ColorBarOptions.java @@ -4,6 +4,7 @@ public class ColorBarOptions { private boolean showColorBars; private boolean showColorBarsTicks; + private boolean useGradients; private ColorBarsLocation location; private ColorBarsSize size; @@ -19,6 +20,10 @@ public class ColorBarOptions { public boolean isShowColorBarsTicks() { return showColorBarsTicks; } + + public boolean isUseGradients() { + return useGradients; + } public ColorBarOptions showColorBarsTicks(boolean show) { this.showColorBarsTicks = show; @@ -64,4 +69,9 @@ public class ColorBarOptions { public static ColorBarOptions useDefault() { return new ColorBarOptions().showColorBars(true).withLocation(ColorBarsLocation.EAST).withSize(ColorBarsSize.SMALL); } + + public ColorBarOptions useGradients(boolean useGradients) { + this.useGradients = useGradients; + return this; + } } diff --git a/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/SizeBarOptions.java b/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/SizeBarOptions.java index 14e9f47f..766a6c69 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/SizeBarOptions.java +++ b/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/SizeBarOptions.java @@ -4,6 +4,7 @@ public class SizeBarOptions { private boolean showColorBars; private boolean showColorBarsTicks; + private boolean useGradients; private SizeBarsLocation location; private SizeBarsSize size; @@ -19,6 +20,10 @@ public class SizeBarOptions { public boolean isShowSizeBarsTicks() { return showColorBarsTicks; } + + public boolean isUseGradients() { + return useGradients; + } public SizeBarOptions showSizeBarsTicks(boolean show) { this.showColorBarsTicks = show; @@ -63,4 +68,9 @@ public class SizeBarOptions { public static SizeBarOptions useDefault() { return new SizeBarOptions().showSizeBars(true).withLocation(SizeBarsLocation.EAST).withSize(SizeBarsSize.SMALL); } + + public SizeBarOptions useGradients(boolean useGradients) { + this.useGradients = useGradients; + return this; + } } -- 2.45.1