KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > core > monitor > AbsoluteConstraints


1 //from the NetBeans redist directory
2
//$Id: AbsoluteConstraints.java,v 1.3 2002/08/27 08:32:26 per_nyfelt Exp $
3

4 package org.ozoneDB.core.monitor;
5
6 import java.awt.*;
7
8
9 /**
10  * An object that encapsulates position and (optionally) size for
11  * Absolute positioning of components.
12  *
13  *
14  * @see AbsoluteLayout
15  * @version 1.01, Aug 19, 1998 ($Revision: 1.3 $)
16  * @author Ian Formanek (modified softwarebuero m&b)
17  */

18 public class AbsoluteConstraints implements java.io.Serializable JavaDoc {
19
20     /** Werte fuer GUI-einstellung*/
21     final static int MOTIF = 0;
22     final static int WIN = 1;
23     /** aktuelle GUI-einstellung*/
24     static int GUI = MOTIF;
25
26     /** generated Serialized Version UID */
27     final static long serialVersionUID = 5261460716622152494L;
28
29     /** The X position of the component */
30     public int x;
31     /** The Y position of the component */
32     public int y;
33     /** The width of the component or -1 if the component's preferred width should be used */
34     public int width = -1;
35     /** The height of the component or -1 if the component's preferred height should be used */
36     public int height = -1;
37
38     /** Groesse und position sind fest */
39     final static int FIXED = 0;
40     /** */
41     final static int X_ABS = 1;
42     final static int X_PROP = 2;
43     final static int Y_ABS = 4;
44     final static int Y_PROP = 8;
45     final static int X2_ABS = 16;
46     final static int X2_PROP = 32;
47     final static int Y2_ABS = 64;
48     final static int Y2_PROP = 128;
49     /** Position wird proportional/fest der groesse des containers angepasst */
50     final static int MOVE_PROP = X_PROP | Y_PROP;
51     final static int MOVE_ABS = X_ABS | Y_ABS;
52     /** Groesse wird proportional/fest der groesse des containers angepasst */
53     final static int RESIZE_PROP = X2_PROP | Y2_PROP;
54     final static int RESIZE_ABS = X2_ABS | Y2_ABS;
55     /** */
56     public int policy = FIXED;
57
58
59     /**
60      * Creates a new AbsoluteConstraints for specified position.
61      * @param pos The position to be represented by this AbsoluteConstraints
62      */

63     public AbsoluteConstraints( Point pos ) {
64         this( pos.x, pos.y );
65     }
66
67
68     /**
69      * Creates a new AbsoluteConstraints for specified position.
70      * @param x The X position to be represented by this AbsoluteConstraints
71      * @param y The Y position to be represented by this AbsoluteConstraints
72      */

73     public AbsoluteConstraints( int x, int y ) {
74         this.x = x;
75         this.y = y;
76     }
77
78
79     /**
80      * Creates a new AbsoluteConstraints for specified position and size.
81      * @param pos The position to be represented by this AbsoluteConstraints
82      * @param size The size to be represented by this AbsoluteConstraints or null
83      * if the component's preferred size should be used
84      */

85     public AbsoluteConstraints( Point pos, Dimension size ) {
86         this.x = pos.x;
87         this.y = pos.y;
88         if (size != null) {
89             this.width = size.width;
90             this.height = size.height;
91         }
92     }
93
94
95     /**
96      * Creates a new AbsoluteConstraints for specified position and size.
97      * @param x The X position to be represented by this AbsoluteConstraints
98      * @param y The Y position to be represented by this AbsoluteConstraints
99      * @param width The width to be represented by this AbsoluteConstraints or -1 if the
100      * component's preferred width should be used
101      * @param height The height to be represented by this AbsoluteConstraints or -1 if the
102      * component's preferred height should be used
103      */

104     public AbsoluteConstraints( int x, int y, int width, int height ) {
105         this.x = x;
106         this.y = y;
107         this.width = width;
108         this.height = height;
109     }
110
111
112     /** */
113     public AbsoluteConstraints( int x, int y, int width, int height, int policy ) {
114         this.x = x;
115         this.y = y;
116         this.width = width;
117         this.height = height;
118         this.policy = policy;
119     }
120
121
122     /** @return The X position represented by this AbsoluteConstraints */
123     public int getX() {
124         return x;
125     }
126
127
128     /** @return The Y position represented by this AbsoluteConstraints */
129     public int getY() {
130         return y;
131     }
132
133
134     /**
135      * @return The width represented by this AbsoluteConstraints or -1 if the
136      * component's preferred width should be used
137      */

138     public int getWidth() {
139         return GUI == MOTIF || width == -1 ? width : width - 3;
140     }
141
142
143     /**
144      * @return The height represented by this AbsoluteConstraints or -1 if the
145      * component's preferred height should be used
146      */

147     public int getHeight() {
148         return GUI == MOTIF || height == -1 ? height : height - 5;
149     }
150
151
152     public String JavaDoc toString() {
153         return super.toString() + " [x=" + x + ", y=" + y + ", width=" + width + ", height=" + height + "]";
154     }
155 }
156
Popular Tags