Skip to content

Commit

Permalink
repaint main panel to avoid flickering on windows
Browse files Browse the repository at this point in the history
- issue repaint to top level component instead of just the SubjectView
  • Loading branch information
alee committed Nov 23, 2019
1 parent 37b5ff3 commit b6fe733
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/edu/asu/commons/foraging/ui/GridView.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 2 additions & 8 deletions src/main/java/edu/asu/commons/foraging/ui/SubjectView.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,13 @@
import edu.asu.commons.util.Duration;

/**
* $Id$
* <p>
* This class encapsulates the client's view of the game board. Used by the
* ForagerGameWindow to render the current state of the game.
*
* <br/>
* FIXME: refactor field of vision
* </p>
*
*
*
* @author Allen Lee
* @version $Revision$
*
*
*/
public class SubjectView extends GridView {

Expand Down

0 comments on commit b6fe733

Please sign in to comment.