FileDocCategorySizeDatePackage
FitsViewer.javaAPI DocExample1526Sat Sep 09 21:21:00 BST 2000None

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);
      // add space for title bar on top
      height += this.getInsets().top;
      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 e) {
        System.err.println(args[i] + " is not a URL I recognize."); 
      }
      catch (IOException e) {
        e.printStackTrace(); 
      }
    }
  
  
public voidpaint(java.awt.Graphics g)

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