]> gerrit.simantics Code Review - simantics/district.git/commitdiff
Arrow length indicators for flow magnitude 71/2771/1
authorReino Ruusu <reino.ruusu@semantum.fi>
Mon, 11 Mar 2019 09:11:39 +0000 (11:11 +0200)
committerReino Ruusu <reino.ruusu@semantum.fi>
Wed, 13 Mar 2019 14:21:55 +0000 (16:21 +0200)
gitlab #39

Change-Id: I0fa73f0025f02e115a49199ef41c82885a1bf4ca

org.simantics.district.network.ontology/graph/DistrictNetworkDiagramSettings.pgraph
org.simantics.district.network.ontology/graph/DistrictNetworkProfiles.pgraph
org.simantics.district.network.ontology/src/org/simantics/district/network/ontology/DistrictNetworkResource.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/function/Functions.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeNode.java
org.simantics.district.network/adapters.xml
org.simantics.district.network/src/org/simantics/district/network/profile/ArrowLengthStyle.java [new file with mode: 0644]
org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettings.java
org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettingsRequest.java

index 8abc05deed5a9c0229a8ad6b744a877ca9d116b0..69cb2807cd32e30574c3e0a13910c697bf8054e6 100644 (file)
@@ -19,6 +19,12 @@ DN.EdgeThicknessPropertyParameterType <T SEL.GenericParameterType
             SEL.HasEnumerationValues DN.Functions.edgeThicknessPropertyEnumerationValues : L0.Function
             SEL.HasCustomModifier DN.Functions.edgeThicknessPropertyModifier : L0.Function
 
+DN.ArrowLengthPropertyParameterType <T SEL.GenericParameterType
+    @L0.assert SEL.HasDisplayValue
+        _ : SEL.DisplayValue
+            SEL.HasEnumerationValues DN.Functions.arrowLengthPropertyEnumerationValues : L0.Function
+            SEL.HasCustomModifier DN.Functions.arrowLengthPropertyModifier : L0.Function
+
 DN.VertexScalePropertyParameterType <T SEL.GenericParameterType
     @L0.assert SEL.HasDisplayValue
         _ : SEL.DisplayValue
@@ -36,6 +42,17 @@ DN.Edge.ThicknessProperty <T L0.Value
     @L0.assert DN.Edge.ThicknessProperty.gain 1.0
     @L0.assert DN.Edge.ThicknessProperty.bias 0.0
 
+DN.Edge.ArrowLengthProperty <T L0.Value
+    @L0.assert L0.ConvertsToValueWith DN.Functions.convertToValue
+    >-- DN.Edge.ArrowLengthProperty.value ==> "Resource -> <ReadGraph> Maybe Double" <R L0.HasProperty : SEL.GenericParameterType
+        L0.readOnly true
+    >-- DN.Edge.ArrowLengthProperty.gain --> L0.Double <R L0.HasProperty : SEL.GenericParameterType
+        L0.readOnly true
+    >-- DN.Edge.ArrowLengthProperty.bias --> L0.Double <R L0.HasProperty : SEL.GenericParameterType
+        L0.readOnly true
+    @L0.assert DN.Edge.ArrowLengthProperty.gain 1.0
+    @L0.assert DN.Edge.ArrowLengthProperty.bias 0.0
+
 DN.Vertex.ScaleProperty <T L0.Value
     @L0.assert L0.ConvertsToValueWith DN.Functions.convertToValue
     >-- DN.Vertex.ScaleProperty.value ==> "Resource -> <ReadGraph> Maybe Double" <R L0.HasProperty : SEL.GenericParameterType
@@ -73,6 +90,12 @@ DN.Diagram
         L0.HasLabel "Edge Thickness Bias"
     >-- DN.Diagram.edgeThicknessProperty --> DN.Edge.ThicknessProperty <R L0.HasProperty : DN.EdgeThicknessPropertyParameterType
         L0.HasLabel "Edge Thickness Property"
+    >-- DN.Diagram.arrowLengthGain ==> "Double" <R L0.HasProperty : SEL.GenericParameterType
+        L0.HasLabel "Arrow Length Gain"
+    >-- DN.Diagram.arrowLengthBias ==> "Double" <R L0.HasProperty : SEL.GenericParameterType
+        L0.HasLabel "Arrow Length Bias"
+    >-- DN.Diagram.arrowLengthProperty --> DN.Edge.ArrowLengthProperty <R L0.HasProperty : DN.ArrowLengthPropertyParameterType
+        L0.HasLabel "Arrow Length Property"
     >-- DN.Diagram.nodeScaleGain ==> "Double" <R L0.HasProperty : SEL.GenericParameterType
         L0.HasLabel "Node Scale Gain"
     >-- DN.Diagram.nodeScaleBias ==> "Double" <R L0.HasProperty : SEL.GenericParameterType
@@ -95,6 +118,9 @@ DN.Diagram
     @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
@@ -108,6 +134,9 @@ DN.Diagram
 DN.Functions.constantOne : L0.Function
     L0.HasValueType "Resource -> <ReadGraph> Maybe Double"
 
+DN.Functions.hasNominalMassFlowValue : L0.Function
+    L0.HasValueType "Resource -> <ReadGraph> Maybe Double"
+
 DN.Edge.ThicknessProperty.OnlyGainAndBias: DN.Edge.ThicknessProperty
     L0.HasLabel "Only Gain and Bias"
     DN.Edge.ThicknessProperty.value
@@ -120,6 +149,17 @@ DN.Edge.ThicknessProperty.Diameter : DN.Edge.ThicknessProperty
             L0.HasValueType "Resource -> <ReadGraph> 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"
index 54700829336935bb9a8d9ea2cc2d0adc88a7a72f..a853d85e8058337a52b7d52e2757d4a4193cbc6c 100644 (file)
@@ -22,6 +22,7 @@ DN.Groups.EdgeGroup : DIA.TypeGroup
 DN.ElementColoringStyle : DIA.Style
 DN.VertexSizeStyle : DIA.Style
 DN.EdgeThicknessStyle : DIA.Style
+DN.ArrowLengthStyle : DIA.Style
 DN.HideStyle : DIA.Style
 DN.VertexSymbolStyle : DIA.Style
 DN.ConnectionLineStyle : DIA.Style
index 178dbc2898bcacd53997192280728deaac974c1b..a48137cf625bf68cd6ecdf51a6b697d28a4838a1 100644 (file)
@@ -15,6 +15,8 @@ public class DistrictNetworkResource {
     public final Resource Actions;
     public final Resource Actions_NewDNDiagram;
     public final Resource AddLayerToDNDiagramTemplate;
+    public final Resource ArrowLengthPropertyParameterType;
+    public final Resource ArrowLengthStyle;
     public final Resource BrowseContext;
     public final Resource Composite;
     public final Resource Connection;
@@ -22,6 +24,12 @@ public class DistrictNetworkResource {
     public final Resource Diagram;
     public final Resource Diagram_MappedDiagram;
     public final Resource Diagram_MappedFromDiagram;
+    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;
@@ -60,6 +68,14 @@ public class DistrictNetworkResource {
     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;
+    public final Resource Edge_ArrowLengthProperty_bias_Inverse;
+    public final Resource Edge_ArrowLengthProperty_gain;
+    public final Resource Edge_ArrowLengthProperty_gain_Inverse;
+    public final Resource Edge_ArrowLengthProperty_value;
+    public final Resource Edge_ArrowLengthProperty_value_Inverse;
     public final Resource Edge_HasDiameter;
     public final Resource Edge_HasDiameter_Inverse;
     public final Resource Edge_HasElevation;
@@ -82,6 +98,7 @@ public class DistrictNetworkResource {
     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;
@@ -92,6 +109,8 @@ public class DistrictNetworkResource {
     public final Resource Element;
     public final Resource ElementColoringStyle;
     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;
@@ -103,6 +122,7 @@ public class DistrictNetworkResource {
     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;
@@ -294,6 +314,8 @@ public class DistrictNetworkResource {
         public static final String Actions = "http://www.simantics.org/DistrictNetwork-1.0/Actions";
         public static final String Actions_NewDNDiagram = "http://www.simantics.org/DistrictNetwork-1.0/Actions/NewDNDiagram";
         public static final String AddLayerToDNDiagramTemplate = "http://www.simantics.org/DistrictNetwork-1.0/AddLayerToDNDiagramTemplate";
+        public static final String ArrowLengthPropertyParameterType = "http://www.simantics.org/DistrictNetwork-1.0/ArrowLengthPropertyParameterType";
+        public static final String ArrowLengthStyle = "http://www.simantics.org/DistrictNetwork-1.0/ArrowLengthStyle";
         public static final String BrowseContext = "http://www.simantics.org/DistrictNetwork-1.0/BrowseContext";
         public static final String Composite = "http://www.simantics.org/DistrictNetwork-1.0/Composite";
         public static final String Connection = "http://www.simantics.org/DistrictNetwork-1.0/Connection";
@@ -301,6 +323,12 @@ public class DistrictNetworkResource {
         public static final String Diagram = "http://www.simantics.org/DistrictNetwork-1.0/Diagram";
         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_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";
@@ -339,6 +367,14 @@ public class DistrictNetworkResource {
         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";
+        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";
+        public static final String Edge_ArrowLengthProperty_gain_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ArrowLengthProperty/gain/Inverse";
+        public static final String Edge_ArrowLengthProperty_value = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ArrowLengthProperty/value";
+        public static final String Edge_ArrowLengthProperty_value_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/ArrowLengthProperty/value/Inverse";
         public static final String Edge_HasDiameter = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasDiameter";
         public static final String Edge_HasDiameter_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasDiameter/Inverse";
         public static final String Edge_HasElevation = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasElevation";
@@ -361,6 +397,7 @@ public class DistrictNetworkResource {
         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";
@@ -371,6 +408,8 @@ public class DistrictNetworkResource {
         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 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";
@@ -382,6 +421,7 @@ public class DistrictNetworkResource {
         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";
@@ -583,6 +623,8 @@ public class DistrictNetworkResource {
         Actions = getResourceOrNull(graph, URIs.Actions);
         Actions_NewDNDiagram = getResourceOrNull(graph, URIs.Actions_NewDNDiagram);
         AddLayerToDNDiagramTemplate = getResourceOrNull(graph, URIs.AddLayerToDNDiagramTemplate);
+        ArrowLengthPropertyParameterType = getResourceOrNull(graph, URIs.ArrowLengthPropertyParameterType);
+        ArrowLengthStyle = getResourceOrNull(graph, URIs.ArrowLengthStyle);
         BrowseContext = getResourceOrNull(graph, URIs.BrowseContext);
         Composite = getResourceOrNull(graph, URIs.Composite);
         Connection = getResourceOrNull(graph, URIs.Connection);
@@ -590,6 +632,12 @@ public class DistrictNetworkResource {
         Diagram = getResourceOrNull(graph, URIs.Diagram);
         Diagram_MappedDiagram = getResourceOrNull(graph, URIs.Diagram_MappedDiagram);
         Diagram_MappedFromDiagram = getResourceOrNull(graph, URIs.Diagram_MappedFromDiagram);
+        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);
@@ -628,6 +676,14 @@ public class DistrictNetworkResource {
         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);
+        Edge_ArrowLengthProperty_bias_Inverse = getResourceOrNull(graph, URIs.Edge_ArrowLengthProperty_bias_Inverse);
+        Edge_ArrowLengthProperty_gain = getResourceOrNull(graph, URIs.Edge_ArrowLengthProperty_gain);
+        Edge_ArrowLengthProperty_gain_Inverse = getResourceOrNull(graph, URIs.Edge_ArrowLengthProperty_gain_Inverse);
+        Edge_ArrowLengthProperty_value = getResourceOrNull(graph, URIs.Edge_ArrowLengthProperty_value);
+        Edge_ArrowLengthProperty_value_Inverse = getResourceOrNull(graph, URIs.Edge_ArrowLengthProperty_value_Inverse);
         Edge_HasDiameter = getResourceOrNull(graph, URIs.Edge_HasDiameter);
         Edge_HasDiameter_Inverse = getResourceOrNull(graph, URIs.Edge_HasDiameter_Inverse);
         Edge_HasElevation = getResourceOrNull(graph, URIs.Edge_HasElevation);
@@ -650,6 +706,7 @@ public class DistrictNetworkResource {
         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);
@@ -660,6 +717,8 @@ public class DistrictNetworkResource {
         Element = getResourceOrNull(graph, URIs.Element);
         ElementColoringStyle = getResourceOrNull(graph, URIs.ElementColoringStyle);
         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);
@@ -671,6 +730,7 @@ public class DistrictNetworkResource {
         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);
index 627561a12ca04dba26d84676c22e6eaead598405..60dd3e22131ee17b4ba9890052d5c5d0fca6fe2e 100644 (file)
@@ -483,7 +483,13 @@ public class Functions {
         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);
@@ -497,6 +503,13 @@ public class Functions {
         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 {
+        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 Object nodeScalePropertyModifier(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {
         Resource diagram = resolveElement(graph, context);
index a4f348eb11e1314b0b07119a7adf235861b453dc..21f3d741e77d81755376faa7047b3762266d0a92 100644 (file)
@@ -5,6 +5,7 @@ import java.awt.Color;
 import java.awt.Graphics2D;
 import java.awt.RenderingHints;
 import java.awt.geom.AffineTransform;
+import java.awt.geom.Line2D;
 import java.awt.geom.Path2D;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
@@ -44,11 +45,18 @@ public class DistrictNetworkEdgeNode extends G2DParentNode implements ISelection
     private static final double height = 0.5;
 
     private static final Rectangle2D NORMAL = new Rectangle2D.Double(left, top, width, height);
-    
+
     private transient Point2D centerPoint;
     private transient Rectangle2D symbolRect;
     private transient AffineTransform symbolTransform;
-    
+
+    private Double arrowLength;
+
+    private static double startX;
+    private static double startY;
+    private static double endX;
+    private static double endY;
+
     @Override
     public void init() {
     }
@@ -90,6 +98,37 @@ public class DistrictNetworkEdgeNode extends G2DParentNode implements ISelection
         g2d.setStroke(bs);
         g2d.draw(path);
 
+        // Draw arrow
+        if (arrowLength != null) {
+            g2d.setColor(Color.BLACK);
+            g2d.setStroke(new BasicStroke(bs.getLineWidth(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
+            
+            double l = arrowLength;
+            double w = 2 * (double) bs.getLineWidth() * Math.signum(l);
+            if (Math.abs(w) > Math.abs(l)) w = l;
+            double offset = 2 * (double) bs.getLineWidth();
+            
+            double centerX = (startX + endX) / 2, centerY = (startY + endY) / 2;
+            double deltaX = endX - startX, deltaY = endY - startY;
+            double length = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
+            deltaX /= length;
+            deltaY /= length;
+            
+            double x0 = centerX - l/2 * deltaX + offset * deltaY;
+            double y0 = centerY - l/2 * deltaY - offset * deltaX;
+            double x1 = centerX + (l/2 - w) * deltaX + offset * deltaY;
+            double y1 = centerY + (l/2 - w) * deltaY - offset * deltaX;
+            
+            g2d.draw(new Line2D.Double(x0, y0, x1, y1));
+            
+            Path2D path = new Path2D.Double();
+            path.moveTo(x1 + w * deltaX, y1 + w * deltaY);
+            path.lineTo(x1 + w * deltaY, y1 - w * deltaX);
+            path.lineTo(x1 - w * deltaY, y1 + w * deltaX);
+            path.closePath();
+            g2d.fill(path);
+        }
+        
         // Reset
         g2d.setStroke(oldStroke);
         g2d.setColor(oldColor);
@@ -141,11 +180,10 @@ public class DistrictNetworkEdgeNode extends G2DParentNode implements ISelection
 //    }
 
     public static Path2D calculatePath(DistrictNetworkEdge edge, Path2D result, boolean detailed) {
-        // Convert to screen coordinates
-        double startX = ModelledCRS.longitudeToX(edge.getStartPoint().getX());
-        double startY = ModelledCRS.latitudeToY(-edge.getStartPoint().getY()); // Invert for Simantics
-        double endX = ModelledCRS.longitudeToX(edge.getEndPoint().getX());
-        double endY = ModelledCRS.latitudeToY(-edge.getEndPoint().getY());// Invert for Simantics
+        startX = ModelledCRS.longitudeToX(edge.getStartPoint().getX());
+        startY = ModelledCRS.latitudeToY(-edge.getStartPoint().getY());
+        endX = ModelledCRS.longitudeToX(edge.getEndPoint().getX());
+        endY = ModelledCRS.latitudeToY(-edge.getEndPoint().getY());
 
         if (result == null) {
              result = new Path2D.Double();
@@ -211,6 +249,11 @@ public class DistrictNetworkEdgeNode extends G2DParentNode implements ISelection
     public void setDynamicColor(Color color) {
         this.dynamicColor = color;
     }
+    
+    @PropertySetter(value = "arrowLength")
+    public void setArroLength(Double length) {
+        arrowLength = length;
+    }
 
     @PropertySetter(value = "SVG")
     public void setSVG(String value) {
index 8cec44000d1c7b4ecfe1b28724fce4bb51e333e3..fddb3b74017fb050ee20173aaa4d28ef8cf5c007 100644 (file)
@@ -18,6 +18,9 @@
                <resource uri="http://www.simantics.org/DistrictNetwork-1.0/EdgeThicknessStyle"
                        class="org.simantics.district.network.profile.EdgeThicknessStyle">
                </resource>
+               <resource uri="http://www.simantics.org/DistrictNetwork-1.0/ArrowLengthStyle"
+                       class="org.simantics.district.network.profile.ArrowLengthStyle">
+               </resource>
                <resource uri="http://www.simantics.org/DistrictNetwork-1.0/HideStyle"
                        class="org.simantics.district.network.profile.HideStyle">
                </resource>
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
new file mode 100644 (file)
index 0000000..3b0524d
--- /dev/null
@@ -0,0 +1,64 @@
+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 ArrowLengthStyle extends ThrottledStyleBase<Double> {
+
+       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 length = ONE;
+                       if (ds.arrowLengthProperty.isPresent()) {
+                               length = Simantics.applySCLRead(graph, ds.arrowLengthProperty.get(), groupItem);
+       //                      System.out.println("read thickness: " + thickness + " : " + ds.arrowLengthProperty);
+                               if (length == null) {
+                                       length = ONE;
+                               } else {
+                                       length = length * ds.arrowLengthGain + ds.arrowLengthBias;
+                               }
+                       }
+                       
+                       return length;
+               }
+               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);
+               }
+               for (INode nn : n.getNodes())
+                       ProfileVariables.claimNodeProperty(nn, "arrowLength", 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, "arrowLength", null, evaluationContext);
+       }
+
+}
index 13c38bed02d494c1fed8e2ee359a10422e6c6a5b..a0dcd40f9e7a8b022f038e4e1cbb984c07d34521 100644 (file)
@@ -16,6 +16,9 @@ public class DiagramSettings {
        public final Optional<Function1<Resource, Double>> edgeThicknessProperty;
        public final double edgeThicknessGain;
        public final double edgeThicknessBias;
+       public final Optional<Function1<Resource, Double>> arrowLengthProperty;
+       public final double arrowLengthGain;
+       public final double arrowLengthBias;
        public final Optional<Function1<Resource, Double>> elementColoringFunction;
        public final float elementColoringGradientHue;
        public final float elementColoringGradientSaturation;
@@ -24,6 +27,7 @@ public class DiagramSettings {
        public DiagramSettings(
                        Function1<Resource, Double> vertexScaleProperty, double vertexScaleGain, double vertexScaleBias,
                        Function1<Resource, Double> edgeThicknessProperty, double edgeThicknessGain, double edgeThicknessBias,
+                       Function1<Resource, Double> arrowLengthProperty, double arrowLengthGain, double arrowLengthBias,
                        Function1<Resource, Double> elementColoringFunction,
                        float elementColoringGradientHue,
                        float elementColoringGradientSaturation
@@ -34,6 +38,9 @@ public class DiagramSettings {
                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;
@@ -49,11 +56,16 @@ public class DiagramSettings {
                final int prime = 31;
                int result = 1;
                result = prime * result + edgeThicknessProperty.hashCode();
+               result = prime * result + arrowLengthProperty.hashCode();
                long temp;
                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));
                result = prime * result + vertexScaleProperty.hashCode();
                temp = Double.doubleToLongBits(vertexScaleGain);
                result = prime * result + (int) (temp ^ (temp >>> 32));
@@ -80,6 +92,12 @@ public class DiagramSettings {
                        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))
@@ -97,9 +115,10 @@ public class DiagramSettings {
 
        @Override
        public String toString() {
-               return String.format("DiagramSettings[%s * %f + %f - %s * %f + %f - coloringFunction: %s, hue: %f, saturation: %f]",
+               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
                                );
index a17464d8aefe655ea4e83b9eea54832a513cc9f6..2254b305706c6fb0d997fcbe9c65fba6384b4bfe 100644 (file)
@@ -30,9 +30,12 @@ public class DiagramSettingsRequest extends ResourceRead<DiagramSettings> {
                float elementColoringGradientHue = 0;
                float elementColoringGradientSaturation = 1;
                Function1<Resource, Double> edgeThicknessProperty = null;
+               Function1<Resource, Double> arrowLengthProperty = null;
                Function1<Resource, Double> nodeScaleProperty = null;
                double edgeThicknessGain = 1;
                double edgeThicknessBias = 0;
+               double arrowLengthGain = 1;
+               double arrowLengthBias = 0;
                double nodeScaleGain = 1;
                double nodeScaleBias = 0;
 
@@ -68,6 +71,22 @@ public class DiagramSettingsRequest extends ResourceRead<DiagramSettings> {
                                                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) {
+                               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);
+                       }
                        Resource nsp = graph.getPossibleObject(diagram, DN.Diagram_nodeScaleProperty);
                        if (nsp != null) {
                                Variable nspv = Variables.getPossibleVariable(graph, nsp);
@@ -88,6 +107,7 @@ public class DiagramSettingsRequest extends ResourceRead<DiagramSettings> {
                DiagramSettings ds = new DiagramSettings(
                                nodeScaleProperty, nodeScaleGain, nodeScaleBias,
                                edgeThicknessProperty, edgeThicknessGain, edgeThicknessBias,
+                               arrowLengthProperty, arrowLengthGain, arrowLengthBias,
                                elementColoringFunction,
                                elementColoringGradientHue,
                                elementColoringGradientSaturation);