Package com.positive.charts.util

Examples of com.positive.charts.util.Size2D


   *            the constraint (<code>null</code> not permitted).
   *
   * @return The block size (in Java2D units, never <code>null</code>).
   */
  public Size2D arrange(final GC g2, final RectangleConstraint constraint) {
    final Size2D result = new Size2D();
    this.fetchLegendItems();
    if (this.items.isEmpty()) {
      return result;
    }
    BlockContainer container = this.wrapper;
    if (container == null) {
      container = this.items;
    }
    final RectangleConstraint c = this.toContentConstraint(constraint);
    final Size2D size = container.arrange(g2, c);
    result.height = this.calculateTotalHeight(size.height);
    result.width = this.calculateTotalWidth(size.width);
    return result;
  }
View Full Code Here


    double y = 0.0;
    double maxHeight = 0.0;
    final List itemsInRow = new ArrayList();
    for (int i = 0; i < blocks.size(); i++) {
      final Block block = (Block) blocks.get(i);
      final Size2D size = block.arrange(g2, RectangleConstraint.NONE);
      if (x + size.width <= width) {
        itemsInRow.add(block);
        block.setBounds(RectUtils.doubleRect(x, y, size.width,
            size.height));
        x = x + size.width + this.horizontalGap;
        maxHeight = Math.max(maxHeight, size.height);
      } else {
        if (itemsInRow.isEmpty()) {
          // place in this row (truncated) anyway
          block.setBounds(RectUtils.doubleRect(x, y, Math.min(
              size.width, width - x), size.height));
          x = 0.0;
          y = y + size.height + this.verticalGap;
        } else {
          // start new row
          itemsInRow.clear();
          x = 0.0;
          y = y + maxHeight + this.verticalGap;
          maxHeight = size.height;
          block.setBounds(RectUtils.doubleRect(x, y, Math.min(
              size.width, width), size.height));
          x = size.width + this.horizontalGap;
          itemsInRow.add(block);
        }
      }
    }
    return new Size2D(constraint.getWidth(), y + maxHeight);
  }
View Full Code Here

   * @return The size following the arrangement.
   */
  protected Size2D arrangeFR(final BlockContainer container, final GC g2,
      final RectangleConstraint constraint) {

    final Size2D s = this.arrangeFN(container, g2, constraint);
    if (constraint.getHeightRange().contains(s.height)) {
      return s;
    } else {
      final RectangleConstraint c = constraint.toFixedHeight(constraint
          .getHeightRange().constrain(s.getHeight()));
      return this.arrangeFF(container, g2, c);
    }
  }
View Full Code Here

            // TODO: shift block down to bottom
          }
        }
      }
    }
    return new Size2D(width, maxHeight);
  }
View Full Code Here

   * @return The size following the arrangement.
   */
  protected Size2D arrangeRF(final BlockContainer container, final GC g2,
      final RectangleConstraint constraint) {

    final Size2D s = this.arrangeNF(container, g2, constraint);
    if (constraint.getWidthRange().contains(s.width)) {
      return s;
    } else {
      final RectangleConstraint c = constraint.toFixedWidth(constraint
          .getWidthRange().constrain(s.getWidth()));
      return this.arrangeFF(container, g2, c);
    }
  }
View Full Code Here

   */
  protected Size2D arrangeRN(final BlockContainer container, final GC g2,
      final RectangleConstraint constraint) {
    // first arrange without constraints, then see if the width fits
    // within the required range...if not, call arrangeFN() at max width
    final Size2D s1 = this.arrangeNN(container, g2);
    if (constraint.getWidthRange().contains(s1.width)) {
      return s1;
    } else {
      final RectangleConstraint c = constraint.toFixedWidth(constraint
          .getWidthRange().getUpperBound());
View Full Code Here

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

    // first arrange without constraints, and see if this fits within
    // the required ranges...
    final Size2D s1 = this.arrangeNN(container, g2);
    if (constraint.getWidthRange().contains(s1.width)) {
      return s1; // TODO: we didn't check the height yet
    } else {
      final RectangleConstraint c = constraint.toFixedWidth(constraint
          .getWidthRange().getUpperBound());
View Full Code Here

        .toContentConstraint(constraint);
    final LengthConstraintType w = contentConstraint
        .getWidthConstraintType();
    final LengthConstraintType h = contentConstraint
        .getHeightConstraintType();
    Size2D contentSize = null;
    if (w == LengthConstraintType.NONE) {
      if (h == LengthConstraintType.NONE) {
        contentSize = this.arrangeNN(g2);
      } else if (h == LengthConstraintType.RANGE) {
        throw new RuntimeException("Not yet implemented.");
      } else if (h == LengthConstraintType.FIXED) {
        throw new RuntimeException("Not yet implemented.");
      }
    } else if (w == LengthConstraintType.RANGE) {
      if (h == LengthConstraintType.NONE) {
        throw new RuntimeException("Not yet implemented.");
      } else if (h == LengthConstraintType.RANGE) {
        throw new RuntimeException("Not yet implemented.");
      } else if (h == LengthConstraintType.FIXED) {
        throw new RuntimeException("Not yet implemented.");
      }
    } else if (w == LengthConstraintType.FIXED) {
      if (h == LengthConstraintType.NONE) {
        throw new RuntimeException("Not yet implemented.");
      } else if (h == LengthConstraintType.RANGE) {
        throw new RuntimeException("Not yet implemented.");
      } else if (h == LengthConstraintType.FIXED) {
        contentSize = new Size2D(contentConstraint.getWidth(),
            contentConstraint.getHeight());
      }
    }
    return new Size2D(this.calculateTotalWidth(contentSize.getWidth()),
        this.calculateTotalHeight(contentSize.getHeight()));
  }
View Full Code Here

   * @return The content size.
   */
  protected Size2D arrangeNN(final GC g2) {
    Rectangle contentSize = null;
    if (this.line != null) {
      return new Size2D(this.line.width, this.line.height);
    }
    if (this.shape != null) {
      contentSize = RectangleUtil.createUnion(this.line, this.shape);
    }
    return new Size2D(contentSize.width, contentSize.height);
  }
View Full Code Here

   *            the base size.
   *
   * @return The constrained size.
   */
  public Size2D calculateConstrainedSize(final Size2D base) {
    final Size2D result = new Size2D();
    if (this.widthConstraintType == LengthConstraintType.NONE) {
      result.width = base.width;
      if (this.heightConstraintType == LengthConstraintType.NONE) {
        result.height = base.height;
      } else if (this.heightConstraintType == LengthConstraintType.RANGE) {
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.