Search in sources :

Example 1 with DataMatrix

use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.DataMatrix in project clusterMaker2 by RBVI.

the class KnnDendroView method setupViews.

/**
 *  This method should be called only during initial setup of the modelview
 *
 *  It sets up the views and binds them all to config nodes.
 */
protected void setupViews() {
    DataModel knnModel = getDataModel();
    hintpanel = new MessagePanel("Usage Hints");
    statuspanel = new MessagePanel("View Status");
    colorPresets = new ColorPresets(root);
    cpresetEditor = new ColorPresetEditor(colorPresets);
    ColorExtractor colorExtractor = new ColorExtractor();
    colorExtractor.setDefaultColorSet(colorPresets.getDefaultColorSet());
    colorExtractor.bindConfig(root);
    colorExtractor.setMissing(DataModel.NODATA, DataModel.EMPTY);
    KnnArrayDrawer kArrayDrawer = new KnnArrayDrawer();
    kArrayDrawer.setColorExtractor(colorExtractor);
    arrayDrawer = kArrayDrawer;
    // XXX shouldn't need to observer, should be immuable?
    ((Observable) getDataModel()).addObserver(arrayDrawer);
    globalview = new GlobalView();
    // scrollbars, mostly used by maps
    globalXscrollbar = new JScrollBar(JScrollBar.HORIZONTAL, 0, 1, 0, 1);
    globalYscrollbar = new JScrollBar(JScrollBar.VERTICAL, 0, 1, 0, 1);
    zoomXscrollbar = new JScrollBar(JScrollBar.HORIZONTAL, 0, 1, 0, 1);
    zoomYscrollbar = new JScrollBar(JScrollBar.VERTICAL, 0, 1, 0, 1);
    zoomXmap = new MapContainer();
    zoomXmap.setDefaultScale(12.0);
    zoomXmap.setScrollbar(zoomXscrollbar);
    zoomYmap = new MapContainer();
    zoomYmap.setDefaultScale(12.0);
    zoomYmap.setScrollbar(zoomYscrollbar);
    // globalmaps tell globalview, atrview, and gtrview
    // where to draw each data point.
    // the scrollbars "scroll" by communicating with the maps.
    globalXmap = new MapContainer();
    globalXmap.setDefaultScale(2.0);
    globalXmap.setScrollbar(globalXscrollbar);
    globalYmap = new MapContainer();
    globalYmap.setDefaultScale(2.0);
    globalYmap.setScrollbar(globalYscrollbar);
    globalview.setXMap(globalXmap);
    globalview.setYMap(globalYmap);
    globalview.setZoomYMap(getZoomYmap());
    globalview.setZoomXMap(getZoomXmap());
    arraynameview = new ArrayNameView(getDataModel().getArrayHeaderInfo());
    leftTreeDrawer = new LeftTreeDrawer();
    gtrview = new GTRView();
    gtrview.setMap(globalYmap);
    gtrview.setLeftTreeDrawer(leftTreeDrawer);
    invertedTreeDrawer = new InvertedTreeDrawer();
    atrview = new ATRView();
    atrview.setMap(globalXmap);
    atrview.setInvertedTreeDrawer(invertedTreeDrawer);
    atrzview = new ATRZoomView();
    atrzview.setZoomMap(getZoomXmap());
    atrzview.setInvertedTreeDrawer(invertedTreeDrawer);
    zoomview = new ZoomView();
    zoomview.setYMap(getZoomYmap());
    zoomview.setXMap(getZoomXmap());
    zoomview.setArrayDrawer(arrayDrawer);
    globalview.setArrayDrawer(arrayDrawer);
    arraynameview.setMapping(getZoomXmap());
    textview = new TextViewManager(getDataModel().getGeneHeaderInfo());
    textview.setMap(getZoomYmap());
    doDoubleLayout();
    // reset persistent popups
    settingsFrame = null;
    // color extractor
    colorExtractor.bindConfig(getFirst("ColorExtractor"));
    // set data first to avoid adding auto-genereated contrast to documentConfig.
    kArrayDrawer.setDataMatrix(knnModel.getDataMatrix());
    kArrayDrawer.bindConfig(getFirst("ArrayDrawer"));
    // responsible for adding and removing components...
    bindTrees();
    globalXmap.bindConfig(getFirst("GlobalXMap"));
    globalYmap.bindConfig(getFirst("GlobalYMap"));
    getZoomXmap().bindConfig(getFirst("ZoomXMap"));
    getZoomYmap().bindConfig(getFirst("ZoomYMap"));
    textview.bindConfig(getFirst("TextViewParent"));
    arraynameview.bindConfig(getFirst("ArrayNameView"));
    // perhaps I could remember this stuff in the MapContainer...
    DataMatrix dataMatrix = getDataModel().getDataMatrix();
    globalXmap.setIndexRange(0, dataMatrix.getNumCol() - 1);
    globalYmap.setIndexRange(0, dataMatrix.getNumRow() - 1);
    getZoomXmap().setIndexRange(-1, -1);
    getZoomYmap().setIndexRange(-1, -1);
    globalXmap.notifyObservers();
    globalYmap.notifyObservers();
    getZoomXmap().notifyObservers();
    getZoomYmap().notifyObservers();
}
Also used : DataMatrix(edu.ucsf.rbvi.clusterMaker2.internal.treeview.DataMatrix) Observable(java.util.Observable) JScrollBar(javax.swing.JScrollBar) DataModel(edu.ucsf.rbvi.clusterMaker2.internal.treeview.DataModel) MessagePanel(edu.ucsf.rbvi.clusterMaker2.internal.treeview.MessagePanel)

Example 2 with DataMatrix

use of edu.ucsf.rbvi.clusterMaker2.internal.treeview.DataMatrix in project clusterMaker2 by RBVI.

the class TVModel method reorderArrays.

/**
 * Reorders all the arrays in the new ordering.
 * @param ordering the new ordering of arrays, must have size equal to number of arrays
 */
public void reorderArrays(int[] ordering) {
    if (ordering == null || // make sure input to function makes sense
    ordering.length != dataMatrix.getNumUnappendedCol()) {
        return;
    }
    DataMatrix data = getDataMatrix();
    for (int j = 0; j < data.getNumRow(); j++) {
        double[] temp = new double[data.getNumUnappendedCol()];
        for (int i = 0; i < ordering.length; i++) {
            temp[i] = data.getValue(ordering[i], j);
        }
        for (int i = 0; i < ordering.length; i++) {
            data.setValue(temp[i], i, j);
        }
    }
    String[][] aHeaders = arrayHeaderInfo.headerArray;
    String[][] temp2 = new String[aHeaders.length][];
    for (int i = 0; i < aHeaders.length; i++) {
        if (i < ordering.length) {
            temp2[i] = aHeaders[ordering[i]];
        } else {
            temp2[i] = aHeaders[i];
        }
    }
    setArrayHeaders(temp2);
    hashAIDs();
    setChanged();
}
Also used : DataMatrix(edu.ucsf.rbvi.clusterMaker2.internal.treeview.DataMatrix)

Aggregations

DataMatrix (edu.ucsf.rbvi.clusterMaker2.internal.treeview.DataMatrix)2 DataModel (edu.ucsf.rbvi.clusterMaker2.internal.treeview.DataModel)1 MessagePanel (edu.ucsf.rbvi.clusterMaker2.internal.treeview.MessagePanel)1 Observable (java.util.Observable)1 JScrollBar (javax.swing.JScrollBar)1