001package org.opengion.hayabusa.taglib; 002 003import org.opengion.hayabusa.common.HybsSystem; 004import org.opengion.hayabusa.common.HybsSystemException; 005import org.opengion.hayabusa.io.JsChartData; 006 007/** 008 * 設定された値をJsChartDataに設定し、 009 * JsChartTagのJsChartDataリストに追加するタグです。 010 * 011 * @og.formSample 012 * ●形式:<og:jsChartData chartColumn="…" … /> 013 * ●body:なし 014 * 015 * ●Tag定義: 016 * <og:jsChartData 017 * chartColumn ○ 【TAG】チャートのカラム名を指定します。(必須) 018 * label 【TAG】凡例の値を指定します。 019 * fill 【TAG】線下を塗りつぶすかどうか[true/false]を指定します。(初期値:false) 020 * tension 【TAG】線の伸張を指定します。0で直線になります。(初期値:0.4) 021 * borderColor 【TAG】線の色を指定します。 022 * borderWidth 【TAG】線の幅を指定します。 023 * backgroundColor 【TAG】データの背景色を指定します。 024 * optionAttributes 【TAG】その他オプションを指定します。 025 * > /> 026 * 027 * ●使用例 028 * <og:jsChart...> 029 * <og:jsChartData 030 * chartColumn ="CLM1" 031 * label ="ラベル" 032 * fill ="true" 033 * tension ="0" 034 * borderColor ="rbga(150,150,150,0.7)" 035 * borderWidth ="2" 036 * />> 037 * </og:jsChart> 038 * 039 * 040 * @og.group 画面表示 041 * 042 * @version 5.9.17.2 2017/02/08 043 * @author T.OTA 044 * @since JDK7.0 045 * 046 */ 047public class JsChartDataTag extends CommonTagSupport { 048 //* このプログラムのVERSION文字列を設定します。{@VALUE} */ 049 private static final String VERSION = "5.9.17.2 (2017/02/07)"; 050 private static final long serialVersionUID = -2188726810088630172L; 051 private static final String[] TYPE_BOOLEAN = new String[] { "true", "false" }; 052 // 変数宣言 053 private String chartColumn = null; 054 private String label = null; 055 private String fill = "false"; 056 private String tension = "0.4"; 057 private String borderColor = null; 058 private String borderWidth = null; 059 private String backgroundColor = null; 060 private String optionAttributes = null; 061 private transient JsChartData jsData = new JsChartData(); 062 063 /** 064 * Taglibの開始タグが見つかった時に処理する doStartTag() を オーバーライドします。 065 * 066 * @return 後続処理の指示 067 */ 068 @Override 069 public int doStartTag() { 070 return SKIP_BODY; // Body を評価しない 071 } 072 073 /** 074 * Taglibの終了タグが見つかった時に処理する doEndTag() を オーバーライドします。 075 * 076 * @return 後続処理の指示 077 */ 078 @Override 079 public int doEndTag() { 080 debugPrint(); 081 082 JsChartTag jsChartTag = (JsChartTag) findAncestorWithClass( this, JsChartTag.class ); 083 084 if( jsChartTag == null ) { 085 String errMsg = "jsChart タグが見つかりませんでした。"; 086 throw new HybsSystemException( errMsg ); 087 } 088 089 jsData.setChartColumn( chartColumn ); 090 jsData.setLabel( label ); 091 jsData.setFill( fill ); 092 jsData.setTension( tension ); 093 jsData.setBorderColor( borderColor ); 094 jsData.setBorderWidth( borderWidth ); 095 jsData.setBackgroundColor( backgroundColor ); 096 jsData.setOptionAttributes( optionAttributes ); 097 098 jsChartTag.addJsChartData( jsData ); 099 100 return EVAL_PAGE; 101 } 102 103 /** 104 * タグリブオブジェクトをリリースします。 105 * キャッシュされて再利用されるので、フィールドの初期設定を行います。 106 * 107 */ 108 @Override 109 protected void release2() { 110 super.release2(); 111 jsData = new JsChartData(); 112 chartColumn = null; 113 label = null; 114 fill = "false"; 115 tension = "0.4"; 116 borderColor = null; 117 borderWidth = null; 118 backgroundColor = null; 119 optionAttributes = null; 120 } 121 122 /** 123 * チャートカラム を設定します。 124 * 125 * @param val 126 */ 127 public void setChartColumn( String val ) { 128 chartColumn = getRequestParameter( val ); 129 } 130 131 /** 132 * ラベル を設定します。 133 * 134 * @param label 135 */ 136 public void setLabel( String label ) { 137 this.label = getRequestParameter( label ); 138 } 139 140 /** 141 * フィル(線より下の塗りつぶし) を設定します。 142 * 143 * @param fill 144 */ 145 public void setFill( String fill ) { 146 this.fill = getRequestParameter( fill ); 147 148 checkPara( this.fill, TYPE_BOOLEAN, "fill" ); 149 } 150 151 /** 152 * 伸張 を設定します。 153 * @param tension 154 */ 155 public void setTension( String tension ) { 156 this.tension = getRequestParameter( tension ); 157 } 158 159 /** 160 * 線の色 を設定します。 161 * 162 * @param borderColor 163 */ 164 public void setBorderColor( String borderColor ) { 165 this.borderColor = getRequestParameter( borderColor ); 166 } 167 168 /** 169 * 線の幅 を設定します。 170 * 171 * @param borderWidth 172 */ 173 public void setBorderWidth( String borderWidth ) { 174 this.borderWidth = getRequestParameter( borderWidth ); 175 } 176 177 /** 178 * 背景色 を設定します。 179 * 180 * @param backgroundColor 181 */ 182 public void setBackgroundColor( String backgroundColor ) { 183 this.backgroundColor = getRequestParameter( backgroundColor ); 184 } 185 186 /** 187 * オプション情報 を設定します。 188 * 189 * @param optionAttributes 190 */ 191 public void setOptionAttributes( String optionAttributes ) { 192 this.optionAttributes = getRequestParameter( optionAttributes ); 193 } 194 195 /** 196 * パラメータチェック用メソッド 197 * 198 * @param trg チェック対象 199 * @param list 設定可能なリスト 200 * @param trgStr チェック対象の文字列(エラー表示用) 201 */ 202 private void checkPara( String trg, String[] list, String trgStr ) { 203 if( trg != null && trg.length() > 0 && !check( trg, list ) ) { 204 StringBuilder errMsg = new StringBuilder( HybsSystem.BUFFER_MIDDLE ); 205 errMsg.append( "指定の" ).append( trgStr ).append( "は指定できません。" ); 206 errMsg.append( HybsSystem.CR ); 207 errMsg.append( trgStr ).append( "=[" ).append( trg ).append( "]" ); 208 errMsg.append( HybsSystem.CR ); 209 for( int i = 0; i < list.length; i++ ) { 210 errMsg.append( " | " ); 211 errMsg.append( list[i] ); 212 } 213 throw new HybsSystemException( errMsg.toString() ); 214 } 215 } 216 217 /** 218 * このオブジェクトの文字列表現を返します。 219 * 基本的にデバッグ目的に使用します。 220 * 221 * @return このクラスの文字列表現 222 */ 223 public String toString() { 224 return org.opengion.fukurou.util.ToString.title( this.getClass().getName() ) 225 .println( "VERSIION", VERSION ) 226 .println( "chartColumn", chartColumn ) 227 .println( "label", label ) 228 .println( "fill", fill ) 229 .println( "tension", tension ) 230 .println( "borderColor", borderColor ) 231 .println( "borderWidth", borderWidth ) 232 .println( "backgroundColor", backgroundColor ) 233 .println( "optionAttributes", optionAttributes ).fixForm().toString(); 234 } 235}