Exemplo n.º 1
0
    public LightSwitch()
    {
        button  = new ToggleButton("off", "on");
        counter = new BinaryCounter(0);
        button.addActionListener(counter);
        JPanel contentPane = new JPanel();

        contentPane.add(button);
        contentPane.add(counter);
        JFrame frame = new JFrame("LightSwitch");

        frame.DefaultCloseOperation = JFrame.EXIT_ON_CLOSE;
        frame.ContentPane           = contentPane;
        frame.pack();
        frame.setSize(500, 200);
        frame.Visible = true;
    }
Exemplo n.º 2
0
        /**
         * Main program (used when run as application instead of applet).
         */
        public static void main(String[] args)
        {
            DelaunayAp applet = new DelaunayAp();              // Create applet

            applet.init();                                     // Perform applet initialization
            JFrame dWindow = new JFrame();                     // Create window

            dWindow.setSize(700, 500);                         // Set window size
            dWindow.setTitle("Voronoi/Delaunay Window");
            // Set window title
            dWindow.getContentPane().setLayout(new BorderLayout());
            // Specify layout manager
            dWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            // Specify closing behavior
            dWindow.getContentPane().add(applet, "Center");
            // Place applet into window
            dWindow.setVisible(true);                          // Show the window
        }
Exemplo n.º 3
0
        private void displayWeight(List <double?> currentKernel)
        {
            JFrame frame = new JFrame("Weight Visualiser: ");

            frame.setSize(400, 400);

            JLabel    label = new JLabel();
            Dimension d     = new Dimension(kernel.Width * RATIO, kernel.Height * RATIO);

            label.Size          = d;
            label.PreferredSize = d;

            frame.ContentPane.add(label, BorderLayout.CENTER);
            frame.pack();
            frame.Visible = true;

            BufferedImage image = new BufferedImage(kernel.Width, kernel.Height, BufferedImage.TYPE_BYTE_GRAY);

            int[] rgb = convertWeightToRGB(currentKernel);
            image.setRGB(0, 0, kernel.Width, kernel.Height, rgb, 0, kernel.Width);
            label.Icon = new ImageIcon(image.getScaledInstance(kernel.Width * RATIO, kernel.Height * RATIO, Image.SCALE_SMOOTH));
        }
Exemplo n.º 4
0
 public static void main(string[] args)
 {
     AudioTool.prefs    = Preferences.userRoot().node("/edu/cmu/sphinx/tools/audio/AudioTool");
     AudioTool.filename = AudioTool.prefs.get("filename", "untitled.raw");
     AudioTool.file     = new File(AudioTool.filename);
     if (args.Length == 1 && String.instancehelper_equals(args[0], "-dumpMixers"))
     {
         AudioTool.dumpMixers();
         java.lang.System.exit(0);
     }
     try
     {
         if (args.Length > 0)
         {
             AudioTool.filename = args[0];
         }
         URL url;
         if (args.Length == 2)
         {
             url = new File(args[1]).toURI().toURL();
         }
         else
         {
             url = ClassLiteral <AudioTool> .Value.getResource("spectrogram.config.xml");
         }
         ConfigurationManager configurationManager = new ConfigurationManager(url);
         AudioTool.recorder = (Microphone)configurationManager.lookup("microphone");
         AudioTool.recorder.initialize();
         AudioTool.audio = new AudioData();
         FrontEnd         frontEnd      = (FrontEnd)configurationManager.lookup("frontEnd");
         StreamDataSource dataSource    = (StreamDataSource)configurationManager.lookup("streamDataSource");
         FrontEnd         frontEnd2     = (FrontEnd)configurationManager.lookup("cepstrumFrontEnd");
         StreamDataSource dataSource2   = (StreamDataSource)configurationManager.lookup("cstreamDataSource");
         PropertySheet    propertySheet = configurationManager.getPropertySheet("windower");
         float            @float        = propertySheet.getFloat("windowShiftInMs");
         JFrame           jframe        = new JFrame("AudioTool");
         AudioTool.fileChooser = new JFileChooser();
         AudioTool.createMenuBar(jframe);
         float num = @float * AudioTool.audio.getAudioFormat().getSampleRate() / 1000f;
         AudioTool.audioPanel       = new AudioPanel(AudioTool.audio, 1f / num, 0.004f);
         AudioTool.spectrogramPanel = new SpectrogramPanel(frontEnd, dataSource, AudioTool.audio);
         AudioTool.cepstrumPanel    = new CepstrumPanel(frontEnd2, dataSource2, AudioTool.audio);
         JPanel jpanel = new JPanel();
         jpanel.setLayout(new BoxLayout(jpanel, 3));
         jpanel.add(AudioTool.audioPanel);
         AudioTool.audioPanel.setAlignmentX(0f);
         jpanel.add(AudioTool.spectrogramPanel);
         AudioTool.spectrogramPanel.setAlignmentX(0f);
         jpanel.add(AudioTool.cepstrumPanel);
         AudioTool.cepstrumPanel.setAlignmentX(0f);
         JScrollPane jscrollPane = new JScrollPane(jpanel);
         JPanel      jpanel2     = new JPanel(new BorderLayout());
         jpanel2.add(AudioTool.createButtonPanel(), "North");
         jpanel2.add(jscrollPane);
         AudioTool.player = new AudioPlayer(AudioTool.audio);
         AudioTool.player.start();
         AudioTool.getAudioFromFile(AudioTool.filename);
         jframe.setDefaultCloseOperation(3);
         jframe.setContentPane(jpanel2);
         jframe.pack();
         jframe.setSize(640, 400);
         jframe.setVisible(true);
     }
     catch (System.Exception ex)
     {
         Throwable.instancehelper_printStackTrace(ex);
     }
 }