1
2
3
4
5
6
7
8
9
10
11 package edu.uci.ics.jung.visualization.transform.shape;
12
13 import java.awt.Component;
14 import java.awt.Graphics2D;
15 import java.awt.Shape;
16
17 import javax.swing.CellRendererPane;
18 import javax.swing.Icon;
19
20
21
22
23
24
25
26
27
28
29
30
31 public class GraphicsDecorator extends Graphics2DWrapper {
32
33 public GraphicsDecorator() {
34 this(null);
35 }
36 public GraphicsDecorator(Graphics2D delegate) {
37 super(delegate);
38 }
39
40 public void draw(Icon icon, Component c, Shape clip, int x, int y) {
41 int w = icon.getIconWidth();
42 int h = icon.getIconHeight();
43 icon.paintIcon(c, delegate, x-w/2, y-h/2);
44 }
45
46 public void draw(Component c, CellRendererPane rendererPane,
47 int x, int y, int w, int h, boolean shouldValidate) {
48 rendererPane.paintComponent(delegate, c, c.getParent(), x, y, w, h, shouldValidate);
49 }
50 }