PageRenderTime 101ms CodeModel.GetById 79ms app.highlight 11ms RepoModel.GetById 4ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/org/gjt/sp/jedit/textarea/AntiAlias.java

#
Java | 106 lines | 73 code | 22 blank | 11 comment | 2 complexity | fa005f08c0b32386cc41c220271c3076 MD5 | raw file
  1package org.gjt.sp.jedit.textarea;
  2
  3import org.gjt.sp.jedit.jEdit;
  4
  5/**
  6 * Class for representing AntiAlias values. The following modes are supported:
  7 * none standard lcd subpixel (JDK 1.6 only)
  8 * 
  9 * @author ezust
 10 * @since jedit 4.3pre4
 11 */
 12public class AntiAlias extends Object
 13{
 14	public static final Object NONE = "none";
 15
 16	public static final Object STANDARD = "standard";
 17
 18	public static final Object SUBPIXEL = "subpixel";
 19
 20	public static final Object comboChoices[] = new Object[] { NONE, STANDARD, SUBPIXEL };
 21
 22	/**
 23	 * 
 24	 * @return a AntiAlias object attached to a jedit property
 25	 */
 26	public static AntiAlias appearance()
 27	{
 28		AntiAlias al = new AntiAlias();
 29		return al.load("options.appearance.font.antiAlias");
 30	}
 31
 32	public static AntiAlias textArea()
 33	{
 34		AntiAlias al = new AntiAlias();
 35		return al.load("view.antiAlias");
 36		
 37	}
 38
 39	public void set(int newValue)
 40	{
 41		m_val = newValue;
 42		save();
 43	}
 44
 45	public void save()
 46	{
 47		jEdit.setProperty(m_property, toString());
 48	}
 49
 50	public AntiAlias load(String propName)
 51	{
 52		m_property = propName;
 53		fromString(jEdit.getProperty(m_property));
 54		return this;
 55	}
 56
 57	private AntiAlias()
 58	{
 59	}
 60
 61	public AntiAlias(boolean isEnabled)
 62	{
 63		m_val = isEnabled ? 1 : 0;
 64	}
 65
 66	public AntiAlias(int val)
 67	{
 68		m_val = val;
 69	}
 70
 71	public AntiAlias(String v)
 72	{
 73		fromString(v);
 74	}
 75
 76	public boolean equals(Object other)
 77	{
 78		return toString().equals(other.toString());
 79
 80	}
 81
 82	public void fromString(String v)
 83	{
 84		for (int i = 0; i < comboChoices.length; ++i)
 85		{
 86			if (comboChoices[i].equals(v))
 87			{
 88				m_val = i;
 89			}
 90		}
 91	}
 92
 93	public String toString()
 94	{
 95		return comboChoices[m_val].toString();
 96	}
 97
 98	public int val()
 99	{
100		return m_val;
101	}
102
103	private String m_property = null;
104
105	private int m_val = 0;
106}