KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > common > AbsoluteConstraints


1 package com.calipso.reportgenerator.common;
2
3 /*
4  * Sun Public License Notice
5  *
6  * The contents of this file are subject to the Sun Public License
7  * Version 1.0 (the "License"). You may not use this file except in
8  * compliance with the License. A copy of the License is available at
9  * http://www.sun.com/
10  *
11  * The Original Code is NetBeans. The Initial Developer of the Original
12  * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
13  * Microsystems, Inc. All Rights Reserved.
14  */

15
16 //package org.netbeans.lib.awtextra;
17

18 import java.awt.Dimension JavaDoc;
19 import java.awt.Point JavaDoc;
20
21 /** An object that encapsulates position and (optionally) size for
22 * Absolute positioning of components.
23 *
24 //* @see AbsoluteLayout
25 * @version 1.01, Aug 19, 1998
26 */

27 public class AbsoluteConstraints implements java.io.Serializable JavaDoc {
28     /** generated Serialized Version UID */
29     static final long serialVersionUID = 5261460716622152494L;
30
31     /** The X position of the component */
32     public int x;
33     /** The Y position of the component */
34     public int y;
35     /** The width of the component or -1 if the component's preferred width should be used */
36     public int width = -1;
37     /** The height of the component or -1 if the component's preferred height should be used */
38     public int height = -1;
39
40     /** Creates a new AbsoluteConstraints for specified position.
41     * @param pos The position to be represented by this AbsoluteConstraints
42     */

43     public AbsoluteConstraints(Point JavaDoc pos) {
44         this (pos.x, pos.y);
45     }
46
47     /** Creates a new AbsoluteConstraints for specified position.
48     * @param x The X position to be represented by this AbsoluteConstraints
49     * @param y The Y position to be represented by this AbsoluteConstraints
50     */

51     public AbsoluteConstraints(int x, int y) {
52         this.x = x;
53         this.y = y;
54     }
55
56     /** Creates a new AbsoluteConstraints for specified position and size.
57     * @param pos The position to be represented by this AbsoluteConstraints
58     * @param size The size to be represented by this AbsoluteConstraints or null
59     * if the component's preferred size should be used
60     */

61     public AbsoluteConstraints(Point JavaDoc pos, Dimension JavaDoc size) {
62         this.x = pos.x;
63         this.y = pos.y;
64         if (size != null) {
65             this.width = size.width;
66             this.height = size.height;
67         }
68     }
69
70     /** Creates a new AbsoluteConstraints for specified position and size.
71     * @param x The X position to be represented by this AbsoluteConstraints
72     * @param y The Y position to be represented by this AbsoluteConstraints
73     * @param width The width to be represented by this AbsoluteConstraints or -1 if the
74     * component's preferred width should be used
75     * @param height The height to be represented by this AbsoluteConstraints or -1 if the
76     * component's preferred height should be used
77     */

78     public AbsoluteConstraints(int x, int y, int width, int height) {
79         this.x = x;
80         this.y = y;
81         this.width = width;
82         this.height = height;
83     }
84
85     /** @return The X position represented by this AbsoluteConstraints */
86     public int getX () {
87         return x;
88     }
89
90     /** @return The Y position represented by this AbsoluteConstraints */
91     public int getY () {
92         return y;
93     }
94
95     /** @return The width represented by this AbsoluteConstraints or -1 if the
96     * component's preferred width should be used
97     */

98     public int getWidth () {
99         return width;
100     }
101
102     /** @return The height represented by this AbsoluteConstraints or -1 if the
103     * component's preferred height should be used
104     */

105     public int getHeight () {
106         return height;
107     }
108
109     public String JavaDoc toString () {
110         return super.toString () +" [x="+x+", y="+y+", width="+width+", height="+height+"]";
111     }
112
113 }
114
115
Popular Tags