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; // 5.7.8.0 (2014/07/04) 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.PiePlot; 028 import org.jfree.chart.plot.PiePlot3D; 029 import org.jfree.chart.plot.RingPlot; 030 import org.jfree.chart.plot.SpiderWebPlot; 031 import 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) 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 * @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 }