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