Example usage for javax.swing JCheckBox getText

List of usage examples for javax.swing JCheckBox getText

Introduction

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

Prototype

public String getText() 

Source Link

Document

Returns the button's text.

Usage

From source file:greenfoot.gui.export.ExportPublishPane.java

/**
 * Returns a list of the tags that the user chose for this scenario.
 *///from  w ww  .  j a va2 s  .com
public List<String> getTags() {
    List<String> tagList = new LinkedList<String>();

    for (int i = 0; i < popTags.length; i++) {
        JCheckBox checkBox = popTags[i];
        if (checkBox.isSelected()) {
            tagList.add(checkBox.getText());
        }
    }

    String currentTags = tagArea.getText().trim();
    String[] tags = currentTags.split("\\s");
    for (int i = 0; i < tags.length; i++) {
        String tag = tags[i].trim();
        if (!tag.equals("")) {
            tagList.add(tag);
        }
    }

    if (includeSourceCode() && !tagList.contains(WITH_SOURCE_TAG)) {
        tagList.add(WITH_SOURCE_TAG);
    } else if (!includeSourceCode()) {
        tagList.remove(WITH_SOURCE_TAG);
    }
    return tagList;
}

From source file:logdruid.ui.chart.GraphPanel.java

public void loadGroupCheckbox(final JPanel panel_2) {
    panel_1.removeAll();/*from w  w  w. java2 s. c o  m*/
    //Iterator mineResultSetIterator = mineResultSet.mineResults.entrySet().iterator();

    Map<Source, Map<String, MineResult>> treeMap = new TreeMap<Source, Map<String, MineResult>>(
            mineResultSet.mineResults);
    Iterator mineResultSetIterator = treeMap.entrySet().iterator();

    logger.debug("mineResultSet size: " + mineResultSet.mineResults.size());
    while (mineResultSetIterator.hasNext()) {

        int groupCount = 0;
        int totalGroupCount = 0;
        Map.Entry pairs = (Map.Entry) mineResultSetIterator.next();
        Map mrArrayList = (Map<String, MineResult>) pairs.getValue();
        ArrayList<String> mineResultGroup = new ArrayList<String>();
        Set<String> mrss = mrArrayList.keySet();
        mineResultGroup.addAll(mrss);
        Collections.sort(mineResultGroup, new AlphanumComparator());

        Iterator mrArrayListIterator = mineResultGroup.iterator();
        while (mrArrayListIterator.hasNext()) {
            String key = (String) mrArrayListIterator.next();
            final MineResult mr = (MineResult) mrArrayList.get(key);
            Map<String, ExtendedTimeSeries> statMap = mr.getStatTimeseriesMap();
            Map<String, ExtendedTimeSeries> eventMap = mr.getEventTimeseriesMap();
            if (!statMap.entrySet().isEmpty() || !eventMap.entrySet().isEmpty()) {
                if (mr.getStartDate() != null && mr.getEndDate() != null) {
                    if ((mr.getStartDate().before((Date) endDateJSPinner.getValue()))
                            && (mr.getEndDate().after((Date) startDateJSpinner.getValue()))) {
                        groupCount++;
                    }
                }
            }
        }
        Iterator mrArrayListIterator2 = mineResultGroup.iterator();
        while (mrArrayListIterator2.hasNext()) {
            String key = (String) mrArrayListIterator2.next();
            final MineResult mr = (MineResult) mrArrayList.get(key);
            Map<String, ExtendedTimeSeries> statMap = mr.getStatTimeseriesMap();
            Map<String, ExtendedTimeSeries> eventMap = mr.getEventTimeseriesMap();
            if (!statMap.entrySet().isEmpty() || !eventMap.entrySet().isEmpty()) {
                if (mr.getStartDate() != null && mr.getEndDate() != null) {
                    if ((mr.getStartDate().before((Date) maximumDate))
                            && (mr.getEndDate().after((Date) minimumDate))) {
                        totalGroupCount++;
                    }
                }
            }
        }
        boolean selected = true;
        if (groupCheckBox.containsKey(((Source) pairs.getKey()).getSourceName())) {
            selected = groupCheckBox.get(((Source) pairs.getKey()).getSourceName());
        } else {
            groupCheckBox.put(((Source) pairs.getKey()).getSourceName(), selected);

        }

        JCheckBox chckbxGroup = new JCheckBox(
                ((Source) pairs.getKey()).getSourceName() + "(" + groupCount + "/" + totalGroupCount + ")");
        chckbxGroup.setFont(new Font("Dialog", Font.BOLD, 11));
        chckbxGroup.setSelected(selected);
        panel_1.add(chckbxGroup);
        chckbxGroup.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                JCheckBox chkBox = ((JCheckBox) e.getSource());
                groupCheckBox.put(
                        (String) chkBox.getText().substring(0, ((String) chkBox.getText()).indexOf("(")),
                        !groupCheckBox.get((String) chkBox.getText().substring(0,
                                ((String) chkBox.getText()).indexOf("("))));
                loadGroupCheckbox(panel_2);
                load(panel_2);
                //logger.info("checkBox:"+ chkBox.getText()+","+chkBox.isSelected()+","+groupCheckBox);
                //logger.info("checkBox2:"+((String)chkBox.getText())+", "+((String)chkBox.getText()).indexOf("(")+", "+groupCheckBox.get((String)chkBox.getText().substring(0, ((String)chkBox.getText()).indexOf("(")))); 
            }
        });
    }
}

From source file:logdruid.ui.chart.GraphPanel.java

public void load(JPanel panel_2) {
    startDateJSpinner = (JSpinner) panel_2.getComponent(2);
    endDateJSPinner = (JSpinner) panel_2.getComponent(3);
    // scrollPane.setV
    panel.removeAll();// w ww. ja v  a2 s .  c  om
    Dimension panelSize = this.getSize();
    add(scrollPane, BorderLayout.CENTER);
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    // scrollPane.set trying to replace scroll where it was
    JCheckBox relativeCheckBox = (JCheckBox) panel_2.getComponent(5);
    estimatedTime = System.currentTimeMillis() - startTime;
    logger.info("gathering time: " + estimatedTime);
    startTime = System.currentTimeMillis();
    //   Map<Source, Map<String, MineResult>>
    Map<Source, Map<String, MineResult>> treeMap = new TreeMap<Source, Map<String, MineResult>>(
            mineResultSet.mineResults);
    Iterator mineResultSetIterator = treeMap.entrySet().iterator();
    int ite = 0;
    logger.debug("mineResultSet size: " + mineResultSet.mineResults.size());
    while (mineResultSetIterator.hasNext()) {
        final Map.Entry pairs = (Map.Entry) mineResultSetIterator.next();
        logger.debug("mineResultSet key/source: " + ((Source) pairs.getKey()).getSourceName());
        JCheckBox checkBox = (JCheckBox) panel_1.getComponent(ite++);
        logger.debug("checkbox: " + checkBox.getText() + ", " + checkBox.isSelected());
        if (checkBox.isSelected()) {

            Map mrArrayList = (Map<String, MineResult>) pairs.getValue();
            ArrayList<String> mineResultGroup = new ArrayList<String>();
            Set<String> mrss = mrArrayList.keySet();

            mineResultGroup.addAll(mrss);
            Collections.sort(mineResultGroup, new AlphanumComparator());
            Iterator mrArrayListIterator = mineResultGroup.iterator();
            while (mrArrayListIterator.hasNext()) {

                String key = (String) mrArrayListIterator.next();
                logger.debug(key);
                final MineResult mr = (MineResult) mrArrayList.get(key);
                Map<String, ExtendedTimeSeries> statMap = mr.getStatTimeseriesMap();
                Map<String, ExtendedTimeSeries> eventMap = mr.getEventTimeseriesMap();
                // logger.info("mineResultSet hash size: "
                // +mr.getTimeseriesMap().size());
                // logger.info("mineResultSet hash content: " +
                // mr.getStatTimeseriesMap());
                logger.debug("mineResultSet mr.getStartDate(): " + mr.getStartDate()
                        + " mineResultSet mr.getEndDate(): " + mr.getEndDate());
                logger.debug("mineResultSet (Date)jsp.getValue(): " + (Date) startDateJSpinner.getValue());
                logger.debug("mineResultSet (Date)jsp2.getValue(): " + (Date) endDateJSPinner.getValue());
                if (mr.getStartDate() != null && mr.getEndDate() != null) {
                    if ((mr.getStartDate().before((Date) endDateJSPinner.getValue()))
                            && (mr.getEndDate().after((Date) startDateJSpinner.getValue()))) {

                        ArrayList<String> mineResultGroup2 = new ArrayList<String>();
                        Set<String> mrss2 = statMap.keySet();
                        mineResultGroup2.addAll(mrss2);
                        Collections.sort(mineResultGroup2, new AlphanumComparator());
                        Iterator statMapIterator = mineResultGroup2.iterator();

                        //            Iterator statMapIterator = statMap.entrySet().iterator();
                        if (!statMap.entrySet().isEmpty() || !eventMap.entrySet().isEmpty()) {
                            JPanel checkboxPanel = new JPanel(new WrapLayout());

                            checkboxPanel.setBackground(Color.white);

                            int count = 1;
                            chart = ChartFactory.createXYAreaChart(// Title
                                    mr.getSourceID() + " " + mr.getGroup(), // +
                                    null, // X-Axis
                                    // label
                                    null, // Y-Axis label
                                    null, // Dataset
                                    PlotOrientation.VERTICAL, false, // Show
                                    // legend
                                    true, // tooltips
                                    false // url
                            );
                            TextTitle my_Chart_title = new TextTitle(mr.getSourceID() + " " + mr.getGroup(),
                                    new Font("Verdana", Font.BOLD, 17));
                            chart.setTitle(my_Chart_title);
                            XYPlot plot = (XYPlot) chart.getPlot();
                            ValueAxis range = plot.getRangeAxis();
                            range.setVisible(false);

                            final DateAxis domainAxis1 = new DateAxis();
                            domainAxis1.setTickLabelsVisible(true);
                            // domainAxis1.setTickMarksVisible(true);

                            logger.debug("getRange: " + domainAxis1.getRange());
                            if (relativeCheckBox.isSelected()) {
                                domainAxis1.setRange((Date) startDateJSpinner.getValue(),
                                        (Date) endDateJSPinner.getValue());
                            } else {
                                Date startDate = mr.getStartDate();
                                Date endDate = mr.getEndDate();
                                if (mr.getStartDate().before((Date) startDateJSpinner.getValue())) {
                                    startDate = (Date) startDateJSpinner.getValue();
                                    logger.debug("setMinimumDate: " + (Date) startDateJSpinner.getValue());
                                }
                                if (mr.getEndDate().after((Date) endDateJSPinner.getValue())) {
                                    endDate = (Date) endDateJSPinner.getValue();
                                    logger.debug("setMaximumDate: " + (Date) endDateJSPinner.getValue());
                                }
                                if (startDate.before(endDate)) {
                                    domainAxis1.setRange(startDate, endDate);
                                }
                            }
                            XYToolTipGenerator tt1 = new XYToolTipGenerator() {
                                public String generateToolTip(XYDataset dataset, int series, int item) {
                                    StringBuffer sb = new StringBuffer();
                                    String htmlStr = "<html>";
                                    Number x;
                                    FastDateFormat sdf = FastDateFormat.getInstance("dd-MMM-yyyy HH:mm:ss");
                                    x = dataset.getX(series, item);
                                    sb.append(htmlStr);
                                    if (x != null) {
                                        sb.append("<p style='color:#000000;'>" + (sdf.format(x)) + "</p>");
                                        sb.append("<p style='color:#000000;'>"
                                                + dataset.getSeriesKey(series).toString() + ": "
                                                + form.format(dataset.getYValue(0, item)) + "</p>");
                                        if (mr.getFileLineForDate(new Date(x.longValue()),
                                                dataset.getSeriesKey(series).toString()) != null) {
                                            sb.append(
                                                    "<p style='color:#0000FF;'>"
                                                            + cd.sourceFileArrayListMap
                                                                    .get(pairs.getKey()).get(mr
                                                                            .getFileLineForDate(
                                                                                    new Date(x.longValue()),
                                                                                    dataset.getSeriesKey(series)
                                                                                            .toString())
                                                                            .getFileId())
                                                                    .getFile().getName()
                                                            + ":"
                                                            + mr.getFileLineForDate(new Date(x.longValue()),
                                                                    dataset.getSeriesKey(series).toString())
                                                                    .getLineNumber()
                                                            + "</p>");

                                        }
                                    }
                                    return sb.toString();
                                }
                            };

                            while (statMapIterator.hasNext()) {

                                TimeSeriesCollection dataset = new TimeSeriesCollection();
                                String me = (String) statMapIterator.next();

                                ExtendedTimeSeries ts = (ExtendedTimeSeries) statMap.get(me);
                                // logger.info(((TimeSeries)
                                // me.getValue()).getMaxY());
                                if (((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMaxY() > 0)
                                    dataset.addSeries(ts.getTimeSeries());
                                logger.debug("mineResultSet group: " + mr.getGroup() + ", key: " + me
                                        + " nb records: " + ((ExtendedTimeSeries) statMap.get(me))
                                                .getTimeSeries().getItemCount());
                                logger.debug("(((TimeSeries) me.getValue()).getMaxY(): "
                                        + (((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMaxY()));
                                logger.debug("(((TimeSeries) me.getValue()).getMinY(): "
                                        + (((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMinY()));
                                XYPlot plot1 = chart.getXYPlot();
                                //   LogarithmicAxis axis4 = new LogarithmicAxis(me.toString());
                                NumberAxis axis4 = new NumberAxis(me.toString());
                                axis4.setAutoRange(true);
                                axis4.setAxisLineVisible(true);
                                axis4.setAutoRangeIncludesZero(false);
                                plot1.setDomainCrosshairVisible(true);
                                plot1.setRangeCrosshairVisible(true);
                                axis4.setRange(new Range(
                                        ((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMinY(),
                                        ((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMaxY()));
                                axis4.setLabelPaint(colors[count]);
                                axis4.setTickLabelPaint(colors[count]);
                                plot1.setRangeAxis(count, axis4);
                                final ValueAxis domainAxis = domainAxis1;
                                domainAxis.setLowerMargin(0.0);
                                domainAxis.setUpperMargin(0.0);
                                plot1.setDomainAxis(domainAxis);
                                plot1.setForegroundAlpha(0.5f);
                                plot1.setDataset(count, dataset);
                                plot1.mapDatasetToRangeAxis(count, count);
                                final XYAreaRenderer renderer = new XYAreaRenderer(); // XYAreaRenderer2
                                // also
                                // nice
                                if ((((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMaxY()
                                        - ((ExtendedTimeSeries) statMap.get(me)).getTimeSeries()
                                                .getMinY()) > 0) {

                                    // renderer.setToolTipGenerator(new
                                    // StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,new
                                    // FastDateFormat("d-MMM-yyyy HH:mm:ss"),
                                    // new DecimalFormat("#,##0.00")));
                                }
                                renderer.setSeriesPaint(0, colors[count]);
                                renderer.setSeriesVisible(0, true);
                                renderer.setSeriesToolTipGenerator(0, tt1);
                                plot1.setRenderer(count, renderer);
                                int hits = 0; // ts.getStat()[1]
                                int matchs = 0;
                                if (((ExtendedTimeSeries) statMap.get(me)).getStat() != null) {
                                    hits = ((ExtendedTimeSeries) statMap.get(me)).getStat()[1];
                                    //   matchs= ((ExtendedTimeSeries) statMap.get(me)).getStat()[0];
                                }
                                JCheckBox jcb = new JCheckBox(new VisibleAction(panel, checkboxPanel, axis4,
                                        me.toString() + "(" + hits + ")", 0));
                                Boolean selected = true;
                                jcb.setSelected(true);
                                jcb.setBackground(Color.white);
                                jcb.setBorderPainted(true);
                                jcb.setBorder(BorderFactory.createLineBorder(colors[count], 1, true));
                                jcb.setFont(new Font("Sans-serif", oldSmallFont.getStyle(),
                                        oldSmallFont.getSize()));
                                checkboxPanel.add(jcb);
                                count++;
                            }
                            Iterator eventMapIterator = eventMap.entrySet().iterator();
                            while (eventMapIterator.hasNext()) {

                                //   HistogramDataset histoDataSet=new HistogramDataset();

                                TimeSeriesCollection dataset = new TimeSeriesCollection();
                                Map.Entry me = (Map.Entry) eventMapIterator.next();
                                // if (dataset.getEndXValue(series, item))
                                if (((ExtendedTimeSeries) me.getValue()).getTimeSeries().getMaxY() > 0)
                                    dataset.addSeries(((ExtendedTimeSeries) me.getValue()).getTimeSeries());

                                logger.debug("mineResultSet group: " + mr.getGroup() + ", key: " + me.getKey()
                                        + " nb records: "
                                        + ((ExtendedTimeSeries) me.getValue()).getTimeSeries().getItemCount());
                                logger.debug("mineResultSet hash content: " + mr.getEventTimeseriesMap());
                                logger.debug("(((TimeSeries) me.getValue()).getMaxY(): "
                                        + (((ExtendedTimeSeries) me.getValue()).getTimeSeries().getMaxY()));
                                logger.debug("(((TimeSeries) me.getValue()).getMinY(): "
                                        + (((ExtendedTimeSeries) me.getValue()).getTimeSeries().getMinY()));
                                XYPlot plot2 = chart.getXYPlot();
                                //   LogarithmicAxis axis4 = new LogarithmicAxis(me.toString());
                                NumberAxis axis4 = new NumberAxis(me.getKey().toString());
                                axis4.setAutoRange(true);
                                // axis4.setInverted(true);
                                axis4.setAxisLineVisible(true);
                                axis4.setAutoRangeIncludesZero(true);

                                // axis4.setRange(new Range(((TimeSeries)
                                // axis4.setRange(new Range(((TimeSeries)
                                // me.getValue()).getMinY(), ((TimeSeries)
                                // me.getValue()).getMaxY()));
                                axis4.setLabelPaint(colors[count]);
                                axis4.setTickLabelPaint(colors[count]);
                                plot2.setRangeAxis(count, axis4);
                                final ValueAxis domainAxis = domainAxis1;

                                // domainAxis.setLowerMargin(0.001);
                                // domainAxis.setUpperMargin(0.0);
                                plot2.setDomainCrosshairVisible(true);
                                plot2.setRangeCrosshairVisible(true);
                                //plot2.setRangeCrosshairLockedOnData(true);
                                plot2.setDomainAxis(domainAxis);
                                plot2.setForegroundAlpha(0.5f);
                                plot2.setDataset(count, dataset);
                                plot2.mapDatasetToRangeAxis(count, count);
                                XYBarRenderer rend = new XYBarRenderer(); // XYErrorRenderer

                                rend.setShadowVisible(false);
                                rend.setDrawBarOutline(true);
                                Stroke stroke = new BasicStroke(5);
                                rend.setBaseStroke(stroke);
                                final XYItemRenderer renderer = rend;
                                renderer.setSeriesToolTipGenerator(0, tt1);
                                // renderer.setItemLabelsVisible(true);
                                renderer.setSeriesPaint(0, colors[count]);
                                renderer.setSeriesVisible(0, true);
                                plot2.setRenderer(count, renderer);
                                int hits = 0;
                                int matchs = 0;

                                if (((ExtendedTimeSeries) me.getValue()).getStat() != null) {
                                    hits = ((ExtendedTimeSeries) me.getValue()).getStat()[1];
                                    //   matchs= ((ExtendedTimeSeries) me.getValue()).getStat()[0];
                                }
                                JCheckBox jcb = new JCheckBox(new VisibleAction(panel, checkboxPanel, axis4,
                                        me.getKey().toString() + "(" + hits + ")", 0));

                                jcb.setSelected(true);
                                jcb.setBackground(Color.white);
                                jcb.setBorderPainted(true);
                                jcb.setBorder(BorderFactory.createLineBorder(colors[count], 1, true));
                                jcb.setFont(new Font("Sans-serif", oldSmallFont.getStyle(),
                                        oldSmallFont.getSize()));
                                checkboxPanel.add(jcb);
                                count++;
                            }

                            JPanel pan = new JPanel();

                            pan.setLayout(new BorderLayout());
                            pan.setPreferredSize(new Dimension(600,
                                    Integer.parseInt((String) Preferences.getPreference("chartSize"))));
                            // pan.setPreferredSize(panelSize);
                            panel.add(pan);
                            final ChartPanel cpanel = new ChartPanel(chart);
                            cpanel.setMinimumDrawWidth(0);
                            cpanel.setMinimumDrawHeight(0);
                            cpanel.setMaximumDrawWidth(1920);
                            cpanel.setMaximumDrawHeight(1200);
                            // cpanel.setInitialDelay(0);
                            cpanel.setDismissDelay(9999999);
                            cpanel.setInitialDelay(50);
                            cpanel.setReshowDelay(200);
                            cpanel.setPreferredSize(new Dimension(600, 350));
                            // cpanel.restoreAutoBounds(); fix the tooltip
                            // missing problem but then relative display is
                            // broken
                            panel.add(new JSeparator(SwingConstants.HORIZONTAL));
                            pan.add(cpanel, BorderLayout.CENTER);
                            // checkboxPanel.setPreferredSize(new Dimension(600,
                            // 0));
                            cpanel.addChartMouseListener(new ChartMouseListener() {

                                public void chartMouseClicked(ChartMouseEvent chartmouseevent) {
                                    // chartmouseevent.getEntity().

                                    ChartEntity entity = chartmouseevent.getEntity();
                                    if (entity instanceof XYItemEntity) {
                                        XYItemEntity item = ((XYItemEntity) entity);
                                        if (item.getDataset() instanceof TimeSeriesCollection) {

                                            TimeSeriesCollection data = (TimeSeriesCollection) item
                                                    .getDataset();
                                            TimeSeries series = data.getSeries(item.getSeriesIndex());
                                            TimeSeriesDataItem dataitem = series.getDataItem(item.getItem());

                                            // logger.info(" Serie: "+series.getKey().toString()
                                            // +
                                            // " Period : "+dataitem.getPeriod().toString());
                                            // mr.getFileForDate(new Date
                                            // (x.longValue())
                                            ;
                                            int x = chartmouseevent.getTrigger().getX();
                                            // logger.info(mr.getFileForDate(dataitem.getPeriod().getEnd()));
                                            int y = chartmouseevent.getTrigger().getY();
                                            String myString = "";
                                            if (dataitem.getPeriod() != null) {
                                                logger.info(dataitem.getPeriod().getEnd());
                                                //                                    myString = mr.getFileForDate(dataitem.getPeriod().getEnd()).toString();
                                                String lineString = ""
                                                        + mr.getFileLineForDate(dataitem.getPeriod().getEnd(),
                                                                item.getDataset()
                                                                        .getSeriesKey(item.getSeriesIndex())
                                                                        .toString())
                                                                .getLineNumber();
                                                String fileString = cd.sourceFileArrayListMap
                                                        .get(pairs.getKey())
                                                        .get(mr.getFileLineForDate(
                                                                dataitem.getPeriod().getEnd(),
                                                                item.getDataset()
                                                                        .getSeriesKey(item.getSeriesIndex())
                                                                        .toString())
                                                                .getFileId())
                                                        .getFile().getAbsolutePath();
                                                String command = Preferences.getPreference("editorCommand");
                                                command = command.replace("$line", lineString);
                                                command = command.replace("$file", fileString);
                                                logger.info(command);
                                                Runtime rt = Runtime.getRuntime();
                                                try {
                                                    rt.exec(command);
                                                } catch (IOException e1) {
                                                    // TODO Auto-generated catch block
                                                    e1.printStackTrace();
                                                }
                                                StringSelection stringSelection = new StringSelection(
                                                        fileString);
                                                Clipboard clpbrd = Toolkit.getDefaultToolkit()
                                                        .getSystemClipboard();
                                                clpbrd.setContents(stringSelection, null);
                                                //      cpanel.getGraphics().drawString("file name copied", x - 5, y - 5);
                                                try {
                                                    Thread.sleep(500);
                                                } catch (InterruptedException e) {
                                                    // TODO Auto-generated catch
                                                    // block
                                                    e.printStackTrace();
                                                }
                                            }

                                            // logger.info(mr.getFileForDate(dataitem.getPeriod().getStart()));
                                        }
                                    }
                                }

                                public void chartMouseMoved(ChartMouseEvent e) {
                                }

                            });

                            pan.add(checkboxPanel, BorderLayout.SOUTH);

                        }
                    }
                } else {
                    logger.debug("mr dates null: " + mr.getGroup() + mr.getSourceID() + mr.getLogFiles());
                }
            }
        }
    }
    // Map=miner.mine(sourceFiles,repo);
    estimatedTime = System.currentTimeMillis() - startTime;

    revalidate();
    logger.info("display time: " + estimatedTime);
}

From source file:neembuu.uploader.NeembuuUploader.java

static JCheckBox findByName(Map<JCheckBox, SmallModuleEntry> m, String name) {
    Iterator<JCheckBox> it = m.keySet().iterator();
    while (it.hasNext()) {
        JCheckBox cb = it.next();
        if (cb == null || cb.getText() == null) {
            continue;
        }// www.  j a  v a2 s. c  om
        if (cb.getText().equalsIgnoreCase(name)) {
            return cb;
        }
        //.addActionListener(checkBoxActionListener);
    }
    return null;
}

From source file:HW3.java

private void finalDisplaySubCategory(String catName) {
    for (HashMap map : mapList) {
        if (map != null) {
            Iterator it = map.keySet().iterator();
            while (it.hasNext()) {
                JCheckBox jcheck = (JCheckBox) it.next();
                String s = jcheck.getText();
                boolean flag = checkAlredyExists(s, subCatNames);
                if (map.get(jcheck).equals(catName) && flag == false) {
                    subCatNames.add(s);/*from  w ww .j  a v  a2 s.c  o m*/
                    jcheck.setSelected(false);
                    subCategoryPanel.add(jcheck);
                    jcheck.addItemListener(new ItemListener() {
                        @Override
                        public void itemStateChanged(ItemEvent e) {
                            String subCatName = null;
                            HashMap<JCheckBox, String> returnList = new HashMap<JCheckBox, String>();
                            if (jcheck.isSelected()) {
                                subCatName = jcheck.getText();
                                //System.out.println(subCatName);
                                selectSubCat.add(subCatName);
                                displayAttr(subCatName, returnList);
                                AttrList[attrListCount] = returnList;
                                finalAttributeDisplay(subCatName);
                            } else {
                                subCatName = jcheck.getText();
                                selectSubCat.remove(subCatName);
                                clearBusinessTable();
                                finalAttributeRemove(subCatName);
                            }
                        }
                    });
                }
            }
        }
    }
    subCategoryPanel.setLayout(new GridLayout(0, 1));
    subCategoryPanel.revalidate();
    subCategoryPanel.repaint();
    pack();
    subCategoryPanel.setVisible(true);
    if (mapListCount == MAX_MAP_LIST_COUNT - 1) {
        mapListCount = 0;
    } else {
        mapListCount++;
    }
}

From source file:HW3.java

private void finalAttributeDisplay(String subCatName) {
    for (HashMap hmap : AttrList) {
        if (hmap != null) {
            Iterator iter = hmap.keySet().iterator();
            boolean flag;
            while (iter.hasNext()) {
                JCheckBox jcheck = (JCheckBox) iter.next();
                String attr = jcheck.getText();
                flag = checkAlredyExists(attr, attrNames);
                if (hmap.get(jcheck) == subCatName && flag == false) {
                    attrNames.add(attr);
                    jcheck.setSelected(false);
                    attrPanel.add(jcheck);
                    jcheck.addItemListener(new ItemListener() {

                        @Override
                        public void itemStateChanged(ItemEvent e) {
                            String str = jcheck.getText();
                            if (jcheck.isSelected()) {
                                if (!checkAlredyExists(str, selectedAttrList)) {
                                    selectedAttrList.add(str);
                                }// w w  w . j a va  2  s. c om
                            } else {
                                clearBusinessTable();
                                selectedAttrList.remove(str);
                            }
                        }
                    });
                }
            }
        }
    }
    attrPanel.setLayout(new GridLayout(0, 1));
    attrPanel.revalidate();
    attrPanel.repaint();
    pack();
    attrPanel.setVisible(true);
    if (attrListCount == MAX_ATTR_LIST_COUNT - 1) {
        attrListCount = 0;
    } else {
        attrListCount++;
    }
}

From source file:HW3.java

private void finalRemoveSubCategory(String catName) {
    for (HashMap map : mapList) {
        if (map != null) {
            Iterator it = map.keySet().iterator();
            while (it.hasNext()) {
                JCheckBox jcheck = (JCheckBox) it.next();
                //System.out.println(jcheck);
                String s = jcheck.getText();
                if (map.get(jcheck).equals(catName)) {
                    if (jcheck.isSelected()) {
                        finalAttributeRemove(s);
                    }/*from  w w w. ja va  2  s.  c  o m*/
                    int index = subCatNames.indexOf(s);
                    if (index != -1) {
                        subCatNames.remove(index);
                    }
                    int id = selectSubCat.indexOf(s);
                    if (id != -1) {
                        selectSubCat.remove(id);
                    }
                    subCategoryPanel.remove(jcheck);
                }
            }
            map = null;
        }
    }
    subCategoryPanel.revalidate();
    subCategoryPanel.repaint();
}

From source file:HW3.java

private void finalAttributeRemove(String subCatName) {
    for (HashMap hmap : AttrList) {
        if (hmap != null) {
            Iterator iter = hmap.keySet().iterator();
            while (iter.hasNext()) {
                JCheckBox jcheck = (JCheckBox) iter.next();
                if (hmap.get(jcheck).equals(subCatName)) {
                    //System.out.println("$$$ " +jcheck.getText());
                    String s = jcheck.getText();
                    int index = attrNames.indexOf(s);
                    if (index != -1) {
                        attrNames.remove(index);
                    }//from  w w w  .ja  va2  s  .co m
                    index = selectedAttrList.indexOf(s);
                    if (index != -1) {
                        selectedAttrList.remove(index);
                    }
                    attrPanel.remove(jcheck);
                }
            }
            //hmap.clear();
            hmap = null;
        }
    }
    attrPanel.revalidate();
    attrPanel.repaint();
}

From source file:ffx.ui.ModelingPanel.java

/**
 * This handles conditional command option input.
 *
 * @param evt ActionEvent//  ww  w  . j  a v a 2s.  co  m
 */
private void conditionalCommandEvent(ActionEvent evt) {
    Object source = evt.getSource();
    if (source instanceof JRadioButton) {
        JRadioButton jrb = (JRadioButton) source;
        String selection = jrb.getText().toLowerCase();
        for (JLabel label : conditionals) {
            JTextField jtf = (JTextField) label.getLabelFor();
            String cupon = label.getName().toLowerCase();
            if (cupon.contains(selection) && jrb.isSelected()) {
                label.setEnabled(true);
                jtf.setEnabled(true);
            } else {
                label.setEnabled(false);
                jtf.setEnabled(false);
            }
        }
    } else if (source instanceof JCheckBox) {
        JCheckBox jcb = (JCheckBox) source;
        String selection = jcb.getText().toLowerCase();
        for (JLabel label : conditionals) {
            String cupon = label.getName().toLowerCase();
            JTextField jtf = (JTextField) label.getLabelFor();
            if (cupon.contains(selection) && jcb.isSelected()) {
                label.setEnabled(true);
                jtf.setEnabled(true);
            } else {
                label.setEnabled(false);
                jtf.setEnabled(false);
            }
        }
    }
    statusLabel.setText("  " + createCommandInput());
}

From source file:ffx.ui.ModelingPanel.java

/**
 * Create a string representing the modeling command to execute.
 *
 * @return the modeling command string.//from  w  w  w. j av a 2  s. c o m
 */
private String createCommandInput() {
    StringBuilder commandLineParams = new StringBuilder(activeCommand + " ");
    // Now append command line input to a TextArea, one option per line.
    // This TextArea gets dumped to an input file.
    commandTextArea.setText("");
    int numparams = optionsTabbedPane.getTabCount();
    for (int i = 0; i < numparams; i++) {
        // A few cases require that a newLine not be generated between
        // options.
        boolean newLine = true;
        // The optionString will collect the parameters for this Option,
        // then append them to the CommandTextArea.
        StringBuilder optionString = new StringBuilder();
        JPanel optionPanel = (JPanel) optionsTabbedPane.getComponentAt(i);
        int numOptions = optionPanel.getComponentCount();
        String title = optionsTabbedPane.getTitleAt(i);
        if (title.equalsIgnoreCase("Sequence")) {
            for (int k = 0; k < acidComboBox.getItemCount(); k++) {
                if (k != 0) {
                    optionString.append("\n");
                }
                String s = (String) acidComboBox.getItemAt(k);
                s = s.substring(s.indexOf(" "), s.length()).trim();
                optionString.append(s);
            }
            // Need an extra newline for Nucleic
            if (activeCommand.equalsIgnoreCase("NUCLEIC")) {
                optionString.append("\n");
            }
        } else {
            JPanel valuePanel = (JPanel) optionPanel.getComponent(numOptions - 1);
            int numValues = valuePanel.getComponentCount();
            for (int j = 0; j < numValues; j++) {
                Component value = valuePanel.getComponent(j);
                if (value instanceof JCheckBox) {
                    JCheckBox jcbox = (JCheckBox) value;
                    if (jcbox.isSelected()) {
                        optionString.append("-");
                        optionString.append(jcbox.getName());
                        optionString.append(" ");
                        optionString.append(jcbox.getText());
                    }
                } else if (value instanceof JTextField) {
                    JTextField jtfield = (JTextField) value;
                    optionString.append("-");
                    optionString.append(jtfield.getName());
                    optionString.append(" ");
                    optionString.append(jtfield.getText());
                } else if (value instanceof JComboBox) {
                    JComboBox jcb = (JComboBox) value;
                    Object object = jcb.getSelectedItem();
                    if (object instanceof FFXSystem) {
                        FFXSystem system = (FFXSystem) object;
                        File file = system.getFile();
                        if (file != null) {
                            String absolutePath = file.getAbsolutePath();
                            if (absolutePath.endsWith("xyz")) {
                                absolutePath = absolutePath + "_1";
                            }
                            optionString.append(absolutePath);
                        }
                    }
                } else if (value instanceof JRadioButton) {
                    JRadioButton jrbutton = (JRadioButton) value;
                    if (jrbutton.isSelected()) {
                        if (!jrbutton.getText().equalsIgnoreCase("NONE")) {
                            optionString.append("-");
                            optionString.append(jrbutton.getName());
                            optionString.append(" ");
                            optionString.append(jrbutton.getText());
                        }
                        if (title.equalsIgnoreCase("C-CAP")) {
                            optionString.append("\n");
                        }
                    }
                }
            }
            // Handle Conditional Options
            if (optionPanel.getComponentCount() == 3) {
                valuePanel = (JPanel) optionPanel.getComponent(1);
                // JLabel conditionalLabel = (JLabel)
                // valuePanel.getComponent(0);
                JTextField jtf = (JTextField) valuePanel.getComponent(1);
                if (jtf.isEnabled()) {
                    String conditionalInput = jtf.getText();
                    // Post-Process the Input into Atom Pairs
                    String postProcess = jtf.getName();
                    if (postProcess != null && postProcess.equalsIgnoreCase("ATOMPAIRS")) {
                        String tokens[] = conditionalInput.split(" +");
                        StringBuilder atomPairs = new StringBuilder();
                        int atomNumber = 0;
                        for (String token : tokens) {
                            atomPairs.append(token);
                            if (atomNumber++ % 2 == 0) {
                                atomPairs.append(" ");
                            } else {
                                atomPairs.append("\n");
                            }
                        }
                        conditionalInput = atomPairs.toString();
                    }
                    // Append a newline to "enter" the option string.
                    // Append "conditional" input.
                    optionString.append("\n").append(conditionalInput);
                }
            }
        }
        if (optionString.length() > 0) {
            commandTextArea.append(optionString.toString());
            if (newLine) {
                commandTextArea.append("\n");
            }
        }
    }
    String commandInput = commandTextArea.getText();
    if (commandInput != null && !commandInput.trim().equalsIgnoreCase("")) {
        commandLineParams.append(commandInput);
    }

    // The final token on the command line is the structure file name, except
    // for protein and nucleic.
    if (!activeCommand.equalsIgnoreCase("Protein") && !activeCommand.equalsIgnoreCase("Nucleic")) {
        File file = activeSystem.getFile();
        if (file != null) {
            String name = file.getName();
            commandLineParams.append(name);
            commandLineParams.append(" ");
        } else {
            return null;
        }
    }

    return commandLineParams.toString();
}