elemental.client.Browser Java Examples

The following examples show how to use elemental.client.Browser. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GwtBasicElementBinderTest.java    From flow with Apache License 2.0 6 votes vote down vote up
public void testRemoveChildPosition() {
    Binder.bind(node, element);

    StateNode childNode = createChildNode("child");
    children.add(0, childNode);
    Reactive.flush();

    Element firstChildElement = element.getFirstElementChild();

    // Add an "unofficial" child to mess with index computations
    Element extraChild = Browser.getDocument().createElement("img");
    element.insertBefore(extraChild, firstChildElement);

    children.splice(0, 1);
    Reactive.flush();

    elemental.dom.NodeList childNodes = element.getChildNodes();

    assertEquals(1, childNodes.length());

    assertSame(extraChild, childNodes.item(0));
    assertNull(firstChildElement.getParentElement());
}
 
Example #2
Source File: RouterLinkHandler.java    From flow with Apache License 2.0 6 votes vote down vote up
private static void handleRouterLinkClick(Event clickEvent, String baseURI,
        String href, Registry registry) {
    clickEvent.preventDefault();

    String location = URIResolver.getBaseRelativeUri(baseURI, href);
    if (location.contains("#")) {
        // make sure fragment event gets fired after response
        new FragmentHandler(Browser.getWindow().getLocation().getHref(),
                href, registry).bind();

        // don't send hash to server
        location = location.split("#", 2)[0];
    }

    JsonObject state = createNavigationEventState(href);

    sendServerNavigationEvent(registry, location, state, true);
}
 
Example #3
Source File: FeatureHandler.java    From ThinkMap with Apache License 2.0 6 votes vote down vote up
private boolean handleMissing() {
    if (hasFailed) {
        DivElement el = Browser.getDocument().createDivElement();
        el.getClassList().add("fade-background");
        Browser.getDocument().getBody().appendChild(el);

        DivElement message = Browser.getDocument().createDivElement();
        message.getClassList().add("center-message");
        Element title = Browser.getDocument().createElement("h1");
        title.setInnerHTML("Failed to start ThinkMap");
        message.appendChild(title);
        for (String feature : missingFeatures) {
            Element header = Browser.getDocument().createElement("h2");
            header.setInnerHTML(featureTitles.get(feature));
            message.appendChild(header);
            ParagraphElement body = Browser.getDocument().createParagraphElement();
            body.setInnerHTML(featureErrors.get(feature));
            message.appendChild(body);
        }
        Browser.getDocument().getBody().appendChild(message);
    }
    return !hasFailed;
}
 
Example #4
Source File: MapViewer.java    From ThinkMap with Apache License 2.0 6 votes vote down vote up
/**
 * Entry point to the program
 */
public void onModuleLoad() {
    JavascriptLib.init();
    // Feature detection
    if (!featureHandler.detect()) return;
    // Atlas to look up position of textures
    xhr = Browser.getWindow().newXMLHttpRequest();
    xhr.open("GET", "http://" + getConfigAdddress() + "/resources/blocks.json", true);
    xhr.setOnload(this);
    xhr.send();

    Platform.runRepeated(new Runnable() {
        @Override
        public void run() {
            if (connection == null) return;
            if (Duration.currentTimeMillis() - lastKeepAlive > 1000) {
                lastKeepAlive = Duration.currentTimeMillis();
                connection.send(new KeepAlive());
            }
        }
    }, 1000);
}
 
Example #5
Source File: LoadMainApp.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void execute() {
    String initialToken = History.getToken();
   /* if (!initialToken.isEmpty() && !isBlackListed(initialToken)) {
        List<PlaceRequest> hierarchy = formatter.toPlaceRequestHierarchy(initialToken);
        final PlaceRequest placeRequest = hierarchy.get(hierarchy.size() - 1);

        Scheduler.get().scheduleDeferred(() -> placeManager.revealPlace(placeRequest, true));
        bootstrapContext.setInitialPlace(placeRequest.getNameToken());
    } else {
        placeManager.revealDefaultPlace();
    }*/

    String title = productConfig.getProfile() == PRODUCT ? "JBoss EAP" : "WildFly";
    Browser.getDocument().setTitle(title + " Management");
    // TODO (hbraun): disabled until we now how this should work on a finder access (relative url's)
    placeManager.revealDefaultPlace();
}
 
Example #6
Source File: Connection.java    From ThinkMap with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a connect to the plugin at the address. Calls the callback once the connection succeeds.
 *
 * @param address
 *         The address to connect to, may include the port
 * @param handler
 *         The handler to handle received events
 * @param callback
 *         The Runnable to call once the connection is completed
 */
public Connection(String address, ServerPacketHandler handler, final Runnable callback) {
    this.address = address;
    this.handler = handler;
    webSocket = Browser.getWindow().newWebSocket("ws://" + address + "/server/ws");
    // Work in binary instead of strings
    webSocket.setBinaryType("arraybuffer");
    webSocket.setOnopen(new EventListener() {
        @Override
        public void handleEvent(Event evt) {
            System.out.println("Connected to server");
            send(new InitConnection());
            if (callback != null) callback.run();
        }
    });
    webSocket.setOnmessage(this);
}
 
Example #7
Source File: CubaUIConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
protected void updateBrowserHistory(UIDL uidl) {
    String lastHistoryOp = uidl.getStringAttribute(CubaUIConstants.LAST_HISTORY_OP);

    History history = Browser.getWindow().getHistory();
    String pageTitle = getState().pageState.title;

    String replace = uidl.getStringAttribute(UIConstants.ATTRIBUTE_REPLACE_STATE);
    String push = uidl.getStringAttribute(UIConstants.ATTRIBUTE_PUSH_STATE);

    if (CubaUIConstants.HISTORY_PUSH_OP.equals(lastHistoryOp)) {
        if (uidl.hasAttribute(UIConstants.ATTRIBUTE_REPLACE_STATE)) {
            history.replaceState(null, pageTitle, replace);
        }
        if (uidl.hasAttribute(UIConstants.ATTRIBUTE_PUSH_STATE)) {
            history.pushState(null, pageTitle, push);
        }
    } else {
        if (uidl.hasAttribute(UIConstants.ATTRIBUTE_PUSH_STATE)) {
            history.pushState(null, pageTitle, push);
        }
        if (uidl.hasAttribute(UIConstants.ATTRIBUTE_REPLACE_STATE)) {
            history.replaceState(null, pageTitle, replace);
        }
    }
}
 
Example #8
Source File: SystemErrorHandler.java    From flow with Apache License 2.0 6 votes vote down vote up
/**
 * Shows an error notification for an error which is unrecoverable, using
 * the given parameters.
 *
 * @param caption
 *            the caption of the message
 * @param message
 *            the message body
 * @param details
 *            message details or {@code null} if there are no details
 * @param url
 *            a URL to redirect to when the user clicks the message or
 *            {@code null} to refresh on click
 * @param querySelector
 *            query selector to find the element under which the error will
 *            be added . If element is not found or the selector is
 *            {@code null}, body will be used
 */
public void handleUnrecoverableError(String caption, String message,
        String details, String url, String querySelector) {
    if (caption == null && message == null && details == null) {
        if (!isWebComponentMode()) {
            WidgetUtil.redirect(url);
        }
        return;
    }

    Element systemErrorContainer = handleError(caption, message, details,
            querySelector);
    if (!isWebComponentMode()) {
        systemErrorContainer.addEventListener("click",
                e -> WidgetUtil.redirect(url), false);
        Browser.getDocument().addEventListener(Event.KEYDOWN, e -> {
            int keyCode = ((KeyboardEvent) e).getKeyCode();
            if (keyCode == KeyCode.ESC) {
                e.preventDefault();
                WidgetUtil.redirect(url);
            }
        }, false);
    }
}
 
Example #9
Source File: GwtApplicationConnectionTest.java    From flow with Apache License 2.0 6 votes vote down vote up
public void test_should_not_addNavigationEvents_forWebComponents() {
    mockFlowBootstrapScript(true);

    JsonObject windowEvents = Json.createObject();
    addEventsObserver(Browser.getWindow(), windowEvents);

    JsonObject bodyEvents = Json.createObject();
    addEventsObserver(Browser.getDocument().getBody(), bodyEvents);

    new Bootstrapper().onModuleLoad();

    delayTestFinish(500);
    new Timer() {
        @Override
        public void run() {
            assertFalse(windowEvents.hasKey("popstate"));
            assertFalse(bodyEvents.hasKey("click"));
            finishTest();
        }
    }.schedule(100);
}
 
Example #10
Source File: GwtApplicationConnectionTest.java    From flow with Apache License 2.0 6 votes vote down vote up
public void test_should_addNavigationEvents_byDefault() {
    mockFlowBootstrapScript(false);

    JsonObject windowEvents = Json.createObject();
    addEventsObserver(Browser.getWindow(), windowEvents);

    JsonObject bodyEvents = Json.createObject();
    addEventsObserver(Browser.getDocument().getBody(), bodyEvents);

    new Bootstrapper().onModuleLoad();

    delayTestFinish(500);
    new Timer() {
        @Override
        public void run() {
            assertTrue(windowEvents.hasKey("popstate"));
            assertTrue(bodyEvents.hasKey("click"));
            finishTest();
        }
    }.schedule(100);
}
 
Example #11
Source File: ScrollPositionHandler.java    From flow with Apache License 2.0 6 votes vote down vote up
private void onBeforeUnload(Event event) {
    captureCurrentScrollPositions();

    JsonObject stateObject = createStateObjectWithHistoryIndexAndToken();

    JsonObject sessionStorageObject = Json.createObject();
    sessionStorageObject.put(X_POSITIONS,
            convertArrayToJsonArray(xPositions));
    sessionStorageObject.put(Y_POSITIONS,
            convertArrayToJsonArray(yPositions));

    Browser.getWindow().getHistory().replaceState(stateObject, "",
            Browser.getWindow().getLocation().getHref());
    try {
        Browser.getWindow().getSessionStorage().setItem(
                createSessionStorageKey(historyResetToken),
                sessionStorageObject.toJson());
    } catch (JavaScriptException e) {
        Console.error("Failed to get session storage: " + e.getMessage());
    }
}
 
Example #12
Source File: GwtExecuteJavaScriptElementUtilsTest.java    From flow with Apache License 2.0 6 votes vote down vote up
@Override
protected void gwtSetUp() throws Exception {
    super.gwtSetUp();
    initPolymer();

    map = new ExistingElementMap();

    Registry registry = new Registry() {
        {
            set(ExistingElementMap.class, map);
        }
    };

    tree = new ExistingElementStateTree(registry);

    node = new StateNode(0, tree);
    element = Browser.getDocument().createElement("div");
    node.setDomNode(element);
}
 
Example #13
Source File: GwtBasicElementBinderTest.java    From flow with Apache License 2.0 6 votes vote down vote up
public void testEventFiredWithNoFilters() {
    Binder.bind(node, element);

    String constantPoolKey = "expressionsKey";

    JsonObject expressions = Json.createObject();
    // Expression is not used as a filter
    expressions.put("false", false);

    addToConstantPool(constantPoolKey, expressions);

    node.getMap(NodeFeatures.ELEMENT_LISTENERS).getProperty("click")
            .setValue(constantPoolKey);
    Reactive.flush();
    Browser.getDocument().getBody().appendChild(element);

    element.click();

    assertEquals(1, tree.collectedNodes.length());
}
 
Example #14
Source File: ResourceLoader.java    From flow with Apache License 2.0 6 votes vote down vote up
private void loadScript(String scriptUrl,
        ResourceLoadListener resourceLoadListener, boolean async,
        boolean defer, String type) {
    final String url = WidgetUtil.getAbsoluteUrl(scriptUrl);
    ResourceLoadEvent event = new ResourceLoadEvent(this, url);
    if (loadedResources.has(url)) {
        if (resourceLoadListener != null) {
            resourceLoadListener.onLoad(event);
        }
        return;
    }

    if (addListener(url, resourceLoadListener, loadListeners)) {
        ScriptElement scriptTag = Browser.getDocument()
                .createScriptElement();
        scriptTag.setSrc(url);
        scriptTag.setType(type);
        scriptTag.setAsync(async);
        scriptTag.setDefer(defer);

        addOnloadHandler(scriptTag, new SimpleLoadListener(), event);
        getHead().appendChild(scriptTag);
    }
}
 
Example #15
Source File: ResourceLoader.java    From flow with Apache License 2.0 6 votes vote down vote up
/**
 * Populates the resource loader with the scripts currently added to the
 * page.
 */
private void initLoadedResourcesFromDom() {
    Document document = Browser.getDocument();

    // detect already loaded scripts and stylesheets
    NodeList scripts = document.getElementsByTagName("script");
    for (int i = 0; i < scripts.getLength(); i++) {
        ScriptElement element = (ScriptElement) scripts.item(i);
        String src = element.getSrc();
        if (src != null && src.length() != 0) {
            loadedResources.add(src);
        }
    }

    NodeList links = document.getElementsByTagName("link");
    for (int i = 0; i < links.getLength(); i++) {
        LinkElement linkElement = (LinkElement) links.item(i);
        String rel = linkElement.getRel();
        String href = linkElement.getHref();
        if (("stylesheet".equalsIgnoreCase(rel)
                || "import".equalsIgnoreCase(rel)) && href != null
                && href.length() != 0) {
            loadedResources.add(href);
        }
    }
}
 
Example #16
Source File: GwtMultipleBindingTest.java    From flow with Apache License 2.0 6 votes vote down vote up
@Override
protected void gwtSetUp() throws Exception {
    super.gwtSetUp();
    Reactive.reset();

    registry = new Registry() {
        {
            set(ConstantPool.class, new ConstantPool());
            set(ExistingElementMap.class, new ExistingElementMap());
        }
    };

    tree = new StateTree(registry) {
        @Override
        public void sendTemplateEventToServer(StateNode node,
                String methodName, JsArray<?> argValues, int promiseId) {
        }
    };

    node = new TestStateNode(tree);
    // populate "element data" feature to be able to bind node as a plain
    // element
    node.getMap(NodeFeatures.ELEMENT_DATA);
    element = Browser.getDocument().createElement("div");

}
 
Example #17
Source File: ScrollPositionHandler.java    From flow with Apache License 2.0 6 votes vote down vote up
/**
 * Store scroll positions when there has been navigation triggered by a
 * click on a link element and no server round-trip is needed. It means
 * navigating within the same page.
 * <p>
 * If href for the page navigated into contains a hash (even just #), then
 * the browser will fire a pop state event afterwards.
 *
 * @param newHref
 *            the href of the clicked link
 */
public void beforeClientNavigation(String newHref) {
    captureCurrentScrollPositions();

    Browser.getWindow().getHistory().replaceState(
            createStateObjectWithHistoryIndexAndToken(), "",
            Browser.getWindow().getLocation().getHref());

    // move to page top only if there is no fragment so scroll position
    // doesn't bounce around
    if (!newHref.contains("#")) {
        resetScroll();
    }

    currentHistoryIndex++;

    // remove old stored scroll positions
    xPositions.splice(currentHistoryIndex,
            xPositions.length() - currentHistoryIndex);
    yPositions.splice(currentHistoryIndex,
            yPositions.length() - currentHistoryIndex);
}
 
Example #18
Source File: GwtMultipleBindingTest.java    From flow with Apache License 2.0 6 votes vote down vote up
public void testBindModelPropertiesDoubleBind() {
    String name = "custom-div";
    Element element = Browser.getDocument().createElement(name);
    WidgetUtil.setJsProperty(element, "localName", name);
    initPolymer(element);

    NativeFunction function = NativeFunction.create("");
    WidgetUtil.setJsProperty(element, "set", function);

    Binder.bind(node, element);

    node.getMap(NodeFeatures.ELEMENT_PROPERTIES).getProperty("foo")
            .setValue("bar");

    Reactive.flush();

    node.setBound();
    Binder.bind(node, element);
}
 
Example #19
Source File: GwtStateTreeTest.java    From flow with Apache License 2.0 6 votes vote down vote up
public void testPrepareForResync_rejectsPendingPromise() {
    // given
    StateNode root = tree.getRootNode();
    StateNode child = new StateNode(2, tree);
    child.setParent(root);
    tree.registerNode(child);
    root.getList(NodeFeatures.VIRTUAL_CHILDREN).add(0,child);

    final DivElement element = Browser.getDocument().createDivElement();
    child.setDomNode(element);
    ServerEventObject.get(element);
    createMockPromise(element);

    // when
    tree.prepareForResync();

    // then
    assertFalse(getMockPromiseResult(element));
}
 
Example #20
Source File: GwtBasicElementBinderTest.java    From flow with Apache License 2.0 5 votes vote down vote up
public void testAttachExistingElement() {
    Binder.bind(node, element);

    StateNode childNode = createChildNode("child");

    String tag = (String) childNode.getMap(NodeFeatures.ELEMENT_DATA)
            .getProperty(NodeProperties.TAG).getValue();

    ExistingElementMap existingElementMap = node.getTree().getRegistry()
            .getExistingElementMap();

    // create and add an existing element
    Element span = Browser.getDocument().createElement(tag);
    element.appendChild(span);

    existingElementMap.add(childNode.getId(), span);

    children.add(0, childNode);

    Reactive.flush();

    // nothing has changed: no new child
    assertEquals("No new child should appear in the element", 1,
            element.getChildElementCount());

    Element childElement = element.getFirstElementChild();

    assertEquals(tag,
            childElement.getTagName().toLowerCase(Locale.ENGLISH));
    assertSame(span, childElement);
    assertEquals("child", childElement.getId());
    assertNull(existingElementMap.getElement(childNode.getId()));
}
 
Example #21
Source File: GwtBasicElementBinderTest.java    From flow with Apache License 2.0 5 votes vote down vote up
public void testReadyCallback_deferredPolymerElement_readyIsCalledAndNotified() {
    element = Browser.getDocument().createElement("x-my");
    WidgetUtil.setJsProperty(element, "localName", "x-my");

    PolymerUtils.addReadyListener(element,
            () -> WidgetUtil.setJsProperty(element, "baz", "foobar"));

    assertDeferredPolymerElement_originalReadyIsCalled(element);

    assertEquals("foobar", WidgetUtil.getJsProperty(element, "baz"));
}
 
Example #22
Source File: GwtBasicElementBinderTest.java    From flow with Apache License 2.0 5 votes vote down vote up
private Element createAndAppendElementToShadowRoot(Element shadowRoot,
        String id, String tagName) {
    Element childShadowRootElement = Browser.getDocument()
            .createElement(tagName);
    childShadowRootElement.setId(id);
    shadowRoot.appendChild(childShadowRootElement);

    if (id != null) {
        JsonObject obj = Json.createObject();
        WidgetUtil.setJsProperty(obj, id.toString(),
                childShadowRootElement);
        WidgetUtil.setJsProperty(element, "$", obj);
    }
    return childShadowRootElement;
}
 
Example #23
Source File: GwtNativeFunctionTest.java    From flow with Apache License 2.0 5 votes vote down vote up
public void testCall() {
    NativeFunction adder = new NativeFunction("param1", "param2",
            "return this + param1 + param2");

    Object result = adder.call(Browser.getDocument(), " myString ",
            Double.valueOf(42));

    assertEquals("[object HTMLDocument] myString 42", result);
}
 
Example #24
Source File: GwtRouterLinkHandlerTest.java    From flow with Apache License 2.0 5 votes vote down vote up
@Override
protected void gwtSetUp() throws Exception {
    super.gwtSetUp();

    createDummyWindowVaadinFlow();

    invocations = JsCollections.array();

    ServerConnector connector = new ServerConnector(null) {
        @Override
        public void sendNavigationMessage(String location,
                Object stateObject, boolean routerLinkEvent) {
            invocations.push(location);
        }
    };

    UILifecycle lifecycle = new UILifecycle();
    lifecycle.setState(UIState.RUNNING);
    registry = new Registry() {
        {
            set(UILifecycle.class, lifecycle);
            set(ServerConnector.class, connector);
            set(MessageHandler.class, new MessageHandler(this));
            set(RequestResponseTracker.class,
                    new RequestResponseTracker(this));
            set(ScrollPositionHandler.class,
                    new ScrollPositionHandler(this));
        }
    };
    boundElement = Browser.getDocument().createDivElement();
    Browser.getDocument().getBody().appendChild(boundElement);
    RouterLinkHandler.bind(registry, boundElement);
}
 
Example #25
Source File: GwtRouterLinkHandlerTest.java    From flow with Apache License 2.0 5 votes vote down vote up
private Element createTarget(String tag, String href, boolean routerLink) {
    Element target = Browser.getDocument().createElement(tag);
    target.setAttribute("href", href);
    if (routerLink) {
        target.setAttribute(ApplicationConstants.ROUTER_LINK_ATTRIBUTE, "");
    }
    return target;
}
 
Example #26
Source File: ReadPortOffsetOp.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
void execute(final Server server, final String id) {
    ResourceAddress address = new ResourceAddress()
            .add("host", server.getHostName())
            .add("server", server.getName())
            .add("socket-binding-group", "*");
    Operation operation = new Operation.Builder(READ_ATTRIBUTE_OPERATION, address)
            .param(NAME, "port-offset")
            .build();

    dispatcher.execute(new DMRAction(operation), new AsyncCallback<DMRResponse>() {
        @Override
        public void onFailure(final Throwable throwable) {
            feedback("n/a");
        }

        @Override
        public void onSuccess(final DMRResponse dmrResponse) {
            if (dmrResponse.get().isFailure()) {
                feedback("n/a");
            } else {
                List<ModelNode> nodes = dmrResponse.get().get(RESULT).asList();
                if (!nodes.isEmpty() && !nodes.get(0).isFailure() && nodes.get(0).hasDefined(RESULT)) {
                    feedback(nodes.get(0).get(RESULT).asString());
                } else {
                    feedback("n/a");
                }
            }
        }

        private void feedback(final String portOffset) {
            Element element = Browser.getDocument().getElementById(id);
            if (element != null) {
                Scheduler.get().scheduleDeferred(() -> element.setTextContent(portOffset));
            }
        }
    });
}
 
Example #27
Source File: Renderer.java    From ThinkMap with Apache License 2.0 5 votes vote down vote up
@Override
public void onResize() {
    // Fill the window
    canvas.setWidth(Browser.getWindow().getInnerWidth());
    canvas.setHeight(Browser.getWindow().getInnerHeight());

    // Reset the perspective matrix
    perspectiveMatrix.identity();
    perspectiveMatrix.perspective((float) Math.toRadians(80), (float) canvas.getWidth() / canvas.getHeight(), 0.1f, 500f);
    // TODO: toggle update
}
 
Example #28
Source File: PopStateHandler.java    From flow with Apache License 2.0 5 votes vote down vote up
/**
 * Start listening to <code>popstate</code> events and send them to the
 * server.
 * <p>
 * This method should be triggered only once per instance.
 */
public void bind() {
    // track the location and query string (#6107) after the latest response
    // from server
    registry.getRequestResponseTracker().addResponseHandlingEndedHandler(
            event -> {
                pathAfterPreviousResponse = Browser.getWindow()
                        .getLocation().getPathname();
                queryAfterPreviousResponse = Browser.getWindow()
                        .getLocation().getSearch();
            });
    Browser.getWindow().addEventListener("popstate", this::onPopStateEvent);
}
 
Example #29
Source File: VirtualTexture.java    From ThinkMap with Apache License 2.0 5 votes vote down vote up
public VirtualTexture(MapViewer mapViewer, int id) {
    this.mapViewer = mapViewer;
    this.id = id;
    canvas = Browser.getDocument().createCanvasElement();
    canvas.setWidth(TEXTURE_SIZE);
    canvas.setHeight(TEXTURE_SIZE);
    ctx = (CanvasRenderingContext2D) canvas.getContext("2d");

    ctx.setFillStyle("#FFFFFF");
    ctx.fillRect(0, 0, TEXTURE_SIZE, TEXTURE_SIZE);

    Map<String, Texture> textures = mapViewer.getTextures();
    final ArrayList<Texture> tx = new ArrayList<>();
    final ArrayList<Texture> animatedTextures = new ArrayList<>();
    // Find relevant textures
    for (Texture t : textures.values()) {
        if (t.getVirtualY() / TEXTURE_SIZE == id) {
            tx.add(t);
            if (t.getFrameCount() > 1) {
                animatedTextures.add(t);
            }
        }
    }

    this.textures = tx.toArray(new Texture[tx.size()]);
    this.animatedTextures = animatedTextures.toArray(new Texture[animatedTextures.size()]);
    animatedTexturesLastFrame = new int[this.animatedTextures.length];
}
 
Example #30
Source File: WorkerPool.java    From ThinkMap with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a worker pool with a limit of the number of workers created
 *
 * @param mapViewer
 *         The map viewer that owns this pool
 * @param limit
 *         The max number of workers
 */
public WorkerPool(MapViewer mapViewer, int limit) {
    this.mapViewer = mapViewer;
    for (int i = 0; i < limit; i++) {
        workers.add(new PooledWorker(Browser.getWindow().newWorker(
                "./mapviewerworker/mapviewerworker.worker.js"
        ), i));
    }
}