Frames | No Frames |
1: /* =========================================================== 2: * JFreeChart : a free chart library for the Java(tm) platform 3: * =========================================================== 4: * 5: * (C) Copyright 2000-2007, 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: * AxisState.java 29: * -------------- 30: * (C) Copyright 2003-2007, by Object Refinery Limited and Contributors. 31: * 32: * Original Author: David Gilbert (for Object Refinery Limited); 33: * Contributor(s): -; 34: * 35: * Changes 36: * ------- 37: * 03-Nov-2003 : Added standard header (DG); 38: * 07-Nov-2003 : Added 'max' attribute (DG); 39: * 40: */ 41: 42: package org.jfree.chart.axis; 43: 44: import java.util.List; 45: 46: import org.jfree.ui.RectangleEdge; 47: 48: /** 49: * Instances of this class are used to carry state information for an axis 50: * during the drawing process. By retaining this information in a separate 51: * object, it is possible for multiple threads to draw the same axis to 52: * different output targets (each drawing will maintain separate state 53: * information). 54: */ 55: public class AxisState { 56: 57: /** The cursor position. */ 58: private double cursor; 59: 60: /** The axis ticks. */ 61: private List ticks; 62: 63: /** The maximum width/height. */ 64: private double max; 65: 66: /** 67: * Creates a new axis state. 68: */ 69: public AxisState() { 70: this(0.0); 71: } 72: 73: /** 74: * Creates a new axis state. 75: * 76: * @param cursor the cursor. 77: */ 78: public AxisState(double cursor) { 79: this.cursor = cursor; 80: this.ticks = new java.util.ArrayList(); 81: } 82: 83: /** 84: * Returns the cursor position. 85: * 86: * @return The cursor position. 87: */ 88: public double getCursor() { 89: return this.cursor; 90: } 91: 92: /** 93: * Sets the cursor position. 94: * 95: * @param cursor the cursor position. 96: */ 97: public void setCursor(double cursor) { 98: this.cursor = cursor; 99: } 100: 101: /** 102: * Moves the cursor outwards by the specified number of units. 103: * 104: * @param units the units. 105: * @param edge the edge. 106: */ 107: public void moveCursor(double units, RectangleEdge edge) { 108: if (edge == RectangleEdge.TOP) { 109: cursorUp(units); 110: } 111: else if (edge == RectangleEdge.BOTTOM) { 112: cursorDown(units); 113: } 114: else if (edge == RectangleEdge.LEFT) { 115: cursorLeft(units); 116: } 117: else if (edge == RectangleEdge.RIGHT) { 118: cursorRight(units); 119: } 120: } 121: 122: /** 123: * Moves the cursor up by the specified number of Java 2D units. 124: * 125: * @param units the units. 126: */ 127: public void cursorUp(double units) { 128: this.cursor = this.cursor - units; 129: } 130: 131: /** 132: * Moves the cursor down by the specified number of Java 2D units. 133: * 134: * @param units the units. 135: */ 136: public void cursorDown(double units) { 137: this.cursor = this.cursor + units; 138: } 139: 140: /** 141: * Moves the cursor left by the specified number of Java 2D units. 142: * 143: * @param units the units. 144: */ 145: public void cursorLeft(double units) { 146: this.cursor = this.cursor - units; 147: } 148: 149: /** 150: * Moves the cursor right by the specified number of Java 2D units. 151: * 152: * @param units the units. 153: */ 154: public void cursorRight(double units) { 155: this.cursor = this.cursor + units; 156: } 157: 158: /** 159: * Returns the list of ticks. 160: * 161: * @return The list of ticks. 162: */ 163: public List getTicks() { 164: return this.ticks; 165: } 166: 167: /** 168: * Sets the list of ticks. 169: * 170: * @param ticks the ticks. 171: */ 172: public void setTicks(List ticks) { 173: this.ticks = ticks; 174: } 175: 176: /** 177: * Returns the maximum width/height. 178: * 179: * @return The maximum width/height. 180: */ 181: public double getMax() { 182: return this.max; 183: } 184: 185: /** 186: * Sets the maximum width/height. 187: * 188: * @param max the maximum width/height. 189: */ 190: public void setMax(double max) { 191: this.max = max; 192: } 193: }