001/* =========================================================== 002 * JFreeChart : a free chart library for the Java(tm) platform 003 * =========================================================== 004 * 005 * (C) Copyright 2000-2022, 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 * AxisLocation.java 029 * ----------------- 030 * (C) Copyright 2003-2022, by David Gilbert and Contributors. 031 * 032 * Original Author: David Gilbert; 033 * Contributor(s): Nick Guenther, Tracy Hiltbrand; 034 * 035 */ 036 037package org.jfree.chart.axis; 038 039import org.jfree.chart.internal.Args; 040 041/** 042 * Used to indicate the location of an axis on a 2D plot, prior to knowing the 043 * orientation of the plot. 044 */ 045public enum AxisLocation { 046 047 /** Axis at the top or left. */ 048 TOP_OR_LEFT, 049 050 /** Axis at the top or right. */ 051 TOP_OR_RIGHT, 052 053 /** Axis at the bottom or left. */ 054 BOTTOM_OR_LEFT, 055 056 /** Axis at the bottom or right. */ 057 BOTTOM_OR_RIGHT; 058 059 /** 060 * Returns the location that is opposite to this location. 061 * 062 * @return The opposite location. 063 */ 064 public AxisLocation getOpposite() { 065 return getOpposite(this); 066 } 067 068 /** 069 * Returns the location that is opposite to the supplied location. 070 * 071 * @param location the location ({@code null} not permitted). 072 * 073 * @return The opposite location. 074 */ 075 public static AxisLocation getOpposite(AxisLocation location) { 076 Args.nullNotPermitted(location, "location"); 077 switch (location) { 078 case TOP_OR_LEFT: 079 return AxisLocation.BOTTOM_OR_RIGHT; 080 case TOP_OR_RIGHT: 081 return AxisLocation.BOTTOM_OR_LEFT; 082 case BOTTOM_OR_LEFT: 083 return AxisLocation.TOP_OR_RIGHT; 084 case BOTTOM_OR_RIGHT: 085 return AxisLocation.TOP_OR_LEFT; 086 default: 087 throw new IllegalStateException("AxisLocation not recognised."); 088 } 089 } 090 091}