001/* =========================================================== 002 * JFreeChart : a free chart library for the Java(tm) platform 003 * =========================================================== 004 * 005 * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. 006 * 007 * Project Info: http://www.jfree.org/jfreechart/index.html 008 * 009 * This library is free software; you can redistribute it and/or modify it 010 * under the terms of the GNU Lesser General Public License as published by 011 * the Free Software Foundation; either version 2.1 of the License, or 012 * (at your option) any later version. 013 * 014 * This library is distributed in the hope that it will be useful, but 015 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 016 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 017 * License for more details. 018 * 019 * You should have received a copy of the GNU Lesser General Public 020 * License along with this library; if not, write to the Free Software 021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 022 * USA. 023 * 024 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. 025 * Other names may be trademarks of their respective owners.] 026 * 027 * ---------------------- 028 * PolarAxisLocation.java 029 * ---------------------- 030 * (C) Copyright 2009, by Object Refinery Limited and Contributors. 031 * 032 * Original Author: David Gilbert (for Object Refinery Limited); 033 * Contributor(s): -; 034 * 035 * Changes: 036 * -------- 037 * 25-Nov-2009 : Version 1 (DG); 038 * 039 */ 040 041package org.jfree.chart.plot; 042 043import java.io.ObjectStreamException; 044import java.io.Serializable; 045 046/** 047 * Used to indicate the location of an axis on a {@link PolarPlot}. 048 * 049 * @since 1.0.14 050 */ 051public final class PolarAxisLocation implements Serializable { 052 053 /** For serialization. */ 054 private static final long serialVersionUID = -3276922179323563410L; 055 056 /** Axis left of north. */ 057 public static final PolarAxisLocation NORTH_LEFT 058 = new PolarAxisLocation("PolarAxisLocation.NORTH_LEFT"); 059 060 /** Axis right of north. */ 061 public static final PolarAxisLocation NORTH_RIGHT 062 = new PolarAxisLocation("PolarAxisLocation.NORTH_RIGHT"); 063 064 /** Axis left of south. */ 065 public static final PolarAxisLocation SOUTH_LEFT 066 = new PolarAxisLocation("PolarAxisLocation.SOUTH_LEFT"); 067 068 /** Axis right of south. */ 069 public static final PolarAxisLocation SOUTH_RIGHT 070 = new PolarAxisLocation("PolarAxisLocation.SOUTH_RIGHT"); 071 072 /** Axis above east. */ 073 public static final PolarAxisLocation EAST_ABOVE 074 = new PolarAxisLocation("PolarAxisLocation.EAST_ABOVE"); 075 076 /** Axis below east. */ 077 public static final PolarAxisLocation EAST_BELOW 078 = new PolarAxisLocation("PolarAxisLocation.EAST_BELOW"); 079 080 /** Axis above west. */ 081 public static final PolarAxisLocation WEST_ABOVE 082 = new PolarAxisLocation("PolarAxisLocation.WEST_ABOVE"); 083 084 /** Axis below west. */ 085 public static final PolarAxisLocation WEST_BELOW 086 = new PolarAxisLocation("PolarAxisLocation.WEST_BELOW"); 087 088 /** The name. */ 089 private String name; 090 091 /** 092 * Private constructor. 093 * 094 * @param name the name. 095 */ 096 private PolarAxisLocation(String name) { 097 this.name = name; 098 } 099 100 /** 101 * Returns a string representing the object. 102 * 103 * @return The string. 104 */ 105 @Override 106 public String toString() { 107 return this.name; 108 } 109 110 /** 111 * Returns <code>true</code> if this object is equal to the specified 112 * object, and <code>false</code> otherwise. 113 * 114 * @param obj the other object (<code>null</code> permitted). 115 * 116 * @return A boolean. 117 */ 118 @Override 119 public boolean equals(Object obj) { 120 if (obj == this) { 121 return true; 122 } 123 if (!(obj instanceof PolarAxisLocation)) { 124 return false; 125 } 126 PolarAxisLocation location = (PolarAxisLocation) obj; 127 if (!this.name.equals(location.toString())) { 128 return false; 129 } 130 return true; 131 } 132 133 /** 134 * Ensures that serialization returns the unique instances. 135 * 136 * @return The object. 137 * 138 * @throws ObjectStreamException if there is a problem. 139 */ 140 private Object readResolve() throws ObjectStreamException { 141 if (this.equals(PolarAxisLocation.NORTH_RIGHT)) { 142 return PolarAxisLocation.NORTH_RIGHT; 143 } 144 else if (this.equals(PolarAxisLocation.NORTH_LEFT)) { 145 return PolarAxisLocation.NORTH_LEFT; 146 } 147 else if (this.equals(PolarAxisLocation.SOUTH_RIGHT)) { 148 return PolarAxisLocation.SOUTH_RIGHT; 149 } 150 else if (this.equals(PolarAxisLocation.SOUTH_LEFT)) { 151 return PolarAxisLocation.SOUTH_LEFT; 152 } 153 else if (this.equals(PolarAxisLocation.EAST_ABOVE)) { 154 return PolarAxisLocation.EAST_ABOVE; 155 } 156 else if (this.equals(PolarAxisLocation.EAST_BELOW)) { 157 return PolarAxisLocation.EAST_BELOW; 158 } 159 else if (this.equals(PolarAxisLocation.WEST_ABOVE)) { 160 return PolarAxisLocation.WEST_ABOVE; 161 } 162 else if (this.equals(PolarAxisLocation.WEST_BELOW)) { 163 return PolarAxisLocation.WEST_BELOW; 164 } 165 return null; 166 } 167 168}