01: package gnu.kawa.models;
02:
03: import java.awt.Dimension;
04: import java.awt.geom.Dimension2D;
05:
06: /* An object that provides space between other Model objects. */
07:
08: public class Spacer extends Model implements Viewable,
09: java.io.Serializable {
10: Dimension2D minSize;
11: Dimension2D preferredSize;
12: Dimension2D maxSize;
13:
14: public Dimension2D getMinimumSize2D() {
15: return minSize;
16: }
17:
18: public Dimension2D getPreferredSize2D() {
19: return preferredSize;
20: }
21:
22: public Dimension2D getMaximumSize2D() {
23: return maxSize;
24: }
25:
26: public Dimension getMinimumSize() {
27: return Display.asDimension(minSize);
28: }
29:
30: public Dimension getPreferredSize() {
31: return Display.asDimension(preferredSize);
32: }
33:
34: public Dimension getMaximumSize() {
35: return Display.asDimension(maxSize);
36: }
37:
38: public boolean isRigid() {
39: if (minSize == maxSize)
40: return true;
41: if (minSize != null && maxSize != null
42: && minSize.getWidth() == maxSize.getWidth()
43: && minSize.getHeight() == maxSize.getHeight())
44: return true;
45: return false;
46: }
47:
48: public static Spacer rigidArea(Dimension2D d) {
49: Spacer spacer = new Spacer();
50: spacer.minSize = d;
51: spacer.maxSize = d;
52: spacer.preferredSize = d;
53: return spacer;
54: }
55:
56: public static Spacer rigidArea(int width, int height) {
57: return rigidArea(new Dimension(width, height));
58: }
59:
60: public void makeView(Display display, Object where) {
61: display.addSpacer(this, where);
62: }
63: }
|