Frames | No Frames |
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 20: * License along with this library; if not, write to the Free Software 21: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 22: * USA. 23: * 24: * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 25: * in the United States and other countries.] 26: * 27: * -------------------------- 28: * DatasetRenderingOrder.java 29: * -------------------------- 30: * (C) Copyright 2003-2005, by Object Refinery Limited. 31: * 32: * Original Author: David Gilbert (for Object Refinery Limited); 33: * Contributor(s): -; 34: * 35: * $Id: DatasetRenderingOrder.java,v 1.4.2.1 2005/10/25 20:52:07 mungady Exp $ 36: * 37: * Changes: 38: * -------- 39: * 02-May-2003 : Version 1 (DG); 40: * 02-Jun-2004 : Changed 'STANDARD' --> 'FORWARD' (DG); 41: * 42: */ 43: 44: package org.jfree.chart.plot; 45: 46: import java.io.ObjectStreamException; 47: import java.io.Serializable; 48: 49: /** 50: * Defines the tokens that indicate the rendering order for datasets in a 51: * {@link org.jfree.chart.plot.CategoryPlot} or an 52: * {@link org.jfree.chart.plot.XYPlot}. 53: */ 54: public final class DatasetRenderingOrder implements Serializable { 55: 56: /** For serialization. */ 57: private static final long serialVersionUID = -600593412366385072L; 58: 59: /** 60: * Render datasets in the order 0, 1, 2, ..., N-1, where N is the number 61: * of datasets. 62: */ 63: public static final DatasetRenderingOrder FORWARD 64: = new DatasetRenderingOrder("DatasetRenderingOrder.FORWARD"); 65: 66: /** 67: * Render datasets in the order N-1, N-2, ..., 2, 1, 0, where N is the 68: * number of datasets. 69: */ 70: public static final DatasetRenderingOrder REVERSE 71: = new DatasetRenderingOrder("DatasetRenderingOrder.REVERSE"); 72: 73: /** The name. */ 74: private String name; 75: 76: /** 77: * Private constructor. 78: * 79: * @param name the name. 80: */ 81: private DatasetRenderingOrder(String name) { 82: this.name = name; 83: } 84: 85: /** 86: * Returns a string representing the object. 87: * 88: * @return The string (never <code>null</code>). 89: */ 90: public String toString() { 91: return this.name; 92: } 93: 94: /** 95: * Returns <code>true</code> if this object is equal to the specified 96: * object, and <code>false</code> otherwise. 97: * 98: * @param o the other object. 99: * 100: * @return A boolean. 101: */ 102: public boolean equals(Object o) { 103: 104: if (this == o) { 105: return true; 106: } 107: if (!(o instanceof DatasetRenderingOrder)) { 108: return false; 109: } 110: 111: DatasetRenderingOrder order = (DatasetRenderingOrder) o; 112: if (!this.name.equals(order.toString())) { 113: return false; 114: } 115: 116: return true; 117: 118: } 119: 120: /** 121: * Ensures that serialization returns the unique instances. 122: * 123: * @return The object. 124: * 125: * @throws ObjectStreamException if there is a problem. 126: */ 127: private Object readResolve() throws ObjectStreamException { 128: if (this.equals(DatasetRenderingOrder.FORWARD)) { 129: return DatasetRenderingOrder.FORWARD; 130: } 131: else if (this.equals(DatasetRenderingOrder.REVERSE)) { 132: return DatasetRenderingOrder.REVERSE; 133: } 134: return null; 135: } 136: 137: }