Package com.positive.charts.block

Examples of com.positive.charts.block.RectangleInsets


   * @return The width.
   */
  protected double calculateTextBlockWidth(final TextBlock block,
      final CategoryLabelPosition position, final GC g2) {

    final RectangleInsets insets = this.getTickLabelInsets();
    final Size2D size = block.calculateDimensions(g2);
    final Rectangle box = RectangleUtil.Double(0.0, 0.0, size.width,
        size.height);
    // TODO : support rotation
    // Shape rotatedBox = ShapeUtilities.rotateShape(
    // box, position.getAngle(), 0.0f, 0.0f
    // );
    final Rectangle rotatedBox = box;
    final double w = rotatedBox.width + insets.getTop()
        + insets.getBottom();
    return w;

  }
View Full Code Here


    }

    // Font font = getLabelFont();
    // g2.setFont(font);
    // g2.setPaint(getLabelPaint());
    final RectangleInsets insets = this.getLabelInsets();
    final Rectangle labelBounds = TextUtilities.getTextBounds(label, g2);

    double labelx, labely;

    if (edge == RectangleEdge.TOP) {
      labelx = RectangleUtil.getCenterX(dataArea);
      labely = state.getCursor() - insets.getBottom()
          - labelBounds.height / 2.0;
      TextUtilities.drawRotatedString(label, g2, (float) labelx,
          (float) labely, TextAnchor.CENTER, this.getLabelAngle(),
          TextAnchor.CENTER);
      state.cursorUp(insets.getTop() + labelBounds.height
          + insets.getBottom());
    } else if (edge == RectangleEdge.BOTTOM) {
      labelx = RectangleUtil.getCenterX(dataArea);
      labely = state.getCursor() + insets.getTop() + labelBounds.height
          / 2.0;
      TextUtilities.drawRotatedString(label, g2, (float) labelx,
          (float) labely, TextAnchor.CENTER, this.getLabelAngle(),
          TextAnchor.CENTER);
      state.cursorDown(insets.getTop() + labelBounds.height
          + insets.getBottom());
    } else if (edge == RectangleEdge.LEFT) {
      this.swapWidthAndHeight(labelBounds);

      labelx = state.getCursor() - insets.getRight() - labelBounds.width
          / 2.0;
      labely = RectangleUtil.getCenterY(dataArea);
      TextUtilities.drawRotatedString(label, g2, (float) labelx,
          (float) labely, TextAnchor.CENTER, this.getLabelAngle()
              - Math.PI / 2.0, TextAnchor.BOTTOM_CENTER);
      state.cursorLeft(insets.getLeft() + labelBounds.width
          + insets.getRight());
    } else if (edge == RectangleEdge.RIGHT) {
      this.swapWidthAndHeight(labelBounds);

      labelx = state.getCursor() + insets.getLeft() + labelBounds.width
          / 2.0;
      labely = RectangleUtil.getCenterY(dataArea);
      TextUtilities.drawRotatedString(label, g2, (float) labelx,
          (float) labely, TextAnchor.CENTER, this.getLabelAngle()
              + Math.PI / 2.0, TextAnchor.BOTTOM_CENTER);
      state.cursorRight(insets.getLeft() + labelBounds.width
          + insets.getRight());
    }

    return state;
  }
View Full Code Here

    final String axisLabel = this.getLabel();
    if ((axisLabel != null) && (axisLabel.length() != 0)) {
      g2.setFont(this.getLabelFont());
      final Point textExtent = g2.textExtent(axisLabel);
      Rectangle bounds = new Rectangle(0, 0, textExtent.x, textExtent.y);
      final RectangleInsets insets = this.getLabelInsets();
      bounds = insets.createOutsetRectangle(bounds);

      final Rectangle labelBounds = bounds;
      if (edge.isLeftOrRight()) {
        // Rotated 90 degrees, so swap width and height.
        this.swapWidthAndHeight(labelBounds);
View Full Code Here

   * @return The estimated maximum width of the tick labels.
   */
  private double estimateMaximumTickLabelHeight(final GC g2,
      final DateTickUnit unit) {

    final RectangleInsets tickLabelInsets = this.getTickLabelInsets();
    double result = tickLabelInsets.getTop() + tickLabelInsets.getBottom();

    final Font tickLabelFont = this.getTickLabelFont();
    g2.setFont(tickLabelFont);
    final FontMetrics lm = g2.getFontMetrics();
    if (!this.isVerticalTickLabels()) {
View Full Code Here

   * @return The estimated maximum width of the tick labels.
   */
  private double estimateMaximumTickLabelWidth(final GC g2,
      final DateTickUnit unit) {

    final RectangleInsets tickLabelInsets = this.getTickLabelInsets();
    double result = tickLabelInsets.getLeft() + tickLabelInsets.getRight();

    final Font tickLabelFont = this.getTickLabelFont();
    g2.setFont(tickLabelFont);
    // FontRenderContext frc = g2.getFontRenderContext();
    // LineMetrics lm = tickLabelFont.getLineMetrics("ABCxyz", frc);
View Full Code Here

   * @return The anchor point.
   */
  protected Point calculateAnchorPoint(final ValueTick tick,
      final double cursor, final Rectangle dataArea,
      final RectangleEdge edge) {
    final RectangleInsets insets = this.getTickLabelInsets();
    // FIXME Convert these routines to use integers
    final float[] result = new float[2];

    if (edge == RectangleEdge.TOP) {
      result[0] = (float) this.valueToJava2D(tick.getValue(), dataArea,
          edge);
      result[1] = (float) (cursor - insets.getBottom() - 2.0);
    } else if (edge == RectangleEdge.BOTTOM) {
      result[0] = (float) this.valueToJava2D(tick.getValue(), dataArea,
          edge);
      result[1] = (float) (cursor + insets.getTop() + 2.0);
    } else if (edge == RectangleEdge.LEFT) {
      result[0] = (float) (cursor - insets.getLeft() - 2.0);
      result[1] = (float) this.valueToJava2D(tick.getValue(), dataArea,
          edge);
    } else if (edge == RectangleEdge.RIGHT) {
      result[0] = (float) (cursor + insets.getRight() + 2.0);
      result[1] = (float) this.valueToJava2D(tick.getValue(), dataArea,
          edge);
    }
    return new Point((int) result[0], (int) result[1]);
  }
View Full Code Here

   *
   * @return The height of the tallest tick label.
   */
  protected int findMaximumTickLabelHeight(final List ticks, final GC g2,
      final Rectangle drawArea, final boolean vertical) {
    final RectangleInsets insets = this.getTickLabelInsets();
    final Font font = this.getTickLabelFont();
    int maxHeight = 0;
    g2.setFont(font);
    final FontMetrics fm = g2.getFontMetrics();
    if (vertical) {
      for (final Iterator iter = ticks.iterator(); iter.hasNext();) {
        final ITick tick = (ITick) iter.next();
        final Point extent = g2.textExtent(tick.getText());
        maxHeight = Math.max(maxHeight, extent.x + insets.getTop()
            + insets.getBottom());
      }
    } else {
      maxHeight = fm.getHeight() + insets.getTop() + insets.getBottom();
    }
    return maxHeight;

  }
View Full Code Here

   *
   * @return The width of the tallest tick label.
   */
  protected int findMaximumTickLabelWidth(final List ticks, final GC g2,
      final Rectangle drawArea, final boolean vertical) {
    final RectangleInsets insets = this.getTickLabelInsets();
    final Font font = this.getTickLabelFont();
    int maxWidth = 0;
    g2.setFont(font);
    final FontMetrics fm = g2.getFontMetrics();
    if (!vertical) {
      for (final Iterator iter = ticks.iterator(); iter.hasNext();) {
        final ITick tick = (ITick) iter.next();
        final Point extent = g2.textExtent(tick.getText());
        maxWidth = Math.max(maxWidth, extent.x + insets.getLeft()
            + insets.getRight());
      }
    } else {
      maxWidth = fm.getHeight() + insets.getTop() + insets.getBottom();
    }
    return maxWidth;

  }
View Full Code Here

   *            the graphics device.
   *
   * @return The maximum height.
   */
  protected double estimateMaximumTickLabelHeight(final GC g2) {
    final RectangleInsets tickLabelInsets = this.getTickLabelInsets();
    double result = tickLabelInsets.getTop() + tickLabelInsets.getBottom();

    final Font tickLabelFont = this.getTickLabelFont();
    g2.setFont(tickLabelFont);
    result += g2.getFontMetrics().getHeight();
    return result;
View Full Code Here

   *
   * @return The estimated maximum width of the tick labels.
   */
  protected double estimateMaximumTickLabelWidth(final GC gc,
      final TickUnit unit) {
    final RectangleInsets tickLabelInsets = this.getTickLabelInsets();
    double result = tickLabelInsets.getLeft() + tickLabelInsets.getRight();

    if (this.isVerticalTickLabels()) {
      // all tick labels have the same width (equal to the height of the
      // font)...
      result += gc.getFontMetrics().getHeight();
View Full Code Here

TOP

Related Classes of com.positive.charts.block.RectangleInsets

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.