PageRenderTime 51ms CodeModel.GetById 13ms RepoModel.GetById 1ms 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
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. package org.gjt.sp.jedit.textarea;
  2. import org.gjt.sp.jedit.jEdit;
  3. /**
  4. * Class for representing AntiAlias values. The following modes are supported:
  5. * none standard lcd subpixel (JDK 1.6 only)
  6. *
  7. * @author ezust
  8. * @since jedit 4.3pre4
  9. */
  10. public class AntiAlias extends Object
  11. {
  12. public static final Object NONE = "none";
  13. public static final Object STANDARD = "standard";
  14. public static final Object SUBPIXEL = "subpixel";
  15. public static final Object comboChoices[] = new Object[] { NONE, STANDARD, SUBPIXEL };
  16. /**
  17. *
  18. * @return a AntiAlias object attached to a jedit property
  19. */
  20. public static AntiAlias appearance()
  21. {
  22. AntiAlias al = new AntiAlias();
  23. return al.load("options.appearance.font.antiAlias");
  24. }
  25. public static AntiAlias textArea()
  26. {
  27. AntiAlias al = new AntiAlias();
  28. return al.load("view.antiAlias");
  29. }
  30. public void set(int newValue)
  31. {
  32. m_val = newValue;
  33. save();
  34. }
  35. public void save()
  36. {
  37. jEdit.setProperty(m_property, toString());
  38. }
  39. public AntiAlias load(String propName)
  40. {
  41. m_property = propName;
  42. fromString(jEdit.getProperty(m_property));
  43. return this;
  44. }
  45. private AntiAlias()
  46. {
  47. }
  48. public AntiAlias(boolean isEnabled)
  49. {
  50. m_val = isEnabled ? 1 : 0;
  51. }
  52. public AntiAlias(int val)
  53. {
  54. m_val = val;
  55. }
  56. public AntiAlias(String v)
  57. {
  58. fromString(v);
  59. }
  60. public boolean equals(Object other)
  61. {
  62. return toString().equals(other.toString());
  63. }
  64. public void fromString(String v)
  65. {
  66. for (int i = 0; i < comboChoices.length; ++i)
  67. {
  68. if (comboChoices[i].equals(v))
  69. {
  70. m_val = i;
  71. }
  72. }
  73. }
  74. public String toString()
  75. {
  76. return comboChoices[m_val].toString();
  77. }
  78. public int val()
  79. {
  80. return m_val;
  81. }
  82. private String m_property = null;
  83. private int m_val = 0;
  84. }