DN.VisualisationsFolder <T L0.Entity
DN.Diagram.Visualisations <T L0.Entity
+ >-- DN.Diagram.Visualisations.Interval
+ @defProperty "Interval" L0.Long
+ >-- DN.Diagram.Visualisations.Disabled
+ @defProperty "Disabled" L0.Boolean
>-- DN.Diagram.Visualisations.ShowColorBars
@defProperty "Show Color Bars" L0.Boolean
>-- DN.Diagram.Visualisations.ShowColorBarTicks
public final Resource Diagram_Visualisations_ColorBarSize;
public final Resource Diagram_Visualisations_ColorBarSize_Inverse;
public final Resource Diagram_Visualisations_ColorContribution;
+ public final Resource Diagram_Visualisations_Disabled;
+ public final Resource Diagram_Visualisations_Disabled_Inverse;
public final Resource Diagram_Visualisations_DynamicSymbolsProducers;
public final Resource Diagram_Visualisations_DynamicSymbolsProducers_Inverse;
public final Resource Diagram_Visualisations_DynamicSymbolsPumpingStations;
public final Resource Diagram_Visualisations_HidePumpingStations_Inverse;
public final Resource Diagram_Visualisations_HideValves;
public final Resource Diagram_Visualisations_HideValves_Inverse;
+ public final Resource Diagram_Visualisations_Interval;
+ public final Resource Diagram_Visualisations_Interval_Inverse;
public final Resource Diagram_Visualisations_ShowColorBarTicks;
public final Resource Diagram_Visualisations_ShowColorBarTicks_Inverse;
public final Resource Diagram_Visualisations_ShowColorBars;
public static final String Diagram_Visualisations_ColorBarSize = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/ColorBarSize";
public static final String Diagram_Visualisations_ColorBarSize_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/ColorBarSize/Inverse";
public static final String Diagram_Visualisations_ColorContribution = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/ColorContribution";
+ public static final String Diagram_Visualisations_Disabled = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/Disabled";
+ public static final String Diagram_Visualisations_Disabled_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/Disabled/Inverse";
public static final String Diagram_Visualisations_DynamicSymbolsProducers = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/DynamicSymbolsProducers";
public static final String Diagram_Visualisations_DynamicSymbolsProducers_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/DynamicSymbolsProducers/Inverse";
public static final String Diagram_Visualisations_DynamicSymbolsPumpingStations = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/DynamicSymbolsPumpingStations";
public static final String Diagram_Visualisations_HidePumpingStations_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/HidePumpingStations/Inverse";
public static final String Diagram_Visualisations_HideValves = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/HideValves";
public static final String Diagram_Visualisations_HideValves_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/HideValves/Inverse";
+ public static final String Diagram_Visualisations_Interval = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/Interval";
+ public static final String Diagram_Visualisations_Interval_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/Interval/Inverse";
public static final String Diagram_Visualisations_ShowColorBarTicks = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/ShowColorBarTicks";
public static final String Diagram_Visualisations_ShowColorBarTicks_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/ShowColorBarTicks/Inverse";
public static final String Diagram_Visualisations_ShowColorBars = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/Visualisations/ShowColorBars";
Diagram_Visualisations_ColorBarSize = getResourceOrNull(graph, URIs.Diagram_Visualisations_ColorBarSize);
Diagram_Visualisations_ColorBarSize_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_ColorBarSize_Inverse);
Diagram_Visualisations_ColorContribution = getResourceOrNull(graph, URIs.Diagram_Visualisations_ColorContribution);
+ Diagram_Visualisations_Disabled = getResourceOrNull(graph, URIs.Diagram_Visualisations_Disabled);
+ Diagram_Visualisations_Disabled_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_Disabled_Inverse);
Diagram_Visualisations_DynamicSymbolsProducers = getResourceOrNull(graph, URIs.Diagram_Visualisations_DynamicSymbolsProducers);
Diagram_Visualisations_DynamicSymbolsProducers_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_DynamicSymbolsProducers_Inverse);
Diagram_Visualisations_DynamicSymbolsPumpingStations = getResourceOrNull(graph, URIs.Diagram_Visualisations_DynamicSymbolsPumpingStations);
Diagram_Visualisations_HidePumpingStations_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_HidePumpingStations_Inverse);
Diagram_Visualisations_HideValves = getResourceOrNull(graph, URIs.Diagram_Visualisations_HideValves);
Diagram_Visualisations_HideValves_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_HideValves_Inverse);
+ Diagram_Visualisations_Interval = getResourceOrNull(graph, URIs.Diagram_Visualisations_Interval);
+ Diagram_Visualisations_Interval_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_Interval_Inverse);
Diagram_Visualisations_ShowColorBarTicks = getResourceOrNull(graph, URIs.Diagram_Visualisations_ShowColorBarTicks);
Diagram_Visualisations_ShowColorBarTicks_Inverse = getResourceOrNull(graph, URIs.Diagram_Visualisations_ShowColorBarTicks_Inverse);
Diagram_Visualisations_ShowColorBars = getResourceOrNull(graph, URIs.Diagram_Visualisations_ShowColorBars);
import org.simantics.diagram.ui.DiagramModelHints;
import org.simantics.district.network.DistrictNetworkUtil;
import org.simantics.district.network.ontology.DistrictNetworkResource;
+import org.simantics.district.network.ui.internal.Activator;
import org.simantics.district.network.ui.nodes.DistrictRenderingPreparationNode;
import org.simantics.district.network.ui.participants.DNPointerInteractor;
import org.simantics.district.network.ui.participants.DynamicVisualisationContributionsParticipant;
setupColorBarOptions();
setupSizingObjects();
setupSizeBarOptions();
+
+ // add listeners
+ DistrictDiagramViewerListener[] listeners = Activator.getInstance().getDistrictDiagramViewerListeners();
+ if (listeners != null) {
+ for (DistrictDiagramViewerListener listener : listeners) {
+ listener.diagramLoaded(getRuntime(), canvasContext);
+ }
+ }
+ }
+
+ @Override
+ public void dispose() {
+ DistrictDiagramViewerListener[] listeners = Activator.getInstance().getDistrictDiagramViewerListeners();
+ if (listeners != null) {
+ for (DistrictDiagramViewerListener listener : listeners) {
+ listener.diagramDisposed(getRuntime(), canvasContext);
+ }
+ }
+ super.dispose();
}
private void setupDrawMapEnabled() {
--- /dev/null
+package org.simantics.district.network.ui;
+
+import org.simantics.db.Resource;
+import org.simantics.g2d.canvas.ICanvasContext;
+
+public interface DistrictDiagramViewerListener {
+
+ void diagramLoaded(Resource runtimeDiagram, ICanvasContext canvasContext);
+
+ void diagramDisposed(Resource runtimeDiagram, ICanvasContext canvasContext);
+}
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.variable.Variable;
import org.simantics.district.network.ontology.DistrictNetworkResource;
+import org.simantics.district.network.ui.DistrictDiagramViewerListener;
import org.simantics.district.network.ui.DistrictNetworkUIUtil;
import org.simantics.district.network.ui.breakdown.SubgraphProvider;
import org.simantics.district.route.RouteService;
private ServiceTracker<SubgraphProvider, SubgraphProvider> subgraphProviderTracker;
private ServiceTracker<RouteService, RouteService> routeServiceTracker;
+ private ServiceTracker<DistrictDiagramViewerListener, DistrictDiagramViewerListener> districtDiagramViewerListenerTracker;
private HighlightSelectionEventHandler eventHandler;
subgraphProviderTracker.open();
routeServiceTracker = new ServiceTracker<>(context, RouteService.class.getName(), null);
routeServiceTracker.open();
+ districtDiagramViewerListenerTracker = new ServiceTracker<>(context, DistrictDiagramViewerListener.class.getName(), null);
+ districtDiagramViewerListenerTracker.open();
initializeEventListener();
}
public RouteService getRouteService() {
return routeServiceTracker.getService();
}
+
+ public DistrictDiagramViewerListener[] getDistrictDiagramViewerListeners() {
+ return districtDiagramViewerListenerTracker.getServices(new DistrictDiagramViewerListener[0]);
+ }
private void initializeEventListener() {
@SuppressWarnings("restriction")
private Button dynamicSymbolsValvesButton;
private Button dynamicSymbolsPumpingStationsButton;
+ private Text intervalText;
+
public DynamicVisualisationsUI(Composite parent) {
this.parent = parent;
ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
}
});
+ Composite intervalElementsComposite = new Composite(parent, SWT.NONE);
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(intervalElementsComposite);
+ GridLayoutFactory.fillDefaults().numColumns(1).applyTo(intervalElementsComposite);
+ initializeIntervalElements(intervalElementsComposite);
+
Composite hideElementsComposite = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, false).applyTo(hideElementsComposite);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(hideElementsComposite);
removeVisualisationTemplate(visualisation.getName(), Optional.of(visualisation.getVisualisationResource()));
}
});
+ }
+
+ private void initializeIntervalElements(Composite parent) {
+ Group group = new Group(parent, SWT.NONE);
+ group.setText("Interval");
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(group);
+ GridLayoutFactory.fillDefaults().numColumns(4).margins(5, 5).applyTo(group);
- disableUpdatesButton = new Button(buttonBarsComposite, SWT.CHECK);
+ createIntervalElements(group);
+ }
+
+ private void createIntervalElements(Composite parent) {
+
+ Label label = new Label(parent, SWT.NONE);
+ label.setText("Generic");
+ intervalText = new Text(parent, SWT.BORDER);
+ addSelectionListener(intervalText);
+
+ disableUpdatesButton = new Button(parent, SWT.CHECK);
disableUpdatesButton.setText("Disable updates");
- disableUpdatesButton.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- disableUpdates();
- }
- });
+ addSelectionListener(disableUpdatesButton);
+
}
private void initializeHideElements(Composite parent) {
};
}
- protected void disableUpdates() {
-
- }
-
protected void removeVisualisationTemplate(String name, Optional<Resource> of) {
if (of.isPresent()) {
Resource visualisation = of.get();
boolean dynamicSymbolsValves = dynamicSymbolsValvesButton.getSelection();
boolean dynamicSymbolsPumpingStations = dynamicSymbolsPumpingStationsButton.getSelection();
+ boolean disabled = disableUpdatesButton.getSelection();
+ Long interval;
+ try {
+ interval = Long.parseLong(intervalText.getText());
+ } catch (NumberFormatException e) {
+ // ignore
+ interval = 2000L;
+ }
+ long ii = interval;
+
Simantics.getSession().asyncRequest(new WriteRequest() {
@Override
} else {
exist = DynamicVisualisations.createVisualisation(graph, parentResource, templateName);
}
+ DynamicVisualisations.setIntervalAndDisabled(graph, exist, ii, disabled);
DynamicVisualisations.setColorContributions(graph, exist, colorCollect);
DynamicVisualisations.setColorBarOptions(graph, exist, colorBarOptions);
DynamicVisualisations.setSizeContributions(graph, exist, sizeCollect);
}
}
+ intervalText.setText(Long.toString(visualisation.getInterval()));
+ disableUpdatesButton.setSelection(visualisation.disabled());
+
Map<String, DynamicColorContribution> colorContributions = visualisation.getColorContributions();
for (Entry<String, DynamicColorContribution> entry : colorContributions.entrySet()) {
if (visualisationResource != null) {
String name = graph.getRelatedValue(visualisationResource, Layer0.getInstance(graph).HasName);
+ Long interval = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_Interval, Bindings.LONG);
+ Boolean disabled = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_Disabled, Bindings.BOOLEAN);
+
Collection<DynamicColoringObject> dynamicColoringObjects = DynamicVisualisationsContributions.dynamicColoringObjects(graph);
Map<String, DynamicColoringObject> defaultColoringObjects = dynamicColoringObjects.stream().collect(Collectors.toMap(dcc -> dcc.getColoringObject().getName(), dcc -> dcc));
Boolean dynamicSymbolsPumpingStations = graph.getPossibleRelatedValue(visualisationResource, DN.Diagram_Visualisations_DynamicSymbolsPumpingStations, Bindings.BOOLEAN);
DynamicVisualisation visualisation = new DynamicVisualisation(name, visualisationResource,
+ interval != null ? interval : 2000,
+ disabled != null ? disabled : false,
colorContributions,
defaultColoringObjects,
colorBarOptions,
graph.claimLiteral(visualisation, DN.Diagram_Visualisations_DynamicSymbolsValves, valves, Bindings.BOOLEAN);
graph.claimLiteral(visualisation, DN.Diagram_Visualisations_DynamicSymbolsPumpingStations, pumpingStations, Bindings.BOOLEAN);
}
+
+ public static void setIntervalAndDisabled(WriteGraph graph, Resource visualisation, long interval, boolean disabled) throws DatabaseException {
+ DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+ graph.claimLiteral(visualisation, DN.Diagram_Visualisations_Interval, interval, Bindings.LONG);
+ graph.claimLiteral(visualisation, DN.Diagram_Visualisations_Disabled, disabled, Bindings.BOOLEAN);
+ }
}
private final String name;
private final Resource visualisationResource;
+
+ private final long interval;
+ private final boolean disabled;
private final Map<String, DynamicColorContribution> colorContributions;
private final Map<String, DynamicColoringObject> defaultColorContributions;
private final boolean dynamicSymbolsValves;
private final boolean dynamicSymbolsPumpingStations;
- public DynamicVisualisation(String name, Resource visualisationResource,
+ public DynamicVisualisation(String name, Resource visualisationResource, long interval, boolean disabled,
Map<String, DynamicColorContribution> colorContributions,
Map<String, DynamicColoringObject> defaultColoringObjects, ColorBarOptions colorBarOptions,
Map<String, DynamicSizeContribution> sizeContributions,
) {
this.name = name;
this.visualisationResource = visualisationResource;
+ this.interval = interval;
+ this.disabled = disabled;
this.colorContributions = colorContributions;
this.defaultColorContributions = defaultColoringObjects;
this.colorBarOptions = colorBarOptions;
public boolean isDynamicSymbolsValves() {
return dynamicSymbolsValves;
}
+
+ public long getInterval() {
+ return interval;
+ }
+
+ public boolean disabled() {
+ return disabled;
+ }
}