Package org.timepedia.chronoscope.client

Examples of org.timepedia.chronoscope.client.Chart


     RootPanel.get().add(data);
     delayTestFinish(15000);
     Chronoscope.setMicroformatsEnabled(true);
     Microformats.setMicroformatsReadyListener(new Command() {
       public void execute() {
         Chart c=Chronoscope.getChartById("microformatdemochrono");
         XYDataset xy = c.getPlot().getDataset(0);
         Date start = new Date(53, 0, 1, 0, 0, 0);
         Date end = new Date(64, 0, 1, 0, 0 ,0);
         assertEquals(start.getTime(), (long)xy.getX(0));
         assertEquals(end.getTime(), (long)xy.getX(xy.getNumSamples()-1));
         finishTest();
View Full Code Here


  }

  public StaticImageChartPanel(Dataset[] ds, boolean interactive, int width,
      int height, GssContext gssContext) {
    this.interactive = interactive;
    chart = new Chart();
    plot = new DefaultXYPlot();
    Datasets dss = new Datasets(ds);

    plot.setDatasets(dss);
    plot.setOverviewEnabled(false);
View Full Code Here

      int height, String css, boolean interactive, double domainOrigin,
      double currentDomain, boolean az) {
    StaticImageChartPanel sicp = ServerChronoscope.get()
        .createChart(new Datasets(ds), width, height, null);

    Chart c = sicp.getChart();

    XYPlot xyPlot = c.getPlot();
    xyPlot.getRangeAxis(0).setAutoZoomVisibleRange(az);

    xyPlot.getDomain().setEndpoints(domainOrigin, currentDomain);
    c.redraw();

    BufferedImage bimg = (BufferedImage) sicp.getImage();
    return bimg;
  }
View Full Code Here

    addKeyListener(this);


    label = new JLabel();

    chart = new Chart();
    plot = new DefaultXYPlot();
    plot.setDatasets(new Datasets(xyDatasets));
    XYPlotRenderer plotRenderer = new XYPlotRenderer();
    plot.setPlotRenderer(plotRenderer);
    chart.setPlot(plot);
View Full Code Here

  public void onViewReady(View view) {
    plot.init(view);
   
    // configure chart
    chart = new Chart();
    chart.setPlot(plot);
    chart.setView(view);
    view.setChart(chart);
//    chart.init(view, plot);
    redraw();
View Full Code Here

  private static double hiliteRelativeGrabX;
   
  public void onMouseMove(MouseMoveEvent event) {
    ChartState chartInfo = getChartState(event);
    Chart chart = chartInfo.chart;
    DefaultXYPlot plot = (DefaultXYPlot)chartInfo.chart.getPlot();
   
    if (null == plot.getBounds() || !plot.isOverviewVisible()) {
      return;
    }
   
    OverviewAxisPanel oaPanel = plot.getOverviewAxisPanel();
    ValueAxis overviewAxis = oaPanel.getValueAxis();
    Bounds overviewAxisBounds = oaPanel.getBounds();
    Bounds hiliteBounds = oaPanel.getHighlightBounds();
    CompoundUIAction uiAction = chartInfo.getCompoundUIAction();
   
    // Translate the view (x,y) point into an (x,y) point relative to
    // the OverviewAxisPanel.
    Bounds plotBounds = plot.getBounds();
    int x = getLocalX(event) - (int)plotBounds.x;
    int y = getLocalY(event) - (int)plotBounds.bottomY();

    final boolean isInAxisBounds = null == hiliteBounds ? false: overviewAxisBounds.inside(x, y);
    final boolean isDragging = uiAction.isDragging(overviewAxis);
   
    //log("onMouseMove(" + x + ", " + y + ")" + ": inAxisBounds=" + isInAxisBounds + "; uiAction.startX=" + uiAction.getEndX());
   
    // Determine appropriate cursor type
    if (isInAxisBounds) {
      if (hiliteBounds != null && hiliteBounds.inside(x, y)) {
        chartInfo.chart.setCursor(Cursor.DRAGGABLE);
      }
      else {
        chartInfo.chart.setCursor(Cursor.DEFAULT);
      }
    }
    // else, mouse is outside of overview axis, so don't mess with cursor.
   
    // final double viewOffsetX = plotBounds.x;
    final double viewOffsetX = 0;
   
    if (uiAction.isSelecting(overviewAxis)) {
      chart.setAnimating(true);

      chart.setCursor(Cursor.SELECTING);
      chart.setAnimating(true);
      // Determine the start and end domain of the highlight selection
      double startDomainX = toDomainX(uiAction.getStartX(), plot);
      double boundedX = MathUtil.bound(x, overviewAxisBounds.x, overviewAxisBounds.rightX());
      double endDomainX = toDomainX(boundedX + viewOffsetX, plot);
      if (startDomainX > endDomainX) {
        double tmp = startDomainX;
        startDomainX = endDomainX;
        endDomainX = tmp;
      }
      // Set the current highlight region in the plot
      //  TODO - think about setting highlightPanel.bounds instead
      plot.setHighlight(startDomainX, endDomainX);
      plot.getDomain().setEndpoints(startDomainX, endDomainX);
      plot.redraw();
    }
    else if (hiliteBounds != null && isDragging) {
      chart.setAnimating(true);
     
      // hiliteLeftDomainX represents the domain-x value of the left edge
      // of the highlight window within the overview axis.
      //double hiliteLeftX = x - (hiliteBounds.width / 2.0);x will always be at the center of the hiliteBounds
View Full Code Here

    public static int UP_NUM = 0;
    public final int KEY_DOWN_MAX = 5;

  public void onKeyDown(KeyDownEvent event) {
    ChartState chartInfo = getChartState(event);
    Chart chart = chartInfo.chart;
    boolean handled = true;
    int keyCode = event.getNativeKeyCode();
    // all checks (except TAB) are to prevent focus stealing by the browser.
      if (keyCode == KeyCodes.KEY_PAGEUP) {
      } else if (keyCode == KeyCodes.KEY_PAGEDOWN) {
      } else if (keyCode == KeyCodes.KEY_UP) {
          if (UP_NUM < KEY_DOWN_MAX) {
              if (UP_NUM != 0) {
                  chart.nextZoom();
              }
              UP_NUM++;
          }
      } else if (keyCode == KeyCodes.KEY_DOWN) {
          if (DOWN_NUM < KEY_DOWN_MAX) {
              if (DOWN_NUM != 0) {
                  chart.prevZoom();
              }
              DOWN_NUM++;
          }
      } else if (keyCode == KeyCodes.KEY_TAB) {
          handled = handleTabKey((Event) event.getNativeEvent(), chartInfo, keyCode,
View Full Code Here

  public static final double FULL_PAGE_SCROLL = 1.0;
  private static final double HALF_PAGE_SCROLL = 0.5;
 
  public void onKeyUp(KeyUpEvent event) {
    ChartState chartInfo = getChartState(event);
    Chart chart = chartInfo.chart;

    int keyCode = event.getNativeKeyCode();
    boolean handled = true;

    if (isPageUp(keyCode)) {
      chart.pageLeft(FULL_PAGE_SCROLL);
    } else if (event.isLeftArrow() || isKeyLeft(keyCode)) {
      chart.pageLeft(HALF_PAGE_SCROLL);    
    } else if (isPageDown(keyCode)) {
      chart.pageRight(FULL_PAGE_SCROLL);
    } else if (event.isRightArrow() || isKeyRight(keyCode)) {
      chart.pageRight(HALF_PAGE_SCROLL);
    } else if (event.isUpArrow() || isNextZoom(keyCode)) {
      chart.nextZoom();
      ChartKeyDownHandler.UP_NUM = 0;
    } else if (event.isDownArrow() || isPrevZoom(keyCode)) {
      chart.prevZoom();
      ChartKeyDownHandler.DOWN_NUM = 0;
    } else if (keyCode == KeyCodes.KEY_BACKSPACE) {
      History.back();
    } else if (isMaxZoomOut(keyCode)) {
      chart.maxZoomOut();
    } else {
      handled = false;
    }
   
    chartInfo.setHandled(handled);
View Full Code Here

public final class ChartMouseUpHandler
    extends AbstractEventHandler<MouseUpHandler> implements MouseUpHandler {

  public void onMouseUp(MouseUpEvent event) {
    ChartState chartInfo = getChartState(event);
    Chart chart = chartInfo.chart;
    XYPlot plot = chart.getPlot();
    int x = getLocalX(event);
    int y = getLocalY(event);
    OverviewAxisMouseMoveHandler.setHiliteRelativeGrabX(Double.NaN);

    CompoundUIAction uiAction = chartInfo.getCompoundUIAction();
    if (uiAction.isSelecting()) {
      chart.setAnimating(false);
      chart.zoomToHighlight();
    } else if (uiAction.getSource() != null && uiAction.isDragging(uiAction.getSource()) && x != uiAction.getDragStartX()) {
      if (uiAction.getSource() instanceof Overlay) {
        ((Overlay) uiAction.getSource()).fire(new ChartDragEndEvent(plot, x));
      } else {
        HistoryManager.pushHistory();
      }
      chart.setAnimating(false);
     
      // FIXME: this produces several unneeded redraws, if we remove this, dragging does not
      // redraw correctly, so algorithm  in mouse move should be reviewd
      ((DefaultXYPlot) chart.getPlot()).redraw(true);
    }

    chartInfo.getCompoundUIAction().cancel();
    chart.setCursor(Cursor.DEFAULT);

    if (event.getNativeButton() == Event.BUTTON_RIGHT) {
      ((DefaultXYPlot) chart.getPlot()).fireContextMenuEvent(x, y);
    } else {
      // fire click, in mouse up events this fixes click on flash view.
      chart.click(x, y);
    }

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

public class ChartMouseOutHandler extends AbstractEventHandler<MouseOutHandler>
    implements MouseOutHandler {

  public void onMouseOut(MouseOutEvent event) {
    ChartState chartInfo = getChartState(event);
    Chart chart = chartInfo.chart;
    chart.setAnimating(false);
    chart.setCursor(Cursor.DEFAULT);
    chart.setHover(-1,-1);
    //((DefaultXYPlot)chart.getPlot()).redraw(true);
    chartInfo.setHandled(true);
    chartInfo.getCompoundUIAction().setSource(null);
  }
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.