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.taglib; 017 018import org.opengion.hayabusa.common.HybsSystemException; 019import org.opengion.fukurou.util.StringUtil; 020import org.opengion.fukurou.util.TagBuffer; 021 022/** 023 * 明細棒グラフで、バー部のヘッダーに、進捗率を示す線を表示します。 024 * 025 * iHead タグは、ガントの ヘッダー部に使用されます。 026 * 進捗率を示す線は、2本あり、デフォルトでは、中間点と最大値になります。 027 * グラフの右に、何かを表示する場合は、幅(width)を指定する必要があります。 028 * 029 * @og.formSample 030 * ●形式:<og:iHead ... /> 031 * ●body:なし 032 * ●前提:headタグで、adjustEvent="Bar" を指定してください。 033 * 034 * ●Tag定義: 035 * <og:iHead 036 * width 【TAG】グラフ部分の横幅を[px]で指定します。 037 * leftVal 【TAG】左線のヘッダ部分の文字を指定します(初期値:最大桁の半分) 038 * leftLoc 【TAG】左線のヘッダ部文字(及び線)の位置を左からの割合で指定します。 039 * leftBorderStyle 【TAG】左線のスタイルを指定します(初期値=dotted gray 1px)。 040 * adjustLeft 【TAG】左線のヘッダ部分の文字の上下位置をピクセル単位で指定します(負の数で下方向)。 041 * rightVal 【TAG】右線のヘッダ部分の文字を指定します(初期値:最大桁) 042 * rightLoc 【TAG】右線のヘッダ部文字(及び線)の位置を左からの割合で指定します。 043 * rightBorderStyle 【TAG】右線のスタイルを指定します(初期値=dotted gray 1px)。 044 * adjustRight 【TAG】右線のヘッダ部分の文字の上下位置をピクセル単位で指定します(負の数で下方向)。 045 * debug 【TAG】デバッグ情報を出力するかどうか[true/false]を指定します(初期値:false) 046 * /> 047 * 048 * ●使用例 049 * <og:view 050 * viewFormType = "HTMLCustomTable" 051 * command = "{@command}" 052 * writable = "false" 053 * useScrollBar = "false" 054 * headerSkipCount="10" 055 * > 056 * <og:thead rowspan="2"> 057 * <tr> 058 * <td rowspan="2">[NOORDER]</td> 059 * <td rowspan="2"> 060 * <og:iHead width="150px" 061 * leftVal ="now" leftLoc ="0.8" leftBorderStyle ="solid red 1px" adjustLeft ="15px" 062 * rightVal="Target" rightLoc="1.0" rightBorderStyle="dashed red 2px" adjustRight="-15px" 063 * /> 064 * <td rowspan="2">[SINTYOKU]</td> 065 * </tr> 066 * </og:thead> 067 * <og:tbody rowspan="2"> 068 * <td rowspan="2">[NOORDER]</td> 069 * <td rowspan="2"> 070 * <iBar id="B0_[I]" type="0" value="[SINTYOKU]" baseVal="[KNORDER]" /> 071 * <iBar id="B1_[I]" type="1" value="[KNORDER_G]" color="[COLOR]" text="[KNORDER]" /> 072 * <br/> 073 * <iBar id="B2_[I]" type="1" value="[KNJISK_G],[KNMIKM_G]" color="black,green" /> 074 * <iBar id="B3_[I]" type="2" value="[KNJISK_G],[KNMIKM_G]" baseVal="[KNORDER_G]" color="green" /> 075 * <td rowspan="2">[SINTYOKU]</td> 076 * </og:tbody> 077 * </og:view> 078 * 079 * @og.rev 5.6.3.2 (2013/04/12) 新規作成 080 * @og.group 画面部品 081 * 082 * @version 5.0 083 * @author Kazuhiko Hasegawa 084 * @since JDK6.0, 085 */ 086public class ViewIHeadTag extends CommonTagSupport { 087 /** このプログラムのVERSION文字列を設定します。 {@value} */ 088 private static final String VERSION = "5.6.3.2 (2013/04/12)" ; 089 090 private static final long serialVersionUID = 563220130412L ; 091 092 private TagBuffer tag = new TagBuffer( "iHead" ) ; 093 094 /** 095 * Taglibの終了タグが見つかったときに処理する doEndTag() を オーバーライドします。 096 * 097 * @og.rev 5.8.1.0 (2014/11/07) HTML5対応。javaScriptで、BODYがないと入れ子になってしまう。 098 * @return 後続処理の指示 099 */ 100 @Override 101 public int doEndTag() { 102 debugPrint(); // 4.0.0 (2005/02/28) 103 104 tag.setBody( "<!-- -->" ); // 5.8.1.0 (2014/11/07) HTML5対応。 105 jspPrint( tag.makeTag() ); 106 107 return(EVAL_PAGE); // ページの残りを評価する。 108 } 109 110 /** 111 * タグリブオブジェクトをリリースします。 112 * キャッシュされて再利用されるので、フィールドの初期設定を行います。 113 * 114 */ 115 @Override 116 protected void release2() { 117 super.release2(); 118 tag = new TagBuffer( "iHead" ); 119 } 120 121 /** 122 * 【TAG】グラフ部分の横幅を[px]で指定します。 123 * 124 * @og.tag 125 * 指定しない場合は残りの横幅全てとなります。 126 * グラフの右側に何かを表示したい場合は指定する必要があります。 127 * 単位(px)は設定不要です。それ以外の単位は設定できません。 128 * 129 * @param width グラフ部分の横幅 130 */ 131 public void setWidth( final String width ) { 132 // JavaScript 側の都合で、px 単位は、削除します。 133 String tmpW = StringUtil.nval( getRequestParameter( width ),null ) ; 134 if( tmpW != null && tmpW.endsWith("px") ) { 135 tmpW = tmpW.substring( 0,tmpW.length()-2 ); 136 } 137 138 tag.add( "width",tmpW ); 139 } 140 141 /** 142 * 【TAG】左線のヘッダ部分の文字を指定します(初期値:最大桁の半分)。 143 * 144 * @og.tag 145 * 左線のヘッダ部分に表示する文字を指定します。 146 * 左線は、中間データ、または、途中経過を意味しますので、その様な単語にします。 147 * なにも指定しない場合は、右側が最大桁以下を切り捨てした値となり、左側はその半分の値です。 148 * leftValに関しては、0.4,0.4のように複数の値をカンマ区切りで書く事が可能です。 149 * 150 * @param leftVal 左線のヘッダ部分の文字 151 */ 152 public void setLeftVal( final String leftVal ) { 153 tag.add( "leftVal",StringUtil.nval( getRequestParameter( leftVal ),null ) ); 154 } 155 156 /** 157 * 【TAG】左線のヘッダ部文字(及び線)の位置を左からの割合(少数)で指定します。 158 * 159 * @og.tag 160 * グラフ幅全体を1として、左からの割合で指定します。(左が0.3で右が0.9など) 161 * leftLocに関しては、0.4,0.4のように複数の値をカンマ区切りで書く事が可能です。 162 * 163 * @param leftLoc 左線のヘッダ部文字(及び線)の位置の割合(少数) 164 */ 165 public void setLeftLoc( final String leftLoc ) { 166 tag.add( "leftLoc",StringUtil.nval( getRequestParameter( leftLoc ),null ) ); 167 } 168 169 /** 170 * 【TAG】左線のスタイルを指定します(初期値=dotted gray 1px)。 171 * 172 * @og.tag 173 * グラフに引かれる左線のスタイルを指定します。 174 * 初期値は、dotted gray 1px です。 175 * 176 * @param leftBorderStyle 左線のヘッダ部文字(及び線)の位置の割合(少数) 177 */ 178 public void setLeftBorderStyle( final String leftBorderStyle ) { 179 tag.add( "leftBorderStyle",StringUtil.nval( getRequestParameter( leftBorderStyle ),null ) ); 180 } 181 182 /** 183 * 【TAG】左線のヘッダ部分の文字の上下位置をピクセル単位で指定します(負の数で下方向)。 184 * 185 * @og.tag 186 * 左右の文字が重なる可能性がある場合に利用します。 187 * 10と指定すると、10マイナスされて文字が上方向にずれます。 188 * 負の数を指定すると、文字が下方向にずれます。 189 * 単位(px)は設定不要です。それ以外の単位は設定できません。 190 * 191 * @param adjustLeft 文字の上下位置指定 192 */ 193 public void setAdjustLeft( final String adjustLeft ) { 194 // JavaScript 側の都合で、px 単位は、削除します。 195 String tmpA = StringUtil.nval( getRequestParameter( adjustLeft ),null ) ; 196 if( tmpA != null && tmpA.endsWith("px") ) { 197 tmpA = tmpA.substring( 0,tmpA.length()-2 ); 198 } 199 200 tag.add( "adjustLeft",tmpA ); 201 } 202 203 /** 204 * 【TAG】右線のヘッダ部分の文字を指定します(初期値:最大桁)。 205 * 206 * @og.tag 207 * 右線のヘッダ部分に表示する文字を指定します。 208 * 右線は、最終データ、または、最大データを意味しますので、その様な単語にします。 209 * なにも指定しない場合は、右側が最大桁以下を切り捨てした値となり、左側はその半分の値です。 210 * 211 * @param rightVal 左線のヘッダ部分の文字 212 */ 213 public void setRightVal( final String rightVal ) { 214 tag.add( "rightVal",StringUtil.nval( getRequestParameter( rightVal ),null ) ); 215 } 216 217 /** 218 * 【TAG】右線のヘッダ部文字(及び線)の位置を左からの割合(少数)で指定します。 219 * 220 * @og.tag 221 * グラフ幅全体を1として、左からの割合で指定します。(左が0.3で右が0.9など) 222 * 223 * @param rightLoc 右線のヘッダ部文字(及び線)の位置の割合(少数) 224 */ 225 public void setRightLoc( final String rightLoc ) { 226 tag.add( "rightLoc",StringUtil.nval( getRequestParameter( rightLoc ),null ) ); 227 } 228 229 /** 230 * 【TAG】右線のスタイルを指定します(初期値=dotted gray 1px)。 231 * 232 * @og.tag 233 * グラフに引かれる右線のスタイルを指定します。 234 * 初期値は、dotted gray 1px です。 235 * 236 * @param rightBorderStyle 左線のヘッダ部文字(及び線)の位置の割合(少数) 237 */ 238 public void setRightBorderStyle( final String rightBorderStyle ) { 239 tag.add( "rightBorderStyle",StringUtil.nval( getRequestParameter( rightBorderStyle ),null ) ); 240 } 241 242 /** 243 * 【TAG】右線のヘッダ部分の文字の上下位置をピクセル単位で指定します(負の数で下方向)。 244 * 245 * @og.tag 246 * 左右の文字が重なる可能性がある場合に利用します。 247 * 10と指定すると、10マイナスされて文字が上方向にずれます。 248 * 負の数を指定すると、文字が下方向にずれます。 249 * 単位(px)は設定不要です。それ以外の単位は設定できません。 250 * 251 * @param adjustRight 文字の上下位置指定 252 */ 253 public void setAdjustRight( final String adjustRight ) { 254 // JavaScript 側の都合で、px 単位は、削除します。 255 String tmpA = StringUtil.nval( getRequestParameter( adjustRight ),null ) ; 256 if( tmpA != null && tmpA.endsWith("px") ) { 257 tmpA = tmpA.substring( 0,tmpA.length()-2 ); 258 } 259 260 tag.add( "adjustRight",tmpA ); 261 } 262 263 /** 264 * タグの名称を、返します。 265 * 自分自身のクラス名より、自動的に取り出せないため、このメソッドをオーバーライドします。 266 * 267 * @return タグの名称 268 */ 269 @Override 270 protected String getTagName() { 271 return "iHead" ; 272 } 273 274 /** 275 * このオブジェクトの文字列表現を返します。 276 * 基本的にデバッグ目的に使用します。 277 * 278 * @return このクラスの文字列表現 279 */ 280 @Override 281 public String toString() { 282 return org.opengion.fukurou.util.ToString.title( this.getClass().getName() ) 283 .println( "VERSION" ,VERSION ) 284 .println( "tag" ,tag.makeTag() ) 285 .println( "Other..." ,getAttributes().getAttribute() ) 286 .fixForm().toString() ; 287 } 288}