Ejemplo n.º 1
0
 /**
  * Performs the layout with no constraint, so the content size is determined by the bounds of the
  * shape and/or line drawn to represent the series.
  *
  * @param g2 the graphics device.
  * @return The content size.
  */
 protected ArrangeResult arrangeNN(Graphics2D g2, ArrangeParams params) {
   Rectangle2D contentSize = new Rectangle2D.Double();
   if (this.line != null) {
     contentSize.setRect(this.line.getBounds2D());
   }
   if (this.shape != null) {
     contentSize = contentSize.createUnion(this.shape.getBounds2D());
   }
   ArrangeResult result = params.getRecyclableResult();
   if (result != null) {
     result.setSize(contentSize.getWidth(), contentSize.getHeight());
   } else {
     result = new ArrangeResult(contentSize.getWidth(), contentSize.getHeight(), null);
   }
   return result;
 }
Ejemplo n.º 2
0
  protected ArrangeResult arrangeFF(
      Graphics2D g2, double fixedWidth, double fixedHeight, ArrangeParams params) {

    Rectangle2D contentSize = new Rectangle2D.Double();
    if (this.line != null) {
      contentSize.setRect(this.line.getBounds2D());
    }
    if (this.shape != null) {
      contentSize = contentSize.createUnion(this.shape.getBounds2D());
    }
    // TODO: compare the contentSize to the required fixed size
    // and possibly log the problems
    ArrangeResult result = params.getRecyclableResult();
    if (result != null) {
      result.setSize(fixedWidth, fixedHeight);
    } else {
      result = new ArrangeResult(fixedWidth, fixedHeight, null);
    }
    return result;
  }
Ejemplo n.º 3
0
 /**
  * Arranges the contents of the block, within the given constraints, and returns the block size.
  *
  * @param g2 the graphics device.
  * @param constraint the constraint (<code>null</code> not permitted).
  * @param params the layout parameters (<code>null</code> not permitted).
  * @return The block size (in Java2D units, never <code>null</code>).
  */
 public ArrangeResult arrange(
     Graphics2D g2, RectangleConstraint constraint, ArrangeParams params) {
   RectangleConstraint contentConstraint = toContentConstraint(constraint);
   LengthConstraintType w = contentConstraint.getWidthConstraintType();
   LengthConstraintType h = contentConstraint.getHeightConstraintType();
   ArrangeResult result = null;
   if (w == LengthConstraintType.NONE) {
     if (h == LengthConstraintType.NONE) {
       result = arrangeNN(g2, params);
     } 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) {
       result = arrangeFF(g2, contentConstraint.getWidth(), contentConstraint.getHeight(), params);
     }
   }
   // TODO: review messaging here
   result.setSize(
       calculateTotalWidth(result.getWidth()), calculateTotalHeight(result.getHeight()));
   return result;
 }