Search in sources :

Example 1 with Control

use of ol.control.Control in project gwt-ol3 by TDesjardins.

the class CollectionTest method testCollection.

public void testCollection() {
    this.injectUrlAndTest(() -> {
        Collection<Control> controls = new Collection<Control>();
        assertNotNull(controls);
        assertTrue(controls.getLength() == 0);
        assertTrue(controls.isEmpty());
        assertNotNull(controls.getArray());
        // Does not work before ol v3.20. because bug in ol3.
        int length = controls.push(new Attribution());
        assertTrue(length == 1);
        assertTrue(controls.getLength() == 1);
        assertFalse(controls.isEmpty());
        assertNotNull(controls.getArray());
        assertTrue(controls.getArray().length == 1);
        Control control = controls.pop();
        assertTrue(control instanceof Attribution);
        assertTrue(controls.getLength() == 0);
        assertTrue(controls.isEmpty());
        Attribution attribution = new Attribution();
        controls.push(attribution);
        assertTrue(controls.contains(attribution));
        assertFalse(controls.contains(new Attribution()));
    });
}
Also used : Control(ol.control.Control) Attribution(ol.control.Attribution)

Example 2 with Control

use of ol.control.Control in project gwt-ol3 by TDesjardins.

the class CollectionTest method testCollectionEvents.

public void testCollectionEvents() {
    this.injectUrlAndTest(() -> {
        Collection<Control> controls = new Collection<Control>();
        assertFalse(this.elementAddedEventFired);
        assertFalse(this.elementRemovedEventFired);
        controls.addElementAddedListener(new EventListener<Collection.Event<Control>>() {

            @Override
            public void onEvent(Event<Control> event) {
                elementAddedEventFired = true;
            }
        });
        controls.addElementRemovedListener(new EventListener<Collection.Event<Control>>() {

            @Override
            public void onEvent(Event<Control> event) {
                elementRemovedEventFired = true;
            }
        });
        controls.push(new Attribution());
        assertTrue(this.elementAddedEventFired);
        assertFalse(this.elementRemovedEventFired);
        controls.removeAt(0);
        assertTrue(this.elementAddedEventFired);
        assertTrue(this.elementRemovedEventFired);
    });
}
Also used : Control(ol.control.Control) Event(ol.Collection.Event) Attribution(ol.control.Attribution)

Example 3 with Control

use of ol.control.Control in project gwt-ol3 by TDesjardins.

the class DemoUtils method createMapboxLogo.

/**
 * Create a MapBox logo.
 *
 * @return MapBox logo
 */
public static Control createMapboxLogo() {
    ControlOptions controlOptions = new ControlOptions();
    LinkElement mapboxLogo = Document.get().createLinkElement();
    mapboxLogo.setHref("https://mapbox.com/about/maps");
    mapboxLogo.setTarget("_blank");
    mapboxLogo.getStyle().setPosition(Position.ABSOLUTE);
    mapboxLogo.getStyle().setLeft(2, Unit.PX);
    mapboxLogo.getStyle().setBottom(5, Unit.PX);
    mapboxLogo.getStyle().setWidth(126, Unit.PX);
    mapboxLogo.getStyle().setHeight(40, Unit.PX);
    mapboxLogo.getStyle().setDisplay(Display.BLOCK);
    mapboxLogo.getStyle().setOverflow(Overflow.HIDDEN);
    mapboxLogo.getStyle().setBackgroundImage("url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIIAAAAoCAMAAAAFWtJHAAAAwFBMVEUAAAAAAAAAAABtbW0AAAAAAAAAAAAAAAAAAAAAAAClpaUAAADp6ekAAAD5+fna2toAAAAMDAzv7+/Nzc0AAAA2Njb8/Pz9/f3T09MAAAAAAAD7+/sAAAArKyuxsbH39/fs7OwbGxuIiIjz8/N8fHyenp7u7u74+PgAAAC8vLxWVlbx8fF1dXXl5eVcXFyUlJTQ0NDFxcVCQkLAwMC4uLj19fXo6OjW1tarq6ve3t77+/vi4uL6+vrKysrNzc3///8w7gSSAAAAP3RSTlMAOQNdPSYBPywKexLLGPCxNEHXnzFL+v2nGwf1IEiE6dBFad9jd9PuLo1V2mDDV3Cjl06SiuXIq4C3973ym6BQMVUPAAAEXElEQVR4Ae2WCVP6OBiH05L0l1IqrVbkKHJ54I0oHn+PfP9vtUle0z/YdhbH2XVnd58ZnRJIeHiPJOx//mH4vQSAN+8FjAhFxgHIaPvJeZ99hxwEElon5iAQbj85Y98g8ODwjEOMAvGFyeE3FEKgodTBqj0BJGN9DhyNd5Ta3ean9QEopfaA+LsKhnEKRExqg4FSP6Og7oEkAjBWnxSCgBX4xF+kcLoPcOBQrSv0e5kH7s1j37jECQieCTPiFGxL5VHw2zQWCeeJiPt6kjRQw0XSkIdVChf67xGa4alS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urw7XEe76ynI4aq+v7lEyt1x5awiFlFLQbHKIpabnM3eJLym4Szzzc/du7SU+zOXv9UNpECH7IoH/gecURPlN9vdQpeD47yhIFNX0U0QgvID9nENm+yxk/xb+AGAjNfRZuk9qAAAAAElFTkSuQmCC)");
    controlOptions.setElement(mapboxLogo);
    return new Control(controlOptions);
}
Also used : ControlOptions(ol.control.ControlOptions) Control(ol.control.Control) LinkElement(com.google.gwt.dom.client.LinkElement)

Aggregations

Control (ol.control.Control)3 Attribution (ol.control.Attribution)2 LinkElement (com.google.gwt.dom.client.LinkElement)1 Event (ol.Collection.Event)1 ControlOptions (ol.control.ControlOptions)1