KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > sp > jedit > textarea > AntiAlias


1 /*
2  * AntiAlias.java - a small helper class for AntiAlias settings.
3  * :tabSize=8:indentSize=8:noTabs=false:
4  * :folding=explicit:collapseFolds=1:
5  *
6  * Copyright (C) 2006 Alan Ezust
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21  */

22 package org.gjt.sp.jedit.textarea;
23
24 /**
25  * Class for representing AntiAlias values. The following modes are supported:
26  * none standard lcd subpixel (JDK 1.6 only)
27  *
28  * @author ezust
29  * @since jedit 4.3pre4
30  */

31 public class AntiAlias extends Object JavaDoc
32 {
33     public static final Object JavaDoc NONE = "none";
34
35     public static final Object JavaDoc STANDARD = "standard";
36
37     public static final Object JavaDoc SUBPIXEL = "subpixel";
38
39     public static final Object JavaDoc comboChoices[] = new Object JavaDoc[] { NONE, STANDARD, SUBPIXEL };
40
41     public void set(int newValue)
42     {
43         m_val = newValue;
44     }
45
46     public AntiAlias(boolean isEnabled)
47     {
48         m_val = isEnabled ? 1 : 0;
49     }
50
51     public AntiAlias(int val)
52     {
53         m_val = val;
54     }
55
56     public AntiAlias(String JavaDoc v)
57     {
58         fromString(v);
59     }
60
61     public boolean equals(Object JavaDoc other)
62     {
63         return toString().equals(other.toString());
64
65     }
66
67     public void fromString(String JavaDoc v)
68     {
69         for (int i = 0; i < comboChoices.length; ++i)
70         {
71             if (comboChoices[i].equals(v))
72             {
73                 m_val = i;
74             }
75         }
76     }
77
78     public String JavaDoc toString()
79     {
80         return comboChoices[m_val].toString();
81     }
82
83     public int val()
84     {
85         return m_val;
86     }
87
88     private int m_val = 0;
89 }
90
Popular Tags