Exemplo n.º 1
0
 protected void selectVerticalAutoTickUnit(
     Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) {
   double tickLabelHeight = estimateMaximumTickLabelHeight(g2);
   TickUnitSource tickUnits = getStandardTickUnits();
   TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit());
   double unitHeight = lengthToJava2D(unit1.getSize(), dataArea, edge);
   double guess = unit1.getSize();
   if (unitHeight > 0.0d) {
     guess = (tickLabelHeight / unitHeight) * unit1.getSize();
   }
   NumberTickUnit unit2 = (NumberTickUnit) tickUnits.getCeilingTickUnit(guess);
   if (estimateMaximumTickLabelHeight(g2) > lengthToJava2D(unit2.getSize(), dataArea, edge)) {
     unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2);
   }
   setTickUnit(unit2, DEFAULT_VERTICAL_TICK_LABELS, DEFAULT_VERTICAL_TICK_LABELS);
 }
Exemplo n.º 2
0
 protected void selectHorizontalAutoTickUnit(
     Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) {
   double tickLabelWidth = estimateMaximumTickLabelWidth(g2, getTickUnit());
   TickUnitSource tickUnits = getStandardTickUnits();
   TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit());
   NumberTickUnit unit2 =
       (NumberTickUnit)
           tickUnits.getCeilingTickUnit(
               (tickLabelWidth / lengthToJava2D(unit1.getSize(), dataArea, edge))
                   * unit1.getSize());
   if (estimateMaximumTickLabelWidth(g2, unit2)
       > lengthToJava2D(unit2.getSize(), dataArea, edge)) {
     unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2);
   }
   setTickUnit(unit2, DEFAULT_VERTICAL_TICK_LABELS, DEFAULT_VERTICAL_TICK_LABELS);
 }