Package com.positive.charts.axis.ticks

Examples of com.positive.charts.axis.ticks.TickUnitSource


      final Rectangle dataArea, final RectangleEdge edge) {
    double tickLabelWidth = this.estimateMaximumTickLabelWidth(g2, this
        .getTickUnit());

    // start with the current tick unit...
    final TickUnitSource tickUnits = this.getStandardTickUnits();
    final TickUnit unit1 = tickUnits.getCeilingTickUnit(this.getTickUnit());
    final double unit1Width = this.lengthToJava2D(unit1.getSize(),
        dataArea, edge);

    // then extrapolate...
    final double guess = (tickLabelWidth / unit1Width) * unit1.getSize();

    NumberTickUnit unit2 = (NumberTickUnit) tickUnits
        .getCeilingTickUnit(guess);
    final double unit2Width = this.lengthToJava2D(unit2.getSize(),
        dataArea, edge);

    tickLabelWidth = this.estimateMaximumTickLabelWidth(g2, unit2);
    if (tickLabelWidth > unit2Width) {
      unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2);
    }

    this.setTickUnit(unit2, false, false);
  }
View Full Code Here


  protected void selectVerticalAutoTickUnit(final GC g2,
      final Rectangle dataArea, final RectangleEdge edge) {
    double tickLabelHeight = this.estimateMaximumTickLabelHeight(g2);

    // start with the current tick unit...
    final TickUnitSource tickUnits = this.getStandardTickUnits();
    final TickUnit unit1 = tickUnits.getCeilingTickUnit(this.getTickUnit());
    final double unitHeight = this.lengthToJava2D(unit1.getSize(),
        dataArea, edge);

    // then extrapolate...
    final double guess = (tickLabelHeight / unitHeight) * unit1.getSize();

    NumberTickUnit unit2 = (NumberTickUnit) tickUnits
        .getCeilingTickUnit(guess);
    final double unit2Height = this.lengthToJava2D(unit2.getSize(),
        dataArea, edge);

    tickLabelHeight = this.estimateMaximumTickLabelHeight(g2);
    if (tickLabelHeight > unit2Height) {
      unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2);
    }

    this.setTickUnit(unit2, false, false);
  }
View Full Code Here

    final double zero = this.valueToJava2D(shift + 0.0, dataArea, edge);
    double tickLabelWidth = this.estimateMaximumTickLabelWidth(g2, this
        .getTickUnit());

    // start with the current tick unit...
    final TickUnitSource tickUnits = this.getStandardTickUnits();
    final TickUnit unit1 = tickUnits.getCeilingTickUnit(this.getTickUnit());
    final double x1 = this.valueToJava2D(shift + unit1.getSize(), dataArea,
        edge);
    final double unit1Width = Math.abs(x1 - zero);

    // then extrapolate...
    final double guess = (tickLabelWidth / unit1Width) * unit1.getSize();
    DateTickUnit unit2 = (DateTickUnit) tickUnits.getCeilingTickUnit(guess);
    final double x2 = this.valueToJava2D(shift + unit2.getSize(), dataArea,
        edge);
    final double unit2Width = Math.abs(x2 - zero);
    tickLabelWidth = this.estimateMaximumTickLabelWidth(g2, unit2);
    if (tickLabelWidth > unit2Width) {
      unit2 = (DateTickUnit) tickUnits.getLargerTickUnit(unit2);
    }
    this.setTickUnit(unit2, false, false);
  }
View Full Code Here

   */
  protected void selectVerticalAutoTickUnit(final GC g2,
      final Rectangle dataArea, final RectangleEdge edge) {

    // start with the current tick unit...
    final TickUnitSource tickUnits = this.getStandardTickUnits();
    final double zero = this.valueToJava2D(0.0, dataArea, edge);

    // start with a unit that is at least 1/10th of the axis length
    final double estimate1 = this.getRange().getLength() / 10.0;
    final DateTickUnit candidate1 = (DateTickUnit) tickUnits
        .getCeilingTickUnit(estimate1);
    final double labelHeight1 = this.estimateMaximumTickLabelHeight(g2,
        candidate1);
    final double y1 = this.valueToJava2D(candidate1.getSize(), dataArea,
        edge);
    final double candidate1UnitHeight = Math.abs(y1 - zero);

    // now extrapolate based on label height and unit height...
    final double estimate2 = (labelHeight1 / candidate1UnitHeight)
        * candidate1.getSize();
    final DateTickUnit candidate2 = (DateTickUnit) tickUnits
        .getCeilingTickUnit(estimate2);
    final double labelHeight2 = this.estimateMaximumTickLabelHeight(g2,
        candidate2);
    final double y2 = this.valueToJava2D(candidate2.getSize(), dataArea,
        edge);
    final double unit2Height = Math.abs(y2 - zero);

    // make final selection...
    DateTickUnit finalUnit;
    if (labelHeight2 < unit2Height) {
      finalUnit = candidate2;
    } else {
      finalUnit = (DateTickUnit) tickUnits.getLargerTickUnit(candidate2);
    }
    this.setTickUnit(finalUnit, false, false);

  }
View Full Code Here

TOP

Related Classes of com.positive.charts.axis.ticks.TickUnitSource

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.