From 248e5f685a88c889f4bc80d4875cc663283065f4 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Mon, 10 Nov 2014 20:40:06 +0100 Subject: [PATCH] Move RenderingHints into GameFrame method. --- src/de/teamteamteam/spacescooter/GameFrame.java | 12 +++++++++++- .../spacescooter/screen/GameOverScreen.java | 3 --- .../spacescooter/screen/GamePausedScreen.java | 3 --- .../spacescooter/screen/LoadingScreen.java | 3 --- .../spacescooter/screen/MainMenuScreen.java | 3 --- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/de/teamteamteam/spacescooter/GameFrame.java b/src/de/teamteamteam/spacescooter/GameFrame.java index 995ac17..5159e9f 100644 --- a/src/de/teamteamteam/spacescooter/GameFrame.java +++ b/src/de/teamteamteam/spacescooter/GameFrame.java @@ -1,8 +1,10 @@ package de.teamteamteam.spacescooter; import java.awt.Graphics2D; +import java.awt.RenderingHints; import java.awt.Toolkit; import java.awt.image.BufferStrategy; + import javax.swing.JFrame; import de.teamteamteam.spacescooter.control.Keyboard; @@ -97,6 +99,7 @@ public class GameFrame extends JFrame { do { // bufferStrategy.contentsRestored() try { bufferedGraphics = (Graphics2D) this.bufferStrategy.getDrawGraphics(); + this.applyRenderingHints(bufferedGraphics); this.superScreen.doPaint(bufferedGraphics); //Trigger the actual paint routines. } catch (Exception e) { System.err.println("Exception in GameFrame.draw() gefangen:"); @@ -112,4 +115,11 @@ public class GameFrame extends JFrame { Toolkit.getDefaultToolkit().sync(); //Tell the OS to update its graphics of the window. } -} + /** + * Apply rendering hints to the given Graphics2D. + */ + private void applyRenderingHints(Graphics2D bufferedGraphics) { + bufferedGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + bufferedGraphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + } +} \ No newline at end of file diff --git a/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java b/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java index 521dbc7..cbb63fd 100644 --- a/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/GameOverScreen.java @@ -5,7 +5,6 @@ import java.awt.Font; import java.awt.Graphics2D; import java.awt.event.KeyEvent; import java.awt.image.BufferedImage; -import java.awt.RenderingHints; import de.teamteamteam.spacescooter.control.Keyboard; import de.teamteamteam.spacescooter.entity.Player; @@ -40,8 +39,6 @@ public class GameOverScreen extends Screen { @Override protected void paint(Graphics2D g) { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); g.drawImage(this.img, 0, 0, null); this.entityPaintIterator.reset(); while (this.entityPaintIterator.hasNext()) { diff --git a/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java b/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java index 5ba5dfa..da0abca 100644 --- a/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/GamePausedScreen.java @@ -5,7 +5,6 @@ import java.awt.Font; import java.awt.Graphics2D; import java.awt.event.KeyEvent; import java.awt.image.BufferedImage; -import java.awt.RenderingHints; import de.teamteamteam.spacescooter.control.Keyboard; import de.teamteamteam.spacescooter.entity.Player; @@ -40,8 +39,6 @@ public class GamePausedScreen extends Screen { @Override protected void paint(Graphics2D g) { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); g.drawImage(this.img, 0, 0, null); this.entityPaintIterator.reset(); while (this.entityPaintIterator.hasNext()) { diff --git a/src/de/teamteamteam/spacescooter/screen/LoadingScreen.java b/src/de/teamteamteam/spacescooter/screen/LoadingScreen.java index 0cfd28a..71143b2 100644 --- a/src/de/teamteamteam/spacescooter/screen/LoadingScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/LoadingScreen.java @@ -3,7 +3,6 @@ package de.teamteamteam.spacescooter.screen; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; -import java.awt.RenderingHints; import de.teamteamteam.spacescooter.utility.GameConfig; /** @@ -37,8 +36,6 @@ public class LoadingScreen extends Screen { @Override protected void paint(Graphics2D g) { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(new Color(0,0,120)); g.fillRect(0, 0, GameConfig.windowWidth, GameConfig.windowHeight); g.setColor(new Color(255,255,255)); diff --git a/src/de/teamteamteam/spacescooter/screen/MainMenuScreen.java b/src/de/teamteamteam/spacescooter/screen/MainMenuScreen.java index e4de836..f06075f 100644 --- a/src/de/teamteamteam/spacescooter/screen/MainMenuScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/MainMenuScreen.java @@ -4,7 +4,6 @@ import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.event.KeyEvent; -import java.awt.RenderingHints; import de.teamteamteam.spacescooter.background.StarBackground; import de.teamteamteam.spacescooter.control.Keyboard; @@ -40,8 +39,6 @@ public class MainMenuScreen extends Screen { @Override public void paint(Graphics2D g) { - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); this.entityPaintIterator.reset(); while (this.entityPaintIterator.hasNext()) { this.entityPaintIterator.next().paint(g);