public void windowDeactivated(final WindowEvent e) {
}
+ /**
+ * Repaint the view when the window is deiconified.
+ *
+ * Deiconified means that the window is restored from minimized state.
+ */
@Override
public void windowDeiconified(final WindowEvent e) {
viewPanel.repaintDuringNextViewUpdate();
}
+ /**
+ * Do nothing when the window is iconified.
+ *
+ * Iconified means that the window is minimized.
+ * @param e the event to be processed
+ */
@Override
public void windowIconified(final WindowEvent e) {
}
* It tells view to update itself. View can decide if actual re-rendering of
* graphics is needed.
*/
- void updateView() {
+ void ensureThatViewIsUpToDate() {
maintainRenderingContext();
final int millisecondsPassedSinceLastUpdate = getMillisecondsPassedSinceLastUpdate();
return;
}
+ // create new rendering context if window size has changed
if ((renderingContext == null)
|| (renderingContext.width != panelWidth)
|| (renderingContext.height != panelHeight)) {
*/
package eu.svjatoslav.sixth.e3d.gui;
+/**
+ * Timer task that updates view.
+ *
+ * Tries to keep constant FPS.
+ */
public class ViewUpdateTimerTask extends java.util.TimerTask {
public ViewPanel viewPanel;
@Override
public void run() {
-
- // update and possibly render view
- viewPanel.updateView();
+ viewPanel.ensureThatViewIsUpToDate();
}
}