@defProperty "Key Variables for Vertices on Hover" L0.Boolean
>-- DN.Diagram.Visualisations.KeyVariableEdgeHover
@defProperty "Key Variables for Edges on Hover" L0.Boolean
+ >-- DN.Diagram.Visualisations.ShowElevationServerBoundingBox
+ @defProperty "Show Elevation server bounding box" L0.Boolean
+ >-- DN.Diagram.Visualisations.NotInSimulation
+ @defProperty "Not in Simulation" L0.Boolean
DN.Diagram.Visualisations.ColorContribution <T L0.Entity
DN.Diagram.Visualisations.SizeContribution <T L0.Entity
//DN.ArrowLengthStyle : DIA.Style
//DN.HideStyle : DIA.Style
-DN.VertexSymbolStyle : DIA.Style
+//DN.VertexSymbolStyle : DIA.Style
DN.ConnectionLineStyle : DIA.Style
-DN.ElevationRectangleStyle : DIA.Style
+//DN.ElevationRectangleStyle : DIA.Style
// Style for user component-specified static info text for network branches
-DN.DistrictNetworkStaticInfoStyle : DIA.Style
+//DN.DistrictNetworkStaticInfoStyle : DIA.Style
// Function for dynamic selection of symbols for a vertex
// The input of the function is a DN.Vertex
org.simantics.district.network.ui.breakdown,
org.simantics.district.network.ui.function,
org.simantics.district.network.ui.nodes,
- org.simantics.district.network.ui.participants
+ org.simantics.district.network.ui.participants,
+ org.simantics.district.network.ui.styles
Require-Bundle: org.eclipse.e4.ui.model.workbench;bundle-version="1.1.100.v20150407-1430",
org.eclipse.swt,
org.simantics.g2d,
<resource uri="http://www.simantics.org/DistrictNetwork-1.0/ConnectionLineStyle"
class="org.simantics.district.network.ui.styles.ConnectionLineStyle">
</resource>
- <resource uri="http://www.simantics.org/DistrictNetwork-1.0/DistrictNetworkStaticInfoStyle"
- class="org.simantics.district.network.ui.styles.DistrictNetworkStaticInfoStyle">
- <this />
- </resource>
- <resource uri="http://www.simantics.org/DistrictNetwork-1.0/ElevationRectangleStyle"
- class="org.simantics.district.network.ui.styles.ElevationRectangleStyle">
- </resource>
</target>
<target interface="org.simantics.g2d.diagram.DiagramClass">
import org.simantics.district.network.ui.nodes.DistrictSelectionNode;
import org.simantics.district.network.ui.participants.DNPointerInteractor;
import org.simantics.district.network.ui.participants.DynamicVisualisationContributionsParticipant;
-import org.simantics.district.network.ui.participants.ElevationServerParticipant;
import org.simantics.district.network.ui.participants.MapRulerPainter;
import org.simantics.district.network.visualisations.DynamicVisualisations;
import org.simantics.district.network.visualisations.model.ColorBarOptions;
DynamicVisualisationContributionsParticipant dynamicVisualisationContributionsParticipant = new DynamicVisualisationContributionsParticipant(tr);
ctx.add(new NetworkDrawingParticipant(dynamicVisualisationContributionsParticipant, tr));
- ctx.add(new ElevationServerParticipant(tr));
ctx.add(dynamicVisualisationContributionsParticipant);
// Optimize AffineTransform memory allocations during district diagram rendering
setupColorBarOptions();
setupSizingObjects();
setupSizeBarOptions();
+ setupShowElevationServerBoundingBox();
// add listeners
DistrictDiagramViewerListener[] listeners = Activator.getInstance().getDistrictDiagramViewerListeners();
() -> DistrictDiagramViewer.this.isDisposed()));
}
-
private void setupSizeBarOptions() {
sessionContext.getSession().asyncRequest(new SizeBarOptionsRequest(getInputResource()), new SizeBarOptionsListener(
result -> queueSizeBarOptionsChangeEvent(result),
() -> DistrictDiagramViewer.this.isDisposed()));
}
-
+
+ private void setupShowElevationServerBoundingBox() {
+ sessionContext.getSession().asyncRequest(new ShowElevationServerRequest(getInputResource()), new ShowElevationServerListener(
+ result -> queueShowElevationServerChangeEvent(result),
+ () -> DistrictDiagramViewer.this.isDisposed()));
+ }
+
public static final Key KEY_MAP_COLOR_BAR_OPTIONS = new KeyOf(ColorBarOptions.class, "colorBarOptions");
public static final Command MAP_COLOR_BAR_OPTIONS_CHANGE = new Command("colorBarOptionsChange");
public static final Key KEY_MAP_SIZE_BAR_OPTIONS = new KeyOf(SizeBarOptions.class, "sizeBarOptions");
public static final Key KEY_MAP_SIZING_OBJECTS = new KeyOf(Map.class, "sizingObjects");
public static final Command MAP_SIZING_OBJECTS_CHANGE = new Command("sizingObjectsChange");
-
+ public static final Key KEY_SHOW_ELEVATION_SERVER = new KeyOf(Boolean.class, "showElevationServer");
+ public static final Command SHOW_ELEVATION_SERVER_CHANGE = new Command("showElevationServerChange");
+
private void queueColoringObjectsChangeEvent(Map<String, DynamicColorContribution> result) {
queueEventInternal(KEY_MAP_COLORING_OBJECTS, MAP_COLORING_OBJECTS_CHANGE, result);
}
-
+
private void queueColorBarOptionsChangeEvent(ColorBarOptions result) {
queueEventInternal(KEY_MAP_COLOR_BAR_OPTIONS, MAP_COLOR_BAR_OPTIONS_CHANGE, result);
}
private void queueSizingObjectsChangeEvent(Map<String, DynamicSizeContribution> result) {
queueEventInternal(KEY_MAP_SIZING_OBJECTS, MAP_SIZING_OBJECTS_CHANGE, result);
}
-
+
private void queueSizeBarOptionsChangeEvent(SizeBarOptions result) {
queueEventInternal(KEY_MAP_SIZE_BAR_OPTIONS, MAP_SIZE_BAR_OPTIONS_CHANGE, result);
}
+ private void queueShowElevationServerChangeEvent(Boolean result) {
+ queueEventInternal(KEY_SHOW_ELEVATION_SERVER, SHOW_ELEVATION_SERVER_CHANGE, result);
+ }
+
private void queueEventInternal(Key key, Command command, Object result) {
if (result != null && !canvasContext.isDisposed()) {
canvasContext.getThreadAccess().asyncExec(() -> {
@Override
public void exception(Throwable t) {
- LOGGER.error("Could not listen ColorBarOptions", t);
+ LOGGER.error("Could not listen ColoringObjects", t);
}
@Override
@Override
public void exception(Throwable t) {
- LOGGER.error("Could not listen ColorBarOptions", t);
+ LOGGER.error("Could not listen SizingObjectsOptions", t);
+ }
+
+ @Override
+ public boolean isDisposed() {
+ return isDisposed.get();
+ }
+ }
+
+ private static class ShowElevationServerRequest extends UnaryRead<Resource, Boolean> {
+
+ public ShowElevationServerRequest(Resource diagram) {
+ super(diagram);
+ }
+
+ @Override
+ public Boolean perform(ReadGraph graph) throws DatabaseException {
+ DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+ Resource model = graph.syncRequest(new PossibleIndexRoot(parameter));
+ if (model != null) {
+ Resource vf = DynamicVisualisations.getVisualisationFolder(graph, model);
+ if (vf != null) {
+ Resource activeVisualisation = graph.getPossibleObject(vf, DN.Diagram_hasActiveVisualisation);
+ if (activeVisualisation != null) {
+ return DynamicVisualisations.showElevationServerBoundingBox(graph, activeVisualisation);
+ }
+ } else {
+ LOGGER.debug("No visualisation folder available for model {}", model);
+ }
+ }
+ return false;
+ }
+ }
+
+ private static class ShowElevationServerListener implements Listener<Boolean> {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ShowElevationServerListener.class);
+
+ private Consumer<Boolean> callback;
+ private Supplier<Boolean> isDisposed;
+
+ public ShowElevationServerListener(Consumer<Boolean> callback, Supplier<Boolean> isDisposed) {
+ this.callback = callback;
+ this.isDisposed = isDisposed;
+ }
+
+ @Override
+ public void execute(Boolean result) {
+ callback.accept(result);
+ }
+
+ @Override
+ public void exception(Throwable t) {
+ LOGGER.error("Could not listen Show Elevation Server", t);
}
@Override
@Override
public void render(Graphics2D g2d) {
ParentNode<?> root = (ParentNode<?>) NodeUtil.getNearestParentOfType(this, RTreeNode.class);
- DeferredRenderingNode deferred = root != null ? (DeferredRenderingNode) root.getNode(DistrictNetworkStaticInfoStyle.STATIC_INFO_DEFERRED) : null;
+ DeferredRenderingNode deferred = root != null ? (DeferredRenderingNode) root.getNode(RENDERER_ID) : null;
if (deferred != null)
deferred.deferNode(g2d.getTransform(), this);
else
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
-import java.awt.geom.Line2D;
import java.awt.geom.Path2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
+import java.util.Optional;
import org.simantics.district.network.ModelledCRS;
import org.simantics.district.network.ui.DistrictNetworkEdge;
this.hidden = value;
}
+ public void setStaticInformation(Optional<String> staticInformation) {
+ DistrictNetworkStaticInfoNode child = getOrCreateNode(DistrictNetworkStaticInfoNode.NODE_KEY, DistrictNetworkStaticInfoNode.class);
+ child.setEdgeNode(this);
+ if (staticInformation.isPresent()) {
+ child.setInfo(staticInformation.get());
+ } else {
+ child.setInfo(null);
+ }
+ }
+
+ public void setInSimulation(Optional<Boolean> isInSimulation) {
+ if (!isInSimulation.isPresent()) {
+ removeNode(NotInSimulationNode.NODE_NAME);
+ } else {
+ NotInSimulationNode child = getOrCreateNode(NotInSimulationNode.NODE_NAME, NotInSimulationNode.class);
+ child.setZIndex(1000);
+ child.setIsInSimulation(isInSimulation.get());
+ }
+ }
+
}
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
+import java.util.Optional;
import org.simantics.district.network.ui.adapters.DistrictNetworkVertex;
import org.simantics.maps.MapScalingTransform;
public void setHidden(Boolean value) {
this.hidden = value;
}
+
+ public void setStaticInformation(Optional<String> staticInformation) {
+ DistrictNetworkStaticInfoNode child = getOrCreateNode(DistrictNetworkStaticInfoNode.NODE_KEY, DistrictNetworkStaticInfoNode.class);
+ Point2D calculatePoint2D = DistrictNetworkNodeUtils.calculatePoint2D(vertex.getPoint(), null);
+ child.setLocation(calculatePoint2D, new Point2D.Double(1.0, 0.0));
+ if (staticInformation.isPresent()) {
+ child.setInfo(staticInformation.get());
+ } else {
+ child.setInfo(null);
+ }
+ }
+
+ public void setInSimulation(Optional<Boolean> isInSimulation) {
+ if (!isInSimulation.isPresent()) {
+ removeNode(NotInSimulationNode.NODE_NAME);
+ } else {
+ NotInSimulationNode child = getOrCreateNode(NotInSimulationNode.NODE_NAME, NotInSimulationNode.class);
+ child.setZIndex(1000);
+ child.setIsInSimulation(isInSimulation.get());
+ }
+ }
}
--- /dev/null
+package org.simantics.district.network.ui.nodes;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.geom.Rectangle2D;
+
+import org.simantics.scenegraph.ParentNode;
+import org.simantics.scenegraph.g2d.G2DNode;
+import org.simantics.scenegraph.utils.GeometryUtils;
+
+public class NotInSimulationNode extends G2DNode {
+
+ private static final BasicStroke STROKE = new BasicStroke(1.5f);
+ public static final String NODE_NAME = "notInSimulation";
+
+ private static final long serialVersionUID = 1503248449618244809L;
+ private boolean isInSimulation;
+
+ @Override
+ public Rectangle2D getBoundsInLocal() {
+ return null;
+ }
+
+ @Override
+ public Rectangle2D getBoundsInLocal(boolean b) {
+ return null;
+ }
+
+ @Override
+ public Rectangle2D getBounds() {
+ return null;
+ }
+
+ public void render(java.awt.Graphics2D g) {
+ if (!isInSimulation) {
+ ParentNode<?> parent = getParent();
+ if (!(parent instanceof DistrictNetworkVertexNode))
+ return;
+
+ Rectangle2D bounds = ((DistrictNetworkVertexNode)parent).getBoundsInLocal();
+ Rectangle2D expandedBounds = GeometryUtils.expandRectangle( bounds, bounds.getWidth() / 2 );
+
+ g.setColor(Color.RED);
+ g.setStroke(GeometryUtils.scaleStroke(STROKE, 1.f / (float)g.getTransform().getScaleX()));
+ g.draw(expandedBounds);
+ }
+ }
+
+ public void setIsInSimulation(boolean isInSimulation) {
+ this.isInSimulation = isInSimulation;
+ }
+
+}
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import org.simantics.district.network.ui.nodes.DistrictNetworkEdgeArrayNode;
import org.simantics.district.network.ui.nodes.DistrictNetworkHoverInfoNode;
import org.simantics.district.network.ui.nodes.DynamicVisualisationContributionsNode;
+import org.simantics.district.network.ui.nodes.ElevationServerNode;
import org.simantics.district.network.ui.styles.DistrictNetworkHoverInfoStyle;
import org.simantics.district.network.ui.styles.DistrictNetworkHoverInfoStyle.StyleResult;
import org.simantics.district.network.visualisations.model.ColorBarOptions;
import org.simantics.g2d.canvas.ICanvasContext;
import org.simantics.g2d.canvas.impl.AbstractCanvasParticipant;
import org.simantics.g2d.canvas.impl.SGNodeReflection.SGInit;
+import org.simantics.maps.elevation.server.SingletonTiffTileInterface;
import org.simantics.scenegraph.INode;
import org.simantics.scenegraph.g2d.G2DParentNode;
import org.simantics.scenegraph.g2d.events.EventHandlerReflection.EventHandler;
private DistrictNetworkHoverInfoNode hoverInfoNode;
private DeferredRenderingNode deferredEdgeArrowRendererNode;
+ private ElevationServerNode showElevationServerBoundingBoxNode;
+
public DynamicVisualisationContributionsParticipant(AffineTransform tr) {
this.transform = tr;
}
getHintStack().addKeyHintListener(getThread(), DistrictDiagramViewer.KEY_MAP_COLOR_BAR_OPTIONS, hintListener);
getHintStack().addKeyHintListener(getThread(), DistrictDiagramViewer.KEY_MAP_SIZING_OBJECTS, hintListener);
getHintStack().addKeyHintListener(getThread(), DistrictDiagramViewer.KEY_MAP_SIZE_BAR_OPTIONS, hintListener);
+ getHintStack().addKeyHintListener(getThread(), DistrictDiagramViewer.KEY_SHOW_ELEVATION_SERVER, hintListener);
}
@Override
getHintStack().removeKeyHintListener(getThread(), DistrictDiagramViewer.KEY_MAP_COLOR_BAR_OPTIONS, hintListener);
getHintStack().removeKeyHintListener(getThread(), DistrictDiagramViewer.KEY_MAP_SIZING_OBJECTS, hintListener);
getHintStack().removeKeyHintListener(getThread(), DistrictDiagramViewer.KEY_MAP_SIZE_BAR_OPTIONS, hintListener);
+ getHintStack().removeKeyHintListener(getThread(), DistrictDiagramViewer.KEY_SHOW_ELEVATION_SERVER, hintListener);
super.removedFromContext(ctx);
}
Pair<String, Class<DeferredRenderingNode>> dearn = DistrictNetworkEdgeArrayNode.renderer();
deferredEdgeArrowRendererNode = parent.addNode(dearn.first, dearn.second);
+
+ showElevationServerBoundingBoxNode = parent.addNode(ElevationServerNode.ID, ElevationServerNode.class);
+ showElevationServerBoundingBoxNode.setTransform(transform);
}
@EventHandler(priority = 0)
node.setColorBarOptions(getColorBarOptions());
node.setDynamicSizingObjects(getDynamicSizingObjects());
node.setSizeBarOptions(getSizeBarOptions());
+
+ showElevationServerBoundingBoxNode.setRectangles(getRectangles());
+ }
+
+ private Collection<Rectangle2D> getRectangles() {
+ Boolean enabled = getHint(DistrictDiagramViewer.KEY_SHOW_ELEVATION_SERVER);
+ if (enabled != null && enabled)
+ return SingletonTiffTileInterface.getBoundingBoxes();
+ return Collections.emptyList();
}
private Map<String, DynamicColorContribution> getDynamicColoringObjects() {
+++ /dev/null
-package org.simantics.district.network.ui.participants;
-
-import java.awt.geom.AffineTransform;
-
-import org.simantics.district.network.ui.nodes.ElevationServerNode;
-import org.simantics.g2d.canvas.impl.SGNodeReflection.SGInit;
-import org.simantics.g2d.diagram.participant.AbstractDiagramParticipant;
-import org.simantics.scenegraph.g2d.G2DParentNode;
-
-public class ElevationServerParticipant extends AbstractDiagramParticipant {
-
- private ElevationServerNode node;
-
- private AffineTransform transform;
-
- public ElevationServerParticipant(AffineTransform transform) {
- this.transform = transform;
- }
-
- @SGInit
- public void initSG(G2DParentNode parent) {
- node = parent.addNode(ElevationServerNode.ID, ElevationServerNode.class);
- node.setTransform(transform);
- }
-
-}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@Deprecated
public class DistrictNetworkStaticInfoStyle extends StyleBase<DistrictNetworkStaticInfoStyle.StyleResult> {
private static final Logger LOGGER = LoggerFactory.getLogger(DistrictNetworkStaticInfoStyle.class);
@Override
public StyleResult calculateStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource mapElement)
throws DatabaseException {
- DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
- Set<Resource> types = graph.getTypes(mapElement);
- boolean isEdge = types.contains(DN.Edge);
- boolean isVertex = types.contains(DN.Vertex);
- if (!isEdge && !isVertex)
- return null;
-
- if (isEdge) {
- Resource diagram = graph.getSingleObject(mapElement, Layer0.getInstance(graph).PartOf);
- Set<Resource> edgesToUse = graph.syncRequest(new MidBranchEdgeSetRequest(diagram), TransientCacheListener.instance());
- if (!edgesToUse.contains(mapElement))
- return null;
- }
-
- Resource module = DistrictNetworkUtil.getMappedComponentCached(graph, mapElement);
- if (module == null)
- return null;
-
- StructuralResource2 STR = StructuralResource2.getInstance(graph);
- Resource moduleType = graph.getPossibleType(module, STR.Component);
- if (moduleType == null)
- return null;
-
- Function1<Variable, String> function = getUCPipelineInfoFunctionCached(graph, moduleType);
- if (function == null)
- return null;
-
- String result;
- try {
- Variable variable = Variables.getVariable(graph, module);
- Variable moduleVariable = Variables.possibleActiveVariable(graph, variable);
- if (moduleVariable == null)
- moduleVariable = variable;
-
- result = Simantics.applySCLRead(graph, function, moduleVariable);
- } catch (PendingVariableException | MissingVariableValueException e) {
- result = null;
- } catch (MissingVariableException e) {
- // the requested variable is missing from the UC
- String message = e.getMessage();
- LOGGER.warn("Missing variable for calculating style with function {} {}", function, message);
- result = "<" + message + ">";
- }
-
- if (isVertex) {
- DiagramResource DIA = DiagramResource.getInstance(graph);
- double[] coords = graph.getRelatedValue(mapElement, DIA.HasLocation);
- Point2D p = DistrictNetworkNodeUtils.calculatePoint2D(new Point2D.Double(coords[0], coords[1]), null);
- return new StyleResult(mapElement, p, result);
- } else if (isEdge) {
- return new StyleResult(mapElement, EDGE, result);
- }
- return null;
+ return calculateStyle(graph, entry, mapElement);
}
+ public static StyleResult calculateStyle(ReadGraph graph, Resource entry, Resource mapElement) throws DatabaseException {
+ DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+ Set<Resource> types = graph.getTypes(mapElement);
+ boolean isEdge = types.contains(DN.Edge);
+ boolean isVertex = types.contains(DN.Vertex);
+ if (!isEdge && !isVertex)
+ return null;
+
+ if (isEdge) {
+ Resource diagram = graph.getSingleObject(mapElement, Layer0.getInstance(graph).PartOf);
+ Set<Resource> edgesToUse = graph.syncRequest(new MidBranchEdgeSetRequest(diagram), TransientCacheListener.instance());
+ if (!edgesToUse.contains(mapElement))
+ return null;
+ }
+
+ Resource module = DistrictNetworkUtil.getMappedComponentCached(graph, mapElement);
+ if (module == null)
+ return null;
+
+ StructuralResource2 STR = StructuralResource2.getInstance(graph);
+ Resource moduleType = graph.getPossibleType(module, STR.Component);
+ if (moduleType == null)
+ return null;
+
+ Function1<Variable, String> function = getUCPipelineInfoFunctionCached(graph, moduleType);
+ if (function == null)
+ return null;
+
+ String result;
+ try {
+ Variable variable = Variables.getVariable(graph, module);
+ Variable moduleVariable = Variables.possibleActiveVariable(graph, variable);
+ if (moduleVariable == null)
+ moduleVariable = variable;
+
+ result = Simantics.applySCLRead(graph, function, moduleVariable);
+ } catch (PendingVariableException | MissingVariableValueException e) {
+ result = null;
+ } catch (MissingVariableException e) {
+ // the requested variable is missing from the UC
+ String message = e.getMessage();
+ LOGGER.warn("Missing variable for calculating style with function {} {}", function, message);
+ result = "<" + message + ">";
+ }
+
+ if (isVertex) {
+ DiagramResource DIA = DiagramResource.getInstance(graph);
+ double[] coords = graph.getRelatedValue(mapElement, DIA.HasLocation);
+ Point2D p = DistrictNetworkNodeUtils.calculatePoint2D(new Point2D.Double(coords[0], coords[1]), null);
+ return new StyleResult(mapElement, p, result);
+ } else if (isEdge) {
+ return new StyleResult(mapElement, EDGE, result);
+ }
+ return null;
+ }
+
@Override
public void applyStyleForNode(EvaluationContext evaluationContext, INode parent, StyleResult result) {
if (result == null) {
private Button resetVisualisationButton;
private Button hoveringVertexEnabledButton;
private Button hoveringEdgesEnabledButton;
+ private Button elevationServerEnabledButton;
+ private Button notInSimulationButton;
private List<Supplier<Pair<String, DynamicArrowContribution>>> edgeArrowSuppliers;
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(intervalElementsComposite);
initializeIntervalElements(intervalElementsComposite);
+ Composite hoverElementsComposite = new Composite(parent, SWT.NONE);
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(hoverElementsComposite);
+ GridLayoutFactory.fillDefaults().numColumns(1).applyTo(hoverElementsComposite);
+ initializeHoverElements(hoverElementsComposite);
+
Composite hideElementsComposite = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, false).applyTo(hideElementsComposite);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(hideElementsComposite);
private void initializeIntervalElements(Composite parent) {
Group group = new Group(parent, SWT.NONE);
- group.setText("Interval");
+ group.setText("Generic");
GridDataFactory.fillDefaults().grab(true, false).applyTo(group);
- GridLayoutFactory.fillDefaults().numColumns(6).margins(5, 5).applyTo(group);
+ GridLayoutFactory.fillDefaults().numColumns(2).margins(5, 5).applyTo(group);
createIntervalElements(group);
}
private void createIntervalElements(Composite parent) {
Label label = new Label(parent, SWT.NONE);
- label.setText("Generic");
+ label.setText("Interval (seconds)");
intervalText = new Text(parent, SWT.BORDER);
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(intervalText);
addSelectionListener(intervalText);
disableUpdatesButton = new Button(parent, SWT.CHECK);
resetVisualisationButton.setText("Reset Visualisation");
addSelectionListener(resetVisualisationButton);
+ notInSimulationButton = new Button(parent, SWT.CHECK);
+ notInSimulationButton.setText("Not in Simulation");
+ addSelectionListener(notInSimulationButton);
+
+ elevationServerEnabledButton = new Button(parent, SWT.CHECK);
+ elevationServerEnabledButton.setText("Elevation Server Bounding Box");
+ addSelectionListener(elevationServerEnabledButton);
+ }
+
+ private void initializeHoverElements(Composite parent) {
+ Group group = new Group(parent, SWT.NONE);
+ group.setText("Hover");
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(group);
+ GridLayoutFactory.fillDefaults().numColumns(2).margins(5, 5).applyTo(group);
+
+ createHoverElements(group);
+ }
+
+ private void createHoverElements(Composite parent) {
hoveringVertexEnabledButton = new Button(parent, SWT.CHECK);
hoveringVertexEnabledButton.setText("Vertex Key Variables on Hover");
addSelectionListener(hoveringVertexEnabledButton);
Combo variableCombo = new Combo(parent, SWT.READ_ONLY);
variableCombo.setItems(arrowContributions.keySet().toArray(new String[arrowContributions.size()]));
-
- GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(variableCombo);
+ GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(variableCombo);
Text gainText = new Text(parent, SWT.BORDER);
- GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(gainText);
+ GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(gainText);
addSelectionListener(gainText);
Text biasText = new Text(parent, SWT.BORDER);
- GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(biasText);
+ GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(biasText);
addSelectionListener(biasText);
Button defaultButton = new Button(parent, SWT.CHECK);
boolean resetVisualisation = resetVisualisationButton.getSelection();
Long interval;
try {
- interval = Long.parseLong(intervalText.getText());
+ // inteval is in milliseconds but shown as seconds
+
+ interval = (long)(Double.parseDouble(intervalText.getText()) * 1000);
} catch (NumberFormatException e) {
// ignore
interval = 2000L;
boolean hoverVertex = hoveringVertexEnabledButton.getSelection();
boolean hoverEdges = hoveringEdgesEnabledButton.getSelection();
+ boolean elevationServerBoundingBox = elevationServerEnabledButton.getSelection();
+ boolean notInSimulation = notInSimulationButton.getSelection();
+
Simantics.getSession().asyncRequest(new WriteRequest() {
@Override
dynamicSymbolsPumpingStations
);
DynamicVisualisations.setKeyVariablesHover(graph, exist, hoverVertex, hoverEdges);
+
+ DynamicVisualisations.setElevationServerBoundingBox(graph, exist, elevationServerBoundingBox);
+ DynamicVisualisations.setNotInSimulation(graph, exist, notInSimulation);
}
});
}
Combo variableCombo = new Combo(parent, SWT.READ_ONLY);
variableCombo.setItems(colorContributions.keySet().toArray(new String[colorContributions.size()]));
- GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(variableCombo);
+ GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(variableCombo);
Text minText = new Text(parent, SWT.BORDER);
- GridDataFactory.fillDefaults().grab(true, false).hint(150, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(minText);
+ GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(minText);
addSelectionListener(minText);
Text maxText = new Text(parent, SWT.BORDER);
- GridDataFactory.fillDefaults().grab(true, false).hint(150, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(maxText);
+ GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(maxText);
addSelectionListener(maxText);
Text unit = new Text(parent, SWT.READ_ONLY);
- GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).applyTo(unit);
+ GridDataFactory.fillDefaults().grab(true, false).hint(30, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(unit);
Combo colorMapCombo = new Combo(parent, SWT.READ_ONLY);
- GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(colorMapCombo);
+ GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(colorMapCombo);
colorMapCombo.setItems(colorMaps.keySet().toArray(new String[colorMaps.keySet().size()]));
addSelectionListener(colorMapCombo);
Combo variableCombo = new Combo(parent, SWT.READ_ONLY);
variableCombo.setItems(sizeContributions.keySet().toArray(new String[sizeContributions.size()]));
-
- GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(variableCombo);
+ GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(variableCombo);
Text minText = new Text(parent, SWT.BORDER);
- GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(minText);
+ GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(minText);
addSelectionListener(minText);
Text maxText = new Text(parent, SWT.BORDER);
- GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(maxText);
+ GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(maxText);
addSelectionListener(maxText);
Label unit = new Label(parent, SWT.NONE);
- GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).applyTo(unit);
+ GridDataFactory.fillDefaults().grab(true, false).hint(30, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(unit);
Combo sizeMapCombo = new Combo(parent, SWT.READ_ONLY);
- GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(sizeMapCombo);
+ GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(sizeMapCombo);
sizeMapCombo.setItems(sizeMaps.keySet().toArray(new String[sizeMaps.keySet().size()]));
addSelectionListener(sizeMapCombo);
}
}
- intervalText.setText(Long.toString(visualisation.getInterval()));
+ intervalText.setText(Double.toString(((double)visualisation.getInterval()) / 1000.0));
disableUpdatesButton.setSelection(visualisation.disabledUpdates());
hoveringVertexEnabledButton.setSelection(visualisation.isKeyVariablesVertexHover());
break;
}
}
+
+ pointsStaticPropertiesButton.setSelection(visualisation.isStaticPropertiesPoints());
+ networkBranchesStaticPropertiesButton.setSelection(visualisation.isStaticPropertiesNetworkBranches());
+ consumersStaticPropertiesButton.setSelection(visualisation.isStaticPropertiesConsumers());
}
});
}
<this />
</type>
</target>
- <target interface="org.simantics.scenegraph.profile.Style">
- <!--
- <resource uri="http://www.simantics.org/DistrictNetwork-1.0/ElementColoringStyle"
- class="org.simantics.district.network.profile.DNElementColorStyle">
- </resource>
- <resource uri="http://www.simantics.org/DistrictNetwork-1.0/ElementSizingStyle"
- class="org.simantics.district.network.profile.DNElementSizeStyle">
- </resource>
- <resource uri="http://www.simantics.org/DistrictNetwork-1.0/ArrowLengthStyle"
- class="org.simantics.district.network.profile.ArrowLengthStyle">
- </resource>
- <resource uri="http://www.simantics.org/DistrictNetwork-1.0/HideStyle"
- class="org.simantics.district.network.profile.HideStyle">
- </resource>
- -->
- <resource uri="http://www.simantics.org/DistrictNetwork-1.0/VertexSymbolStyle"
- class="org.simantics.district.network.profile.VertexSymbolStyle">
- </resource>
- </target>
-
<target interface="org.simantics.scenegraph.profile.Group">
<type
uri="http://www.simantics.org/DistrictNetwork-1.0/DistrictNodeGroup"
--- /dev/null
+import "Map" as Map
+import "Simantics/DB"
+
+importJava "org.simantics.district.network.visualisations.model.StaticInformationContribution" where
+ data StaticInformationContribution
+
+ @JavaName "<init>"
+ staticInformationContribution :: String -> String -> String -> String -> StaticInformationContribution
+
+importJava "org.simantics.district.network.visualisations.model.DynamicSymbolContribution" where
+ data DynamicSymbolContribution
+
+ @JavaName "<init>"
+ dynamicSymbolContribution :: [String] -> (Map.T String Integer -> Map.T String String -> <a> Maybe String) -> (() -> <ReadGraph, Proc> Map.T String String) -> DynamicSymbolContribution
\ No newline at end of file
import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicArrowObject;
import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicColoringObject;
import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicSizingObject;
+import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicSymbolContributionObject;
+import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.StaticInformationContributionObject;
import org.simantics.district.network.visualisations.model.ColorBarOptions;
import org.simantics.district.network.visualisations.model.DynamicArrowContribution;
import org.simantics.district.network.visualisations.model.DynamicColorContribution;
SizeBarOptions sizeBarOptions = DynamicVisualisations.sizeBarOptions(graph, visualisationResource);
Map<String, DynamicArrowContribution> arrowContributions = DynamicVisualisations.arrowContributions(graph, visualisationResource);
+ Collection<StaticInformationContributionObject> staticInformationContributions = DynamicVisualisationsContributions.staticInformationContributionObjects(graph);
+ Map<String, StaticInformationContributionObject> staticInformationContributionObjects = staticInformationContributions.stream().collect(Collectors.toMap(dcc -> dcc.getStaticInformationContributionObject().getName(), dcc -> dcc));
+
+ Collection<DynamicSymbolContributionObject> dynamicSymbolContributions = DynamicVisualisationsContributions.dynamicSymbolContributionObjects(graph);
+ Map<String, DynamicSymbolContributionObject> dynamicSymbolContributionObjects = dynamicSymbolContributions.stream().map(dsc -> {
+ // here we resolve the symbol map with the help of readgraph
+ dsc.resolveSymbols(graph);
+ return dsc;
+ }).collect(Collectors.toMap(dcc -> dcc.getDynamicSymbolContributionObject().getName(), dcc -> dcc));
+
Boolean hideEdges = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_HideEdges, Bindings.BOOLEAN);
Boolean hidePoints = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_HidePoints, Bindings.BOOLEAN);
Boolean hideConsumers = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_HideConsumers, Bindings.BOOLEAN);
Boolean keyVariablesVertexHover = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_KeyVariableVertexHover, Bindings.BOOLEAN);
Boolean keyVariablesEdgesHover = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_KeyVariableEdgeHover, Bindings.BOOLEAN);
+ Boolean showElevationServerBoundingBox = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_ShowElevationServerBoundingBox, Bindings.BOOLEAN);
+ Boolean notInSimulation = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_NotInSimulation, Bindings.BOOLEAN);
+
DynamicVisualisation visualisation = new DynamicVisualisation(name, visualisationResource,
interval != null ? interval : 2000,
disabledUpdates != null ? disabledUpdates : false,
sizeBarOptions,
defaultArrowObjects,
arrowContributions,
+ staticInformationContributionObjects,
+ dynamicSymbolContributionObjects,
hideEdges != null ? hideEdges : false,
hidePoints != null ? hidePoints : false,
hideConsumers != null ? hideConsumers : false,
dynamicSymbolsValves != null ? dynamicSymbolsValves : false,
dynamicSymbolsPumpingStations != null ? dynamicSymbolsPumpingStations : false,
keyVariablesVertexHover != null ? keyVariablesVertexHover : false,
- keyVariablesEdgesHover != null ? keyVariablesEdgesHover : false
+ keyVariablesEdgesHover != null ? keyVariablesEdgesHover : false,
+ showElevationServerBoundingBox != null ? showElevationServerBoundingBox : false,
+ notInSimulation != null ? notInSimulation : false
);
return visualisation;
}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@Deprecated
public class VertexSymbolStyle extends ThrottledStyleBase<String> {
private static final Logger LOGGER = LoggerFactory.getLogger(VertexSymbolStyle.class);
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- public String calculateThrottledStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException {
- // Prevent PendingVariableExceptions from coming through
- boolean wasSynchronous = graph.setSynchronous(true);
- try {
- Function symbolFunction = getSymbolFunction(graph, entry);
- if (symbolFunction == null)
- return null;
-
- try {
- return (String) Simantics.applySCLRead(graph, symbolFunction, groupItem);
- } catch (Exception e) {
- LOGGER.error("Getting dynamic symbol for " + groupItem + " (" + graph.getPossibleRelatedValue(groupItem, Layer0.getInstance(graph).HasName) + ") failed", e);
- return null;
- }
- }
- finally {
- graph.setSynchronous(wasSynchronous);
- }
- }
+
+ @Override
+ public String calculateThrottledStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException {
+ return calculateStyle(graph, entry, groupItem);
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public static String calculateStyle(ReadGraph graph, Resource entry, Resource groupItem) throws DatabaseException {
+ // Prevent PendingVariableExceptions from coming through
+ boolean wasSynchronous = graph.setSynchronous(true);
+ try {
+ Function symbolFunction = getSymbolFunction(graph, entry);
+ if (symbolFunction == null)
+ return null;
+
+ try {
+ return (String) Simantics.applySCLRead(graph, symbolFunction, groupItem);
+ } catch (Exception e) {
+ LOGGER.error("Getting dynamic symbol for " + groupItem + " ("
+ + graph.getPossibleRelatedValue(groupItem, Layer0.getInstance(graph).HasName) + ") failed", e);
+ return null;
+ }
+ } finally {
+ graph.setSynchronous(wasSynchronous);
+ }
+ }
@SuppressWarnings("rawtypes")
- protected static Function getSymbolFunction(ReadGraph graph, Resource entry) throws DatabaseException {
+ public static Function getSymbolFunction(ReadGraph graph, Resource entry) throws DatabaseException {
// Cache function read for profile entry
return graph.syncRequest(new SymbolFunctionRequest(entry), TransientCacheListener.<Function>instance());
}
DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
graph.claimLiteral(visualisation, DN.Diagram_Visualisations_KeyVariableVertexHover, hoverVertex, Bindings.BOOLEAN);
graph.claimLiteral(visualisation, DN.Diagram_Visualisations_KeyVariableEdgeHover, hoverEdges, Bindings.BOOLEAN);
+ }
+
+ public static void setElevationServerBoundingBox(WriteGraph graph, Resource visualisation, boolean elevationServerBoundingBox) throws DatabaseException {
+ DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+ graph.claimLiteral(visualisation, DN.Diagram_Visualisations_ShowElevationServerBoundingBox, elevationServerBoundingBox, Bindings.BOOLEAN);
+ }
+
+ public static Boolean showElevationServerBoundingBox(ReadGraph graph, Resource visualisation) throws DatabaseException {
+ DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+ return graph.getPossibleRelatedValue(visualisation, DN.Diagram_Visualisations_ShowElevationServerBoundingBox, Bindings.BOOLEAN);
+ }
+
+ public static void setNotInSimulation(WriteGraph graph, Resource visualisation, boolean notInSimulation) throws DatabaseException {
+ DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+ graph.claimLiteral(visualisation, DN.Diagram_Visualisations_NotInSimulation, notInSimulation, Bindings.BOOLEAN);
+ }
+
+ public static Boolean isNotInSimulation(ReadGraph graph, Resource visualisation) throws DatabaseException {
+ DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+ return graph.getPossibleRelatedValue(visualisation, DN.Diagram_Visualisations_NotInSimulation, Bindings.BOOLEAN);
}
+
}
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.simantics.district.network.visualisations.model.DynamicColorMap;
import org.simantics.district.network.visualisations.model.DynamicSizeContribution;
import org.simantics.district.network.visualisations.model.DynamicSizeMap;
+import org.simantics.district.network.visualisations.model.DynamicSymbolContribution;
+import org.simantics.district.network.visualisations.model.StaticInformationContribution;
import org.simantics.layer0.Layer0;
import org.simantics.scl.compiler.top.ValueNotFound;
import org.simantics.scl.osgi.SCLOsgi;
private static final String COLOR_CONTRIBUTION = "colorContribution";
private static final String SIZE_CONTRIBUTION = "sizeContribution";
private static final String ARROW_CONTRIBUTION = "arrowContribution";
+ private static final String STATIC_INFORMATION_CONTRIBUTION = "staticInformationContribution";
+ private static final String DYNAMIC_SYMBOL_CONTRIBUTION = "symbolContribution";
public static Map<String, DynamicColorMap> dynamicColorMaps(ReadGraph graph) throws DatabaseException {
List<Resource> sharedOntologies = Simantics.applySCL("Simantics/SharedOntologies", "getSharedOntologies", graph, Tuple0.INSTANCE);
}
};
}
+
+ public static Collection<StaticInformationContributionObject> staticInformationContributionObjects(ReadGraph graph) throws DatabaseException {
+
+ List<Resource> sharedOntologies = Simantics.applySCL("Simantics/SharedOntologies", "getSharedOntologies", graph, Tuple0.INSTANCE);
+
+ List<StaticInformationContributionObject> results = new ArrayList<>();
+
+ for (Resource sharedOntology : sharedOntologies) {
+ Collection<Resource> findByType = graph.syncRequest(new ObjectsWithSupertype(sharedOntology, Layer0.getInstance(graph).ConsistsOf, StructuralResource2.getInstance(graph).Component));
+ //Collection<Resource> findByType = QueryIndexUtils.searchByType(graph, sharedOntology, );
+ for (Resource find : findByType) {
+ NamedResource moduleType = new NamedResource(NameLabelUtil.modalName(graph, find), find);
+ StaticInformationContributionObject staticInformationContributionObject = staticInformationContributionObject(graph, moduleType);
+ if (staticInformationContributionObject != null)
+ results.add(staticInformationContributionObject);
+ }
+ }
+ return results;
+ }
+
+ private static StaticInformationContributionObject staticInformationContributionObject(ReadGraph graph, NamedResource moduleType) throws DatabaseException {
+ Layer0 L0 = Layer0.getInstance(graph);
+ Resource sclModule = Layer0Utils.getPossibleChild(graph, moduleType.getResource(), L0.SCLModule, DYNAMIC_VISUALISATIONS_CONTRIBUTION_MODULE);
+ if (sclModule != null) {
+ String moduleURI = graph.getURI(sclModule);
+ return new StaticInformationContributionObject(moduleType, getContributionSupplier(moduleURI, STATIC_INFORMATION_CONTRIBUTION));
+ }
+ return null;
+ }
+
+ public static Collection<DynamicSymbolContributionObject> dynamicSymbolContributionObjects(ReadGraph graph) throws DatabaseException {
+
+ List<Resource> sharedOntologies = Simantics.applySCL("Simantics/SharedOntologies", "getSharedOntologies", graph, Tuple0.INSTANCE);
+ List<DynamicSymbolContributionObject> results = new ArrayList<>();
+
+ for (Resource sharedOntology : sharedOntologies) {
+ Collection<Resource> findByType = graph.syncRequest(new ObjectsWithSupertype(sharedOntology, Layer0.getInstance(graph).ConsistsOf, StructuralResource2.getInstance(graph).Component));
+ //Collection<Resource> findByType = QueryIndexUtils.searchByType(graph, sharedOntology, );
+ for (Resource find : findByType) {
+ NamedResource moduleType = new NamedResource(NameLabelUtil.modalName(graph, find), find);
+ DynamicSymbolContributionObject dynamicSymbolContributionObject = dynamicSymbolContributionObject(graph, moduleType);
+ if (dynamicSymbolContributionObject != null)
+ results.add(dynamicSymbolContributionObject);
+ }
+ }
+ return results;
+ }
+ private static DynamicSymbolContributionObject dynamicSymbolContributionObject(ReadGraph graph, NamedResource moduleType) throws DatabaseException {
+ Layer0 L0 = Layer0.getInstance(graph);
+ Resource sclModule = Layer0Utils.getPossibleChild(graph, moduleType.getResource(), L0.SCLModule, DYNAMIC_VISUALISATIONS_CONTRIBUTION_MODULE);
+ if (sclModule != null) {
+ String moduleURI = graph.getURI(sclModule);
+ return new DynamicSymbolContributionObject(moduleType, getContributionSupplier(moduleURI, DYNAMIC_SYMBOL_CONTRIBUTION));
+ }
+ return null;
+ }
+
public static class DynamicArrowObject {
private final NamedResource arrowObject;
return arrowContributions;
}
}
-
+
+ public static class StaticInformationContributionObject {
+
+ private final NamedResource staticInformationContributionObject;
+ private final Supplier<Stream<StaticInformationContribution>> staticInformationContributionSupplier;
+ private Map<String, StaticInformationContribution> staticInformationContributions;
+
+ public StaticInformationContributionObject(NamedResource staticInformationContributionObject, Supplier<Stream<StaticInformationContribution>> staticInformationContributionSupplier) {
+ this.staticInformationContributionObject = staticInformationContributionObject;
+ this.staticInformationContributionSupplier = staticInformationContributionSupplier;
+ }
+
+ public NamedResource getStaticInformationContributionObject() {
+ return staticInformationContributionObject;
+ }
+
+ public Map<String, StaticInformationContribution> getStaticInformationContributions() {
+ if (staticInformationContributions == null)
+ staticInformationContributions = staticInformationContributionSupplier.get().collect(Collectors.toMap(c -> c.getLabel(), c -> c));
+ return staticInformationContributions;
+ }
+ }
+
+ public static class DynamicSymbolContributionObject {
+
+ private final NamedResource dynamicSymbolContributionObject;
+ private final Supplier<Stream<DynamicSymbolContribution>> dynamicSymbolContributionSupplier;
+ private DynamicSymbolContribution dynamicSymbolContribution;
+
+ public DynamicSymbolContributionObject(NamedResource dynamicSymbolContributionObject, Supplier<Stream<DynamicSymbolContribution>> dynamicSymbolContributionSupplier) {
+ this.dynamicSymbolContributionObject = dynamicSymbolContributionObject;
+ this.dynamicSymbolContributionSupplier = dynamicSymbolContributionSupplier;
+ }
+
+ public NamedResource getDynamicSymbolContributionObject() {
+ return dynamicSymbolContributionObject;
+ }
+
+ public DynamicSymbolContribution getDynamicSymbolContribution() {
+ if (dynamicSymbolContribution == null) {
+ Optional<DynamicSymbolContribution> findFirst = dynamicSymbolContributionSupplier.get().findFirst();
+ findFirst.ifPresent(dsc -> {
+ dynamicSymbolContribution = dsc;
+ });
+ }
+ return dynamicSymbolContribution;
+ }
+
+ public void resolveSymbols(ReadGraph graph) {
+ SCLContext current = SCLContext.getCurrent();
+ Object oldGraph = current.put("graph", graph);
+ try {
+ DynamicSymbolContribution dsc = getDynamicSymbolContribution();
+ if (dsc != null)
+ dsc.resolveSymbolMap();
+ } finally {
+ current.put("graph", oldGraph);
+ }
+ }
+ }
+
public static class DynamicColoringObject {
private final NamedResource coloringObject;
--- /dev/null
+package org.simantics.district.network.visualisations.model;
+
+import java.util.List;
+import java.util.Map;
+
+import org.simantics.scl.runtime.function.Function1;
+import org.simantics.scl.runtime.function.Function2;
+import org.simantics.scl.runtime.tuple.Tuple0;
+
+public class DynamicSymbolContribution {
+
+ private List<String> children;
+ private Function2<Map<String, Integer>, Map<String, String>, String> symbolFunction;
+ private Function1<Tuple0, Map<String, String>> symbolMapFunction;
+
+ private Map<String, String> symbolMap;
+
+ // for graph persistence only
+ private boolean used;
+ private boolean useDefault;
+
+ public DynamicSymbolContribution(List<String> children, Function2<Map<String, Integer>, Map<String, String>, String> symbolFunction, Function1<Tuple0, Map<String, String>> symbolMapFunction) {
+ this.children = children;
+ this.symbolFunction = symbolFunction;
+ this.symbolMapFunction = symbolMapFunction;
+ }
+
+ public List<String> getChildren() {
+ return children;
+ }
+
+ public Function2<Map<String, Integer>, Map<String, String>, String> getSymbolFunction() {
+ return symbolFunction;
+ }
+
+ public void resolveSymbolMap() {
+ symbolMap = symbolMapFunction.apply(Tuple0.INSTANCE);
+ }
+
+ public Map<String, String> getSymbolMap() {
+ return symbolMap;
+ }
+
+ public boolean isUsed() {
+ return used;
+ }
+
+ public void setUsed(boolean used) {
+ this.used = used;
+ }
+
+ public boolean isUseDefault() {
+ return useDefault;
+ }
+
+ public void setUseDefault(boolean useDefault) {
+ this.useDefault = useDefault;
+ }
+
+}
\ No newline at end of file
import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicArrowObject;
import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicColoringObject;
import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicSizingObject;
+import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicSymbolContributionObject;
+import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.StaticInformationContributionObject;
public class DynamicVisualisation {
private final Map<String, DynamicArrowObject> defaultArrowContributions;
private final Map<String, DynamicArrowContribution> arrowContributions;
+ private final Map<String, StaticInformationContributionObject> staticInformationContributions;
+ private final Map<String, DynamicSymbolContributionObject> dynamicSymbolContributions;
+
private final boolean hideEdges;
private final boolean hidePoints;
private final boolean hideConsumers;
private boolean keyVariablesEdgesHover;
private boolean resetVisualisation;
+ private boolean showElevationServerBoundingBox;
+ private boolean isInSimulation;
+
public DynamicVisualisation(String name, Resource visualisationResource, long interval, boolean disabled,
boolean resetVisualisation, Map<String, DynamicColorContribution> colorContributions,
Map<String, DynamicColoringObject> defaultColoringObjects, ColorBarOptions colorBarOptions,
Map<String, DynamicSizingObject> defaultSizingObjects, SizeBarOptions sizeBarOptions,
Map<String, DynamicArrowObject> defaultArrowContributions,
Map<String, DynamicArrowContribution> arrowContributions,
+ Map<String, StaticInformationContributionObject> staticInformationContributions,
+ Map<String, DynamicSymbolContributionObject> dynamicSymbolContributions,
boolean hideEdges,
boolean hidePoints,
boolean hideConsumers,
boolean dynamicSymbolsValves,
boolean dynamicSymbolsPumpingStations,
boolean keyVariablesVertexHover,
- boolean keyVariablesEdgesHover
+ boolean keyVariablesEdgesHover,
+ boolean showElevationServerBoundingBox,
+ boolean isInSimulation
) {
this.name = name;
this.visualisationResource = visualisationResource;
this.sizeBarOptions = sizeBarOptions;
this.defaultArrowContributions = defaultArrowContributions;
this.arrowContributions = arrowContributions;
+ this.staticInformationContributions = staticInformationContributions;
+ this.dynamicSymbolContributions = dynamicSymbolContributions;
this.hidePoints = hidePoints;
this.hideConsumers = hideConsumers;
this.keyVariablesVertexHover = keyVariablesVertexHover;
this.keyVariablesEdgesHover = keyVariablesEdgesHover;
+
+ this.showElevationServerBoundingBox = showElevationServerBoundingBox;
+ this.isInSimulation = isInSimulation;
}
public String getName() {
return arrowContributions;
}
+ public Map<String, StaticInformationContributionObject> getStaticInformationContributions() {
+ return staticInformationContributions;
+ }
+
public boolean isHideEdges() {
return hideEdges;
}
public boolean isResetVisualisation() {
return resetVisualisation;
}
+
+ public boolean isInSimulation() {
+ return isInSimulation;
+ }
+
+ public Map<String, DynamicSymbolContributionObject> getDynamicSymbolContributions() {
+ return dynamicSymbolContributions;
+ }
}
--- /dev/null
+package org.simantics.district.network.visualisations.model;
+
+public class StaticInformationContribution {
+
+ private String label;
+ private String moduleName;
+ private String attributeName;
+ private String unit;
+
+ // for graph persistence only
+ private boolean used;
+ private boolean useDefault;
+
+ public StaticInformationContribution(String label, String moduleName, String attributeName, String unit) {
+ this.label = label;
+ this.moduleName = moduleName;
+ this.attributeName = attributeName;
+ this.unit = unit;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public String getModuleName() {
+ return moduleName;
+ }
+
+ public String getAttributeName() {
+ return attributeName;
+ }
+
+ public String getUnit() {
+ return unit;
+ }
+
+ public boolean isUsed() {
+ return used;
+ }
+
+ public void setUsed(boolean used) {
+ this.used = used;
+ }
+
+ public boolean isUseDefault() {
+ return useDefault;
+ }
+
+ public void setUseDefault(boolean useDefault) {
+ this.useDefault = useDefault;
+ }
+
+}
\ No newline at end of file