1 package org.catacomb.graph.drawing;
2
3
4 import org.catacomb.graph.gui.Painter;
5 import org.catacomb.report.E;
6
7
8 public class IconWrapper extends FixedDrawingComponent {
9
10 VectorIcon icon;
11 double xRel;
12 double yRel;
13 double scale;
14
15 public IconWrapper(VectorIcon vi, double x, double y, double scl) {
16 icon = vi;
17 xRel = x;
18 yRel = y;
19 scale = scl;
20 if (icon == null) {
21 E.warning("wrapped null icon");
22 }
23 }
24
25
26 public boolean isWrapper() {
27 return true;
28 }
29
30 @Override
31 public void instruct(Painter p, double cx, double cy, double pscl) {
32 if (icon != null) {
33 icon.instruct(p, cx + pscl * xRel, cy + pscl * yRel, pscl * scale);
34 }
35 }
36
37
38 public VectorIcon getIcon() {
39 return icon;
40 }
41
42 public double getXRel() {
43 return xRel;
44 }
45
46 public double getYRel() {
47 return yRel;
48 }
49
50 public double getScale() {
51 return scale;
52 }
53
54 @Override
55 public void applyToShape(Shape shp) {
56
57
58 E.missing(" cant apply icon wrapper to shape");
59
60 double rx = 0.2;
61 double ry = 0.2;
62
63
64 double[] xpts = { xRel - rx, xRel - rx, xRel + rx, xRel + rx };
65 double[] ypts = { yRel - ry, yRel + ry, yRel + ry, yRel - ry };
66 shp.setXpts(xpts);
67 shp.setYpts(ypts);
68 }
69
70
71
72
73
74 }