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