1 package org.simantics.district.network.ui.nodes;
3 import java.awt.geom.Rectangle2D;
4 import java.util.Collection;
5 import java.util.Collections;
7 import org.simantics.db.RequestProcessor;
8 import org.simantics.db.Resource;
9 import org.simantics.db.exception.DatabaseException;
10 import org.simantics.maps.elevation.server.SingletonTiffTileInterface;
11 import org.simantics.scenegraph.g2d.IG2DNode;
12 import org.simantics.scenegraph.profile.EvaluationContext;
13 import org.simantics.scenegraph.profile.Group;
14 import org.simantics.scenegraph.profile.Style;
15 import org.simantics.scenegraph.profile.common.ObserverGroupListener;
16 import org.simantics.scenegraph.utils.NodeUtil;
18 public class ElevationRectangleStyle implements Style {
20 private ObserverGroupListener listener = null;
21 private double priority;
24 public void activate(RequestProcessor backend, Resource runtimeDiagram, Resource entry, Group group, EvaluationContext observer) throws DatabaseException {
25 if (listener != null && !listener.isDisposed())
27 listener = new ObserverGroupListener(this, group, observer);
28 group.trackItems(backend, runtimeDiagram, listener);
32 public void deactivate(Resource runtimeDiagram, Resource entry, Group group, EvaluationContext observer) {
33 if (listener != null && !listener.isDisposed()) {
34 setRectangles(observer, Collections.emptyList());
41 public void apply(Resource entry, Group group, EvaluationContext observer) {
42 apply2(entry, observer);
46 public void apply2(Object item, EvaluationContext observer) {
47 setRectangles(observer, SingletonTiffTileInterface.getBoundingBoxes());
50 private void setRectangles(EvaluationContext observer, Collection<Rectangle2D> rectangles) {
51 IG2DNode node = NodeUtil.getNearestChildByClass(observer.getSceneGraph(), ElevationServerNode.class);
53 ((ElevationServerNode) node).setRectangles(rectangles);
58 public void setPriority(double priority) {
59 this.priority = priority;
63 public double getPriority() {