projects
/
sixth-3d.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improved code readability
[sixth-3d.git]
/
src
/
main
/
java
/
eu
/
svjatoslav
/
sixth
/
e3d
/
gui
/
ViewPanel.java
diff --git
a/src/main/java/eu/svjatoslav/sixth/e3d/gui/ViewPanel.java
b/src/main/java/eu/svjatoslav/sixth/e3d/gui/ViewPanel.java
index
9c0681c
..
a511bc7
100755
(executable)
--- a/
src/main/java/eu/svjatoslav/sixth/e3d/gui/ViewPanel.java
+++ b/
src/main/java/eu/svjatoslav/sixth/e3d/gui/ViewPanel.java
@@
-4,7
+4,7
@@
*/
package eu.svjatoslav.sixth.e3d.gui;
*/
package eu.svjatoslav.sixth.e3d.gui;
-import eu.svjatoslav.sixth.e3d.gui.humaninput.HID
Inpu
tTracker;
+import eu.svjatoslav.sixth.e3d.gui.humaninput.HID
Even
tTracker;
import eu.svjatoslav.sixth.e3d.gui.humaninput.KeyboardFocusStack;
import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
import eu.svjatoslav.sixth.e3d.gui.humaninput.KeyboardFocusStack;
import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
@@
-21,7
+21,7
@@
import java.util.concurrent.ConcurrentHashMap;
*/
public class ViewPanel extends JPanel implements ComponentListener {
private static final long serialVersionUID = 1683277888885045387L;
*/
public class ViewPanel extends JPanel implements ComponentListener {
private static final long serialVersionUID = 1683277888885045387L;
- private final HID
InputTracker HIDInputTracker = new HIDInpu
tTracker(this);
+ private final HID
EventTracker HIDEventTracker = new HIDEven
tTracker(this);
private final KeyboardFocusStack keyboardFocusStack;
private final Avatar avatar = new Avatar();
private final ShapeCollection rootShapeCollection = new ShapeCollection();
private final KeyboardFocusStack keyboardFocusStack;
private final Avatar avatar = new Avatar();
private final ShapeCollection rootShapeCollection = new ShapeCollection();
@@
-49,7
+49,7
@@
public class ViewPanel extends JPanel implements ComponentListener {
public ViewPanel() {
viewRenderListeners.add(avatar);
public ViewPanel() {
viewRenderListeners.add(avatar);
- viewRenderListeners.add(HID
Inpu
tTracker);
+ viewRenderListeners.add(HID
Even
tTracker);
keyboardFocusStack = new KeyboardFocusStack(this);
keyboardFocusStack = new KeyboardFocusStack(this);
@@
-72,8
+72,8
@@
public class ViewPanel extends JPanel implements ComponentListener {
return rootShapeCollection;
}
return rootShapeCollection;
}
- public HID
Inpu
tTracker getHIDInputTracker() {
- return HID
Inpu
tTracker;
+ public HID
Even
tTracker getHIDInputTracker() {
+ return HID
Even
tTracker;
}
public void addViewUpdateListener(final ViewRenderListener listener) {
}
public void addViewUpdateListener(final ViewRenderListener listener) {
@@
-145,13
+145,17
@@
public class ViewPanel extends JPanel implements ComponentListener {
}
/**
}
/**
- * Calling th
is
methods tells 3D engine that current 3D view needs to be
+ * Calling th
ese
methods tells 3D engine that current 3D view needs to be
* repainted on first opportunity.
*/
public void repaintDuringNextViewUpdate() {
viewRepaintNeeded = true;
}
* repainted on first opportunity.
*/
public void repaintDuringNextViewUpdate() {
viewRepaintNeeded = true;
}
+ /**
+ * Set target frames per second rate for this view. Target FPS can be changed at runtime.
+ * @param frameRate target frames per second rate for this view.
+ */
public void setFrameRate(final int frameRate) {
if (canvasUpdateTimerTask != null) {
canvasUpdateTimerTask.cancel();
public void setFrameRate(final int frameRate) {
if (canvasUpdateTimerTask != null) {
canvasUpdateTimerTask.cancel();
@@
-163,25
+167,21
@@
public class ViewPanel extends JPanel implements ComponentListener {
targetFPS = frameRate;
targetFPS = frameRate;
- if (frameRate > 0) {
- canvasUpdateTimer = new Timer();
- canvasUpdateTimerTask = new ViewUpdateTimerTask(this);
+ if (frameRate <= 0) return;
- canvasUpdateTimer.schedule(canvasUpdateTimerTask, 0,
- 1000 / frameRate);
- }
+ canvasUpdateTimer = new Timer();
+ canvasUpdateTimerTask = new ViewUpdateTimerTask(this);
+
+ // schedule timer task to run in frequency according to defined frame rate
+ canvasUpdateTimer.schedule(canvasUpdateTimerTask, 0,
+ 1000 / frameRate);
}
}
+ /**
+ * Stops rendering of this view.
+ */
public void stop() {
public void stop() {
- if (canvasUpdateTimerTask != null) {
- canvasUpdateTimerTask.cancel();
- canvasUpdateTimerTask = null;
- }
-
- if (canvasUpdateTimer != null) {
- canvasUpdateTimer.cancel();
- canvasUpdateTimer = null;
- }
+ setFrameRate(0);
}
/**
}
/**