KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > aspects > gui > Border


1 /*
2   Copyright (C) 2002 Renaud Pawlak <renaud@aopsys.com>
3   
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful, but
10   WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public
15   License along with this program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17   USA */

18
19 package org.objectweb.jac.aspects.gui;
20
21 /**
22  * This class represents borders in GUI. */

23
24 public class Border {
25     /** None border constant */
26     public static final int NONE = 0;
27     /** The label of the border if any is diplayed on the left constant */
28     public static final int LEFT = 1;
29     /** The label of the border if any is diplayed on the top constant */
30     public static final int TOP = 2;
31     /** The label of the border if any is diplayed on the right constant */
32     public static final int RIGHT = 3;
33     /** The label of the border if any is diplayed on the bottom constant */
34     public static final int BOTTOM = 4;
35     /** The label of the border if any is diplayed centered constant */
36     public static final int CENTER = 5;
37     /** The style is a line constant */
38     public static final int LINE = 6;
39     /** The style is etched constant */
40     public static final int ETCHED = 7;
41     /** The style is lowered constant */
42     public static final int LOWERED = 8;
43     /** The style is raised constant */
44     public static final int RAISED = 9;
45
46     /**
47      * Converts a string representation of the alignment to an int. */

48    
49     public static int a2iAlignment(String JavaDoc alignment) {
50         if (alignment.equals("LEFT"))
51             return LEFT;
52         else if (alignment.equals("RIGHT"))
53             return RIGHT;
54         else if (alignment.equals("CENTER"))
55             return CENTER;
56         else
57             throw new RuntimeException JavaDoc("Wrong alignment '"+alignment+"'");
58     }
59
60     /**
61      * Converts a string representation of the style to an int. */

62
63     public static int a2iStyle(String JavaDoc style) {
64         if (style.equals("LINE"))
65             return LINE;
66         else if (style.equals("ETCHED"))
67             return ETCHED;
68         else if (style.equals("LOWERED"))
69             return LOWERED;
70         else if (style.equals("RAISED"))
71             return RAISED;
72         else
73             throw new RuntimeException JavaDoc("Wrong style '"+style+"'");
74     }
75
76     /**
77      * Converts an integer representation of the style to a string. */

78
79     public static String JavaDoc i2aStyle(int style) {
80         if (style==LINE)
81             return "LINE";
82         else if (style==ETCHED)
83             return "ETCHED";
84         else if (style==LOWERED)
85             return "LOWERED";
86         else if (style==RAISED)
87             return "RAISED";
88         else
89             throw new RuntimeException JavaDoc("Wrong style '"+style+"'");
90     }
91
92     /**
93      * Constructs a new border.
94      *
95      * @param title the border's title
96      * @param alignment the title alignment
97      * @param style the border's style */

98
99     public Border(String JavaDoc title,int alignment,int style) {
100         this.title = title;
101         this.alignment = alignment;
102         this.style = style;
103     }
104
105     /**
106      * Returns true if the border has a title. */

107     public boolean hasTitle() {
108         return title!=null;
109     }
110    
111     int alignment;
112    
113     /**
114      * Get the value of alignment.
115      * @return value of alignment.
116      */

117     public int getAlignment() {
118         return alignment;
119     }
120    
121     /**
122      * Set the value of alignment.
123      * @param v Value to assign to alignment.
124      */

125     public void setAlignment(int v) {
126         this.alignment = v;
127     }
128    
129     int style;
130    
131     /**
132      * Get the value of style.
133      * @return value of style.
134      */

135     public int getStyle() {
136         return style;
137     }
138    
139     /**
140      * Set the value of style.
141      * @param v Value to assign to style.
142      */

143     public void setStyle(int v) {
144         this.style = v;
145     }
146    
147     String JavaDoc title;
148    
149     /**
150      * Get the value of title.
151      * @return value of title.
152      */

153     public String JavaDoc getTitle() {
154         return title;
155     }
156    
157     /**
158      * Set the value of title.
159      * @param v Value to assign to title.
160      */

161     public void setTitle(String JavaDoc v) {
162         this.title = v;
163     }
164
165     public String JavaDoc toString() {
166         return "Border{title="+title+",style="+style+"}";
167     }
168 }
169
Popular Tags