| 1 | /* |
| 2 | * CustomAxis.java |
| 3 | * |
| 4 | * Copyright (c) 2002-2017 Alexei Drummond, Andrew Rambaut and Marc Suchard |
| 5 | * |
| 6 | * This file is part of BEAST. |
| 7 | * See the NOTICE file distributed with this work for additional |
| 8 | * information regarding copyright ownership and licensing. |
| 9 | * |
| 10 | * BEAST is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU Lesser General Public License as |
| 12 | * published by the Free Software Foundation; either version 2 |
| 13 | * of the License, or (at your option) any later version. |
| 14 | * |
| 15 | * BEAST is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU Lesser General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU Lesser General Public |
| 21 | * License along with BEAST; if not, write to the |
| 22 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, |
| 23 | * Boston, MA 02110-1301 USA |
| 24 | */ |
| 25 | |
| 26 | package dr.app.gui.chart; |
| 27 | |
| 28 | /** |
| 29 | * @author Guy Baele |
| 30 | */ |
| 31 | |
| 32 | public class CustomAxis extends Axis.AbstractAxis { |
| 33 | |
| 34 | /** |
| 35 | * Empty constructor |
| 36 | */ |
| 37 | public CustomAxis() { |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Axis flag constructor |
| 42 | */ |
| 43 | public CustomAxis(int minAxisFlag, int maxAxisFlag) { |
| 44 | setAxisFlags(minAxisFlag, maxAxisFlag); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Transform a value |
| 49 | */ |
| 50 | public double transform(double value) { |
| 51 | return value; // a linear transform ! |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Untransform a value |
| 56 | */ |
| 57 | public double untransform(double value) { |
| 58 | return value; // a linear transform ! |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Set the range of the data |
| 63 | */ |
| 64 | public void setRange(double minValue, double maxValue) { |
| 65 | if (!Double.isNaN(minValue)) { |
| 66 | this.minData = minValue; |
| 67 | this.minAxisFlag = (int)minValue; |
| 68 | } |
| 69 | if (!Double.isNaN(maxValue)) { |
| 70 | this.maxData = maxValue; |
| 71 | this.maxAxisFlag = (int)maxValue; |
| 72 | } |
| 73 | |
| 74 | isCalibrated = false; |
| 75 | } |
| 76 | |
| 77 | public void calibrate() { |
| 78 | |
| 79 | //do nothing |
| 80 | majorTick=1; |
| 81 | minorTick=1; |
| 82 | |
| 83 | minTick=minAxisFlag; |
| 84 | maxTick=maxAxisFlag; |
| 85 | |
| 86 | majorTickCount = (int)((maxTick-minTick+1)/majorTick); |
| 87 | minorTickCount = 0; |
| 88 | |
| 89 | minAxis=minTick-0.5; |
| 90 | maxAxis=maxTick+0.5; |
| 91 | |
| 92 | } |
| 93 | |
| 94 | } |
| 95 |