package org.simantics.district.network.ui.nodes; import java.awt.BasicStroke; import java.awt.Color; import java.awt.geom.Rectangle2D; import org.simantics.scenegraph.ParentNode; import org.simantics.scenegraph.g2d.G2DNode; import org.simantics.scenegraph.utils.GeometryUtils; public class NotInSimulationNode extends G2DNode { private static final BasicStroke STROKE = new BasicStroke(1.5f); public static final String NODE_NAME = "notInSimulation"; private static final long serialVersionUID = 1503248449618244809L; private boolean isInSimulation; @Override public Rectangle2D getBoundsInLocal() { return null; } @Override public Rectangle2D getBoundsInLocal(boolean b) { return null; } @Override public Rectangle2D getBounds() { return null; } public void render(java.awt.Graphics2D g) { if (!isInSimulation) { ParentNode parent = getParent(); if (!(parent instanceof DistrictNetworkVertexNode)) return; Rectangle2D bounds = ((DistrictNetworkVertexNode)parent).getBoundsInLocal(); Rectangle2D expandedBounds = GeometryUtils.expandRectangle( bounds, bounds.getWidth() / 2 ); g.setColor(Color.RED); g.setStroke(GeometryUtils.scaleStroke(STROKE, 1.f / (float)g.getTransform().getScaleX())); g.draw(expandedBounds); } } public void setIsInSimulation(boolean isInSimulation) { this.isInSimulation = isInSimulation; } }