Search in sources :

Example 1 with DataReference

use of cbit.vcell.modelopt.DataReference in project vcell by virtualcell.

the class MultisourcePlotListModel method refreshAll.

/**
 * Insert the method's description here.
 * Creation date: (8/31/2005 4:18:09 PM)
 */
private void refreshAll() {
    // 
    // get list of objects (data names)
    // 
    sortDataReferenceHelpers = new ArrayList<SortDataReferenceHelper>();
    for (int i = 0; getDataSources() != null && i < getDataSources().length; i++) {
        DataSource dataSource = getDataSources(i);
        String[] columnNames = dataSource.getColumnNames();
        int timeIndex = dataSource.getTimeColumnIndex();
        for (int j = 0; j < columnNames.length; j++) {
            if (j == timeIndex) {
                continue;
            }
            sortDataReferenceHelpers.add(new SortDataReferenceHelper(sortDataReferenceHelpers.size(), new DataReference(dataSource, columnNames[j])));
        // System.out.println("unsort="+(sortDataReferenceHelpers.size()-1)+" i="+i+" j="+j+" columnames[j]="+columnNames[j]);
        }
    }
    if (sortDataReferenceHelpers.size() > 0) {
        if (comparatorDataSource != null) {
            Collections.sort(sortDataReferenceHelpers, comparatorDataSource);
        } else {
            // default sort
            Collections.sort(sortDataReferenceHelpers, new Comparator<SortDataReferenceHelper>() {

                @Override
                public int compare(SortDataReferenceHelper o1, SortDataReferenceHelper o2) {
                    int idCompare = o1.dataReference.getIdentifier().compareToIgnoreCase(o2.dataReference.getIdentifier());
                    if (idCompare == 0) {
                        return o1.dataReference.getDataSource().getName().compareToIgnoreCase(o2.dataReference.getDataSource().getName());
                    }
                    return idCompare;
                }
            });
        }
    }
    if (sortDataReferenceHelpers.size() > 0) {
        DataReference[] dataReferences = new DataReference[sortDataReferenceHelpers.size()];
        for (int i = 0; i < dataReferences.length; i++) {
            dataReferences[i] = sortDataReferenceHelpers.get(i).dataReference;
        }
        setContents(dataReferences);
    } else {
        setContents(null);
    }
}
Also used : DataReference(cbit.vcell.modelopt.DataReference) DataSource(cbit.vcell.modelopt.DataSource)

Example 2 with DataReference

use of cbit.vcell.modelopt.DataReference in project vcell by virtualcell.

the class MultisourcePlotPane method getJList1.

/**
 * Return the JList1 property value.
 * @return javax.swing.JList
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JList<DataReference> getJList1() {
    if (ivjJList1 == null) {
        try {
            ivjJList1 = new javax.swing.JList<DataReference>();
            ivjJList1.setName("JList1");
            ivjJList1.setBounds(0, 0, 255, 480);
            ivjJList1.setCellRenderer(new ListCellRenderer<DataReference>() {

                DefaultListCellRenderer defaultListCellRenderer = new DefaultListCellRenderer();

                private Boolean isEvenMatchedSet(int index0) {
                    if (ivjJList1.getModel().getSize() == 0) {
                        return null;
                    }
                    if (getmultisourcePlotListModel().getSortedDataReferences().get(index0).matchCount == null) {
                        // create matched set group counts (this happens 1 time)
                        int masterMatchCount = 0;
                        for (int i = 0; i < ivjJList1.getModel().getSize(); i++) {
                            DataSource dataSource = getmultisourcePlotListModel().getSortedDataReferences().get(i).dataReference.getDataSource();
                            if (dataSource instanceof DataSource.DataSourceReferenceData) {
                                if (i != ivjJList1.getModel().getSize() - 1) {
                                    SortDataReferenceHelper mySortDataReferenceHelper = getmultisourcePlotListModel().getSortedDataReferences().get(i);
                                    SortDataReferenceHelper potentialMatchSortDataReferenceHelper = getmultisourcePlotListModel().getSortedDataReferences().get(i + 1);
                                    if (potentialMatchSortDataReferenceHelper.getReferenceDataMappingSpec() != null && mySortDataReferenceHelper != null && potentialMatchSortDataReferenceHelper.getReferenceDataMappingSpec().getReferenceDataColumnName().equals(mySortDataReferenceHelper.dataReference.getIdentifier())) {
                                        mySortDataReferenceHelper.matchCount = masterMatchCount;
                                        potentialMatchSortDataReferenceHelper.matchCount = masterMatchCount;
                                        masterMatchCount++;
                                    } else {
                                        mySortDataReferenceHelper.matchCount = -1;
                                    }
                                } else {
                                    getmultisourcePlotListModel().getSortedDataReferences().get(i).matchCount = -1;
                                }
                            } else if (getmultisourcePlotListModel().getSortedDataReferences().get(i).matchCount == null) {
                                getmultisourcePlotListModel().getSortedDataReferences().get(i).matchCount = -1;
                            }
                        }
                    }
                    if (getmultisourcePlotListModel().getSortedDataReferences().get(index0).matchCount == -1) {
                        // not part of matched set
                        return null;
                    }
                    return getmultisourcePlotListModel().getSortedDataReferences().get(index0).matchCount % 2 == 0;
                }

                @Override
                public Component getListCellRendererComponent(JList<? extends DataReference> list, DataReference value, int index, boolean isSelected, boolean cellHasFocus) {
                    Component comp = defaultListCellRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                    try {
                        if (bGroupingListSorter && comp instanceof JLabel) {
                            if (isSelected) {
                                comp.setBackground(getJList1().getSelectionBackground());
                                comp.setForeground(getJList1().getSelectionForeground());
                            } else {
                                Boolean evenMatch = isEvenMatchedSet(index);
                                comp.setBackground(evenMatch == null || evenMatch ? getJList1().getBackground() : DefaultScrollTableCellRenderer.everyOtherRowColor);
                                comp.setForeground(getJList1().getForeground());
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    return comp;
                }
            });
        // user code begin {1}
        // user code end
        } catch (java.lang.Throwable ivjExc) {
            // user code begin {2}
            // user code end
            handleException(ivjExc);
        }
    }
    return ivjJList1;
}
Also used : JLabel(javax.swing.JLabel) DataSource(cbit.vcell.modelopt.DataSource) SortDataReferenceHelper(cbit.vcell.modelopt.gui.MultisourcePlotListModel.SortDataReferenceHelper) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) Component(java.awt.Component) DataReference(cbit.vcell.modelopt.DataReference)

Example 3 with DataReference

use of cbit.vcell.modelopt.DataReference in project vcell by virtualcell.

the class MultisourcePlotPane method selectionModel1_ValueChanged.

/**
 * Comment
 */
private void selectionModel1_ValueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent) throws Exception {
    if (listSelectionEvent.getValueIsAdjusting() == true) {
        return;
    }
    int firstIndex = listSelectionEvent.getFirstIndex();
    int lastIndex = listSelectionEvent.getLastIndex();
    if (firstIndex < 0 || lastIndex < 0) {
        getplotPane().setPlot2D(new Plot2D(null, null, new String[0], new PlotData[0]));
    }
    // 
    // make plotDatas for the reference data
    // 
    Vector<PlotData> plotDataList = new Vector<PlotData>();
    Vector<String> nameList = new Vector<String>();
    Vector<Integer> renderHintList = new Vector<Integer>();
    Vector<Color> colorV = new Vector<Color>();
    int[] selectedIndices = getJList1().getSelectedIndices();
    for (int ii = 0; ii < selectedIndices.length; ii++) {
        int selectedIndex = selectedIndices[ii];
        DataReference dataReference = (DataReference) getmultisourcePlotListModel().getElementAt(selectedIndex);
        DataSource dataSource = dataReference.getDataSource();
        // instanceof DataSource.DataSourceReferenceData ? refDataLabelPrefix : modelDataLabelPrefix;
        String prefix = dataSource.getName() + ": ";
        String[] columnNames = dataSource.getColumnNames();
        int timeIndex = dataSource.getTimeColumnIndex();
        if (timeIndex == -1) {
            throw new RuntimeException("no time variable specified");
        }
        for (int i = 0; i < columnNames.length; i++) {
            if (i == timeIndex) {
                continue;
            }
            if (columnNames[i].equals(dataReference.getIdentifier())) {
                double[] independentValues = dataSource.getColumnData(timeIndex);
                double[] dependentValues = dataSource.getColumnData(i);
                PlotData plotData = new PlotData(independentValues, dependentValues);
                plotDataList.add(plotData);
                int unsortedSelecteIndex = (getmultisourcePlotListModel().getSortedDataReferences() == null ? selectedIndex : getmultisourcePlotListModel().getSortedDataReferences().get(selectedIndex).unsortedIndex);
                colorV.add(autoContrastColors[unsortedSelecteIndex]);
                nameList.add(prefix + columnNames[i]);
                renderHintList.add(dataSource.getRenderHints());
                break;
            }
        }
    }
    String[] labels = { "", "t", "" };
    String[] names = (String[]) BeanUtils.getArray(nameList, String.class);
    PlotData[] plotDatas = (PlotData[]) BeanUtils.getArray(plotDataList, PlotData.class);
    boolean[] visibleFlags = new boolean[plotDatas.length];
    for (int i = 0; i < visibleFlags.length; i++) {
        visibleFlags[i] = true;
    }
    int[] renderHints = new int[plotDatas.length];
    for (int i = 0; i < renderHints.length; i++) {
        renderHints[i] = ((Integer) renderHintList.elementAt(i)).intValue();
    }
    Plot2D plot2D = new Plot2D(null, null, names, plotDatas, labels, visibleFlags, renderHints);
    Color[] colorArr = colorV.toArray(new Color[0]);
    // if(colorV.size() == plot2D.getNumberOfPlots()){
    // colorArr = colorV.toArray(new Color[0]);
    // }
    getplotPane().setPlot2D(plot2D, colorArr);
    return;
}
Also used : PlotData(cbit.plot.PlotData) Color(java.awt.Color) DataSource(cbit.vcell.modelopt.DataSource) Plot2D(cbit.plot.Plot2D) Vector(java.util.Vector) DataReference(cbit.vcell.modelopt.DataReference)

Aggregations

DataReference (cbit.vcell.modelopt.DataReference)3 DataSource (cbit.vcell.modelopt.DataSource)3 Plot2D (cbit.plot.Plot2D)1 PlotData (cbit.plot.PlotData)1 SortDataReferenceHelper (cbit.vcell.modelopt.gui.MultisourcePlotListModel.SortDataReferenceHelper)1 Color (java.awt.Color)1 Component (java.awt.Component)1 Vector (java.util.Vector)1 DefaultListCellRenderer (javax.swing.DefaultListCellRenderer)1 JLabel (javax.swing.JLabel)1