Example usage for java.awt List size

List of usage examples for java.awt List size

Introduction

In this page you can find the example usage for java.awt List size.

Prototype

@Deprecated
public Dimension size() 

Source Link

Document

Returns the size of this component in the form of a Dimension object.

Usage

From source file:uk.ac.ebi.demo.picr.swing.PICRBLASTDemo.java

public PICRBLASTDemo() {

    //set general layout
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

    add(Box.createVerticalStrut(5));

    //create components
    JPanel row1 = new JPanel();
    row1.setLayout(new BoxLayout(row1, BoxLayout.X_AXIS));
    row1.add(Box.createHorizontalStrut(5));
    row1.setBorder(BorderFactory.createTitledBorder(""));
    row1.add(new JLabel("Fragment:"));
    row1.add(Box.createHorizontalStrut(10));
    final JTextArea sequenceArea = new JTextArea(5, 40);
    sequenceArea.setMaximumSize(sequenceArea.getPreferredSize());
    row1.add(Box.createHorizontalStrut(10));

    row1.add(sequenceArea);/* w ww.  ja  v a  2s . co m*/
    row1.add(Box.createHorizontalGlue());

    JPanel row2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    row2.setBorder(BorderFactory.createTitledBorder("Target Databases"));
    final JList databaseList = new JList();
    JScrollPane listScroller = new JScrollPane(databaseList);
    listScroller.setMaximumSize(new Dimension(100, 10));
    JButton loadDBButton = new JButton("Load Databases");
    row2.add(listScroller);
    row2.add(loadDBButton);

    JPanel row3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    JCheckBox onlyActiveCheckBox = new JCheckBox("Only Active");
    onlyActiveCheckBox.setSelected(true);
    row3.add(new JLabel("Options:  "));
    row3.add(onlyActiveCheckBox);

    add(row1);
    add(row2);
    add(row3);

    final String[] columns = new String[] { "Database", "Accession", "Version", "Taxon ID" };
    final JTable dataTable = new JTable(new Object[0][0], columns);
    dataTable.setShowGrid(true);
    add(new JScrollPane(dataTable));

    JPanel buttonPanel = new JPanel();
    JButton mapAccessionButton = new JButton("Generate Mapping!");
    buttonPanel.add(mapAccessionButton);
    add(buttonPanel);

    //create listeners!

    //update boolean flag in communication class
    onlyActiveCheckBox.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            client.setOnlyActive(((JCheckBox) e.getSource()).isSelected());
        }
    });

    //performs mapping call and updates interface with results
    mapAccessionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            try {

                if (!"".equals(sequenceArea.getText())) {
                    //TODO filters and database are hardcoded here.  They should be added to the input panel at a later revision.
                    java.util.List<UPEntry> entries = client.performBlastMapping(sequenceArea.getText(),
                            databaseList.getSelectedValues(), "90", "", "IDENTITY", "UniprotKB", "", false,
                            new BlastParameter());

                    //compute size of array
                    if (entries != null) {
                        int size = 0;
                        for (UPEntry entry : entries) {
                            for (CrossReference xref : entry.getIdenticalCrossReferences()) {
                                size++;
                            }
                            for (CrossReference xref : entry.getLogicalCrossReferences()) {
                                size++;
                            }
                        }

                        if (size > 0) {

                            final Object[][] data = new Object[size][4];
                            int i = 0;
                            for (UPEntry entry : entries) {
                                for (CrossReference xref : entry.getIdenticalCrossReferences()) {
                                    data[i][0] = xref.getDatabaseName();
                                    data[i][1] = xref.getAccession();
                                    data[i][2] = xref.getAccessionVersion();
                                    data[i][3] = xref.getTaxonId();
                                    i++;
                                }
                                for (CrossReference xref : entry.getLogicalCrossReferences()) {
                                    data[i][0] = xref.getDatabaseName();
                                    data[i][1] = xref.getAccession();
                                    data[i][2] = xref.getAccessionVersion();
                                    data[i][3] = xref.getTaxonId();
                                    i++;
                                }
                            }

                            //refresh
                            DefaultTableModel dataModel = new DefaultTableModel();
                            dataModel.setDataVector(data, columns);
                            dataTable.setModel(dataModel);

                            System.out.println("update done");

                        } else {
                            JOptionPane.showMessageDialog(null, "No Mappind data found.");
                        }
                    } else {
                        JOptionPane.showMessageDialog(null, "No Mappind data found.");
                    }
                } else {
                    JOptionPane.showMessageDialog(null, "You must enter a valid FASTA sequence to map.");
                }
            } catch (SOAPFaultException soapEx) {
                JOptionPane.showMessageDialog(null, "A SOAP Error occurred.");
                soapEx.printStackTrace();
            }
        }
    });

    //loads list of mapping databases from communication class
    loadDBButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            try {

                java.util.List<String> databases = client.loadDatabases();
                if (databases != null && databases.size() > 0) {

                    databaseList.setListData(databases.toArray());
                    System.out.println("database refresh done");

                } else {
                    JOptionPane.showMessageDialog(null, "No Databases Loaded!.");
                }

            } catch (SOAPFaultException soapEx) {
                JOptionPane.showMessageDialog(null, "A SOAP Error occurred.");
                soapEx.printStackTrace();
            }
        }
    });

}

From source file:org.openfaces.component.chart.impl.plots.PiePlot3DAdapter.java

private void sectorProcessing(PiePlot plot, PieChartView chartView, PieDataset dataset,
        CategoryDataset categoryDataset) {
    java.util.List<PieSectorProperties> sectors = chartView.getSectors();
    if (sectors == null || sectors.size() == 0)
        return;//from  w  w w  .j a va  2s.  com

    for (PieSectorProperties sector : sectors) {
        DynamicPieGenerator generator = new DynamicPieGenerator(chartView, null);

        int index = -1;

        Float sectorPulled = sector.getPulled();
        if (dataset instanceof CategoryToPieDataset) {
            CategoryToPieDataset cds = (CategoryToPieDataset) dataset;
            int count = getIterationCount(cds);
            for (int q = 0; q < count; q++) {
                CategoryToPieDataset currPieDataset = new CategoryToPieDataset(categoryDataset, order, q);
                java.util.List keys = currPieDataset.getKeys();
                index = -1;
                for (int j = 0; j < keys.size(); j++) {
                    index++;

                    boolean conditionValue = generator.getConditionValue(sector, q, currPieDataset,
                            currPieDataset.getKey(j));
                    if (!conditionValue)
                        continue;

                    if (sectorPulled != null && sectorPulled > 0) {
                        plot.setExplodePercent(index, (double) sectorPulled);
                    }

                    StyleObjectModel cssSectorModel = sector.getStyleObjectModel();
                    if (cssSectorModel != null && cssSectorModel.getBorder() != null) {
                        StyleBorderModel border = cssSectorModel.getBorder();
                        Color borderColor = border.getColor();
                        if (borderColor != null) {
                            plot.setSectionOutlinePaint(index, borderColor);
                            plot.setSectionOutlineStroke(index, PropertiesConverter.toStroke(border));
                        }

                        Color sectorModelColor = cssSectorModel.getColor();
                        if (sectorModelColor != null) {
                            plot.setSectionPaint(index, sectorModelColor);
                        }
                    }
                }
            }
        } else {
            if (dataset == null || dataset.getKeys() == null)
                continue;

            for (int j = 0; j < dataset.getKeys().size(); j++) {
                index++;

                boolean conditionValue = generator.getConditionValue(sector, 0, dataset, dataset.getKey(j));
                if (!conditionValue)
                    continue;

                if (sectorPulled != null && sectorPulled > 0) {
                    plot.setExplodePercent(index, (double) sectorPulled);
                }

                StyleObjectModel cssSectorModel = sector.getStyleObjectModel();
                if (cssSectorModel != null && cssSectorModel.getBorder() != null) {
                    StyleBorderModel border = cssSectorModel.getBorder();
                    if (border.getColor() != null) {
                        plot.setSectionOutlinePaint(index, border.getColor());
                        plot.setSectionOutlineStroke(index, PropertiesConverter.toStroke(border));
                    }

                }
                if (cssSectorModel != null && cssSectorModel.getColor() != null) {
                    plot.setSectionPaint(index, cssSectorModel.getColor());
                }
            }
        }

    }

}

From source file:dbseer.gui.chart.DBSeerChartFactory.java

public static DefaultPieDataset getPieDataset(String chartName, DBSeerDataSet dataset) throws Exception {
    StatisticalPackageRunner runner = DBSeerGUI.runner;

    runner.eval("[title legends Xdata Ydata Xlabel Ylabel timestamp] = plotter.plot" + chartName + ";");

    String title = runner.getVariableString("title");
    Object[] legends = (Object[]) runner.getVariableCell("legends");
    Object[] xCellArray = (Object[]) runner.getVariableCell("Xdata");
    Object[] yCellArray = (Object[]) runner.getVariableCell("Ydata");
    String xLabel = runner.getVariableString("Xlabel");
    String yLabel = runner.getVariableString("Ylabel");
    timestamp = runner.getVariableDouble("timestamp");

    DefaultPieDataset pieDataSet = new DefaultPieDataset();

    int numLegends = legends.length;
    int numXCellArray = xCellArray.length;
    int numYCellArray = yCellArray.length;
    int dataCount = 0;

    if (numXCellArray != numYCellArray) {
        JOptionPane.showMessageDialog(null, "The number of X dataset and Y dataset does not match.",
                "The number of X dataset and Y dataset does not match.", JOptionPane.ERROR_MESSAGE);
        return null;
    }//from   ww  w  . j  ava2 s. c  o  m

    final java.util.List<String> transactionTypeNames = dataset.getTransactionTypeNames();

    for (int i = 0; i < numYCellArray; ++i) {
        double[] xArray = (double[]) xCellArray[i];
        runner.eval("yArraySize = size(Ydata{" + (i + 1) + "});");
        runner.eval("yArray = Ydata{" + (i + 1) + "};");
        double[] yArraySize = runner.getVariableDouble("yArraySize");
        double[] yArray = runner.getVariableDouble("yArray");

        int xLength = xArray.length;
        int row = (int) yArraySize[0];
        int col = (int) yArraySize[1];

        for (int c = 0; c < col; ++c) {
            if (c < transactionTypeNames.size()) {
                String name = transactionTypeNames.get(c);
                if (!name.isEmpty()) {
                    pieDataSet.setValue(name, yArray[c]);
                } else {
                    pieDataSet.setValue("Transaction Type " + (c + 1), yArray[c]);
                }
            }
        }
    }

    return pieDataSet;
}

From source file:dbseer.gui.chart.DBSeerChartFactory.java

public static JFreeChart createPieChart(String chartName, DBSeerDataSet dataset) throws Exception {
    StatisticalPackageRunner runner = DBSeerGUI.runner;

    runner.eval("[title legends Xdata Ydata Xlabel Ylabel timestamp] = plotter.plot" + chartName + ";");

    String title = runner.getVariableString("title");
    Object[] legends = (Object[]) runner.getVariableCell("legends");
    Object[] xCellArray = (Object[]) runner.getVariableCell("Xdata");
    Object[] yCellArray = (Object[]) runner.getVariableCell("Ydata");
    String xLabel = runner.getVariableString("Xlabel");
    String yLabel = runner.getVariableString("Ylabel");
    timestamp = runner.getVariableDouble("timestamp");

    DefaultPieDataset pieDataSet = new DefaultPieDataset();

    int numLegends = legends.length;
    int numXCellArray = xCellArray.length;
    int numYCellArray = yCellArray.length;
    int dataCount = 0;

    if (numXCellArray != numYCellArray) {
        JOptionPane.showMessageDialog(null, "The number of X dataset and Y dataset does not match.",
                "The number of X dataset and Y dataset does not match.", JOptionPane.ERROR_MESSAGE);
        return null;
    }//from w  ww .  ja va2 s. c o  m

    final java.util.List<String> transactionTypeNames = dataset.getTransactionTypeNames();

    for (int i = 0; i < numYCellArray; ++i) {
        double[] xArray = (double[]) xCellArray[i];
        runner.eval("yArraySize = size(Ydata{" + (i + 1) + "});");
        runner.eval("yArray = Ydata{" + (i + 1) + "};");
        double[] yArraySize = runner.getVariableDouble("yArraySize");
        double[] yArray = runner.getVariableDouble("yArray");

        int xLength = xArray.length;
        int row = (int) yArraySize[0];
        int col = (int) yArraySize[1];

        for (int c = 0; c < col; ++c) {
            if (c < transactionTypeNames.size()) {
                String name = transactionTypeNames.get(c);
                if (!name.isEmpty()) {
                    //                     pieDataSet.setValue(name, new Double(yArray.getRealValue(0, c)));
                    pieDataSet.setValue(name, yArray[c]);
                } else {
                    //                     pieDataSet.setValue("Transaction Type " + (c+1), yArray.getRealValue(0, c));
                    pieDataSet.setValue("Transaction Type " + (c + 1), yArray[c]);
                }
            }
        }
    }

    JFreeChart chart = ChartFactory.createPieChart(title, pieDataSet, true, true, false);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}: {1} ({2})", new DecimalFormat("0"),
            new DecimalFormat("0%")));
    plot.setLegendLabelGenerator(new PieSectionLabelGenerator() {
        @Override
        public String generateSectionLabel(PieDataset pieDataset, Comparable comparable) {
            return (String) comparable;
        }

        @Override
        public AttributedString generateAttributedSectionLabel(PieDataset pieDataset, Comparable comparable) {
            return null;
        }
    });
    return chart;
}

From source file:org.fhcrc.cpl.toolbox.gui.chart.PanelWithScatterPlot.java

public void addData(java.util.List<? extends Number> xValues, java.util.List<? extends Number> yValues,
        String dataSetName) {//from   w w w  .ja  v  a2 s .com
    double[] xArray = new double[xValues.size()];
    double[] yArray = new double[yValues.size()];

    for (int i = 0; i < xValues.size(); i++) {
        xArray[i] = xValues.get(i).doubleValue();
        yArray[i] = yValues.get(i).doubleValue();
    }
    addData(xArray, yArray, dataSetName, defaultShape, getDefaultColorForSeries(dataset.getSeriesCount()));
}

From source file:org.fhcrc.cpl.toolbox.gui.chart.PanelWithScatterPlot.java

public PanelWithScatterPlot(java.util.List<? extends Number> xValues, java.util.List<? extends Number> yValues,
        String dataSetName) {/*w  ww.j  a v a2s  . c  om*/
    this();
    double[] xValuesArray = new double[xValues.size()];
    double[] yValuesArray = new double[yValues.size()];
    for (int i = 0; i < xValues.size(); i++) {
        xValuesArray[i] = xValues.get(i).doubleValue();
        yValuesArray[i] = yValues.get(i).doubleValue();
    }
    addData(xValuesArray, yValuesArray, dataSetName);
    setName(dataSetName);
}

From source file:uk.ac.ucl.cs.cmic.giftcloud.uploadapp.GiftCloudDialogs.java

public String showInputDialogToSelectProject(final java.util.List<String> projectMap, final Component component,
        final Optional<String> lastProject) throws IOException {
    final String lastProjectName = lastProject.isPresent() ? lastProject.get() : "";

    if (projectMap.size() < 1) {
        return null;
    }/*w w  w  .  java2s  .  c o m*/

    String[] projectStringArray = projectMap.toArray(new String[0]);

    final String defaultSelection = projectMap.contains(lastProjectName) ? lastProjectName : null;

    final Object returnValue = JOptionPane.showInputDialog(component,
            "Please select a project to which data will be uploaded.", applicationName,
            JOptionPane.QUESTION_MESSAGE, null, projectStringArray, defaultSelection);

    if (returnValue == null) {
        throw new CancellationException("User cancelled project selection during upload");
    }

    if (!(returnValue instanceof String)) {
        throw new RuntimeException("Bad return type");
    }
    return (String) returnValue;
}

From source file:uk.nhs.cfh.dsp.srth.desktop.modules.queryresultspanel.QueryResultsPanel.java

/**
 * Hide concept Id and Entry time columns.
 * //from   w  w  w  .  ja v  a2s  .c  o  m
 * We know that column's follow the generic pattern : Concept_ID, Entry_Time, Free_Text_Entry
 * So we use this pattern to hide columns, 1 and 2 of the series. Note this patterns will change if
 * the table model is changed to use clinical entries.
 */
public void renderColumns() {

    java.util.List<TableColumnExt> cols = new ArrayList<TableColumnExt>();
    for (int i = 0; i < resultsTable.getColumnCount(true); i++) {
        cols.add(resultsTable.getColumnExt(i));
    }

    for (int i = 0; i < cols.size(); i++) {
        TableColumnExt col = cols.get(i);
        col.setCellRenderer(new QueryResultsTableCellRenderer());
        if (i % 3 == 0) {
            // set column visible
            col.setVisible(true);
        } else {
            col.setVisible(false);
        }
    }
}

From source file:brainflow.app.presentation.controls.FileObjectGroupSelector.java

private String unambiguousIdentifier(int index, java.util.List<FileObject> fileList) {

    FileObject candidate = fileList.get(index);
    String[] parts = candidate.getName().getPath().split("/");
    if (fileList.size() == 1) {
        return parts[parts.length - 1];
    }/*from   ww w  .j ava  2  s  . co  m*/

    int maxParts = 0;

    for (int i = 0; i < fileList.size(); i++) {
        if (i == index)
            continue;
        FileObject other = fileList.get(i);
        String[] otherParts = other.getName().getPath().split("/");
        maxParts = Math.max(maxParts, numMatches(parts, otherParts));
    }

    return joinParts(parts, maxParts + 1);

}

From source file:lu.lippmann.cdb.common.gui.ts.TimeSeriesChartUtil.java

public static ChartPanel buildChartPanelForNominalAttribute(final Instances ds, final Attribute attr,
        final int dateIdx) {
    final TaskSeriesCollection localTaskSeriesCollection = new TaskSeriesCollection();
    final java.util.List<String> names = new ArrayList<String>();

    final Set<String> present = WekaDataStatsUtil.getPresentValuesForNominalAttribute(ds, attr.index());
    for (final String pr : present) {
        names.add(pr);//  w  w w.  jav a2s  .c o m
        localTaskSeriesCollection.add(new TaskSeries(pr));
    }

    final Calendar cal = Calendar.getInstance();
    try {
        for (final double[] dd : WekaTimeSeriesUtil.split(ds, attr.index())) {
            cal.setTimeInMillis((long) dd[0]);
            final Date start = cal.getTime();
            cal.setTimeInMillis((long) dd[1]);
            final Date end = cal.getTime();
            final String sd = ds.instance((int) dd[2]).stringValue(attr);
            localTaskSeriesCollection.getSeries(sd).add(new Task("T", start, end));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    final XYTaskDataset localXYTaskDataset = new XYTaskDataset(localTaskSeriesCollection);
    localXYTaskDataset.setTransposed(true);
    localXYTaskDataset.setSeriesWidth(0.6D);

    final DateAxis localDateAxis = new DateAxis(DATE_TIME_LABEL);
    final SymbolAxis localSymbolAxis = new SymbolAxis("", names.toArray(new String[names.size()]));
    localSymbolAxis.setGridBandsVisible(false);
    final XYBarRenderer localXYBarRenderer = new XYBarRenderer();
    localXYBarRenderer.setUseYInterval(true);
    localXYBarRenderer.setShadowVisible(false);
    final XYPlot localXYPlot = new XYPlot(localXYTaskDataset, localDateAxis, localSymbolAxis,
            localXYBarRenderer);

    final CombinedDomainXYPlot localCombinedDomainXYPlot = new CombinedDomainXYPlot(
            new DateAxis(DATE_TIME_LABEL));
    localCombinedDomainXYPlot.add(localXYPlot);
    final JFreeChart localJFreeChart = new JFreeChart("", localCombinedDomainXYPlot);
    localJFreeChart.setBackgroundPaint(Color.white);

    final ChartPanel cp = new ChartPanel(localJFreeChart, true);
    cp.setBorder(new TitledBorder(attr.name()));
    return cp;
}