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 */ 016package org.opengion.hayabusa.io; 017 018import org.jfree.chart.axis.NumberAxis; 019import org.jfree.data.Range; 020 021/** 022 * HybsNumberAxis は、NumberAxis を継承した、縦軸レンジのチック幅指定クラスです。 023 * 従来の NumberAxis では、0 から、NumberTickUnit で設定した サイズを刻みます。 024 * 例えば、lowerBound=200 , upperBound=7000 で、tickSize=900 とすると、 025 * 空白、900,1800,2700・・ と設定されます。 026 * 実際に行いたいのは、200,1100,2000・・ という、最小値から始まり、刻み幅を 900 に 027 * するという表示です。 028 * 029 * @og.rev 4.1.1.0 (2008/02/04) 新規作成 030 * 031 * @version 0.9.0 2008/02/04 032 * @author Kazuhiko Hasegawa 033 * @since JDK1.1, 034 */ 035public class HybsNumberAxis extends NumberAxis { 036 private static final long serialVersionUID = 411020080204L ; 037 038 /** 039 * ラベルを指定した、コンストラクター 040 * 041 * 親クラスに委譲しています。 042 * 043 * @param label ラベル 044 */ 045 public HybsNumberAxis( final String label ) { 046 super(label); 047 } 048 049 /** 050 * 軸の上の最小の表示されるチックの値を計算します。 051 * 052 * @return 軸の上の最小のチックの値 053 * 054 * @see #calculateHighestVisibleTickValue() 055 */ 056 @Override 057 protected double calculateLowestVisibleTickValue() { 058 059 // double unit = getTickUnit().getSize(); 060 // double index = Math.ceil(getRange().getLowerBound() / unit); 061 // return index * unit; 062 return getRange().getLowerBound() ; 063 } 064 065 /** 066 * 表示されるチックの数を計算します。 067 * 068 * @return 軸の上の表示されるチックの数 069 */ 070 @Override 071 protected int calculateVisibleTickCount() { 072 073 final double unit = getTickUnit().getSize(); 074 final Range range = getRange(); 075 // return (int) (Math.floor(range.getUpperBound() / unit) 076 // - Math.ceil(range.getLowerBound() / unit) + 1); 077 078 return (int)Math.ceil( ( range.getUpperBound() - range.getLowerBound() + 1.0 ) / unit ); 079 } 080}