Jindolfプロジェクトは、CGIゲーム「人狼BBS」を快適にプレイするための専用クライアントを製作するために発足したオープンソースプロジェクトです。
Revision | d6e76f74d49077cc27d1751c5ecacfbc351fe647 (tree) |
---|---|
Time | 2020-04-25 13:44:19 |
Author | Olyutorskii <olyutorskii@user...> |
Commiter | Olyutorskii |
speed up Village node drawing.
@@ -7,6 +7,7 @@ | ||
7 | 7 | |
8 | 8 | package jp.sfjp.jindolf.data; |
9 | 9 | |
10 | +import java.text.MessageFormat; | |
10 | 11 | import java.util.ArrayList; |
11 | 12 | import java.util.Collections; |
12 | 13 | import java.util.HashMap; |
@@ -24,6 +25,8 @@ import jp.sourceforge.jindolf.corelib.LandDef; | ||
24 | 25 | * {@link javax.swing.JTree}のモデルとして国一覧と村一覧を管理。 |
25 | 26 | * |
26 | 27 | * <p>ツリー階層は ROOT - 国 - 範囲セクション - 村 の4階層。 |
28 | + * | |
29 | + * <p>昇順/降順の切り替えをサポート。 | |
27 | 30 | */ |
28 | 31 | public class LandsTreeModel implements TreeModel{ |
29 | 32 |
@@ -413,24 +416,31 @@ public class LandsTreeModel implements TreeModel{ | ||
413 | 416 | */ |
414 | 417 | private static final class VillageSection{ |
415 | 418 | |
416 | - private final String prefix; | |
419 | + private static final String FORM_NODE = | |
420 | + "{0}{1,number,#} ~ {0}{2,number,#}"; | |
421 | + private static final String FORM_NODE_G = | |
422 | + "{0}{1,number,#000} ~ {0}{2,number,#000}"; | |
423 | + | |
424 | + | |
417 | 425 | private final int startId; |
418 | 426 | private final int endId; |
419 | 427 | |
428 | + private final String text; | |
429 | + | |
420 | 430 | private final List<Village> villageList; |
421 | 431 | |
422 | 432 | |
423 | 433 | /** |
424 | 434 | * セクション集合を生成する。 |
425 | 435 | * |
426 | - * @param pfx 国名プレフィクス | |
436 | + * @param prefix 国名プレフィクス | |
427 | 437 | * @param startId 区間開始村ID |
428 | 438 | * @param endId 区間終了村ID |
429 | 439 | * @param spanList 村の区間リスト |
430 | 440 | * @throws java.lang.IndexOutOfBoundsException IDの範囲指定が変 |
431 | 441 | */ |
432 | 442 | VillageSection( |
433 | - String pfx, int startId, int endId, List<Village> spanList) | |
443 | + String prefix, int startId, int endId, List<Village> spanList) | |
434 | 444 | throws IndexOutOfBoundsException{ |
435 | 445 | super(); |
436 | 446 |
@@ -438,10 +448,15 @@ public class LandsTreeModel implements TreeModel{ | ||
438 | 448 | throw new IndexOutOfBoundsException(); |
439 | 449 | } |
440 | 450 | |
441 | - this.prefix = pfx; | |
442 | 451 | this.startId = startId; |
443 | 452 | this.endId = endId; |
444 | 453 | |
454 | + String format; | |
455 | + if("G".equals(prefix)) format = FORM_NODE_G; | |
456 | + else format = FORM_NODE; | |
457 | + this.text = MessageFormat.format( | |
458 | + format, prefix, this.startId, this.endId); | |
459 | + | |
445 | 460 | List<Village> newList = new ArrayList<>(spanList); |
446 | 461 | this.villageList = Collections.unmodifiableList(newList); |
447 | 462 |
@@ -493,11 +508,7 @@ public class LandsTreeModel implements TreeModel{ | ||
493 | 508 | */ |
494 | 509 | @Override |
495 | 510 | public String toString(){ |
496 | - StringBuilder result = new StringBuilder(); | |
497 | - result.append(this.prefix).append(this.startId); | |
498 | - result.append(" ~ "); | |
499 | - result.append(this.prefix).append(this.endId); | |
500 | - return result.toString(); | |
511 | + return this.text; | |
501 | 512 | } |
502 | 513 | |
503 | 514 | } |