]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.district.network.ui/src/org/simantics/district/network/ui/nodes/DistrictRenderingPreparationNode.java
First testing version of TechTypeTable
[simantics/district.git] / org.simantics.district.network.ui / src / org / simantics / district / network / ui / nodes / DistrictRenderingPreparationNode.java
1 package org.simantics.district.network.ui.nodes;
2
3 import java.awt.Graphics2D;
4 import java.awt.geom.AffineTransform;
5
6 import org.simantics.maps.MapScalingTransform;
7 import org.simantics.scenegraph.g2d.nodes.UnboundedNode;
8
9 public class DistrictRenderingPreparationNode extends UnboundedNode {
10
11     private static final long serialVersionUID = 6891204351705486193L;
12
13     @Override
14     public boolean validate() {
15         // This allows render() to be invoked always.
16         return true;
17     }
18
19     @Override
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);
28     }
29
30 }