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    import org.opengion.fukurou.util.StringUtil;
019    import org.opengion.hayabusa.common.HybsSystem;
020    import org.opengion.hayabusa.common.HybsSystemException;
021    import org.opengion.hayabusa.db.DBTableModel;
022    
023    import java.sql.Connection;
024    import java.sql.SQLException;
025    import java.util.Map;
026    import java.util.HashMap;
027    import java.util.Arrays;
028    
029    import org.jfree.chart.LegendItemSource;
030    import org.jfree.data.jdbc.JDBCPieDataset;
031    import org.jfree.data.jdbc.JDBCXYDataset;
032    import org.jfree.data.general.Dataset;
033    import org.jfree.data.general.DefaultValueDataset;
034    
035    import org.jfree.data.category.DefaultCategoryDataset;
036    import org.jfree.data.xy.CategoryTableXYDataset;
037    import org.jfree.data.general.DefaultPieDataset;
038    import 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     */
049    final 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    }