001/* =========================================================== 002 * JFreeChart : a free chart library for the Java(tm) platform 003 * =========================================================== 004 * 005 * (C) Copyright 2000-present, by David Gilbert 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-present, by David Gilbert and Contributors. 031 * 032 * Original Author: David Gilbert; 033 * Contributor(s): -; 034 */ 035 036package org.jfree.chart.plot; 037 038import java.io.ObjectStreamException; 039import java.io.Serializable; 040 041/** 042 * Used to indicate the location of an axis on a {@link PolarPlot}. 043 */ 044public final class PolarAxisLocation implements Serializable { 045 046 /** For serialization. */ 047 private static final long serialVersionUID = -3276922179323563410L; 048 049 /** Axis left of north. */ 050 public static final PolarAxisLocation NORTH_LEFT 051 = new PolarAxisLocation("PolarAxisLocation.NORTH_LEFT"); 052 053 /** Axis right of north. */ 054 public static final PolarAxisLocation NORTH_RIGHT 055 = new PolarAxisLocation("PolarAxisLocation.NORTH_RIGHT"); 056 057 /** Axis left of south. */ 058 public static final PolarAxisLocation SOUTH_LEFT 059 = new PolarAxisLocation("PolarAxisLocation.SOUTH_LEFT"); 060 061 /** Axis right of south. */ 062 public static final PolarAxisLocation SOUTH_RIGHT 063 = new PolarAxisLocation("PolarAxisLocation.SOUTH_RIGHT"); 064 065 /** Axis above east. */ 066 public static final PolarAxisLocation EAST_ABOVE 067 = new PolarAxisLocation("PolarAxisLocation.EAST_ABOVE"); 068 069 /** Axis below east. */ 070 public static final PolarAxisLocation EAST_BELOW 071 = new PolarAxisLocation("PolarAxisLocation.EAST_BELOW"); 072 073 /** Axis above west. */ 074 public static final PolarAxisLocation WEST_ABOVE 075 = new PolarAxisLocation("PolarAxisLocation.WEST_ABOVE"); 076 077 /** Axis below west. */ 078 public static final PolarAxisLocation WEST_BELOW 079 = new PolarAxisLocation("PolarAxisLocation.WEST_BELOW"); 080 081 /** The name. */ 082 private String name; 083 084 /** 085 * Private constructor. 086 * 087 * @param name the name. 088 */ 089 private PolarAxisLocation(String name) { 090 this.name = name; 091 } 092 093 /** 094 * Returns a string representing the object. 095 * 096 * @return The string. 097 */ 098 @Override 099 public String toString() { 100 return this.name; 101 } 102 103 /** 104 * Returns {@code true} if this object is equal to the specified 105 * object, and {@code false} otherwise. 106 * 107 * @param obj the other object ({@code null} permitted). 108 * 109 * @return A boolean. 110 */ 111 @Override 112 public boolean equals(Object obj) { 113 if (obj == this) { 114 return true; 115 } 116 if (!(obj instanceof PolarAxisLocation)) { 117 return false; 118 } 119 PolarAxisLocation location = (PolarAxisLocation) obj; 120 if (!this.name.equals(location.toString())) { 121 return false; 122 } 123 return true; 124 } 125 126 /** 127 * Ensures that serialization returns the unique instances. 128 * 129 * @return The object. 130 * 131 * @throws ObjectStreamException if there is a problem. 132 */ 133 private Object readResolve() throws ObjectStreamException { 134 if (this.equals(PolarAxisLocation.NORTH_RIGHT)) { 135 return PolarAxisLocation.NORTH_RIGHT; 136 } 137 else if (this.equals(PolarAxisLocation.NORTH_LEFT)) { 138 return PolarAxisLocation.NORTH_LEFT; 139 } 140 else if (this.equals(PolarAxisLocation.SOUTH_RIGHT)) { 141 return PolarAxisLocation.SOUTH_RIGHT; 142 } 143 else if (this.equals(PolarAxisLocation.SOUTH_LEFT)) { 144 return PolarAxisLocation.SOUTH_LEFT; 145 } 146 else if (this.equals(PolarAxisLocation.EAST_ABOVE)) { 147 return PolarAxisLocation.EAST_ABOVE; 148 } 149 else if (this.equals(PolarAxisLocation.EAST_BELOW)) { 150 return PolarAxisLocation.EAST_BELOW; 151 } 152 else if (this.equals(PolarAxisLocation.WEST_ABOVE)) { 153 return PolarAxisLocation.WEST_ABOVE; 154 } 155 else if (this.equals(PolarAxisLocation.WEST_BELOW)) { 156 return PolarAxisLocation.WEST_BELOW; 157 } 158 return null; 159 } 160 161}