source: other-projects/trunk/greenstone3-extension/mat/DLMetadataQuality/src/org/greenstone3/ms/AbsoluteConstraints.java@ 17184

Last change on this file since 17184 was 17184, checked in by cc108, 16 years ago

Metadata Quality For Digital Libraries

File size: 3.8 KB
Line 
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.
12 */
13
14//package org.netbeans.lib.awtextra;
15
16package org.greenstone3.ms;
17
18import java.awt.Dimension;
19import java.awt.Point;
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 */
27public class AbsoluteConstraints implements java.io.Serializable {
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 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 pos, Dimension 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 toString() {
110 return super.toString() + " [x=" + x + ", y=" + y + ", width=" + width + ", height=" + height + "]";
111 }
112
113}
114
115
116
Note: See TracBrowser for help on using the repository browser.