1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.scenegraph.g2d.nodes;
14 import java.awt.BasicStroke;
15 import java.awt.Color;
16 import java.awt.Graphics2D;
17 import java.awt.geom.AffineTransform;
18 import java.awt.geom.GeneralPath;
19 import java.awt.geom.Point2D;
20 import java.awt.geom.Rectangle2D;
22 import org.simantics.scenegraph.g2d.G2DNode;
23 import org.simantics.scenegraph.utils.GeometryUtils;
25 public class SelectionPivotNode extends G2DNode {
29 private static final long serialVersionUID = 1382614767907193882L;
31 public transient static final BasicStroke SELECTION_STROKE = new BasicStroke(1.0f,
32 BasicStroke.CAP_SQUARE, BasicStroke.CAP_SQUARE, 10.0f);
34 protected Point2D pivot = null;
37 public void setPivot(Point2D pivot) {
42 public void render(Graphics2D g) {
43 AffineTransform ot = g.getTransform();
45 g.setColor(Color.RED);
46 g.translate(pivot.getX(), pivot.getY());
48 double scale = GeometryUtils.getScale(g.getTransform());
49 double scaleRecip = 1.0 / scale;
51 g.setStroke(GeometryUtils.scaleStroke(SELECTION_STROKE, (float) scaleRecip));
53 double padding = 5.0 * scaleRecip;
54 float d = (float) padding;
56 GeneralPath p = new GeneralPath();
68 public Rectangle2D getBoundsInLocal() {
69 return new Rectangle2D.Double(pivot.getX()-5, pivot.getY()-5, 10, 10);