@@ -82,8 +82,8 @@ public abstract class Mode {
8282 */
8383 protected ClassLoader classLoader ;
8484
85- static final int BACKGROUND_WIDTH = 580 ;
86- static final int BACKGROUND_HEIGHT = 250 ;
85+ static final int BACKGROUND_WIDTH = 1025 ;
86+ static final int BACKGROUND_HEIGHT = 65 ;
8787 protected Image backgroundImage ;
8888
8989// public Mode(Base base, File folder) {
@@ -170,9 +170,13 @@ public ClassLoader getClassLoader() {
170170 */
171171 public void setupGUI () {
172172 try {
173- //theme = new Settings(new File(folder, " theme/theme.txt"));
173+ // First load the default theme data for the whole PDE.
174174 theme = new Settings (Base .getContentFile ("lib/theme.txt" ));
175175
176+ // The mode-specific theme.txt file should only contain additions,
177+ // and in extremely rare cases, it might override entries from the
178+ // main theme. Do not override for style changes unless they are
179+ // objectively necessary for your Mode.
176180 File modeTheme = new File (folder , "theme/theme.txt" );
177181 if (modeTheme .exists ()) {
178182 // Override the built-in settings with what the theme provides
@@ -182,8 +186,7 @@ public void setupGUI() {
182186 // other things that have to be set explicitly for the defaults
183187 theme .setColor ("run.window.bgcolor" , SystemColor .control );
184188
185- String suffix = Toolkit .highResDisplay () ? "-2x.png" : ".png" ;
186- backgroundImage = loadImage ("theme/mode" + suffix );
189+ loadBackground ();
187190
188191 } catch (IOException e ) {
189192 Base .showError ("Problem loading theme.txt" ,
@@ -192,8 +195,30 @@ public void setupGUI() {
192195 }
193196
194197
198+ protected void loadBackground () {
199+ String suffix = Toolkit .highResDisplay () ? "-2x.png" : ".png" ;
200+ backgroundImage = loadImage ("theme/mode" + suffix );
201+ if (backgroundImage == null ) {
202+ // If the image wasn't available, try the other resolution.
203+ // i.e. we don't (currently) have low-res versions of mode.png,
204+ // so this will grab the 2x version and scale it when drawn.
205+ suffix = !Toolkit .highResDisplay () ? "-2x.png" : ".png" ;
206+ backgroundImage = loadImage ("theme/mode" + suffix );
207+ }
208+ }
209+
210+
195211 public void drawBackground (Graphics g , int offset ) {
196212 if (backgroundImage != null ) {
213+ if (!Toolkit .highResDisplay ()) {
214+ // Image might be downsampled from a 2x version. If so, we need nice
215+ // anti-aliasing for the very geometric images we're using.
216+ Graphics2D g2 = (Graphics2D ) g ;
217+ g2 .setRenderingHint (RenderingHints .KEY_ANTIALIASING ,
218+ RenderingHints .VALUE_ANTIALIAS_ON );
219+ g2 .setRenderingHint (RenderingHints .KEY_INTERPOLATION ,
220+ RenderingHints .VALUE_INTERPOLATION_BICUBIC );
221+ }
197222 g .drawImage (backgroundImage , 0 , -offset ,
198223 BACKGROUND_WIDTH , BACKGROUND_HEIGHT , null );
199224 }
0 commit comments