Skip to content

Commit 510cf0c

Browse files
committed
Deprecation/Lint fixes
1 parent 444c2fc commit 510cf0c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1165
-1889
lines changed

src/gov/nasa/worldwind/WorldWind.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ public static Object createComponent(String className) throws WWRuntimeException
211211

212212
try
213213
{
214-
Class c = Class.forName(className.trim());
215-
return c.newInstance();
214+
Class<?> c = Class.forName(className.trim());
215+
return c.getConstructor().newInstance();
216216
}
217217
catch (Exception e)
218218
{

src/gov/nasa/worldwind/awt/KeyEventState.java

Lines changed: 90 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -5,239 +5,229 @@
55
*/
66
package gov.nasa.worldwind.awt;
77

8+
import gov.nasa.worldwind.util.Logging;
89
import java.awt.event.*;
910
import java.util.*;
1011

1112
/**
1213
* @author dcollins
1314
* @version $Id: KeyEventState.java 2193 2014-08-01 23:33:16Z dcollins $
1415
*/
15-
public class KeyEventState implements KeyListener, MouseListener
16-
{
17-
protected static class InputState
18-
{
16+
public class KeyEventState implements KeyListener, MouseListener {
17+
18+
protected static class InputState {
1919

2020
protected int eventType;
2121
protected int keyOrButtonCode;
2222
protected long timestamp;
2323

24-
public InputState(int eventType, int keyOrButtonCode, long timestamp)
25-
{
24+
public InputState(int eventType, int keyOrButtonCode, long timestamp) {
2625
this.eventType = eventType;
2726
this.keyOrButtonCode = keyOrButtonCode;
2827
this.timestamp = timestamp;
2928
}
3029

31-
public int getEventType()
32-
{
30+
public int getEventType() {
3331
return this.eventType;
3432
}
3533

36-
public int getKeyOrButtonCode()
37-
{
34+
public int getKeyOrButtonCode() {
3835
return this.keyOrButtonCode;
3936
}
4037

41-
public long getTimestamp()
42-
{
38+
public long getTimestamp() {
4339
return this.timestamp;
4440
}
4541
}
4642

47-
protected Map<Object, InputState> keyStateMap = new HashMap<Object, InputState>();
48-
protected int modifiers;
43+
protected Map<Object, InputState> keyStateMap = new HashMap<>();
4944
protected int modifiersEx;
50-
protected int mouseModifiers;
5145
protected int mouseModifiersEx;
5246

53-
public KeyEventState()
54-
{
47+
public KeyEventState() {
5548
}
5649

57-
public boolean isKeyDown(int keyCode)
58-
{
50+
public boolean isKeyDown(int keyCode) {
5951
InputState state = this.getKeyState(keyCode);
6052
return state != null && state.getEventType() == KeyEvent.KEY_PRESSED;
6153
}
6254

63-
public int keyState(int keyCode)
64-
{
55+
public int keyState(int keyCode) {
6556
InputState state = this.getKeyState(keyCode);
6657
return state != null && state.getEventType() == KeyEvent.KEY_PRESSED ? 1 : 0;
6758
}
6859

69-
public int getNumKeysDown()
70-
{
71-
if (keyStateMap.isEmpty())
72-
{
73-
return(0);
60+
public int getNumKeysDown() {
61+
if (keyStateMap.isEmpty()) {
62+
return (0);
7463
}
7564
int numKeys = 0;
76-
for (Object o : this.keyStateMap.keySet())
77-
{
65+
for (Object o : this.keyStateMap.keySet()) {
7866
//Integer key = (KeyEvent) o;
7967
InputState is = this.keyStateMap.get(o);
80-
if (is.getEventType() == KeyEvent.KEY_PRESSED)
81-
{
68+
if (is.getEventType() == KeyEvent.KEY_PRESSED) {
8269
numKeys++;
8370
}
8471

8572
}
86-
return(numKeys);
73+
return (numKeys);
8774
}
8875

89-
public int getNumButtonsDown()
90-
{
91-
if (keyStateMap.isEmpty())
92-
{
93-
return(0);
76+
public int getNumButtonsDown() {
77+
if (keyStateMap.isEmpty()) {
78+
return (0);
9479
}
9580
int numKeys = 0;
96-
for (Object o : this.keyStateMap.keySet())
97-
{
98-
//Integer key = (KeyEvent) o;
81+
for (Object o : this.keyStateMap.keySet()) {
9982
InputState is = this.keyStateMap.get(o);
100-
if (is.getEventType() == MouseEvent.MOUSE_PRESSED)
101-
{
83+
if (is.getEventType() == MouseEvent.MOUSE_PRESSED) {
10284
numKeys++;
10385
}
10486

10587
}
106-
return(numKeys);
88+
return (numKeys);
10789
}
10890

109-
public int getModifiers()
110-
{
111-
return this.modifiers;
91+
/**
92+
* @return The same value as {@link #getModifiersEx()}.
93+
* @deprecated Use {@link #getModifiersEx()} instead
94+
*/
95+
@Deprecated
96+
public int getModifiers() {
97+
String msg = Logging.getMessage("generic.OperationDeprecatedAndChanged", "getModifiers", "getModifiersEx");
98+
Logging.logger().severe(msg);
99+
return this.modifiersEx;
112100
}
113101

114-
public int getModifiersEx()
115-
{
102+
/**
103+
* @return The extended event modifiers.
104+
*/
105+
public int getModifiersEx() {
116106
return this.modifiersEx;
117107
}
118108

119-
public int getMouseModifiers()
120-
{
121-
return this.mouseModifiers;
109+
/**
110+
* @return The same value as {@link #getMouseModifiersEx()}.
111+
* @deprecated Use {@link #getMouseModifiersEx()} instead
112+
*/
113+
@Deprecated
114+
public int getMouseModifiers() {
115+
String msg = Logging.getMessage("generic.OperationDeprecatedAndChanged", "getMouseModifiers", "getMouseModifiersEx");
116+
Logging.logger().severe(msg);
117+
return this.mouseModifiersEx;
122118
}
123119

124-
public int getMouseModifiersEx()
125-
{
120+
/**
121+
* @return The extended mouse event modifiers.
122+
*/
123+
public int getMouseModifiersEx() {
126124
return this.mouseModifiersEx;
127125
}
128126

129-
public void clearKeyState()
130-
{
127+
public void clearKeyState() {
131128
this.keyStateMap.clear();
132-
this.modifiers = 0;
133129
this.modifiersEx = 0;
134-
this.mouseModifiers = 0;
135130
this.mouseModifiersEx = 0;
136131
}
137132

138133
@Override
139-
public void keyTyped(KeyEvent e)
140-
{
134+
public void keyTyped(KeyEvent e) {
141135
}
142136

143137
@Override
144-
public void keyPressed(KeyEvent e)
145-
{
138+
public void keyPressed(KeyEvent e) {
146139
this.onKeyEvent(e, KeyEvent.KEY_PRESSED);
147140
}
148141

149142
@Override
150-
public void keyReleased(KeyEvent e)
151-
{
143+
public void keyReleased(KeyEvent e) {
152144
this.removeKeyState(e);
153145
}
154146

155-
protected void onKeyEvent(KeyEvent e, int eventType)
156-
{
157-
if (e == null)
147+
protected void onKeyEvent(KeyEvent e, int eventType) {
148+
if (e == null) {
158149
return;
150+
}
159151

160152
long timestamp = this.getTimeStamp(e, eventType, this.keyStateMap.get(e.getKeyCode()));
161153
this.setKeyState(e.getKeyCode(), new InputState(eventType, e.getKeyCode(), timestamp));
162-
this.setModifiers(e.getModifiers());
163154
this.setModifiersEx(e.getModifiersEx());
164155
}
165156

166157
@Override
167-
public void mouseClicked(java.awt.event.MouseEvent mouseEvent)
168-
{
158+
public void mouseClicked(java.awt.event.MouseEvent mouseEvent) {
169159
}
170160

171161
@Override
172-
public void mousePressed(java.awt.event.MouseEvent e)
173-
{
162+
public void mousePressed(java.awt.event.MouseEvent e) {
174163
long timestamp = this.getTimeStamp(e, MouseEvent.MOUSE_PRESSED, this.keyStateMap.get(e.getModifiersEx()));
175164
this.setKeyState(e.getButton(), new InputState(MouseEvent.MOUSE_PRESSED, e.getButton(), timestamp));
176-
this.setMouseModifiers(e.getModifiers());
177165
this.setMouseModifiersEx(e.getModifiersEx());
178166
}
179167

180-
public void mouseReleased(java.awt.event.MouseEvent e)
181-
{
168+
@Override
169+
public void mouseReleased(java.awt.event.MouseEvent e) {
182170
this.keyStateMap.remove(e.getButton());
183-
this.setMouseModifiers(0);
184171
this.setMouseModifiersEx(0);
185172
}
186173

187-
public void mouseEntered(java.awt.event.MouseEvent mouseEvent)
188-
{
174+
@Override
175+
public void mouseEntered(java.awt.event.MouseEvent mouseEvent) {
189176

190177
}
191178

192-
public void mouseExited(java.awt.event.MouseEvent mouseEvent)
193-
{
194-
179+
@Override
180+
public void mouseExited(java.awt.event.MouseEvent mouseEvent) {
181+
195182
}
196183

197-
protected InputState getKeyState(int keyCode)
198-
{
184+
protected InputState getKeyState(int keyCode) {
199185
return this.keyStateMap.get(keyCode);
200186
}
201187

202-
protected void setKeyState(int keyCode, InputState state)
203-
{
188+
protected void setKeyState(int keyCode, InputState state) {
204189
this.keyStateMap.put(keyCode, state);
205190
}
206191

207-
protected void setModifiers(int modifiers)
208-
{
209-
this.modifiers = modifiers;
192+
/**
193+
* @param modifiers Unused.
194+
* @deprecated Use {@link #setModifiersEx(int)} instead
195+
*/
196+
@Deprecated
197+
protected void setModifiers(int modifiers) {
198+
String msg = Logging.getMessage("generic.OperationDeprecatedAndChanged", "setModifiers", "setModifiersEx");
199+
Logging.logger().severe(msg);
210200
}
211201

212-
protected void setModifiersEx(int modifiersEx)
213-
{
202+
protected void setModifiersEx(int modifiersEx) {
214203
this.modifiersEx = modifiersEx;
215204
}
216205

217-
protected void setMouseModifiersEx(int modifiersEx)
218-
{
206+
protected void setMouseModifiersEx(int modifiersEx) {
219207
this.mouseModifiersEx = modifiersEx;
220208
}
221209

222-
protected void setMouseModifiers(int modifiers)
223-
{
224-
this.mouseModifiers = modifiers;
210+
/**
211+
* @param modifiers Unused.
212+
* @deprecated Use {@link #setMouseModifiersEx(int)} instead
213+
*/
214+
@Deprecated
215+
protected void setMouseModifiers(int modifiers) {
216+
String msg = Logging.getMessage("generic.OperationDeprecatedAndChanged", "setMouseModifiers", "setMouseModifiersEx");
217+
Logging.logger().severe(msg);
225218
}
226219

227-
228-
229220
protected void removeKeyState(KeyEvent e) {
230221
this.keyStateMap.remove(e.getKeyCode());
231-
this.setModifiers(e.getModifiers());
232222
this.setModifiersEx(e.getModifiersEx());
233223
}
234224

235-
protected long getTimeStamp(InputEvent e, int eventType, InputState currentState)
236-
{
225+
protected long getTimeStamp(InputEvent e, int eventType, InputState currentState) {
237226
// If the current state for this input event type exists and is not null, then keep the current timestamp.
238-
if (currentState != null && currentState.getEventType() == eventType)
227+
if (currentState != null && currentState.getEventType() == eventType) {
239228
return currentState.getTimestamp();
229+
}
240230
// Otherwise return the InputEvent's timestamp.
241231
return e.getWhen();
242232
}
243-
}
233+
}

src/gov/nasa/worldwind/cache/BasicMemoryCache.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -408,20 +408,4 @@ public String toString()
408408
return "MemoryCache " + this.name + " max size = " + this.getCapacity() + " current size = "
409409
+ this.currentUsedCapacity.get() + " number of items: " + this.getNumObjects();
410410
}
411-
412-
@Override
413-
protected void finalize() throws Throwable
414-
{
415-
try
416-
{
417-
// clear doesn't throw any checked exceptions
418-
// but this is in case of an unchecked exception
419-
// basically, we don't want to exit without calling super.finalize
420-
this.clear();
421-
}
422-
finally
423-
{
424-
super.finalize();
425-
}
426-
}
427411
}

src/gov/nasa/worldwind/formats/shapefile/ShapefileRecordMultiPoint.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,17 @@ public class ShapefileRecordMultiPoint extends ShapefileRecord
3030
protected double[] mRange; // will be null if no measures
3131
protected double[] mValues; // will be null if no measures
3232

33-
/** {@inheritDoc} */
33+
/**
34+
* Constructs a record instance from the given {@link java.nio.ByteBuffer}. The buffer's current position must be
35+
* the start of the record, and will be the start of the next record when the constructor returns.
36+
*
37+
* @param shapeFile the parent {@link Shapefile}.
38+
* @param buffer the shapefile record {@link java.nio.ByteBuffer} to read from.
39+
*
40+
* @throws IllegalArgumentException if any argument is null or otherwise invalid.
41+
* @throws gov.nasa.worldwind.exception.WWRuntimeException
42+
* if the record's shape type does not match that of the shapefile.
43+
*/
3444
public ShapefileRecordMultiPoint(Shapefile shapeFile, ByteBuffer buffer)
3545
{
3646
super(shapeFile, buffer);

0 commit comments

Comments
 (0)