1. /* ===========================================================
  2. * JFreeChart : a free chart library for the Java(tm) platform
  3. * ===========================================================
  4. *
  5. * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
  6. *
  7. * Project Info: http://www.jfree.org/jfreechart/index.html
  8. *
  9. * This library is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU Lesser General Public License as published by
  11. * the Free Software Foundation; either version 2.1 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This library is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  16. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  17. * License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public License
  20. * along with this library; if not, write to the Free Software Foundation,
  21. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  22. *
  23. * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
  24. * in the United States and other countries.]
  25. *
  26. * ------------------------
  27. * AreaRendererEndType.java
  28. * ------------------------
  29. * (C) Copyright 2004, 2005, by Object Refinery Limited.
  30. *
  31. * Original Author: David Gilbert (for Object Refinery Limited);
  32. * Contributor(s): -;
  33. *
  34. * $Id: AreaRendererEndType.java,v 1.3 2005/02/09 13:57:23 mungady Exp $
  35. *
  36. * Changes:
  37. * --------
  38. * 29-April-2004 : Version 1 (DG);
  39. *
  40. */
  41. package org.jfree.chart.renderer;
  42. import java.io.ObjectStreamException;
  43. import java.io.Serializable;
  44. /**
  45. * An enumeration of the 'end types' for an area renderer.
  46. */
  47. public final class AreaRendererEndType implements Serializable {
  48. /**
  49. * The area tapers from the first or last value down to zero.
  50. */
  51. public static final AreaRendererEndType TAPER = new AreaRendererEndType(
  52. "AreaRendererEndType.TAPER"
  53. );
  54. /**
  55. * The area is truncated at the first or last value.
  56. */
  57. public static final AreaRendererEndType TRUNCATE = new AreaRendererEndType(
  58. "AreaRendererEndType.TRUNCATE"
  59. );
  60. /**
  61. * The area is levelled at the first or last value.
  62. */
  63. public static final AreaRendererEndType LEVEL = new AreaRendererEndType(
  64. "AreaRendererEndType.LEVEL"
  65. );
  66. /** The name. */
  67. private String name;
  68. /**
  69. * Private constructor.
  70. *
  71. * @param name the name.
  72. */
  73. private AreaRendererEndType(String name) {
  74. this.name = name;
  75. }
  76. /**
  77. * Returns a string representing the object.
  78. *
  79. * @return The string.
  80. */
  81. public String toString() {
  82. return this.name;
  83. }
  84. /**
  85. * Returns <code>true</code> if this object is equal to the specified
  86. * object, and <code>false</code> otherwise.
  87. *
  88. * @param o the other object.
  89. *
  90. * @return A boolean.
  91. */
  92. public boolean equals(Object o) {
  93. if (this == o) {
  94. return true;
  95. }
  96. if (!(o instanceof AreaRendererEndType)) {
  97. return false;
  98. }
  99. AreaRendererEndType t = (AreaRendererEndType) o;
  100. if (!this.name.equals(t.toString())) {
  101. return false;
  102. }
  103. return true;
  104. }
  105. /**
  106. * Ensures that serialization returns the unique instances.
  107. *
  108. * @return The object.
  109. *
  110. * @throws ObjectStreamException if there is a problem.
  111. */
  112. private Object readResolve() throws ObjectStreamException {
  113. Object result = null;
  114. if (this.equals(AreaRendererEndType.LEVEL)) {
  115. result = AreaRendererEndType.LEVEL;
  116. }
  117. else if (this.equals(AreaRendererEndType.TAPER)) {
  118. result = AreaRendererEndType.TAPER;
  119. }
  120. else if (this.equals(AreaRendererEndType.TRUNCATE)) {
  121. result = AreaRendererEndType.TRUNCATE;
  122. }
  123. return result;
  124. }
  125. }