KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jxl > format > BorderLineStyle


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  * The border line style
24  */

25 public /*final*/ class BorderLineStyle
26 {
27   /**
28    * The value
29    */

30   private int value;
31
32   /**
33    * The string description
34    */

35   private String JavaDoc string;
36
37   /**
38    * The list of alignments
39    */

40   private static BorderLineStyle[] styles = new BorderLineStyle[0];
41
42
43   /**
44    * Constructor
45    */

46   protected BorderLineStyle(int val, String JavaDoc s)
47   {
48     value = val;
49     string = s;
50
51     BorderLineStyle[] oldstyles = styles;
52     styles = new BorderLineStyle[oldstyles.length + 1];
53     System.arraycopy(oldstyles, 0, styles, 0, oldstyles.length);
54     styles[oldstyles.length] = this;
55   }
56
57   /**
58    * Gets the value for this line style
59    *
60    * @return the value
61    */

62   public int getValue()
63   {
64     return value;
65   }
66
67   /**
68    * Gets the textual description
69    */

70   public String JavaDoc getDescription()
71   {
72     return string;
73   }
74
75   /**
76    * Gets the alignment from the value
77    *
78    * @param val
79    * @return the alignment with that value
80    */

81   public static BorderLineStyle getStyle(int val)
82   {
83     for (int i = 0 ; i < styles.length ; i++)
84     {
85       if (styles[i].getValue() == val)
86       {
87         return styles[i];
88       }
89     }
90
91     return NONE;
92   }
93   
94   public final static BorderLineStyle NONE
95                        = new BorderLineStyle(0, "none");
96   public final static BorderLineStyle THIN
97                        = new BorderLineStyle(1, "thin");
98   public final static BorderLineStyle MEDIUM
99                        = new BorderLineStyle(2, "medium");
100   public final static BorderLineStyle DASHED
101                        = new BorderLineStyle(3, "dashed");
102   public final static BorderLineStyle DOTTED
103                        = new BorderLineStyle(4, "dotted");
104   public final static BorderLineStyle THICK
105                        = new BorderLineStyle(5, "thick");
106   public final static BorderLineStyle DOUBLE
107                        = new BorderLineStyle(6, "double");
108   public final static BorderLineStyle HAIR
109                        = new BorderLineStyle(7, "hair");
110   public final static BorderLineStyle MEDIUM_DASHED
111                        = new BorderLineStyle(8, "medium dashed");
112   public final static BorderLineStyle DASH_DOT
113                        = new BorderLineStyle(9, "dash dot");
114   public final static BorderLineStyle MEDIUM_DASH_DOT
115                        = new BorderLineStyle(0xa, "medium dash dot");
116   public final static BorderLineStyle DASH_DOT_DOT
117                        = new BorderLineStyle(0xb, "Dash dot dot");
118   public final static BorderLineStyle MEDIUM_DASH_DOT_DOT
119                        = new BorderLineStyle(0xc, "Medium dash dot dot");
120   public final static BorderLineStyle SLANTED_DASH_DOT
121                        = new BorderLineStyle(0xd, "Slanted dash dot");
122 }
123
Popular Tags