KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jxl > format > UnderlineStyle


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

19
20 package jxl.format;
21
22 /**
23  * Enumeration class which contains the various underline styles available
24  * within the standard Excel UnderlineStyle palette
25  *
26  */

27 public final class UnderlineStyle
28 {
29   /**
30    * The internal numerical representation of the UnderlineStyle
31    */

32   private int value;
33
34   /**
35    * The display string for the underline style. Used when presenting the
36    * format information
37    */

38   private String JavaDoc string;
39
40   /**
41    * The list of UnderlineStyles
42    */

43   private static UnderlineStyle[] styles = new UnderlineStyle[0];
44
45   /**
46    * Private constructor
47    *
48    * @param val
49    * @param s the display string
50    */

51   protected UnderlineStyle(int val, String JavaDoc s)
52   {
53     value = val;
54     string = s;
55
56     UnderlineStyle[] oldstyles = styles;
57     styles = new UnderlineStyle[oldstyles.length + 1];
58     System.arraycopy(oldstyles, 0, styles, 0, oldstyles.length);
59     styles[oldstyles.length] = this;
60   }
61
62   /**
63    * Gets the value of this style. This is the value that is written to
64    * the generated Excel file
65    *
66    * @return the binary value
67    */

68   public int getValue()
69   {
70     return value;
71   }
72
73   /**
74    * Gets the string description for display purposes
75    *
76    * @return the string description
77    */

78   public String JavaDoc getDescription()
79   {
80     return string;
81   }
82
83   /**
84    * Gets the UnderlineStyle from the value
85    *
86    * @param val
87    * @return the UnderlineStyle with that value
88    */

89   public static UnderlineStyle getStyle(int val)
90   {
91     for (int i = 0 ; i < styles.length ; i++)
92     {
93       if (styles[i].getValue() == val)
94       {
95         return styles[i];
96       }
97     }
98
99     return NO_UNDERLINE;
100   }
101
102   // The underline styles
103
public static final UnderlineStyle NO_UNDERLINE =
104     new UnderlineStyle(0, "none");
105
106   public static final UnderlineStyle SINGLE =
107     new UnderlineStyle(1, "single");
108
109   public static final UnderlineStyle DOUBLE =
110     new UnderlineStyle(2, "double");
111
112   public static final UnderlineStyle SINGLE_ACCOUNTING =
113     new UnderlineStyle(0x21, "single accounting");
114
115   public static final UnderlineStyle DOUBLE_ACCOUNTING =
116     new UnderlineStyle(0x22, "double accounting");
117 }
118
119
120
121
122
123
124
125
126
127
128
129
Popular Tags