1 package org.glassbox.graphview;
2
3 import java.awt.*;
4
5 import de.fzi.wim.guibase.graphview.graph.*;
6 import de.fzi.wim.guibase.graphview.view.*;
7
8 /***
9 The null node painter just gives a node a size.
10 */
11 public class NullNodePainter implements ZoomableNodePainter {
12 private Dimension _size;
13 private Rectangle _bounds;
14 private double _w, _h;
15
16 /***
17 Constructor.
18 @param size The size of the node.
19 */
20 public NullNodePainter(Dimension size) {
21 _size = size;
22 _bounds = new Rectangle();
23 _w = _size.width;
24 _h = _size.height;
25 }
26
27 public void setZoomFactor(double zf) {
28 _w = ((double)_size.width) * zf;
29 _h = ((double)_size.height) * zf;
30 }
31
32 public void paintNode(JGraphPane graphpane,Graphics2D g,Node node) {
33
34 }
35
36 public boolean isInNode(JGraphPane graphpane,Node node,Point point) {
37 getNodeScreenBounds(graphpane, node, _bounds);
38 return _bounds.contains(point);
39 }
40
41 public void getNodeScreenBounds(JGraphPane graphpane, Node node, Rectangle nodebounds) {
42 Point p = graphpane.getScreenPointForNode(node);
43 nodebounds.setBounds((int)(p.x - _w / 2d),
44 (int)(p.y - _h / 2d),
45 (int)_w,
46 (int)_h);
47 }
48
49 public String getToolTipText(JGraphPane graphpane,Node node,Point point) {
50 return null;
51 }
52 }