More Graphics 3 23 2011 Opening Discussion Minute essay comments Following along in class and little errors Animation suggestions g drawAnimation Importing movie files Doing gradient paints Add a Timer and cycle through images IcP solutions Images We talked briefly last time about how to load images with ImageIO We need to talk a bit more about the BufferedImage It is a raster image a 2 D grid of pixels If you make a BufferedImage you can use createGraphics to get a Graphics2D that will draw to it Double Buffering The proper way to write the paint method is to have a BufferedImage that you draw to then draw the image to the provided Graphics2D object This is called double buffering and it prevents flicker and can make things run faster Mouse Events There are several types of events that relate to the mouse MouseClicked MouseDragged MousePressed Listen to one of the publishers on a component mouse clicks mouse moves mouse wheel Key Events There are three event types for keys KeyPressed KeyReleased KeyTyped Listen to the keys object in a component to get these Compare the key value in the event to values in the Key object if e key Key A if e key Key Left TexturePaint Now that we can use images we can test out the TexturePaint Writing Transforms Last time we mentioned AffineTransforms but didn t see what they can do Let s take some time now to write code that uses an AffineTransform in our drawing Minute Essay Questions about graphics before we move to sorting
View Full Document