16-Multithreaded-Graphics

16-Multithreaded-Gra - 2006 Marty Hall Multithreaded Graphics J2EE Training http/courses.coreservlets.com 2 Servlets JSP Struts JSF Hibernate AJAX

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
2 J2EE Training: http://courses.coreservlets.com/ Servlets, JSP, Struts, JSF, Hibernate, AJAX, Java 5, etc. Developed and taught by well-known author and developer. At public venues or onsite at your location. © 2006 Marty Hall Multithreaded Graphics 3 Developed and taught by well-known author and developer. At public venues or onsite at your location. © 2006 Marty Hall For live Java training, please see training courses at http://courses.coreservlets.com/. Servlets, JSP, Struts, JSF, AJAX, Java 5, etc. Taught by the author of Core Servlets and JSP , More Servlets and JSP , and this tutorial. Available at public venues, or customized versions can be held on-site at your organization.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 J2EE training: http://courses.coreservlets.com Agenda Approaches for multithreaded graphics Redraw everything in paint Have routines other than paint draw directly on window Override update and have paint do incremental updating Double buffering Reducing flicker in animations Implementing double buffering Animating images Controlling timers 5 J2EE training: http://courses.coreservlets.com Multithreaded Graphics: Alternative Approaches Redraw everything in paint Simple and easy, but if things change quickly it is slow and can result in a flickering display Have routines other than paint directly do drawing operations Easy, efficient, and flicker-free, but results in “transient” drawing that is lost next time the screen is redrawn Override update and have paint do incremental updating Eliminates the flicker and improves efficiency somewhat, but requires the graphics to be non-overlapping Double buffering Most efficient option and has no problem with overlapping graphics. More complex and requires additional memory resources
Background image of page 2
6 J2EE training: http://courses.coreservlets.com Redraw Everything in paint Idea Have user actions change non-graphical data structures, then call repaint . The repaint method sets a flag that tells the event- handling process to call update . The standard update method clears the screen and then calls paint . The paint method completely redraws everything. Advantage Easy Disadvantages Flickers, slow. 7 J2EE training: http://courses.coreservlets.com Redrawing Everything in paint : Example import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.util.Vector; /** Applet that draws a small circle where you click. */ public class DrawCircles extends Applet { private Vector circles; public void init() { circles = new Vector(); addMouseListener(new CircleDrawer()); setBackground(Color.white); } ...
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 J2EE training: http://courses.coreservlets.com Redrawing Everything in paint: Example (Continued) /** When you click the mouse, create a SimpleCircle, * put it in the Vector, and tell the system * to repaint (which calls update, which clears * the screen and calls paint).
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/16/2009 for the course CSCI 571 taught by Professor Papa during the Summer '07 term at USC.

Page1 / 20

16-Multithreaded-Gra - 2006 Marty Hall Multithreaded Graphics J2EE Training http/courses.coreservlets.com 2 Servlets JSP Struts JSF Hibernate AJAX

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online