import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
+import java.util.Optional;
import org.simantics.district.network.ui.adapters.DistrictNetworkVertex;
import org.simantics.maps.MapScalingTransform;
import org.simantics.scenegraph.ISelectionPainterNode;
import org.simantics.scenegraph.g2d.G2DNode;
import org.simantics.scenegraph.g2d.G2DParentNode;
+import org.simantics.scenegraph.g2d.G2DRenderingHints;
import org.simantics.scenegraph.g2d.IG2DNode;
import org.simantics.scenegraph.g2d.nodes.SVGNode;
import org.simantics.scenegraph.utils.GeometryUtils;
private DistrictNetworkVertex vertex;
- private boolean scaleStroke = true;
+ private static boolean scaleStroke = true;
private boolean hover;
private Color color;
public void render(Graphics2D g2d) {
AffineTransform ot = null;
AffineTransform t = getTransform();
+ double viewScaleRecip = scaleStroke ? (Double) g2d.getRenderingHint(DistrictRenderingHints.KEY_VIEW_SCALE_RECIPROCAL_UNDER_SPATIAL_ROOT) : 1.0;
if (t != null && !t.isIdentity()) {
- ot = g2d.getTransform();
+ //ot = g2d.getTransform();
+ ot = (AffineTransform) g2d.getRenderingHint(G2DRenderingHints.KEY_TRANSFORM_UNDER_SPATIAL_ROOT);
+ if (ot == null)
+ ot = g2d.getTransform();
g2d.transform(t);
+
+ if (scaleStroke) {
+ AffineTransform work = DistrictNetworkNodeUtils.sharedTransform.get();
+ work.setTransform(ot);
+ work.concatenate(t);
+ viewScaleRecip = DistrictNetworkNodeUtils.calculateScaleRecip(work);
+ }
}
// Translate lat and lon to X and Y
Point2D p = point = DistrictNetworkNodeUtils.calculatePoint2D(vertex.getPoint(), point);
-
- double viewScaleRecip = 1;
- if (scaleStroke) {
- viewScaleRecip *= DistrictNetworkNodeUtils.calculateScaleRecip(g2d.getTransform());
- }
-
+
if (!hidden && nodeSize > 0.0) {
Object oaaHint = null;
Object aaHint = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
updateBounds();
}
- @Override
- public AffineTransform getTransform() {
- return super.getTransform();
- }
-
private Rectangle2D calculateBounds(Rectangle2D rect) {
Point2D calcPoint = DistrictNetworkNodeUtils.calculatePoint2D(vertex.getPoint(), point);
AffineTransform at = NodeUtil.getLocalToGlobalTransform(this);
updateBounds();
}
+ public DistrictNetworkVertex getVertex() {
+ return vertex;
+ }
+
@Override
public boolean hover(boolean hover, boolean isConnectionTool) {
// Only react to hover when the connection tool is active
public void setHidden(Boolean value) {
this.hidden = value;
}
+
+ public void setStaticInformation(Optional<String> staticInformation) {
+ DistrictNetworkStaticInfoNode child = getOrCreateNode(DistrictNetworkStaticInfoNode.NODE_KEY, DistrictNetworkStaticInfoNode.class);
+ Point2D calculatePoint2D = DistrictNetworkNodeUtils.calculatePoint2D(vertex.getPoint(), null);
+ child.setLocation(calculatePoint2D, new Point2D.Double(1.0, 0.0));
+ if (staticInformation.isPresent()) {
+ child.setInfo(staticInformation.get());
+ } else {
+ child.setInfo(null);
+ }
+ }
+
+ public void setInSimulation(Optional<Boolean> isInSimulation) {
+ if (!isInSimulation.isPresent()) {
+ removeNode(NotInSimulationNode.NODE_NAME);
+ } else {
+ NotInSimulationNode child = getOrCreateNode(NotInSimulationNode.NODE_NAME, NotInSimulationNode.class);
+ child.setZIndex(1000);
+ child.setIsInSimulation(isInSimulation.get());
+ }
+ }
}