1515import java .awt .event .*;
1616
1717/**
18- * Shows the {@link gov.nasa.worldwind.layers.ViewControlsLayer} and allows you to adjust its size, orientation,
19- * and available controls.
18+ * Shows the {@link gov.nasa.worldwind.layers.ViewControlsLayer} and allows you to adjust its size, orientation, and
19+ * available controls.
2020 *
2121 * @author Patrick Murris
2222 * @version $Id: ViewControls.java 2109 2014-06-30 16:52:38Z tgaskins $
2323 * @see gov.nasa.worldwind.layers.ViewControlsLayer
2424 * @see gov.nasa.worldwind.layers.ViewControlsSelectListener
2525 * @see gov.nasa.worldwind.layers.CompassLayer
2626 */
27- public class ViewControls extends ApplicationTemplate
28- {
29- public static class AppFrame extends ApplicationTemplate .AppFrame
30- {
27+ public class ViewControls extends ApplicationTemplate {
28+
29+ public static class AppFrame extends ApplicationTemplate .AppFrame {
30+
3131 protected ViewControlsLayer viewControlsLayer ;
3232
33- public AppFrame ()
34- {
33+ public AppFrame () {
3534 super (true , true , false );
3635
3736 // Find ViewControls layer and keep reference to it
38- for (Layer layer : this .getWwd ().getModel ().getLayers ())
39- {
40- if (layer instanceof ViewControlsLayer )
41- {
37+ for (Layer layer : this .getWwd ().getModel ().getLayers ()) {
38+ if (layer instanceof ViewControlsLayer ) {
4239 viewControlsLayer = (ViewControlsLayer ) layer ;
4340 }
4441 }
@@ -47,12 +44,11 @@ public AppFrame()
4744 this .getControlPanel ().add (makeControlPanel (), BorderLayout .SOUTH );
4845 }
4946
50- private JPanel makeControlPanel ()
51- {
47+ private JPanel makeControlPanel () {
5248 JPanel controlPanel = new JPanel ();
5349 controlPanel .setLayout (new BoxLayout (controlPanel , BoxLayout .Y_AXIS ));
5450 controlPanel .setBorder (
55- new CompoundBorder (BorderFactory .createEmptyBorder (9 , 9 , 9 , 9 ), new TitledBorder ("View Controls" )));
51+ new CompoundBorder (BorderFactory .createEmptyBorder (9 , 9 , 9 , 9 ), new TitledBorder ("View Controls" )));
5652 controlPanel .setToolTipText ("Select active view controls" );
5753
5854 // Radio buttons - layout
@@ -61,24 +57,16 @@ private JPanel makeControlPanel()
6157 ButtonGroup group = new ButtonGroup ();
6258 JRadioButton button = new JRadioButton ("Horizontal" , true );
6359 group .add (button );
64- button .addActionListener (new ActionListener ()
65- {
66- public void actionPerformed (ActionEvent actionEvent )
67- {
68- viewControlsLayer .setLayout (AVKey .HORIZONTAL );
69- getWwd ().redraw ();
70- }
60+ button .addActionListener ((ActionEvent actionEvent ) -> {
61+ viewControlsLayer .setLayout (AVKey .HORIZONTAL );
62+ getWwd ().redraw ();
7163 });
7264 layoutPanel .add (button );
7365 button = new JRadioButton ("Vertical" , false );
7466 group .add (button );
75- button .addActionListener (new ActionListener ()
76- {
77- public void actionPerformed (ActionEvent actionEvent )
78- {
79- viewControlsLayer .setLayout (AVKey .VERTICAL );
80- getWwd ().redraw ();
81- }
67+ button .addActionListener ((ActionEvent actionEvent ) -> {
68+ viewControlsLayer .setLayout (AVKey .VERTICAL );
69+ getWwd ().redraw ();
8270 });
8371 layoutPanel .add (button );
8472
@@ -87,13 +75,9 @@ public void actionPerformed(ActionEvent actionEvent)
8775 scalePanel .setBorder (BorderFactory .createEmptyBorder (5 , 5 , 5 , 5 ));
8876 scalePanel .add (new JLabel ("Scale:" ));
8977 JSlider scaleSlider = new JSlider (1 , 20 , 10 );
90- scaleSlider .addChangeListener (new ChangeListener ()
91- {
92- public void stateChanged (ChangeEvent event )
93- {
94- viewControlsLayer .setScale (((JSlider ) event .getSource ()).getValue () / 10d );
95- getWwd ().redraw ();
96- }
78+ scaleSlider .addChangeListener ((ChangeEvent event ) -> {
79+ viewControlsLayer .setScale (((JSlider ) event .getSource ()).getValue () / 10d );
80+ getWwd ().redraw ();
9781 });
9882 scalePanel .add (scaleSlider );
9983
@@ -103,73 +87,49 @@ public void stateChanged(ChangeEvent event)
10387
10488 JCheckBox check = new JCheckBox ("Pan" );
10589 check .setSelected (true );
106- check .addActionListener (new ActionListener ()
107- {
108- public void actionPerformed (ActionEvent actionEvent )
109- {
110- viewControlsLayer .setShowPanControls (((JCheckBox ) actionEvent .getSource ()).isSelected ());
111- getWwd ().redraw ();
112- }
90+ check .addActionListener ((ActionEvent actionEvent ) -> {
91+ viewControlsLayer .setShowPanControls (((JCheckBox ) actionEvent .getSource ()).isSelected ());
92+ getWwd ().redraw ();
11393 });
11494 checkPanel .add (check );
11595
11696 check = new JCheckBox ("Look" );
11797 check .setSelected (false );
118- check .addActionListener (new ActionListener ()
119- {
120- public void actionPerformed (ActionEvent actionEvent )
121- {
122- viewControlsLayer .setShowLookControls (((JCheckBox ) actionEvent .getSource ()).isSelected ());
123- getWwd ().redraw ();
124- }
98+ check .addActionListener ((ActionEvent actionEvent ) -> {
99+ viewControlsLayer .setShowLookControls (((JCheckBox ) actionEvent .getSource ()).isSelected ());
100+ getWwd ().redraw ();
125101 });
126102 checkPanel .add (check );
127103
128104 check = new JCheckBox ("Zoom" );
129105 check .setSelected (true );
130- check .addActionListener (new ActionListener ()
131- {
132- public void actionPerformed (ActionEvent actionEvent )
133- {
134- viewControlsLayer .setShowZoomControls (((JCheckBox ) actionEvent .getSource ()).isSelected ());
135- getWwd ().redraw ();
136- }
106+ check .addActionListener ((ActionEvent actionEvent ) -> {
107+ viewControlsLayer .setShowZoomControls (((JCheckBox ) actionEvent .getSource ()).isSelected ());
108+ getWwd ().redraw ();
137109 });
138110 checkPanel .add (check );
139111
140112 check = new JCheckBox ("Heading" );
141113 check .setSelected (true );
142- check .addActionListener (new ActionListener ()
143- {
144- public void actionPerformed (ActionEvent actionEvent )
145- {
146- viewControlsLayer .setShowHeadingControls (((JCheckBox ) actionEvent .getSource ()).isSelected ());
147- getWwd ().redraw ();
148- }
114+ check .addActionListener ((ActionEvent actionEvent ) -> {
115+ viewControlsLayer .setShowHeadingControls (((JCheckBox ) actionEvent .getSource ()).isSelected ());
116+ getWwd ().redraw ();
149117 });
150118 checkPanel .add (check );
151119
152120 check = new JCheckBox ("Pitch" );
153121 check .setSelected (true );
154- check .addActionListener (new ActionListener ()
155- {
156- public void actionPerformed (ActionEvent actionEvent )
157- {
158- viewControlsLayer .setShowPitchControls (((JCheckBox ) actionEvent .getSource ()).isSelected ());
159- getWwd ().redraw ();
160- }
122+ check .addActionListener ((ActionEvent actionEvent ) -> {
123+ viewControlsLayer .setShowPitchControls (((JCheckBox ) actionEvent .getSource ()).isSelected ());
124+ getWwd ().redraw ();
161125 });
162126 checkPanel .add (check );
163127
164128 check = new JCheckBox ("Field of view" );
165129 check .setSelected (false );
166- check .addActionListener (new ActionListener ()
167- {
168- public void actionPerformed (ActionEvent actionEvent )
169- {
170- viewControlsLayer .setShowFovControls (((JCheckBox ) actionEvent .getSource ()).isSelected ());
171- getWwd ().redraw ();
172- }
130+ check .addActionListener ((ActionEvent actionEvent ) -> {
131+ viewControlsLayer .setShowFovControls (((JCheckBox ) actionEvent .getSource ()).isSelected ());
132+ getWwd ().redraw ();
173133 });
174134 checkPanel .add (check );
175135
@@ -180,8 +140,7 @@ public void actionPerformed(ActionEvent actionEvent)
180140 }
181141 }
182142
183- public static void main (String [] args )
184- {
143+ public static void main (String [] args ) {
185144 ApplicationTemplate .start ("WorldWind View Controls" , AppFrame .class );
186145 }
187146}
0 commit comments