From a995d5d46f03f25bd77fb3f6d8349839886b2ec2 Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Wed, 22 Apr 2020 12:34:40 +0300 Subject: [PATCH] Fixed most warnings from district codebase after JavaSE-11 switch gitlab simantics/platform#524 Change-Id: Iaacf66511566b43a2af2dff18317c639ff6ffe2a --- .../src/org/simantics/maps/WebService.java | 8 +- .../src/org/simantics/maps/sg/MapNode.java | 2 +- .../ChangeMappingTypeHandler.java | 2 - .../ChangeRoutePointToVertexHandler.java | 5 +- .../ChangeVertexToRoutePointHandler.java | 10 - .../network/ui/function/Functions.java | 2 +- .../nodes/DistrictNetworkEdgeArrayNode.java | 1 - .../nodes/DistrictNetworkStaticInfoNode.java | 5 +- .../DistrictNetworkStaticInfoStyle.java | 4 +- .../network/profile/ArrowLengthStyle.java | 137 -------------- .../network/profile/DNElementColorStyle.java | 136 -------------- .../network/profile/DNElementSizeStyle.java | 153 --------------- .../profile/DynamicVisualisationsRequest.java | 1 - .../district/network/profile/HideStyle.java | 47 ----- .../network/profile/ThrottledStyleBase.java | 176 ------------------ .../network/profile/VertexSymbolStyle.java | 98 ---------- .../model/DynamicSizeContribution.java | 3 - org.simantics.district.repository/pom.xml | 17 ++ .../route/ui/actions/ValidateRouteAction.java | 1 - .../maps/elevation/server/TiffInterface.java | 8 +- .../elevation/server/TiffTileInterface.java | 3 +- 21 files changed, 36 insertions(+), 783 deletions(-) delete mode 100644 org.simantics.district.network/src/org/simantics/district/network/profile/ArrowLengthStyle.java delete mode 100644 org.simantics.district.network/src/org/simantics/district/network/profile/DNElementColorStyle.java delete mode 100644 org.simantics.district.network/src/org/simantics/district/network/profile/DNElementSizeStyle.java delete mode 100644 org.simantics.district.network/src/org/simantics/district/network/profile/HideStyle.java delete mode 100644 org.simantics.district.network/src/org/simantics/district/network/profile/ThrottledStyleBase.java delete mode 100644 org.simantics.district.network/src/org/simantics/district/network/profile/VertexSymbolStyle.java diff --git a/org.simantics.district.maps/src/org/simantics/maps/WebService.java b/org.simantics.district.maps/src/org/simantics/maps/WebService.java index 3bfab58c..0e6ccf9c 100644 --- a/org.simantics.district.maps/src/org/simantics/maps/WebService.java +++ b/org.simantics.district.maps/src/org/simantics/maps/WebService.java @@ -12,6 +12,7 @@ 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; @@ -47,10 +48,9 @@ public class WebService { 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) { diff --git a/org.simantics.district.maps/src/org/simantics/maps/sg/MapNode.java b/org.simantics.district.maps/src/org/simantics/maps/sg/MapNode.java index fe83bd10..5bdd2555 100644 --- a/org.simantics.district.maps/src/org/simantics/maps/sg/MapNode.java +++ b/org.simantics.district.maps/src/org/simantics/maps/sg/MapNode.java @@ -197,7 +197,7 @@ public class MapNode extends G2DNode implements ITileListener { // 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) { diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/contributions/ChangeMappingTypeHandler.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/contributions/ChangeMappingTypeHandler.java index 3f32f445..3b33020f 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/contributions/ChangeMappingTypeHandler.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/contributions/ChangeMappingTypeHandler.java @@ -148,8 +148,6 @@ public class ChangeMappingTypeHandler { @Override public void perform(WriteGraph graph) throws DatabaseException { - DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - for (Map.Entry> entry : results.entrySet()) { List elements = entry.getValue().stream() .map(NamedResource::getResource) diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/contributions/ChangeRoutePointToVertexHandler.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/contributions/ChangeRoutePointToVertexHandler.java index f9e37c08..8d3037c5 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/contributions/ChangeRoutePointToVertexHandler.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/contributions/ChangeRoutePointToVertexHandler.java @@ -38,8 +38,6 @@ import org.simantics.district.network.ui.NetworkDrawingParticipant; 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; @@ -159,9 +157,12 @@ public class ChangeRoutePointToVertexHandler { 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 leftEdge = DNEdgeBuilder.create(graph, diagram, currentStartVertexCoords, Double.MAX_VALUE, midVertexCoords, Double.MAX_VALUE, detailedLeftEdgeGeometryCoords, 0.001); + @SuppressWarnings("unused") Optional rightEdge = DNEdgeBuilder.create(graph, diagram, midVertexCoords, Double.MAX_VALUE, currentEndVertexCoords, Double.MAX_VALUE, detailedRightEdgeGeometryCoords, 0.001); } } diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/contributions/ChangeVertexToRoutePointHandler.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/contributions/ChangeVertexToRoutePointHandler.java index cd713417..bf8571be 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/contributions/ChangeVertexToRoutePointHandler.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/contributions/ChangeVertexToRoutePointHandler.java @@ -6,8 +6,6 @@ import java.awt.geom.Point2D; 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; @@ -23,15 +21,12 @@ import org.simantics.databoard.Bindings; 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; @@ -39,10 +34,7 @@ import org.simantics.district.network.ui.NetworkDrawingParticipant; 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; @@ -94,8 +86,6 @@ public class ChangeVertexToRoutePointHandler { return; if (!(activeEditorPart instanceof DistrictDiagramEditor)) return; - DistrictDiagramEditor editor = (DistrictDiagramEditor) activeEditorPart; - Resource diagram = editor.getInputResource(); Simantics.getSession().asyncRequest(new WriteRequest() { diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/function/Functions.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/function/Functions.java index 2513c39d..eafb6f38 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/function/Functions.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/function/Functions.java @@ -175,7 +175,7 @@ public class Functions { @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(); } diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeArrayNode.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeArrayNode.java index a28abada..9d3adebe 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeArrayNode.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkEdgeArrayNode.java @@ -8,7 +8,6 @@ import java.awt.geom.Path2D; 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; diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkStaticInfoNode.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkStaticInfoNode.java index 523f7e80..a8544a9b 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkStaticInfoNode.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictNetworkStaticInfoNode.java @@ -9,7 +9,6 @@ import java.awt.geom.AffineTransform; 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; @@ -24,6 +23,8 @@ public class DistrictNetworkStaticInfoNode extends G2DNode implements DeferredNo 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(); @@ -35,7 +36,7 @@ public class DistrictNetworkStaticInfoNode extends G2DNode implements DeferredNo @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 diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/styles/DistrictNetworkStaticInfoStyle.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/styles/DistrictNetworkStaticInfoStyle.java index ca592acf..3dff9ad9 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/styles/DistrictNetworkStaticInfoStyle.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/styles/DistrictNetworkStaticInfoStyle.java @@ -50,8 +50,6 @@ public class DistrictNetworkStaticInfoStyle extends StyleBase 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); } diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/ArrowLengthStyle.java b/org.simantics.district.network/src/org/simantics/district/network/profile/ArrowLengthStyle.java deleted file mode 100644 index bcbb06eb..00000000 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/ArrowLengthStyle.java +++ /dev/null @@ -1,137 +0,0 @@ -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 { - - 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 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 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); - } -} diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/DNElementColorStyle.java b/org.simantics.district.network/src/org/simantics/district/network/profile/DNElementColorStyle.java deleted file mode 100644 index 1e50a92e..00000000 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/DNElementColorStyle.java +++ /dev/null @@ -1,136 +0,0 @@ -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 { - - 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 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); - } - -} diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/DNElementSizeStyle.java b/org.simantics.district.network/src/org/simantics/district/network/profile/DNElementSizeStyle.java deleted file mode 100644 index 870f7457..00000000 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/DNElementSizeStyle.java +++ /dev/null @@ -1,153 +0,0 @@ -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 { - - 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 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); - } - } - -} diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/DynamicVisualisationsRequest.java b/org.simantics.district.network/src/org/simantics/district/network/profile/DynamicVisualisationsRequest.java index 0387029f..f8aa0b0a 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/DynamicVisualisationsRequest.java +++ b/org.simantics.district.network/src/org/simantics/district/network/profile/DynamicVisualisationsRequest.java @@ -9,7 +9,6 @@ import org.simantics.db.Resource; 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; diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/HideStyle.java b/org.simantics.district.network/src/org/simantics/district/network/profile/HideStyle.java deleted file mode 100644 index fff5fde5..00000000 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/HideStyle.java +++ /dev/null @@ -1,47 +0,0 @@ -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 { - - @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"; - } - -} diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/ThrottledStyleBase.java b/org.simantics.district.network/src/org/simantics/district/network/profile/ThrottledStyleBase.java deleted file mode 100644 index 483f62ed..00000000 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/ThrottledStyleBase.java +++ /dev/null @@ -1,176 +0,0 @@ -/******************************************************************************* - * 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 extends StyleBase> { - - 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> resultListener; - - @Override - protected Read> 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> 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 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) { - 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 { - - 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 { - - 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 getEnclosingInstance() { - return ThrottledStyleBase.this; - } - } - -} diff --git a/org.simantics.district.network/src/org/simantics/district/network/profile/VertexSymbolStyle.java b/org.simantics.district.network/src/org/simantics/district/network/profile/VertexSymbolStyle.java deleted file mode 100644 index 913ba201..00000000 --- a/org.simantics.district.network/src/org/simantics/district/network/profile/VertexSymbolStyle.java +++ /dev/null @@ -1,98 +0,0 @@ -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 { - - 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.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 { - protected static final Function CONST_NULL = new FunctionImpl1() { - @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; - } - } - -} diff --git a/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicSizeContribution.java b/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicSizeContribution.java index 9adc4ddd..9dc67d1c 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicSizeContribution.java +++ b/org.simantics.district.network/src/org/simantics/district/network/visualisations/model/DynamicSizeContribution.java @@ -1,8 +1,5 @@ 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; diff --git a/org.simantics.district.repository/pom.xml b/org.simantics.district.repository/pom.xml index c43ce767..889477d6 100644 --- a/org.simantics.district.repository/pom.xml +++ b/org.simantics.district.repository/pom.xml @@ -62,6 +62,23 @@ + + + org.simantics + + graph-builder-maven-plugin + + + [0.0.9,) + + + compile-graphs + + + + + + diff --git a/org.simantics.district.route.ui/src/org/simantics/district/route/ui/actions/ValidateRouteAction.java b/org.simantics.district.route.ui/src/org/simantics/district/route/ui/actions/ValidateRouteAction.java index 5b0e7d05..5ef65b77 100644 --- a/org.simantics.district.route.ui/src/org/simantics/district/route/ui/actions/ValidateRouteAction.java +++ b/org.simantics.district.route.ui/src/org/simantics/district/route/ui/actions/ValidateRouteAction.java @@ -1,6 +1,5 @@ package org.simantics.district.route.ui.actions; -import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; diff --git a/org.simantics.maps.elevation.server/src/org/simantics/maps/elevation/server/TiffInterface.java b/org.simantics.maps.elevation.server/src/org/simantics/maps/elevation/server/TiffInterface.java index f5935318..c3a27a4f 100644 --- a/org.simantics.maps.elevation.server/src/org/simantics/maps/elevation/server/TiffInterface.java +++ b/org.simantics.maps.elevation.server/src/org/simantics/maps/elevation/server/TiffInterface.java @@ -67,21 +67,21 @@ public class TiffInterface implements Closeable { 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; } diff --git a/org.simantics.maps.elevation.server/src/org/simantics/maps/elevation/server/TiffTileInterface.java b/org.simantics.maps.elevation.server/src/org/simantics/maps/elevation/server/TiffTileInterface.java index 0cbf3fa5..6cc9cd7b 100644 --- a/org.simantics.maps.elevation.server/src/org/simantics/maps/elevation/server/TiffTileInterface.java +++ b/org.simantics.maps.elevation.server/src/org/simantics/maps/elevation/server/TiffTileInterface.java @@ -118,6 +118,7 @@ public class TiffTileInterface implements Closeable { 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 tifFiles = (List) index.query(new Envelope(new Coordinate(x, y))); for (Path tifFile : tifFiles) { TiffInterface tifInterface = openTifInterface(tifFile); @@ -131,7 +132,7 @@ public class TiffTileInterface implements Closeable { //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 -- 2.47.1