Search in sources :

Example 6 with ClipImage

use of org.concord.energy3d.util.ClipImage in project energy3d by concord-consortium.

the class EventTimeSeries method showGui.

public void showGui() {
    final JDialog dialog = new JDialog(MainFrame.getInstance(), "Time Series of Events", true);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    final JPanel contentPane = new JPanel(new BorderLayout());
    dialog.setContentPane(contentPane);
    final JMenuBar menuBar = new JMenuBar();
    dialog.setJMenuBar(menuBar);
    final JMenu menu = new JMenu("Export");
    menuBar.add(menu);
    final JMenuItem mi = new JMenuItem("Copy Image");
    mi.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            new ClipImage().copyImageToClipboard(EventTimeSeries.this);
        }
    });
    menu.add(mi);
    final JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createEtchedBorder());
    contentPane.add(panel, BorderLayout.CENTER);
    panel.add(this, BorderLayout.CENTER);
    final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    contentPane.add(buttonPanel, BorderLayout.SOUTH);
    final JButton button = new JButton("Close");
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            dialog.dispose();
        }
    });
    buttonPanel.add(button);
    dialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(final WindowEvent e) {
            dialog.dispose();
        }
    });
    dialog.pack();
    dialog.setLocationRelativeTo(MainFrame.getInstance());
    dialog.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) ClipImage(org.concord.energy3d.util.ClipImage) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent) JMenuItem(javax.swing.JMenuItem) JDialog(javax.swing.JDialog) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 7 with ClipImage

use of org.concord.energy3d.util.ClipImage in project energy3d by concord-consortium.

the class AnnualEnvironmentalTemperature method showDialog.

public void showDialog() {
    final JDialog dialog = new JDialog(MainFrame.getInstance(), "Annual Environmental Temperature", true);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    final JPanel contentPane = new JPanel(new BorderLayout());
    dialog.setContentPane(contentPane);
    final JMenuBar menuBar = new JMenuBar();
    dialog.setJMenuBar(menuBar);
    final JCheckBoxMenuItem cbmiAirTemperature = new JCheckBoxMenuItem("Air Temperature");
    Util.selectSilently(cbmiAirTemperature, !hideData.get(lowestAirTemperature));
    final JCheckBoxMenuItem[] cbmiGroundTemperature = new JCheckBoxMenuItem[depth.length];
    for (int i = 0; i < depth.length; i++) {
        cbmiGroundTemperature[i] = new JCheckBoxMenuItem("Ground Temperature (" + depth[i] + "m)");
        Util.selectSilently(cbmiGroundTemperature[i], !hideData.get(lowestGroundTemperature[i]));
    }
    final JCheckBoxMenuItem cbmiShowAverage = new JCheckBoxMenuItem("Show Average");
    Util.selectSilently(cbmiShowAverage, showAverage);
    final JMenu menuView = new JMenu("View");
    menuBar.add(menuView);
    menuView.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(final MenuEvent e) {
            Util.selectSilently(cbmiAirTemperature, !hideData.get(lowestAirTemperature));
            for (int i = 0; i < depth.length; i++) {
                Util.selectSilently(cbmiGroundTemperature[i], !hideData.get(lowestGroundTemperature[i]));
            }
            Util.selectSilently(cbmiShowAverage, showAverage);
        }

        @Override
        public void menuDeselected(final MenuEvent e) {
        }

        @Override
        public void menuCanceled(final MenuEvent e) {
        }
    });
    cbmiAirTemperature.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            final JCheckBoxMenuItem source = (JCheckBoxMenuItem) e.getSource();
            hideData.put(lowestAirTemperature, !source.isSelected());
            AnnualEnvironmentalTemperature.this.repaint();
        }
    });
    menuView.add(cbmiAirTemperature);
    for (int i = 0; i < depth.length; i++) {
        final int i2 = i;
        cbmiGroundTemperature[i].addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(final ItemEvent e) {
                final JCheckBoxMenuItem source = (JCheckBoxMenuItem) e.getSource();
                hideData.put(lowestGroundTemperature[i2], !source.isSelected());
                AnnualEnvironmentalTemperature.this.repaint();
            }
        });
        menuView.add(cbmiGroundTemperature[i]);
    }
    menuView.addSeparator();
    cbmiShowAverage.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            final JCheckBoxMenuItem source = (JCheckBoxMenuItem) e.getSource();
            showAverage = source.isSelected();
            AnnualEnvironmentalTemperature.this.repaint();
        }
    });
    menuView.add(cbmiShowAverage);
    final JMenu menuExport = new JMenu("Export");
    menuBar.add(menuExport);
    final JMenuItem mi = new JMenuItem("Copy Image");
    mi.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            new ClipImage().copyImageToClipboard(AnnualEnvironmentalTemperature.this);
        }
    });
    menuExport.add(mi);
    final JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createEtchedBorder());
    contentPane.add(panel, BorderLayout.CENTER);
    panel.add(this, BorderLayout.CENTER);
    final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    contentPane.add(buttonPanel, BorderLayout.SOUTH);
    final JButton button = new JButton("Close");
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            dialog.dispose();
        }
    });
    buttonPanel.add(button);
    dialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(final WindowEvent e) {
            dialog.dispose();
        }
    });
    dialog.pack();
    dialog.setLocationRelativeTo(MainFrame.getInstance());
    dialog.setVisible(true);
    TimeSeriesLogger.getInstance().logAnalysis(this);
    final HashMap<String, Object> attributes = new HashMap<String, Object>();
    attributes.put("Location", Scene.getInstance().getCity());
    MainApplication.addEvent(new OperationEvent(Scene.getURL(), System.currentTimeMillis(), getClass().getSimpleName(), attributes));
}
Also used : JPanel(javax.swing.JPanel) ItemEvent(java.awt.event.ItemEvent) FlowLayout(java.awt.FlowLayout) HashMap(java.util.HashMap) MenuListener(javax.swing.event.MenuListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) BorderLayout(java.awt.BorderLayout) JMenuItem(javax.swing.JMenuItem) MenuEvent(javax.swing.event.MenuEvent) ClipImage(org.concord.energy3d.util.ClipImage) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent) ItemListener(java.awt.event.ItemListener) OperationEvent(org.concord.energy3d.agents.OperationEvent) JDialog(javax.swing.JDialog) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 8 with ClipImage

use of org.concord.energy3d.util.ClipImage in project energy3d by concord-consortium.

the class DailyEnvironmentalTemperature method showDialog.

public void showDialog() {
    final JDialog dialog = new JDialog(MainFrame.getInstance(), "Daily Environmental Temperature", true);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    final JPanel contentPane = new JPanel(new BorderLayout());
    dialog.setContentPane(contentPane);
    final JMenuBar menuBar = new JMenuBar();
    dialog.setJMenuBar(menuBar);
    final JCheckBoxMenuItem[] cbmiGroundTemperature = new JCheckBoxMenuItem[depth.length];
    for (int i = 0; i < depth.length; i++) {
        cbmiGroundTemperature[i] = new JCheckBoxMenuItem(i == 0 ? "Air Temperature" : "Ground Temperature (" + depth[i] + "m)");
        Util.selectSilently(cbmiGroundTemperature[i], !hideData.get(groundTemperature[i]));
    }
    final JMenu menuView = new JMenu("View");
    menuBar.add(menuView);
    menuView.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(final MenuEvent e) {
            for (int i = 0; i < depth.length; i++) {
                Util.selectSilently(cbmiGroundTemperature[i], !hideData.get(groundTemperature[i]));
            }
        }

        @Override
        public void menuDeselected(final MenuEvent e) {
        }

        @Override
        public void menuCanceled(final MenuEvent e) {
        }
    });
    for (int i = 0; i < depth.length; i++) {
        final int i2 = i;
        cbmiGroundTemperature[i].addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(final ItemEvent e) {
                final JCheckBoxMenuItem source = (JCheckBoxMenuItem) e.getSource();
                hideData.put(groundTemperature[i2], !source.isSelected());
                DailyEnvironmentalTemperature.this.repaint();
            }
        });
        menuView.add(cbmiGroundTemperature[i]);
    }
    final JMenu menuExport = new JMenu("Export");
    menuBar.add(menuExport);
    final JMenuItem mi = new JMenuItem("Copy Image");
    mi.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            new ClipImage().copyImageToClipboard(DailyEnvironmentalTemperature.this);
        }
    });
    menuExport.add(mi);
    final JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createEtchedBorder());
    contentPane.add(panel, BorderLayout.CENTER);
    panel.add(this, BorderLayout.CENTER);
    final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    contentPane.add(buttonPanel, BorderLayout.SOUTH);
    final JButton button = new JButton("Close");
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            dialog.dispose();
        }
    });
    buttonPanel.add(button);
    dialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(final WindowEvent e) {
            dialog.dispose();
        }
    });
    dialog.pack();
    dialog.setLocationRelativeTo(MainFrame.getInstance());
    dialog.setVisible(true);
    TimeSeriesLogger.getInstance().logAnalysis(this);
    final HashMap<String, Object> attributes = new HashMap<String, Object>();
    attributes.put("Location", Scene.getInstance().getCity());
    attributes.put("Date", Scene.getInstance().getDate().toString());
    MainApplication.addEvent(new OperationEvent(Scene.getURL(), System.currentTimeMillis(), getClass().getSimpleName(), attributes));
}
Also used : JPanel(javax.swing.JPanel) ItemEvent(java.awt.event.ItemEvent) FlowLayout(java.awt.FlowLayout) HashMap(java.util.HashMap) MenuListener(javax.swing.event.MenuListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) BorderLayout(java.awt.BorderLayout) JMenuItem(javax.swing.JMenuItem) MenuEvent(javax.swing.event.MenuEvent) ClipImage(org.concord.energy3d.util.ClipImage) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent) ItemListener(java.awt.event.ItemListener) OperationEvent(org.concord.energy3d.agents.OperationEvent) JDialog(javax.swing.JDialog) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 9 with ClipImage

use of org.concord.energy3d.util.ClipImage in project energy3d by concord-consortium.

the class ResultList method showGui.

public void showGui() {
    if (events.isEmpty()) {
        JOptionPane.showMessageDialog(MainFrame.getInstance(), "No previous results were found.", "No Result", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    final JDialog dialog = new JDialog(MainFrame.getInstance(), "List of Results", true);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    final JPanel contentPane = new JPanel(new BorderLayout());
    dialog.setContentPane(contentPane);
    final JMenuBar menuBar = new JMenuBar();
    dialog.setJMenuBar(menuBar);
    final JMenu menu = new JMenu("Export");
    menuBar.add(menu);
    final JMenuItem mi = new JMenuItem("Copy Image");
    mi.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            if (graph != null) {
                new ClipImage().copyImageToClipboard(graph);
            }
        }
    });
    menu.add(mi);
    graphContainer = new JPanel(new BorderLayout());
    graphContainer.setBorder(BorderFactory.createEtchedBorder());
    contentPane.add(graphContainer, BorderLayout.CENTER);
    if (graph != null) {
        graph.setPreferredSize(new Dimension(600, 400));
        graph.setBackground(Color.WHITE);
        graphContainer.add(graph, BorderLayout.CENTER);
    }
    final DefaultListModel<String> listModel = new DefaultListModel<String>();
    for (final AnalysisEvent e : events) {
        listModel.addElement(e.getName() + " (" + EnergyPanel.ONE_DECIMAL.format(0.001 * (System.currentTimeMillis() - e.getTimestamp())) + " s ago)");
    }
    final JList<String> list = new JList<String>(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(final ListSelectionEvent e) {
            if (graph != null) {
                graphContainer.remove(graph);
            }
            final int i = list.getSelectedIndex();
            final AnalysisEvent a = events.get(i);
            setGraph(a);
            fileLabel.setText("File: " + Util.getFileName(a.getFile().getPath()));
            graphContainer.add(graph, BorderLayout.CENTER);
            graphContainer.validate();
            final Map<String, List<Double>> r = a.getResults();
            graph.clearData();
            final Map<String, List<Double>> d = graph.getData();
            for (final String x : r.keySet()) {
                d.put(x, new ArrayList<Double>(r.get(x)));
            }
            graph.repaint();
        }
    });
    final JScrollPane scrollPane = new JScrollPane(list);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    graphContainer.add(scrollPane, BorderLayout.WEST);
    final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    contentPane.add(buttonPanel, BorderLayout.SOUTH);
    fileLabel = new JLabel();
    buttonPanel.add(fileLabel);
    final JButton button = new JButton("Close");
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            dialog.dispose();
        }
    });
    buttonPanel.add(button);
    dialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(final WindowEvent e) {
            dialog.dispose();
        }
    });
    dialog.pack();
    dialog.setLocationRelativeTo(MainFrame.getInstance());
    dialog.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ArrayList(java.util.ArrayList) JButton(javax.swing.JButton) DefaultListModel(javax.swing.DefaultListModel) WindowAdapter(java.awt.event.WindowAdapter) BorderLayout(java.awt.BorderLayout) JMenuItem(javax.swing.JMenuItem) JScrollPane(javax.swing.JScrollPane) ClipImage(org.concord.energy3d.util.ClipImage) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) ListSelectionListener(javax.swing.event.ListSelectionListener) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent) Map(java.util.Map) JDialog(javax.swing.JDialog) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu) JList(javax.swing.JList)

Example 10 with ClipImage

use of org.concord.energy3d.util.ClipImage in project energy3d by concord-consortium.

the class EventFrequency method showGui.

public void showGui() {
    final JDialog dialog = new JDialog(MainFrame.getInstance(), "Event Count", true);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    final JPanel contentPane = new JPanel(new BorderLayout());
    dialog.setContentPane(contentPane);
    final JMenuBar menuBar = new JMenuBar();
    dialog.setJMenuBar(menuBar);
    final JMenu menu = new JMenu("Export");
    menuBar.add(menu);
    final JMenuItem mi = new JMenuItem("Copy Image");
    mi.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            new ClipImage().copyImageToClipboard(EventFrequency.this);
        }
    });
    menu.add(mi);
    final JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createEtchedBorder());
    contentPane.add(panel, BorderLayout.CENTER);
    panel.add(this, BorderLayout.CENTER);
    final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    contentPane.add(buttonPanel, BorderLayout.SOUTH);
    final JButton button = new JButton("Close");
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            dialog.dispose();
        }
    });
    buttonPanel.add(button);
    dialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(final WindowEvent e) {
            dialog.dispose();
        }
    });
    dialog.pack();
    dialog.setLocationRelativeTo(MainFrame.getInstance());
    dialog.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) ClipImage(org.concord.energy3d.util.ClipImage) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent) JMenuItem(javax.swing.JMenuItem) JDialog(javax.swing.JDialog) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Aggregations

ActionEvent (java.awt.event.ActionEvent)11 ActionListener (java.awt.event.ActionListener)11 JMenuItem (javax.swing.JMenuItem)11 ClipImage (org.concord.energy3d.util.ClipImage)11 JMenu (javax.swing.JMenu)10 BorderLayout (java.awt.BorderLayout)8 FlowLayout (java.awt.FlowLayout)8 WindowAdapter (java.awt.event.WindowAdapter)8 WindowEvent (java.awt.event.WindowEvent)8 JButton (javax.swing.JButton)8 JDialog (javax.swing.JDialog)8 JMenuBar (javax.swing.JMenuBar)8 JPanel (javax.swing.JPanel)8 ItemEvent (java.awt.event.ItemEvent)5 ItemListener (java.awt.event.ItemListener)5 MenuEvent (javax.swing.event.MenuEvent)5 MenuListener (javax.swing.event.MenuListener)5 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)4 HashMap (java.util.HashMap)3 OperationEvent (org.concord.energy3d.agents.OperationEvent)3