001    /*
002     * Copyright (c) 2009 The openGion Project.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *     http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
013     * either express or implied. See the License for the specific language
014     * governing permissions and limitations under the License.
015     */
016    package org.opengion.hayabusa.io;
017    
018    
019    import org.jfree.chart.axis.NumberAxis;
020    import org.jfree.data.Range;
021    
022    /**
023     * HybsNumberAxis は、NumberAxis を継承した、縦軸レンジのチックå¹?Œ‡定クラスですã?
024     * 従来の NumberAxis ではã€? から、NumberTickUnit で設定しã�?サイズを刻みますã?
025     * 例えば、lowerBound=200 , upperBound=7000 で、tickSize=900 とするとã€?
026     * 空白ã€?00,1800,2700・・ と設定されますã?
027     * 実際に行いたいのはã€?00,1100,2000・・ とã�?�†、最小å?から始まりã?刻みå¹?‚’ 900 に
028     * するとã�?�†表示ですã?
029     *
030     * @og.rev 4.1.1.0 (2008/02/04) 新規作æ?
031     *
032     * @version  0.9.0      2008/02/04
033     * @author       Kazuhiko Hasegawa
034     * @since        JDK1.1,
035     */
036    public class HybsNumberAxis extends NumberAxis {
037            private static final long serialVersionUID = 411020080204L ;
038    
039            /**
040             * ラベルを指定したã?コンストラクター
041             *
042             * 親クラスに委譲してã�?�¾すã?
043             *
044             * @param       label   ラベル
045             */
046            public HybsNumberAxis( final String label ) {
047                    super(label);
048            }
049    
050            /**
051             * 軸の上ã?æœ?°�ã?表示されるチãƒ?‚¯の値を計算しまã�?
052             *
053             * @return      軸の上ã?æœ?°�ã?チックの値
054             *
055             * @see #calculateHighestVisibleTickValue()
056             */
057            @Override
058            protected double calculateLowestVisibleTickValue() {
059    
060            //      double unit = getTickUnit().getSize();
061            //      double index = Math.ceil(getRange().getLowerBound() / unit);
062            //      return index * unit;
063                    return getRange().getLowerBound() ;
064    
065            }
066    
067            /**
068             * 表示されるチãƒ?‚¯の数を計算しますã?
069             *
070             * @return      軸の上ã?表示されるチãƒ?‚¯の数
071             */
072            @Override
073            protected int calculateVisibleTickCount() {
074    
075                    double unit = getTickUnit().getSize();
076                    Range range = getRange();
077            //      return (int) (Math.floor(range.getUpperBound() / unit)
078            //                                - Math.ceil(range.getLowerBound() / unit) + 1);
079    
080                    return (int)Math.ceil(
081                                                    ( range.getUpperBound() - range.getLowerBound() + 1.0 ) / unit);
082            }
083    }