Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/GWT_Sandbox/MultiModule/anywhere/src/org/litesoft/sandbox/anywhere/die/State.java

Diff revisions: vs.
  @@ -4,92 +4,74 @@
4 4
5 5 import static org.litesoft.sandbox.anywhere.die.View.*;
6 6
7 - public class State
8 - {
7 + public class State {
9 8 private Map<View, Integer> mViewValues = new EnumMap<View, Integer>( View.class );
10 9 private final Orientation mOrientation;
11 10
12 11 /**
13 12 * Initialize to Identifier 1?2
14 13 */
15 - public State( Orientation pOrientation )
16 - {
14 + public State( Orientation pOrientation ) {
17 15 mViewValues.put( Result, 1 );
18 16 mViewValues.put( Other, 6 );
19 17
20 18 mViewValues.put( North, 2 );
21 19 mViewValues.put( South, 5 );
22 20
23 - if ( Orientation.L.equals( mOrientation = pOrientation ) )
24 - {
21 + if ( Orientation.L.equals( mOrientation = pOrientation ) ) {
25 22 mViewValues.put( East, 3 );
26 23 mViewValues.put( West, 4 );
27 - }
28 - else
29 - {
24 + } else {
30 25 mViewValues.put( West, 3 );
31 26 mViewValues.put( East, 4 );
32 27 }
33 28 }
34 29
35 - public synchronized Identifier getIdentifier()
36 - {
30 + public synchronized Identifier getIdentifier() {
37 31 return new Identifier( mOrientation, getValue(), getValue( North ) );
38 32 }
39 33
40 - public int getValue()
41 - {
34 + public int getValue() {
42 35 return getValue( Result );
43 36 }
44 37
45 - public synchronized Integer getValue( View pView )
46 - {
38 + public synchronized Integer getValue( View pView ) {
47 39 return mViewValues.get( pView );
48 40 }
49 41
50 - public synchronized View getViewForValue( int pValue )
51 - {
52 - for ( View zView : View.values() )
53 - {
54 - if ( pValue == getValue( zView ) )
55 - {
42 + public synchronized View getViewForValue( int pValue ) {
43 + for ( View zView : View.values() ) {
44 + if ( pValue == getValue( zView ) ) {
56 45 return zView;
57 46 }
58 47 }
59 48 return null;
60 49 }
61 50
62 - public synchronized void adjustTo( Identifier pIdentifier )
63 - {
64 - if ( pIdentifier == null )
65 - {
51 + public synchronized void adjustTo( Identifier pIdentifier ) {
52 + if ( pIdentifier == null ) {
66 53 return;
67 54 }
68 - if ( mOrientation != pIdentifier.getOrientation() )
69 - {
55 + if ( mOrientation != pIdentifier.getOrientation() ) {
70 56 throw new IllegalStateException( "Orientation Incompatible" );
71 57 }
72 58 makeResultEqual( pIdentifier.getFace() );
73 59 makeNorthEqual( pIdentifier.getNorthSide() );
74 60 }
75 61
76 - public void makeNorthResult()
77 - {
62 + public void makeNorthResult() {
78 63 rollToSide( North ); // Move Down
79 64 }
80 65
81 - public void makeSouthResult()
82 - {
66 + public void makeSouthResult() {
83 67 rollToSide( South ); // Move Up
84 68 }
85 69
86 - public void makeWestResult()
87 - {
70 + public void makeWestResult() {
88 71 rollToSide( West ); // Move Right
89 72 }
90 73
91 - public void makeEastResult()
92 - {
74 + public void makeEastResult() {
93 75 rollToSide( East ); // Move Left
94 76 }
95 77
  @@ -103,24 +85,21 @@
103 85 rotateEastOrWestToNorth( East );
104 86 }
105 87
106 - public void rotate180degrees()
107 - {
88 + public void rotate180degrees() {
108 89 moveSides( North, South, //
109 90 East, West, //
110 91 West, East, //
111 92 South, North );
112 93 }
113 94
114 - public void rollOver()
115 - {
95 + public void rollOver() {
116 96 moveSides( Result, Other, // Rotate around the East-West Axis
117 97 North, South, //
118 98 South, North, //
119 99 Other, Result );
120 100 }
121 101
122 - private void rotateEastOrWestToNorth( View pFromSide )
123 - {
102 + private void rotateEastOrWestToNorth( View pFromSide ) {
124 103 View zOpposite = pFromSide.opposite();
125 104 moveSides( pFromSide, North, //
126 105 North, zOpposite, //
  @@ -128,8 +107,7 @@
128 107 South, pFromSide );
129 108 }
130 109
131 - private void rollToSide( View pFromSide )
132 - {
110 + private void rollToSide( View pFromSide ) {
133 111 View zOpposite = pFromSide.opposite();
134 112 moveSides( Other, pFromSide, //
135 113 pFromSide, Result, //
  @@ -137,10 +115,8 @@
137 115 zOpposite, Other );
138 116 }
139 117
140 - private void makeResultEqual( int pValue )
141 - {
142 - switch ( getViewForValue( pValue ) )
143 - {
118 + private void makeResultEqual( int pValue ) {
119 + switch ( getViewForValue( pValue ) ) {
144 120 case North:
145 121 makeNorthResult();
146 122 break;
  @@ -161,10 +137,8 @@
161 137 }
162 138 }
163 139
164 - private void makeNorthEqual( int pValue )
165 - {
166 - switch ( getViewForValue( pValue ) )
167 - {
140 + private void makeNorthEqual( int pValue ) {
141 + switch ( getViewForValue( pValue ) ) {
168 142 default: // & North
169 143 break;
170 144 case East:
  @@ -185,11 +159,9 @@
185 159 }
186 160 }
187 161
188 - private synchronized void moveSides( View... pFromToViewPairs )
189 - {
162 + private synchronized void moveSides( View... pFromToViewPairs ) {
190 163 Map<View, Integer> zViewValues = new EnumMap<View, Integer>( mViewValues );
191 - for ( int i = 0; i < pFromToViewPairs.length; )
192 - {
164 + for ( int i = 0; i < pFromToViewPairs.length; ) {
193 165 // **** Do NOT inline the following
194 166 View zFromView = pFromToViewPairs[i++];
195 167 View zToView = pFromToViewPairs[i++];