Search in sources :

Example 21 with Observable

use of java.util.Observable in project clusterMaker2 by RBVI.

the class DendroView 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() {
    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);
    hintpanel = new MessagePanel("Usage Hints");
    statuspanel = new MessagePanel("View Status");
    DoubleArrayDrawer dArrayDrawer = new DoubleArrayDrawer();
    dArrayDrawer.setColorExtractor(colorExtractor);
    arrayDrawer = dArrayDrawer;
    ((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());
    globalview.setArrayDrawer(arrayDrawer);
    arraynameview = new ArrayNameView(getDataModel().getArrayHeaderInfo());
    arraynameview.setDataModel(getDataModel());
    leftTreeDrawer = new LeftTreeDrawer();
    gtrview = new GTRView();
    gtrview.setMap(globalYmap);
    gtrview.setLeftTreeDrawer(leftTreeDrawer);
    gtrview.getHeaderSummary().setIncluded(new int[] { 0, 3 });
    invertedTreeDrawer = new InvertedTreeDrawer();
    atrview = new ATRView();
    atrview.setMap(globalXmap);
    atrview.setInvertedTreeDrawer(invertedTreeDrawer);
    atrview.getHeaderSummary().setIncluded(new int[] { 0, 3 });
    atrzview = new ATRZoomView();
    atrzview.setZoomMap(getZoomXmap());
    atrzview.setHeaderSummary(atrview.getHeaderSummary());
    atrzview.setInvertedTreeDrawer(invertedTreeDrawer);
    zoomview = new ZoomView();
    zoomview.setYMap(getZoomYmap());
    zoomview.setXMap(getZoomXmap());
    zoomview.setArrayDrawer(arrayDrawer);
    arraynameview.setMapping(getZoomXmap());
    textview = new TextViewManager(getDataModel().getGeneHeaderInfo());
    textview.setMap(getZoomYmap());
    doDoubleLayout();
    // reset persistent popups
    settingsFrame = null;
    // urls
    colorExtractor.bindConfig(getFirst("ColorExtractor"));
    // set data first to avoid adding auto-genereated contrast to documentConfig.
    dArrayDrawer.setDataMatrix(getDataModel().getDataMatrix());
    dArrayDrawer.bindConfig(getFirst("ArrayDrawer"));
    // this is here because my only subclass shares this code.
    bindTrees();
    zoomview.setHeaders(getDataModel().getGeneHeaderInfo(), getDataModel().getArrayHeaderInfo());
    globalXmap.bindConfig(getFirst("GlobalXMap"));
    globalYmap.bindConfig(getFirst("GlobalYMap"));
    getZoomXmap().bindConfig(getFirst("ZoomXMap"));
    getZoomYmap().bindConfig(getFirst("ZoomYMap"));
    textview.bindConfig(getFirst("TextView"));
    arraynameview.bindConfig(getFirst("ArrayNameView"));
    HeaderSummary atrSummary = atrview.getHeaderSummary();
    atrzview.setHeaderSummary(atrSummary);
    atrSummary.bindConfig(getFirst("AtrSummary"));
    gtrview.getHeaderSummary().bindConfig(getFirst("GtrSummary"));
    // perhaps I could remember this stuff in the MapContainer...
    globalXmap.setIndexRange(0, dataModel.getDataMatrix().getNumCol() - 1);
    globalYmap.setIndexRange(0, dataModel.getDataMatrix().getNumRow() - 1);
    getZoomXmap().setIndexRange(-1, -1);
    getZoomYmap().setIndexRange(-1, -1);
    globalXmap.notifyObservers();
    globalYmap.notifyObservers();
    getZoomXmap().notifyObservers();
    getZoomYmap().notifyObservers();
}
Also used : Observable(java.util.Observable) HeaderSummary(edu.ucsf.rbvi.clusterMaker2.internal.treeview.HeaderSummary) MessagePanel(edu.ucsf.rbvi.clusterMaker2.internal.treeview.MessagePanel)

Example 22 with Observable

use of java.util.Observable in project j2objc by google.

the class ObservableTest method test_addObserverLjava_util_Observer.

/**
 * java.util.Observable#addObserver(java.util.Observer)
 */
public void test_addObserverLjava_util_Observer() {
    // Test for method void
    // java.util.Observable.addObserver(java.util.Observer)
    TestObserver test = new TestObserver();
    observable.addObserver(test);
    assertEquals("Failed to add observer", 1, observable.countObservers());
    observable.addObserver(test);
    assertEquals("Duplicate observer", 1, observable.countObservers());
    Observable o = new Observable();
    try {
        o.addObserver(null);
        fail("Expected adding a null observer to throw a NPE.");
    } catch (NullPointerException ex) {
    // expected;
    } catch (Throwable ex) {
        fail("Did not expect adding a new observer to throw a " + ex.getClass().getName());
    }
}
Also used : Observable(java.util.Observable)

Example 23 with Observable

use of java.util.Observable in project j2objc by google.

the class ObservableTest method test_Constructor.

/**
 * java.util.Observable#Observable()
 */
public void test_Constructor() {
    // Test for method java.util.Observable()
    try {
        Observable ov = new Observable();
        assertTrue("Wrong initial values.", !ov.hasChanged());
        assertEquals("Wrong initial values.", 0, ov.countObservers());
    } catch (Exception e) {
        fail("Exception during test : " + e.getMessage());
    }
}
Also used : Observable(java.util.Observable)

Example 24 with Observable

use of java.util.Observable in project druid by alibaba.

the class ZookeeperNodeListenerTest method testRemoveOneNode.

@Test
public void testRemoveOneNode() throws Exception {
    ZookeeperNodeRegister register = registerNodeAndReturnRegister();
    // Wait for the Node to be created.
    Thread.sleep(2000);
    final CountDownLatch addCDL = new CountDownLatch(1);
    final CountDownLatch removeCDL = new CountDownLatch(1);
    ZookeeperNodeListener listener = new ZookeeperNodeListener();
    listener.setZkConnectString(server.getConnectString());
    listener.setPath(PATH);
    listener.setUrlTemplate("jdbc:mysql://${host}:${port}/foo");
    listener.setPrefix("foo");
    listener.setObserver(new Observer() {

        @Override
        public void update(Observable o, Object arg) {
            NodeEvent[] events = (NodeEvent[]) arg;
            assertEquals(1, events.length);
            NodeEvent event = events[0];
            LOG.info("NodeEvent received: " + event);
            if (NodeEventTypeEnum.DELETE == event.getType()) {
                assertEquals("sa", event.getUsername());
                assertEquals("", event.getPassword());
                assertEquals("foo.test-foo", event.getNodeName());
                assertEquals("jdbc:mysql://127.0.0.1:1234/foo", event.getUrl());
                removeCDL.countDown();
            } else {
                addCDL.countDown();
            }
        }
    });
    listener.init();
    listener.update();
    addCDL.await(10, TimeUnit.SECONDS);
    Properties properties = listener.getProperties();
    assertEquals(6, properties.size());
    register.destroy();
    removeCDL.await(10, TimeUnit.SECONDS);
    assertTrue(properties.isEmpty());
    listener.destroy();
}
Also used : Observer(java.util.Observer) CountDownLatch(java.util.concurrent.CountDownLatch) Properties(java.util.Properties) Observable(java.util.Observable) Test(org.junit.Test)

Example 25 with Observable

use of java.util.Observable in project osumer by mob41.

the class Queue method start.

public void start() {
    runBeforeActions();
    setStartTime(System.nanoTime());
    downloader.download();
    // downloader.deleteObservers();
    downloader.addObserver(new Observer() {

        @Override
        public void update(Observable arg0, Object arg1) {
            if (downloader.getStatus() == Downloader.COMPLETED) {
                runAfterActions();
            }
        }
    });
}
Also used : Observer(java.util.Observer) Observable(java.util.Observable)

Aggregations

Observable (java.util.Observable)52 Observer (java.util.Observer)30 Test (org.junit.Test)8 ContentQueryMap (android.content.ContentQueryMap)6 ContentResolver (android.content.ContentResolver)6 ContentValues (android.content.ContentValues)6 Cursor (android.database.Cursor)6 Handler (android.os.Handler)6 MediumTest (android.test.suitebuilder.annotation.MediumTest)6 LinkedList (java.util.LinkedList)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 MessagePanel (edu.ucsf.rbvi.clusterMaker2.internal.treeview.MessagePanel)2 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)2 IJobChangeListener (org.eclipse.core.runtime.jobs.IJobChangeListener)2 Job (org.eclipse.core.runtime.jobs.Job)2 KeyStoreAlias (org.jcryptool.crypto.keystore.backend.KeyStoreAlias)2 WithDumpException (com.github.mob41.osumer.debug.WithDumpException)1 OsuDownloader (com.github.mob41.osumer.io.OsuDownloader)1