1 package org.simantics.debug.graphical.model;
5 import java.awt.Graphics2D;
6 import java.awt.font.FontRenderContext;
7 import java.awt.geom.AffineTransform;
8 import java.awt.geom.Point2D;
9 import java.awt.geom.Rectangle2D;
12 public static final Font FONT = new Font("Arial", Font.PLAIN, 12);
13 public static final FontRenderContext FRC =
14 new FontRenderContext(new AffineTransform(), true, true);
15 public static final Rectangle2D MAX_BOUNDS = FONT.getMaxCharBounds(FRC);
16 public static final double FONT_HEIGHT = MAX_BOUNDS.getHeight();
18 public static double PADDING = 3.0;
30 public double forceX, forceY;
32 public Node(NodeData data) {
36 public void setContent(Content content) {
37 this.content = content;
38 this.radiusX = content.radiusX;
39 this.radiusY = content.radiusY;
42 public NodeData getData() {
46 public void setPos(double x, double y) {
51 public void render(Graphics2D g) {
52 Rectangle2D rect = new Rectangle2D.Double(x-radiusX, y-radiusY, 2*radiusX, 2*radiusY);
53 g.setColor(new Color(200, 200, 255));
55 g.setColor(Color.BLACK);
58 content.render(g, x, y);
63 public Point2D clipLineFromCenter(double targetX, double targetY) {
66 if(radiusX * Math.abs(targetY) < radiusY * Math.abs(targetX)) {
67 return new Point2D.Double(
68 x+Math.signum(targetX)*radiusX,
69 y+targetY * radiusX / Math.abs(targetX));
72 return new Point2D.Double(
73 x+targetX * radiusY / Math.abs(targetY),
74 y+Math.signum(targetY)*radiusY);
78 public boolean pick(double px, double py) {
79 return Math.abs(px - x) <= radiusX && Math.abs(py - y) <= radiusY;
82 public double getX() {
86 public double getY() {
90 public double getMinX() {
94 public double getMinY() {
98 public double getMaxX() {
102 public double getMaxY() {