Example usage for javax.swing JCheckBox isSelected

List of usage examples for javax.swing JCheckBox isSelected

Introduction

In this page you can find the example usage for javax.swing JCheckBox isSelected.

Prototype

public boolean isSelected() 

Source Link

Document

Returns the state of the button.

Usage

From source file:com.vgi.mafscaling.OpenLoop.java

@Override
public void actionPerformed(ActionEvent e) {
    if (checkActionPerformed(e))
        return;/*from  ww  w . j a v a 2  s  .c om*/
    if ("mafrpm".equals(e.getActionCommand())) {
        JCheckBox checkBox = (JCheckBox) e.getSource();
        if (checkBox.isSelected()) {
            clearNotRunDataCheckboxes();
            if (!plotMafVRpmData())
                checkBox.setSelected(false);
        } else
            runData.clear();
        setRanges();
    } else if ("rdata".equals(e.getActionCommand())) {
        JCheckBox checkBox = (JCheckBox) e.getSource();
        if (checkBox.isSelected()) {
            if (checkBoxMafRpmData.isSelected()) {
                checkBoxMafRpmData.setSelected(false);
                runData.clear();
            }
            if (!plotRunData())
                checkBox.setSelected(false);
        } else
            runData.clear();
        setRanges();
    } else if ("current".equals(e.getActionCommand())) {
        JCheckBox checkBox = (JCheckBox) e.getSource();
        if (checkBox.isSelected()) {
            if (checkBoxMafRpmData.isSelected()) {
                checkBoxMafRpmData.setSelected(false);
                runData.clear();
            }
            if (!plotCurrentMafData())
                checkBox.setSelected(false);
        } else
            currMafData.clear();
        setRanges();
    } else if ("corrected".equals(e.getActionCommand())) {
        JCheckBox checkBox = (JCheckBox) e.getSource();
        if (checkBox.isSelected()) {
            if (checkBoxMafRpmData.isSelected()) {
                checkBoxMafRpmData.setSelected(false);
                runData.clear();
            }
            if (!setCorrectedMafData())
                checkBox.setSelected(false);
        } else
            corrMafData.clear();
        setRanges();
    } else if ("smoothed".equals(e.getActionCommand())) {
        JCheckBox checkBox = (JCheckBox) e.getSource();
        if (checkBox.isSelected()) {
            if (checkBoxMafRpmData.isSelected()) {
                checkBoxMafRpmData.setSelected(false);
                runData.clear();
            }
            if (!setSmoothedMafData())
                checkBox.setSelected(false);
        } else
            smoothMafData.clear();
        setRanges();
    } else if ("smoothing".equals(e.getActionCommand())) {
        JCheckBox checkBox = (JCheckBox) e.getSource();
        if (checkBox.isSelected())
            enableSmoothingView(true);
        else
            enableSmoothingView(false);
        setRanges();
    }
}

From source file:gov.sandia.umf.platform.ui.jobs.RunPanel.java

public RunPanel() {
    root = new NodeBase();
    model = new DefaultTreeModel(root);
    tree = new JTree(model);
    tree.setRootVisible(false);//from  w  w  w .j  av  a 2 s .c  o m
    tree.setShowsRootHandles(true);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);

    tree.setCellRenderer(new DefaultTreeCellRenderer() {
        @Override
        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected,
                boolean expanded, boolean leaf, int row, boolean hasFocus) {
            super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);

            NodeBase node = (NodeBase) value;
            Icon icon = node.getIcon(expanded); // A node knows whether it should hold other nodes or not, so don't pass leaf to it.
            if (icon == null) {
                if (leaf)
                    icon = getDefaultLeafIcon();
                else if (expanded)
                    icon = getDefaultOpenIcon();
                else
                    icon = getDefaultClosedIcon();
            }
            setIcon(icon);

            return this;
        }
    });

    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
            NodeBase newNode = (NodeBase) tree.getLastSelectedPathComponent();
            if (newNode == null)
                return;
            if (newNode == displayNode)
                return;

            if (displayThread != null)
                synchronized (displayText) {
                    displayThread.stop = true;
                }
            displayNode = newNode;
            if (displayNode instanceof NodeFile)
                viewFile();
            else if (displayNode instanceof NodeJob)
                viewJob();
        }
    });

    tree.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            int keycode = e.getKeyCode();
            if (keycode == KeyEvent.VK_DELETE || keycode == KeyEvent.VK_BACK_SPACE) {
                delete();
            }
        }
    });

    tree.addTreeWillExpandListener(new TreeWillExpandListener() {
        public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
            TreePath path = event.getPath(); // TODO: can this ever be null?
            Object o = path.getLastPathComponent();
            if (o instanceof NodeJob)
                ((NodeJob) o).build(tree);
        }

        public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
        }
    });

    tree.addTreeExpansionListener(new TreeExpansionListener() {
        public void treeExpanded(TreeExpansionEvent event) {
            Rectangle node = tree.getPathBounds(event.getPath());
            Rectangle visible = treePane.getViewport().getViewRect();
            visible.height -= node.y - visible.y;
            visible.y = node.y;
            tree.repaint(visible);
        }

        public void treeCollapsed(TreeExpansionEvent event) {
            Rectangle node = tree.getPathBounds(event.getPath());
            Rectangle visible = treePane.getViewport().getViewRect();
            visible.height -= node.y - visible.y;
            visible.y = node.y;
            tree.repaint(visible);
        }
    });

    Thread refreshThread = new Thread() {
        public void run() {
            try {
                // Initial load
                synchronized (running) {
                    for (MNode n : AppData.runs)
                        running.add(0, new NodeJob(n)); // This should be efficient on a doubly-linked list.
                    for (NodeJob job : running)
                        root.add(job);
                }
                EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        model.nodeStructureChanged(root);
                        if (model.getChildCount(root) > 0)
                            tree.setSelectionRow(0);
                    }
                });

                // Periodic refresh to show status of running jobs
                int shortCycles = 100; // Force full scan on first cycle.
                while (true) {
                    NodeBase d = displayNode; // Make local copy (atomic action) to prevent it changing from under us
                    if (d instanceof NodeJob)
                        ((NodeJob) d).monitorProgress(RunPanel.this);
                    if (shortCycles++ < 20) {
                        Thread.sleep(1000);
                        continue;
                    }
                    shortCycles = 0;

                    synchronized (running) {
                        Iterator<NodeJob> i = running.iterator();
                        while (i.hasNext()) {
                            NodeJob job = i.next();
                            if (job != d)
                                job.monitorProgress(RunPanel.this);
                            if (job.complete >= 1)
                                i.remove();
                        }
                    }
                }
            } catch (InterruptedException e) {
            }
        }
    };
    refreshThread.setDaemon(true);
    refreshThread.start();

    displayText = new JTextArea();
    displayText.setEditable(false);

    final JCheckBox chkFixedWidth = new JCheckBox("Fixed-Width Font");
    chkFixedWidth.setFocusable(false);
    chkFixedWidth.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int size = displayText.getFont().getSize();
            if (chkFixedWidth.isSelected()) {
                displayText.setFont(new Font(Font.MONOSPACED, Font.PLAIN, size));
            } else {
                displayText.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, size));
            }
        }
    });

    displayPane.setViewportView(displayText);

    ActionListener graphListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (displayNode instanceof NodeFile) {
                NodeFile nf = (NodeFile) displayNode;
                if (nf.type == NodeFile.Type.Output || nf.type == NodeFile.Type.Result) {
                    String graphType = e.getActionCommand();
                    if (displayPane.getViewport().getView() instanceof ChartPanel
                            && displayGraph.equals(graphType)) {
                        viewFile();
                        displayGraph = "";
                    } else {
                        if (graphType.equals("Graph")) {
                            Plot plot = new Plot(nf.path.getAbsolutePath());
                            if (!plot.columns.isEmpty())
                                displayPane.setViewportView(plot.createGraphPanel());
                        } else // Raster
                        {
                            Raster raster = new Raster(nf.path.getAbsolutePath(), displayPane.getHeight());
                            displayPane.setViewportView(raster.createGraphPanel());
                        }
                        displayGraph = graphType;
                    }
                }
            }
        }
    };

    buttonGraph = new JButton("Graph", ImageUtil.getImage("analysis.gif"));
    buttonGraph.setFocusable(false);
    buttonGraph.addActionListener(graphListener);
    buttonGraph.setActionCommand("Graph");

    buttonRaster = new JButton("Raster", ImageUtil.getImage("prnplot.gif"));
    buttonRaster.setFocusable(false);
    buttonRaster.addActionListener(graphListener);
    buttonRaster.setActionCommand("Raster");

    Lay.BLtg(this, "C",
            Lay.SPL(Lay.BL("C", treePane = Lay.sp(tree)), Lay.BL("N",
                    Lay.FL(chkFixedWidth, Lay.FL(buttonGraph, buttonRaster), "hgap=50"), "C", displayPane),
                    "divpixel=250"));
    setFocusCycleRoot(true);
}

From source file:lu.lippmann.cdb.datasetview.tabs.ScatterPlotTabView.java

private void update0(final Instances dataSet, int xidx, int yidx, int coloridx, final boolean asSerie) {
    System.out.println(xidx + " " + yidx);

    this.panel.removeAll();

    if (xidx == -1)
        xidx = 0;/*from w  w w  . j  a v a 2  s .c o  m*/
    if (yidx == -1)
        yidx = 1;
    if (coloridx == -1)
        coloridx = 0;

    final Object[] numericAttrNames = WekaDataStatsUtil.getNumericAttributesNames(dataSet).toArray();

    final JComboBox xCombo = new JComboBox(numericAttrNames);
    xCombo.setBorder(new TitledBorder("x"));
    xCombo.setSelectedIndex(xidx);
    final JComboBox yCombo = new JComboBox(numericAttrNames);
    yCombo.setBorder(new TitledBorder("y"));
    yCombo.setSelectedIndex(yidx);
    final JCheckBox jcb = new JCheckBox("Draw lines");
    jcb.setSelected(asSerie);
    final JComboBox colorCombo = new JComboBox(numericAttrNames);
    colorCombo.setBorder(new TitledBorder("color"));
    colorCombo.setSelectedIndex(coloridx);
    colorCombo.setVisible(dataSet.classIndex() < 0);

    xCombo.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            update0(dataSet, xCombo.getSelectedIndex(), yCombo.getSelectedIndex(),
                    colorCombo.getSelectedIndex(), jcb.isSelected());
        }
    });

    yCombo.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            update0(dataSet, xCombo.getSelectedIndex(), yCombo.getSelectedIndex(),
                    colorCombo.getSelectedIndex(), jcb.isSelected());
        }
    });

    colorCombo.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            update0(dataSet, xCombo.getSelectedIndex(), yCombo.getSelectedIndex(),
                    colorCombo.getSelectedIndex(), jcb.isSelected());
        }
    });

    jcb.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            update0(dataSet, xCombo.getSelectedIndex(), yCombo.getSelectedIndex(),
                    colorCombo.getSelectedIndex(), jcb.isSelected());
        }
    });

    final JXPanel comboPanel = new JXPanel();
    comboPanel.setLayout(new GridLayout(1, 0));
    comboPanel.add(xCombo);
    comboPanel.add(yCombo);
    comboPanel.add(colorCombo);
    comboPanel.add(jcb);
    this.panel.add(comboPanel, BorderLayout.NORTH);

    final java.util.List<Integer> numericAttrIdx = WekaDataStatsUtil.getNumericAttributesIndexes(dataSet);
    final ChartPanel scatterplotChartPanel = buildChartPanel(dataSet, numericAttrIdx.get(xidx),
            numericAttrIdx.get(yidx), numericAttrIdx.get(coloridx), asSerie);

    this.panel.add(scatterplotChartPanel, BorderLayout.CENTER);

    this.panel.repaint();
    this.panel.updateUI();
}

From source file:sim.util.media.chart.BoxPlotGenerator.java

protected void buildGlobalAttributes(LabelledList list) {
    // create the chart
    ((CategoryPlot) (chart.getPlot())).setRangeGridlinesVisible(false);
    ((CategoryPlot) (chart.getPlot())).setRangeGridlinePaint(new Color(200, 200, 200));

    xLabel = new PropertyField() {
        public String newValue(String newValue) {
            setXAxisLabel(newValue);/*  w w  w  .jav  a 2  s. co  m*/
            getChartPanel().repaint();
            return newValue;
        }
    };
    xLabel.setValue(getXAxisLabel());

    list.add(new JLabel("X Label"), xLabel);

    yLabel = new PropertyField() {
        public String newValue(String newValue) {
            setYAxisLabel(newValue);
            getChartPanel().repaint();
            return newValue;
        }
    };
    yLabel.setValue(getYAxisLabel());

    list.add(new JLabel("Y Label"), yLabel);

    yLog = new JCheckBox();
    yLog.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (yLog.isSelected()) {
                LogarithmicAxis logAxis = new LogarithmicAxis(yLabel.getValue());
                logAxis.setStrictValuesFlag(false);
                ((CategoryPlot) (chart.getPlot())).setRangeAxis(logAxis);
            } else
                ((CategoryPlot) (chart.getPlot())).setRangeAxis(new NumberAxis(yLabel.getValue()));
        }
    });

    list.add(new JLabel("Y Log Axis"), yLog);

    final JCheckBox ygridlines = new JCheckBox();
    ygridlines.setSelected(false);
    ItemListener il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                ((CategoryPlot) (chart.getPlot())).setRangeGridlinesVisible(true);
            } else {
                ((CategoryPlot) (chart.getPlot())).setRangeGridlinesVisible(false);
            }
        }
    };
    ygridlines.addItemListener(il);

    // JFreeChart's Box Plots look awful when wide because the mean
    // circle is based on the width of the bar to the exclusion of all
    // else.  So I've restricted the width to be no more than 0.4, and 0.1
    // is the suggested default.

    final double INITIAL_WIDTH = 0.1;
    final double MAXIMUM_RATIONAL_WIDTH = 0.4;

    maximumWidthField = new NumberTextField(INITIAL_WIDTH, 2.0, 0) {
        public double newValue(double newValue) {
            if (newValue <= 0.0 || newValue > MAXIMUM_RATIONAL_WIDTH)
                newValue = currentValue;
            ((BoxAndWhiskerRenderer) (((CategoryPlot) (chart.getPlot())).getRenderer()))
                    .setMaximumBarWidth(newValue);
            //update();
            return newValue;
        }
    };
    list.addLabelled("Max Width", maximumWidthField);

    Box box = Box.createHorizontalBox();
    box.add(new JLabel(" Y"));
    box.add(ygridlines);
    box.add(Box.createGlue());
    list.add(new JLabel("Y Grid Lines"), ygridlines);

    mean = new JCheckBox();
    mean.setSelected(true);
    il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            BoxAndWhiskerRenderer renderer = ((BoxAndWhiskerRenderer) ((CategoryPlot) (chart.getPlot()))
                    .getRenderer());
            renderer.setMeanVisible(mean.isSelected());
        }
    };
    mean.addItemListener(il);

    median = new JCheckBox();
    median.setSelected(true);
    il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            BoxAndWhiskerRenderer renderer = ((BoxAndWhiskerRenderer) ((CategoryPlot) (chart.getPlot()))
                    .getRenderer());
            renderer.setMedianVisible(median.isSelected());
        }
    };
    median.addItemListener(il);

    list.add(new JLabel("Mean"), mean);
    list.add(new JLabel("Median"), median);

    final JCheckBox horizontal = new JCheckBox();
    horizontal.setSelected(false);
    il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            CategoryPlot plot = (CategoryPlot) (chart.getPlot());
            if (e.getStateChange() == ItemEvent.SELECTED) {
                plot.setOrientation(PlotOrientation.HORIZONTAL);
            } else {
                plot.setOrientation(PlotOrientation.VERTICAL);
            }
            //updateGridLines();
        }
    };
    horizontal.addItemListener(il);

    list.add(new JLabel("Horizontal"), horizontal);

    final JCheckBox whiskersUseFillColorButton = new JCheckBox();
    whiskersUseFillColorButton.setSelected(false);
    whiskersUseFillColorButton.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            BoxAndWhiskerRenderer renderer = ((BoxAndWhiskerRenderer) ((CategoryPlot) (chart.getPlot()))
                    .getRenderer());
            renderer.setUseOutlinePaintForWhiskers(!whiskersUseFillColorButton.isSelected());
        }
    });

    box = Box.createHorizontalBox();
    box.add(new JLabel(" Colored"));
    box.add(whiskersUseFillColorButton);
    box.add(Box.createGlue());
    list.add(new JLabel("Whiskers"), box);
}

From source file:edu.gmu.cs.sim.util.media.chart.BoxPlotGenerator.java

protected void buildGlobalAttributes(LabelledList list) {
    // create the chart
    ((CategoryPlot) (chart.getPlot())).setRangeGridlinesVisible(false);
    ((CategoryPlot) (chart.getPlot())).setRangeGridlinePaint(new Color(200, 200, 200));

    xLabel = new PropertyField() {
        public String newValue(String newValue) {
            setXAxisLabel(newValue);//  w  ww .j  a v a2 s  . c o  m
            getChartPanel().repaint();
            return newValue;
        }
    };
    xLabel.setValue(getXAxisLabel());

    list.add(new JLabel("X Label"), xLabel);

    yLabel = new PropertyField() {
        public String newValue(String newValue) {
            setYAxisLabel(newValue);
            getChartPanel().repaint();
            return newValue;
        }
    };
    yLabel.setValue(getYAxisLabel());

    list.add(new JLabel("Y Label"), yLabel);

    yLog = new JCheckBox();
    yLog.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (yLog.isSelected()) {
                LogarithmicAxis logAxis = new LogarithmicAxis(yLabel.getValue());
                logAxis.setStrictValuesFlag(false);
                ((CategoryPlot) (chart.getPlot())).setRangeAxis(logAxis);
            } else {
                ((CategoryPlot) (chart.getPlot())).setRangeAxis(new NumberAxis(yLabel.getValue()));
            }
        }
    });

    list.add(new JLabel("Y Log Axis"), yLog);

    final JCheckBox ygridlines = new JCheckBox();
    ygridlines.setSelected(false);
    ItemListener il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                ((CategoryPlot) (chart.getPlot())).setRangeGridlinesVisible(true);
            } else {
                ((CategoryPlot) (chart.getPlot())).setRangeGridlinesVisible(false);
            }
        }
    };
    ygridlines.addItemListener(il);

    // JFreeChart's Box Plots look awful when wide because the mean
    // circle is based on the width of the bar to the exclusion of all
    // else.  So I've restricted the width to be no more than 0.4, and 0.1
    // is the suggested default.

    final double INITIAL_WIDTH = 0.1;
    final double MAXIMUM_RATIONAL_WIDTH = 0.4;

    maximumWidthField = new NumberTextField(INITIAL_WIDTH, 2.0, 0) {
        public double newValue(double newValue) {
            if (newValue <= 0.0 || newValue > MAXIMUM_RATIONAL_WIDTH) {
                newValue = currentValue;
            }
            ((BoxAndWhiskerRenderer) (((CategoryPlot) (chart.getPlot())).getRenderer()))
                    .setMaximumBarWidth(newValue);
            //update();
            return newValue;
        }
    };
    list.addLabelled("Max Width", maximumWidthField);

    Box box = Box.createHorizontalBox();
    box.add(new JLabel(" Y"));
    box.add(ygridlines);
    box.add(Box.createGlue());
    list.add(new JLabel("Y Grid Lines"), ygridlines);

    mean = new JCheckBox();
    mean.setSelected(true);
    il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            BoxAndWhiskerRenderer renderer = ((BoxAndWhiskerRenderer) ((CategoryPlot) (chart.getPlot()))
                    .getRenderer());
            renderer.setMeanVisible(mean.isSelected());
        }
    };
    mean.addItemListener(il);

    median = new JCheckBox();
    median.setSelected(true);
    il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            BoxAndWhiskerRenderer renderer = ((BoxAndWhiskerRenderer) ((CategoryPlot) (chart.getPlot()))
                    .getRenderer());
            renderer.setMedianVisible(median.isSelected());
        }
    };
    median.addItemListener(il);

    list.add(new JLabel("Mean"), mean);
    list.add(new JLabel("Median"), median);

    final JCheckBox horizontal = new JCheckBox();
    horizontal.setSelected(false);
    il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            CategoryPlot plot = (CategoryPlot) (chart.getPlot());
            if (e.getStateChange() == ItemEvent.SELECTED) {
                plot.setOrientation(PlotOrientation.HORIZONTAL);
            } else {
                plot.setOrientation(PlotOrientation.VERTICAL);
            }
            //updateGridLines();
        }
    };
    horizontal.addItemListener(il);

    list.add(new JLabel("Horizontal"), horizontal);

    final JCheckBox whiskersUseFillColorButton = new JCheckBox();
    whiskersUseFillColorButton.setSelected(false);
    whiskersUseFillColorButton.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            BoxAndWhiskerRenderer renderer = ((BoxAndWhiskerRenderer) ((CategoryPlot) (chart.getPlot()))
                    .getRenderer());
            renderer.setUseOutlinePaintForWhiskers(!whiskersUseFillColorButton.isSelected());
        }
    });

    box = Box.createHorizontalBox();
    box.add(new JLabel(" Colored"));
    box.add(whiskersUseFillColorButton);
    box.add(Box.createGlue());
    list.add(new JLabel("Whiskers"), box);
}

From source file:net.sf.jclal.gui.view.components.chart.ExternalBasicChart.java

/**
 *
 * @return Create the menu that allows load the result from others
 * experiments.// w  ww. j  a va 2  s  .  c o  m
 */
private JMenu createMenu() {

    final JMenu fileMenu = new JMenu("Options");

    final JFileChooser f = new JFileChooser();
    f.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);

    fileMenu.add("Add report file or directory").addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            if (curveOptions != null) {
                curveOptions.setVisible(false);
                curveOptions = null;
            }
            int action = f.showOpenDialog(fileMenu);

            if (action == JFileChooser.APPROVE_OPTION) {

                loadReportFile(f.getSelectedFile());

            }

        }
    });

    fileMenu.add("Area under learning curve (ALC)").addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

            if (comboBox.getItemCount() != 0) {

                if (!comboBox.getSelectedItem().toString().isEmpty()) {

                    StringBuilder st = new StringBuilder();

                    st.append("Measure: ").append(comboBox.getSelectedItem()).append("\n\n");

                    for (int query = 0; query < queryNames.size(); query++) {

                        double value = LearningCurveUtility.getArea(evaluationsCollection.get(query),
                                comboBox.getSelectedItem().toString());

                        String valueString = String.format("%.3f", value);

                        st.append(queryNames.get(query)).append(": ").append(valueString).append("\n");

                    }

                    JOptionPane.showMessageDialog(content, st.toString(), "Area under the learning curve",
                            JOptionPane.INFORMATION_MESSAGE);
                }
            }
        }
    });

    fileMenu.add("Clear").addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

            queryNames = new ArrayList<String>();
            evaluationsCollection = new ArrayList<List<AbstractEvaluation>>();
            comboBox.removeAllItems();
            controlCurveColor = new HashMap<String, Color>();
            colors.clear();
            data = null;
            set.clear();
            curveOptions.setVisible(false);
            curveOptions = null;
            setSeries.clear();
            passiveEvaluation = null;

        }
    });

    fileMenu.add("Curve options").addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

            data = informationTable();

            if (queryNames.isEmpty()) {
                JOptionPane.showMessageDialog(null, "Please add curves");
                return;
            }
            if (curveOptions == null) {
                curveOptions = new LearningCurvesVisualTable(ExternalBasicChart.this);
            } else {
                curveOptions.setVisible(true);
            }

        }

    });

    final JCheckBox viewPoints = new JCheckBox("View points's shapes");
    viewPoints.setSelected(false);

    viewPoints.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            viewPointsForm = viewPoints.isSelected();
            jComboBoxItemStateChanged();
        }
    });

    fileMenu.add(viewPoints);

    final JCheckBox withOutColor = new JCheckBox("View without color");
    withOutColor.setSelected(false);

    withOutColor.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            viewWithOutColor = withOutColor.isSelected();
            jComboBoxItemStateChanged();
        }
    });

    fileMenu.add(withOutColor);

    return fileMenu;
}

From source file:emailplugin.MailCreator.java

/**
 * Show the EMail-Open Dialog./*from   w ww .ja  va  2  s .  c  o m*/
 *
 * This Dialog says that the EMail should have been opened. It gives the User
 * a chance to specify another EMail Program if it went wrong.
 *
 * @param parent
 *          Parent-Frame
 */
private void showEMailOpenedDialog(Frame parent) {
    final JDialog dialog = new JDialog(parent, true);

    dialog.setTitle(mLocalizer.msg("EMailOpenedTitel", "Email was opened"));

    JPanel panel = (JPanel) dialog.getContentPane();
    panel.setLayout(new FormLayout("fill:200dlu:grow", "default, 3dlu, default, 3dlu, default"));
    panel.setBorder(Borders.DIALOG_BORDER);

    CellConstraints cc = new CellConstraints();

    panel.add(UiUtilities.createHelpTextArea(mLocalizer.msg("EMailOpened", "Email was opened. Configure it?")),
            cc.xy(1, 1));

    final JCheckBox dontShowAgain = new JCheckBox(
            mLocalizer.msg("DontShowAgain", "Don't show this Dialog again"));
    panel.add(dontShowAgain, cc.xy(1, 3));

    JButton configure = new JButton(mLocalizer.msg("configure", "Configure"));
    configure.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Plugin.getPluginManager().showSettings(mPlugin);
            dialog.setVisible(false);
        }
    });

    JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK));
    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (dontShowAgain.isSelected()) {
                mSettings.setShowEmailOpened(false);
            }
            dialog.setVisible(false);
        }
    });

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    buttonPanel.add(configure);
    buttonPanel.add(ok);
    panel.add(buttonPanel, cc.xy(1, 5));

    UiUtilities.registerForClosing(new WindowClosingIf() {
        public void close() {
            dialog.setVisible(false);
        }

        public JRootPane getRootPane() {
            return dialog.getRootPane();
        }
    });

    dialog.getRootPane().setDefaultButton(ok);

    dialog.pack();
    UiUtilities.centerAndShow(dialog);
}

From source file:jchrest.gui.VisualSearchPane.java

private JPanel constructButtons() {

    Box buttons = Box.createVerticalBox();
    JSpinner numFixations = new JSpinner(new SpinnerNumberModel(20, 1, 1000, 1));

    JPanel labelledSpinner = new JPanel();
    labelledSpinner.setLayout(new GridLayout(1, 2));
    labelledSpinner.add(new JLabel("Number of fixations: "));
    labelledSpinner.add(numFixations);//w  ww .  ja  v  a2  s  .c  om

    JButton recallButton = new JButton(new RecallAction(numFixations));
    recallButton.setToolTipText("Scan shown scene and display results");

    final JCheckBox showFixations = new JCheckBox("Show fixations", false);
    showFixations.setToolTipText("Show fixations for recalled scene");
    showFixations.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            _sceneDisplay.setShowFixations(showFixations.isSelected());
        }
    });

    buttons.add(Box.createRigidArea(new Dimension(0, 20)));
    buttons.add(labelledSpinner);
    buttons.add(recallButton);
    buttons.add(Box.createRigidArea(new Dimension(0, 20)));
    buttons.add(showFixations);
    buttons.add(Box.createRigidArea(new Dimension(0, 20)));

    // TODO: There must be a better solution to this problem!
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(buttons, BorderLayout.NORTH);

    return panel;
}

From source file:es.emergya.ui.plugins.admin.aux1.RecursoDialog.java

public RecursoDialog(final Recurso rec, final AdminResources adminResources) {
    super();//from w w w. ja va 2s  .  c  o m
    setAlwaysOnTop(true);
    setSize(600, 400);

    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            super.windowClosing(e);
            if (cambios) {
                int res = JOptionPane.showConfirmDialog(RecursoDialog.this,
                        "Existen cambios sin guardar. Seguro que desea cerrar la ventana?",
                        "Cambios sin guardar", JOptionPane.OK_CANCEL_OPTION);
                if (res != JOptionPane.CANCEL_OPTION) {
                    e.getWindow().dispose();
                }
            } else {
                e.getWindow().dispose();
            }
        }
    });
    final Recurso r = (rec == null) ? null : RecursoConsultas.get(rec.getId());
    if (r != null) {
        setTitle(i18n.getString("Resources.summary.titleWindow") + " " + r.getIdentificador());
    } else {
        setTitle(i18n.getString("Resources.summary.titleWindow.new"));
    }
    setIconImage(getBasicWindow().getFrame().getIconImage());
    JPanel base = new JPanel();
    base.setBackground(Color.WHITE);
    base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS));

    // Icono del titulo
    JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING));
    title.setOpaque(false);
    JLabel labelTitulo = null;
    if (r != null) {
        labelTitulo = new JLabel(i18n.getString("Resources.summary"),
                LogicConstants.getIcon("tittleficha_icon_recurso"), JLabel.LEFT);

    } else {
        labelTitulo = new JLabel(i18n.getString("Resources.cabecera.nuevo"),
                LogicConstants.getIcon("tittleficha_icon_recurso"), JLabel.LEFT);

    }
    labelTitulo.setFont(LogicConstants.deriveBoldFont(12f));
    title.add(labelTitulo);
    base.add(title);

    // Nombre
    JPanel mid = new JPanel(new SpringLayout());
    mid.setOpaque(false);
    mid.add(new JLabel(i18n.getString("Resources.name"), JLabel.RIGHT));
    final JTextField name = new JTextField(25);
    if (r != null) {
        name.setText(r.getNombre());
    }

    name.getDocument().addDocumentListener(changeListener);
    name.setEditable(r == null);
    mid.add(name);

    // patrullas
    final JLabel labelSquads = new JLabel(i18n.getString("Resources.squad"), JLabel.RIGHT);
    mid.add(labelSquads);
    List<Patrulla> pl = PatrullaConsultas.getAll();
    pl.add(0, null);
    final JComboBox squads = new JComboBox(pl.toArray());
    squads.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXX");
    squads.addActionListener(changeSelectionListener);
    squads.setOpaque(false);
    labelSquads.setLabelFor(squads);
    if (r != null) {
        squads.setSelectedItem(r.getPatrullas());
    } else {
        squads.setSelectedItem(null);
    }
    squads.setEnabled((r != null && r.getHabilitado() != null) ? r.getHabilitado() : true);
    mid.add(squads);

    // // Identificador
    // mid.setOpaque(false);
    // mid.add(new JLabel(i18n.getString("Resources.identificador"),
    // JLabel.RIGHT));
    // final JTextField identificador = new JTextField("");
    // if (r != null) {
    // identificador.setText(r.getIdentificador());
    // }
    // identificador.getDocument().addDocumentListener(changeListener);
    // identificador.setEditable(r == null);
    // mid.add(identificador);
    // Espacio en blanco
    // mid.add(Box.createHorizontalGlue());
    // mid.add(Box.createHorizontalGlue());

    // Tipo
    final JLabel labelTipoRecursos = new JLabel(i18n.getString("Resources.type"), JLabel.RIGHT);
    mid.add(labelTipoRecursos);
    final JComboBox types = new JComboBox(RecursoConsultas.getTipos());
    labelTipoRecursos.setLabelFor(types);
    types.addActionListener(changeSelectionListener);
    if (r != null) {
        types.setSelectedItem(r.getTipo());
    } else {
        types.setSelectedItem(0);
    }
    // types.setEditable(true);
    types.setEnabled(true);
    mid.add(types);

    // Estado Eurocop
    mid.add(new JLabel(i18n.getString("Resources.status"), JLabel.RIGHT));
    final JTextField status = new JTextField();
    if (r != null && r.getEstadoEurocop() != null) {
        status.setText(r.getEstadoEurocop().getIdentificador());
    }
    status.setEditable(false);
    mid.add(status);

    // Subflota y patrulla
    mid.add(new JLabel(i18n.getString("Resources.subfleet"), JLabel.RIGHT));
    final JComboBox subfleets = new JComboBox(FlotaConsultas.getAllHabilitadas());
    subfleets.addActionListener(changeSelectionListener);
    if (r != null) {
        subfleets.setSelectedItem(r.getFlotas());
    } else {
        subfleets.setSelectedIndex(0);
    }
    subfleets.setEnabled(true);
    subfleets.setOpaque(false);
    mid.add(subfleets);

    // Referencia humana
    mid.add(new JLabel(i18n.getString("Resources.incidences"), JLabel.RIGHT));
    final JTextField rhumana = new JTextField();
    // if (r != null && r.getIncidencias() != null) {
    // rhumana.setText(r.getIncidencias().getReferenciaHumana());
    // }
    rhumana.setEditable(false);
    mid.add(rhumana);

    // dispositivo
    mid.add(new JLabel(i18n.getString("Resources.device"), JLabel.RIGHT));
    final PlainDocument plainDocument = new PlainDocument() {

        private static final long serialVersionUID = 4929271093724956016L;

        @Override
        public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
            if (this.getLength() + str.length() <= LogicConstants.LONGITUD_ISSI) {
                super.insertString(offs, str, a);
            }
        }
    };
    final JTextField issi = new JTextField(plainDocument, "", LogicConstants.LONGITUD_ISSI);
    plainDocument.addDocumentListener(changeListener);
    issi.setEditable(true);
    mid.add(issi);
    mid.add(new JLabel(i18n.getString("Resources.enabled"), JLabel.RIGHT));
    final JCheckBox enabled = new JCheckBox("", true);
    enabled.addActionListener(changeSelectionListener);
    enabled.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            if (enabled.isSelected()) {
                squads.setSelectedIndex(0);
            }
            squads.setEnabled(enabled.isSelected());
        }
    });
    enabled.setEnabled(true);
    enabled.setOpaque(false);
    if (r != null) {
        enabled.setSelected(r.getHabilitado());
    } else {
        enabled.setSelected(true);
    }
    if (r != null && r.getDispositivo() != null) {
        issi.setText(
                StringUtils.leftPad(String.valueOf(r.getDispositivo()), LogicConstants.LONGITUD_ISSI, '0'));
    }

    mid.add(enabled);

    // Fecha ultimo gps
    mid.add(new JLabel(i18n.getString("Resources.lastPosition"), JLabel.RIGHT));
    JTextField lastGPS = new JTextField();
    final Date lastGPSDateForRecurso = HistoricoGPSConsultas.lastGPSDateForRecurso(r);
    if (lastGPSDateForRecurso != null) {
        lastGPS.setText(SimpleDateFormat.getDateTimeInstance().format(lastGPSDateForRecurso));
    }
    lastGPS.setEditable(false);
    mid.add(lastGPS);

    // Espacio en blanco
    mid.add(Box.createHorizontalGlue());
    mid.add(Box.createHorizontalGlue());

    // informacion adicional
    JPanel infoPanel = new JPanel(new SpringLayout());
    final JTextField info = new JTextField(25);
    info.getDocument().addDocumentListener(changeListener);
    infoPanel.add(new JLabel(i18n.getString("Resources.info")));
    infoPanel.add(info);
    infoPanel.setOpaque(false);
    info.setOpaque(false);
    SpringUtilities.makeCompactGrid(infoPanel, 1, 2, 6, 6, 6, 18);

    if (r != null) {
        info.setText(r.getInfoAdicional());
    } else {
        info.setText("");
    }
    info.setEditable(true);

    // Espacio en blanco
    mid.add(Box.createHorizontalGlue());
    mid.add(Box.createHorizontalGlue());

    SpringUtilities.makeCompactGrid(mid, 5, 4, 6, 6, 6, 18);
    base.add(mid);
    base.add(infoPanel);

    JPanel buttons = new JPanel();
    buttons.setOpaque(false);
    JButton accept = null;
    if (r == null) {
        accept = new JButton("Crear", LogicConstants.getIcon("button_crear"));
    } else {
        accept = new JButton("Guardar", LogicConstants.getIcon("button_save"));
    }
    accept.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                if (cambios || r == null || r.getId() == null) {
                    boolean shithappens = true;
                    if ((r == null || r.getId() == null)) { // Estamos
                        // creando
                        // uno nuevo
                        if (RecursoConsultas.alreadyExists(name.getText())) {
                            shithappens = false;
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.nombreUnico"));
                        } else if (issi.getText() != null && issi.getText().length() > 0 && StringUtils
                                .trimToEmpty(issi.getText()).length() != LogicConstants.LONGITUD_ISSI) {
                            JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString(Locale.ROOT,
                                    "admin.recursos.popup.error.faltanCifras", LogicConstants.LONGITUD_ISSI));
                            shithappens = false;
                        } else if (issi.getText() != null && issi.getText().length() > 0
                                && LogicConstants.isNumeric(issi.getText())
                                && RecursoConsultas.alreadyExists(new Integer(issi.getText()))) {
                            shithappens = false;
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.dispositivoUnico"));
                        }
                    }
                    if (shithappens) {
                        if (name.getText().isEmpty()) {
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.nombreNulo"));
                        } else if (issi.getText() != null && issi.getText().length() > 0 && StringUtils
                                .trimToEmpty(issi.getText()).length() != LogicConstants.LONGITUD_ISSI) {
                            JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString(Locale.ROOT,
                                    "admin.recursos.popup.error.faltanCifras", LogicConstants.LONGITUD_ISSI));
                        } else if (issi.getText() != null && issi.getText().length() > 0
                                && LogicConstants.isNumeric(issi.getText()) && r != null && r.getId() != null
                                && RecursoConsultas.alreadyExists(new Integer(issi.getText()), r.getId())) {
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.issiUnico"));
                        } else if (issi.getText() != null && issi.getText().length() > 0
                                && !LogicConstants.isNumeric(issi.getText())) {
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.noNumerico"));
                            // } else if (identificador.getText().isEmpty())
                            // {
                            // JOptionPane
                            // .showMessageDialog(
                            // RecursoDialog.this,
                            // i18n.getString("admin.recursos.popup.error.identificadorNulo"));
                        } else if (subfleets.getSelectedIndex() == -1) {
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.noSubflota"));
                        } else if (types.getSelectedItem() == null
                                || types.getSelectedItem().toString().trim().isEmpty()) {
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.noTipo"));
                        } else {
                            int i = JOptionPane.showConfirmDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.dialogo.guardar.titulo"),
                                    i18n.getString("admin.recursos.popup.dialogo.guardar.guardar"),
                                    JOptionPane.YES_NO_CANCEL_OPTION);

                            if (i == JOptionPane.YES_OPTION) {

                                Recurso recurso = r;

                                if (r == null) {
                                    recurso = new Recurso();
                                }

                                recurso.setInfoAdicional(info.getText());
                                if (issi.getText() != null && issi.getText().length() > 0) {
                                    recurso.setDispositivo(new Integer(issi.getText()));
                                } else {
                                    recurso.setDispositivo(null);
                                }
                                recurso.setFlotas(FlotaConsultas.find(subfleets.getSelectedItem().toString()));
                                if (squads.getSelectedItem() != null && enabled.isSelected()) {
                                    recurso.setPatrullas(
                                            PatrullaConsultas.find(squads.getSelectedItem().toString()));
                                } else {
                                    recurso.setPatrullas(null);
                                }
                                recurso.setNombre(name.getText());
                                recurso.setHabilitado(enabled.isSelected());
                                // recurso.setIdentificador(identificador
                                // .getText());
                                recurso.setTipo(types.getSelectedItem().toString());
                                dispose();

                                RecursoAdmin.saveOrUpdate(recurso);
                                adminResources.refresh(null);

                                PluginEventHandler.fireChange(adminResources);
                            } else if (i == JOptionPane.NO_OPTION) {
                                dispose();
                            }
                        }
                    }
                } else {
                    log.debug("No hay cambios");
                    dispose();
                }

            } catch (Throwable t) {
                log.error("Error guardando un recurso", t);
            }
        }
    });
    buttons.add(accept);

    JButton cancelar = new JButton("Cancelar", LogicConstants.getIcon("button_cancel"));

    cancelar.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (cambios) {
                if (JOptionPane.showConfirmDialog(RecursoDialog.this,
                        "Existen cambios sin guardar. Seguro que desea cerrar la ventana?",
                        "Cambios sin guardar", JOptionPane.OK_CANCEL_OPTION) != JOptionPane.CANCEL_OPTION) {
                    dispose();
                }
            } else {
                dispose();
            }
        }
    });

    buttons.add(cancelar);

    base.add(buttons);

    getContentPane().add(base);
    setLocationRelativeTo(null);
    cambios = false;
    if (r == null) {
        cambios = true;
    }

    pack();

    int x;
    int y;

    Container myParent = getBasicWindow().getPluginContainer().getDetachedTab(0);
    Point topLeft = myParent.getLocationOnScreen();
    Dimension parentSize = myParent.getSize();

    Dimension mySize = getSize();

    if (parentSize.width > mySize.width) {
        x = ((parentSize.width - mySize.width) / 2) + topLeft.x;
    } else {
        x = topLeft.x;
    }

    if (parentSize.height > mySize.height) {
        y = ((parentSize.height - mySize.height) / 2) + topLeft.y;
    } else {
        y = topLeft.y;
    }

    setLocation(x, y);
    cambios = false;
}

From source file:main.UIController.java

@SuppressWarnings("deprecation")
public void convertToImladris() {
    UI window = this.getUi();

    String errorEmptyYear = "Please insert a year.";
    String errorYearNotNumeric = "Please insert the year as a numeric value.";
    String errorYearNotValid = "Please insert a valid year (from 1 to "
            + Integer.toString(GregorianInfo.MAX_SUPPORTED_YEAR) + ").";
    String errorDayNotRead = "Sorry, the day could not be read.";

    JTextField year = window.getYear();
    JComboBox month = window.getMonth();
    JComboBox day = window.getDay();
    JCheckBox afterSunset = window.getAfterSunset();
    JTextPane result = window.getResImladris();
    String value = year.getText();
    if (!value.isEmpty()) {
        try {//from   ww  w .  j  av  a  2s.c o m
            int yearNum = Integer.parseInt(value);
            if (yearNum > 0 && yearNum <= GregorianInfo.MAX_SUPPORTED_YEAR) {
                int monthNum = month.getSelectedIndex() + 1;
                int dayNum = 0;
                if (day.isEnabled()) {
                    dayNum = day.getSelectedIndex() + 1;
                    ImladrisCalendar cal;
                    if (afterSunset.isSelected()) {
                        GregorianCalendar gcal = new GregorianCalendar(yearNum, monthNum, dayNum);
                        Time time = this.calculateSunsetForActualLocation(gcal, true);
                        cal = new ImladrisCalendar(time, yearNum, monthNum, dayNum, time.getHours(),
                                time.getMinutes(), time.getSeconds());
                    } else {
                        cal = new ImladrisCalendar(yearNum, monthNum, dayNum);
                    }
                    result.setText(cal.toString());
                } else {
                    result.setText(errorDayNotRead);
                }
            } else {
                result.setText(errorYearNotValid);
            }
        } catch (NumberFormatException e) {
            result.setText(errorYearNotNumeric);
        }
    } else {
        result.setText(errorEmptyYear);
    }
}