1 package org.catacomb.druid.gui.base;
2
3
4 import org.catacomb.druid.swing.DBorderLayout;
5 import org.catacomb.interlish.interact.Workbench;
6 import org.catacomb.interlish.structure.AssemblyEditor;
7 import org.catacomb.interlish.structure.ModeController;
8 import org.catacomb.report.E;
9
10
11 import java.awt.Color;
12
13
14
15 public class DruAssemblyPanel extends DruBorderPanel implements AssemblyEditor {
16 static final long serialVersionUID = 1001;
17
18 Workbench workbench;
19
20 int prefw;
21 int prefh;
22
23 Color bgc;
24 Color canvasColor;
25 Color shelfColor;
26 ModeController modeController;
27
28
29 public DruAssemblyPanel(int w, int h, String bsName) {
30 super();
31 prefw = w;
32 prefh = h;
33 }
34
35
36 public void setWorkbench(Workbench wkb) {
37 workbench = wkb;
38 workbench.setPreferredSize(prefw, prefh);
39 addDComponent(workbench, DBorderLayout.CENTER);
40 applyToWorkbench();
41 }
42
43
44 private void applyToWorkbench() {
45 if (bgc != null) {
46 workbench.setBg(bgc);
47 workbench.setSunkenBorder(bgc);
48 }
49 if (modeController != null) {
50 workbench.setModeController(modeController);
51 }
52 if (canvasColor != null) {
53 workbench.setCanvasColor(canvasColor);
54 }
55 if (shelfColor != null) {
56 workbench.setShelfColor(shelfColor);
57 }
58 if (infoReceiver != null) {
59 workbench.setInfoReceiver(infoReceiver);
60 }
61 }
62
63
64
65 public void setBg(Color c) {
66 super.setBg(c);
67 bgc = c;
68 if (workbench != null) {
69 workbench.setBg(c);
70 workbench.setSunkenBorder(c);
71 }
72 }
73
74 public void postApply() {
75 if (workbench != null) {
76 applyToWorkbench();
77 }
78 }
79
80
81 public void setModeController(ModeController mc) {
82 modeController = mc;
83 if (workbench != null) {
84 workbench.setModeController(mc);
85 }
86 }
87
88
89
90
91 public void setAssembly(Object ass) {
92 if (workbench != null) {
93 workbench.setAssembly(ass);
94 } else {
95 E.error("must have workbench before setting assembly");
96 }
97 }
98
99 public Workbench getWorkbench() {
100 return workbench;
101 }
102
103
104 public void setCanvasColor(Color color) {
105 canvasColor = color;
106 if (workbench != null) {
107 workbench.setCanvasColor(color);
108 }
109 }
110
111 public void setShelfColor(Color color) {
112 shelfColor = color;
113 if (workbench != null) {
114 workbench.setShelfColor(color);
115 }
116 }
117
118 }