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 java.util.List;
019
020 import org.jfree.data.general.Dataset;
021 import org.jfree.data.general.PieDataset;
022 import org.jfree.data.general.ValueDataset;
023 import org.jfree.data.category.CategoryDataset;
024 import org.jfree.data.xy.XYDataset;
025 import org.jfree.chart.plot.Plot;
026 import org.jfree.chart.plot.MultiplePiePlot;
027 import org.jfree.chart.plot.MeterPlot;
028 import org.jfree.chart.plot.PiePlot;
029 import org.jfree.chart.plot.PiePlot3D;
030 import org.jfree.chart.plot.RingPlot;
031 import org.jfree.chart.plot.SpiderWebPlot;
032 import org.jfree.chart.plot.ThermometerPlot;
033 import org.jfree.chart.plot.PolarPlot;
034 import org.jfree.chart.plot.CompassPlot;
035 import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
036 import org.jfree.chart.labels.StandardPieToolTipGenerator;
037
038 /**
039 * ChartPlot_Pie は、ChartPlot インターフェースを継承した実体クラスです?
040 * JFreeChart では、各種オブジェクト??合わせで、色?グラフを作?できます?
041 * チャートタイプが、?種類存在するため、ここでは、特殊な方法として、各タイプ毎に
042 * オブジェクトを構築して?す?(ファクトリメソ??処?
043 *
044 * @version 0.9.0 2007/06/21
045 * @author Kazuhiko Hasegawa
046 * @since JDK1.1,
047 */
048 public class ChartPlot_Pie implements ChartPlot {
049
050 /**
051 * Plot オブジェクトを取得します?
052 *
053 * Plot オブジェク?には、その種類?応じた???タセ??ン?ー?
054 * 設定する?があります?
055 * また??の??タセ???それに関係する属???も?設定する?が
056 * あります?
057 * Plot は、JFreeChart オブジェクトにつき??用意しなければなりません?
058 * チャート合成時でも?Plot は?です?
059 *
060 * @og.rev 5.3.0.0 (2010/12/01) 特殊?ロ?の追?
061 *
062 * @param create ChartCreateオブジェク?
063 *
064 * @return Plotオブジェク?
065 */
066 public Plot getPlot( final ChartCreate create ) {
067
068 List<ChartDataset> datasetList = create.getDatasetList();
069 ChartDataset chDataset = datasetList.get(0);
070
071 Dataset dtset = chDataset.getDataset();
072
073 // クリ?ブル・マッ?
074 HybsURLGenerator urlGen = create.getURLGenerator();
075 // boolean useToolTip = create.getUseToolTip(); // 4.3.1.0 (2008/08/09) ??ルチップス利用フラグ
076 boolean useToolTip = create.isUseToolTip(); // 4.9.9.9 (2009/08/07) メソ?名変更
077
078 Plot plot = null;
079 String type = chDataset.getChartType();
080 if( "MultiplePie".equalsIgnoreCase( type ) ) {
081 plot = new MultiplePiePlot();
082 ((MultiplePiePlot)plot).setDataset( (CategoryDataset)dtset );
083 }
084 else if( "Meter".equalsIgnoreCase( type ) ) {
085 plot = new MeterPlot();
086 ((MeterPlot)plot).setDataset( (ValueDataset)dtset );
087 }
088 else if( "Pie".equalsIgnoreCase( type ) ) {
089 plot = new PiePlot();
090 ((PiePlot)plot).setDataset( (PieDataset)dtset );
091 if( urlGen != null ) {
092 ((PiePlot)plot).setURLGenerator( urlGen );
093 }
094 if( useToolTip ){ // 4.3.1.0 (2008/08/09) ??ルチップスの利用
095 ((PiePlot)plot).setToolTipGenerator( new StandardPieToolTipGenerator() );
096 }
097 }
098 else if( "Pie3D".equalsIgnoreCase( type ) ) {
099 plot = new PiePlot3D();
100 ((PiePlot3D)plot).setDataset( (PieDataset)dtset );
101 if( urlGen != null ) {
102 ((PiePlot)plot).setURLGenerator( urlGen );
103 }
104 if( useToolTip ){ // 4.3.1.0 (2008/08/09) ??ルチップスの利用
105 ((PiePlot)plot).setToolTipGenerator( new StandardPieToolTipGenerator() );
106 }
107 }
108 else if( "Ring".equalsIgnoreCase( type ) ) {
109 plot = new RingPlot();
110 ((RingPlot)plot).setDataset( (PieDataset)dtset );
111 if( urlGen != null ) {
112 ((PiePlot)plot).setURLGenerator( urlGen );
113 }
114 if( useToolTip ){ // 4.3.1.0 (2008/08/09) ??ルチップスの利用
115 ((RingPlot)plot).setToolTipGenerator( new StandardPieToolTipGenerator() );
116 }
117 }
118 else if( "SpiderWeb".equalsIgnoreCase( type ) ) {
119 plot = new SpiderWebPlot();
120 ((SpiderWebPlot)plot).setDataset( (CategoryDataset)dtset );
121 if( urlGen != null ) {
122 ((SpiderWebPlot)plot).setURLGenerator( urlGen );
123 }
124 if( useToolTip ){ // 4.3.1.0 (2008/08/09) ??ルチップスの利用
125 ((SpiderWebPlot)plot).setToolTipGenerator( new StandardCategoryToolTipGenerator() );
126 }
127 }
128 else if( "Thermometer".equalsIgnoreCase( type ) ) {
129 plot = new ThermometerPlot();
130 ((ThermometerPlot)plot).setDataset( (ValueDataset)dtset );
131 }
132 // 5.3.0.0 (2010/12/01) 特殊?ロ?の追?
133 else if( "Polar".equalsIgnoreCase( type ) ) {
134 plot = new PolarPlot();
135 ((PolarPlot)plot).setDataset( (XYDataset)dtset );
136 }
137 else if( "Compass".equalsIgnoreCase( type ) ) {
138 plot = new CompassPlot();
139 ((CompassPlot)plot).addDataset( (ValueDataset)dtset );
140 }
141
142 return plot;
143 }
144 }