第4回:実機に載せよう(ダウンサイズ)
001: //package com.s_cradle.improve.client; 002: 003: /** 004: * タイトル: 005: * 説明: 006: * 著作権: Copyright (c) 2003 007: * 会社名: 008: * @author 未入力 009: * @version 1.0 010: */ 011: 012: import javax.microedition.lcdui.Graphics; 013: import javax.microedition.lcdui.Image; 014: import java.io.DataInputStream; 015: import java.io.IOException; 016: 017: /** 018: * Copyright (C) 2003 Sophia Cradle, Inc. 019: * 020: * 友達(本人も含む)を表現するクラスです。 021: * 022: * @author Masaru Yoshimura 023: */ 024: public class A/*Buddy*/ { 025: //downsize 定数展開 026: // 本人か友達か 027: //public static final int ATTRIBUTE_HIM = 0; 028: //public static final int ATTRIBUTE_FRIEND = 1; 029: 030: // 色定数 031: //private static final int COLOR_COLUMN_SELECT = ( 102<<16) | (51<<8) | 255; 032: //private static final int COLOR_STRING_SELECT_OTHER = ( 255<<16) | (255<<8) | 255; 033: //private static final int COLOR_STRING_NORMAL_OTHER = ( 0<<16) | (0<<8) | 0; 034: //private static final int COLOR_STRING_SELECT_HIM = ( 255<<16) | (0<<8) | 0; 035: //private static final int COLOR_STRING_NORMAL_HIM = ( 255<<16) | (0<<8) | 0; 036: 037: // 描画用の種々の定数 038: //private static final int IMAGE_CIRCLE_WIDTH = 14; 039: //private static final int IMAGE_CIRCLE_HEIGHT = 14; 040: //private static final int IMAGE_CIRCLE_RIGHT_INTERVAL = 11; 041: //private static final int COLUMN_HEIGHT = 18; 042: 043: //private static final int STRING_LEFT_INTERVAL = 6; 044: //private static final int STRING_LEFT_INTERVAL_ARROW = 12; 045: //private static final int HEIGHT_MARGIN = 3; 046: 047: //private static final int IMAGE_ARROW_HORIZONTAL_WIDTH = 4; 048: //private static final int IMAGE_ARROW_HORIZONTAL_HEIGHT = 7; 049: //private static final int IMAGE_ARROW_HORIZONTAL_RIGHT_INTERVAL = 4; 050: //private static final int IMAGE_ARROW_HORIZONTAL_LEFT_INTERVAL = 4; 051: 052: //private static final int TICKER_HEIGHT = 18; 053: 054: // 矢印の画像 055: //downsize 配列化 056: private static final Image[] setColor/*images*/ = new Image[]{ 057: I/*ImproveMIDlet*//*ResourceManager*/.Code/*getImage*/( 2/*ResourceManager.IMAGE_RIGHT*/), 058: I/*ImproveMIDlet*//*ResourceManager*/.Code/*getImage*/( /*ResourceManager.IMAGE_LEFT*/) 059: }; 060: 061: //downsize メソッドインライン化 062: public String[] StackMap/*etc*/ = new String[4]; 063: //downsize 配列化 064: //public String account; 065: //public String nickname; 066: //public String description; 067: //public String phoneNumber; 068: 069: public int[] Code/*idata*/ = new int[2]; 070: //downsize 配列化 071: //public int status; 072: //public int attribute; 073: 074: public L/*MessageBox*/ L/*messageBox*/; 075: 076: /** 077: * 文字列からのコンストラクタ。 078: */ 079: public A/*Buddy*/(String account_, String nickname_, int status_, 080: String description_, int attribute_, String phoneNumber_) { 081: StackMap/*etc*/[0]/*account*/ = account_; 082: StackMap/*etc*/[1]/*nickname*/ = nickname_; 083: Code/*idata*/[0]/*status*/ = status_; 084: StackMap/*etc*/[2]/*description*/ = description_; 085: Code/*idata*/[1]/*attribute*/ = attribute_; 086: StackMap/*etc*/[3]/*phoneNumber*/ = phoneNumber_; 087: } 088: 089: /** 090: * DataInputStreamからのコンストラクタ。 091: */ 092: public A/*Buddy*/(DataInputStream input) throws IOException { 093: StackMap/*etc*/[0]/*account*/ = input.readUTF(); 094: StackMap/*etc*/[1]/*nickname*/ = input.readUTF(); 095: StackMap/*etc*/[3]/*phoneNumber*/ = input.readUTF(); 096: Code/*idata*/[0]/*status*/ = input.readInt(); 097: StackMap/*etc*/[2]/*description*/ = input.readUTF(); 098: Code/*idata*/[1]/*attribute*/ = 1/*ATTRIBUTE_FRIEND*/; 099: } 100: 101: // ここよりsetter,getter 102: //downsize メソッドインライン化 103: /* 104: public void setAccount(String account_){ 105: account = account_; 106: } 107: 108: public String getAccount(){ 109: return account; 110: } 111: 112: public void setNickname(String nickname_){ 113: nickname = nickname_; 114: } 115: 116: public String getNickname(){ 117: return nickname; 118: } 119: 120: public void setStatus(int status_){ 121: status = status_; 122: } 123: 124: public int getStatus(){ 125: return status; 126: } 127: 128: public void setDescription(String description_){ 129: description = description_; 130: } 131: 132: public String getDescription(){ 133: return description; 134: } 135: 136: public void setAttribute(int attribute_){ 137: attribute = attribute_; 138: } 139: 140: public int getAttribute(){ 141: return attribute; 142: } 143: 144: public void setPhoneNumber(String phoneNumber_){ 145: phoneNumber = phoneNumber_; 146: } 147: 148: public String getPhoneNumber(){ 149: return phoneNumber; 150: } 151: 152: public void setMessageBox(MessageBox messageBox_){ 153: messageBox = messageBox_; 154: } 155: 156: public MessageBox getMessageBox(){ 157: return messageBox; 158: } 159: */ 160: // setter,getterここまで 161: 162: /** 163: * equals の定義。アカウントが同じなら true。 164: */ 165: public boolean equals(Object obj){ 166: if( obj instanceof A/*Buddy*/ ){ 167: return StackMap/*etc*/[0]/*account*/.equals( ((A/*Buddy*/)obj).StackMap/*etc*/[0]/*account*/); 168: } else{ 169: return false; 170: } 171: } 172: 173: /** 174: * Buddyオブジェクトで内容を更新。 175: */ 176: public void StackMap/*update*/(A/*Buddy*/ buddy){ 177: StackMap/*etc*/[1]/*nickname*/ = buddy.StackMap/*etc*/[1]/*nickname*/; 178: StackMap/*etc*/[3]/*phoneNumber*/ = buddy.StackMap/*etc*/[3]/*phoneNumber*/; 179: StackMap/*etc*/[2]/*description*/ = buddy.StackMap/*etc*/[2]/*description*/; 180: Code/*idata*/[0]/*status*/ = buddy.Code/*idata*/[0]/*status*/; 181: } 182: 183: /** 184: * 選択状況に応じた画像の取得。 185: */ 186: public Image StackMap/*getImage*/(boolean select){ 187: //downsize 即値の利用 188: //Image image; 189: switch( Code/*idata*/[0]/*status*/ ){ 190: case 3/*Constants.STATUS_BLUE*/: 191: return I/*ImproveMIDlet*//*ResourceManager*/.Code/*getImage*/( 192: (select) ? 8/*ResourceManager.IMAGE_SELECT_GREEN*/ : 193: 4/*ResourceManager.IMAGE_NORMAL_GREEN*/); 194: case 2/*Constants.STATUS_YELLOW*/: 195: return I/*ImproveMIDlet*//*ResourceManager*/.Code/*getImage*/( 196: (select) ? 9/*ResourceManager.IMAGE_SELECT_YELLOW*/ : 197: 5/*ResourceManager.IMAGE_NORMAL_YELLOW*/); 198: case 1/*Constants.STATUS_RED*/: 199: return I/*ImproveMIDlet*//*ResourceManager*/.Code/*getImage*/( 200: (select) ? 10/*ResourceManager.IMAGE_SELECT_RED*/ : 201: 6/*ResourceManager.IMAGE_NORMAL_RED*/); 202: //case STATUS_LOGOFF: 203: default: 204: return I/*ImproveMIDlet*//*ResourceManager*/.Code/*getImage*/( 205: (select) ? 11/*ResourceManager.IMAGE_SELECT_OFF*/ : 206: 7/*ResourceManager.IMAGE_NORMAL_OFF*/); 207: } 208: } 209: 210: /** 211: * 名前・フォーカス・アイコンの描画 212: */ 213: public void StackMap/*draw*/( Graphics g, int width, int positionY, boolean focus, boolean left){ 214: //downsize アルゴリズム 未使用・・・フィールドじゃないですよね? 215: //int color; 216: int stringColor; 217: //downsize 即値の利用 218: //Image image = getImage(focus); 219: 220: switch( Code/*idata*/[1]/*attribute*/ ){ 221: case 0/*ATTRIBUTE_HIM*/: 222: stringColor = (focus) ? (255<<16) | (0<<8) | 0/* COLOR_STRING_SELECT_HIM*/ : (255<<16) | (0<<8) | 0/*COLOR_STRING_NORMAL_HIM*/; 223: break; 224: //case ATTRIBUTE_FRIEND: 225: default: 226: stringColor = (focus) ? ((255<<16) | (255<<8) | 255)/* COLOR_STRING_SELECT_OTHER*/ 227: : ((0<<16) | (0<<8) | 0)/*COLOR_STRING_NORMAL_OTHER*/; 228: break; 229: } 230: 231: if( focus ){ 232: g.setColor((102<<16) | (51<<8) | 255/*COLOR_COLUMN_SELECT*/); 233: g.fillRect(1, positionY+1, width-2, 18/*COLUMN_HEIGHT*/-2); 234: } 235: if( left ){ 236: g.drawImage(setColor/*images*/[1]/*leftImage*/,4/* IMAGE_ARROW_HORIZONTAL_LEFT_INTERVAL*/, 237: positionY+(18/*COLUMN_HEIGHT*/-7/* IMAGE_ARROW_HORIZONTAL_HEIGHT*/)/2, 238: Graphics.LEFT | Graphics.TOP); 239: } else if( L/*messageBox*/ != null ){ 240: g.drawImage(setColor/*images*/[0]/*rightImage*/,width-4/* IMAGE_ARROW_HORIZONTAL_WIDTH*/- 241: 4/*IMAGE_ARROW_HORIZONTAL_RIGHT_INTERVAL*/, 242: positionY+(18/*COLUMN_HEIGHT*/-7/* IMAGE_ARROW_ HORIZONTAL_HEIGHT*/)/2, 243: Graphics.LEFT | Graphics.TOP); 244: } 245: g.setColor(stringColor); 246: g.drawString(StackMap/*etc*/[0]/*nickname*/, 247: (left) ? 12/*STRING_LEFT_INTERVAL_ARROW*/ : 6/* STRING_LEFT_INTERVAL*/, 248: positionY+3/*HEIGHT_MARGIN*/, Graphics.LEFT | Graphics.TOP); 249: g.drawImage(StackMap/*getImage*/(focus),width-14/*IMAGE_CIRCLE_WIDTH*/-11/* IMAGE_CIRCLE_RIGHT_INTERVAL*/, 250: positionY+(18/*COLUMN_HEIGHT*/-14/*IMAGE_CIRCLE_HEIGHT*/)/2, 251: Graphics.LEFT | Graphics.TOP); 252: } 253: }