Merge /pub/main
[educational.data.git] / Dr.NO / src / org / netbeans / lib / awtextra / AbsoluteConstraints.java
blobce1b3ba81b3edc8b0e4bf8ae25d96d05aec7de7a
1 /*
2 * Sun Public License Notice
3 *
4 * The contents of this file are subject to the Sun Public License
5 * Version 1.0 (the "License"). You may not use this file except in
6 * compliance with the License. A copy of the License is available at
7 * http://www.sun.com/
8 *
9 * The Original Code is NetBeans. The Initial Developer of the Original
10 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
11 * Microsystems, Inc. All Rights Reserved.
14 package org.netbeans.lib.awtextra;
16 import java.awt.Dimension;
17 import java.awt.Point;
19 /** An object that encapsulates position and (optionally) size for
20 * Absolute positioning of components.
22 * @see AbsoluteLayout
23 * @version 1.01, Aug 19, 1998
25 public class AbsoluteConstraints implements java.io.Serializable {
26 /** generated Serialized Version UID */
27 static final long serialVersionUID = 5261460716622152494L;
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;
38 /** Creates a new AbsoluteConstraints for specified position.
39 * @param pos The position to be represented by this AbsoluteConstraints
41 public AbsoluteConstraints(Point pos) {
42 this (pos.x, pos.y);
45 /** Creates a new AbsoluteConstraints for specified position.
46 * @param x The X position to be represented by this AbsoluteConstraints
47 * @param y The Y position to be represented by this AbsoluteConstraints
49 public AbsoluteConstraints(int x, int y) {
50 this.x = x;
51 this.y = y;
54 /** Creates a new AbsoluteConstraints for specified position and size.
55 * @param pos The position to be represented by this AbsoluteConstraints
56 * @param size The size to be represented by this AbsoluteConstraints or null
57 * if the component's preferred size should be used
59 public AbsoluteConstraints(Point pos, Dimension size) {
60 this.x = pos.x;
61 this.y = pos.y;
62 if (size != null) {
63 this.width = size.width;
64 this.height = size.height;
68 /** Creates a new AbsoluteConstraints for specified position and size.
69 * @param x The X position to be represented by this AbsoluteConstraints
70 * @param y The Y position to be represented by this AbsoluteConstraints
71 * @param width The width to be represented by this AbsoluteConstraints or -1 if the
72 * component's preferred width should be used
73 * @param height The height to be represented by this AbsoluteConstraints or -1 if the
74 * component's preferred height should be used
76 public AbsoluteConstraints(int x, int y, int width, int height) {
77 this.x = x;
78 this.y = y;
79 this.width = width;
80 this.height = height;
83 /** @return The X position represented by this AbsoluteConstraints */
84 public int getX () {
85 return x;
88 /** @return The Y position represented by this AbsoluteConstraints */
89 public int getY () {
90 return y;
93 /** @return The width represented by this AbsoluteConstraints or -1 if the
94 * component's preferred width should be used
96 public int getWidth () {
97 return width;
100 /** @return The height represented by this AbsoluteConstraints or -1 if the
101 * component's preferred height should be used
103 public int getHeight () {
104 return height;
107 public String toString () {
108 return super.toString () +" [x="+x+", y="+y+", width="+width+", height="+height+"]";