001: package com.calipso.reportgenerator.common;
002:
003: /*
004: * Sun Public License Notice
005: *
006: * The contents of this file are subject to the Sun Public License
007: * Version 1.0 (the "License"). You may not use this file except in
008: * compliance with the License. A copy of the License is available at
009: * http://www.sun.com/
010: *
011: * The Original Code is NetBeans. The Initial Developer of the Original
012: * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
013: * Microsystems, Inc. All Rights Reserved.
014: */
015:
016: //package org.netbeans.lib.awtextra;
017: import java.awt.Dimension;
018: import java.awt.Point;
019:
020: /** An object that encapsulates position and (optionally) size for
021: * Absolute positioning of components.
022: *
023: //* @see AbsoluteLayout
024: * @version 1.01, Aug 19, 1998
025: */
026: public class AbsoluteConstraints implements java.io.Serializable {
027: /** generated Serialized Version UID */
028: static final long serialVersionUID = 5261460716622152494L;
029:
030: /** The X position of the component */
031: public int x;
032: /** The Y position of the component */
033: public int y;
034: /** The width of the component or -1 if the component's preferred width should be used */
035: public int width = -1;
036: /** The height of the component or -1 if the component's preferred height should be used */
037: public int height = -1;
038:
039: /** Creates a new AbsoluteConstraints for specified position.
040: * @param pos The position to be represented by this AbsoluteConstraints
041: */
042: public AbsoluteConstraints(Point pos) {
043: this (pos.x, pos.y);
044: }
045:
046: /** Creates a new AbsoluteConstraints for specified position.
047: * @param x The X position to be represented by this AbsoluteConstraints
048: * @param y The Y position to be represented by this AbsoluteConstraints
049: */
050: public AbsoluteConstraints(int x, int y) {
051: this .x = x;
052: this .y = y;
053: }
054:
055: /** Creates a new AbsoluteConstraints for specified position and size.
056: * @param pos The position to be represented by this AbsoluteConstraints
057: * @param size The size to be represented by this AbsoluteConstraints or null
058: * if the component's preferred size should be used
059: */
060: public AbsoluteConstraints(Point pos, Dimension size) {
061: this .x = pos.x;
062: this .y = pos.y;
063: if (size != null) {
064: this .width = size.width;
065: this .height = size.height;
066: }
067: }
068:
069: /** Creates a new AbsoluteConstraints for specified position and size.
070: * @param x The X position to be represented by this AbsoluteConstraints
071: * @param y The Y position to be represented by this AbsoluteConstraints
072: * @param width The width to be represented by this AbsoluteConstraints or -1 if the
073: * component's preferred width should be used
074: * @param height The height to be represented by this AbsoluteConstraints or -1 if the
075: * component's preferred height should be used
076: */
077: public AbsoluteConstraints(int x, int y, int width, int height) {
078: this .x = x;
079: this .y = y;
080: this .width = width;
081: this .height = height;
082: }
083:
084: /** @return The X position represented by this AbsoluteConstraints */
085: public int getX() {
086: return x;
087: }
088:
089: /** @return The Y position represented by this AbsoluteConstraints */
090: public int getY() {
091: return y;
092: }
093:
094: /** @return The width represented by this AbsoluteConstraints or -1 if the
095: * component's preferred width should be used
096: */
097: public int getWidth() {
098: return width;
099: }
100:
101: /** @return The height represented by this AbsoluteConstraints or -1 if the
102: * component's preferred height should be used
103: */
104: public int getHeight() {
105: return height;
106: }
107:
108: public String toString() {
109: return super .toString() + " [x=" + x + ", y=" + y + ", width="
110: + width + ", height=" + height + "]";
111: }
112:
113: }
|