]> gerrit.simantics Code Review - simantics/district.git/commitdiff
First draft of vertex size adjusting district network diagram profiles 58/2258/2
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 28 Sep 2018 13:33:33 +0000 (16:33 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 28 Sep 2018 13:55:24 +0000 (16:55 +0300)
* Non-scaling edge/vertex rendering is now limited to view scale range
  [1,5] which supports seems to work well for current models.
* View zooming is now limited to range [0.01, 10000].
* Vertices and edges can be separately hidden with respective profile
  entries

gitlab #2

Change-Id: If8015fc4d65db88abb8c307b14be9139a4450c0d
(cherry picked from commit 29914be09d4a237840e5c793bdb562ec83093b8d)

18 files changed:
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 [new file with mode: 0644]
org.simantics.district.network.ui.ontology/src/org/simantics/district/network/ui/ontology/DistrictNetworkUIResource.java [new file with mode: 0644]
org.simantics.district.network.ui/src/org/simantics/district/network/ui/DistrictDiagramViewer.java
org.simantics.district.network.ui/src/org/simantics/district/network/ui/adapters/DistrictNetworkEdgeElement.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.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkVertexNode.java
org.simantics.district.network/META-INF/MANIFEST.MF
org.simantics.district.network/adapters.xml
org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettings.java
org.simantics.district.network/src/org/simantics/district/network/profile/DiagramSettingsRequest.java
org.simantics.district.network/src/org/simantics/district/network/profile/DistrictNodeGroup.java [new file with mode: 0644]
org.simantics.district.network/src/org/simantics/district/network/profile/EdgeThicknessStyle.java [moved from org.simantics.district.network/src/org/simantics/district/network/profile/EdgeStyle.java with 83% similarity]
org.simantics.district.network/src/org/simantics/district/network/profile/HideStyle.java [new file with mode: 0644]
org.simantics.district.network/src/org/simantics/district/network/profile/VertexSizeStyle.java [new file with mode: 0644]
org.simantics.district.network/src/org/simantics/district/network/profile/VertexStyle.java [deleted file]

index f01546e38ad02dbcfc25fddcfc38930f1d421ecb..10744ea144927aa7120f9d87fd947ba9fa5231c2 100644 (file)
@@ -17,47 +17,88 @@ DN.EdgeThicknessPropertyParameterType <T SEL.GenericParameterType
             SEL.HasEnumerationValues DN.Functions.edgeThicknessPropertyEnumerationValues : L0.Function
             SEL.HasCustomModifier DN.Functions.edgeThicknessPropertyModifier : L0.Function
 
-DN.Vertex.ScaleProperty <T L0.Value
-    >-- DN.Vertex.ScaleProperty.value --> L0.Relation <R L0.HasProperty : SEL.GenericParameterType
+DN.VertexScalePropertyParameterType <T SEL.GenericParameterType
+    @L0.assert SEL.HasDisplayValue
+        _ : SEL.DisplayValue
+            SEL.HasEnumerationValues DN.Functions.nodeScalePropertyEnumerationValues : L0.Function
+            SEL.HasCustomModifier DN.Functions.nodeScalePropertyModifier : L0.Function
+
+DN.Edge.ThicknessProperty <T L0.Value
+    @L0.assert L0.ConvertsToValueWith DN.Functions.convertToValue
+    >-- DN.Edge.ThicknessProperty.value ==> "Resource -> <ReadGraph> Maybe Double" <R L0.HasProperty : SEL.GenericParameterType
+        L0.readOnly true
+    >-- DN.Edge.ThicknessProperty.gain --> L0.Double <R L0.HasProperty : SEL.GenericParameterType
         L0.readOnly true
-    >-- DN.Vertex.ScaleProperty.scale ==> "Double" <R L0.HasProperty : SEL.GenericParameterType
+    >-- DN.Edge.ThicknessProperty.bias --> L0.Double <R L0.HasProperty : SEL.GenericParameterType
         L0.readOnly true
+    @L0.assert DN.Edge.ThicknessProperty.gain 1.0
+    @L0.assert DN.Edge.ThicknessProperty.bias 0.0
 
-DN.Edge.ThicknessProperty <T L0.Value
-    >-- DN.Edge.ThicknessProperty.scale --> L0.Double <R L0.HasProperty : SEL.GenericParameterType
+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
+        L0.readOnly true
+    >-- DN.Vertex.ScaleProperty.gain ==> "Double" <R L0.HasProperty : SEL.GenericParameterType
         L0.readOnly true
-    >-- DN.Edge.ThicknessProperty.value --> L0.Relation <R L0.HasProperty : SEL.GenericParameterType
+    >-- DN.Vertex.ScaleProperty.bias ==> "Double" <R L0.HasProperty : SEL.GenericParameterType
         L0.readOnly true
+    @L0.assert DN.Vertex.ScaleProperty.gain 1.0
+    @L0.assert DN.Vertex.ScaleProperty.bias 0.0
 
 DN.Diagram
-    //>-- DN.Diagram.nodeScale ==> "Double" <R L0.HasProperty : SEL.GenericParameterType
-    //    L0.HasLabel "Node Scale"
-    //>-- DN.Diagram.nodeScalingProperty --> DN.Vertex.ScaleProperty <R L0.HasProperty : SEL.GenericParameterType
-    //   L0.HasLabel "Node Scaling Property"
-    >-- DN.Diagram.edgeThicknessScale ==> "Double" <R L0.HasProperty : SEL.GenericParameterType
-        L0.HasLabel "Edge Thickness Scale"
+    >-- DN.Diagram.edgeThicknessGain ==> "Double" <R L0.HasProperty : SEL.GenericParameterType
+        L0.HasLabel "Edge Thickness Gain"
+    >-- DN.Diagram.edgeThicknessBias ==> "Double" <R L0.HasProperty : SEL.GenericParameterType
+        L0.HasLabel "Edge Thickness Bias"
     >-- DN.Diagram.edgeThicknessProperty --> DN.Edge.ThicknessProperty <R L0.HasProperty : DN.EdgeThicknessPropertyParameterType
         L0.HasLabel "Edge Thickness Property"
-    //@L0.assert DN.Diagram.nodeScale 1.0
-    //@L0.assert DN.Diagram.nodeScaleProperty DN.Vertex.ScaleProperty.SupplyPressure
-    @L0.assert DN.Diagram.edgeThicknessScale 1.0
+    >-- DN.Diagram.nodeScaleGain ==> "Double" <R L0.HasProperty : SEL.GenericParameterType
+        L0.HasLabel "Node Scale Gain"
+    >-- DN.Diagram.nodeScaleBias ==> "Double" <R L0.HasProperty : SEL.GenericParameterType
+        L0.HasLabel "Node Scale Bias"
+    >-- DN.Diagram.nodeScaleProperty --> DN.Vertex.ScaleProperty <R L0.HasProperty : DN.VertexScalePropertyParameterType
+        L0.HasLabel "Node Scale Property"
+    @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.nodeScaleGain 1.0
+    @L0.assert DN.Diagram.nodeScaleBias 0.0
+    @L0.assert DN.Diagram.nodeScaleProperty DN.Vertex.ScaleProperty.NominalSupplyPressure
 
 // ----------------------------------------------------------------------------
 // Built-in enumerated ScaleProperty & ThicknessProperty instances
 
-//DN.Vertex.ScaleProperty.SupplyPressure : DN.Vertex.ColorProperty
-//    L0.HasLabel "Nominal Supply Pressure"
-//    DN.Vertex.ScaleProperty.value DN.Vertex.HasSupplyPressure
-//    DN.Vertex.ScaleProperty.scale 1.0
+DN.Edge.ThicknessProperty.OnlyGainAndBias: DN.Edge.ThicknessProperty
+    L0.HasLabel "Only Gain and Bias"
+    DN.Edge.ThicknessProperty.value
+        DN.Functions.constantOne : L0.Function
+            L0.HasValueType "Resource -> <ReadGraph> Maybe Double"
 
 DN.Edge.ThicknessProperty.Diameter : DN.Edge.ThicknessProperty
     L0.HasLabel "Diameter"
-    DN.Edge.ThicknessProperty.value DN.Edge.HasDiameter
-    DN.Edge.ThicknessProperty.scale 0.001
+    DN.Edge.ThicknessProperty.value
+        DN.Functions.hasDiameterValue : L0.Function
+            L0.HasValueType "Resource -> <ReadGraph> Maybe Double"
+    DN.Edge.ThicknessProperty.gain 0.001
+
+
+DN.Vertex.ScaleProperty.OnlyGainAndBias: DN.Vertex.ScaleProperty
+    L0.HasLabel "Only Gain and Bias"
+    DN.Vertex.ScaleProperty.value
+        DN.Functions.constantOne : L0.Function
+            L0.HasValueType "Resource -> <ReadGraph> Maybe Double"
 
-DN.Edge.ThicknessProperty.NominalMassFlow : DN.Edge.ThicknessProperty
-    L0.HasLabel "Nominal Mass Flow"
-    DN.Edge.ThicknessProperty.value DN.Edge.HasNominalMassFlow
-    DN.Edge.ThicknessProperty.scale 1.0
+DN.Vertex.ScaleProperty.NominalSupplyPressure : DN.Vertex.ScaleProperty
+    L0.HasLabel "Nominal Supply Pressure"
+    DN.Vertex.ScaleProperty.value
+        DN.Functions.hasNominalSupplyPressure : L0.Function
+            L0.HasValueType "Resource -> <ReadGraph> 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 -> <ReadGraph> Maybe Double"
+    DN.Vertex.ScaleProperty.gain 0.1
+    DN.Vertex.ScaleProperty.bias 0.001
index d00bf42259b1db2314b7a7949623d027e6b5d572..773ddd300212727fd3a8d869bd9aeebf042ea467 100644 (file)
@@ -9,27 +9,16 @@ SEL_UI = <http://www.simantics.org/SelectionViewUI-1.1>
 G2D = <http://www.simantics.org/G2D-1.1>
 DN = <http://www.simantics.org/DistrictNetwork-1.0>
 
-/*
-DN.DistrictProfile : DIA.Profile
-    L0.HasLabel "District Network Profile"
-    DIA.Profile.priority 0.0
-    DIA.HasEntries
-      _ : DIA.Profile
-        @L0.list
-          DN.DistrictProfile.entry1
-            L0.HasLabel "Node Coloring"
-            @DIA.groupStyleProfileEntry DN.VertexStyle DN.Groups.VertexGroup
-          DN.DistrictProfile.entry2
-            L0.HasLabel "Edge Styling"
-            @DIA.groupStyleProfileEntry DN.EdgeStyle DN.Groups.EdgeGroup
-*/
-
 DN.Groups : L0.Library
 
+DN.DistrictNodeGroup <T DIA.TypeGroup
+    >-- DN.DistrictNodeGroup.hasComponentTypeName ==> "String" <R L0.HasProperty
+
 DN.Groups.VertexGroup : DIA.TypeGroup
-  DIA.TypeGroup.HasType DN.Vertex
+    DIA.TypeGroup.HasType DN.Vertex
 DN.Groups.EdgeGroup : DIA.TypeGroup
-  DIA.TypeGroup.HasType DN.Edge
+    DIA.TypeGroup.HasType DN.Edge
 
-DN.VertexStyle : DIA.Style
-DN.EdgeStyle : DIA.Style
+DN.VertexSizeStyle : DIA.Style
+DN.EdgeThicknessStyle : DIA.Style
+DN.HideStyle : 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
new file mode 100644 (file)
index 0000000..2f00824
--- /dev/null
@@ -0,0 +1,790 @@
+package org.simantics.district.network.ontology;
+
+import org.simantics.db.RequestProcessor;
+import org.simantics.db.Resource;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.request.Read;
+import org.simantics.db.Session;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.service.QueryControl;
+
+public class DistrictNetworkResource {
+    
+    public final Resource ActionContext;
+    public final Resource ActionContext_newDiagramContribution;
+    public final Resource Actions;
+    public final Resource Actions_NewDNDiagram;
+    public final Resource AddLayerToDNDiagramTemplate;
+    public final Resource BrowseContext;
+    public final Resource Composite;
+    public final Resource Connection;
+    public final Resource Diagram;
+    public final Resource Diagram_MappedDiagram;
+    public final Resource Diagram_MappedFromDiagram;
+    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_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 DistrictNodeGroup;
+    public final Resource DistrictNodeGroup_hasComponentTypeName;
+    public final Resource DistrictNodeGroup_hasComponentTypeName_Inverse;
+    public final Resource EPSG_4326;
+    public final Resource Edge;
+    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_HasDiameter;
+    public final Resource Edge_HasDiameter_Inverse;
+    public final Resource Edge_HasElevation;
+    public final Resource Edge_HasElevation_Inverse;
+    public final Resource Edge_HasFlowArea;
+    public final Resource Edge_HasFlowArea_Inverse;
+    public final Resource Edge_HasKReturn;
+    public final Resource Edge_HasKReturn_Inverse;
+    public final Resource Edge_HasKSupply;
+    public final Resource Edge_HasKSupply_Inverse;
+    public final Resource Edge_HasLength;
+    public final Resource Edge_HasLength_Inverse;
+    public final Resource Edge_HasNominalMassFlow;
+    public final Resource Edge_HasNominalMassFlow_Inverse;
+    public final Resource Edge_HasOuterDiameter;
+    public final Resource Edge_HasOuterDiameter_Inverse;
+    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_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 Functions;
+    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_hasNominalSupplyPressure;
+    public final Resource Functions_mappingModifier;
+    public final Resource Functions_nodeScalePropertyEnumerationValues;
+    public final Resource Functions_nodeScalePropertyModifier;
+    public final Resource Groups;
+    public final Resource Groups_EdgeGroup;
+    public final Resource Groups_VertexGroup;
+    public final Resource HasEndVertex;
+    public final Resource HasEndVertex_Inverse;
+    public final Resource HasId;
+    public final Resource HasId_Inverse;
+    public final Resource HasInLayerTag;
+    public final Resource HasInLayerTag_Inverse;
+    public final Resource HasMapping;
+    public final Resource HasMapping_Inverse;
+    public final Resource HasSRID;
+    public final Resource HasSRID_Inverse;
+    public final Resource HasSRTEXT;
+    public final Resource HasSRTEXT_Inverse;
+    public final Resource HasSpatialRefSystem;
+    public final Resource HasSpatialRefSystem_Inverse;
+    public final Resource HasStartVertex;
+    public final Resource HasStartVertex_Inverse;
+    public final Resource HideStyle;
+    public final Resource Images;
+    public final Resource Images_MapImage;
+    public final Resource InLayer;
+    public final Resource Layer;
+    public final Resource MappedComponent;
+    public final Resource MappedFromElement;
+    public final Resource Mapping;
+    public final Resource MappingParameterType;
+    public final Resource Mapping_Base;
+    public final Resource Mapping_ComponentType;
+    public final Resource Mapping_ComponentType_Inverse;
+    public final Resource Mapping_EdgeMapping;
+    public final Resource Mapping_EdgeMapping_DiameterAttribute;
+    public final Resource Mapping_EdgeMapping_DiameterAttribute_Inverse;
+    public final Resource Mapping_EdgeMapping_ElevationAttribute;
+    public final Resource Mapping_EdgeMapping_ElevationAttribute_Inverse;
+    public final Resource Mapping_EdgeMapping_FlowAreaAttribute;
+    public final Resource Mapping_EdgeMapping_FlowAreaAttribute_Inverse;
+    public final Resource Mapping_EdgeMapping_KReturnAttribute;
+    public final Resource Mapping_EdgeMapping_KReturnAttribute_Inverse;
+    public final Resource Mapping_EdgeMapping_KSupplyAttribute;
+    public final Resource Mapping_EdgeMapping_KSupplyAttribute_Inverse;
+    public final Resource Mapping_EdgeMapping_LengthAttribute;
+    public final Resource Mapping_EdgeMapping_LengthAttribute_Inverse;
+    public final Resource Mapping_EdgeMapping_NominalMassFlowAttribute;
+    public final Resource Mapping_EdgeMapping_NominalMassFlowAttribute_Inverse;
+    public final Resource Mapping_EdgeMapping_OuterDiameterAttribute;
+    public final Resource Mapping_EdgeMapping_OuterDiameterAttribute_Inverse;
+    public final Resource Mapping_EdgeMapping_TGroundAttribute;
+    public final Resource Mapping_EdgeMapping_TGroundAttribute_Inverse;
+    public final Resource Mapping_Id;
+    public final Resource Mapping_Id_Inverse;
+    public final Resource Mapping_InputTerminal;
+    public final Resource Mapping_InputTerminal_Inverse;
+    public final Resource Mapping_OutputTerminal;
+    public final Resource Mapping_OutputTerminal_Inverse;
+    public final Resource Mapping_Terminal;
+    public final Resource Mapping_TerminalPair;
+    public final Resource Mapping_Terminals;
+    public final Resource Mapping_Terminals_Inverse;
+    public final Resource Mapping_VertexMapping;
+    public final Resource Mapping_VertexMapping_AddressAttribute;
+    public final Resource Mapping_VertexMapping_AddressAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_DeltaPressureAttribute;
+    public final Resource Mapping_VertexMapping_DeltaPressureAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_DeltaTemperatureAttribute;
+    public final Resource Mapping_VertexMapping_DeltaTemperatureAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_ElevationAttribute;
+    public final Resource Mapping_VertexMapping_ElevationAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_FlowAreaAttribute;
+    public final Resource Mapping_VertexMapping_FlowAreaAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_HeatLoadDsAttribute;
+    public final Resource Mapping_VertexMapping_HeatLoadDsAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_HeatPowerAttribute;
+    public final Resource Mapping_VertexMapping_HeatPowerAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_MassFlowAttribute;
+    public final Resource Mapping_VertexMapping_MassFlowAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_MaximumHeadMAttribute;
+    public final Resource Mapping_VertexMapping_MaximumHeadMAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_NominalFlowAttribute;
+    public final Resource Mapping_VertexMapping_NominalFlowAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_NominalHeadBAttribute;
+    public final Resource Mapping_VertexMapping_NominalHeadBAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_NominalHeadMAttribute;
+    public final Resource Mapping_VertexMapping_NominalHeadMAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_NominalMassFlowAttribute;
+    public final Resource Mapping_VertexMapping_NominalMassFlowAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_NominalPressureLossAttribute;
+    public final Resource Mapping_VertexMapping_NominalPressureLossAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_ReturnPressureAttribute;
+    public final Resource Mapping_VertexMapping_ReturnPressureAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_ReturnTemperatureAttribute;
+    public final Resource Mapping_VertexMapping_ReturnTemperatureAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_SupplyPressureAttribute;
+    public final Resource Mapping_VertexMapping_SupplyPressureAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_SupplyTemperatureAttribute;
+    public final Resource Mapping_VertexMapping_SupplyTemperatureAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_ValvePositionAttribute;
+    public final Resource Mapping_VertexMapping_ValvePositionAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_VelocityAttribute;
+    public final Resource Mapping_VertexMapping_VelocityAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_VolFlowAttribute;
+    public final Resource Mapping_VertexMapping_VolFlowAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_XAttribute;
+    public final Resource Mapping_VertexMapping_XAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_YAttribute;
+    public final Resource Mapping_VertexMapping_YAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_dpAttribute;
+    public final Resource Mapping_VertexMapping_dpAttribute_Inverse;
+    public final Resource Mapping_VertexMapping_dtAttribute;
+    public final Resource Mapping_VertexMapping_dtAttribute_Inverse;
+    public final Resource SCLMain;
+    public final Resource SpatialRefSystem;
+    public final Resource Vertex;
+    public final Resource VertexDefaultMapping;
+    public final Resource VertexDefaultMapping_Inverse;
+    public final Resource VertexMappingParameterType;
+    public final Resource VertexScalePropertyParameterType;
+    public final Resource VertexSizeStyle;
+    public final Resource Vertex_HasAddress;
+    public final Resource Vertex_HasAddress_Inverse;
+    public final Resource Vertex_HasDeltaPressure;
+    public final Resource Vertex_HasDeltaPressure_Inverse;
+    public final Resource Vertex_HasDeltaTemperature;
+    public final Resource Vertex_HasDeltaTemperature_Inverse;
+    public final Resource Vertex_HasElevation;
+    public final Resource Vertex_HasElevation_Inverse;
+    public final Resource Vertex_HasFlowArea;
+    public final Resource Vertex_HasFlowArea_Inverse;
+    public final Resource Vertex_HasHeatLoadDs;
+    public final Resource Vertex_HasHeatLoadDs_Inverse;
+    public final Resource Vertex_HasHeatPower;
+    public final Resource Vertex_HasHeatPower_Inverse;
+    public final Resource Vertex_HasMassFlow;
+    public final Resource Vertex_HasMassFlow_Inverse;
+    public final Resource Vertex_HasMaximumHeadM;
+    public final Resource Vertex_HasMaximumHeadM_Inverse;
+    public final Resource Vertex_HasNominalFlow;
+    public final Resource Vertex_HasNominalFlow_Inverse;
+    public final Resource Vertex_HasNominalHeadB;
+    public final Resource Vertex_HasNominalHeadB_Inverse;
+    public final Resource Vertex_HasNominalHeadM;
+    public final Resource Vertex_HasNominalHeadM_Inverse;
+    public final Resource Vertex_HasNominalPressureLoss;
+    public final Resource Vertex_HasNominalPressureLoss_Inverse;
+    public final Resource Vertex_HasReturnPressure;
+    public final Resource Vertex_HasReturnPressure_Inverse;
+    public final Resource Vertex_HasReturnTemperature;
+    public final Resource Vertex_HasReturnTemperature_Inverse;
+    public final Resource Vertex_HasSupplyPressure;
+    public final Resource Vertex_HasSupplyPressure_Inverse;
+    public final Resource Vertex_HasSupplyTemperature;
+    public final Resource Vertex_HasSupplyTemperature_Inverse;
+    public final Resource Vertex_HasValvePosition;
+    public final Resource Vertex_HasValvePosition_Inverse;
+    public final Resource Vertex_HasVelocity;
+    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";
+        public static final String ActionContext_newDiagramContribution = "http://www.simantics.org/DistrictNetwork-1.0/ActionContext/newDiagramContribution";
+        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 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";
+        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_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_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 DistrictNodeGroup = "http://www.simantics.org/DistrictNetwork-1.0/DistrictNodeGroup";
+        public static final String DistrictNodeGroup_hasComponentTypeName = "http://www.simantics.org/DistrictNetwork-1.0/DistrictNodeGroup/hasComponentTypeName";
+        public static final String DistrictNodeGroup_hasComponentTypeName_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/DistrictNodeGroup/hasComponentTypeName/Inverse";
+        public static final String EPSG_4326 = "http://www.simantics.org/DistrictNetwork-1.0/EPSG_4326";
+        public static final String Edge = "http://www.simantics.org/DistrictNetwork-1.0/Edge";
+        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_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";
+        public static final String Edge_HasElevation_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasElevation/Inverse";
+        public static final String Edge_HasFlowArea = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasFlowArea";
+        public static final String Edge_HasFlowArea_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasFlowArea/Inverse";
+        public static final String Edge_HasKReturn = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasKReturn";
+        public static final String Edge_HasKReturn_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasKReturn/Inverse";
+        public static final String Edge_HasKSupply = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasKSupply";
+        public static final String Edge_HasKSupply_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasKSupply/Inverse";
+        public static final String Edge_HasLength = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasLength";
+        public static final String Edge_HasLength_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasLength/Inverse";
+        public static final String Edge_HasNominalMassFlow = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasNominalMassFlow";
+        public static final String Edge_HasNominalMassFlow_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasNominalMassFlow/Inverse";
+        public static final String Edge_HasOuterDiameter = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasOuterDiameter";
+        public static final String Edge_HasOuterDiameter_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasOuterDiameter/Inverse";
+        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_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 Functions = "http://www.simantics.org/DistrictNetwork-1.0/Functions";
+        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_hasNominalSupplyPressure = "http://www.simantics.org/DistrictNetwork-1.0/Functions/hasNominalSupplyPressure";
+        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 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";
+        public static final String HasEndVertex = "http://www.simantics.org/DistrictNetwork-1.0/HasEndVertex";
+        public static final String HasEndVertex_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasEndVertex_Inverse";
+        public static final String HasId = "http://www.simantics.org/DistrictNetwork-1.0/HasId";
+        public static final String HasId_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasId/Inverse";
+        public static final String HasInLayerTag = "http://www.simantics.org/DistrictNetwork-1.0/HasInLayerTag";
+        public static final String HasInLayerTag_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasInLayerTag/Inverse";
+        public static final String HasMapping = "http://www.simantics.org/DistrictNetwork-1.0/HasMapping";
+        public static final String HasMapping_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasMapping/Inverse";
+        public static final String HasSRID = "http://www.simantics.org/DistrictNetwork-1.0/HasSRID";
+        public static final String HasSRID_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasSRID/Inverse";
+        public static final String HasSRTEXT = "http://www.simantics.org/DistrictNetwork-1.0/HasSRTEXT";
+        public static final String HasSRTEXT_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasSRTEXT/Inverse";
+        public static final String HasSpatialRefSystem = "http://www.simantics.org/DistrictNetwork-1.0/HasSpatialRefSystem";
+        public static final String HasSpatialRefSystem_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasSpatialRefSystem/Inverse";
+        public static final String HasStartVertex = "http://www.simantics.org/DistrictNetwork-1.0/HasStartVertex";
+        public static final String HasStartVertex_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasStartVertex_Inverse";
+        public static final String HideStyle = "http://www.simantics.org/DistrictNetwork-1.0/HideStyle";
+        public static final String Images = "http://www.simantics.org/DistrictNetwork-1.0/Images";
+        public static final String Images_MapImage = "http://www.simantics.org/DistrictNetwork-1.0/Images/MapImage";
+        public static final String InLayer = "http://www.simantics.org/DistrictNetwork-1.0/InLayer";
+        public static final String Layer = "http://www.simantics.org/DistrictNetwork-1.0/Layer";
+        public static final String MappedComponent = "http://www.simantics.org/DistrictNetwork-1.0/MappedComponent";
+        public static final String MappedFromElement = "http://www.simantics.org/DistrictNetwork-1.0/MappedFromElement";
+        public static final String Mapping = "http://www.simantics.org/DistrictNetwork-1.0/Mapping";
+        public static final String MappingParameterType = "http://www.simantics.org/DistrictNetwork-1.0/MappingParameterType";
+        public static final String Mapping_Base = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/Base";
+        public static final String Mapping_ComponentType = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/ComponentType";
+        public static final String Mapping_ComponentType_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/ComponentType/Inverse";
+        public static final String Mapping_EdgeMapping = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping";
+        public static final String Mapping_EdgeMapping_DiameterAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/DiameterAttribute";
+        public static final String Mapping_EdgeMapping_DiameterAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/DiameterAttribute/Inverse";
+        public static final String Mapping_EdgeMapping_ElevationAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/ElevationAttribute";
+        public static final String Mapping_EdgeMapping_ElevationAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/ElevationAttribute/Inverse";
+        public static final String Mapping_EdgeMapping_FlowAreaAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/FlowAreaAttribute";
+        public static final String Mapping_EdgeMapping_FlowAreaAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/FlowAreaAttribute/Inverse";
+        public static final String Mapping_EdgeMapping_KReturnAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/KReturnAttribute";
+        public static final String Mapping_EdgeMapping_KReturnAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/KReturnAttribute/Inverse";
+        public static final String Mapping_EdgeMapping_KSupplyAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/KSupplyAttribute";
+        public static final String Mapping_EdgeMapping_KSupplyAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/KSupplyAttribute/Inverse";
+        public static final String Mapping_EdgeMapping_LengthAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/LengthAttribute";
+        public static final String Mapping_EdgeMapping_LengthAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/LengthAttribute/Inverse";
+        public static final String Mapping_EdgeMapping_NominalMassFlowAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/NominalMassFlowAttribute";
+        public static final String Mapping_EdgeMapping_NominalMassFlowAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/NominalMassFlowAttribute/Inverse";
+        public static final String Mapping_EdgeMapping_OuterDiameterAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/OuterDiameterAttribute";
+        public static final String Mapping_EdgeMapping_OuterDiameterAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/OuterDiameterAttribute/Inverse";
+        public static final String Mapping_EdgeMapping_TGroundAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/TGroundAttribute";
+        public static final String Mapping_EdgeMapping_TGroundAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/TGroundAttribute/Inverse";
+        public static final String Mapping_Id = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/Id";
+        public static final String Mapping_Id_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/Id/Inverse";
+        public static final String Mapping_InputTerminal = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/InputTerminal";
+        public static final String Mapping_InputTerminal_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/InputTerminal/Inverse";
+        public static final String Mapping_OutputTerminal = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/OutputTerminal";
+        public static final String Mapping_OutputTerminal_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/OutputTerminal/Inverse";
+        public static final String Mapping_Terminal = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/Terminal";
+        public static final String Mapping_TerminalPair = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/TerminalPair";
+        public static final String Mapping_Terminals = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/Terminals";
+        public static final String Mapping_Terminals_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/Terminals/Inverse";
+        public static final String Mapping_VertexMapping = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping";
+        public static final String Mapping_VertexMapping_AddressAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/AddressAttribute";
+        public static final String Mapping_VertexMapping_AddressAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/AddressAttribute/Inverse";
+        public static final String Mapping_VertexMapping_DeltaPressureAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/DeltaPressureAttribute";
+        public static final String Mapping_VertexMapping_DeltaPressureAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/DeltaPressureAttribute/Inverse";
+        public static final String Mapping_VertexMapping_DeltaTemperatureAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/DeltaTemperatureAttribute";
+        public static final String Mapping_VertexMapping_DeltaTemperatureAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/DeltaTemperatureAttribute/Inverse";
+        public static final String Mapping_VertexMapping_ElevationAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/ElevationAttribute";
+        public static final String Mapping_VertexMapping_ElevationAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/ElevationAttribute/Inverse";
+        public static final String Mapping_VertexMapping_FlowAreaAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/FlowAreaAttribute";
+        public static final String Mapping_VertexMapping_FlowAreaAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/FlowAreaAttribute/Inverse";
+        public static final String Mapping_VertexMapping_HeatLoadDsAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/HeatLoadDsAttribute";
+        public static final String Mapping_VertexMapping_HeatLoadDsAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/HeatLoadDsAttribute/Inverse";
+        public static final String Mapping_VertexMapping_HeatPowerAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/HeatPowerAttribute";
+        public static final String Mapping_VertexMapping_HeatPowerAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/HeatPowerAttribute/Inverse";
+        public static final String Mapping_VertexMapping_MassFlowAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/MassFlowAttribute";
+        public static final String Mapping_VertexMapping_MassFlowAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/MassFlowAttribute/Inverse";
+        public static final String Mapping_VertexMapping_MaximumHeadMAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/MaximumHeadMAttribute";
+        public static final String Mapping_VertexMapping_MaximumHeadMAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/MaximumHeadMAttribute/Inverse";
+        public static final String Mapping_VertexMapping_NominalFlowAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/NominalFlowAttribute";
+        public static final String Mapping_VertexMapping_NominalFlowAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/NominalFlowAttribute/Inverse";
+        public static final String Mapping_VertexMapping_NominalHeadBAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/NominalHeadBAttribute";
+        public static final String Mapping_VertexMapping_NominalHeadBAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/NominalHeadBAttribute/Inverse";
+        public static final String Mapping_VertexMapping_NominalHeadMAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/NominalHeadMAttribute";
+        public static final String Mapping_VertexMapping_NominalHeadMAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/NominalHeadMAttribute/Inverse";
+        public static final String Mapping_VertexMapping_NominalMassFlowAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/NominalMassFlowAttribute";
+        public static final String Mapping_VertexMapping_NominalMassFlowAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/NominalMassFlowAttribute/Inverse";
+        public static final String Mapping_VertexMapping_NominalPressureLossAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/NominalPressureLossAttribute";
+        public static final String Mapping_VertexMapping_NominalPressureLossAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/NominalPressureLossAttribute/Inverse";
+        public static final String Mapping_VertexMapping_ReturnPressureAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/ReturnPressureAttribute";
+        public static final String Mapping_VertexMapping_ReturnPressureAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/ReturnPressureAttribute/Inverse";
+        public static final String Mapping_VertexMapping_ReturnTemperatureAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/ReturnTemperatureAttribute";
+        public static final String Mapping_VertexMapping_ReturnTemperatureAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/ReturnTemperatureAttribute/Inverse";
+        public static final String Mapping_VertexMapping_SupplyPressureAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/SupplyPressureAttribute";
+        public static final String Mapping_VertexMapping_SupplyPressureAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/SupplyPressureAttribute/Inverse";
+        public static final String Mapping_VertexMapping_SupplyTemperatureAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/SupplyTemperatureAttribute";
+        public static final String Mapping_VertexMapping_SupplyTemperatureAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/SupplyTemperatureAttribute/Inverse";
+        public static final String Mapping_VertexMapping_ValvePositionAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/ValvePositionAttribute";
+        public static final String Mapping_VertexMapping_ValvePositionAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/ValvePositionAttribute/Inverse";
+        public static final String Mapping_VertexMapping_VelocityAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/VelocityAttribute";
+        public static final String Mapping_VertexMapping_VelocityAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/VelocityAttribute/Inverse";
+        public static final String Mapping_VertexMapping_VolFlowAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/VolFlowAttribute";
+        public static final String Mapping_VertexMapping_VolFlowAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/VolFlowAttribute/Inverse";
+        public static final String Mapping_VertexMapping_XAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/XAttribute";
+        public static final String Mapping_VertexMapping_XAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/XAttribute/Inverse";
+        public static final String Mapping_VertexMapping_YAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/YAttribute";
+        public static final String Mapping_VertexMapping_YAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/YAttribute/Inverse";
+        public static final String Mapping_VertexMapping_dpAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/dpAttribute";
+        public static final String Mapping_VertexMapping_dpAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/dpAttribute/Inverse";
+        public static final String Mapping_VertexMapping_dtAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/dtAttribute";
+        public static final String Mapping_VertexMapping_dtAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/dtAttribute/Inverse";
+        public static final String SCLMain = "http://www.simantics.org/DistrictNetwork-1.0/SCLMain";
+        public static final String SpatialRefSystem = "http://www.simantics.org/DistrictNetwork-1.0/SpatialRefSystem";
+        public static final String Vertex = "http://www.simantics.org/DistrictNetwork-1.0/Vertex";
+        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 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";
+        public static final String Vertex_HasDeltaPressure = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasDeltaPressure";
+        public static final String Vertex_HasDeltaPressure_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasDeltaPressure/Inverse";
+        public static final String Vertex_HasDeltaTemperature = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasDeltaTemperature";
+        public static final String Vertex_HasDeltaTemperature_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasDeltaTemperature/Inverse";
+        public static final String Vertex_HasElevation = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasElevation";
+        public static final String Vertex_HasElevation_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasElevation/Inverse";
+        public static final String Vertex_HasFlowArea = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasFlowArea";
+        public static final String Vertex_HasFlowArea_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasFlowArea/Inverse";
+        public static final String Vertex_HasHeatLoadDs = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasHeatLoadDs";
+        public static final String Vertex_HasHeatLoadDs_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasHeatLoadDs/Inverse";
+        public static final String Vertex_HasHeatPower = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasHeatPower";
+        public static final String Vertex_HasHeatPower_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasHeatPower/Inverse";
+        public static final String Vertex_HasMassFlow = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasMassFlow";
+        public static final String Vertex_HasMassFlow_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasMassFlow/Inverse";
+        public static final String Vertex_HasMaximumHeadM = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasMaximumHeadM";
+        public static final String Vertex_HasMaximumHeadM_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasMaximumHeadM/Inverse";
+        public static final String Vertex_HasNominalFlow = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasNominalFlow";
+        public static final String Vertex_HasNominalFlow_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasNominalFlow/Inverse";
+        public static final String Vertex_HasNominalHeadB = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasNominalHeadB";
+        public static final String Vertex_HasNominalHeadB_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasNominalHeadB/Inverse";
+        public static final String Vertex_HasNominalHeadM = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasNominalHeadM";
+        public static final String Vertex_HasNominalHeadM_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasNominalHeadM/Inverse";
+        public static final String Vertex_HasNominalPressureLoss = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasNominalPressureLoss";
+        public static final String Vertex_HasNominalPressureLoss_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasNominalPressureLoss/Inverse";
+        public static final String Vertex_HasReturnPressure = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasReturnPressure";
+        public static final String Vertex_HasReturnPressure_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasReturnPressure/Inverse";
+        public static final String Vertex_HasReturnTemperature = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasReturnTemperature";
+        public static final String Vertex_HasReturnTemperature_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasReturnTemperature/Inverse";
+        public static final String Vertex_HasSupplyPressure = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasSupplyPressure";
+        public static final String Vertex_HasSupplyPressure_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasSupplyPressure/Inverse";
+        public static final String Vertex_HasSupplyTemperature = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasSupplyTemperature";
+        public static final String Vertex_HasSupplyTemperature_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasSupplyTemperature/Inverse";
+        public static final String Vertex_HasValvePosition = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasValvePosition";
+        public static final String Vertex_HasValvePosition_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasValvePosition/Inverse";
+        public static final String Vertex_HasVelocity = "http://www.simantics.org/DistrictNetwork-1.0/Vertex/HasVelocity";
+        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) {
+        try {
+            return graph.getResource(uri);
+        } catch(DatabaseException e) {
+            System.err.println(e.getMessage());
+            return null;
+        }
+    }
+    
+    public DistrictNetworkResource(ReadGraph graph) {
+        ActionContext = getResourceOrNull(graph, URIs.ActionContext);
+        ActionContext_newDiagramContribution = getResourceOrNull(graph, URIs.ActionContext_newDiagramContribution);
+        Actions = getResourceOrNull(graph, URIs.Actions);
+        Actions_NewDNDiagram = getResourceOrNull(graph, URIs.Actions_NewDNDiagram);
+        AddLayerToDNDiagramTemplate = getResourceOrNull(graph, URIs.AddLayerToDNDiagramTemplate);
+        BrowseContext = getResourceOrNull(graph, URIs.BrowseContext);
+        Composite = getResourceOrNull(graph, URIs.Composite);
+        Connection = getResourceOrNull(graph, URIs.Connection);
+        Diagram = getResourceOrNull(graph, URIs.Diagram);
+        Diagram_MappedDiagram = getResourceOrNull(graph, URIs.Diagram_MappedDiagram);
+        Diagram_MappedFromDiagram = getResourceOrNull(graph, URIs.Diagram_MappedFromDiagram);
+        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_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);
+        DistrictNodeGroup = getResourceOrNull(graph, URIs.DistrictNodeGroup);
+        DistrictNodeGroup_hasComponentTypeName = getResourceOrNull(graph, URIs.DistrictNodeGroup_hasComponentTypeName);
+        DistrictNodeGroup_hasComponentTypeName_Inverse = getResourceOrNull(graph, URIs.DistrictNodeGroup_hasComponentTypeName_Inverse);
+        EPSG_4326 = getResourceOrNull(graph, URIs.EPSG_4326);
+        Edge = getResourceOrNull(graph, URIs.Edge);
+        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_HasDiameter = getResourceOrNull(graph, URIs.Edge_HasDiameter);
+        Edge_HasDiameter_Inverse = getResourceOrNull(graph, URIs.Edge_HasDiameter_Inverse);
+        Edge_HasElevation = getResourceOrNull(graph, URIs.Edge_HasElevation);
+        Edge_HasElevation_Inverse = getResourceOrNull(graph, URIs.Edge_HasElevation_Inverse);
+        Edge_HasFlowArea = getResourceOrNull(graph, URIs.Edge_HasFlowArea);
+        Edge_HasFlowArea_Inverse = getResourceOrNull(graph, URIs.Edge_HasFlowArea_Inverse);
+        Edge_HasKReturn = getResourceOrNull(graph, URIs.Edge_HasKReturn);
+        Edge_HasKReturn_Inverse = getResourceOrNull(graph, URIs.Edge_HasKReturn_Inverse);
+        Edge_HasKSupply = getResourceOrNull(graph, URIs.Edge_HasKSupply);
+        Edge_HasKSupply_Inverse = getResourceOrNull(graph, URIs.Edge_HasKSupply_Inverse);
+        Edge_HasLength = getResourceOrNull(graph, URIs.Edge_HasLength);
+        Edge_HasLength_Inverse = getResourceOrNull(graph, URIs.Edge_HasLength_Inverse);
+        Edge_HasNominalMassFlow = getResourceOrNull(graph, URIs.Edge_HasNominalMassFlow);
+        Edge_HasNominalMassFlow_Inverse = getResourceOrNull(graph, URIs.Edge_HasNominalMassFlow_Inverse);
+        Edge_HasOuterDiameter = getResourceOrNull(graph, URIs.Edge_HasOuterDiameter);
+        Edge_HasOuterDiameter_Inverse = getResourceOrNull(graph, URIs.Edge_HasOuterDiameter_Inverse);
+        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_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);
+        Functions = getResourceOrNull(graph, URIs.Functions);
+        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_hasNominalSupplyPressure = getResourceOrNull(graph, URIs.Functions_hasNominalSupplyPressure);
+        Functions_mappingModifier = getResourceOrNull(graph, URIs.Functions_mappingModifier);
+        Functions_nodeScalePropertyEnumerationValues = getResourceOrNull(graph, URIs.Functions_nodeScalePropertyEnumerationValues);
+        Functions_nodeScalePropertyModifier = getResourceOrNull(graph, URIs.Functions_nodeScalePropertyModifier);
+        Groups = getResourceOrNull(graph, URIs.Groups);
+        Groups_EdgeGroup = getResourceOrNull(graph, URIs.Groups_EdgeGroup);
+        Groups_VertexGroup = getResourceOrNull(graph, URIs.Groups_VertexGroup);
+        HasEndVertex = getResourceOrNull(graph, URIs.HasEndVertex);
+        HasEndVertex_Inverse = getResourceOrNull(graph, URIs.HasEndVertex_Inverse);
+        HasId = getResourceOrNull(graph, URIs.HasId);
+        HasId_Inverse = getResourceOrNull(graph, URIs.HasId_Inverse);
+        HasInLayerTag = getResourceOrNull(graph, URIs.HasInLayerTag);
+        HasInLayerTag_Inverse = getResourceOrNull(graph, URIs.HasInLayerTag_Inverse);
+        HasMapping = getResourceOrNull(graph, URIs.HasMapping);
+        HasMapping_Inverse = getResourceOrNull(graph, URIs.HasMapping_Inverse);
+        HasSRID = getResourceOrNull(graph, URIs.HasSRID);
+        HasSRID_Inverse = getResourceOrNull(graph, URIs.HasSRID_Inverse);
+        HasSRTEXT = getResourceOrNull(graph, URIs.HasSRTEXT);
+        HasSRTEXT_Inverse = getResourceOrNull(graph, URIs.HasSRTEXT_Inverse);
+        HasSpatialRefSystem = getResourceOrNull(graph, URIs.HasSpatialRefSystem);
+        HasSpatialRefSystem_Inverse = getResourceOrNull(graph, URIs.HasSpatialRefSystem_Inverse);
+        HasStartVertex = getResourceOrNull(graph, URIs.HasStartVertex);
+        HasStartVertex_Inverse = getResourceOrNull(graph, URIs.HasStartVertex_Inverse);
+        HideStyle = getResourceOrNull(graph, URIs.HideStyle);
+        Images = getResourceOrNull(graph, URIs.Images);
+        Images_MapImage = getResourceOrNull(graph, URIs.Images_MapImage);
+        InLayer = getResourceOrNull(graph, URIs.InLayer);
+        Layer = getResourceOrNull(graph, URIs.Layer);
+        MappedComponent = getResourceOrNull(graph, URIs.MappedComponent);
+        MappedFromElement = getResourceOrNull(graph, URIs.MappedFromElement);
+        Mapping = getResourceOrNull(graph, URIs.Mapping);
+        MappingParameterType = getResourceOrNull(graph, URIs.MappingParameterType);
+        Mapping_Base = getResourceOrNull(graph, URIs.Mapping_Base);
+        Mapping_ComponentType = getResourceOrNull(graph, URIs.Mapping_ComponentType);
+        Mapping_ComponentType_Inverse = getResourceOrNull(graph, URIs.Mapping_ComponentType_Inverse);
+        Mapping_EdgeMapping = getResourceOrNull(graph, URIs.Mapping_EdgeMapping);
+        Mapping_EdgeMapping_DiameterAttribute = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_DiameterAttribute);
+        Mapping_EdgeMapping_DiameterAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_DiameterAttribute_Inverse);
+        Mapping_EdgeMapping_ElevationAttribute = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_ElevationAttribute);
+        Mapping_EdgeMapping_ElevationAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_ElevationAttribute_Inverse);
+        Mapping_EdgeMapping_FlowAreaAttribute = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_FlowAreaAttribute);
+        Mapping_EdgeMapping_FlowAreaAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_FlowAreaAttribute_Inverse);
+        Mapping_EdgeMapping_KReturnAttribute = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_KReturnAttribute);
+        Mapping_EdgeMapping_KReturnAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_KReturnAttribute_Inverse);
+        Mapping_EdgeMapping_KSupplyAttribute = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_KSupplyAttribute);
+        Mapping_EdgeMapping_KSupplyAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_KSupplyAttribute_Inverse);
+        Mapping_EdgeMapping_LengthAttribute = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_LengthAttribute);
+        Mapping_EdgeMapping_LengthAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_LengthAttribute_Inverse);
+        Mapping_EdgeMapping_NominalMassFlowAttribute = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_NominalMassFlowAttribute);
+        Mapping_EdgeMapping_NominalMassFlowAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_NominalMassFlowAttribute_Inverse);
+        Mapping_EdgeMapping_OuterDiameterAttribute = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_OuterDiameterAttribute);
+        Mapping_EdgeMapping_OuterDiameterAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_OuterDiameterAttribute_Inverse);
+        Mapping_EdgeMapping_TGroundAttribute = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_TGroundAttribute);
+        Mapping_EdgeMapping_TGroundAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_TGroundAttribute_Inverse);
+        Mapping_Id = getResourceOrNull(graph, URIs.Mapping_Id);
+        Mapping_Id_Inverse = getResourceOrNull(graph, URIs.Mapping_Id_Inverse);
+        Mapping_InputTerminal = getResourceOrNull(graph, URIs.Mapping_InputTerminal);
+        Mapping_InputTerminal_Inverse = getResourceOrNull(graph, URIs.Mapping_InputTerminal_Inverse);
+        Mapping_OutputTerminal = getResourceOrNull(graph, URIs.Mapping_OutputTerminal);
+        Mapping_OutputTerminal_Inverse = getResourceOrNull(graph, URIs.Mapping_OutputTerminal_Inverse);
+        Mapping_Terminal = getResourceOrNull(graph, URIs.Mapping_Terminal);
+        Mapping_TerminalPair = getResourceOrNull(graph, URIs.Mapping_TerminalPair);
+        Mapping_Terminals = getResourceOrNull(graph, URIs.Mapping_Terminals);
+        Mapping_Terminals_Inverse = getResourceOrNull(graph, URIs.Mapping_Terminals_Inverse);
+        Mapping_VertexMapping = getResourceOrNull(graph, URIs.Mapping_VertexMapping);
+        Mapping_VertexMapping_AddressAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_AddressAttribute);
+        Mapping_VertexMapping_AddressAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_AddressAttribute_Inverse);
+        Mapping_VertexMapping_DeltaPressureAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_DeltaPressureAttribute);
+        Mapping_VertexMapping_DeltaPressureAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_DeltaPressureAttribute_Inverse);
+        Mapping_VertexMapping_DeltaTemperatureAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_DeltaTemperatureAttribute);
+        Mapping_VertexMapping_DeltaTemperatureAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_DeltaTemperatureAttribute_Inverse);
+        Mapping_VertexMapping_ElevationAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_ElevationAttribute);
+        Mapping_VertexMapping_ElevationAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_ElevationAttribute_Inverse);
+        Mapping_VertexMapping_FlowAreaAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_FlowAreaAttribute);
+        Mapping_VertexMapping_FlowAreaAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_FlowAreaAttribute_Inverse);
+        Mapping_VertexMapping_HeatLoadDsAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_HeatLoadDsAttribute);
+        Mapping_VertexMapping_HeatLoadDsAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_HeatLoadDsAttribute_Inverse);
+        Mapping_VertexMapping_HeatPowerAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_HeatPowerAttribute);
+        Mapping_VertexMapping_HeatPowerAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_HeatPowerAttribute_Inverse);
+        Mapping_VertexMapping_MassFlowAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_MassFlowAttribute);
+        Mapping_VertexMapping_MassFlowAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_MassFlowAttribute_Inverse);
+        Mapping_VertexMapping_MaximumHeadMAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_MaximumHeadMAttribute);
+        Mapping_VertexMapping_MaximumHeadMAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_MaximumHeadMAttribute_Inverse);
+        Mapping_VertexMapping_NominalFlowAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_NominalFlowAttribute);
+        Mapping_VertexMapping_NominalFlowAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_NominalFlowAttribute_Inverse);
+        Mapping_VertexMapping_NominalHeadBAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_NominalHeadBAttribute);
+        Mapping_VertexMapping_NominalHeadBAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_NominalHeadBAttribute_Inverse);
+        Mapping_VertexMapping_NominalHeadMAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_NominalHeadMAttribute);
+        Mapping_VertexMapping_NominalHeadMAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_NominalHeadMAttribute_Inverse);
+        Mapping_VertexMapping_NominalMassFlowAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_NominalMassFlowAttribute);
+        Mapping_VertexMapping_NominalMassFlowAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_NominalMassFlowAttribute_Inverse);
+        Mapping_VertexMapping_NominalPressureLossAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_NominalPressureLossAttribute);
+        Mapping_VertexMapping_NominalPressureLossAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_NominalPressureLossAttribute_Inverse);
+        Mapping_VertexMapping_ReturnPressureAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_ReturnPressureAttribute);
+        Mapping_VertexMapping_ReturnPressureAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_ReturnPressureAttribute_Inverse);
+        Mapping_VertexMapping_ReturnTemperatureAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_ReturnTemperatureAttribute);
+        Mapping_VertexMapping_ReturnTemperatureAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_ReturnTemperatureAttribute_Inverse);
+        Mapping_VertexMapping_SupplyPressureAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_SupplyPressureAttribute);
+        Mapping_VertexMapping_SupplyPressureAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_SupplyPressureAttribute_Inverse);
+        Mapping_VertexMapping_SupplyTemperatureAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_SupplyTemperatureAttribute);
+        Mapping_VertexMapping_SupplyTemperatureAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_SupplyTemperatureAttribute_Inverse);
+        Mapping_VertexMapping_ValvePositionAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_ValvePositionAttribute);
+        Mapping_VertexMapping_ValvePositionAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_ValvePositionAttribute_Inverse);
+        Mapping_VertexMapping_VelocityAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_VelocityAttribute);
+        Mapping_VertexMapping_VelocityAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_VelocityAttribute_Inverse);
+        Mapping_VertexMapping_VolFlowAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_VolFlowAttribute);
+        Mapping_VertexMapping_VolFlowAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_VolFlowAttribute_Inverse);
+        Mapping_VertexMapping_XAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_XAttribute);
+        Mapping_VertexMapping_XAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_XAttribute_Inverse);
+        Mapping_VertexMapping_YAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_YAttribute);
+        Mapping_VertexMapping_YAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_YAttribute_Inverse);
+        Mapping_VertexMapping_dpAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_dpAttribute);
+        Mapping_VertexMapping_dpAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_dpAttribute_Inverse);
+        Mapping_VertexMapping_dtAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_dtAttribute);
+        Mapping_VertexMapping_dtAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_dtAttribute_Inverse);
+        SCLMain = getResourceOrNull(graph, URIs.SCLMain);
+        SpatialRefSystem = getResourceOrNull(graph, URIs.SpatialRefSystem);
+        Vertex = getResourceOrNull(graph, URIs.Vertex);
+        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);
+        Vertex_HasAddress = getResourceOrNull(graph, URIs.Vertex_HasAddress);
+        Vertex_HasAddress_Inverse = getResourceOrNull(graph, URIs.Vertex_HasAddress_Inverse);
+        Vertex_HasDeltaPressure = getResourceOrNull(graph, URIs.Vertex_HasDeltaPressure);
+        Vertex_HasDeltaPressure_Inverse = getResourceOrNull(graph, URIs.Vertex_HasDeltaPressure_Inverse);
+        Vertex_HasDeltaTemperature = getResourceOrNull(graph, URIs.Vertex_HasDeltaTemperature);
+        Vertex_HasDeltaTemperature_Inverse = getResourceOrNull(graph, URIs.Vertex_HasDeltaTemperature_Inverse);
+        Vertex_HasElevation = getResourceOrNull(graph, URIs.Vertex_HasElevation);
+        Vertex_HasElevation_Inverse = getResourceOrNull(graph, URIs.Vertex_HasElevation_Inverse);
+        Vertex_HasFlowArea = getResourceOrNull(graph, URIs.Vertex_HasFlowArea);
+        Vertex_HasFlowArea_Inverse = getResourceOrNull(graph, URIs.Vertex_HasFlowArea_Inverse);
+        Vertex_HasHeatLoadDs = getResourceOrNull(graph, URIs.Vertex_HasHeatLoadDs);
+        Vertex_HasHeatLoadDs_Inverse = getResourceOrNull(graph, URIs.Vertex_HasHeatLoadDs_Inverse);
+        Vertex_HasHeatPower = getResourceOrNull(graph, URIs.Vertex_HasHeatPower);
+        Vertex_HasHeatPower_Inverse = getResourceOrNull(graph, URIs.Vertex_HasHeatPower_Inverse);
+        Vertex_HasMassFlow = getResourceOrNull(graph, URIs.Vertex_HasMassFlow);
+        Vertex_HasMassFlow_Inverse = getResourceOrNull(graph, URIs.Vertex_HasMassFlow_Inverse);
+        Vertex_HasMaximumHeadM = getResourceOrNull(graph, URIs.Vertex_HasMaximumHeadM);
+        Vertex_HasMaximumHeadM_Inverse = getResourceOrNull(graph, URIs.Vertex_HasMaximumHeadM_Inverse);
+        Vertex_HasNominalFlow = getResourceOrNull(graph, URIs.Vertex_HasNominalFlow);
+        Vertex_HasNominalFlow_Inverse = getResourceOrNull(graph, URIs.Vertex_HasNominalFlow_Inverse);
+        Vertex_HasNominalHeadB = getResourceOrNull(graph, URIs.Vertex_HasNominalHeadB);
+        Vertex_HasNominalHeadB_Inverse = getResourceOrNull(graph, URIs.Vertex_HasNominalHeadB_Inverse);
+        Vertex_HasNominalHeadM = getResourceOrNull(graph, URIs.Vertex_HasNominalHeadM);
+        Vertex_HasNominalHeadM_Inverse = getResourceOrNull(graph, URIs.Vertex_HasNominalHeadM_Inverse);
+        Vertex_HasNominalPressureLoss = getResourceOrNull(graph, URIs.Vertex_HasNominalPressureLoss);
+        Vertex_HasNominalPressureLoss_Inverse = getResourceOrNull(graph, URIs.Vertex_HasNominalPressureLoss_Inverse);
+        Vertex_HasReturnPressure = getResourceOrNull(graph, URIs.Vertex_HasReturnPressure);
+        Vertex_HasReturnPressure_Inverse = getResourceOrNull(graph, URIs.Vertex_HasReturnPressure_Inverse);
+        Vertex_HasReturnTemperature = getResourceOrNull(graph, URIs.Vertex_HasReturnTemperature);
+        Vertex_HasReturnTemperature_Inverse = getResourceOrNull(graph, URIs.Vertex_HasReturnTemperature_Inverse);
+        Vertex_HasSupplyPressure = getResourceOrNull(graph, URIs.Vertex_HasSupplyPressure);
+        Vertex_HasSupplyPressure_Inverse = getResourceOrNull(graph, URIs.Vertex_HasSupplyPressure_Inverse);
+        Vertex_HasSupplyTemperature = getResourceOrNull(graph, URIs.Vertex_HasSupplyTemperature);
+        Vertex_HasSupplyTemperature_Inverse = getResourceOrNull(graph, URIs.Vertex_HasSupplyTemperature_Inverse);
+        Vertex_HasValvePosition = getResourceOrNull(graph, URIs.Vertex_HasValvePosition);
+        Vertex_HasValvePosition_Inverse = getResourceOrNull(graph, URIs.Vertex_HasValvePosition_Inverse);
+        Vertex_HasVelocity = getResourceOrNull(graph, URIs.Vertex_HasVelocity);
+        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) {
+        Session session = graph.getSession();
+        DistrictNetworkResource ret = session.peekService(DistrictNetworkResource.class);
+        if(ret == null) {
+            QueryControl qc = graph.getService(QueryControl.class);
+            ret = new DistrictNetworkResource(qc.getIndependentGraph(graph));
+            session.registerService(DistrictNetworkResource.class, ret);
+        }
+        return ret;
+    }
+    
+    public static DistrictNetworkResource getInstance(RequestProcessor session) throws DatabaseException {
+        DistrictNetworkResource ret = session.peekService(DistrictNetworkResource.class);
+        if(ret == null) {
+            ret = session.syncRequest(new Read<DistrictNetworkResource>() {
+                public DistrictNetworkResource perform(ReadGraph graph) throws DatabaseException {
+                    QueryControl qc = graph.getService(QueryControl.class);
+                    return new DistrictNetworkResource(qc.getIndependentGraph(graph));
+                }
+            });
+            session.registerService(DistrictNetworkResource.class, ret);
+        }
+        return ret;
+    }
+    
+}
+
diff --git a/org.simantics.district.network.ui.ontology/src/org/simantics/district/network/ui/ontology/DistrictNetworkUIResource.java b/org.simantics.district.network.ui.ontology/src/org/simantics/district/network/ui/ontology/DistrictNetworkUIResource.java
new file mode 100644 (file)
index 0000000..d6ae2f6
--- /dev/null
@@ -0,0 +1,64 @@
+package org.simantics.district.network.ui.ontology;
+
+import org.simantics.db.RequestProcessor;
+import org.simantics.db.Resource;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.request.Read;
+import org.simantics.db.Session;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.service.QueryControl;
+
+public class DistrictNetworkUIResource {
+    
+    public final Resource NetworkProperties;
+    public final Resource SelectionTab;
+    public final Resource SelectionTabContribution;
+        
+    public static class URIs {
+        public static final String NetworkProperties = "http://www.simantics.org/DistrictNetworkUI-1.0/NetworkProperties";
+        public static final String SelectionTab = "http://www.simantics.org/DistrictNetworkUI-1.0/SelectionTab";
+        public static final String SelectionTabContribution = "http://www.simantics.org/DistrictNetworkUI-1.0/SelectionTabContribution";
+    }
+    
+    public static Resource getResourceOrNull(ReadGraph graph, String uri) {
+        try {
+            return graph.getResource(uri);
+        } catch(DatabaseException e) {
+            System.err.println(e.getMessage());
+            return null;
+        }
+    }
+    
+    public DistrictNetworkUIResource(ReadGraph graph) {
+        NetworkProperties = getResourceOrNull(graph, URIs.NetworkProperties);
+        SelectionTab = getResourceOrNull(graph, URIs.SelectionTab);
+        SelectionTabContribution = getResourceOrNull(graph, URIs.SelectionTabContribution);
+    }
+    
+    public static DistrictNetworkUIResource getInstance(ReadGraph graph) {
+        Session session = graph.getSession();
+        DistrictNetworkUIResource ret = session.peekService(DistrictNetworkUIResource.class);
+        if(ret == null) {
+            QueryControl qc = graph.getService(QueryControl.class);
+            ret = new DistrictNetworkUIResource(qc.getIndependentGraph(graph));
+            session.registerService(DistrictNetworkUIResource.class, ret);
+        }
+        return ret;
+    }
+    
+    public static DistrictNetworkUIResource getInstance(RequestProcessor session) throws DatabaseException {
+        DistrictNetworkUIResource ret = session.peekService(DistrictNetworkUIResource.class);
+        if(ret == null) {
+            ret = session.syncRequest(new Read<DistrictNetworkUIResource>() {
+                public DistrictNetworkUIResource perform(ReadGraph graph) throws DatabaseException {
+                    QueryControl qc = graph.getService(QueryControl.class);
+                    return new DistrictNetworkUIResource(qc.getIndependentGraph(graph));
+                }
+            });
+            session.registerService(DistrictNetworkUIResource.class, ret);
+        }
+        return ret;
+    }
+    
+}
+
index 9d07f0378a18e69fd9252200b06a4000b3ff2233..f3e556718202027ce966b2bab9c1f1e86414461e 100644 (file)
@@ -43,8 +43,8 @@ public class DistrictDiagramViewer extends DiagramViewer {
     public void initializeCanvasContext(CanvasContext ctx) {
         super.initializeCanvasContext(ctx);
         IHintContext h = ctx.getDefaultHintContext();
-        h.setHint(PanZoomRotateHandler.KEY_ZOOM_IN_LIMIT, 1000000.0);
-        h.setHint(PanZoomRotateHandler.KEY_ZOOM_OUT_LIMIT, 0.003);
+        h.setHint(PanZoomRotateHandler.KEY_ZOOM_IN_LIMIT, 10000.0);
+        h.setHint(PanZoomRotateHandler.KEY_ZOOM_OUT_LIMIT, 0.01);
     }
 
     @Override
index db730b1e6fafcec231b54ecdde6afe73d36e0d57..cbc6a578638e9a1d679915613af759de27b751be 100644 (file)
@@ -1,23 +1,32 @@
 package org.simantics.district.network.ui.adapters;
 
 import java.awt.Color;
+import java.awt.Shape;
 import java.awt.geom.AffineTransform;
+import java.awt.geom.Line2D;
 import java.awt.geom.Rectangle2D;
 import java.util.Collection;
 import java.util.Collections;
 
+import org.simantics.district.network.ModelledCRS;
 import org.simantics.district.network.ui.DistrictNetworkEdge;
 import org.simantics.district.network.ui.nodes.DistrictNetworkEdgeNode;
 import org.simantics.g2d.connection.handler.ConnectionHandler;
+import org.simantics.g2d.diagram.handler.PickRequest.PickPolicy;
 import org.simantics.g2d.diagram.handler.Topology.Connection;
 import org.simantics.g2d.element.ElementClass;
 import org.simantics.g2d.element.ElementUtils;
 import org.simantics.g2d.element.IElement;
 import org.simantics.g2d.element.SceneGraphNodeKey;
 import org.simantics.g2d.element.handler.InternalSize;
+import org.simantics.g2d.element.handler.Outline;
+import org.simantics.g2d.element.handler.Pick;
 import org.simantics.g2d.element.handler.SceneGraph;
+import org.simantics.g2d.element.handler.SelectionOutline;
+import org.simantics.g2d.element.handler.impl.ConnectionSelectionOutline;
 import org.simantics.g2d.element.handler.impl.DefaultTransform;
 import org.simantics.g2d.element.handler.impl.SimpleElementLayers;
+import org.simantics.maps.MapScalingTransform;
 import org.simantics.scenegraph.g2d.G2DParentNode;
 import org.simantics.utils.datastructures.hints.IHintContext.Key;
 import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;
@@ -28,7 +37,7 @@ public class DistrictNetworkEdgeElement {
 
     public static final Key KEY_DN_EDGE = new KeyOf(DistrictNetworkEdge.class, "DN_EDGE");
     public static final Key KEY_DN_EDGE_NODE = new SceneGraphNodeKey(DistrictNetworkEdgeNode.class, "DN_EDGE_NODE");
-    
+
     public static final ElementClass CLASS =
             ElementClass.compile(
                     DefaultTransform.INSTANCE,
@@ -36,14 +45,16 @@ public class DistrictNetworkEdgeElement {
                     DNEdgeSceneGraph.INSTANCE,
                     DNEdgeConnectionHandler.INSTANCE,
                     SimpleElementLayers.INSTANCE,
+                    // TODO: do we need this and does it work?
+                    ConnectionSelectionOutline.INSTANCE,
                     DistrictNetworkAdditionalColor.INSTANCE
             ).setId(DistrictNetworkEdgeElement.class.getSimpleName());
-    
+
     static final class DNEdgeSceneGraph implements SceneGraph {
-        
+
         public static final DNEdgeSceneGraph INSTANCE = new DNEdgeSceneGraph();
 
-        private static final long serialVersionUID = 8894367073815556871L;
+        private static final long serialVersionUID = 68135568495835923L;
 
         @Override
         public void init(IElement edgeElement, G2DParentNode parent) {
@@ -72,13 +83,13 @@ public class DistrictNetworkEdgeElement {
             edge.removeHint(KEY_DN_EDGE_NODE);
         }
     }
-    
-    static final class DNEdgeInternalSize implements InternalSize {
+
+    static final class DNEdgeInternalSize implements InternalSize, Outline, Pick {
 
         private static final Logger LOGGER = LoggerFactory.getLogger(DNEdgeInternalSize.class);
-        
-        private static final long serialVersionUID = -2725017034692179676L;
-        
+
+        private static final long serialVersionUID = -7346653820911240628L;
+
         public static final DNEdgeInternalSize INSTANCE = new DNEdgeInternalSize();
 
         @Override
@@ -87,18 +98,84 @@ public class DistrictNetworkEdgeElement {
             if (size == null)
                 size = new Rectangle2D.Double();
             if (edge != null)
-                size.setFrame(DistrictNetworkEdgeNode.calculatePath(edge).getBounds2D());
+                size.setFrame(DistrictNetworkEdgeNode.calculatePath(edge, null).getBounds2D());
             else
                 LOGGER.debug("Element {} does not have edge!", e);
 
             return size;
         }
+
+        @Override
+        public Shape getElementShape(IElement e) {
+            DistrictNetworkEdge edge = e.getHint(KEY_DN_EDGE);
+            if (edge != null) {
+                return DistrictNetworkEdgeNode.calculatePath(edge, null);
+            } else {
+                return getBounds(e, null);
+            }
+        }
+
+        private Shape getSelectionShape(IElement e) {
+            for (SelectionOutline so : e.getElementClass().getItemsByClass(SelectionOutline.class)) {
+                Shape shape = so.getSelectionShape(e);
+                if (shape != null)
+                    return shape;
+            }
+            // Using on-diagram coordinates because neither connections nor
+            // edges have a non-identity transform which means that
+            // coordinates are always absolute. Therefore branch point
+            // shape also needs to be calculated in absolute coordinates.
+            Shape shape = ElementUtils.getElementShapeOrBoundsOnDiagram(e);
+            return shape;
+        }
+
+        @Override
+        public boolean pickTest(IElement e, Shape s, PickPolicy policy) {
+            DistrictNetworkEdge edge = e.getHint(KEY_DN_EDGE);
+            if (edge != null) {
+                Rectangle2D bounds = getBounds(s);
+
+                switch (policy) {
+                case PICK_CONTAINED_OBJECTS:
+                    Shape selectionShape = getSelectionShape(e);
+                    return bounds.contains(selectionShape.getBounds2D());
+
+                case PICK_INTERSECTING_OBJECTS:
+                    double tolerance = (bounds.getHeight() + bounds.getHeight()) * 0.25 / MapScalingTransform.getScaleX();
+                    Line2D line = new Line2D.Double(edge.getStartPoint(), edge.getEndPoint());
+                    double sx = bounds.getCenterX() / MapScalingTransform.getScaleX();
+                    double sy = bounds.getCenterY() / MapScalingTransform.getScaleY();
+                    double ssx = ModelledCRS.xToLongitude(sx);
+                    double ssy = ModelledCRS.yToLatitude(-sy); // Invert for Simantics diagram coordinate system
+                    double distSq = line.ptSegDistSq(ssx, ssy);
+//                    System.out.println("s: " + sx + ", " + sy);
+//                    System.out.println("ss: " + ssx + ", " + ssy);
+//                    System.out.println("p1: " + edge.getStartPoint());
+//                    System.out.println("p2: " + edge.getEndPoint());
+//                    System.out.println("line: " + "(" + line.getX1() + ", " + line.getY1() + ", " + line.getX2() + ", " + line.getY2() + ")");
+//                    System.out.println("distance from line is " + Math.sqrt(distSq) + " with tolerance " + tolerance);
+                    if (distSq <= tolerance * tolerance) {
+                        return true;
+                    }
+                }
+                return false;
+            }
+
+            return false;
+        }
+
+        private Rectangle2D getBounds(Shape shape) {
+            if (shape instanceof Rectangle2D)
+                return (Rectangle2D) shape;
+            return shape.getBounds2D();
+        }
+
     }
-    
+
     static class DNEdgeConnectionHandler implements ConnectionHandler {
 
-        private static final long serialVersionUID = -410377314637446238L;
-        
+        private static final long serialVersionUID = -6882671891381761687L;
+
         public static final DNEdgeConnectionHandler INSTANCE = new DNEdgeConnectionHandler();
 
         @Override
@@ -121,4 +198,5 @@ public class DistrictNetworkEdgeElement {
             return Collections.emptyList();
         }
     }
+
 }
index 9748f87c8fc4980f77a767e84dde9d157b6885d4..04cd94cf46658f2d3c0bbb8431275d06f8640ad0 100644 (file)
@@ -41,18 +41,21 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.exception.RuntimeDatabaseException;
 import org.simantics.db.exception.ServiceException;
+import org.simantics.db.layer0.QueryIndexUtils;
 import org.simantics.db.layer0.variable.Variable;
+import org.simantics.db.layer0.variable.Variables;
 import org.simantics.db.layer0.variable.Variables.Role;
 import org.simantics.db.procedure.Procedure;
-import org.simantics.diagram.stubs.DiagramResource;
 import org.simantics.district.network.ontology.DistrictNetworkResource;
 import org.simantics.layer0.Layer0;
 import org.simantics.modeling.ModelingResources;
-import org.simantics.modeling.ModelingUtils;
 import org.simantics.modeling.adapters.NewCompositeActionFactory;
 import org.simantics.modeling.typicals.TypicalUtil;
 import org.simantics.operation.Layer0X;
 import org.simantics.scl.reflection.annotations.SCLValue;
+import org.simantics.scl.runtime.SCLContext;
+import org.simantics.scl.runtime.function.Function1;
+import org.simantics.scl.runtime.function.FunctionImpl1;
 import org.simantics.ui.workbench.action.DefaultActions;
 import org.simantics.utils.ui.SWTUtils;
 import org.slf4j.Logger;
@@ -116,7 +119,7 @@ public class Functions {
 
     public static Map<String, Resource> getNetworkMappingsByType(ReadGraph graph, Resource element, Resource mappingType) throws DatabaseException {
         Resource indexRoot = graph.sync(new IndexRoot(element));
-        List<Resource> mappings = ModelingUtils.searchByType(graph, indexRoot, mappingType);
+        List<Resource> mappings = QueryIndexUtils.searchByType(graph, indexRoot, mappingType);
         Map<String, Resource> result = new HashMap<>(mappings.size());
         Layer0 L0 = Layer0.getInstance(graph);
         mappings.forEach(mapping -> {
@@ -135,7 +138,7 @@ public class Functions {
     
     private static Object baseMappingModifier(ReadGraph graph, Resource element, Resource property, Resource mappingType, Variable context) throws DatabaseException {
         Resource indexRoot = graph.sync(new IndexRoot(element));
-        List<Resource> mappings = ModelingUtils.searchByType(graph, indexRoot, mappingType);
+        List<Resource> mappings = QueryIndexUtils.searchByType(graph, indexRoot, mappingType);
         Enumeration<Resource> enums = Enumeration
                 .make(mappings.stream().map(m -> createEnumeratedValue(graph, m)).collect(Collectors.toList()));
         
@@ -180,8 +183,11 @@ public class Functions {
     
     @SCLValue(type = "ReadGraph -> Resource -> a -> b")
     public static Object convertToValue(ReadGraph graph, Resource resource, Object context) throws DatabaseException {
-        return graph.getRelatedValue2(resource, Layer0.getInstance(graph).HasName, Bindings.STRING);
-//        return null;
+        Layer0 L0 = Layer0.getInstance(graph);
+        String label = graph.getPossibleRelatedValue2(resource, L0.HasLabel, Bindings.STRING);
+        if (label == null)
+            label = graph.getRelatedValue(resource, L0.HasName, Bindings.STRING);
+        return label;
     }
     
     
@@ -213,7 +219,6 @@ public class Functions {
         private Map<String, Resource> edgeMappings = new HashMap<>();
         private Map<String, Resource> composites = new HashMap<>();
         private Map<String, Resource> crss = new HashMap<>();
-        private Map<String, Map<String, Resource>> components = new HashMap<>();
         
         private Resource defaultVertexMapping;
         private Resource defaultEdgeMapping;
@@ -254,10 +259,7 @@ public class Functions {
                     edgeMappings = getEdgeMappings(graph, configuration);
                     
                     composites = getComposites(graph, configuration);
-                    if (composites.size() > 0) {
-                        components = getComponents(graph, composites.get(0));
-                    }
-                    
+                  
                     crss = getCRSs(graph, configuration);
                     
                     composite.getDisplay().asyncExec(() -> {
@@ -282,16 +284,7 @@ public class Functions {
             return composite;
         }
         
-        protected Map<String, Map<String, Resource>> getComponents(ReadGraph graph, Resource resource) {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
         protected Map<String, Resource> getComposites(ReadGraph graph, Resource element) throws DatabaseException {
-            
-            Resource indexRoot = graph.sync(new IndexRoot(element));
-            List<Resource> diagrams = ModelingUtils.searchByType(graph, indexRoot, DiagramResource.getInstance(graph).Diagram);
-            
             List<Resource> nonDistrictComposites = composites.values().stream().filter(comp -> {
                 try {
                     return !graph.isInstanceOf(comp, DistrictNetworkResource.getInstance(graph).Composite);
@@ -462,15 +455,32 @@ public class Functions {
         DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
         Set<Resource> results = new HashSet<>();
         for (Resource indexRoot : indexRoots) {
-            Collection<Resource> diagrams = ModelingUtils.searchByType(graph, indexRoot, DN.Diagram);
+            Collection<Resource> diagrams = QueryIndexUtils.searchByType(graph, indexRoot, DN.Diagram);
             results.addAll(diagrams);
         }
         return results;
     }
 
+    private static List<String> listInstanceNames(ReadGraph graph, Variable context, Resource type) throws DatabaseException {
+        Resource indexRoot = Variables.getIndexRoot(graph, context);
+        DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+        List<Resource> properties = 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 {
-        return Collections.emptyList();
+        DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+        return listInstanceNames(graph, context, DN.Edge_ThicknessProperty);
+    }
+
+    @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")
@@ -480,4 +490,61 @@ public class Functions {
         return baseMappingModifier(graph, diagram, DN.Diagram_edgeThicknessProperty, DN.Edge_ThicknessProperty, 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<Resource, Double> hasDiameterValue(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {
+        return directPropertyValueFunction(DistrictNetworkResource.getInstance(graph).Edge_HasDiameter, 0);
+    }
+
+    @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
+    public static Function1<Resource, Double> hasNominalMassFlowValue(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {
+        return directPropertyValueFunction(DistrictNetworkResource.getInstance(graph).Edge_HasNominalMassFlow, 0);
+    }
+
+    @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
+    public static Function1<Resource, Double> hasNominalSupplyPressure(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {
+        return directPropertyValueFunction(DistrictNetworkResource.getInstance(graph).Vertex_HasSupplyPressure, 0);
+    }
+
+    @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
+    public static Function1<Resource, Double> hasElevation(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {
+        return directPropertyValueFunction(DistrictNetworkResource.getInstance(graph).Vertex_HasElevation, 0);
+    }
+
+    private static final Function1<Resource, Double> ONE = new FunctionImpl1<Resource, Double>() {
+        private final Double ONE = 1.0;
+        @Override
+        public Double apply(Resource edge) {
+            return ONE;
+        }
+    };
+
+    @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
+    public static Function1<Resource, Double> constantOne(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {
+        return ONE;
+    }
+
+    private static Function1<Resource, Double> directPropertyValueFunction(Resource property, double defaultValue) throws DatabaseException {
+        Double def = defaultValue;
+        return new FunctionImpl1<Resource, Double>() {
+            @Override
+            public Double apply(Resource edge) {
+               ReadGraph graph = (ReadGraph) SCLContext.getCurrent().get("graph");
+                try {
+                    Double d = graph.getPossibleRelatedValue(edge, property, Bindings.DOUBLE);
+                    return d != null ? d : def;
+                } catch (DatabaseException e) {
+                    LOGGER.error("Failed to evaluate property value", e);
+                    return def;
+                }
+            }
+        };
+    }
+
 }
index 9229932400a8ff12b964621a3643c2102bb0b634..1e577e97a4553faebcfebd82659f56c4a8c96894 100644 (file)
@@ -6,26 +6,29 @@ import java.awt.Graphics2D;
 import java.awt.RenderingHints;
 import java.awt.Stroke;
 import java.awt.geom.AffineTransform;
+import java.awt.geom.Line2D;
 import java.awt.geom.Path2D;
 import java.awt.geom.Rectangle2D;
 
 import org.simantics.district.network.ModelledCRS;
 import org.simantics.district.network.ui.DistrictNetworkEdge;
+import org.simantics.scenegraph.ISelectionPainterNode;
 import org.simantics.scenegraph.g2d.G2DNode;
 import org.simantics.scenegraph.utils.GeometryUtils;
 import org.simantics.scenegraph.utils.NodeUtil;
 
-public class DistrictNetworkEdgeNode extends G2DNode {
+public class DistrictNetworkEdgeNode extends G2DNode implements ISelectionPainterNode {
 
     private static final long serialVersionUID = 8049769475036519806L;
-    
+
     private static final Stroke     SELECTION_STROKE = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);
     private static final Color      SELECTION_COLOR  = new Color(255, 0, 255, 96);
-    
+
     private DistrictNetworkEdge edge;
     private Rectangle2D bounds;
-    
-    private static final Stroke STROKE = new BasicStroke(4, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
+    private Line2D path;
+
+    private static final BasicStroke STROKE = new BasicStroke(4, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
     private boolean scaleStroke = true;
 
     private Color color;
@@ -35,68 +38,81 @@ public class DistrictNetworkEdgeNode extends G2DNode {
     @Override
     public void init() {
     }
-    
+
     @Override
     public void render(Graphics2D g2d) {
-        
         AffineTransform ot = null;
         AffineTransform t = getTransform();
         if (t != null && !t.isIdentity()) {
             ot = g2d.getTransform();
             g2d.transform(getTransform());
         }
-        
+
         Object aaHint = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
         g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
 
         Color oldColor = g2d.getColor();
         BasicStroke oldStroke = (BasicStroke) g2d.getStroke();
-//        boolean selected = isSelected();
-//        if (selected) {
-//            Path2D selectionPath = edge.getPath();
-//            Shape selectionShape = SELECTION_STROKE.createStrokedShape(selectionPath);
-//            g2d.setColor(SELECTION_COLOR);
-//            g2d.fill(selectionShape);
-//        }
-//        
+
         g2d.setColor(color);
-        if (STROKE != null) {
-            if (scaleStroke && STROKE instanceof BasicStroke) {
-                double str;
-                if (stroke != null)
-                    str = Math.abs(stroke);
-                else
-                    str = 1.0;
-                BasicStroke bs = GeometryUtils.scaleStroke(STROKE, (float) (str / GeometryUtils.getScale(g2d.getTransform())));
-                g2d.setStroke(bs);
-            } else {
-                g2d.setStroke(STROKE);
-            }
+        BasicStroke bs = null;
+        if (scaleStroke) {
+            double scale = GeometryUtils.getScale(g2d.getTransform());
+            scale = Math.max(10000, Math.min(scale, 50000));
+            double str = stroke != null ? Math.abs(stroke) : 1.0;
+            bs = GeometryUtils.scaleStroke(STROKE, (float) (str / scale));
+        } else {
+            bs = STROKE;
         }
 
-        g2d.draw(calculatePath(edge));
-        
+        path = calculateLine(edge, path);
+
+        if (isSelected()) {
+            g2d.setColor(SELECTION_COLOR);
+            g2d.setStroke(GeometryUtils.scaleStroke(bs, 4f));
+            g2d.draw(path);
+        }
+
+        g2d.setStroke(bs);
+        g2d.draw(path);
+
         // Reset
         g2d.setStroke(oldStroke);
         g2d.setColor(oldColor);
         g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, aaHint);
-        
+
         if (ot != null)
             g2d.setTransform(ot);
     }
-    
-    public static Path2D calculatePath(DistrictNetworkEdge edge) {
+
+    public static Line2D calculateLine(DistrictNetworkEdge edge, Line2D result) {
+        // 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
+
+        if (result == null)
+            result = new Line2D.Double();
+        result.setLine(startX, startY, endX, endY);
+        return result;
+    }
+
+    public static Path2D calculatePath(DistrictNetworkEdge edge, Path2D result) {
         // 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
-        
-        // render
-        Path2D path = new Path2D.Double();
-        path.moveTo(startX, startY);
-        path.lineTo(endX, endY);
-        return path;
+
+        if (result == null) {
+             result = new Path2D.Double();
+        } else {
+             result.reset();
+        }
+        result.moveTo(startX, startY);
+        result.lineTo(endX, endY);
+        return result;
     }
 
     private boolean isSelected() {
@@ -107,7 +123,7 @@ public class DistrictNetworkEdgeNode extends G2DNode {
     public Rectangle2D getBoundsInLocal() {
         return bounds;
     }
-    
+
     private void updateBounds() {
         Rectangle2D oldBounds = bounds;
         if (oldBounds == null)
@@ -116,7 +132,7 @@ public class DistrictNetworkEdgeNode extends G2DNode {
     }
 
     private Rectangle2D calculateBounds(Rectangle2D rect) {
-        return calculatePath(edge).getBounds2D();
+        return calculatePath(edge, null).getBounds2D();
     }
 
     public void setDNEdge(DistrictNetworkEdge edge) {
@@ -127,7 +143,7 @@ public class DistrictNetworkEdgeNode extends G2DNode {
     public void setColor(Color color) {
         this.color = color;
     }
-    
+
     public Color getColor() {
         return color;
     }
index 99eb3cc117b7fb91cbb8352016a62da7e9836249..1dd0afe5c5e52a30b773262f85207d79066a9c9b 100644 (file)
@@ -1,17 +1,14 @@
 package org.simantics.district.network.ui.nodes;
 
-import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Graphics2D;
 import java.awt.RenderingHints;
-import java.awt.Stroke;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
 
 import org.simantics.district.network.ModelledCRS;
 import org.simantics.district.network.ui.adapters.DistrictNetworkVertex;
-import org.simantics.scenegraph.ParentNode;
 import org.simantics.scenegraph.g2d.G2DNode;
 import org.simantics.scenegraph.utils.GeometryUtils;
 import org.slf4j.Logger;
@@ -20,7 +17,7 @@ import org.slf4j.LoggerFactory;
 public class DistrictNetworkVertexNode extends G2DNode {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(DistrictNetworkVertexNode.class);
-    
+
     private static final long serialVersionUID = -2641639101400236719L;
     private DistrictNetworkVertex vertex;
 
@@ -28,11 +25,10 @@ public class DistrictNetworkVertexNode extends G2DNode {
     private static final double top = -0.25;
     private static final double width = 0.5;
     private static final double height = 0.5;
-    
+
     private static final Rectangle2D NORMAL = new Rectangle2D.Double(left, top, width, height);
     private static final Rectangle2D HOVERED = new Rectangle2D.Double(left * 3, top * 3, width * 3, height * 3);
-    
-    private Stroke stroke = new BasicStroke(2);
+
     private boolean scaleStroke = true;
     private boolean hover;
 
@@ -40,46 +36,46 @@ public class DistrictNetworkVertexNode extends G2DNode {
 
     private Rectangle2D bounds;
 
-    private Double strokee;
+    private double nodeSize = 1;
 
     @Override
     public void init() {
         setZIndex(2);
     }
-    
+
     @Override
     public void render(Graphics2D g2d) {
+        if (nodeSize <= 0.0)
+            return;
+
         AffineTransform ot = null;
         AffineTransform t = getTransform();
         if (t != null && !t.isIdentity()) {
             ot = g2d.getTransform();
             g2d.transform(getTransform());
         }
-        
+
+        Object oaaHint = null;
         Object aaHint = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
-        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
-        
+        if (aaHint != RenderingHints.VALUE_ANTIALIAS_OFF) {
+            oaaHint = aaHint;
+            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
+        }
+
         Color oldColor = g2d.getColor();
-        Stroke oldStroke = g2d.getStroke();
-        
         g2d.setColor(color);
-        
+
         double scaleRecip = 1;
         if (scaleStroke) {
             double scale = GeometryUtils.getScale(g2d.getTransform());
-            double str;
-            if (strokee != null)
-                str = strokee;
-            else
-                str = 1.0;
-            //System.out.println("scale: " + scale);
+            scale = Math.max(10000, Math.min(scale, 50000));
             scaleRecip = 1.0 / scale;
         }
-        scaleRecip = 8.0 * scaleRecip;
-        
+        scaleRecip = scaleRecip * nodeSize;
+
         // Translate lat and lon to X and Y
         Point2D res = calculatePoint2D(vertex);
-        
+
         Rectangle2D toDraw;
         if (hover) {
             toDraw = new Rectangle2D.Double(res.getX() - (HOVERED.getWidth() / 2 * scaleRecip), res.getY() - (HOVERED.getHeight() / 2 * scaleRecip), HOVERED.getWidth() * scaleRecip, HOVERED.getHeight() * scaleRecip);
@@ -88,13 +84,11 @@ public class DistrictNetworkVertexNode extends G2DNode {
         }
         // render
         g2d.fill(toDraw);
-        
-        // Reset stats
+
+        // Reset settings
         g2d.setColor(oldColor);
-        g2d.setStroke(oldStroke);
-        
-        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, aaHint);
-        
+        if (oaaHint != null)
+           g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, aaHint);
         if (ot != null)
             g2d.setTransform(ot);
     }
@@ -103,12 +97,12 @@ public class DistrictNetworkVertexNode extends G2DNode {
     public Rectangle2D getBounds() {
         return super.getBounds();
     }
-    
+
     @Override
     public Rectangle2D getBoundsInLocal() {
         return bounds;
     }
-    
+
     private void updateBounds() {
         Rectangle2D oldBounds = bounds;
         if (oldBounds == null)
@@ -122,16 +116,16 @@ public class DistrictNetworkVertexNode extends G2DNode {
         // Update bounds
         updateBounds();
     }
-    
+
     @Override
     public AffineTransform getTransform() {
         return super.getTransform();
     }
-    
+
     private Rectangle2D calculateBounds(Rectangle2D rect) {
         Point2D calcPoint = calculatePoint2D(vertex);
         AffineTransform at = getTransform();
-        return new Rectangle2D.Double(calcPoint.getX(), calcPoint.getY(), 1 / at.getScaleX(), 1 / at.getScaleY()).getBounds2D();
+        return new Rectangle2D.Double(calcPoint.getX(), calcPoint.getY(), width / at.getScaleX(), height / at.getScaleY()).getBounds2D();
     }
 
     private static Point2D calculatePoint2D(DistrictNetworkVertex vertex) {
@@ -148,7 +142,7 @@ public class DistrictNetworkVertexNode extends G2DNode {
         this.vertex = vertex;
         updateBounds();
     }
-    
+
     public boolean hover(boolean hover) {
 //        if (hover && LOGGER.isDebugEnabled())
 //            LOGGER.debug("Hovering " + this);
@@ -163,13 +157,23 @@ public class DistrictNetworkVertexNode extends G2DNode {
     public void setColor(Color color) {
         this.color = color;
     }
-    
+
     public Color getColor() {
         return color;
     }
 
-    @PropertySetter(value = "stroke")
-    public void setStroke(Double stroke) {
-        this.strokee = stroke / 10;
+    @PropertySetter(value = "size")
+    public void setSize(Double size) {
+        boolean changed = false;
+        if (size != null) {
+            changed = size != this.nodeSize;
+            this.nodeSize = size;
+        } else {
+            changed = this.nodeSize != 1.0;
+            this.nodeSize = 1.0;
+        }
+        if (changed)
+            updateBounds();
     }
+
 }
index 2d1fe771ff1e313c11f68fa1d3e0744639be2598..8fb9329ffa5cf4dcde370ce991237ca476a56a9c 100644 (file)
@@ -13,5 +13,7 @@ Require-Bundle: org.simantics.db,
  org.simantics.district.maps,
  org.simantics.district.geotools;bundle-version="1.0.0",
  org.simantics.diagram,
- org.simantics.scenegraph.profile;bundle-version="1.0.0"
-Export-Package: org.simantics.district.network
+ org.simantics.scenegraph.profile;bundle-version="1.0.0",
+ org.simantics;bundle-version="1.0.0"
+Export-Package: org.simantics.district.network,
+ org.simantics.district.network.profile
index a6463cd78eaaa288f065220af7c7cc9413726d88..cd7b433747cda8303ecab3b142dd2d3c51c97766 100644 (file)
@@ -9,11 +9,22 @@
                </type>
        </target>
        <target interface="org.simantics.scenegraph.profile.Style">
-               <resource uri="http://www.simantics.org/DistrictNetwork-1.0/VertexStyle"
-                       class="org.simantics.district.network.profile.VertexStyle">
+               <resource uri="http://www.simantics.org/DistrictNetwork-1.0/VertexSizeStyle"
+                       class="org.simantics.district.network.profile.VertexSizeStyle">
                </resource>
-               <resource uri="http://www.simantics.org/DistrictNetwork-1.0/EdgeStyle"
-                       class="org.simantics.district.network.profile.EdgeStyle">
+               <resource uri="http://www.simantics.org/DistrictNetwork-1.0/EdgeThicknessStyle"
+                       class="org.simantics.district.network.profile.EdgeThicknessStyle">
                </resource>
-    </target>
+               <resource uri="http://www.simantics.org/DistrictNetwork-1.0/HideStyle"
+                       class="org.simantics.district.network.profile.HideStyle">
+               </resource>
+       </target>
+       <target interface="org.simantics.scenegraph.profile.Group">
+               <type
+                       uri="http://www.simantics.org/DistrictNetwork-1.0/DistrictNodeGroup"
+                       class="org.simantics.district.network.profile.DistrictNodeGroup">
+                       <graph />
+                       <this />
+               </type>
+       </target>
 </adapters>
\ No newline at end of file
index 8136b19c257a37f62d47b14e751178a94cb1730e..071489de1b0a8cf2f9b2cad1d16f86b0b791b412 100644 (file)
@@ -3,22 +3,27 @@ package org.simantics.district.network.profile;
 import java.util.Optional;
 
 import org.simantics.db.Resource;
+import org.simantics.scl.runtime.function.Function1;
 
 /**
  * @author Tuukka Lehtonen
  */
 public class DiagramSettings {
 
-       public final Optional<Resource> vertexScalingProperty;
-       public final double vertexScalingScale;
-       public final Optional<Resource> edgeThicknessProperty;
-       public final double edgeThicknessScale;
+       public final Optional<Function1<Resource, Double>> vertexScaleProperty;
+       public final double vertexScaleGain;
+       public final double vertexScaleBias;
+       public final Optional<Function1<Resource, Double>> edgeThicknessProperty;
+       public final double edgeThicknessGain;
+       public final double edgeThicknessBias;
 
-       public DiagramSettings(Resource vertexScalingProperty, double vertexScalingScale, Resource edgeThicknessProperty, double edgeThicknessScale) {
-               this.vertexScalingProperty = Optional.ofNullable(vertexScalingProperty);
-               this.vertexScalingScale = vertexScalingScale;
+       public DiagramSettings(Function1<Resource, Double> vertexScaleProperty, double vertexScaleGain, double vertexScaleBias, Function1<Resource, Double> edgeThicknessProperty, double edgeThicknessGain, double edgeThicknessBias) {
+               this.vertexScaleProperty = Optional.ofNullable(vertexScaleProperty);
+               this.vertexScaleGain = vertexScaleGain;
+               this.vertexScaleBias = vertexScaleBias;
                this.edgeThicknessProperty = Optional.ofNullable(edgeThicknessProperty);
-               this.edgeThicknessScale = edgeThicknessScale;
+               this.edgeThicknessGain = edgeThicknessGain;
+               this.edgeThicknessBias = edgeThicknessBias;
        }
 
        @Override
@@ -27,10 +32,14 @@ public class DiagramSettings {
                int result = 1;
                result = prime * result + edgeThicknessProperty.hashCode();
                long temp;
-               temp = Double.doubleToLongBits(edgeThicknessScale);
+               temp = Double.doubleToLongBits(edgeThicknessGain);
                result = prime * result + (int) (temp ^ (temp >>> 32));
-//             result = prime * result + vertexScalingProperty.hashCode();
-               temp = Double.doubleToLongBits(vertexScalingScale);
+               temp = Double.doubleToLongBits(edgeThicknessBias);
+               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));
                return result;
        }
@@ -46,14 +55,23 @@ public class DiagramSettings {
                DiagramSettings other = (DiagramSettings) obj;
                if (!edgeThicknessProperty.equals(other.edgeThicknessProperty))
                        return false;
-               if (Double.doubleToLongBits(edgeThicknessScale) != Double.doubleToLongBits(other.edgeThicknessScale))
+               if (Double.doubleToLongBits(edgeThicknessGain) != Double.doubleToLongBits(other.edgeThicknessGain))
+                       return false;
+               if (Double.doubleToLongBits(edgeThicknessBias) != Double.doubleToLongBits(other.edgeThicknessBias))
+                       return false;
+               if (!vertexScaleProperty.equals(other.vertexScaleProperty))
                        return false;
-               if (!vertexScalingProperty.equals(other.vertexScalingProperty))
+               if (Double.doubleToLongBits(vertexScaleGain) != Double.doubleToLongBits(other.vertexScaleGain))
                        return false;
-               if (Double.doubleToLongBits(vertexScalingScale) != Double.doubleToLongBits(other.vertexScalingScale))
+               if (Double.doubleToLongBits(vertexScaleBias) != Double.doubleToLongBits(other.vertexScaleBias))
                        return false;
                return true;
        }
 
-       
+       @Override
+       public String toString() {
+               return String.format("DiagramSettings[%s * %f + %f - %s * %f + %f]", vertexScaleProperty.toString(),
+                               vertexScaleGain, vertexScaleBias, edgeThicknessProperty, edgeThicknessGain, edgeThicknessBias);
+       }
+
 }
index 726005eef7e088dfcd0024153988d0c2f2b50fc9..6fdb9721f059b20d32498e75f0f423659ebfa5be 100644 (file)
@@ -5,15 +5,18 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.common.request.ResourceRead;
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.variable.Variable;
+import org.simantics.db.layer0.variable.Variables;
 import org.simantics.diagram.stubs.DiagramResource;
 import org.simantics.district.network.ontology.DistrictNetworkResource;
+import org.simantics.scl.runtime.function.Function1;
 
 /**
  * @author Tuukka Lehtonen
  */
 public class DiagramSettingsRequest extends ResourceRead<DiagramSettings> {
 
-       protected DiagramSettingsRequest(Resource runtimeDiagram) {
+       public DiagramSettingsRequest(Resource runtimeDiagram) {
                super(runtimeDiagram);
        }
 
@@ -22,28 +25,53 @@ public class DiagramSettingsRequest extends ResourceRead<DiagramSettings> {
                DiagramResource DIA = DiagramResource.getInstance(graph);
                DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
 
-               Resource edgeThicknessProperty = null;
-               Resource nodeScalingProperty = null;
-               double edgeThicknessScale = 1;
-               double nodeScalingScale = 1;
+               Function1<Resource, Double> edgeThicknessProperty = null;
+               Function1<Resource, Double> nodeScaleProperty = null;
+               double edgeThicknessGain = 1;
+               double edgeThicknessBias = 0;
+               double nodeScaleGain = 1;
+               double nodeScaleBias = 0;
 
                Resource diagram = graph.getPossibleObject(resource, DIA.RuntimeDiagram_HasConfiguration);
                if (diagram != null) {
                        Resource etp = graph.getPossibleObject(diagram, DN.Diagram_edgeThicknessProperty);
-                       edgeThicknessProperty = graph.getPossibleObject(etp, DN.Edge_ThicknessProperty_value);
-//                     Resource nsp = graph.getPossibleObject(diagram, DN.Diagram_nodeScalingProperty);
-//                     nodeScalingProperty = graph.getPossibleObject(nsp, DN.Vertex_ScaleProperty_value);
+                       //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);
+                               }
 
-                       edgeThicknessScale =
-                                       safeDoubleProperty(graph, etp, DN.Edge_ThicknessProperty_scale, 1)
-                                       * safeDoubleProperty(graph, diagram, DN.Diagram_edgeThicknessScale, 1);
+                               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 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);
+                               }
 
-//                     nodeScalingScale =
-//                                     safeDoubleProperty(graph, nsp, DN.Vertex_ScaleProperty_scale, 1)
-//                                     * safeDoubleProperty(graph, diagram, DN.Diagram_nodeScale, 1);
+                               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);
+                       }
                }
 
-               return new DiagramSettings(nodeScalingProperty, nodeScalingScale, edgeThicknessProperty, edgeThicknessScale);
+               DiagramSettings ds = new DiagramSettings(
+                               nodeScaleProperty, nodeScaleGain, nodeScaleBias,
+                               edgeThicknessProperty, edgeThicknessGain, edgeThicknessBias);
+               //System.out.println("new diagram settings: " + ds);
+               return ds;
        }
 
        private static double safeDoubleProperty(ReadGraph graph, Resource r, Resource property, double defaultValue) throws DatabaseException {
diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/DistrictNodeGroup.java b/org.simantics.district.network/src/org/simantics/district/network/profile/DistrictNodeGroup.java
new file mode 100644 (file)
index 0000000..8d229b7
--- /dev/null
@@ -0,0 +1,143 @@
+package org.simantics.district.network.profile;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.RequestProcessor;
+import org.simantics.db.Resource;
+import org.simantics.db.common.primitiverequest.OrderedSet;
+import org.simantics.db.common.procedure.wrapper.SetListenerToSingleSetListener;
+import org.simantics.db.common.request.BinaryRead;
+import org.simantics.db.common.request.TernaryRead;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.procedure.SetListener;
+import org.simantics.diagram.stubs.DiagramResource;
+import org.simantics.district.network.ontology.DistrictNetworkResource;
+import org.simantics.layer0.Layer0;
+import org.simantics.scenegraph.profile.Group;
+import org.simantics.utils.strings.StringUtils;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class DistrictNodeGroup implements Group {
+
+    private final String               name;
+    private final Collection<Resource> types;
+    private final Set<String>          mappedComponentTypeNames;
+
+    public DistrictNodeGroup(ReadGraph graph, Resource group) throws DatabaseException {
+        Layer0 L0 = Layer0.getInstance(graph);
+        DiagramResource DIA = DiagramResource.getInstance(graph);
+        DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+
+        this.name = StringUtils.safeString( graph.getPossibleRelatedValue(group, L0.HasName, Bindings.STRING) );
+        this.types = graph.getObjects(group, DIA.TypeGroup_HasType);
+        Collection<Resource> names = graph.getObjects(group, DN.DistrictNodeGroup_hasComponentTypeName);
+        this.mappedComponentTypeNames = new HashSet<>(names.size());
+        for (Resource name : names) {
+            mappedComponentTypeNames.add( graph.getValue(name, Bindings.STRING) );
+        }
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + name.hashCode();
+        result = prime * result + types.hashCode();
+        result = prime * result + mappedComponentTypeNames.hashCode();
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        DistrictNodeGroup other = (DistrictNodeGroup) obj;
+        return name.equals(other.name) && types.equals(other.types) && mappedComponentTypeNames.equals(other.mappedComponentTypeNames);
+    }
+
+    @Override
+    public void trackItems(RequestProcessor processor, final Resource runtimeDiagram, final SetListener<Resource> listener) throws DatabaseException {
+        if (types.isEmpty()) {
+            System.out.println("DistrictNodeGroup has no types!");
+            return;
+        }
+        processor.syncRequest(new TernaryRead<Resource, Collection<Resource>, Set<String>, Collection<Resource>>(runtimeDiagram, types, mappedComponentTypeNames) {
+            @Override
+            public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {
+                return graph.syncRequest(new ElementsMappedToComponentTypes(parameter, parameter2, parameter3));
+            }
+        }, new SetListenerToSingleSetListener<Resource>(listener));
+    }
+
+    @Override
+    public String toString() {
+        return "every '" + name + "' of mapped type " + mappedComponentTypeNames;
+    }
+
+    private static class ElementsMappedToComponentTypes extends TernaryRead<Resource, Collection<Resource>, Set<String>, Set<Resource>> {
+
+        public ElementsMappedToComponentTypes(Resource runtimeDiagram, Collection<Resource> elementTypes, Set<String> componentTypeNames) {
+            super(runtimeDiagram, elementTypes, componentTypeNames);
+        }
+
+        @Override
+        public Set<Resource> perform(ReadGraph graph) throws DatabaseException {
+            DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+            Set<Resource> result = new HashSet<>();
+            Set<Resource> elementsOfType = graph.syncRequest(new ElementsOfType(parameter, parameter2));
+            for (Resource e : elementsOfType) {
+                Resource mapping = graph.getPossibleObject(e, DN.HasMapping);
+                if (mapping != null) {
+                    String ct = graph.getPossibleRelatedValue(mapping, DN.Mapping_ComponentType, Bindings.STRING);
+                    if (ct != null) {
+                        if (parameter3.contains(ct)) {
+                            //System.out.println("GROUP: added element " + NameUtils.getSafeName(graph, e) + " of type " + ct);
+                            result.add(e);
+                        }
+                    }
+                }
+            }
+            return result;
+        }
+
+    }
+
+    private static class ElementsOfType extends BinaryRead<Resource, Collection<Resource>, Set<Resource>> {
+
+        public ElementsOfType(Resource runtimeDiagram, Collection<Resource> types) {
+            super(runtimeDiagram, types);
+        }
+
+        @Override
+        public Set<Resource> perform(ReadGraph graph) throws DatabaseException {
+            HashSet<Resource> result = new HashSet<>();
+
+            Resource realDiagram = graph.getPossibleObject(parameter, DiagramResource.getInstance(graph).RuntimeDiagram_HasConfiguration);
+            if (realDiagram == null)
+                return result;
+
+            Collection<Resource> elements = graph.syncRequest(new OrderedSet(realDiagram));
+            for (Resource element : elements) {
+                Collection<Resource> elementTypes = graph.getTypes(element);
+                if (!Collections.disjoint(parameter2, elementTypes)) {
+                    result.add(element);
+                }
+            }
+
+            return result;
+        }
+
+    }
+
+}
similarity index 83%
rename from org.simantics.district.network/src/org/simantics/district/network/profile/EdgeStyle.java
rename to org.simantics.district.network/src/org/simantics/district/network/profile/EdgeThicknessStyle.java
index 4ee26ad4f7b00f1014668d78feeeed2d8443e0eb..45b55549333848a94c3d808fbfe4e824e94af877 100644 (file)
@@ -1,6 +1,6 @@
 package org.simantics.district.network.profile;
 
-import org.simantics.databoard.Bindings;
+import org.simantics.Simantics;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
@@ -12,7 +12,7 @@ import org.simantics.scenegraph.g2d.nodes.ConnectionNode;
 import org.simantics.scenegraph.profile.EvaluationContext;
 import org.simantics.scenegraph.profile.common.ProfileVariables;
 
-public class EdgeStyle extends StyleBase<Double> {
+public class EdgeThicknessStyle extends StyleBase<Double> {
 
        private static final Double PENDING = Double.NaN;
        private static final Double ONE = 1.0;
@@ -22,12 +22,12 @@ public class EdgeStyle extends StyleBase<Double> {
                DiagramSettings ds = graph.syncRequest(new DiagramSettingsRequest(runtimeDiagram), TransientCacheAsyncListener.instance());
                Double thickness = ONE;
                if (ds.edgeThicknessProperty.isPresent()) {
-                       thickness = graph.getPossibleRelatedValue2(groupItem, ds.edgeThicknessProperty.get(), Bindings.DOUBLE);
-                       //System.out.println("read thickness: " + thickness + " : " + ds.edgeThicknessProperty);
+                       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.edgeThicknessScale;
+                               thickness = thickness * ds.edgeThicknessGain + ds.edgeThicknessBias;
                        }
                }
                return thickness;
@@ -35,7 +35,7 @@ public class EdgeStyle extends StyleBase<Double> {
 
        @Override
        public void applyStyleForNode(EvaluationContext observer, INode node, Double value) {
-               //System.out.println("apply: " + node + " : " + value);
+//             System.out.println("apply: " + node + " : " + value);
                ConnectionNode n = (ConnectionNode) node;
                if (value == PENDING) {
                        ((G2DSceneGraph)node.getRootNode()).setPending(node);
diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/HideStyle.java b/org.simantics.district.network/src/org/simantics/district/network/profile/HideStyle.java
new file mode 100644 (file)
index 0000000..8e053a0
--- /dev/null
@@ -0,0 +1,38 @@
+package org.simantics.district.network.profile;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.diagram.profile.StyleBase;
+import org.simantics.scenegraph.INode;
+import org.simantics.scenegraph.g2d.nodes.SingleElementNode;
+import org.simantics.scenegraph.profile.EvaluationContext;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class HideStyle extends StyleBase<Boolean> {
+
+    @Override
+    public Boolean calculateStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException {
+        return Boolean.TRUE;
+    }
+
+    @Override
+    public void applyStyleForNode(EvaluationContext observer, INode node, Boolean result) {
+        SingleElementNode n = (SingleElementNode) node;
+        n.setVisible(false);
+    }
+
+    @Override
+    protected void cleanupStyleForNode(EvaluationContext evaluationContext, INode node) {
+        SingleElementNode n = (SingleElementNode) node;
+        n.setVisible(true);
+    }
+
+    @Override
+    public String toString() {
+        return "Hide";
+    }
+
+}
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
new file mode 100644 (file)
index 0000000..b33cd1c
--- /dev/null
@@ -0,0 +1,60 @@
+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.diagram.profile.StyleBase;
+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 StyleBase<Double> {
+
+       private static final Double PENDING = Double.NaN;
+       private static final Double ONE = 1.0;
+
+       @Override
+       public Double calculateStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException {
+               DiagramSettings ds = graph.syncRequest(new DiagramSettingsRequest(runtimeDiagram), TransientCacheAsyncListener.instance());
+               Double scaling = ONE;
+               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;
+       }
+
+       @Override
+       public void applyStyleForNode(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/profile/VertexStyle.java b/org.simantics.district.network/src/org/simantics/district/network/profile/VertexStyle.java
deleted file mode 100644 (file)
index 6fc5dfc..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.simantics.district.network.profile;
-
-import org.simantics.db.ReadGraph;
-import org.simantics.db.Resource;
-import org.simantics.db.exception.DatabaseException;
-import org.simantics.diagram.profile.StyleBase;
-import org.simantics.district.network.ontology.DistrictNetworkResource;
-import org.simantics.scenegraph.INode;
-import org.simantics.scenegraph.g2d.nodes.ConnectionNode;
-import org.simantics.scenegraph.profile.EvaluationContext;
-import org.simantics.scenegraph.profile.common.ProfileVariables;
-
-public class VertexStyle extends StyleBase<Double> {
-
-    @Override
-    public Double calculateStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException {
-        return 1.0;
-    }
-
-    @Override
-    public void applyStyleForNode(EvaluationContext observer, INode node, Double result) {
-//        if (result != null) {
-//            ConnectionNode n = (ConnectionNode) node;
-//            for (INode nn : n.getNodes()) {
-//                ProfileVariables.claimNodeProperty(nn, "stroke", result, observer);
-//            }
-//        }
-    }
-    
-}