KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sshtools > ui > swing > AbstractLayout


1 /*
2  * Gruntspud
3  *
4  * Copyright (C) 2002 Brett Smith.
5  *
6  * Written by: Brett Smith <t_magicthize@users.sourceforge.net>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public License
10  * as published by the Free Software Foundation; either version 2 of
11  * the License, or (at your option) any later version.
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this program; if not, write to the Free Software
19  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */

21
22 /**
23  * $Log: AbstractLayout.java,v $
24  * Revision 1.1 2006/10/08 22:58:36 brett
25  * Lots of refactoring and tidying up. Converse now depends on ui.
26  *
27  * Revision 1.1 2004/02/22 22:19:48 brett
28  * Reworking of the connection profile editor to be an outlook
29  * style side tool bar.
30  *
31  * Revision 1.5 2003/11/22 17:33:35 t_magicthize
32  * Started work on internationalisation. Split the gruntspud.ui package up into more manageable parts. Added option to show text on some actions.
33  *
34  * Revision 1.4 2003/07/21 20:25:10 t_magicthize
35  * Preparation for release.
36  *
37  * Revision 1.3 2003/03/30 19:21:50 t_magicthize
38  * See RELEASE_NOTES.txt (0.4.0-beta)
39  *
40  * Revision 1.2 2003/01/30 23:37:39 t_magicthize
41  * Global source format using jalopy
42  *
43  * Revision 1.1 2002/12/23 01:22:09 t_magicthize
44  * Many improvements. The new preferences dialog UI in the standalone version. Many other small bug fixes.
45  *
46  * Revision 1.2 2001/12/11 22:24:43 Hymndinner
47  * Added 'Log' statements to all source in this tree.
48  *
49  */

50 package com.sshtools.ui.swing;
51
52 import java.awt.Component JavaDoc;
53 import java.awt.Container JavaDoc;
54 import java.awt.Dimension JavaDoc;
55 import java.awt.LayoutManager2 JavaDoc;
56 import java.io.Serializable JavaDoc;
57
58 /**
59  * DOCUMENT ME!
60  *
61  * @author $author$
62  */

63 public abstract class AbstractLayout
64     implements LayoutManager2 JavaDoc, Serializable JavaDoc {
65     protected int hgap;
66     protected int vgap;
67
68     /**
69      * Creates a new AbstractLayout object.
70      */

71     public AbstractLayout() {
72         this(0, 0);
73     }
74
75     /**
76      * Creates a new AbstractLayout object.
77      *
78      * @param hgap DOCUMENT ME!
79      * @param vgap DOCUMENT ME!
80      */

81     public AbstractLayout(int hgap, int vgap) {
82         setHgap(hgap);
83         setVgap(vgap);
84     }
85
86     /**
87      * Get the horizontal gap between components.
88      **/

89     public int getHgap() {
90         return hgap;
91     }
92
93     /**
94      * Get the vertical gap between components.
95      **/

96     public int getVgap() {
97         return vgap;
98     }
99
100     /**
101      * Set the horizontal gap between components.
102      * @param gap The horizontal gap to be set
103      **/

104     public void setHgap(int gap) {
105         hgap = gap;
106     }
107
108     /**
109      * Set the vertical gap between components.
110      * @param gap The vertical gap to be set
111      **/

112     public void setVgap(int gap) {
113         vgap = gap;
114     }
115
116     /**
117      * Returns the maximum dimensions for this layout given
118      * the component in the specified target container.
119      * @param target The component which needs to be laid out
120      **/

121     public Dimension JavaDoc maximumLayoutSize(Container JavaDoc target) {
122         return new Dimension JavaDoc(Integer.MAX_VALUE, Integer.MAX_VALUE);
123     }
124
125     /**
126      * Returns the alignment along the x axis. This specifies how
127      * the component would like to be aligned relative to other
128      * components. The value should be a number between 0 and 1
129      * where 0 represents alignment along the origin, 1 is aligned
130      * the furthest away from the origin, 0.5 is centered, etc.
131      **/

132     public float getLayoutAlignmentX(Container JavaDoc parent) {
133         return 0.5f;
134     }
135
136     /**
137      * Returns the alignment along the y axis. This specifies how
138      * the component would like to be aligned relative to other
139      * components. The value should be a number between 0 and 1
140      * where 0 represents alignment along the origin, 1 is aligned
141      * the furthest away from the origin, 0.5 is centered, etc.
142      **/

143     public float getLayoutAlignmentY(Container JavaDoc parent) {
144         return 0.5f;
145     }
146
147     /**
148      * Invalidates the layout, indicating that if the layout
149      * manager has cached information it should be discarded.
150      **/

151     public void invalidateLayout(Container JavaDoc target) {
152     }
153
154     /**
155      * Adds the specified component with the specified name
156      * to the layout. By default, we call the more recent
157      * addLayoutComponent method with an object constraint
158      * argument. The name is passed through directly.
159      * @param name The name of the component
160      * @param comp The component to be added
161      **/

162     public void addLayoutComponent(String JavaDoc name, Component JavaDoc comp) {
163         addLayoutComponent(comp, name);
164     }
165
166     /**
167      * Add the specified component from the layout.
168      * By default, we let the Container handle this directly.
169      * @param comp The component to be added
170      * @param constraints The constraints to apply when laying out.
171      **/

172     public void addLayoutComponent(Component JavaDoc comp, Object JavaDoc constraints) {
173     }
174
175     /**
176      * Removes the specified component from the layout.
177      * By default, we let the Container handle this directly.
178      * @param comp the component to be removed
179      **/

180     public void removeLayoutComponent(Component JavaDoc comp) {
181     }
182
183     /**
184      * Return a string representation of the layout manager
185      **/

186     public String JavaDoc toString() {
187         return getClass().getName() + "[hgap=" + hgap + ",vgap=" + vgap + "]";
188     }
189 }
190
Popular Tags