• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Browser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中elemental.client.Browser的典型用法代码示例。如果您正苦于以下问题:Java Browser类的具体用法?Java Browser怎么用?Java Browser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Browser类属于elemental.client包,在下文中一共展示了Browser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: off

import elemental.client.Browser; //导入依赖的package包/类
/** Turn off Super DevMode for the current IDE GWT app. */
void off() {
  Window window = Browser.getWindow();
  Storage sessionStorage = window.getSessionStorage();

  for (int i = 0; i < sessionStorage.getLength(); i++) {
    String key = sessionStorage.key(i);

    if (key.equals("__gwtDevModeHook:" + IDE_GWT_APP_SHORT_NAME)) {
      sessionStorage.removeItem(key);
      break;
    }
  }

  window.getLocation().reload();
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:GWTDevMode.java


示例2: addMark

import elemental.client.Browser; //导入依赖的package包/类
@Override
public void addMark(final double relativePos, final String style, final int line, final Integer level) {
    changed();
    final DivElement mark = Browser.getDocument().createDivElement();
    mark.setClassName(style);
    mark.getStyle().setPosition(Position.ABSOLUTE);
    mark.getStyle().setTop(Double.toString(relativePos * 100) + "%");
    mark.getStyle().setHeight(MARKER_HEIGHT); // could be proportional to the document size
    mark.getStyle().setMarginTop("0");
    mark.getStyle().setMarginBottom("0");
    mark.getStyle().setWidth("100%");
    mark.getStyle().setLeft("0");
    mark.getStyle().setCursor(Cursor.POINTER);
    if (level != null) {
        mark.getStyle().setZIndex(level);
    }

    mark.getDataset().setAt(DATASET_KEY_LINE, line);

    this.offscreen.appendChild(mark);
}
 
开发者ID:codenvy-legacy,项目名称:plugin-editor-codemirror,代码行数:22,代码来源:MinimapViewImpl.java


示例3: loadChunk

import elemental.client.Browser; //导入依赖的package包/类
/**
 * Triggers an async request to load the chunk. The chunk is forwarded to all workers to be processed before being returned to the client
 *
 * @param x
 *         The chunk x position
 * @param z
 *         The chunk z position
 */
private void loadChunk(final int x, final int z) {
    final String key = chunkKey(x, z);
    if (loadingChunks.contains(key) || isLoaded(x, z)) {
        return;
    }
    final XMLHttpRequest xmlHttpRequest = Browser.getWindow().newXMLHttpRequest();
    xmlHttpRequest.open("POST", "http://" + mapViewer.getConnection().getAddress() + "/server/chunk", true);
    xmlHttpRequest.setResponseType("arraybuffer");
    xmlHttpRequest.setOnreadystatechange(new EventListener() {
        @Override
        public void handleEvent(Event evt) {
            if (xmlHttpRequest.getReadyState() != 4) return;
            if (xmlHttpRequest.getStatus() == 200) {
                // Got the chunk successfully, move on
                // to processing the chunk
                ArrayBuffer data = (ArrayBuffer) xmlHttpRequest.getResponse();
                ViewBuffer dataStream = JavascriptViewBuffer.create(data, false, 0, data.getByteLength());
                if (dataStream.getInt8(0) == 0) {
                    loadingChunks.remove(key);
                    return;
                }
                UByteBuffer sendableData = JavascriptUByteBuffer.create(data, 0, data.getByteLength());
                mapViewer.getWorkerPool().sendMessage(new ChunkLoadMessage(x, z, sendableData), true);
            } else {
                // Request failed (e.g. non-existing chunk)
                // remove from the loadingChunks set so
                // that it may be tried again
                loadingChunks.remove(key);
            }
        }
    });
    xmlHttpRequest.send(key);
}
 
开发者ID:Thinkofname,项目名称:ThinkMap,代码行数:42,代码来源:ClientWorld.java


示例4: handleMissing

import elemental.client.Browser; //导入依赖的package包/类
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;
}
 
开发者ID:Thinkofname,项目名称:ThinkMap,代码行数:24,代码来源:FeatureHandler.java


示例5: Connection

import elemental.client.Browser; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:Thinkofname,项目名称:ThinkMap,代码行数:27,代码来源:Connection.java


示例6: onModuleLoad

import elemental.client.Browser; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:Thinkofname,项目名称:ThinkMap,代码行数:25,代码来源:MapViewer.java


示例7: findSelf

import elemental.client.Browser; //导入依赖的package包/类
@Override
protected E findSelf(E parent) {
  if (el != null) {
    return el;
  }
  // First, look on the document.  This is the fastest, IF we are attached
  String id = getId();
  if (id == null) {
    return super.findSelf(parent);
  }
  el = (E) Browser.getDocument().getElementById(id);
  if (el == null && parent != null) {
    // If we aren't attached, fallback to the slower querySelector
    el = (E) parent.querySelector("#"+id);
  }
  if (el != null) {
    return el;
  }
  return super.findSelf(parent);
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:21,代码来源:PotentialNode.java


示例8: onResize

import elemental.client.Browser; //导入依赖的package包/类
@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
}
 
开发者ID:Thinkofname,项目名称:ThinkMap,代码行数:12,代码来源:Renderer.java


示例9: VirtualTexture

import elemental.client.Browser; //导入依赖的package包/类
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];
}
 
开发者ID:Thinkofname,项目名称:ThinkMap,代码行数:29,代码来源:VirtualTexture.java


示例10: WorkerPool

import elemental.client.Browser; //导入依赖的package包/类
/**
 * 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));
    }
}
 
开发者ID:Thinkofname,项目名称:ThinkMap,代码行数:17,代码来源:WorkerPool.java


示例11: handleEvent

import elemental.client.Browser; //导入依赖的package包/类
/**
 * Internal method
 *
 * @param event
 *         Event
 */
@Override
public void handleEvent(Event event) {
    loaded++;
    if (loaded == 1) {
        TextureMap tmap = new TextureMap();
        tmap.deserialize(JsObjectSerializer.from(Json.parse((String) xhr.getResponse())));
        tmap.copyTextures(textures);
        tmap.copyGrassColormap(Model.grassBiomeColors);
        tmap.copyFoliageColormap(Model.foliageBiomeColors);
        // Sync to workers
        getWorkerPool().sendMessage(new TextureMessage(tmap), true);
        noTextures = tmap.getNumberVirtuals();
        virtualTextures = new VirtualTexture[noTextures];
        for (int i = 0; i < noTextures; i++) {
            virtualTextures[i] = new VirtualTexture(this, i);
        }
        imageElements = new ImageElement[tmap.getNumberOfImages()];
        for (int i = 0; i < tmap.getNumberOfImages(); i++) {
            ImageElement texture = imageElements[i] = (ImageElement) Browser.getDocument().createElement("img");
            texture.setOnload(new TextureLoadHandler(this, i, texture));
            texture.setCrossOrigin("anonymous");
            texture.setSrc("http://" + getConfigAdddress() + "/resources/blocks_" + i + ".png");
        }
        inputManager.hook();

        connection = new Connection(getConfigAdddress(), this, null);
    }
}
 
开发者ID:Thinkofname,项目名称:ThinkMap,代码行数:35,代码来源:MapViewer.java


示例12: handle

import elemental.client.Browser; //导入依赖的package包/类
@Override
public void handle(ServerSettings serverSettings) {
    clientSettings = ClientSettings.create(serverSettings.areOresHidden());

    // Sync to workers
    getWorkerPool().sendMessage(new ClientSettingsMessage(clientSettings.areOresHidden()), true);
    handleSettings();

    getBlockRegistry().init();
    world = new ClientWorld(MapViewer.this);
    renderer = new Renderer(MapViewer.this, (CanvasElement) Browser.getDocument().getElementById("main"));
    for (TextureLoadHandler handler : earlyTextures) {
        handler.load();
    }
}
 
开发者ID:Thinkofname,项目名称:ThinkMap,代码行数:16,代码来源:MapViewer.java


示例13: finishInitialize

import elemental.client.Browser; //导入依赖的package包/类
@Override
protected void finishInitialize(E el) {
  final Element body = Browser.getDocument().getBody();
  if (body == el.getParentElement()) {
    body.removeChild(el);
  }
  super.finishInitialize(el);
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:9,代码来源:PotentialNode.java


示例14: attachTo

import elemental.client.Browser; //导入依赖的package包/类
public static Iterable<Element> attachTo(final Element body, final String html) {
  final DivElement wrapper = Browser.getDocument().createDivElement();
  wrapper.setInnerHTML(html);
  final Iterable<Element> iter = ElementIterable.forEach(wrapper.getChildren());
  for (final Element e : iter) {
    body.appendChild(e);
  }
  return iter;
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:10,代码来源:X_Elemental.java


示例15: toFragment

import elemental.client.Browser; //导入依赖的package包/类
public static DocumentFragment toFragment(final String string) {
  final DocumentFragment frag = Browser.getDocument().createDocumentFragment();
  final Element clone = (Element) X_Elemental.DIV.cloneNode(false);
  clone.setInnerHTML(string);
  for (Element element : ElementIterable.forEach(clone.getChildren())) {
    frag.appendChild(element);
  }
  return frag;
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:10,代码来源:X_Elemental.java


示例16: ElementalServiceDefault

import elemental.client.Browser; //导入依赖的package包/类
public ElementalServiceDefault() {
  offscreen = Lazy.deferred1(()->{
    Element el = newNode("div").getElement();
    el.getStyle().setPosition("absolute");
    el.getStyle().setLeft(-2000, "px");
    el.getStyle().setTop(-2000, "px");
    Browser.getDocument().getBody().appendChild(el);
    return el;
  });
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:11,代码来源:ElementalServiceDefault.java


示例17: setFullscreen

import elemental.client.Browser; //导入依赖的package包/类
public void setFullscreen(BooleanSupplier delayFinish) {

    final Element stage = getStage();
    final Element parent = stage.getParentElement();
    final Node after = stage.getNextSibling();

    X_Elemental.addClassName(stage, "fullscreen");
    String oldWidth = stage.getStyle().getWidth();
    String oldHeight = stage.getStyle().getHeight();

    stage.getStyle().setWidth(Browser.getWindow().getInnerWidth()+"px");
    stage.getStyle().setHeight(Browser.getWindow().getInnerHeight()+"px");

    Browser.getDocument().getBody().appendChild(stage);

    execution.onBeforeFinished(delayFinish);

    execution.onFinished((method, error) ->{
          if (after == null) {
            parent.appendChild(stage);
          } else {
            parent.insertBefore(stage, after);
          }
          if (oldWidth == null) {
            stage.getStyle().clearWidth();
          } else {
            stage.getStyle().setWidth(oldWidth);
          }
          if (oldHeight == null) {
            stage.getStyle().clearHeight();
          } else {
            stage.getStyle().setHeight(oldHeight);
          }
          X_Elemental.removeClassName(stage, "fullscreen");
          return null;
    });
  }
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:38,代码来源:JUnitGuiController.java


示例18: onModuleLoad

import elemental.client.Browser; //导入依赖的package包/类
public void onModuleLoad() {
    Storage storage = Browser.getWindow().getLocalStorage();
    RootPanel.get().add(new HTML("<h3>Open more tabs to send <i>messages</i> and <i>mouse positions<i>!</h3>"));

    // text box which synchronizes its text with the active tab
    HorizontalPanel panel = new HorizontalPanel();
    panel.add(new InlineLabel("message:"));
    TextBox text = new TextBox(); panel.add(text);
    text.addKeyUpHandler(e -> {
        String msg = text.getValue();
        L.log("msg '" + msg + "'");
        storage.setItem("intercomm.msg", msg);
    });
    RootPanel.get().add(panel);

    // floating circle which shows the mouse position of the active tab
    SimplePanel box = new SimplePanel();
    box.getElement().setAttribute("style", ""
            + "position: absolute;"
            + "background-color: #FF9800;"
            + "width: 10px;"
            + "height: 10px;"
            + "border-radius: 10px;");
    RootPanel.get().add(box);
    wnd.addEventListener("mousemove", e -> {
        MouseEvent me = (MouseEvent) e;
        storage.setItem("intercomm.mouse", me.getClientX() + "," + me.getClientY());
    });

    // listeners on the passive tabs
    wnd.addEventListener("storage", e -> {
        L.log(e);
        StorageEvent se = (StorageEvent) e;
        if ("intercomm.msg".equals(se.getKey())) {
            text.setValue(se.getNewValue());
        }
        if ("intercomm.mouse".equals(se.getKey())) {
            String[] xy = se.getNewValue().split(",");
            box.getElement().getStyle().setProperty("left", xy[0] + "px");
            box.getElement().getStyle().setProperty("top", xy[1] + "px");
        }
    });
}
 
开发者ID:ibaca,项目名称:intercomm-gwt,代码行数:44,代码来源:App.java


示例19: getDocument

import elemental.client.Browser; //导入依赖的package包/类
public static Document getDocument() {
  return Browser.getDocument();
}
 
开发者ID:eclipse,项目名称:che,代码行数:4,代码来源:Elements.java


示例20: getWindow

import elemental.client.Browser; //导入依赖的package包/类
public static Window getWindow() {
  return Browser.getWindow();
}
 
开发者ID:eclipse,项目名称:che,代码行数:4,代码来源:Elements.java



注:本文中的elemental.client.Browser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WebContent类代码示例发布时间:2022-05-22
下一篇:
Java FindAll类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap