@@ -26,7 +26,6 @@ public class Exercise15_28 extends Application {
2626 @ Override 
2727 public  void  start (Stage  primaryStage ) {
2828 FanPane  fan  = new  FanPane ();
29- 
3029 HBox  hBox  = new  HBox (5 );
3130 Button  btPause  = new  Button ("Pause" );
3231 Button  btResume  = new  Button ("Resume" );
@@ -56,66 +55,71 @@ public void start(Stage primaryStage) {
5655 btReverse .setOnAction (e  -> fan .reverse ());
5756 }
5857
59- }
60- 
61- class  FanPane  extends  Pane  {
62-  private  double  w  = 200 ;
63-  private  double  h  = 200 ;
64-  private  double  radius  = Math .min (w , h ) * 0.45 ;
65-  private  Arc  arc [] = new  Arc [4 ];
66-  private  double  startAngle  = 30 ;
67-  private  Circle  circle  = new  Circle (w  / 2 , h  / 2 , radius );
68- 
69-  public  FanPane () {
70-  circle .setStroke (Color .BLACK );
71-  circle .setFill (Color .WHITE );
72-  getChildren ().add (circle );
73- 
74-  for  (int  i  = 0 ; i  < 4 ; i ++) {
75-  arc [i ] = new  Arc (w  / 2 , h  / 2 , radius  * 0.9 , radius  * 0.9 , startAngle  + i  * 90 , 35 );
76-  arc [i ].setFill (Color .RED );
77-  arc [i ].setType (ArcType .ROUND );
78-  getChildren ().addAll (arc [i ]);
58+  static  class  FanPane  extends  Pane  {
59+  private  double  w  = 200 ;
60+  private  double  h  = 200 ;
61+  private  double  radius  = Math .min (w , h ) * 0.45 ;
62+  private  Arc  arc [] = new  Arc [4 ];
63+  private  double  startAngle  = 30 ;
64+  private  Circle  circle  = new  Circle (w  / 2 , h  / 2 , radius );
65+ 
66+  public  FanPane () {
67+  circle .setStroke (Color .BLACK );
68+  circle .setFill (Color .WHITE );
69+  getChildren ().add (circle );
70+ 
71+  for  (int  i  = 0 ; i  < 4 ; i ++) {
72+  arc [i ] = new  Arc (w  / 2 ,
73+  h  / 2 ,
74+  radius  * 0.9 ,
75+  radius  * 0.9 ,
76+  startAngle  + i  * 90 ,
77+  35 );
78+  arc [i ].setFill (Color .RED );
79+  arc [i ].setType (ArcType .ROUND );
80+  getChildren ().addAll (arc [i ]);
81+  }
7982 }
80-  }
8183
82-  private  double  increment  = 5 ;
84+    private  double  increment  = 5 ;
8385
84-  public  void  reverse () {
85-  increment  = -increment ;
86-  }
86+    public  void  reverse () {
87+    increment  = -increment ;
88+    }
8789
88-  public  void  move () {
89-  setStartAngle (startAngle  + increment );
90-  }
90+    public  void  move () {
91+    setStartAngle (startAngle  + increment );
92+    }
9193
92-  public  void  setStartAngle (double  angle ) {
93-  startAngle  = angle ;
94-  setValues ();
95-  }
94+    public  void  setStartAngle (double  angle ) {
95+    startAngle  = angle ;
96+    setValues ();
97+    }
9698
97-  public  void  setValues () {
98-  radius  = Math .min (w , h ) * 0.45 ;
99-  circle .setRadius (radius );
100-  circle .setCenterX (w  / 2 );
101-  circle .setCenterY (h  / 2 );
102- 
103-  for  (int  i  = 0 ; i  < 4 ; i ++) {
104-  arc [i ].setRadiusX (radius  * 0.9 );
105-  arc [i ].setRadiusY (radius  * 0.9 );
106-  arc [i ].setCenterX (w  / 2 );
107-  arc [i ].setCenterY (h  / 2 );
108-  arc [i ].setStartAngle (startAngle  + i  * 90 );
99+  public  void  setValues () {
100+  radius  = Math .min (w , h ) * 0.45 ;
101+  circle .setRadius (radius );
102+  circle .setCenterX (w  / 2 );
103+  circle .setCenterY (h  / 2 );
104+ 
105+  for  (int  i  = 0 ; i  < 4 ; i ++) {
106+  arc [i ].setRadiusX (radius  * 0.9 );
107+  arc [i ].setRadiusY (radius  * 0.9 );
108+  arc [i ].setCenterX (w  / 2 );
109+  arc [i ].setCenterY (h  / 2 );
110+  arc [i ].setStartAngle (startAngle  + i  * 90 );
111+  }
109112 }
110-  }
111113
112-  public  void  setW (double  w ) {
113-  this .w  = w ;
114-  setValues ();
115-  }
114+    public  void  setW (double  w ) {
115+    this .w  = w ;
116+    setValues ();
117+    }
116118
117-  public  void  setH (double  h ) {
118-  this .h  = h ;
119-  setValues ();
119+  public  void  setH (double  h ) {
120+  this .h  = h ;
121+  setValues ();
122+  }
120123 }
124+ 
121125}
0 commit comments