コード例 #1
0
  /**
   * Reserve some space on each axis side because we draw a centered label at each extremity.
   *
   * @param g2 the graphics device.
   * @param plot the plot.
   * @param plotArea the plot area.
   * @param edge the edge.
   * @param space the space already reserved.
   * @return The reserved space.
   */
  public AxisSpace reserveSpace(
      Graphics2D g2, Plot plot, Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) {

    this.internalMarkerCycleBoundTick = null;
    AxisSpace ret = super.reserveSpace(g2, plot, plotArea, edge, space);
    if (this.internalMarkerCycleBoundTick == null) {
      return ret;
    }

    FontMetrics fm = g2.getFontMetrics(getTickLabelFont());
    Rectangle2D r =
        TextUtilities.getTextBounds(this.internalMarkerCycleBoundTick.getText(), g2, fm);

    if (RectangleEdge.isTopOrBottom(edge)) {
      if (isVerticalTickLabels()) {
        space.add(r.getHeight() / 2, RectangleEdge.RIGHT);
      } else {
        space.add(r.getWidth() / 2, RectangleEdge.RIGHT);
      }
    } else if (RectangleEdge.isLeftOrRight(edge)) {
      if (isVerticalTickLabels()) {
        space.add(r.getWidth() / 2, RectangleEdge.TOP);
      } else {
        space.add(r.getHeight() / 2, RectangleEdge.TOP);
      }
    }

    return ret;
  }
コード例 #2
0
ファイル: ColorBar.java プロジェクト: littlekai13/androidmcr
  /**
   * Reserves the space required to draw the color bar.
   *
   * @param g2 the graphics device.
   * @param plot the plot that the axis belongs to.
   * @param plotArea the area within which the plot should be drawn.
   * @param dataArea the data area.
   * @param edge the axis location.
   * @param space the space already reserved.
   * @return The space required to draw the axis in the specified plot area.
   */
  public AxisSpace reserveSpace(
      Graphics2D g2,
      Plot plot,
      Rectangle2D plotArea,
      Rectangle2D dataArea,
      RectangleEdge edge,
      AxisSpace space) {

    AxisSpace result = this.axis.reserveSpace(g2, plot, plotArea, edge, space);
    double thickness = calculateBarThickness(dataArea, edge);
    result.add(thickness + 2 * this.outerGap, edge);
    return result;
  }
コード例 #3
0
  /**
   * Estimates the space (height or width) required to draw the axis.
   *
   * @param g2 the graphics device.
   * @param plot the plot that the axis belongs to.
   * @param plotArea the area within which the plot (including axes) should be drawn.
   * @param edge the axis location.
   * @param space space already reserved.
   * @return The space required to draw the axis (including pre-reserved space).
   */
  @Override
  public AxisSpace reserveSpace(
      Graphics2D g2, Plot plot, Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) {
    // create a new space object if one wasn't supplied...
    if (space == null) {
      space = new AxisSpace();
    }

    // if the axis is not visible, no additional space is required...
    if (!isVisible()) {
      return space;
    }

    // if the axis has a fixed dimension, return it...
    double dimension = getFixedDimension();
    if (dimension > 0.0) {
      space.ensureAtLeast(dimension, edge);
    }

    // get the axis label size and update the space object...
    Rectangle2D labelEnclosure = getLabelEnclosure(g2, edge);
    double labelHeight = 0.0;
    double labelWidth = 0.0;
    double tickLabelBandsDimension = 0.0;

    for (PeriodAxisLabelInfo info : this.labelInfo) {
      FontMetrics fm = g2.getFontMetrics(info.getLabelFont());
      tickLabelBandsDimension += info.getPadding().extendHeight(fm.getHeight());
    }

    if (RectangleEdge.isTopOrBottom(edge)) {
      labelHeight = labelEnclosure.getHeight();
      space.add(labelHeight + tickLabelBandsDimension, edge);
    } else if (RectangleEdge.isLeftOrRight(edge)) {
      labelWidth = labelEnclosure.getWidth();
      space.add(labelWidth + tickLabelBandsDimension, edge);
    }

    // add space for the outer tick labels, if any...
    double tickMarkSpace = 0.0;
    if (isTickMarksVisible()) {
      tickMarkSpace = getTickMarkOutsideLength();
    }
    if (this.minorTickMarksVisible) {
      tickMarkSpace = Math.max(tickMarkSpace, this.minorTickMarkOutsideLength);
    }
    space.add(tickMarkSpace, edge);
    return space;
  }
コード例 #4
0
  /**
   * Estimates the space required for the axis, given a specific drawing area.
   *
   * @param g2 the graphics device (used to obtain font information).
   * @param plot the plot that the axis belongs to.
   * @param plotArea the area within which the axis should be drawn.
   * @param edge the axis location (top or bottom).
   * @param space the space already reserved.
   * @return The space required to draw the axis.
   */
  @Override
  public AxisSpace reserveSpace(
      Graphics2D g2, Plot plot, Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) {

    // create a new space object if one wasn't supplied...
    if (space == null) {
      space = new AxisSpace();
    }

    // if the axis is not visible, no additional space is required...
    if (!isVisible()) {
      return space;
    }

    // calculate the max size of the tick labels (if visible)...
    double tickLabelHeight = 0.0;
    double tickLabelWidth = 0.0;
    if (isTickLabelsVisible()) {
      g2.setFont(getTickLabelFont());
      AxisState state = new AxisState();
      // we call refresh ticks just to get the maximum width or height
      refreshTicks(g2, state, plotArea, edge);
      if (edge == RectangleEdge.TOP) {
        tickLabelHeight = state.getMax();
      } else if (edge == RectangleEdge.BOTTOM) {
        tickLabelHeight = state.getMax();
      } else if (edge == RectangleEdge.LEFT) {
        tickLabelWidth = state.getMax();
      } else if (edge == RectangleEdge.RIGHT) {
        tickLabelWidth = state.getMax();
      }
    }

    // get the axis label size and update the space object...
    Rectangle2D labelEnclosure = getLabelEnclosure(g2, edge);
    double labelHeight, labelWidth;
    if (RectangleEdge.isTopOrBottom(edge)) {
      labelHeight = labelEnclosure.getHeight();
      space.add(labelHeight + tickLabelHeight + this.categoryLabelPositionOffset, edge);
    } else if (RectangleEdge.isLeftOrRight(edge)) {
      labelWidth = labelEnclosure.getWidth();
      space.add(labelWidth + tickLabelWidth + this.categoryLabelPositionOffset, edge);
    }
    return space;
  }
コード例 #5
0
ファイル: SubCategoryAxis.java プロジェクト: nologic/nabs
  /**
   * Estimates the space required for the axis, given a specific drawing area.
   *
   * @param g2 the graphics device (used to obtain font information).
   * @param plot the plot that the axis belongs to.
   * @param plotArea the area within which the axis should be drawn.
   * @param edge the axis location (top or bottom).
   * @param space the space already reserved.
   * @return The space required to draw the axis.
   */
  public AxisSpace reserveSpace(
      Graphics2D g2, Plot plot, Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) {

    // create a new space object if one wasn't supplied...
    if (space == null) {
      space = new AxisSpace();
    }

    // if the axis is not visible, no additional space is required...
    if (!isVisible()) {
      return space;
    }

    space = super.reserveSpace(g2, plot, plotArea, edge, space);
    double maxdim = getMaxDim(g2, edge);
    if (RectangleEdge.isTopOrBottom(edge)) {
      space.add(maxdim, edge);
    } else if (RectangleEdge.isLeftOrRight(edge)) {
      space.add(maxdim, edge);
    }
    return space;
  }