Changeset 9627
- Timestamp:
- 04/17/08 21:00:52 (5 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/java/sabotter/trunk/src/jp/xet/eclipse/sabotter/views/LabelProcessor.java
r9597 r9627 9 9 import java.text.SimpleDateFormat; 10 10 import java.util.Date; 11 import java.util.HashMap;12 11 import java.util.Locale; 13 import java.util.Map;14 12 15 13 import jp.xet.eclipse.sabotter.SabotterPlugin; … … 21 19 import org.apache.commons.httpclient.HttpMethod; 22 20 import org.apache.commons.httpclient.methods.GetMethod; 21 import org.eclipse.jface.resource.ImageRegistry; 23 22 import org.eclipse.swt.SWT; 24 23 import org.eclipse.swt.graphics.Color; … … 33 32 /** 34 33 * 表示文字列等の加工(色づけ等)クラス。 34 * 35 35 * @author daisuke 36 36 */ 37 37 public class LabelProcessor { 38 38 39 39 private TwitterManager manager; 40 40 … … 48 48 49 49 /** アイコン画像のキャッシュ */ 50 private Map<String, Image> cashe = new HashMap<String, Image>();51 50 private ImageRegistry cache = new ImageRegistry(); 51 52 52 /** プリファレンス */ 53 53 SabotterPreference pref = SabotterPlugin.getPreference(); … … 55 55 /** 56 56 * コンストラクタ。 57 * 57 58 * @param manager 58 59 * @category instance creation … … 64 65 /** 65 66 * 表示する名前を取得する。 67 * 66 68 * @param status 67 69 * @return 名前 … … 82 84 /** 83 85 * 表示するメッセージを取得する。 86 * 84 87 * @param status 85 88 * @return メッセージ … … 91 94 /** 92 95 * 表示する日時を取得する。 96 * 93 97 * @param status 94 98 * @return 日時 … … 107 111 /** 108 112 * 表示するアイコンを取得する 113 * 109 114 * @param status 110 115 * @return アイコン 111 116 */ 112 117 public Image getImage(Status status) { 113 Image image = null;114 118 if (status == null) { 115 return image;119 return null; 116 120 } 117 121 String url = encode(status.getUser().getProfileImageURL().toString()); 118 if (ca she.get(url) == null) {122 if (cache.get(url) == null) { 119 123 HttpClient client = new HttpClient(); 120 124 … … 126 130 } 127 131 132 Image tmpImage = null; 133 128 134 try { 129 135 HttpMethod method = new GetMethod(url); 130 136 client.executeMethod(method); 131 137 InputStream is = method.getResponseBodyAsStream(); 132 image = new Image(null, is);133 ca she.put(url, image);138 tmpImage = new Image(null, is); 139 cache.put(url, processImage(tmpImage)); 134 140 } catch (HttpException e) { 135 141 SabotterPlugin.handleException(e); … … 139 145 SabotterPlugin.handleException(e, SabotterPlugin.LOG 140 146 | SabotterPlugin.STACKTRACE); 147 } finally { 148 if ((tmpImage != null) && !tmpImage.isDisposed()) { 149 tmpImage.dispose(); 150 } 141 151 } 142 } else { 143 image = cashe.get(url); 144 } 145 146 return processImage(image); 152 } 153 154 return cache.get(url); 147 155 } 148 156 149 157 /** 150 158 * APIから取得したURLのエンコーディングを行う。(本来はAPI側で処理されているべきなんだが) 159 * 151 160 * @param url 152 161 * @return エンコーディング結果。 … … 168 177 /** 169 178 * 画像を設定の通りに加工する。 179 * 170 180 * @param image 171 181 * @return 加工された画像 … … 215 225 /** 216 226 * 背景色を取得する。 227 * 217 228 * @param status 218 229 * @return 背景色 … … 233 244 /** 234 245 * 文字色を取得する。 246 * 235 247 * @param status 236 248 * @return 文字色 … … 246 258 /** 247 259 * フォントを取得する。 260 * 248 261 * @param status 249 262 * @return フォント 250 263 */ 251 264 public Font getFont(Status status) { 252 if (manager.isUnread(status)) {265 if (manager.isUnread(status)) { 253 266 // なんか微妙だな。。 254 267 return new Font(null, new FontData("", 9, SWT.BOLD));
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)