1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.xulux.guilayer.swing.layouts;
17
18 import java.awt.Component;
19 import java.awt.Container;
20 import java.awt.Dimension;
21 import java.awt.LayoutManager2;
22
23 import javax.swing.BoxLayout;
24
25 import org.xulux.api.gui.IWidget;
26
27
28
29
30
31
32
33 public class SwingBoxLayout extends SwingLayoutAbstract implements LayoutManager2 {
34
35
36 protected BoxLayout layout;
37
38
39 public SwingBoxLayout() {
40 }
41
42
43
44
45
46 public void addWidget(IWidget widget) {
47 if (layout == null) {
48 int axis = BoxLayout.X_AXIS;
49 String orientation = getParent().getProperty("layout-orientation");
50 if (orientation != null && orientation.equalsIgnoreCase("y")) {
51 axis = BoxLayout.Y_AXIS;
52 }
53 layout = new BoxLayout((Container) getParent().getNativeWidget(), axis);
54 }
55 }
56
57
58
59
60 public void removeWidget(IWidget widget) {
61
62 }
63
64
65
66
67 public void destroy() {
68
69 }
70
71
72
73 public void addLayoutComponent(Component comp, Object constraints) {
74 addWidget((IWidget) constraints);
75
76
77
78 if (comp != null) {
79 layout.addLayoutComponent(comp, constraints);
80 }
81 }
82
83
84
85 public Dimension maximumLayoutSize(Container target) {
86 return layout.maximumLayoutSize(target);
87 }
88
89
90
91 public float getLayoutAlignmentX(Container target) {
92 return layout.getLayoutAlignmentX(target);
93 }
94
95
96
97 public float getLayoutAlignmentY(Container target) {
98 return layout.getLayoutAlignmentY(target);
99 }
100
101
102
103 public void invalidateLayout(Container target) {
104 if (layout != null) {
105 layout.invalidateLayout(target);
106 }
107 }
108
109
110
111 public void addLayoutComponent(String name, Component comp) {
112 System.out.println("layoutComponent called : " + name);
113 }
114
115
116
117 public void removeLayoutComponent(Component comp) {
118
119
120
121 if (comp != null) {
122 layout.removeLayoutComponent(comp);
123 }
124 }
125
126
127
128 public Dimension preferredLayoutSize(Container parent) {
129 return layout.preferredLayoutSize(parent);
130 }
131
132
133
134 public Dimension minimumLayoutSize(Container parent) {
135 return layout.minimumLayoutSize(parent);
136 }
137
138
139
140 public void layoutContainer(Container parent) {
141 if (layout == null) {
142 addWidget(null);
143 }
144 layout.layoutContainer(parent);
145 }
146
147 }