Skip to content

Commit 427ae0a

Browse files
authored
Added Override annotations, finals, some cleanup and better null checks (#1271)
* Added Override annotations, finals, some cleanup and better null checks * More general null check * Follow naming conventions
1 parent 2023440 commit 427ae0a

File tree

10 files changed

+745
-661
lines changed

10 files changed

+745
-661
lines changed

jme3-niftygui/src/main/java/com/jme3/cinematic/events/GuiEvent.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import com.jme3.export.JmeImporter;
3838
import com.jme3.export.OutputCapsule;
3939
import de.lessvoid.nifty.Nifty;
40+
import de.lessvoid.nifty.screen.Screen;
4041
import java.io.IOException;
4142
import java.util.logging.Level;
4243
import java.util.logging.Logger;
@@ -51,7 +52,7 @@ public class GuiEvent extends AbstractCinematicEvent {
5152
/**
5253
* message logger for this class
5354
*/
54-
static final Logger log = Logger.getLogger(GuiEvent.class.getName());
55+
private static final Logger log = Logger.getLogger(GuiEvent.class.getName());
5556

5657
/**
5758
* name of the associated Nifty screen(not null)
@@ -135,8 +136,9 @@ public void onPlay() {
135136
*/
136137
@Override
137138
public void onStop() {
138-
if (nifty.getCurrentScreen() != null) {
139-
nifty.getCurrentScreen().endScreen(null);
139+
Screen currentScreen = nifty.getCurrentScreen();
140+
if (currentScreen != null) {
141+
currentScreen.endScreen(null);
140142
}
141143
}
142144

jme3-niftygui/src/main/java/com/jme3/cinematic/events/GuiTrack.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import com.jme3.export.JmeImporter;
3838
import com.jme3.export.OutputCapsule;
3939
import de.lessvoid.nifty.Nifty;
40+
import de.lessvoid.nifty.screen.Screen;
4041
import java.io.IOException;
4142

4243
/**
@@ -84,8 +85,9 @@ public void onPlay() {
8485

8586
@Override
8687
public void onStop() {
87-
if (nifty.getCurrentScreen() != null) {
88-
nifty.getCurrentScreen().endScreen(null);
88+
Screen currentScreen = nifty.getCurrentScreen();
89+
if (currentScreen != null) {
90+
currentScreen.endScreen(null);
8991
}
9092
}
9193

jme3-niftygui/src/main/java/com/jme3/niftygui/InputSystemJme.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,15 @@
4646
import de.lessvoid.nifty.spi.input.InputSystem;
4747
import de.lessvoid.nifty.tools.resourceloader.NiftyResourceLoader;
4848
import java.util.ArrayList;
49+
import java.util.List;
4950
import java.util.logging.Level;
5051
import java.util.logging.Logger;
5152

5253
public class InputSystemJme implements InputSystem, RawInputListener {
5354

54-
private final ArrayList<InputEvent> inputQueue = new ArrayList<InputEvent>();
55-
private InputManager inputManager;
56-
private boolean[] niftyOwnsDragging = new boolean[3];
55+
private final List<InputEvent> inputQueue = new ArrayList<>();
56+
private final InputManager inputManager;
57+
private final boolean[] niftyOwnsDragging = new boolean[3];
5758
private int inputPointerId = -1;
5859
private int x, y;
5960
private int height;
@@ -65,6 +66,7 @@ public InputSystemJme(InputManager inputManager) {
6566
this.inputManager = inputManager;
6667
}
6768

69+
@Override
6870
public void setResourceLoader(NiftyResourceLoader niftyResourceLoader) {
6971
}
7072

@@ -101,15 +103,18 @@ public void setHeight(int height) {
101103
this.height = height;
102104
}
103105

106+
@Override
104107
public void setMousePosition(int x, int y) {
105108
// TODO: When does nifty use this?
106109
}
107110

111+
@Override
108112
public void beginInput() {
109113
}
110114

115+
@Override
111116
public void endInput() {
112-
boolean result = nifty.update();
117+
nifty.update();
113118
}
114119

115120
private void handleMouseEvent(int button, boolean value, NiftyInputConsumer nic, InputEvent evt) {
@@ -251,6 +256,7 @@ private void onKeyEventQueued(KeyInputEvent evt, NiftyInputConsumer nic) {
251256
}
252257
}
253258

259+
@Override
254260
public void onMouseMotionEvent(MouseMotionEvent evt) {
255261
// Only forward the event if there's actual motion involved.
256262
if (inputManager.isCursorVisible() && (evt.getDX() != 0
@@ -260,6 +266,7 @@ public void onMouseMotionEvent(MouseMotionEvent evt) {
260266
}
261267
}
262268

269+
@Override
263270
public void onMouseButtonEvent(MouseButtonEvent evt) {
264271
if (evt.getButtonIndex() >= 0 && evt.getButtonIndex() <= 2) {
265272
if (evt.isReleased() || inputManager.isCursorVisible()) {
@@ -270,20 +277,25 @@ public void onMouseButtonEvent(MouseButtonEvent evt) {
270277
}
271278
}
272279

280+
@Override
273281
public void onJoyAxisEvent(JoyAxisEvent evt) {
274282
}
275283

284+
@Override
276285
public void onJoyButtonEvent(JoyButtonEvent evt) {
277286
}
278287

288+
@Override
279289
public void onKeyEvent(KeyInputEvent evt) {
280290
inputQueue.add(evt);
281291
}
282292

293+
@Override
283294
public void onTouchEvent(TouchEvent evt) {
284295
inputQueue.add(evt);
285296
}
286297

298+
@Override
287299
public void forwardEvents(NiftyInputConsumer nic) {
288300
int queueSize = inputQueue.size();
289301

@@ -317,6 +329,8 @@ private void processSoftKeyboard() {
317329
}
318330

319331
softTextDialogInput.requestDialog(SoftTextDialogInput.TEXT_ENTRY_DIALOG, "Enter Text", initialValue, new SoftTextDialogInputListener() {
332+
333+
@Override
320334
public void onSoftText(int action, String text) {
321335
if (action == SoftTextDialogInputListener.COMPLETE) {
322336
textField.setText(text);

0 commit comments

Comments
 (0)