Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/Java/KeyHole/src/org/litesoft/aokeyhole/toolkit/BoxedSet.java

Diff revisions: vs.
  @@ -3,31 +3,24 @@
3 3
4 4 import java.awt.*;
5 5
6 - public abstract class BoxedSet
7 - {
6 + public abstract class BoxedSet {
8 7 protected BoxedText[] mBoxes = BoxedText.EMPTY_ARRAY;
9 8
10 9 private View mView = ViewNull.INSTANCE;
11 10
12 - public int size()
13 - {
11 + public int size() {
14 12 return mBoxes.length;
15 13 }
16 14
17 - public void draw( Graphics pGraphics )
18 - {
19 - for ( BoxedText box : mBoxes )
20 - {
15 + public void draw( Graphics pGraphics ) {
16 + for ( BoxedText box : mBoxes ) {
21 17 box.draw( pGraphics );
22 18 }
23 19 }
24 20
25 - public boolean remove( int pID )
26 - {
27 - for ( int i = 0; i < mBoxes.length; i++ )
28 - {
29 - if ( mBoxes[i].getID() == pID )
30 - {
21 + public boolean remove( int pID ) {
22 + for ( int i = 0; i < mBoxes.length; i++ ) {
23 + if ( mBoxes[i].getID() == pID ) {
31 24 mBoxes[i].dispose();
32 25 innerRemove( i );
33 26 setChanged();
  @@ -37,56 +30,46 @@
37 30 return false;
38 31 }
39 32
40 - public BoxedText add( BoxedText pNew )
41 - {
42 - if ( pNew != null )
43 - {
33 + public BoxedText add( BoxedText pNew ) {
34 + if ( pNew != null ) {
44 35 innerAdd( pNew );
45 36 setChanged();
46 37 }
47 38 return pNew;
48 39 }
49 40
50 - public void setView( View pView )
51 - {
41 + public void setView( View pView ) {
52 42 mView = (pView != null) ? pView : ViewNull.INSTANCE;
53 43 }
54 44
55 - public void setChanged()
56 - {
45 + public void setChanged() {
57 46 mView.update();
58 47 }
59 48
60 - public BoxedText[] getBoxes()
61 - {
49 + public BoxedText[] getBoxes() {
62 50 return mBoxes;
63 51 }
64 52
65 - public BoxedText getLastBox()
66 - {
53 + public BoxedText getLastBox() {
67 54 return (mBoxes.length == 0) ? null : mBoxes[mBoxes.length - 1];
68 55 }
69 56
70 - public void dispose()
71 - {
72 - for ( BoxedText box : mBoxes )
73 - {
57 + public void dispose() {
58 + for ( BoxedText box : mBoxes ) {
74 59 box.dispose();
75 60 }
76 61 mBoxes = BoxedText.EMPTY_ARRAY;
77 62 mView = ViewNull.INSTANCE;
78 63 }
79 64
80 - protected void innerAdd( BoxedText pNew )
81 - {
65 + protected void innerAdd( BoxedText pNew ) {
82 66 BoxedText[] extended = new BoxedText[mBoxes.length + 1];
83 67 System.arraycopy( mBoxes, 0, extended, 0, mBoxes.length );
84 68 extended[mBoxes.length] = pNew;
85 69 mBoxes = extended;
86 70 }
87 71
88 - private void innerRemove( int pIndex )
89 - {
72 + private void innerRemove( int pIndex ) {
90 73 BoxedText[] shrunk = new BoxedText[mBoxes.length - 1];
91 74 if ( pIndex != 0 ) // Not First
92 75 {