Package org.timepedia.chronoscope.client

Examples of org.timepedia.chronoscope.client.Chart


  static final int KEY_Z = 90 + 32;

  public void onKeyPress(KeyPressEvent event) {
    ChartState chartInfo = getChartState(event);

    Chart chart = chartInfo.chart;

    int keyCode = event.getCharCode();
    boolean handled = true;
    if (keyCode == KeyCodes.KEY_TAB) {
      handled = handleTabKey((Event)event.getNativeEvent(), chartInfo, keyCode, event.isShiftKeyDown());
    } else if (keyCode == KEY_Z) {
      chart.nextZoom();
    } else if (keyCode == KEY_X) {
      chart.prevZoom();
    } else if (keyCode == KeyCodes.KEY_ENTER) {
      chart.maxZoomToFocus();
    } else {
      handled = false;
    }

    chartInfo.setHandled(handled);
View Full Code Here


    extends AbstractEventHandler<DoubleClickHandler>
    implements DoubleClickHandler {

  public void onDoubleClick(DoubleClickEvent event) {
    ChartState chartInfo = getChartState(event);
    Chart chart = chartInfo.chart;

    chart.setAnimating(false);

    boolean handled = false;
    if (chart.maxZoomTo(getLocalX(event), getLocalY(event))) {
      event.stopPropagation();
      event.preventDefault();
      handled = true;
    }
View Full Code Here

public final class ChartMouseMoveHandler
    extends AbstractEventHandler<MouseMoveHandler> implements MouseMoveHandler {

  public void onMouseMove(MouseMoveEvent event) {
    ChartState chartInfo = getChartState(event);
    Chart chart = chartInfo.chart;
    XYPlot plot = chart.getPlot();
    int x = getLocalX(event);
    int y = getLocalY(event);

    CompoundUIAction uiAction = chartInfo.getCompoundUIAction();
    if (uiAction.isSelecting(plot)) {
      chart.setAnimating(true);
      plot.setHighlight(uiAction.getStartX(), x);
    } else if (uiAction.getSource() != null && uiAction
        .isDragging(uiAction.getSource())) {
      int dragThd = uiAction.isDragStarted(plot) ? 1
          : (uiAction.getSource() instanceof Overlay ? 5 : 10);

      boolean dragThresholdReached = Math.abs(uiAction.getStartX() - x)
          > dragThd;
      if (dragThresholdReached) {
        if (uiAction.getSource() instanceof Overlay) {
          if (!uiAction.isDragStarted(plot)) {
            plot.fireEvent(new ChartDragStartEvent(plot, x));
            uiAction.setDragStarted(true);
            uiAction.setDragStartX(uiAction.getStartX());
          }
          ((Overlay) uiAction.getSource()).fire(new ChartDragEvent(plot, x));
          chart.setHover(x,y);
        } else {
          chart.setAnimating(true);
          chart.scrollPixels(uiAction.getStartX() - x);
        }
        uiAction.setStartX(x);
        event.stopPropagation();
        event.preventDefault();
      }
    } else if ((null != plot) && (null != plot.getBounds()) && (plot.getBounds().inside(x, y))) {
      if (chart.setHover(x, y)) {
        chart.setCursor(Cursor.CLICKABLE);
      } else {
        chart.setCursor(Cursor.DRAGGABLE);
      }
    }

    chartInfo.setHandled(true);
  }
View Full Code Here

public final class ChartMouseDownHandler
    extends AbstractEventHandler<MouseDownHandler> implements MouseDownHandler {

  public void onMouseDown(MouseDownEvent event) {
    ChartState chartInfo = getChartState(event);
    Chart chart = chartInfo.chart;
    int x = getLocalX(event);
    int y = getLocalY(event);

    if (y > (chart.getView().getHeight() - chart.getPlot().getOverviewAxisPanel().getBounds().height)) {
      int overviewX = (int)chart.getPlot().getBounds().x;
      Bounds highlightBounds = chart.getPlot().getOverviewAxisPanel().getHighlightBounds();
      if ( highlightBounds != null) {
        int hiliteX = (int) highlightBounds.x;
        System.out.println("   MOUSEDOWN    x:"+x+" overviewX:"+overviewX+" hiliteX:"+hiliteX);
        OverviewAxisMouseMoveHandler.setHiliteRelativeGrabX((double)((x - overviewX) - hiliteX));
      }
    }
    boolean handled;

    if (event.getNativeButton() == Event.BUTTON_RIGHT) {
      // Ignore mouse right-click -- let browser handle event.
      handled = false;
    } else {
      // Set the UI component that initiated the drag or select
      CompoundUIAction uiAction = chartInfo.getCompoundUIAction();
      uiAction.setSource(getComponent(x, y, chart.getPlot()));
      if (event.isShiftKeyDown()) {
        chart.setCursor(Cursor.SELECTING);
        uiAction.setSelectAction(true);
      } else {
        chart.setCursor(Cursor.DRAGGING);
        uiAction.setSelectAction(false);
      }
      uiAction.setStartX(x);
      if (uiAction.getSource() instanceof Overlay) {
     
        handled = true;
      } else {
        chart.setPlotFocus(x, y);
        handled = true;
      }
    }

    chartInfo.setHandled(handled);
View Full Code Here

public class ChartMouseWheelHandler extends AbstractEventHandler<MouseWheelHandler> implements MouseWheelHandler {

  public void onMouseWheel(MouseWheelEvent event) {
    try {
      ChartState chartInfo = getChartState(event);
      Chart chart = chartInfo.chart;

      int wheelDir = event.getNativeEvent().getMouseWheelVelocityY();
      boolean isMouseWheelUp = (wheelDir <= 0);
      if (isMouseWheelUp) {
        chart.nextZoom();
      }
      else {
        chart.prevZoom();
      }
     
      chartInfo.setHandled(true);
     
    } catch (Exception e) {
View Full Code Here

public class ChartMouseOverHandler
    extends AbstractEventHandler<MouseOverHandler> implements MouseOverHandler {

  public void onMouseOver(MouseOverEvent event) {
    ChartState chartInfo = getChartState(event);
    Chart chart = chartInfo.chart;
    int x = getLocalX(event);
    int y = getLocalY(event);
    chart.setPlotFocus(x, y);
    boolean isMouseInPlot = false;
    if ((null != chart) && (null != chart.getPlot()) && (null != chart.getPlot().getBounds())) {
      isMouseInPlot = chart.getPlot().getBounds().inside(x, y);
    }
    chart.setCursor(
        isMouseInPlot ? Cursor.DRAGGABLE : Cursor.DEFAULT);
    //((DOMView) chart.getView()).focus();
    chartInfo.setHandled(true);
  }
View Full Code Here

    addKeyUpHandler(keyUpHandler);
    addKeyPressHandler(keyPressHandler);
    addKeyDownHandler(keyDownHandler);
   
    view = (View) GWT.create(DOMView.class);
    chart = new Chart();
  }
View Full Code Here

      this.elt = elt;
      this.latch = latch;
    }

    public void onViewReady(View view) {
      Chart chart = view.getChart();
      if (chart == null) {
        return;
      }

      for (int j = 0; j < links.length; j++) {
        String href = DOM.getElementAttribute(links[j], "href");
        int hash = href != null ? href.indexOf("#") : -1;
        if (hash != -1) {
          href = href.substring(hash);
        }

        if (href != null && href.startsWith("#" + chartId)) {

          String date = href.substring(("#" + chartId + ":").length());
          String label = getAttribute(links[j], "accesskey");
          if (label == null) {
            char c[] = new char[1];
            c[0] = (char) ('A' + charCounter);

            label = new String(c);
          }
          final Element[] infoWindow = getElementsByClassName(links[j], "span",
              CMF_PREFIX + "-infowindow");
          final Marker m = new Marker((double) Date.parse(date), label, 0);
          attachOnClick(links[j], m);

          if (infoWindow != null && infoWindow[0] != null) {
            m.addOverlayClickListener(new OverlayClickListener() {
              public void onOverlayClick(Overlay overlay, int x, int y) {
                m.openInfoWindow(DOM.getInnerHTML(infoWindow[0]));
              }
            });
          }
          XYPlot plot = chart.getPlot();
          plot.addOverlay(m);
          String[] hdrs = getTableHeaders(elt);
          if (hdrs != null && hdrs.length > 1) {
            plot.getDomainAxisPanel().getValueAxis().setLabel(hdrs[0]);
            for (int k = 1; k < hdrs.length; k++) {
              plot.getRangeAxis(k - 1).setLabel(hdrs[k]);
            }
          }
        }
      }
      latch.decrement();
      chart.redraw();
    }
View Full Code Here

TOP

Related Classes of org.timepedia.chronoscope.client.Chart

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.