Package org.timepedia.chronoscope.client.util

Examples of org.timepedia.chronoscope.client.util.Interval


      drawableDataset.visDomainStartIndex = domainStartIdx;
      drawableDataset.visDomainEndIndex = domainEndIdx;

      RangeAxis rangeAxis = plot.getRangeAxis(datasetIdx);
      Interval visRange = calcVisibleRange(bestMipMap, domainStartIdx,
       domainEndIdx, drawableDataset.getRenderer());

      if (rangeAxis.isCalcRangeAsPercent()) {
        DatasetRenderer dr = plot.getDatasetRenderer(datasetIdx);
        Interval rangeExtrema = dr.getRangeExtrema(drawableDataset.currMipMap);

        double refY = calcReferenceY(rangeAxis, drawableDataset);
        double pmin = rangeExtrema.getPercentChange(refY, visRange.getStart());
        double pmax = rangeExtrema.getPercentChange(refY, visRange.getEnd());

        rangeAxis.setVisibleRange(pmin, pmax);
      }

      rangeAxis.adjustVisibleRange(
View Full Code Here


      rangeMin = Math.min(rangeMin, pt.getRange0());
      rangeMax = Math.max(rangeMax, y);
      rangeMax = Math.max(rangeMax, pt.getRange0());
    }

    return new Interval(rangeMin, rangeMax);
  }
View Full Code Here

            Tuple2D dataPt = tupleItr.next();
            renderState.setFocused(focusSeries == datasetIndex && focusDomainX == dataPt.getDomain());

            if (calcRangeAsPercent) {
              LocalTuple tmpTuple = new LocalTuple();
              Interval rangeExtrema = dds.currMipMap.getRangeExtrema(pass);
              double pctY = rangeExtrema.getPercentChange(refY, dataPt.getRange0());
              tmpTuple.setXY(dataPt.getDomain(), pctY);
              dataPt = tmpTuple;
            }
            // FIXME: refactor to remove cast
            renderer.drawCurvePart(datasetIndex, i, layer, (T) dataPt, methodCallCount++, renderState);
         } else {
             break;
         }
      }
      renderer.endCurve(layer, renderState);

      if (!overviewMode) {
        // Render the focus points on the curve
        renderer.beginPoints(layer, renderState);
        //startIdx = Math.max(0, domainStartIdx - 2);
        tupleItr = currMipMap.getTupleIterator(domainStartIdx);
        for (int i = domainStartIdx; i <= domainEndIdx; i++) {
          Tuple2D dataPt = tupleItr.next();
          renderState.setFocused(focusSeries == datasetIndex && focusPoint == i && focusDomainX == dataPt.getDomain() && renderState.getPassNumber() == pass);

          if (calcRangeAsPercent) {
            LocalTuple tmpTuple = new LocalTuple();
            Interval rangeExtrema = dds.currMipMap.getRangeExtrema(pass);
            double pctY = rangeExtrema.getPercentChange(refY, dataPt.getRange0());
            tmpTuple.setXY(dataPt.getDomain(), pctY);
            dataPt = tmpTuple;
          }
          // FIXME: refactor to remove cast
          renderer.drawPoint(datasetIndex, i, layer, (T) dataPt, renderState);
View Full Code Here

  public Interval calcWidestPlotDomain() {
    if (drawableDatasets.isEmpty()) {
      return null;
    }

    Interval widestPlotDomain = null;
    for (DrawableDataset<T> dds : drawableDatasets) {
      Dataset<T> ds = dds.dataset;
      final int maxDrawableDataPoints = getMaxDrawableDataPoints(dds);
      MipMap mm = ds.getMipMapChain()
          .findHighestResolution(maxDrawableDataPoints);

      Interval drawableDomain = dds.getRenderer()
          .getDrawableDomain(mm.getDomain());
      if (widestPlotDomain == null) {
        widestPlotDomain = drawableDomain;
      } else {
        widestPlotDomain.expand(drawableDomain);
View Full Code Here

          // Need to store domain/range values from the flyweight dataPt object
          // in tmp variables, because currMipMap.getTuple() overwrites the
          // dataPt object's state
          final double hoverX = dataPt.getDomain();
          final double hoverY = dataPt.getRange0();
          Interval rangeExtrema = dds.currMipMap.getRangeExtrema(i);
          final double refY = calcReferenceY(rangeAxis, dds);
          double pctY = rangeExtrema.getPercentChange(refY, hoverY);
          LocalTuple tmpTuple = new LocalTuple();
          tmpTuple.setXY(hoverX, pctY);
          dataPt = (T) (Object) tmpTuple;
        }
        dds.getRenderer().drawHoverPoint(layer, dataPt, i);
View Full Code Here

   * across all {@link Dataset} elements within this container.
   */
  @Export
  public Interval getDomainExtrema() {
    verifyDatasetNotEmpty();
    return new Interval(this.minDomain, this.maxDomain);
  }
View Full Code Here

    RangeAxis ra = getRangeAxis(datasetIdx);
    double y = dds.getRenderer().getRangeValue(dds.currMipMap.getTuple(pointIdx), dimension);
    if (ra.isCalcRangeAsPercent()) {
      double refY = plotRenderer.calcReferenceY(ra, dds);
      // Interval rangeExtrema = dds.currMipMap.getRangeExtrema(dimension);
      Interval rangeExtrema = ra.getExtrema();
      return rangeExtrema.getPercentChange(refY, y);
    }

    return y;
  }
View Full Code Here

    background.paint(this, backgroundLayer, visDomain.getStart(), visDomain.length());
  }

  public void drawOverviewPlot(Layer overviewLayer) {
    // save original endpoints so they can be restored later
    Interval origVisPlotDomain = getDomain().copy();
    getWidestDomain().copyTo(getDomain());
    // Canvas backingCanvas = view.getCanvas();
    // backingCanvas.beginFrame();

    overviewLayer.save();

    overviewLayer.clear();
    // overviewLayer.setVisibility(false);
    overviewLayer.setFillColor(Color.TRANSPARENT);
    overviewLayer.fillRect(0, 0, overviewLayer.getWidth(), overviewLayer.getHeight());

    Bounds oldBounds = plotBounds;
    Layer oldLayer = plotLayer;
    // plotBounds = new Bounds(
    //    oldBounds.x, view.getHeight() - OverviewAxisPanel.OVERVIEW_HEIGHT,
    //    oldBounds.width, OverviewAxisPanel.OVERVIEW_HEIGHT);
    plotBounds = getOverviewAxisPanel().getBounds();
    plotLayer = overviewLayer;
    plotRenderer.drawDatasets(true);
    plotBounds = oldBounds;
    plotLayer = oldLayer;

    overviewLayer.restore();

    // backingCanvas.endFrame();
    // restore original endpoints
    origVisPlotDomain.copyTo(getDomain());
  }
View Full Code Here

  @Export
  public void reloadStyles() {

    bottomPanel.clearDrawCaches();
    Interval tmpPlotDomain = visDomain.copy();

    // hack, eval order dependency
    initViewIndependent(datasets);
    fixDomainDisjoint();
    init(view, false);
    ArrayList<Overlay> oldOverlays = overlays;
    overlays = new ArrayList<Overlay>();
    visDomain = plotRenderer.calcWidestPlotDomain();
    tmpPlotDomain.copyTo(visDomain);
    overlays = oldOverlays;

    initCrosshairs();

    redraw(true);
View Full Code Here

        animationContinuation.run(animationTimer);
      }
      animationTimer = null;
    }

    final Interval destDomain;
    if (fence) {
      destDomain = fenceDomain(destDomainOrigin, destDomainLength);
    } else {
      destDomain = new Interval(destDomainOrigin,
          destDomainOrigin + destDomainLength);
    }

    animationContinuation = continuation;
    final Interval visibleDomain = this.visDomain;

    animationTimer = view.createTimer(new PortableTimerTask() {
      final double destDomainMid = destDomain.midpoint();

      final Interval srcDomain = visibleDomain.copy();

      // Ratio of destination domain to current domain
      final double zoomFactor = destDomain.length() / srcDomain.length();

      double startTime = 0;

      boolean lastFrame = false;

      public void run(PortableTimer t) {
       
        // lerpFactor==1 means do just one step, better for low-performance devices (flash)
        double lerpFactor = 1;
        if (!ChronoscopeOptions.isLowPerformance()) {
          if (startTime == 0) {
            startTime = t.getTime();
          }
          double curTime = t.getTime();
          lerpFactor = (curTime - startTime) / 300;
          if (lerpFactor > 1) {
            lerpFactor = 1;
          }
        }
       
        isAnimating = true;

        final double domainCenter =
            (destDomainMid - srcDomain.midpoint()) * lerpFactor + srcDomain
                .midpoint();
        final double domainLength = srcDomain.length() * ((1 - lerpFactor) + (
            zoomFactor * lerpFactor));
        final double domainStart = domainCenter - domainLength / 2;
        visibleDomain.setEndpoints(domainStart, domainStart + domainLength);
        redraw(true);

        if (lerpFactor < 1) {
          t.schedule(10);
        } else if (lastFrame) {
View Full Code Here

TOP

Related Classes of org.timepedia.chronoscope.client.util.Interval

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.