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 java.util.List; 019 020import org.jfree.data.general.Dataset; 021import org.jfree.data.general.PieDataset; 022// import org.jfree.data.general.ValueDataset; // 5.7.8.0 (2014/07/04) 023import org.jfree.data.category.CategoryDataset; 024import org.jfree.data.xy.XYDataset; 025import org.jfree.chart.plot.Plot; 026import org.jfree.chart.plot.MultiplePiePlot; 027import org.jfree.chart.plot.PiePlot; 028import org.jfree.chart.plot.PiePlot3D; 029import org.jfree.chart.plot.RingPlot; 030import org.jfree.chart.plot.SpiderWebPlot; 031import org.jfree.chart.plot.PolarPlot; 032// import org.jfree.chart.plot.MeterPlot; // 5.7.8.0 (2014/07/04) 033// import org.jfree.chart.plot.ThermometerPlot; // 5.7.8.0 (2014/07/04) 034// import org.jfree.chart.plot.CompassPlot; // 5.7.8.0 (2014/07/04) 035import org.jfree.chart.labels.StandardCategoryToolTipGenerator; 036import 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 */ 048public 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 * @og.rev 5.7.8.0 (2014/07/04) MeterPlot 、Compass 、Thermometer の機能追加 062 * 063 * @param create ChartCreateオブジェクト 064 * 065 * @return Plotオブジェクト 066 */ 067 public Plot getPlot( final ChartCreate create ) { 068 069 List<ChartDataset> datasetList = create.getDatasetList(); 070 ChartDataset chDataset = datasetList.get(0); 071 072 Dataset dtset = chDataset.getDataset(); 073 074 // クリッカブル・マップ 075 HybsURLGenerator urlGen = create.getURLGenerator(); 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( "Pie".equalsIgnoreCase( type ) ) { 085 plot = new PiePlot(); 086 ((PiePlot)plot).setDataset( (PieDataset)dtset ); 087 if( urlGen != null ) { 088 ((PiePlot)plot).setURLGenerator( urlGen ); 089 } 090 if( useToolTip ){ // 4.3.1.0 (2008/08/09) ツールチップスの利用 091 ((PiePlot)plot).setToolTipGenerator( new StandardPieToolTipGenerator() ); 092 } 093 } 094 else if( "Pie3D".equalsIgnoreCase( type ) ) { 095 plot = new PiePlot3D(); 096 ((PiePlot3D)plot).setDataset( (PieDataset)dtset ); 097 if( urlGen != null ) { 098 ((PiePlot)plot).setURLGenerator( urlGen ); 099 } 100 if( useToolTip ){ // 4.3.1.0 (2008/08/09) ツールチップスの利用 101 ((PiePlot)plot).setToolTipGenerator( new StandardPieToolTipGenerator() ); 102 } 103 } 104 else if( "Ring".equalsIgnoreCase( type ) ) { 105 plot = new RingPlot(); 106 ((RingPlot)plot).setDataset( (PieDataset)dtset ); 107 if( urlGen != null ) { 108 ((PiePlot)plot).setURLGenerator( urlGen ); 109 } 110 if( useToolTip ){ // 4.3.1.0 (2008/08/09) ツールチップスの利用 111 ((RingPlot)plot).setToolTipGenerator( new StandardPieToolTipGenerator() ); 112 } 113 } 114 else if( "SpiderWeb".equalsIgnoreCase( type ) ) { 115 plot = new SpiderWebPlot(); 116 ((SpiderWebPlot)plot).setDataset( (CategoryDataset)dtset ); 117 if( urlGen != null ) { 118 ((SpiderWebPlot)plot).setURLGenerator( urlGen ); 119 } 120 if( useToolTip ){ // 4.3.1.0 (2008/08/09) ツールチップスの利用 121 ((SpiderWebPlot)plot).setToolTipGenerator( new StandardCategoryToolTipGenerator() ); 122 } 123 } 124 // 5.3.0.0 (2010/12/01) 特殊プロットの追加 125 else if( "Polar".equalsIgnoreCase( type ) ) { 126 plot = new PolarPlot(); 127 ((PolarPlot)plot).setDataset( (XYDataset)dtset ); 128 } 129 else if( "Meter".equalsIgnoreCase( type ) ) { 130 // 5.7.8.0 (2014/07/04) 機能追加 131 plot = chDataset.makeMeterPlot(); 132// plot = new MeterPlot(); 133// ((MeterPlot)plot).setDataset( (ValueDataset)dtset ); 134 } 135 else if( "Thermometer".equalsIgnoreCase( type ) ) { 136 // 5.7.8.0 (2014/07/04) 機能追加 137 plot = chDataset.makeThermometerPlot(); 138// plot = new ThermometerPlot(); 139// ((ThermometerPlot)plot).setDataset( (ValueDataset)dtset ); 140 } 141 else if( "Compass".equalsIgnoreCase( type ) ) { 142 // 5.7.8.0 (2014/07/04) 機能追加 143 plot = chDataset.makeCompassPlot(); 144// plot = new CompassPlot(); 145// ((CompassPlot)plot).addDataset( (ValueDataset)dtset ); 146 } 147 148 return plot; 149 } 150}