FileDocCategorySizeDatePackage
FitsViewer.javaAPI DocExample1445Sun Dec 12 10:55:44 GMT 2004None

FitsViewer

public class FitsViewer extends JFrame

Fields Summary
private URL
url
private Image
theImage
Constructors Summary
public FitsViewer(URL u)

  
    super(u.getFile());
    this.url = u;
  
Methods Summary
public voidloadImage()

     
    Object content = this.url.getContent();
    ImageProducer producer;
    try {
      producer = (ImageProducer) content;
    }
    catch (ClassCastException e) {
      throw new IOException("Unexpected type " + content.getClass());        
    }
    if (producer == null) theImage = null;
    else {
      theImage = this.createImage(producer);
      int width = theImage.getWidth(this);
      int height = theImage.getHeight(this);
      if (width > 0 && height > 0) this.setSize(width, height);
    }
    
  
public static voidmain(java.lang.String[] args)

  
    URLConnection.setContentHandlerFactory(new FitsFactory());
    for (int i = 0; i < args.length; i++) {
      try {
        FitsViewer f = new FitsViewer(new URL(args[i]));
        f.setSize(252, 252);
        f.loadImage();
        f.show();
      }
      catch (MalformedURLException ex) {
        System.err.println(args[i] + " is not a URL I recognize."); 
      }
      catch (IOException ex) {
        ex.printStackTrace(); 
      }
    }
  
public voidpaint(java.awt.Graphics g)

  
    if (theImage != null) g.drawImage(theImage, 0, 0, this);