harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r607327 - in /harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer: AppletFrame.java AppletInfo.java HTMLParser.java Main.java ViewerAppletContext.java ViewerAudioClip.java
Date Fri, 28 Dec 2007 20:58:15 GMT
Author: apetrenko
Date: Fri Dec 28 12:58:14 2007
New Revision: 607327

URL: http://svn.apache.org/viewvc?rev=607327&view=rev
Log:
Tabs are converted to spaces

Modified:
    harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletFrame.java
    harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletInfo.java
    harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/HTMLParser.java
    harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/Main.java
    harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/ViewerAppletContext.java
    harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/ViewerAudioClip.java

Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletFrame.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletFrame.java?rev=607327&r1=607326&r2=607327&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletFrame.java
(original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletFrame.java
Fri Dec 28 12:58:14 2007
@@ -32,79 +32,79 @@
 import javax.swing.SwingConstants;
 
 class AppletFrame extends JFrame {
-	private final AppletInfo appletInfo;
-	private final Applet applet;
-	private final JLabel statusLabel;
-	
-	private static ShutdownHandler shutdownHandler = new ShutdownHandler();
-	
-	public AppletFrame(AppletInfo appletInfo) throws Exception {
-		this.appletInfo = appletInfo;
-		shutdownHandler.addFrame(this);
-		
-		// Load applet class
-		URL []urls = new URL[1];
-		urls[0] = appletInfo.getCodeBase();
-		URLClassLoader cl = new URLClassLoader(urls);
-		Class clz = cl.loadClass(this.appletInfo.getCode());
-		applet = (Applet)clz.newInstance();
-		applet.setStub(new ViewerAppletStub(applet, appletInfo));
-		
-		// Create applet pane
-		setLayout(new BorderLayout());
-		JPanel appletPanel = new JPanel();
-		appletPanel.add(applet);
-		add(appletPanel, BorderLayout.CENTER);
-		applet.setPreferredSize(new Dimension(appletInfo.getWidth(), appletInfo.getHeight()));
-		
-		// Create status pane
-		JPanel panel = new JPanel();
-		statusLabel = new JLabel();
-		panel.add(statusLabel);
-		add(panel, BorderLayout.SOUTH);
-		appletInfo.setStatusLabel(statusLabel);
-		
-		statusLabel.setMinimumSize(new Dimension(100, 40));
-		statusLabel.setHorizontalAlignment(SwingConstants.LEFT);
-
-		// Start applet and make frame visible
-		// Init should be called after pack to make components displayable
-		pack();
-		applet.init();
-		setVisible(true);		
-		applet.start();
-	}		
-	
-	private  static class ShutdownHandler implements WindowListener {
-		HashSet<JFrame> frameList = new HashSet<JFrame>();
-
-		public void windowActivated(WindowEvent e) {
-		}
-
-		public void windowClosed(WindowEvent e) {
-		}
-
-		public void windowClosing(WindowEvent e) {
-			frameList.remove(e.getWindow());
-			if (frameList.isEmpty())
-				System.exit(0);
-		}
-
-		public void windowDeactivated(WindowEvent e) {
-		}
-
-		public void windowDeiconified(WindowEvent e) {
-		}
-
-		public void windowIconified(WindowEvent e) {
-		}
-
-		public void windowOpened(WindowEvent e) {
-		}
-		
-		public void addFrame(JFrame frame) {
-			frameList.add(frame);
-			frame.addWindowListener(this);
-		}
-	}
+    private final AppletInfo appletInfo;
+    private final Applet applet;
+    private final JLabel statusLabel;
+    
+    private static ShutdownHandler shutdownHandler = new ShutdownHandler();
+    
+    public AppletFrame(AppletInfo appletInfo) throws Exception {
+        this.appletInfo = appletInfo;
+        shutdownHandler.addFrame(this);
+        
+        // Load applet class
+        URL []urls = new URL[1];
+        urls[0] = appletInfo.getCodeBase();
+        URLClassLoader cl = new URLClassLoader(urls);
+        Class clz = cl.loadClass(this.appletInfo.getCode());
+        applet = (Applet)clz.newInstance();
+        applet.setStub(new ViewerAppletStub(applet, appletInfo));
+        
+        // Create applet pane
+        setLayout(new BorderLayout());
+        JPanel appletPanel = new JPanel();
+        appletPanel.add(applet);
+        add(appletPanel, BorderLayout.CENTER);
+        applet.setPreferredSize(new Dimension(appletInfo.getWidth(), appletInfo.getHeight()));
+        
+        // Create status pane
+        JPanel panel = new JPanel();
+        statusLabel = new JLabel();
+        panel.add(statusLabel);
+        add(panel, BorderLayout.SOUTH);
+        appletInfo.setStatusLabel(statusLabel);
+        
+        statusLabel.setMinimumSize(new Dimension(100, 40));
+        statusLabel.setHorizontalAlignment(SwingConstants.LEFT);
+
+        // Start applet and make frame visible
+        // Init should be called after pack to make components displayable
+        pack();
+        applet.init();
+        setVisible(true);       
+        applet.start();
+    }       
+    
+    private  static class ShutdownHandler implements WindowListener {
+        HashSet<JFrame> frameList = new HashSet<JFrame>();
+
+        public void windowActivated(WindowEvent e) {
+        }
+
+        public void windowClosed(WindowEvent e) {
+        }
+
+        public void windowClosing(WindowEvent e) {
+            frameList.remove(e.getWindow());
+            if (frameList.isEmpty())
+                System.exit(0);
+        }
+
+        public void windowDeactivated(WindowEvent e) {
+        }
+
+        public void windowDeiconified(WindowEvent e) {
+        }
+
+        public void windowIconified(WindowEvent e) {
+        }
+
+        public void windowOpened(WindowEvent e) {
+        }
+        
+        public void addFrame(JFrame frame) {
+            frameList.add(frame);
+            frame.addWindowListener(this);
+        }
+    }
 }

Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletInfo.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletInfo.java?rev=607327&r1=607326&r2=607327&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletInfo.java
(original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletInfo.java
Fri Dec 28 12:58:14 2007
@@ -24,87 +24,87 @@
 import javax.swing.JLabel;
 
 public class AppletInfo {
-	private static final int DEFAULT_WIDTH=300;
-	private static final int DEFAULT_HEIGHT=200;	
-	
-	private URL documentBase;
-	private URL codeBase;
-	private String code;
-	private int width;
-	private int height;
-	private HashMap<String, String> params;
-	private JLabel statusLabel = null;
-	
-	public AppletInfo() {
-		params = new HashMap<String, String>();
-	}
-
-	public URL getDocumentBase() {
-		return documentBase;
-	}
-
-	public void setDocumentBase(URL documentBase) {
-		this.documentBase = documentBase;
-	}
-
-	public URL getCodeBase() {
-		return codeBase;
-	}
-
-	public void setCodeBase(URL codeBase) {
-		this.codeBase = codeBase;
-	}
-
-	public void setCodeBase(String codeBaseStr) throws MalformedURLException {
-		this.codeBase = new URL(this.documentBase, (codeBaseStr == null)?"./":codeBaseStr);
-	}
-
-	public String getParameter(String name) {
-		return params.get(name.toUpperCase());
-	}
-
-	public void setParameter(String name, String value) {
-		params.put(name.toUpperCase(), value);
-	}
-
-	public String getCode() {
-		return code;
-	}
-
-	public void setCode(String code) {
-		this.code = (code.endsWith(".class"))?code.substring(0, code.length()-6):code;
-	}
-
-	public int getWidth() {
-		return width;
-	}
-
-	public void setWidth(int width) {
-		this.width = width;
-	}
-
-	public void setWidth(String widthStr) {		
-		this.width = (widthStr == null)?DEFAULT_WIDTH:Integer.parseInt(widthStr);
-	}
-
-	public int getHeight() {
-		return height;
-	}
-
-	public void setHeight(int height) {
-		this.height = height;
-	}	
-
-	public void setHeight(String heightStr) {		
-		this.height = (heightStr == null)?DEFAULT_HEIGHT:Integer.parseInt(heightStr);
-	}
-
-	public void setStatusLabel(JLabel statusLabel) {
-		this.statusLabel  = statusLabel;
-	}
-
-	public void setStatus(String text) {
-		if (statusLabel != null)
-			statusLabel.setText(text);
-	}
+    private static final int DEFAULT_WIDTH=300;
+    private static final int DEFAULT_HEIGHT=200;    
+    
+    private URL documentBase;
+    private URL codeBase;
+    private String code;
+    private int width;
+    private int height;
+    private HashMap<String, String> params;
+    private JLabel statusLabel = null;
+    
+    public AppletInfo() {
+        params = new HashMap<String, String>();
+    }
+
+    public URL getDocumentBase() {
+        return documentBase;
+    }
+
+    public void setDocumentBase(URL documentBase) {
+        this.documentBase = documentBase;
+    }
+
+    public URL getCodeBase() {
+        return codeBase;
+    }
+
+    public void setCodeBase(URL codeBase) {
+        this.codeBase = codeBase;
+    }
+
+    public void setCodeBase(String codeBaseStr) throws MalformedURLException {
+        this.codeBase = new URL(this.documentBase, (codeBaseStr == null)?"./":codeBaseStr);
+    }
+
+    public String getParameter(String name) {
+        return params.get(name.toUpperCase());
+    }
+
+    public void setParameter(String name, String value) {
+        params.put(name.toUpperCase(), value);
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = (code.endsWith(".class"))?code.substring(0, code.length()-6):code;
+    }
+
+    public int getWidth() {
+        return width;
+    }
+
+    public void setWidth(int width) {
+        this.width = width;
+    }
+
+    public void setWidth(String widthStr) {     
+        this.width = (widthStr == null)?DEFAULT_WIDTH:Integer.parseInt(widthStr);
+    }
+
+    public int getHeight() {
+        return height;
+    }
+
+    public void setHeight(int height) {
+        this.height = height;
+    }   
+
+    public void setHeight(String heightStr) {       
+        this.height = (heightStr == null)?DEFAULT_HEIGHT:Integer.parseInt(heightStr);
+    }
+
+    public void setStatusLabel(JLabel statusLabel) {
+        this.statusLabel  = statusLabel;
+    }
+
+    public void setStatus(String text) {
+        if (statusLabel != null)
+            statusLabel.setText(text);
+    }
 }

Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/HTMLParser.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/HTMLParser.java?rev=607327&r1=607326&r2=607327&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/HTMLParser.java
(original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/HTMLParser.java
Fri Dec 28 12:58:14 2007
@@ -33,67 +33,67 @@
 import org.xml.sax.helpers.DefaultHandler;
 
 class HTMLParser {
-	HTMLParser() {
-	}
-	
-	Object []parse(String urls[], int start) throws ParserConfigurationException, SAXException,
IOException {
-		SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
-		ArrayList<AppletInfo> list = new ArrayList<AppletInfo>(urls.length-start);
-		for (int i = start; i < urls.length; i++) {
-			AppletHTMLHandler handler = new AppletHTMLHandler(urls[i], list);
-			parser.parse(urls[i], handler);
-		}
-		return list.toArray();
-	}
+    HTMLParser() {
+    }
+    
+    Object []parse(String urls[], int start) throws ParserConfigurationException, SAXException,
IOException {
+        SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
+        ArrayList<AppletInfo> list = new ArrayList<AppletInfo>(urls.length-start);
+        for (int i = start; i < urls.length; i++) {
+            AppletHTMLHandler handler = new AppletHTMLHandler(urls[i], list);
+            parser.parse(urls[i], handler);
+        }
+        return list.toArray();
+    }
 
-	private class AppletHTMLHandler extends DefaultHandler {
-		private URL documentBase;
-		private final ArrayList<AppletInfo> list;
-		private AppletInfo appletInfo = null;
-		private String startElement = null;
-		
-		public AppletHTMLHandler(String url, ArrayList<AppletInfo> list) throws MalformedURLException
{
-			super();
-			
-			// String could represent file path or URL
-			try  {
-				this.documentBase = new URL(url);
-			} catch (MalformedURLException _) {
-				File f = new File(url);
-				this.documentBase = f.toURL();
-			}
-			this.list = list;
-		}
+    private class AppletHTMLHandler extends DefaultHandler {
+        private URL documentBase;
+        private final ArrayList<AppletInfo> list;
+        private AppletInfo appletInfo = null;
+        private String startElement = null;
+        
+        public AppletHTMLHandler(String url, ArrayList<AppletInfo> list) throws MalformedURLException
{
+            super();
+            
+            // String could represent file path or URL
+            try  {
+                this.documentBase = new URL(url);
+            } catch (MalformedURLException _) {
+                File f = new File(url);
+                this.documentBase = f.toURL();
+            }
+            this.list = list;
+        }
 
-		public void startElement(String uri, String lName, String qName, Attributes attrs) throws
SAXException {
-			if (qName.equalsIgnoreCase("APPLET") || qName.equalsIgnoreCase("OBJECT")) {
-				if (startElement != null) {
-					throw new SAXParseException(qName+" inside "+startElement, null);
-				}
-				
-				startElement = qName;
-				appletInfo = new AppletInfo();
-				appletInfo.setDocumentBase(documentBase);
-				appletInfo.setCode(attrs.getValue("code"));
-				try {
-					appletInfo.setCodeBase(attrs.getValue("codebase"));
-				} catch (Exception e) {
-					appletInfo.setCodeBase((URL)null);
-				}
-				appletInfo.setWidth(attrs.getValue("width"));
-				appletInfo.setHeight(attrs.getValue("height"));
-				list.add(appletInfo);
-				return;
-			}
-			
-			if (appletInfo != null && qName.equalsIgnoreCase("PARAM")) {
-				appletInfo.setParameter(attrs.getValue("name"), attrs.getValue("value"));
-			}
-		}
-		
-		public void endElement(String uri, String lName, String qName) throws SAXException {
-			if (qName.equalsIgnoreCase(startElement))
-				startElement = null;
-		}
-	}
+        public void startElement(String uri, String lName, String qName, Attributes attrs)
throws SAXException {
+            if (qName.equalsIgnoreCase("APPLET") || qName.equalsIgnoreCase("OBJECT")) {
+                if (startElement != null) {
+                    throw new SAXParseException(qName+" inside "+startElement, null);
+                }
+                
+                startElement = qName;
+                appletInfo = new AppletInfo();
+                appletInfo.setDocumentBase(documentBase);
+                appletInfo.setCode(attrs.getValue("code"));
+                try {
+                    appletInfo.setCodeBase(attrs.getValue("codebase"));
+                } catch (Exception e) {
+                    appletInfo.setCodeBase((URL)null);
+                }
+                appletInfo.setWidth(attrs.getValue("width"));
+                appletInfo.setHeight(attrs.getValue("height"));
+                list.add(appletInfo);
+                return;
+            }
+            
+            if (appletInfo != null && qName.equalsIgnoreCase("PARAM")) {
+                appletInfo.setParameter(attrs.getValue("name"), attrs.getValue("value"));
+            }
+        }
+        
+        public void endElement(String uri, String lName, String qName) throws SAXException
{
+            if (qName.equalsIgnoreCase(startElement))
+                startElement = null;
+        }
+    }
 }

Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/Main.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/Main.java?rev=607327&r1=607326&r2=607327&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/Main.java
(original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/Main.java
Fri Dec 28 12:58:14 2007
@@ -19,22 +19,22 @@
 
 public class Main {
     public static void main(String argv[]) throws Exception {
-    	if (argv.length == 0) {
-    		printHelp();
-    		return;
-    	}
-    	
-    	HTMLParser parser = new HTMLParser();
-    	Object []applets = parser.parse(argv, 0);
-    	
-    	// Start applets
-    	for (int i = 0; i < applets.length; i++)
-    		new AppletFrame((AppletInfo)applets[i]);
+        if (argv.length == 0) {
+            printHelp();
+            return;
+        }
+        
+        HTMLParser parser = new HTMLParser();
+        Object []applets = parser.parse(argv, 0);
+        
+        // Start applets
+        for (int i = 0; i < applets.length; i++)
+            new AppletFrame((AppletInfo)applets[i]);
     }
 
-	private static void printHelp() {
-		System.err.println("Applet viewer");
-		System.err.println("Usage: appletviewer urls");
-	}
+    private static void printHelp() {
+        System.err.println("Applet viewer");
+        System.err.println("Usage: appletviewer urls");
+    }
 }
 

Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/ViewerAppletContext.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/ViewerAppletContext.java?rev=607327&r1=607326&r2=607327&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/ViewerAppletContext.java
(original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/ViewerAppletContext.java
Fri Dec 28 12:58:14 2007
@@ -29,56 +29,56 @@
 import java.util.Iterator;
 
 class ViewerAppletContext implements AppletContext {
-	private final AppletInfo appletInfo;
+    private final AppletInfo appletInfo;
 
-	public ViewerAppletContext(AppletInfo appletInfo) {
-		this.appletInfo = appletInfo;
-	}
+    public ViewerAppletContext(AppletInfo appletInfo) {
+        this.appletInfo = appletInfo;
+    }
 
-	public Applet getApplet(String name) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    public Applet getApplet(String name) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	public Enumeration<Applet> getApplets() {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    public Enumeration<Applet> getApplets() {
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	public AudioClip getAudioClip(URL url) {
-		return new ViewerAudioClip(url);
-	}
+    public AudioClip getAudioClip(URL url) {
+        return new ViewerAudioClip(url);
+    }
 
-	public Image getImage(URL url) {
-		return Toolkit.getDefaultToolkit().createImage(url);
-	}
+    public Image getImage(URL url) {
+        return Toolkit.getDefaultToolkit().createImage(url);
+    }
 
-	public InputStream getStream(String key) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    public InputStream getStream(String key) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	public Iterator<String> getStreamKeys() {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    public Iterator<String> getStreamKeys() {
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	public void setStream(String key, InputStream stream) throws IOException {
-		// TODO Auto-generated method stub
+    public void setStream(String key, InputStream stream) throws IOException {
+        // TODO Auto-generated method stub
 
-	}
+    }
 
-	public void showDocument(URL url) {
-		// TODO Auto-generated method stub
+    public void showDocument(URL url) {
+        // TODO Auto-generated method stub
 
-	}
+    }
 
-	public void showDocument(URL url, String target) {
-		// TODO Auto-generated method stub
+    public void showDocument(URL url, String target) {
+        // TODO Auto-generated method stub
 
-	}
+    }
 
-	public void showStatus(String status) {
-		appletInfo.setStatus(status);
-	}
+    public void showStatus(String status) {
+        appletInfo.setStatus(status);
+    }
 }

Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/ViewerAudioClip.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/ViewerAudioClip.java?rev=607327&r1=607326&r2=607327&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/ViewerAudioClip.java
(original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/ViewerAudioClip.java
Fri Dec 28 12:58:14 2007
@@ -28,53 +28,53 @@
 import javax.sound.midi.Transmitter;
 
 class ViewerAudioClip implements AudioClip {
-	//private Clip clip;
-	private Sequencer sequencer;
-	
-	public ViewerAudioClip(URL url) {
-		try {
-			sequencer = MidiSystem.getSequencer();
-			sequencer.open();
-			
-			Sequence sequence = MidiSystem.getSequence(url);
-			sequencer.setSequence(sequence);
-			
-			if (!(sequencer instanceof Synthesizer)) {
-				Synthesizer synthesizer = MidiSystem.getSynthesizer();
-				synthesizer.open();
-				Receiver receiver = synthesizer.getReceiver();
-				Transmitter transmitter = sequencer.getTransmitter();
-				transmitter.setReceiver(receiver);
-			}
-		} catch (Exception e) {
-			sequencer = null;
-		}
-//		try {
-//			this.clip = AudioSystem.getClip();
-//			clip.open(AudioSystem.getAudioInputStream(url));
-//		} catch (Exception e) {
-//			this.clip = null;
-//		}		
-	}
+    //private Clip clip;
+    private Sequencer sequencer;
+    
+    public ViewerAudioClip(URL url) {
+        try {
+            sequencer = MidiSystem.getSequencer();
+            sequencer.open();
+            
+            Sequence sequence = MidiSystem.getSequence(url);
+            sequencer.setSequence(sequence);
+            
+            if (!(sequencer instanceof Synthesizer)) {
+                Synthesizer synthesizer = MidiSystem.getSynthesizer();
+                synthesizer.open();
+                Receiver receiver = synthesizer.getReceiver();
+                Transmitter transmitter = sequencer.getTransmitter();
+                transmitter.setReceiver(receiver);
+            }
+        } catch (Exception e) {
+            sequencer = null;
+        }
+//      try {
+//          this.clip = AudioSystem.getClip();
+//          clip.open(AudioSystem.getAudioInputStream(url));
+//      } catch (Exception e) {
+//          this.clip = null;
+//      }       
+    }
 
-	public void loop() {
-		if (sequencer != null)
-			sequencer.start();
-//		if (clip != null) 
-//			clip.loop(Clip.LOOP_CONTINUOUSLY);
-	}
+    public void loop() {
+        if (sequencer != null)
+            sequencer.start();
+//      if (clip != null) 
+//          clip.loop(Clip.LOOP_CONTINUOUSLY);
+    }
 
-	public void play() {
-		if (sequencer != null)
-			sequencer.start();
-//		if (clip != null) 
-//			clip.start();		
-	}
+    public void play() {
+        if (sequencer != null)
+            sequencer.start();
+//      if (clip != null) 
+//          clip.start();       
+    }
 
-	public void stop() {
-		if (sequencer != null)
-			sequencer.stop();
-//		if (clip != null) 
-//			clip.stop();
-	}
+    public void stop() {
+        if (sequencer != null)
+            sequencer.stop();
+//      if (clip != null) 
+//          clip.stop();
+    }
 }



Mime
View raw message