Package org.vaadin.gwtgraphics.client

Examples of org.vaadin.gwtgraphics.client.Image


  // ------------------------------------------------------------------------

  public void onDraw(final ViewPort viewPort, final ScreenContainer container) {
    this.container = container;

    Image panBg = new Image(5, 5, 50, 50, panBackgroundImage);
    Image left = new Image(5, 21, 18, 18, panLeftImage);
    Image right = new Image(37, 21, 18, 18, panRightImage);
    Image up = new Image(21, 5, 18, 18, panUpImage);
    Image down = new Image(21, 37, 18, 18, panDownImage);

    DOM.setStyleAttribute(left.getElement(), "cursor", "pointer");
    DOM.setStyleAttribute(right.getElement(), "cursor", "pointer");
    DOM.setStyleAttribute(up.getElement(), "cursor", "pointer");
    DOM.setStyleAttribute(down.getElement(), "cursor", "pointer");

    StopPropagationHandler handler = new StopPropagationHandler();
    left.addMouseUpHandler(new MouseUpHandler() {

      public void onMouseUp(MouseUpEvent event) {
        Bbox bounds = viewPort.getBounds();
        double deltaX = -bounds.getWidth() / 3;
        PanAnimation animation = new PanAnimation(viewPort);
        animation.panTo(deltaX, 0, 300);
        event.stopPropagation();
      }
    });
    left.addMouseDownHandler(handler);
    left.addClickHandler(handler);
    left.addDoubleClickHandler(handler);

    right.addMouseUpHandler(new MouseUpHandler() {

      public void onMouseUp(MouseUpEvent event) {
        Bbox bounds = viewPort.getBounds();
        double deltaX = bounds.getWidth() / 3;
        PanAnimation animation = new PanAnimation(viewPort);
        animation.panTo(deltaX, 0, 300);
        event.stopPropagation();
      }
    });
    right.addMouseDownHandler(handler);
    right.addClickHandler(handler);
    right.addDoubleClickHandler(handler);

    up.addMouseUpHandler(new MouseUpHandler() {

      public void onMouseUp(MouseUpEvent event) {
        Bbox bounds = viewPort.getBounds();
        double deltaY = bounds.getHeight() / 3;
        PanAnimation animation = new PanAnimation(viewPort);
        animation.panTo(0, deltaY, 300);
        event.stopPropagation();
      }
    });
    up.addMouseDownHandler(handler);
    up.addClickHandler(handler);
    up.addDoubleClickHandler(handler);

    down.addMouseUpHandler(new MouseUpHandler() {

      public void onMouseUp(MouseUpEvent event) {
        Bbox bounds = viewPort.getBounds();
        double deltaY = -bounds.getHeight() / 3;
        PanAnimation animation = new PanAnimation(viewPort);
        animation.panTo(0, deltaY, 300);
        event.stopPropagation();
      }
    });
    down.addMouseDownHandler(handler);
    down.addClickHandler(handler);
    down.addDoubleClickHandler(handler);

    container.add(panBg);
    container.add(left);
    container.add(right);
    container.add(up);
    container.add(down);

    // Zooming buttons:

    Image zoomBg = new Image(20, 60, 20, 60, zoomBackgroundImage);
    Image zoomIn = new Image(20, 60, 20, 20, zoomInImage);
    Image zoomExtent = new Image(20, 80, 20, 20, zoomExtentImage);
    Image zoomOut = new Image(20, 100, 20, 20, zoomOutImage);

    DOM.setStyleAttribute(zoomIn.getElement(), "cursor", "pointer");
    DOM.setStyleAttribute(zoomOut.getElement(), "cursor", "pointer");
    DOM.setStyleAttribute(zoomExtent.getElement(), "cursor", "pointer");

    zoomIn.addMouseUpHandler(new MouseUpHandler() {

      public void onMouseUp(MouseUpEvent event) {
        int index = viewPort.getZoomStrategy().getZoomStepIndex(viewPort.getScale());
        viewPort.applyScale(viewPort.getZoomStrategy().getZoomStepScale(index - 1));
        event.stopPropagation();
      }
    });
    zoomIn.addMouseDownHandler(handler);
    zoomIn.addClickHandler(handler);
    zoomIn.addDoubleClickHandler(handler);

    zoomExtent.addMouseUpHandler(new MouseUpHandler() {

      public void onMouseUp(MouseUpEvent event) {
        viewPort.applyBounds(viewPort.getMaximumBounds());
        event.stopPropagation();
      }
    });
    zoomExtent.addMouseDownHandler(handler);
    zoomExtent.addClickHandler(handler);
    zoomExtent.addDoubleClickHandler(handler);

    zoomOut.addMouseUpHandler(new MouseUpHandler() {

      public void onMouseUp(MouseUpEvent event) {
        int index = viewPort.getZoomStrategy().getZoomStepIndex(viewPort.getScale());
        viewPort.applyScale(viewPort.getZoomStrategy().getZoomStepScale(index + 1));
        event.stopPropagation();
      }
    });
    zoomOut.addMouseDownHandler(handler);
    zoomOut.addClickHandler(handler);
    zoomOut.addDoubleClickHandler(handler);

    container.add(zoomBg);
    container.add(zoomIn);
    container.add(zoomExtent);
    container.add(zoomOut);

    // Zoom to rectangle buttons:

    Image zoomToRectangle = new Image(20, 130, 20, 20, zoomToRectangleImage);
    zoomToRectangle.setTitle("Zoom to rectangle by dragging the mouse on the map.");
    DOM.setStyleAttribute(zoomToRectangle.getElement(), "cursor", "pointer");
    zoomToRectangle.addMouseUpHandler(new MouseUpHandler() {

      public void onMouseUp(MouseUpEvent event) {
        zoomToRectangleGroup = new ZoomToRectGroup(viewPort);
        container.add(zoomToRectangleGroup);
        event.stopPropagation();
      }
    });
    zoomToRectangle.addMouseDownHandler(handler);
    zoomToRectangle.addClickHandler(handler);
    zoomToRectangle.addDoubleClickHandler(handler);

    container.add(zoomToRectangle);
  }
View Full Code Here


    background = new Rectangle(viewPort.getMapWidth() - 125, viewPort.getMapHeight() - 12, 125, 12);
    background.setStrokeOpacity(0);
    background.setFillOpacity(0.65);
    container.add(background);

    image = new Image(viewPort.getMapWidth() - 125, viewPort.getMapHeight() - 12, 125, 12, GWT.getModuleBaseURL()
        + "geomajas/images/mapgadget/powered_by_geomajas.gif");
    container.add(image);
  }
View Full Code Here

TOP

Related Classes of org.vaadin.gwtgraphics.client.Image

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.