lecture10

lecture10 - ISE 582: Information Technology for Industrial...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ISE 582: Information Technology for Industrial Engineering Instructor: Elaine Chew University of Southern California Department of Industrial and Systems Engineering Lecture 10 JAVA Cup 9: Images, Interactive Forms Winston & Narasimhan: Chapt 47,49 13 November 2003 Web Technology for IE 2 JAVA Cup 9 • Adding Images to Applets • Creating Forms and Firing Events 13 November 2003 Web Technology for IE 3 Adding Images to Applets • Move Image Files into Applets • Define Subclass of JComponent • Display Images (in paint method) using drawImage (from Graphics class) • Modify other parts of program 13 November 2003 Web Technology for IE 4 The Parts • MovieApplication • MovieAuxiliaries • MovieDataInterface, MovieData , MovieDataObserver • MovieListListener • MovieInterface, Movie , MovieObserver • MeterInterface, Meter , MeterListener • PosterInterface, Poster 13 November 2003 Web Technology for IE 5 The Poster Interface public interface PosterInterface { // Setter public abstract void setImageFile (String fileName); } public void setImageFile (String s) { if (s != file) { file = s; if (file == null) {image = null;} else { image = MovieAuxiliaries. readMovieImage (file); } } } 13 November 2003 Web Technology for IE 6 The Poster Class Itself import java.awt.*; import javax.swing.*; import java.util.*; public class Poster extends JComponent implements PosterInterface { private String file ; private Image image ; public void setImageFile (String s) { ... } public void paint (Graphics g) { ... } public Dimension getMinimumSize () {return new Dimension(200, 300);} public Dimension getPreferredSize () {return new Dimension(200, 300);} } 13 November 2003 Web Technology for IE 7 Remember… public static Image readMovieImage (String fileName) { try { URL url = MovieAuxiliaries.class . getResource (fileName); if (url == null) {return null;} ImageProducer producer = (ImageProducer) (url.getContent()); if (producer == null) {return null;} Toolkit tk = Toolkit.getDefaultToolkit(); Image image = tk. createImage (producer); return image; } catch (IOException e) {System.out.println(e);}; return null; } Auxili aries 13 November 2003 Web Technology for IE 8 The DrawImage Method • Defined in Graphics class • An instance method • Arguments specify the image, the origin, the dimensions and the component • Usage: g. drawImage (image,x,y,width,height,component) 13 November 2003 Web Technology for IE 9 Poster class: paint : drawImage public void paint (Graphics g) { if (image != null) { Dimension d = getSize(); g.drawImage(image,10,10,d.width-20,d.height-20,this); } } g. drawImage (<image>,<x>,<y>,<width>,<height>,<component>) 13 November 2003 Web Technology for IE 10 Getting Image Dimensions • Usage: image. getWidth ( this ) • Usage: image. getHeight ( this ) • this = component • Method needs to know about the image-displaying properties of the component. 13 November 2003 Web Technology for IE 11 Poster class: paint method 2 public void...
View Full Document

This note was uploaded on 02/01/2009 for the course ISE 582 taught by Professor Chew during the Fall '03 term at USC.

Page1 / 41

lecture10 - ISE 582: Information Technology for Industrial...

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

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