import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
+import java.util.Collection;
+import java.util.List;
import java.util.Set;
+import java.util.stream.Collectors;
import org.simantics.g2d.canvas.ICanvasContext;
import org.simantics.g2d.canvas.impl.DependencyReflection.Dependency;
import org.simantics.g2d.canvas.impl.DependencyReflection.Reference;
import org.simantics.g2d.diagram.DiagramHints;
-import org.simantics.g2d.diagram.DiagramUtils;
import org.simantics.g2d.diagram.IDiagram;
import org.simantics.g2d.diagram.participant.Selection;
import org.simantics.g2d.element.ElementUtils;
if (d == null)
return false;
- Rectangle2D diagramRect = DiagramUtils.getContentRect(d);
+ Rectangle2D diagramRect = ElementUtils.getSurroundingElementBoundsOnDiagram(getMapElements(d.getElements()));
if (diagramRect == null)
return false;
if (diagramRect.isEmpty())
return true;
}
+ protected static List<IElement> getMapElements(Collection<IElement> elements) {
+ List<IElement> justMapElements = elements.stream()
+ .filter(e -> "DistrictNetworkEdgeElement".equals(e.getElementClass().getId())
+ || "DistrictNetworkVertexElement".equals(e.getElementClass().getId()))
+ .collect(Collectors.toList());
+ return justMapElements;
+ }
+
private boolean zoomToPage() {
int currentZoomLevel = MapScalingTransform.zoomLevel(util.getTransform());
// no can do,
return zoomToPage();
}
- Rectangle2D diagramRect = ElementUtils.getSurroundingElementBoundsOnDiagram(selections);
+ Rectangle2D diagramRect = ElementUtils.getSurroundingElementBoundsOnDiagram(getMapElements(selections));
// Make sure that even empty bounds can be zoomed into.
org.simantics.scenegraph.utils.GeometryUtils.expandRectangle(diagramRect, 1);