1 package org.simantics.district.network.ui.nodes;
3 import java.awt.Graphics2D;
4 import java.awt.geom.AffineTransform;
6 import org.simantics.maps.MapScalingTransform;
7 import org.simantics.scenegraph.g2d.nodes.UnboundedNode;
9 public class DistrictRenderingPreparationNode extends UnboundedNode {
11 private static final long serialVersionUID = 6891204351705486193L;
14 public boolean validate() {
15 // This allows render() to be invoked always.
20 public void render(Graphics2D g2d) {
21 AffineTransform ot = g2d.getTransform();
22 double scale = DistrictNetworkNodeUtils.getScale(ot);
23 double scaleRecip = DistrictNetworkNodeUtils.calculateScaleRecip(ot);
24 int zoomLevel = MapScalingTransform.zoomLevel(ot);
25 g2d.setRenderingHint(DistrictRenderingHints.KEY_VIEW_SCALE_UNDER_SPATIAL_ROOT, scale);
26 g2d.setRenderingHint(DistrictRenderingHints.KEY_VIEW_SCALE_RECIPROCAL_UNDER_SPATIAL_ROOT, scaleRecip);
27 g2d.setRenderingHint(DistrictRenderingHints.KEY_VIEW_ZOOM_LEVEL, zoomLevel);