< prev index next >

src/com/sun/javatest/exec/MultiFormatPane.java

Print this page
rev 145 : 7902237: Fixing raw use of parameterized class
Reviewed-by: jjg


  24  * or visit www.oracle.com if you need additional information or have any
  25  * questions.
  26  */
  27 package com.sun.javatest.exec;
  28 
  29 import com.sun.javatest.tool.UIFactory;
  30 import com.sun.javatest.report.HTMLWriterEx;
  31 
  32 import java.awt.*;
  33 import java.awt.event.ActionEvent;
  34 import java.awt.event.ActionListener;
  35 import java.awt.print.PageFormat;
  36 import java.awt.print.Printable;
  37 import java.io.*;
  38 import java.net.MalformedURLException;
  39 import java.net.URL;
  40 import java.nio.charset.StandardCharsets;
  41 import java.util.HashMap;
  42 import java.util.Iterator;
  43 import javax.imageio.ImageIO;

  44 import javax.imageio.stream.ImageInputStream;
  45 import javax.sound.midi.InvalidMidiDataException;
  46 import javax.sound.midi.MidiFileFormat;
  47 import javax.sound.midi.MidiSystem;
  48 import javax.sound.midi.Sequence;
  49 import javax.sound.midi.Sequencer;
  50 import javax.sound.sampled.AudioFileFormat;
  51 import javax.sound.sampled.AudioFormat;
  52 import javax.sound.sampled.AudioInputStream;
  53 import javax.sound.sampled.AudioSystem;
  54 import javax.sound.sampled.Clip;
  55 import javax.sound.sampled.DataLine;
  56 import javax.sound.sampled.LineEvent;
  57 import javax.sound.sampled.LineListener;
  58 import javax.sound.sampled.UnsupportedAudioFileException;
  59 import javax.swing.*;
  60 import javax.swing.event.HyperlinkEvent;
  61 import javax.swing.event.HyperlinkListener;
  62 import javax.swing.text.*;
  63 import javax.swing.text.html.HTML;


 942     }
 943 
 944     public int getMode() {
 945         return MultiFormatPane.IMAGE;
 946     }
 947 
 948     public void showImage(URL url) {
 949         if(isImageFormatSupported(url)) {
 950             ImageIcon img = new ImageIcon(url);
 951             setIcon(img);
 952 
 953             owner.setViewportView(this);
 954             owner.revalidate();
 955             owner.repaint();
 956         }
 957     }
 958 
 959     public static boolean isImageResource(URL url) {
 960         String file = url.getFile();
 961         String ext = file.substring(file.lastIndexOf('.')+1);
 962         Iterator iter = ImageIO.getImageReadersBySuffix(ext);
 963         return iter.hasNext();
 964     }
 965 
 966     public static boolean isImageFormatSupported(URL url) {
 967         try {
 968             ImageInputStream iis = ImageIO.createImageInputStream(new File(url.getFile()));
 969             Iterator iter = ImageIO.getImageReaders(iis);
 970             if(!iter.hasNext())
 971                 return false;
 972         } catch (IOException exc) {
 973             exc.printStackTrace();
 974             return false;
 975         }
 976         return true;
 977     }
 978 
 979     private JScrollPane owner;
 980 }
 981 
 982 class ErrorFormatPane extends JPanel implements MultiFormatPane.MediaPane {
 983     public ErrorFormatPane(UIFactory uif, String uiKey, JScrollPane owner) {
 984         super();
 985         uif.initPanel(this, uiKey, true);
 986 
 987         this.owner = owner;
 988 
 989         setLayout(new GridBagLayout());




  24  * or visit www.oracle.com if you need additional information or have any
  25  * questions.
  26  */
  27 package com.sun.javatest.exec;
  28 
  29 import com.sun.javatest.tool.UIFactory;
  30 import com.sun.javatest.report.HTMLWriterEx;
  31 
  32 import java.awt.*;
  33 import java.awt.event.ActionEvent;
  34 import java.awt.event.ActionListener;
  35 import java.awt.print.PageFormat;
  36 import java.awt.print.Printable;
  37 import java.io.*;
  38 import java.net.MalformedURLException;
  39 import java.net.URL;
  40 import java.nio.charset.StandardCharsets;
  41 import java.util.HashMap;
  42 import java.util.Iterator;
  43 import javax.imageio.ImageIO;
  44 import javax.imageio.ImageReader;
  45 import javax.imageio.stream.ImageInputStream;
  46 import javax.sound.midi.InvalidMidiDataException;
  47 import javax.sound.midi.MidiFileFormat;
  48 import javax.sound.midi.MidiSystem;
  49 import javax.sound.midi.Sequence;
  50 import javax.sound.midi.Sequencer;
  51 import javax.sound.sampled.AudioFileFormat;
  52 import javax.sound.sampled.AudioFormat;
  53 import javax.sound.sampled.AudioInputStream;
  54 import javax.sound.sampled.AudioSystem;
  55 import javax.sound.sampled.Clip;
  56 import javax.sound.sampled.DataLine;
  57 import javax.sound.sampled.LineEvent;
  58 import javax.sound.sampled.LineListener;
  59 import javax.sound.sampled.UnsupportedAudioFileException;
  60 import javax.swing.*;
  61 import javax.swing.event.HyperlinkEvent;
  62 import javax.swing.event.HyperlinkListener;
  63 import javax.swing.text.*;
  64 import javax.swing.text.html.HTML;


 943     }
 944 
 945     public int getMode() {
 946         return MultiFormatPane.IMAGE;
 947     }
 948 
 949     public void showImage(URL url) {
 950         if(isImageFormatSupported(url)) {
 951             ImageIcon img = new ImageIcon(url);
 952             setIcon(img);
 953 
 954             owner.setViewportView(this);
 955             owner.revalidate();
 956             owner.repaint();
 957         }
 958     }
 959 
 960     public static boolean isImageResource(URL url) {
 961         String file = url.getFile();
 962         String ext = file.substring(file.lastIndexOf('.')+1);
 963         Iterator<ImageReader> iter = ImageIO.getImageReadersBySuffix(ext);
 964         return iter.hasNext();
 965     }
 966 
 967     public static boolean isImageFormatSupported(URL url) {
 968         try {
 969             ImageInputStream iis = ImageIO.createImageInputStream(new File(url.getFile()));
 970             Iterator<ImageReader> iter = ImageIO.getImageReaders(iis);
 971             if(!iter.hasNext())
 972                 return false;
 973         } catch (IOException exc) {
 974             exc.printStackTrace();
 975             return false;
 976         }
 977         return true;
 978     }
 979 
 980     private JScrollPane owner;
 981 }
 982 
 983 class ErrorFormatPane extends JPanel implements MultiFormatPane.MediaPane {
 984     public ErrorFormatPane(UIFactory uif, String uiKey, JScrollPane owner) {
 985         super();
 986         uif.initPanel(this, uiKey, true);
 987 
 988         this.owner = owner;
 989 
 990         setLayout(new GridBagLayout());


< prev index next >