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    }