package org.simantics.maps;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.MalformedURLException;
IProxyUtil util = null;
try {
Class<?> proxyClass = (Class<?>) Class.forName("org.simantics.maps.eclipse.EclipseProxyUtil");
- util = (IProxyUtil)proxyClass.newInstance();
- } catch (ClassNotFoundException e1) {
- } catch (InstantiationException e) {
- } catch (IllegalAccessException e) {
+ util = (IProxyUtil)proxyClass.getDeclaredConstructor().newInstance();
+ } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException
+ | InvocationTargetException | NoSuchMethodException | SecurityException e) {
}
// AppletProxyUtil should exist always..
if(util == null) {
// Try to load eclipse specific implementation of TileJobQueue, if it doesn't exist, fall back to pojo implementation
try {
Class<?> proxyClass = (Class<?>) Class.forName("org.simantics.maps.eclipse.TileJobQueue");
- job = (ITileJobQueue)proxyClass.newInstance();
+ job = (ITileJobQueue)proxyClass.getDeclaredConstructor().newInstance();
} catch (ClassNotFoundException e1) {
} catch (InstantiationException e) {
} catch (IllegalAccessException e) {
@Override
public void perform(WriteGraph graph) throws DatabaseException {
- DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
-
for (Map.Entry<Resource, Collection<NamedResource>> entry : results.entrySet()) {
List<Resource> elements = entry.getValue().stream()
.map(NamedResource::getResource)
import org.simantics.g2d.canvas.ICanvasContext;
import org.simantics.g2d.participant.MouseUtil;
import org.simantics.g2d.participant.MouseUtil.MouseInfo;
-import org.simantics.maps.elevation.server.SingletonTiffTileInterface;
-import org.simantics.maps.elevation.server.prefs.MapsElevationServerPreferences;
import org.simantics.ui.workbench.e4.E4WorkbenchUtils;
import org.simantics.utils.threads.ThreadUtils;
import org.simantics.utils.ui.ISelectionUtils;
double y = finalClosestPoint.getY();
double[] midVertexCoords = new double[] { x, y };
+ @SuppressWarnings("unused")
Resource createdVertex = DistrictNetworkUtil.createVertex(graph, diagram, midVertexCoords, Double.MAX_VALUE, mapping);
+ @SuppressWarnings("unused")
Optional<Resource> leftEdge = DNEdgeBuilder.create(graph, diagram, currentStartVertexCoords, Double.MAX_VALUE, midVertexCoords, Double.MAX_VALUE, detailedLeftEdgeGeometryCoords, 0.001);
+ @SuppressWarnings("unused")
Optional<Resource> rightEdge = DNEdgeBuilder.create(graph, diagram, midVertexCoords, Double.MAX_VALUE, currentEndVertexCoords, Double.MAX_VALUE, detailedRightEdgeGeometryCoords, 0.001);
}
}
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.List;
-import java.util.Optional;
-import java.util.concurrent.TimeUnit;
import javax.inject.Named;
import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
import org.simantics.db.WriteGraph;
-import org.simantics.db.common.request.ReadRequest;
import org.simantics.db.common.request.WriteRequest;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.SelectionHints;
import org.simantics.db.layer0.util.RemoverUtil;
import org.simantics.db.request.Read;
import org.simantics.diagram.stubs.DiagramResource;
-import org.simantics.district.network.DNEdgeBuilder;
-import org.simantics.district.network.DistrictNetworkUtil;
import org.simantics.district.network.ModelledCRS;
import org.simantics.district.network.ontology.DistrictNetworkResource;
import org.simantics.district.network.ui.DistrictDiagramEditor;
import org.simantics.g2d.canvas.ICanvasContext;
import org.simantics.g2d.participant.MouseUtil;
import org.simantics.g2d.participant.MouseUtil.MouseInfo;
-import org.simantics.maps.elevation.server.SingletonTiffTileInterface;
-import org.simantics.maps.elevation.server.prefs.MapsElevationServerPreferences;
import org.simantics.ui.workbench.e4.E4WorkbenchUtils;
-import org.simantics.utils.threads.ThreadUtils;
import org.simantics.utils.ui.ISelectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
return;
if (!(activeEditorPart instanceof DistrictDiagramEditor))
return;
- DistrictDiagramEditor editor = (DistrictDiagramEditor) activeEditorPart;
- Resource diagram = editor.getInputResource();
Simantics.getSession().asyncRequest(new WriteRequest() {
@SCLValue(type = "ReadGraph -> Resource -> a -> b")
public static Object enumerationValues(ReadGraph graph, Resource resource, Object context) throws DatabaseException {
- Variable var = (Variable) context;
+ //Variable var = (Variable) context;
return Collections.emptyList();
}
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
-import org.simantics.district.network.ui.styles.DistrictNetworkStaticInfoStyle;
import org.simantics.scenegraph.ParentNode;
import org.simantics.scenegraph.g2d.G2DNode;
import org.simantics.scenegraph.g2d.nodes.spatial.RTreeNode;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
-import org.simantics.district.network.ui.styles.DistrictNetworkStaticInfoStyle;
import org.simantics.scenegraph.ParentNode;
import org.simantics.scenegraph.g2d.G2DNode;
import org.simantics.scenegraph.g2d.nodes.spatial.RTreeNode;
public static final String NODE_KEY = "DISTRICT_NETWORK_STATIC_INFO";
+ public static final String STATIC_INFO_DEFERRED = "staticInfo";
+
String info = null;
Point2D origin = new Point2D.Double();
Point2D direction = new Point2D.Double();
@Override
public void render(Graphics2D g) {
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(STATIC_INFO_DEFERRED) : null;
if (deferred != null)
deferred.deferNode(g.getTransform(), this);
else
private static final String ACTIONS_MODULE = "Actions";
private static final String PIPELINE_INFO = "pipelineInfo";
- public static final String STATIC_INFO_DEFERRED = "staticInfo";
-
public static class StyleResult {
public StyleResult(Resource r, Point2D p1, String info) {
this.r = r;
ParentNode<?> root = (ParentNode<?>) NodeUtil.getNearestParentOfType(parent, RTreeNode.class);
if (root != null) {
- DeferredRenderingNode deferred = ProfileVariables.claimChild(root, "", STATIC_INFO_DEFERRED, DeferredRenderingNode.class, evaluationContext);
+ DeferredRenderingNode deferred = ProfileVariables.claimChild(root, "", DistrictNetworkStaticInfoNode.STATIC_INFO_DEFERRED, DeferredRenderingNode.class, evaluationContext);
deferred.setZIndex(Integer.MAX_VALUE-1);
}
+++ /dev/null
-package org.simantics.district.network.profile;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.simantics.databoard.Bindings;
-import org.simantics.db.ReadGraph;
-import org.simantics.db.Resource;
-import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
-import org.simantics.db.common.procedure.adapter.TransientCacheListener;
-import org.simantics.db.exception.DatabaseException;
-import org.simantics.db.layer0.variable.Variable;
-import org.simantics.db.layer0.variable.Variables;
-import org.simantics.district.network.ontology.DistrictNetworkResource;
-import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicArrowObject;
-import org.simantics.district.network.visualisations.model.DynamicArrowContribution;
-import org.simantics.district.network.visualisations.model.DynamicVisualisation;
-import org.simantics.layer0.Layer0;
-import org.simantics.modeling.ModelingResources;
-import org.simantics.scenegraph.INode;
-import org.simantics.scenegraph.g2d.G2DSceneGraph;
-import org.simantics.scenegraph.g2d.nodes.ConnectionNode;
-import org.simantics.scenegraph.profile.EvaluationContext;
-import org.simantics.scenegraph.profile.common.ProfileVariables;
-import org.simantics.scl.runtime.SCLContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ArrowLengthStyle extends ThrottledStyleBase<Double> {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ArrowLengthStyle.class);
- private static final Double PENDING = Double.NaN;
-
- @Override
- public Double calculateThrottledStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException {
- Resource diagram = graph.getSingleObject(groupItem, Layer0.getInstance(graph).PartOf);
- Set<Resource> edgesToUse = graph.syncRequest(new MidBranchEdgeSetRequest(diagram), TransientCacheListener.instance());
- if (!edgesToUse.contains(groupItem))
- return null;
-
- DynamicVisualisation dv = graph.syncRequest(new RuntimeDynamicVisualisationsRequest(runtimeDiagram),
- TransientCacheAsyncListener.instance());
- // Prevent PendingVariableExceptions from coming through
- boolean wasSynchronous = graph.setSynchronous(true);
- try {
- if (dv != null) {
- Layer0 L0 = Layer0.getInstance(graph);
- DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
- ModelingResources MOD = ModelingResources.getInstance(graph);
- Resource mapping = graph.getSingleObject(groupItem, DN.HasMapping);
-
- Map<String, DynamicArrowContribution> arrowContributions = dv.getArrowContributions();
- String mappingName = graph.getRelatedValue(mapping, L0.HasName);
- DynamicArrowContribution dac = arrowContributions.get(mappingName);
- if (dac != null && dac.isUsed()) {
-
- Resource mappedComponent = graph.getPossibleObject(groupItem, DN.MappedComponent);
- if (mappedComponent != null) {
-
- Resource component = graph.getSingleObject(mappedComponent, MOD.ElementToComponent);
- Variable variable = Variables.getVariable(graph, component);
- Variable possibleActiveVariable = Variables.possibleActiveVariable(graph, variable);
- if (possibleActiveVariable != null) {
-
- Variable module = possibleActiveVariable.getPossibleChild(graph, dac.getModuleName());
- if (module != null) {
- Variable attribute = module.getPossibleProperty(graph, dac.getAttributeName());
- if (attribute != null) {
- Double possibleValue = attribute.getPossibleValue(graph, Bindings.DOUBLE);
- if (possibleValue != null) {
-
- double biasValue;
- double gainValue;
- if (dac.isUseDefault()) {
- DynamicArrowObject dynamicArrowObject = dv.getDefaultArrowContributions().get(mappingName);
-
- // This is required if ontology module needs to be compiled
- Object currentGraph = SCLContext.getCurrent().get("graph");
- try {
- SCLContext.getCurrent().put("graph", graph);
-
- DynamicArrowContribution ddcc = dynamicArrowObject.getArrowContributions().get(dac.getLabel());
- biasValue = ddcc.getDefaultBias();
- gainValue = ddcc.getDefaultGain();
- } finally {
- SCLContext.getCurrent().put("graph", currentGraph);
- }
- } else {
- biasValue = dac.getDefaultBias();
- gainValue = dac.getDefaultGain();
- }
- // here we do the adjusting according to spec in #15038
- return possibleValue.doubleValue() * gainValue + biasValue;
- } else {
- LOGGER.warn("No value for {}", attribute.getURI(graph));
- }
- } else {
- LOGGER.warn("Wrong attribute name {} for {} !!", dac.getAttributeName(), module.getURI(graph));
- }
- } else {
- LOGGER.warn("Wrong modulename {} for {} !!", dac.getModuleName(), possibleActiveVariable.getURI(graph));
- }
- } else {
- LOGGER.debug("No active experiment for {}", variable.getURI(graph));
- }
- } else {
- LOGGER.debug("No mapped component for {} to calculate dynamic color style", groupItem);
- }
- }
- }
- } finally {
- graph.setSynchronous(wasSynchronous);
- }
- return null;
- }
-
- @Override
- public void applyThrottledStyleForNode(EvaluationContext observer, INode node, Double value) {
-// System.out.println("apply: " + node + " : " + value);
- ConnectionNode n = (ConnectionNode) node;
- if (value == PENDING) {
- ((G2DSceneGraph)node.getRootNode()).setPending(node);
- } else {
- ((G2DSceneGraph)node.getRootNode()).clearPending(node);
- }
- for (INode nn : n.getNodes())
- ProfileVariables.claimNodeProperty(nn, "arrowLength", value, observer);
- }
-
- @Override
- protected void cleanupStyleForNode(EvaluationContext evaluationContext, INode node) {
- ((G2DSceneGraph)node.getRootNode()).clearPending(node);
- ConnectionNode n = (ConnectionNode) node;
- for (INode nn : n.getNodes())
- ProfileVariables.claimNodeProperty(nn, "arrowLength", null, evaluationContext);
- }
-}
+++ /dev/null
-package org.simantics.district.network.profile;
-
-import java.awt.Color;
-import java.util.Map;
-
-import org.simantics.databoard.Bindings;
-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.db.layer0.variable.Variable;
-import org.simantics.db.layer0.variable.Variables;
-import org.simantics.district.network.ontology.DistrictNetworkResource;
-import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicColoringObject;
-import org.simantics.district.network.visualisations.model.DynamicColorContribution;
-import org.simantics.district.network.visualisations.model.DynamicColorMap;
-import org.simantics.district.network.visualisations.model.DynamicVisualisation;
-import org.simantics.layer0.Layer0;
-import org.simantics.modeling.ModelingResources;
-import org.simantics.scenegraph.INode;
-import org.simantics.scenegraph.g2d.nodes.SingleElementNode;
-import org.simantics.scenegraph.profile.EvaluationContext;
-import org.simantics.scenegraph.profile.common.ProfileVariables;
-import org.simantics.scl.runtime.SCLContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author Tuukka Lehtonen
- * @since 1.35.0
- */
-public class DNElementColorStyle extends ThrottledStyleBase<Color> {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(DNElementColorStyle.class);
-
- private static final boolean DEBUG = false;
-
- @Override
- public Color calculateThrottledStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException {
-
- DynamicVisualisation dv = graph.syncRequest(new RuntimeDynamicVisualisationsRequest(runtimeDiagram),
- TransientCacheAsyncListener.instance());
-
- // Prevent PendingVariableExceptions from coming through
- boolean wasSynchronous = graph.setSynchronous(true);
- try {
- if (dv != null) {
- Layer0 L0 = Layer0.getInstance(graph);
- DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
- ModelingResources MOD = ModelingResources.getInstance(graph);
- Resource mapping = graph.getSingleObject(groupItem, DN.HasMapping);
-
- Map<String, DynamicColorContribution> colorContributions = dv.getColorContributions();
- String mappingName = graph.getRelatedValue(mapping, L0.HasName);
- DynamicColorContribution dcc = colorContributions.get(mappingName);
- if (dcc != null && dcc.isUsed()) {
-
- Resource mappedComponent = graph.getPossibleObject(groupItem, DN.MappedComponent);
- if (mappedComponent != null) {
-
- Resource component = graph.getSingleObject(mappedComponent, MOD.ElementToComponent);
- Variable variable = Variables.getVariable(graph, component);
- Variable possibleActiveVariable = Variables.possibleActiveVariable(graph, variable);
- if (possibleActiveVariable != null) {
-
- Variable module = possibleActiveVariable.getPossibleChild(graph, dcc.getModuleName());
- if (module != null) {
- Variable attribute = module.getPossibleProperty(graph, dcc.getAttributeName());
- if (attribute != null) {
- Double possibleValue = attribute.getPossibleValue(graph, Bindings.DOUBLE);
- if (possibleValue != null) {
-
- double minValue;
- double maxValue;
- if (dcc.isUseDefault()) {
- DynamicColoringObject dynamicColoringObject = dv.getDefaultColorContributions().get(mappingName);
-
- // This is required if ontology module needs to be compiled
- Object currentGraph = SCLContext.getCurrent().get("graph");
- try {
- SCLContext.getCurrent().put("graph", graph);
-
- DynamicColorContribution ddcc = dynamicColoringObject.getColorContributions().get(dcc.getLabel());
- minValue = ddcc.getDefaultMin();
- maxValue = ddcc.getDefaultMax();
- } finally {
- SCLContext.getCurrent().put("graph", currentGraph);
- }
- } else {
- minValue = dcc.getDefaultMin();
- maxValue = dcc.getDefaultMax();
- }
- // here we do the adjusting according to spec in #15038
- double adjustedValue = possibleValue.doubleValue() * dcc.getVariableGain() + dcc.getVariableBias();
- DynamicColorMap defaultColorMap = dcc.getDefaultColorMap();
- Color color = defaultColorMap.getColor(adjustedValue, dv.getColorBarOptions().isUseGradients(), minValue, maxValue);
- return color;
- } else {
- LOGGER.warn("No value for {}", attribute.getURI(graph));
- }
- } else {
- LOGGER.warn("Wrong attribute name {} for {} !!", dcc.getAttributeName(), module.getURI(graph));
- }
- } else {
- LOGGER.warn("Wrong modulename {} for {} !!", dcc.getModuleName(), possibleActiveVariable.getURI(graph));
- }
- } else {
- LOGGER.debug("No active experiment for {}", variable.getURI(graph));
- }
- } else {
- LOGGER.debug("No mapped component for {} to calculate dynamic color style", groupItem);
- }
- }
- }
- }
- finally {
- graph.setSynchronous(wasSynchronous);
- }
- return null;
- }
-
- @Override
- public void applyThrottledStyleForNode(EvaluationContext observer, INode node, Color color) {
- SingleElementNode n = (SingleElementNode) node;
- for (INode nn : n.getNodes())
- ProfileVariables.claimNodeProperty(nn, "dynamicColor", color, observer);
- }
-
- @Override
- protected void cleanupStyleForNode(EvaluationContext evaluationContext, INode node) {
- SingleElementNode n = (SingleElementNode) node;
- for (INode nn : n.getNodes())
- ProfileVariables.claimNodeProperty(nn, "dynamicColor", null, evaluationContext);
- }
-
-}
+++ /dev/null
-package org.simantics.district.network.profile;
-
-import java.util.Map;
-
-import org.simantics.databoard.Bindings;
-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.db.layer0.variable.Variable;
-import org.simantics.db.layer0.variable.Variables;
-import org.simantics.district.network.ontology.DistrictNetworkResource;
-import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicColoringObject;
-import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicSizingObject;
-import org.simantics.district.network.visualisations.model.DynamicColorContribution;
-import org.simantics.district.network.visualisations.model.DynamicSizeContribution;
-import org.simantics.district.network.visualisations.model.DynamicSizeMap;
-import org.simantics.district.network.visualisations.model.DynamicVisualisation;
-import org.simantics.layer0.Layer0;
-import org.simantics.modeling.ModelingResources;
-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;
-import org.simantics.scl.runtime.SCLContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author Jani Simomaa
- */
-public class DNElementSizeStyle extends ThrottledStyleBase<Double> {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(DNElementSizeStyle.class);
- private static final boolean DEBUG = false;
-
- private static final Double PENDING = Double.NaN;
- private static final Double ONE = 1.0;
-
- @Override
- public Double calculateThrottledStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException {
-
- DynamicVisualisation dv = graph.syncRequest(new RuntimeDynamicVisualisationsRequest(runtimeDiagram),
- TransientCacheAsyncListener.instance());
-
- // Prevent PendingVariableExceptions from coming through
- boolean wasSynchronous = graph.setSynchronous(true);
- try {
- if (dv != null) {
- Layer0 L0 = Layer0.getInstance(graph);
- DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
- ModelingResources MOD = ModelingResources.getInstance(graph);
- Resource mapping = graph.getSingleObject(groupItem, DN.HasMapping);
-
- Map<String, DynamicSizeContribution> sizeContributions = dv.getSizeContributions();
- String mappingName = graph.getRelatedValue(mapping, L0.HasName);
- DynamicSizeContribution dsc = sizeContributions.get(mappingName);
- if (dsc != null && dsc.isUsed()) {
-
- Resource mappedComponent = graph.getPossibleObject(groupItem, DN.MappedComponent);
- if (mappedComponent != null) {
-
- Resource component = graph.getSingleObject(mappedComponent, MOD.ElementToComponent);
- Variable variable = Variables.getVariable(graph, component);
- Variable possibleActiveVariable = Variables.possibleActiveVariable(graph, variable);
- if (possibleActiveVariable != null) {
-
- Variable module = possibleActiveVariable.getPossibleChild(graph, dsc.getModuleName());
- if (module != null) {
- Variable attribute = module.getPossibleProperty(graph, dsc.getAttributeName());
- if (attribute != null) {
- Double possibleValue = attribute.getPossibleValue(graph, Bindings.DOUBLE);
- if (possibleValue != null) {
-
-
- double minValue;
- double maxValue;
- if (dsc.isUseDefault()) {
- DynamicSizingObject dynamicSizingObject = dv.getDefaultSizeContributions().get(mappingName);
-
- // This is required if ontology module needs to be compiled
- Object currentGraph = SCLContext.getCurrent().get("graph");
- try {
- SCLContext.getCurrent().put("graph", graph);
-
- DynamicSizeContribution ddcc = dynamicSizingObject.getSizeContributions().get(dsc.getLabel());
- minValue = ddcc.getDefaultMin();
- maxValue = ddcc.getDefaultMax();
- } finally {
- SCLContext.getCurrent().put("graph", currentGraph);
- }
- } else {
- minValue = dsc.getDefaultMin();
- maxValue = dsc.getDefaultMax();
- }
- // here we do the adjusting according to spec in #15038
- double adjustedValue = possibleValue.doubleValue() * dsc.getVariableGain() + dsc.getVariableBias();
- DynamicSizeMap defaultSizeMap = dsc.getDefaultSizeMap();
- double size = defaultSizeMap.getSize(adjustedValue, dv.getSizeBarOptions().isUseGradients(), minValue, maxValue);
- return size;
- } else {
- LOGGER.warn("No value for {}", attribute.getURI(graph));
- }
- } else {
- LOGGER.warn("Wrong attribute name {} for {} !!", dsc.getAttributeName(), module.getURI(graph));
- }
- } else {
- LOGGER.warn("Wrong modulename {} for {} !!", dsc.getModuleName(), possibleActiveVariable.getURI(graph));
- }
- } else {
- LOGGER.debug("No active experiment for {}", variable.getURI(graph));
- }
- } else {
- LOGGER.debug("No mapped component for {} to calculate dynamic size style", groupItem);
- }
- }
- }
- }
- finally {
- graph.setSynchronous(wasSynchronous);
- }
- return 1.0;
- }
-
- @Override
- public void applyThrottledStyleForNode(EvaluationContext observer, INode node, Double value) {
- //System.out.println("apply: " + node + " : " + value);
- SingleElementNode n = (SingleElementNode) node;
- if (value == PENDING) {
- ((G2DSceneGraph)node.getRootNode()).setPending(node);
- } else {
- ((G2DSceneGraph)node.getRootNode()).clearPending(node);
- }
- if (value == null)
- value = ONE;
- for (INode nn : n.getNodes()) {
- ProfileVariables.claimNodeProperty(nn, "size", value, observer);
- ProfileVariables.claimNodeProperty(nn, "stroke", 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);
- ProfileVariables.claimNodeProperty(nn, "stroke", ONE, evaluationContext);
- }
- }
-
-}
import org.simantics.db.common.NamedResource;
import org.simantics.db.common.request.ResourceRead;
import org.simantics.db.exception.DatabaseException;
-import org.simantics.district.network.DistrictNetworkUtil;
import org.simantics.district.network.ontology.DistrictNetworkResource;
import org.simantics.district.network.visualisations.DynamicVisualisations;
import org.simantics.layer0.Layer0;
+++ /dev/null
-package org.simantics.district.network.profile;
-
-import org.simantics.db.ReadGraph;
-import org.simantics.db.Resource;
-import org.simantics.db.common.procedure.adapter.TransientCacheListener;
-import org.simantics.db.exception.DatabaseException;
-import org.simantics.diagram.profile.StyleBase;
-import org.simantics.district.network.visualisations.model.DynamicVisualisation;
-import org.simantics.scenegraph.INode;
-import org.simantics.scenegraph.g2d.nodes.SingleElementNode;
-import org.simantics.scenegraph.profile.EvaluationContext;
-import org.simantics.scenegraph.profile.common.ProfileVariables;
-
-/**
- * @author Tuukka Lehtonen
- */
-public class HideStyle extends StyleBase<Boolean> {
-
- @Override
- public Boolean calculateStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException {
-
- DynamicVisualisation dv = graph.syncRequest(new ActiveDynamicVisualisationsRequest(runtimeDiagram), TransientCacheListener.instance());
-
-
- return Boolean.TRUE;
- }
-
- @Override
- public void applyStyleForNode(EvaluationContext evaluationContext, INode node, Boolean result) {
- SingleElementNode n = (SingleElementNode) node;
- for (INode nn : n.getNodes())
- ProfileVariables.claimNodeProperty(nn, "hidden", true, evaluationContext);
- }
-
- @Override
- protected void cleanupStyleForNode(EvaluationContext evaluationContext, INode node) {
- SingleElementNode n = (SingleElementNode) node;
- for (INode nn : n.getNodes())
- ProfileVariables.claimNodeProperty(nn, "hidden", false, evaluationContext);
- }
-
- @Override
- public String toString() {
- return "Hide";
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2007, 2019 Association for Decentralized Information Management in
- * Industry THTH ry.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Semantum Oy - initial API and implementation
- *******************************************************************************/
-package org.simantics.district.network.profile;
-
-import java.util.Optional;
-import java.util.concurrent.atomic.AtomicLong;
-
-import org.simantics.db.ReadGraph;
-import org.simantics.db.Resource;
-import org.simantics.db.common.request.UnaryRead;
-import org.simantics.db.exception.DatabaseException;
-import org.simantics.db.procedure.Listener;
-import org.simantics.db.request.Read;
-import org.simantics.diagram.profile.StyleBase;
-import org.simantics.diagram.stubs.DiagramResource;
-import org.simantics.district.network.ontology.DistrictNetworkResource;
-import org.simantics.scenegraph.INode;
-import org.simantics.scenegraph.profile.EvaluationContext;
-import org.simantics.scenegraph.profile.Group;
-import org.simantics.scenegraph.profile.Observer;
-import org.simantics.scenegraph.profile.common.ObserverGroupListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class ThrottledStyleBase<Result> extends StyleBase<Optional<Result>> {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ThrottledStyleBase.class);
- private static final long DEFAULT_INTERVAL = 2000;
-
- //private long lastCalculateTimestamp = 0;
- private AtomicLong interval = new AtomicLong(DEFAULT_INTERVAL);
- private Listener<Optional<Result>> resultListener;
-
- @Override
- protected Read<Optional<Result>> getStyleCalculationRequest(Resource runtimeDiagram, Resource entry, Resource item) {
- //Simantics.getSession().asyncRequest(new ProfileUpdateIntervalRead(runtimeDiagram), new ProfileUpdateIntervalListener(runtimeDiagram, entry, item));
- return super.getStyleCalculationRequest(runtimeDiagram, entry, item);
- }
-
- @Override
- protected Listener<Optional<Result>> getStyleResultListener(ObserverGroupListener groupListener, Resource item,
- Group group, Observer observer, Resource runtimeDiagram) {
- resultListener = super.getStyleResultListener(groupListener, item, group, observer, runtimeDiagram);
- return resultListener;
- }
-
- @Override
- public final Optional<Result> calculateStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry,
- Resource groupItem) throws DatabaseException {
-// Needs fixing - this will result registration of listeners for nothing in the cache
-// long currentTimestamp = System.currentTimeMillis();
-// if (lastCalculateTimestamp > (currentTimestamp - interval.get())) {
-// LOGGER.debug("Throttling result calculation for {} {} {} {}", runtimeDiagram, entry, groupItem, interval.get());
-// return Optional.empty();
-// }
-// lastCalculateTimestamp = currentTimestamp;
- // let's calculate
- return Optional.ofNullable(calculateThrottledStyle(graph, runtimeDiagram, entry, groupItem));
- }
-
- public abstract Result calculateThrottledStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException;
-
- @Override
- public final void applyStyleForNode(EvaluationContext evaluationContext, INode node, Optional<Result> result) {
- if (!Optional.empty().equals(result) && result != null) {
- applyThrottledStyleForNode(evaluationContext, node, result.get());
- } else {
- LOGGER.debug("Do not apply as results are unchanged for {} {} {}", evaluationContext, node, result);
- // TODO: fix this duplicate method invocation with null
- applyThrottledStyleForNode(evaluationContext, node, null);
- }
- }
-
- public abstract void applyThrottledStyleForNode(EvaluationContext evaluationContext, INode node, Result result);
-
- private static class ProfileUpdateIntervalRead extends UnaryRead<Resource, Long> {
-
- public ProfileUpdateIntervalRead(Resource parameter) {
- super(parameter);
- }
-
- @Override
- public Long perform(ReadGraph graph) throws DatabaseException {
- Resource configuration = graph.getPossibleObject(parameter, DiagramResource.getInstance(graph).RuntimeDiagram_HasConfiguration);
- DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
- Long interval = DEFAULT_INTERVAL;
- if (configuration != null) {
- // TODO: take back to use when throttled profile is actually working
- // interval = graph.getPossibleRelatedValue(configuration, DN.Diagram_profileUpdateInterval, Bindings.LONG);
- }
- return interval != null ? interval : DEFAULT_INTERVAL;
- }
- }
-
- private class ProfileUpdateIntervalListener implements Listener<Long> {
-
- private Resource runtimeDiagram;
- private Resource entry;
- private Resource item;
-
- public ProfileUpdateIntervalListener(Resource runtimeDiagram, Resource entry, Resource item) {
- this.runtimeDiagram = runtimeDiagram;
- this.entry = entry;
- this.item = item;
- }
-
- @Override
- public void execute(Long result) {
- interval.set(result);
- }
-
- @Override
- public void exception(Throwable t) {
- LOGGER.error("Could not listen interval from runtime diagram {}", runtimeDiagram, t);
- }
-
- @Override
- public boolean isDisposed() {
- return resultListener.isDisposed();
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + getEnclosingInstance().hashCode();
- result = prime * result + ((entry == null) ? 0 : entry.hashCode());
- result = prime * result + ((item == null) ? 0 : item.hashCode());
- result = prime * result + ((runtimeDiagram == null) ? 0 : runtimeDiagram.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;
- ProfileUpdateIntervalListener other = (ProfileUpdateIntervalListener) obj;
- if (!getEnclosingInstance().equals(other.getEnclosingInstance()))
- return false;
- if (entry == null) {
- if (other.entry != null)
- return false;
- } else if (!entry.equals(other.entry))
- return false;
- if (item == null) {
- if (other.item != null)
- return false;
- } else if (!item.equals(other.item))
- return false;
- if (runtimeDiagram == null) {
- if (other.runtimeDiagram != null)
- return false;
- } else if (!runtimeDiagram.equals(other.runtimeDiagram))
- return false;
- return true;
- }
-
- private ThrottledStyleBase<Result> getEnclosingInstance() {
- return ThrottledStyleBase.this;
- }
- }
-
-}
+++ /dev/null
-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.TransientCacheListener;
-import org.simantics.db.common.request.ResourceRead;
-import org.simantics.db.exception.DatabaseException;
-import org.simantics.district.network.ontology.DistrictNetworkResource;
-import org.simantics.layer0.Layer0;
-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;
-import org.simantics.scl.runtime.function.Function;
-import org.simantics.scl.runtime.function.FunctionImpl1;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated
-public class VertexSymbolStyle extends ThrottledStyleBase<String> {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(VertexSymbolStyle.class);
-
- @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")
- 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());
- }
-
- @Override
- public void applyThrottledStyleForNode(EvaluationContext observer, INode node, String value) {
- SingleElementNode n = (SingleElementNode) node;
- for (INode nn : n.getNodes())
- ProfileVariables.claimNodeProperty(nn, "SVG", 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, "SVG", null, evaluationContext);
- }
-
- @SuppressWarnings("rawtypes")
- protected static final class SymbolFunctionRequest extends ResourceRead<Function> {
- protected static final Function CONST_NULL = new FunctionImpl1<Resource, String>() {
- @Override
- public String apply(Resource p0) {
- return null;
- }
- };
-
- public SymbolFunctionRequest(Resource entry) {
- super(entry);
- }
-
- @Override
- public Function perform(ReadGraph graph) throws DatabaseException {
- DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
-
- Function symbolFunction = (Function) graph.getPossibleRelatedValue2(resource, DN.HasSymbolFunction, resource);
- if (symbolFunction == null)
- symbolFunction = CONST_NULL;
-
- return symbolFunction;
- }
- }
-
-}
package org.simantics.district.network.visualisations.model;
-import org.simantics.district.network.visualisations.DynamicVisualisationsContributions.DynamicSizingObject;
-import org.simantics.scl.runtime.SCLContext;
-
public class DynamicSizeContribution {
private String label;
<ignore></ignore>
</action>
</pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.simantics</groupId>
+ <artifactId>
+ graph-builder-maven-plugin
+ </artifactId>
+ <versionRange>
+ [0.0.9,)
+ </versionRange>
+ <goals>
+ <goal>compile-graphs</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
package org.simantics.district.route.ui.actions;
-import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
case DataBuffer.TYPE_BYTE: {
// TODO: if the result is byte how does one subtract the pipeDepth form the value?
// Might not be even relevant with this use case
- return new Byte(((byte[]) r)[0]);
+ return Byte.valueOf(((byte[]) r)[0]);
}
case DataBuffer.TYPE_SHORT: // Fall through
case DataBuffer.TYPE_USHORT: // Fall through
case DataBuffer.TYPE_INT: {
int val = ((int[]) r)[0] - pipeDepthUnderGround;
- return new Integer(val);
+ return Integer.valueOf(val);
}
case DataBuffer.TYPE_FLOAT: {
float val = ((float[]) r)[0] - pipeDepthUnderGround;
- return new Float(val);
+ return Float.valueOf(val);
}
case DataBuffer.TYPE_DOUBLE: {
double val = ((double[]) r)[0] - pipeDepthUnderGround;
- return new Double(val);
+ return Double.valueOf(val);
}
default: return null;
}
public Number lookup(double x, double y) {
LOGGER.trace("Looking up x={} y={}", x, y);
DirectPosition p = new DirectPosition2D(c4326, x, y);
+ @SuppressWarnings("unchecked")
List<Path> tifFiles = (List<Path>) index.query(new Envelope(new Coordinate(x, y)));
for (Path tifFile : tifFiles) {
TiffInterface tifInterface = openTifInterface(tifFile);
//System.out.println("not found");
}
}
- return new Double(0); // use 0 by default for now
+ return Double.valueOf(0); // use 0 by default for now
}
@Override