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 018 019import org.jfree.chart.axis.NumberAxis; 020import org.jfree.data.Range; 021 022/** 023 * HybsNumberAxis は、NumberAxis を継承した、縦軸レンジのチック幅指定クラスです。 024 * 従来の NumberAxis では、0 から、NumberTickUnit で設定した サイズを刻みます。 025 * 例えば、lowerBound=200 , upperBound=7000 で、tickSize=900 とすると、 026 * 空白、900,1800,2700・・ と設定されます。 027 * 実際に行いたいのは、200,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 */ 036public 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( ( range.getUpperBound() - range.getLowerBound() + 1.0 ) / unit ); 081 } 082}