1 package org.catacomb.graph.drawing;
2
3 import org.catacomb.be.Position;
4 import org.catacomb.graph.gui.Painter;
5 import org.catacomb.interlish.structure.AddableTo;
6 import org.catacomb.report.E;
7
8
9 import java.awt.Color;
10 import java.util.ArrayList;
11
12
13 public class FixedDrawing implements AddableTo {
14
15 public ArrayList<FixedDrawingComponent> items;
16
17
18 public FixedDrawing() {
19 items = new ArrayList<FixedDrawingComponent>();
20 }
21
22
23 public void instruct(Painter p, double cx, double cy, double scale) {
24
25 for (FixedDrawingComponent fdCpt : items) {
26 fdCpt.instruct(p, cx, cy, scale);
27 }
28 }
29
30 public void randomInit() {
31 items.add(new Square(0., 0., 1., 1.));
32 }
33
34
35 public ArrayList<Shape> makeShapes() {
36 ArrayList<Shape> shapes = new ArrayList<Shape>();
37 for (FixedDrawingComponent cpt : items) {
38 if (cpt.isWrapper()) {
39
40
41
42
43 } else {
44 Shape shp = cpt.makeShape();
45 if (shp != null) {
46 shapes.add(shp);
47 }
48 }
49 }
50 return shapes;
51 }
52
53
54 public void addFromScaledShape(Shape sh, Position cpos, double scl) {
55 items.add(new GenericShape(sh, cpos, scl));
56 }
57
58
59
60 public ArrayList<Shape> makeOffsetShapes(double offx, double offy) {
61 ArrayList<Shape> shapes = makeShapes();
62 for (Shape shp : shapes) {
63 shp.shiftExpand(offx, offy, 1.0);
64
65 }
66 return shapes;
67 }
68
69
70
71 public void add(Object obj) {
72 if (obj instanceof FixedDrawingComponent) {
73
74 items.add((FixedDrawingComponent)obj);
75 } else {
76 E.error("wrong type in drawing " + obj);
77 }
78 }
79
80
81 public ArrayList<FixedDrawingComponent> getComponents() {
82 return items;
83 }
84
85
86 public void addStraightLine(double xa, double ya, double xb, double yb) {
87 StraightLine sl = new StraightLine(xa, ya, xb, yb);
88 items.add(sl);
89 }
90
91 public SegmentLine getBoundary() {
92
93 double[] xp = { -1., 1., 1., -1., -1. };
94 double[] yp = { 1., 1., -1., -1., 1. };
95
96 SegmentLine ret = new SegmentLine(xp, yp, Color.gray);
97 return ret;
98 }
99
100
101
102 }