Package com.positive.charts.util

Examples of com.positive.charts.util.Size2D


   */
  public Size2D arrange(final BlockContainer container, final GC g2,
      final RectangleConstraint constraint) {
    final RectangleConstraint contentConstraint = container
        .toContentConstraint(constraint);
    Size2D contentSize = null;
    final LengthConstraintType w = contentConstraint
        .getWidthConstraintType();
    final LengthConstraintType h = contentConstraint
        .getHeightConstraintType();
    if (w == LengthConstraintType.NONE) {
      if (h == LengthConstraintType.NONE) {
        contentSize = this.arrangeNN(container, g2);
      } else if (h == LengthConstraintType.FIXED) {
        throw new RuntimeException("Not implemented.");
      } else if (h == LengthConstraintType.RANGE) {
        throw new RuntimeException("Not implemented.");
      }
    } else if (w == LengthConstraintType.FIXED) {
      if (h == LengthConstraintType.NONE) {
        contentSize = this.arrangeFN(container, g2, constraint
            .getWidth());
      } else if (h == LengthConstraintType.FIXED) {
        contentSize = this.arrangeFF(container, g2, constraint);
      } else if (h == LengthConstraintType.RANGE) {
        contentSize = this.arrangeFR(container, g2, constraint);
      }
    } else if (w == LengthConstraintType.RANGE) {
      if (h == LengthConstraintType.NONE) {
        throw new RuntimeException("Not implemented.");
      } else if (h == LengthConstraintType.FIXED) {
        throw new RuntimeException("Not implemented.");
      } else if (h == LengthConstraintType.RANGE) {
        contentSize = this.arrangeRR(container, constraint
            .getWidthRange(), constraint.getHeightRange(), g2);
      }
    }
    return new Size2D(
        container.calculateTotalWidth(contentSize.getWidth()),
        container.calculateTotalHeight(contentSize.getHeight()));
  }
View Full Code Here


      g2.setFont(this.font);
      this.content = TextUtilities.createTextBlock(this.text, this.font,
          this.paint, maxWidth, this.maximumLinesToDisplay,
          new G2TextMeasurer(g2));
      this.content.setLineAlignment(this.textAlignment);
      final Size2D contentSize = this.content.calculateDimensions(g2);
      if (this.expandToFitSpace) {
        return new Size2D(maxWidth, contentSize.getHeight());
      } else {
        return contentSize;
      }
    } else if ((position == RectangleEdge.LEFT)
        || (position == RectangleEdge.RIGHT)) {
      final float maxWidth = Float.MAX_VALUE;
      g2.setFont(this.font);
      this.content = TextUtilities.createTextBlock(this.text, this.font,
          this.paint, maxWidth, this.maximumLinesToDisplay,
          new G2TextMeasurer(g2));
      this.content.setLineAlignment(this.textAlignment);
      final Size2D contentSize = this.content.calculateDimensions(g2);

      // transpose the dimensions, because the title is rotated
      if (this.expandToFitSpace) {
        return new Size2D(contentSize.getHeight(), maxWidth);
      } else {
        return new Size2D(contentSize.height, contentSize.width);
      }
    } else {
      throw new RuntimeException("Unrecognised exception.");
    }
  }
View Full Code Here

    w[0] = constraint.getWidth();
    if (this.topBlock != null) {
      final RectangleConstraint c1 = new RectangleConstraint(w[0], null,
          LengthConstraintType.FIXED, 0.0, new Range(0.0, constraint
              .getHeight()), LengthConstraintType.RANGE);
      final Size2D size = this.topBlock.arrange(g2, c1);
      h[0] = size.height;
    }
    w[1] = w[0];
    if (this.bottomBlock != null) {
      final RectangleConstraint c2 = new RectangleConstraint(w[0], null,
          LengthConstraintType.FIXED, 0.0, new Range(0.0, constraint
              .getHeight()
              - h[0]), LengthConstraintType.RANGE);
      final Size2D size = this.bottomBlock.arrange(g2, c2);
      h[1] = size.height;
    }
    h[2] = constraint.getHeight() - h[1] - h[0];
    if (this.leftBlock != null) {
      final RectangleConstraint c3 = new RectangleConstraint(0.0,
          new Range(0.0, constraint.getWidth()),
          LengthConstraintType.RANGE, h[2], null,
          LengthConstraintType.FIXED);
      final Size2D size = this.leftBlock.arrange(g2, c3);
      w[2] = size.width;
    }
    h[3] = h[2];
    if (this.rightBlock != null) {
      final RectangleConstraint c4 = new RectangleConstraint(
          0.0,
          new Range(0.0, Math.max(constraint.getWidth() - w[2], 0.0)),
          LengthConstraintType.RANGE, h[2], null,
          LengthConstraintType.FIXED);
      final Size2D size = this.rightBlock.arrange(g2, c4);
      w[3] = size.width;
    }
    h[4] = h[2];
    w[4] = constraint.getWidth() - w[3] - w[2];
    final RectangleConstraint c5 = new RectangleConstraint(w[4], h[4]);
    if (this.centerBlock != null) {
      this.centerBlock.arrange(g2, c5);
    }

    if (this.topBlock != null) {
      this.topBlock.setBounds(RectUtils.doubleRect(0.0, 0.0, w[0], h[0]));
    }
    if (this.bottomBlock != null) {
      this.bottomBlock.setBounds(RectUtils.doubleRect(0.0, h[0] + h[2],
          w[1], h[1]));
    }
    if (this.leftBlock != null) {
      this.leftBlock.setBounds(RectUtils
          .doubleRect(0.0, h[0], w[2], h[2]));
    }
    if (this.rightBlock != null) {
      this.rightBlock.setBounds(RectUtils.doubleRect(w[2] + w[4], h[0],
          w[3], h[3]));
    }
    if (this.centerBlock != null) {
      this.centerBlock.setBounds(RectUtils.doubleRect(w[2], h[0], w[4],
          h[4]));
    }
    return new Size2D(constraint.getWidth(), constraint.getHeight());
  }
View Full Code Here

    final double[] h = new double[5];
    final RectangleConstraint c1 = new RectangleConstraint(width, null,
        LengthConstraintType.FIXED, 0.0, null,
        LengthConstraintType.NONE);
    if (this.topBlock != null) {
      final Size2D size = this.topBlock.arrange(g2, c1);
      w[0] = size.width;
      h[0] = size.height;
    }
    if (this.bottomBlock != null) {
      final Size2D size = this.bottomBlock.arrange(g2, c1);
      w[1] = size.width;
      h[1] = size.height;
    }
    final RectangleConstraint c2 = new RectangleConstraint(0.0, new Range(
        0.0, width), LengthConstraintType.RANGE, 0.0, null,
        LengthConstraintType.NONE);
    if (this.leftBlock != null) {
      final Size2D size = this.leftBlock.arrange(g2, c2);
      w[2] = size.width;
      h[2] = size.height;
    }
    if (this.rightBlock != null) {
      final double maxW = Math.max(width - w[2], 0.0);
      final RectangleConstraint c3 = new RectangleConstraint(0.0,
          new Range(Math.min(w[2], maxW), maxW),
          LengthConstraintType.RANGE, 0.0, null,
          LengthConstraintType.NONE);
      final Size2D size = this.rightBlock.arrange(g2, c3);
      w[3] = size.width;
      h[3] = size.height;
    }

    h[2] = Math.max(h[2], h[3]);
    h[3] = h[2];

    if (this.centerBlock != null) {
      final RectangleConstraint c4 = new RectangleConstraint(width - w[2]
          - w[3], null, LengthConstraintType.FIXED, 0.0, null,
          LengthConstraintType.NONE);
      final Size2D size = this.centerBlock.arrange(g2, c4);
      w[4] = size.width;
      h[4] = size.height;
    }
    final double height = h[0] + h[1]
        + Math.max(h[2], Math.max(h[3], h[4]));
View Full Code Here

   *
   * @return The container size after the arrangement.
   */
  protected Size2D arrangeFR(final BlockContainer container, final GC g2,
      final RectangleConstraint constraint) {
    final Size2D size1 = this.arrangeFN(container, g2, constraint
        .getWidth());
    if (constraint.getHeightRange().contains(size1.getHeight())) {
      return size1;
    } else {
      final double h = constraint.getHeightRange().constrain(
          size1.getHeight());
      final RectangleConstraint c2 = constraint.toFixedHeight(h);
      return this.arrange(container, g2, c2);
    }
  }
View Full Code Here

   * @return The content size.
   *
   * @since 1.0.9
   */
  protected Size2D arrangeRN(final GC g2, final Range widthRange) {
    final Size2D s = this.arrangeNN(g2);
    if (widthRange.contains(s.getWidth())) {
      return s;
    }
    final double ww = widthRange.constrain(s.getWidth());
    return this.arrangeFN(g2, ww);
  }
View Full Code Here

   */
  protected Size2D arrangeNN(final BlockContainer container, final GC g2) {
    final double[] w = new double[5];
    final double[] h = new double[5];
    if (this.topBlock != null) {
      final Size2D size = this.topBlock.arrange(g2,
          RectangleConstraint.NONE);
      w[0] = size.width;
      h[0] = size.height;
    }
    if (this.bottomBlock != null) {
      final Size2D size = this.bottomBlock.arrange(g2,
          RectangleConstraint.NONE);
      w[1] = size.width;
      h[1] = size.height;
    }
    if (this.leftBlock != null) {
      final Size2D size = this.leftBlock.arrange(g2,
          RectangleConstraint.NONE);
      w[2] = size.width;
      h[2] = size.height;
    }
    if (this.rightBlock != null) {
      final Size2D size = this.rightBlock.arrange(g2,
          RectangleConstraint.NONE);
      w[3] = size.width;
      h[3] = size.height;
    }

    h[2] = Math.max(h[2], h[3]);
    h[3] = h[2];

    if (this.centerBlock != null) {
      final Size2D size = this.centerBlock.arrange(g2,
          RectangleConstraint.NONE);
      w[4] = size.width;
      h[4] = size.height;
    }
    final double width = Math.max(w[0], Math.max(w[1], w[2] + w[4] + w[3]));
    final double centerHeight = Math.max(h[2], Math.max(h[3], h[4]));
    final double height = h[0] + h[1] + centerHeight;
    if (this.topBlock != null) {
      this.topBlock
          .setBounds(new Rectangle(0, 0, (int) width, (int) h[0]));
    }
    if (this.bottomBlock != null) {
      this.bottomBlock.setBounds(RectUtils.doubleRect(0.0, height - h[1],
          width, h[1]));
    }
    if (this.leftBlock != null) {
      this.leftBlock.setBounds(RectUtils.doubleRect(0.0, h[0], w[2],
          centerHeight));
    }
    if (this.rightBlock != null) {
      this.rightBlock.setBounds(RectUtils.doubleRect(width - w[3], h[0],
          w[3], centerHeight));
    }

    if (this.centerBlock != null) {
      this.centerBlock.setBounds(RectUtils.doubleRect(w[2], h[0], width
          - w[2] - w[3], centerHeight));
    }
    return new Size2D(width, height);
  }
View Full Code Here

    final double[] w = new double[5];
    final double[] h = new double[5];
    if (this.topBlock != null) {
      final RectangleConstraint c1 = new RectangleConstraint(widthRange,
          heightRange);
      final Size2D size = this.topBlock.arrange(g2, c1);
      w[0] = size.width;
      h[0] = size.height;
    }
    if (this.bottomBlock != null) {
      final Range heightRange2 = Range.shift(heightRange, -h[0], false);
      final RectangleConstraint c2 = new RectangleConstraint(widthRange,
          heightRange2);
      final Size2D size = this.bottomBlock.arrange(g2, c2);
      w[1] = size.width;
      h[1] = size.height;
    }
    final Range heightRange3 = Range.shift(heightRange, -(h[0] + h[1]));
    if (this.leftBlock != null) {
      final RectangleConstraint c3 = new RectangleConstraint(widthRange,
          heightRange3);
      final Size2D size = this.leftBlock.arrange(g2, c3);
      w[2] = size.width;
      h[2] = size.height;
    }
    final Range widthRange2 = Range.shift(widthRange, -w[2], false);
    if (this.rightBlock != null) {
      final RectangleConstraint c4 = new RectangleConstraint(widthRange2,
          heightRange3);
      final Size2D size = this.rightBlock.arrange(g2, c4);
      w[3] = size.width;
      h[3] = size.height;
    }

    h[2] = Math.max(h[2], h[3]);
    h[3] = h[2];
    final Range widthRange3 = Range
        .shift(widthRange, -(w[2] + w[3]), false);
    if (this.centerBlock != null) {
      final RectangleConstraint c5 = new RectangleConstraint(widthRange3,
          heightRange3);
      final Size2D size = this.centerBlock.arrange(g2, c5);
      w[4] = size.width;
      h[4] = size.height;
    }
    final double width = Math.max(w[0], Math.max(w[1], w[2] + w[4] + w[3]));
    final double height = h[0] + h[1]
        + Math.max(h[2], Math.max(h[3], h[4]));
    if (this.topBlock != null) {
      this.topBlock
          .setBounds(RectUtils.doubleRect(0.0, 0.0, width, h[0]));
    }
    if (this.bottomBlock != null) {
      this.bottomBlock.setBounds(RectUtils.doubleRect(0.0, height - h[1],
          width, h[1]));
    }
    if (this.leftBlock != null) {
      this.leftBlock.setBounds(RectUtils
          .doubleRect(0.0, h[0], w[2], h[2]));
    }
    if (this.rightBlock != null) {
      this.rightBlock.setBounds(RectUtils.doubleRect(width - w[3], h[0],
          w[3], h[3]));
    }

    if (this.centerBlock != null) {
      this.centerBlock.setBounds(RectUtils.doubleRect(w[2], h[0], width
          - w[2] - w[3], height - h[0] - h[1]));
    }
    return new Size2D(width, height);
  }
View Full Code Here

      g2.setFont(this.font);
      this.content = TextUtilities.createTextBlock(this.text, this.font,
          this.paint, maxWidth, this.maximumLinesToDisplay,
          new G2TextMeasurer(g2));
      this.content.setLineAlignment(this.textAlignment);
      final Size2D contentSize = this.content.calculateDimensions(g2);
      if (this.expandToFitSpace) {
        return new Size2D(maxWidth, contentSize.getHeight());
      } else {
        return contentSize;
      }
    } else if ((position == RectangleEdge.LEFT)
        || (position == RectangleEdge.RIGHT)) {
      final float maxWidth = (float) heightRange.getUpperBound();
      g2.setFont(this.font);
      this.content = TextUtilities.createTextBlock(this.text, this.font,
          this.paint, maxWidth, this.maximumLinesToDisplay,
          new G2TextMeasurer(g2));
      this.content.setLineAlignment(this.textAlignment);
      final Size2D contentSize = this.content.calculateDimensions(g2);

      // transpose the dimensions, because the title is rotated
      if (this.expandToFitSpace) {
        return new Size2D(contentSize.getHeight(), maxWidth);
      } else {
        return new Size2D(contentSize.height, contentSize.width);
      }
    } else {
      throw new RuntimeException("Unrecognised exception.");
    }
  }
View Full Code Here

  protected Size2D arrangeFN(final BlockContainer container, final GC g2,
      final RectangleConstraint constraint) {

    final List blocks = container.getBlocks();
    final Block b = (Block) blocks.get(0);
    final Size2D s = b.arrange(g2, RectangleConstraint.NONE);
    final double width = constraint.getWidth();
    final Rectangle bounds = new Rectangle(
        (int) ((int) (width - s.width) / 2.0), 0, (int) s.width,
        (int) s.height);
    b.setBounds(bounds);
    return new Size2D((width - s.width) / 2.0, s.height);
  }
View Full Code Here

TOP

Related Classes of com.positive.charts.util.Size2D

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.