001: //from the NetBeans redist directory
002: //$Id: AbsoluteConstraints.java,v 1.2 2002/07/29 11:30:23 per_nyfelt Exp $
003:
004: package org.ozoneDB.core.monitor;
005:
006: import java.awt.*;
007:
008: /**
009: * An object that encapsulates position and (optionally) size for
010: * Absolute positioning of components.
011: *
012: *
013: * @see AbsoluteLayout
014: * @version 1.01, Aug 19, 1998 ($Revision: 1.2 $)
015: * @author Ian Formanek (modified softwarebuero m&b)
016: */
017: public class AbsoluteConstraints implements java.io.Serializable {
018:
019: /** Werte fuer GUI-einstellung*/
020: final static int MOTIF = 0;
021: final static int WIN = 1;
022: /** aktuelle GUI-einstellung*/
023: static int GUI = MOTIF;
024:
025: /** generated Serialized Version UID */
026: final static long serialVersionUID = 5261460716622152494L;
027:
028: /** The X position of the component */
029: public int x;
030: /** The Y position of the component */
031: public int y;
032: /** The width of the component or -1 if the component's preferred width should be used */
033: public int width = -1;
034: /** The height of the component or -1 if the component's preferred height should be used */
035: public int height = -1;
036:
037: /** Groesse und position sind fest */
038: final static int FIXED = 0;
039: /** */
040: final static int X_ABS = 1;
041: final static int X_PROP = 2;
042: final static int Y_ABS = 4;
043: final static int Y_PROP = 8;
044: final static int X2_ABS = 16;
045: final static int X2_PROP = 32;
046: final static int Y2_ABS = 64;
047: final static int Y2_PROP = 128;
048: /** Position wird proportional/fest der groesse des containers angepasst */
049: final static int MOVE_PROP = X_PROP | Y_PROP;
050: final static int MOVE_ABS = X_ABS | Y_ABS;
051: /** Groesse wird proportional/fest der groesse des containers angepasst */
052: final static int RESIZE_PROP = X2_PROP | Y2_PROP;
053: final static int RESIZE_ABS = X2_ABS | Y2_ABS;
054: /** */
055: public int policy = FIXED;
056:
057: /**
058: * Creates a new AbsoluteConstraints for specified position.
059: * @param pos The position to be represented by this AbsoluteConstraints
060: */
061: public AbsoluteConstraints(Point pos) {
062: this (pos.x, pos.y);
063: }
064:
065: /**
066: * Creates a new AbsoluteConstraints for specified position.
067: * @param x The X position to be represented by this AbsoluteConstraints
068: * @param y The Y position to be represented by this AbsoluteConstraints
069: */
070: public AbsoluteConstraints(int x, int y) {
071: this .x = x;
072: this .y = y;
073: }
074:
075: /**
076: * Creates a new AbsoluteConstraints for specified position and size.
077: * @param pos The position to be represented by this AbsoluteConstraints
078: * @param size The size to be represented by this AbsoluteConstraints or null
079: * if the component's preferred size should be used
080: */
081: public AbsoluteConstraints(Point pos, Dimension size) {
082: this .x = pos.x;
083: this .y = pos.y;
084: if (size != null) {
085: this .width = size.width;
086: this .height = size.height;
087: }
088: }
089:
090: /**
091: * Creates a new AbsoluteConstraints for specified position and size.
092: * @param x The X position to be represented by this AbsoluteConstraints
093: * @param y The Y position to be represented by this AbsoluteConstraints
094: * @param width The width to be represented by this AbsoluteConstraints or -1 if the
095: * component's preferred width should be used
096: * @param height The height to be represented by this AbsoluteConstraints or -1 if the
097: * component's preferred height should be used
098: */
099: public AbsoluteConstraints(int x, int y, int width, int height) {
100: this .x = x;
101: this .y = y;
102: this .width = width;
103: this .height = height;
104: }
105:
106: /** */
107: public AbsoluteConstraints(int x, int y, int width, int height,
108: int policy) {
109: this .x = x;
110: this .y = y;
111: this .width = width;
112: this .height = height;
113: this .policy = policy;
114: }
115:
116: /** @return The X position represented by this AbsoluteConstraints */
117: public int getX() {
118: return x;
119: }
120:
121: /** @return The Y position represented by this AbsoluteConstraints */
122: public int getY() {
123: return y;
124: }
125:
126: /**
127: * @return The width represented by this AbsoluteConstraints or -1 if the
128: * component's preferred width should be used
129: */
130: public int getWidth() {
131: return GUI == MOTIF || width == -1 ? width : width - 3;
132: }
133:
134: /**
135: * @return The height represented by this AbsoluteConstraints or -1 if the
136: * component's preferred height should be used
137: */
138: public int getHeight() {
139: return GUI == MOTIF || height == -1 ? height : height - 5;
140: }
141:
142: public String toString() {
143: return super .toString() + " [x=" + x + ", y=" + y + ", width="
144: + width + ", height=" + height + "]";
145: }
146: }
|