From b6fe7336b87a11610a88a0cd55f38c673a7fabb8 Mon Sep 17 00:00:00 2001 From: Allen Lee Date: Fri, 22 Nov 2019 22:20:13 -0700 Subject: [PATCH] repaint main panel to avoid flickering on windows - issue repaint to top level component instead of just the SubjectView --- .../java/edu/asu/commons/foraging/ui/GameWindow2D.java | 2 +- .../java/edu/asu/commons/foraging/ui/GridView.java | 10 ++++------ .../java/edu/asu/commons/foraging/ui/SubjectView.java | 10 ++-------- 3 files changed, 7 insertions(+), 15 deletions(-) mode change 100644 => 100755 src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java mode change 100644 => 100755 src/main/java/edu/asu/commons/foraging/ui/GridView.java mode change 100644 => 100755 src/main/java/edu/asu/commons/foraging/ui/SubjectView.java diff --git a/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java b/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java old mode 100644 new mode 100755 index 433e9fbf..ec816a12 --- a/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java +++ b/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java @@ -433,7 +433,7 @@ public void actionPerformed(ActionEvent e) { if (singlePlayer) { dataModel.moveClient(direction); event = new MovementEvent(client.getId(), direction); - subjectView.repaint(); + getPanel().repaint(); } else { event = new ClientMovementRequest(client.getId(), direction); diff --git a/src/main/java/edu/asu/commons/foraging/ui/GridView.java b/src/main/java/edu/asu/commons/foraging/ui/GridView.java old mode 100644 new mode 100755 index 800e13ce..14051d47 --- a/src/main/java/edu/asu/commons/foraging/ui/GridView.java +++ b/src/main/java/edu/asu/commons/foraging/ui/GridView.java @@ -23,13 +23,10 @@ import edu.asu.commons.util.ResourceLoader; /** - * $Id$ - * + * Superclass for experimenter and subject views of the simulation world. + * * @author Allen Lee - * @version $Revision$ - * - * Superclass for experimenter and subject views of the simulation - * world. + * */ @SuppressWarnings("serial") public abstract class GridView extends JPanel { @@ -230,6 +227,7 @@ private Image loadImage(String path) { } protected void paintComponent(Graphics graphics) { + super.paintComponent(graphics); Graphics2D graphics2D = (Graphics2D) graphics; graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // FIXME: can be made more efficient. diff --git a/src/main/java/edu/asu/commons/foraging/ui/SubjectView.java b/src/main/java/edu/asu/commons/foraging/ui/SubjectView.java old mode 100644 new mode 100755 index 6034d79a..18619645 --- a/src/main/java/edu/asu/commons/foraging/ui/SubjectView.java +++ b/src/main/java/edu/asu/commons/foraging/ui/SubjectView.java @@ -24,19 +24,13 @@ import edu.asu.commons.util.Duration; /** - * $Id$ - *

* This class encapsulates the client's view of the game board. Used by the * ForagerGameWindow to render the current state of the game. * - *
* FIXME: refactor field of vision - *

- * - * + * * @author Allen Lee - * @version $Revision$ - * + * */ public class SubjectView extends GridView {