001    // GraphLab Project: http://graphlab.sharif.edu
002    // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology
003    // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/
004    
005    package graphlab.plugins.algorithmanimator;
006    
007    import javax.swing.*;
008    import java.awt.*;
009    import java.awt.event.ActionListener;
010    
011    /**
012     * @author Azin Azadi
013     */
014    public class AnimatorGUI {
015        public JPanel animatorFrame;
016        public JButton pauseButton;
017        public JButton playButton;
018        public JButton playOneStepButton;
019        public JSlider speedSlider;
020        public JTextArea algorithmOutputTextArea;
021    
022        public AnimatorGUI(ActionListener listener) {
023            pauseButton.addActionListener(listener);
024            playButton.addActionListener(listener);
025            playOneStepButton.addActionListener(listener);
026        }
027    
028        {
029    // GUI initializer generated by IntelliJ IDEA GUI Designer
030    // >>> IMPORTANT!! <<<
031    // DO NOT EDIT OR ADD ANY CODE HERE!
032            $$$setupUI$$$();
033        }
034    
035        /**
036         * Method generated by IntelliJ IDEA GUI Designer
037         * >>> IMPORTANT!! <<<
038         * DO NOT edit this method OR call it in your code!
039         *
040         * @noinspection ALL
041         */
042        private void $$$setupUI$$$() {
043            animatorFrame = new JPanel();
044            animatorFrame.setLayout(new GridBagLayout());
045            animatorFrame.setOpaque(true);
046            animatorFrame.setPreferredSize(new Dimension(275, 500));
047            pauseButton = new JButton();
048            pauseButton.setText("Pause");
049            pauseButton.setVerticalAlignment(1);
050            GridBagConstraints gbc;
051            gbc = new GridBagConstraints();
052            gbc.gridx = 1;
053            gbc.gridy = 1;
054            gbc.fill = GridBagConstraints.HORIZONTAL;
055            animatorFrame.add(pauseButton, gbc);
056            final JPanel spacer1 = new JPanel();
057            gbc = new GridBagConstraints();
058            gbc.gridx = 0;
059            gbc.gridy = 1;
060            gbc.fill = GridBagConstraints.HORIZONTAL;
061            animatorFrame.add(spacer1, gbc);
062            final JPanel spacer2 = new JPanel();
063            gbc = new GridBagConstraints();
064            gbc.gridx = 0;
065            gbc.gridy = 2;
066            gbc.fill = GridBagConstraints.VERTICAL;
067            animatorFrame.add(spacer2, gbc);
068            playButton = new JButton();
069            playButton.setText("Play");
070            gbc = new GridBagConstraints();
071            gbc.gridx = 2;
072            gbc.gridy = 1;
073            gbc.fill = GridBagConstraints.HORIZONTAL;
074            animatorFrame.add(playButton, gbc);
075            playOneStepButton = new JButton();
076            playOneStepButton.setText("Play One Step");
077            playOneStepButton.setToolTipText("Play just one step of algorithm");
078            gbc = new GridBagConstraints();
079            gbc.gridx = 3;
080            gbc.gridy = 1;
081            gbc.fill = GridBagConstraints.HORIZONTAL;
082            animatorFrame.add(playOneStepButton, gbc);
083            speedSlider = new JSlider();
084            speedSlider.setMajorTickSpacing(25);
085            speedSlider.setMaximum(100);
086            speedSlider.setMinimum(0);
087            speedSlider.setMinorTickSpacing(5);
088            speedSlider.setPaintLabels(true);
089            speedSlider.setPaintTicks(false);
090            speedSlider.setPaintTrack(true);
091            speedSlider.setSnapToTicks(true);
092            speedSlider.setToolTipText("The delay between steps of algorithm");
093            speedSlider.setValue(50);
094            speedSlider.setValueIsAdjusting(false);
095            speedSlider.putClientProperty("Slider.paintThumbArrowShape", Boolean.TRUE);
096            gbc = new GridBagConstraints();
097            gbc.gridx = 2;
098            gbc.gridy = 3;
099            gbc.gridwidth = 2;
100            gbc.anchor = GridBagConstraints.WEST;
101            gbc.fill = GridBagConstraints.HORIZONTAL;
102            animatorFrame.add(speedSlider, gbc);
103            final JLabel label1 = new JLabel();
104            label1.setText("Speed:");
105            gbc = new GridBagConstraints();
106            gbc.gridx = 1;
107            gbc.gridy = 3;
108            gbc.anchor = GridBagConstraints.EAST;
109            animatorFrame.add(label1, gbc);
110            final JPanel spacer3 = new JPanel();
111            gbc = new GridBagConstraints();
112            gbc.gridx = 0;
113            gbc.gridy = 4;
114            gbc.weighty = 1.0;
115            gbc.fill = GridBagConstraints.VERTICAL;
116            animatorFrame.add(spacer3, gbc);
117            final JScrollPane scrollPane1 = new JScrollPane();
118            gbc = new GridBagConstraints();
119            gbc.gridx = 1;
120            gbc.gridy = 4;
121            gbc.gridwidth = 3;
122            gbc.weightx = 1.0;
123            gbc.weighty = 1.0;
124            gbc.fill = GridBagConstraints.BOTH;
125            animatorFrame.add(scrollPane1, gbc);
126            algorithmOutputTextArea = new JTextArea();
127            algorithmOutputTextArea.setAutoscrolls(true);
128            algorithmOutputTextArea.setLineWrap(true);
129            algorithmOutputTextArea.setText("Algorithm Output:");
130            algorithmOutputTextArea.setToolTipText("Messegas sent by algorithm");
131            algorithmOutputTextArea.setWrapStyleWord(true);
132            scrollPane1.setViewportView(algorithmOutputTextArea);
133            final JPanel spacer4 = new JPanel();
134            gbc = new GridBagConstraints();
135            gbc.gridx = 4;
136            gbc.gridy = 2;
137            gbc.fill = GridBagConstraints.HORIZONTAL;
138            animatorFrame.add(spacer4, gbc);
139            final JPanel spacer5 = new JPanel();
140            gbc = new GridBagConstraints();
141            gbc.gridx = 2;
142            gbc.gridy = 5;
143            gbc.fill = GridBagConstraints.VERTICAL;
144            animatorFrame.add(spacer5, gbc);
145            final JPanel spacer6 = new JPanel();
146            gbc = new GridBagConstraints();
147            gbc.gridx = 3;
148            gbc.gridy = 0;
149            gbc.fill = GridBagConstraints.VERTICAL;
150            animatorFrame.add(spacer6, gbc);
151        }
152    
153        /**
154         * @noinspection ALL
155         */
156        public JComponent $$$getRootComponent$$$() {
157            return animatorFrame;
158        }
159    }