comparison ScreenAdjuster.java @ 2:77e2655ac09d

Whitespace clean.
author Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no>
date Wed, 08 Jan 2014 19:01:02 +0100
parents c5bdb7bee4a7
children 265f66a2f14f
comparison
equal deleted inserted replaced
1:c5bdb7bee4a7 2:77e2655ac09d
41 fullscreenFrame.add(new JLabel("Press ALT+F4 to exit fullscreen.", 41 fullscreenFrame.add(new JLabel("Press ALT+F4 to exit fullscreen.",
42 SwingConstants.CENTER), 42 SwingConstants.CENTER),
43 BorderLayout.CENTER); 43 BorderLayout.CENTER);
44 */ 44 */
45 validate(); 45 validate();
46 46
47 setVisible(true); 47 setVisible(true);
48 GraphicsEnvironment.getLocalGraphicsEnvironment() 48 GraphicsEnvironment.getLocalGraphicsEnvironment()
49 .getDefaultScreenDevice().setFullScreenWindow(this); 49 .getDefaultScreenDevice().setFullScreenWindow(this);
50 } 50 }
51 else { 51 else {
225 225
226 if (args.length >= 1) { 226 if (args.length >= 1) {
227 fullscreen = false; 227 fullscreen = false;
228 } 228 }
229 //fullscreen = false; 229 //fullscreen = false;
230 230
231 final JFrame fullscreenFrame = new ScreenAdjuster(fullscreen); 231 final JFrame fullscreenFrame = new ScreenAdjuster(fullscreen);
232 232
233 } 233 }
234 234
235 public static void paintCheckers(Graphics g, Rectangle bounds, int size, int numColors, int mode, boolean alternativeColors) 235 public static void paintCheckers(Graphics g, Rectangle bounds, int size, int numColors, int mode, boolean alternativeColors)
236 { 236 {
237 Rectangle cbounds = g.getClipBounds(); 237 Rectangle cbounds = g.getClipBounds();
238 238
239 g.setColor(Color.WHITE); 239 g.setColor(Color.WHITE);
240 //g.fillRect(cbounds.x, cbounds.y, cbounds.width, cbounds.height); 240 //g.fillRect(cbounds.x, cbounds.y, cbounds.width, cbounds.height);
241 g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); 241 g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
242 242
243 //Offset xmin by 1, if cliparea is on an odd boundary 243 //Offset xmin by 1, if cliparea is on an odd boundary
244 int xmin = bounds.x; 244 int xmin = bounds.x;
245 int xmax = bounds.x + bounds.width; 245 int xmax = bounds.x + bounds.width;
246 int ymin = bounds.y; 246 int ymin = bounds.y;
247 int ymax = bounds.y + bounds.height; 247 int ymax = bounds.y + bounds.height;
332 y += (height - width) /2; 332 y += (height - width) /2;
333 } 333 }
334 Log.DEFAULT.println("Geometry:"+bounds.x+"x"+bounds.y+":"+bounds.width + "x" + bounds.height); 334 Log.DEFAULT.println("Geometry:"+bounds.x+"x"+bounds.y+":"+bounds.width + "x" + bounds.height);
335 g.setColor(Color.BLACK); 335 g.setColor(Color.BLACK);
336 g.fillOval(x, y, diameter, diameter); 336 g.fillOval(x, y, diameter, diameter);
337 337
338 break; 338 break;
339 } 339 }
340 case 8: { 340 case 8: {
341 g.setColor(Color.YELLOW); 341 g.setColor(Color.YELLOW);
342 g.drawRect(bounds.x+1, bounds.y+1, bounds.width-2, bounds.height-2); 342 g.drawRect(bounds.x+1, bounds.y+1, bounds.width-2, bounds.height-2);
355 if (messageText.isVisible()) 355 if (messageText.isVisible())
356 messageText.paint(g); 356 messageText.paint(g);
357 */ 357 */
358 if (messageVisible) { 358 if (messageVisible) {
359 drawMessage(g2); 359 drawMessage(g2);
360 } 360 }
361 } 361 }
362 362
363 void drawMessage(Graphics2D g2) 363 void drawMessage(Graphics2D g2)
364 { 364 {
365 Font font = g2.getFont(); 365 Font font = g2.getFont();
373 double y = (bounds.height - totalHeight) /2.0; 373 double y = (bounds.height - totalHeight) /2.0;
374 374
375 for (int i = 0; i < messageText.size(); ++i) { 375 for (int i = 0; i < messageText.size(); ++i) {
376 String text = messageText.get(i); 376 String text = messageText.get(i);
377 if (text.length() > 0 ) { 377 if (text.length() > 0 ) {
378 TextLayout tl = 378 TextLayout tl =
379 new TextLayout(messageText.get(i), 379 new TextLayout(messageText.get(i),
380 font, g2.getFontRenderContext()); 380 font, g2.getFontRenderContext());
381 double textWidth = tl.getBounds().getWidth(); 381 double textWidth = tl.getBounds().getWidth();
382 double x = (bounds.width - textWidth) /2.0; 382 double x = (bounds.width - textWidth) /2.0;
383 383
384 Shape outline = 384 Shape outline =
385 tl.getOutline(AffineTransform.getTranslateInstance(x,y)); 385 tl.getOutline(AffineTransform.getTranslateInstance(x,y));
386 386
387 Rectangle tBounds = outline.getBounds(); 387 Rectangle tBounds = outline.getBounds();
388 388
389 if (messageBBox) { 389 if (messageBBox) {
390 g2.setColor(backgroundColor); 390 g2.setColor(backgroundColor);
391 g2.fillRect(tBounds.x, tBounds.y, tBounds.width, tBounds.height); 391 g2.fillRect(tBounds.x, tBounds.y, tBounds.width, tBounds.height);
399 } 399 }
400 y += fontHeight; 400 y += fontHeight;
401 } 401 }
402 402
403 } 403 }
404 404
405 } 405 }