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