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.opengion.fukurou.util.StringUtil; 019 020import org.jfree.chart.LegendItemSource; 021 022/** 023 * 引数タイプに応じたレンデラーやデータセットを管理します。 024 * 025 * タイプ、レンデラー、データセット の組み合わせで、構築するオブジェクトが異なります。 026 * 027 * @version 0.9.0 2007/06/21 028 * @author Kazuhiko Hasegawa 029 * @since JDK1.1, 030 */ 031final class TypeRenderer { 032 private static final String REND_CLASS = "org.jfree.chart.renderer." ; 033 private static final String HYBS_CLASS = "org.opengion.hayabusa.io." ; // 4.1.1.0 (2008/02/04) 034 035 private final String type ; 036 private final String rend ; // org.jfree.chart.renderer 以降の文字列 037 private final String dtset ; // org.opengion.hayabusa.io 以降の文字列 038 private final String plot ; // 以降の文字列 039 040 /** 041 * TypeRenderer オブジェクトを作成します。 042 * 043 * チャートタイプ は、外部からチャートを指定するのに便利なように、キー化 044 * されています。このキーに基づいて、ChartFactory クラスの 045 * チャートタイプ変換表に基づいて、レンデラーや、データセットを作成します。 046 * このクラスは、これらの変換表の個々の属性を管理しています。 047 * 048 * @og.rev 5.3.0.0 (2010/12/01) plot 追加 049 * 050 * @param type チャートのタイプを区別する文字列 051 * @param renderer チャートのタイプに応じたレンデラーのキー文字列 052 * @param dtset チャートのタイプに応じたデータセットのキー文字列 053 * @param plot チャートのタイプに応じたプロットのキー文字列 054 */ 055 public TypeRenderer( final String type,final String renderer,final String dtset,final String plot ) { 056 this.type = type ; 057 this.rend = renderer ; 058 this.dtset = dtset ; 059 this.plot = plot ; // 5.3.0.0 (2010/12/01) plot 追加 060 } 061 062 /** 063 * チャートのタイプを区別する文字列を返します。 064 * 065 * @return チャートのタイプを区別する文字列 066 */ 067 public String getType() { return type; } 068 069 /** 070 * チャートのタイプに応じたレンデラーのキー文字列を返します。 071 * 072 * @return チャートのタイプに応じたレンデラーのキー文字列 073 */ 074 public String getRendererType() { return rend; } 075 076 /** 077 * チャートのタイプに応じたレンデラーオブジェクトを返します。 078 * 079 * org.jfree.chart.renderer パッケージのサブモジュールのレンデラークラスを 080 * 先に登録してある レンデラーのキー文字列 と合成して、クラスを動的に作成します。 081 * 082 * @og.rev 4.1.1.0 (2008/02/04) Barチャート追加 083 * @og.rev 5.3.0.0 (2010/12/01) レンデラーが null の場合の対応 084 * 085 * @return LegendItemSource チャートのタイプに応じたレンデラーオブジェクト(存在しない場合は、null) 086 */ 087 public LegendItemSource getRenderer() { 088 if( rend == null ) { return null; } // 5.3.0.0 (2010/12/01) 089 090 String key ; 091 if( type.startsWith( "Hybs" ) ) { 092 key = HYBS_CLASS + rend ; 093 } 094 else { 095 key = REND_CLASS + rend ; 096 } 097 098 return (LegendItemSource)StringUtil.newInstance( key ) ; 099 } 100 101 /** 102 * チャートのタイプに応じたデータセットのキー文字列を返します。 103 * 104 * @return チャートのタイプに応じたデータセットのキー文字列 105 */ 106 public String getDatasetType() { return dtset; } 107 108 /** 109 * チャートのタイプに応じたプロットのキー文字列を返します。 110 * 111 * @og.rev 5.3.0.0 (2010/12/01) 新規追加 112 * 113 * @return チャートのタイプに応じたプロットのキー文字列 114 */ 115 public String getPlotType() { return plot; } 116}