Calculates the size based constraint width and height if present, otherwise from children sizes.
347755
public void calculateSize(PdfContext context) {
		float width = 0;
		float height = 0;
		for (PrintComponent<?> child : children) {
			child.calculateSize(context);
			float cw = child.getBounds().getWidth() + 2 * child.getConstraint().getMarginX();
			float ch = child.getBounds().getHeight() + 2 * child.getConstraint().getMarginY();
			switch (getConstraint().getFlowDirection()) {
				case LayoutConstraint.FLOW_NONE:
					width = Math.max(width, cw);
					height = Math.max(height, ch);
					break;
				case LayoutConstraint.FLOW_X:
					width += cw;
					height = Math.max(height, ch);
					break;
				case LayoutConstraint.FLOW_Y:
					width = Math.max(width, cw);
					height += ch;
					break;
				default:
					throw new IllegalStateException("Unknown flow direction " + getConstraint().getFlowDirection());
			}
		}
		if (getConstraint().getWidth() != 0) {
			width = getConstraint().getWidth();
		}
		if (getConstraint().getHeight() != 0) {
			height = getConstraint().getHeight();
		}
		setBounds(new Rectangle(0, 0, width, height));
	}
1315052
def size_as_drawn(lines, screen_width):
    """"""
    y = 0
    x = 0
    for line in lines:
        wrapped = list(wc_wrap(line, screen_width))
        if len(wrapped) > 0:
            for wrapped_line in wrapped:
                x = len(wrapped_line)
                y += 1
        else:
            x = 0
            y += 1
    return y - 1, x - 1 if x != 0 else 0
192719
def get_size(self):
        
        rec = self.get_rectangle()
        return (int(rec[2]-rec[0]), int(rec[3]-rec[1]))
1186633
def set_size(params = {})
      @width    = params[:width]    if params[:width]
      @height   = params[:height]   if params[:height]
      @x_scale  = params[:x_scale]  if params[:x_scale]
      @y_scale  = params[:y_scale]  if params[:y_scale]
      @x_offset = params[:x_offset] if params[:x_offset]
      @y_offset = params[:y_offset] if params[:y_offset]
    end
531868
def calculate_size(name, entries):
    
    data_size = 0
    data_size += calculate_size_str(name)
    data_size += INT_SIZE_IN_BYTES
    for key, val in six.iteritems(entries):
        data_size += calculate_size_data(key)
        data_size += calculate_size_data(val)
    return data_size
498991
def _compute_zones_sizes(self):
        """"""
        # Left panels
        left = 0
        for panel in self.panels_for_zone(Panel.Position.LEFT):
            if not panel.isVisible():
                continue
            size_hint = panel.sizeHint()
            left += size_hint.width()
        # Right panels
        right = 0
        for panel in self.panels_for_zone(Panel.Position.RIGHT):
            if not panel.isVisible():
                continue
            size_hint = panel.sizeHint()
            right += size_hint.width()
        # Top panels
        top = 0
        for panel in self.panels_for_zone(Panel.Position.TOP):
            if not panel.isVisible():
                continue
            size_hint = panel.sizeHint()
            top += size_hint.height()
        # Bottom panels
        bottom = 0
        for panel in self.panels_for_zone(Panel.Position.BOTTOM):
            if not panel.isVisible():
                continue
            size_hint = panel.sizeHint()
            bottom += size_hint.height()
        self._top, self._left, self._right, self._bottom = (
            top, left, right, bottom)
        return bottom, left, right, top
68506
protected function _calculate_restricted_height()
    {
        $frame = $this->_frame;
        $style = $frame->get_style();
        $content_height = $this->_calculate_content_height();
        $cb = $frame->get_containing_block();

        $height = $style->length_in_pt($style->height, $cb["h"]);

        $top = $style->length_in_pt($style->top, $cb["h"]);
        $bottom = $style->length_in_pt($style->bottom, $cb["h"]);

        $margin_top = $style->length_in_pt($style->margin_top, $cb["h"]);
        $margin_bottom = $style->length_in_pt($style->margin_bottom, $cb["h"]);

        if ($frame->is_absolute()) {

            // see http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-height

            $dims = array($top !== "auto" ? $top : 0,
                $style->margin_top !== "auto" ? $style->margin_top : 0,
                $style->padding_top,
                $style->border_top_width,
                $height !== "auto" ? $height : 0,
                $style->border_bottom_width,
                $style->padding_bottom,
                $style->margin_bottom !== "auto" ? $style->margin_bottom : 0,
                $bottom !== "auto" ? $bottom : 0);

            $sum = (float)$style->length_in_pt($dims, $cb["h"]);

            $diff = $cb["h"] - $sum;

            if ($diff > 0) {
                if ($height === "auto" && $top === "auto" && $bottom === "auto") {
                    if ($margin_top === "auto") {
                        $margin_top = 0;
                    }
                    if ($margin_bottom === "auto") {
                        $margin_bottom = 0;
                    }

                    $height = $diff;
                } else if ($height === "auto" && $top === "auto") {
                    if ($margin_top === "auto") {
                        $margin_top = 0;
                    }
                    if ($margin_bottom === "auto") {
                        $margin_bottom = 0;
                    }

                    $height = $content_height;
                    $top = $diff - $content_height;
                } else if ($height === "auto" && $bottom === "auto") {
                    if ($margin_top === "auto") {
                        $margin_top = 0;
                    }
                    if ($margin_bottom === "auto") {
                        $margin_bottom = 0;
                    }

                    $height = $content_height;
                    $bottom = $diff - $content_height;
                } else if ($top === "auto" && $bottom === "auto") {
                    if ($margin_top === "auto") {
                        $margin_top = 0;
                    }
                    if ($margin_bottom === "auto") {
                        $margin_bottom = 0;
                    }

                    $bottom = $diff;
                } else if ($top === "auto") {
                    if ($margin_top === "auto") {
                        $margin_top = 0;
                    }
                    if ($margin_bottom === "auto") {
                        $margin_bottom = 0;
                    }

                    $top = $diff;
                } else if ($height === "auto") {
                    if ($margin_top === "auto") {
                        $margin_top = 0;
                    }
                    if ($margin_bottom === "auto") {
                        $margin_bottom = 0;
                    }

                    $height = $diff;
                } else if ($bottom === "auto") {
                    if ($margin_top === "auto") {
                        $margin_top = 0;
                    }
                    if ($margin_bottom === "auto") {
                        $margin_bottom = 0;
                    }

                    $bottom = $diff;
                } else {
                    if ($style->overflow === "visible") {
                        // set all autos to zero
                        if ($margin_top === "auto") {
                            $margin_top = 0;
                        }
                        if ($margin_bottom === "auto") {
                            $margin_bottom = 0;
                        }
                        if ($top === "auto") {
                            $top = 0;
                        }
                        if ($bottom === "auto") {
                            $bottom = 0;
                        }
                        if ($height === "auto") {
                            $height = $content_height;
                        }
                    }

                    // FIXME: overflow hidden
                }
            }

        } else {
            // Expand the height if overflow is visible
            if ($height === "auto" && $content_height > $height /* && $style->overflow === "visible" */) {
                $height = $content_height;
            }

            // FIXME: this should probably be moved to a seperate function as per
            // _calculate_restricted_width

            // Only handle min/max height if the height is independent of the frame's content
            if (!($style->overflow === "visible" || ($style->overflow === "hidden" && $height === "auto"))) {
                $min_height = $style->min_height;
                $max_height = $style->max_height;

                if (isset($cb["h"])) {
                    $min_height = $style->length_in_pt($min_height, $cb["h"]);
                    $max_height = $style->length_in_pt($max_height, $cb["h"]);
                } else if (isset($cb["w"])) {
                    if (mb_strpos($min_height, "%") !== false) {
                        $min_height = 0;
                    } else {
                        $min_height = $style->length_in_pt($min_height, $cb["w"]);
                    }

                    if (mb_strpos($max_height, "%") !== false) {
                        $max_height = "none";
                    } else {
                        $max_height = $style->length_in_pt($max_height, $cb["w"]);
                    }
                }

                if ($max_height !== "none" && $min_height > $max_height) {
                    // Swap 'em
                    list($max_height, $min_height) = array($min_height, $max_height);
                }

                if ($max_height !== "none" && $height > $max_height) {
                    $height = $max_height;
                }

                if ($height < $min_height) {
                    $height = $min_height;
                }
            }
        }

        return array($height, $margin_top, $margin_bottom, $top, $bottom);
    }
134156
def calculate_size(name, expected, updated):
    
    data_size = 0
    data_size += calculate_size_str(name)
    data_size += LONG_SIZE_IN_BYTES
    data_size += LONG_SIZE_IN_BYTES
    return data_size
496359
def get_minimum_size(self, data):
        """"""
        width = 0
        min_height = 0
        for element in self.elements:
            size = element.get_minimum_size(data)
            min_height = max(min_height, size.y)
            width += size.x
        width += (len(self.elements)-1)*self.margin
        return datatypes.Point(width, min_height)
361891
def get_minimum_size(self, data):
        """"""
        min_width = 0
        min_height = 0
        for element in self.elements:
            size = (
                datatypes.Point(0, 0) if element is None
                else element.get_minimum_size(data)
                )
            min_height = max(min_height, size.y)
            min_width = max(min_width, size.x)

        num_elements = len(self.elements)
        height = min_height * num_elements + self.margin * (num_elements-1)
        return datatypes.Point(min_width, height)
11466
def get_size( self ):
        """"""
        klass = self.__class__
        size = 0
        for name in klass._fields:
            size = max( size, klass._fields[name].get_end_offset( self._field_data[name], parent=self ) )
        for check in klass._checks.values():
            size = max( size, check.get_end_offset( parent=self ) )
        return size
962195
public void adjustChildren(int widthMeasureSpec, int heightMeasureSpec) {
        if (Log.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, "adjustChildren: " + mHost + " widthMeasureSpec: "
                    + View.MeasureSpec.toString(widthMeasureSpec) + " heightMeasureSpec: "
                    + View.MeasureSpec.toString(heightMeasureSpec));
        }

        int widthHint = View.MeasureSpec.getSize(widthMeasureSpec);
        int heightHint = View.MeasureSpec.getSize(heightMeasureSpec);
        for (int i = 0, N = mHost.getChildCount(); i < N; i++) {
            View view = mHost.getChildAt(i);
            ViewGroup.LayoutParams params = view.getLayoutParams();
            if (Log.isLoggable(TAG, Log.DEBUG)) {
                Log.d(TAG, "should adjust " + view + " " + params);
            }
            if (params instanceof PercentLayoutParams) {
                PercentLayoutInfo info =
                        ((PercentLayoutParams) params).getPercentLayoutInfo();
                if (Log.isLoggable(TAG, Log.DEBUG)) {
                    Log.d(TAG, "using " + info);
                }
                if (info != null) {
                    if (params instanceof ViewGroup.MarginLayoutParams) {
                        info.fillMarginLayoutParams((ViewGroup.MarginLayoutParams) params,
                                widthHint, heightHint);
                    } else {
                        info.fillLayoutParams(params, widthHint, heightHint);
                    }
                }
            }
        }
    }
960637
protected function _calculate_height()
    {
        $style = $this->_frame->get_style();
        $height = $style->height;

        $cellmap = $this->_frame->get_cellmap();
        $cellmap->assign_frame_heights();
        $rows = $cellmap->get_rows();

        // Determine our content height
        $content_height = 0;
        foreach ($rows as $r) {
            $content_height += $r["height"];
        }

        $cb = $this->_frame->get_containing_block();

        if (!($style->overflow === "visible" ||
            ($style->overflow === "hidden" && $height === "auto"))
        ) {
            // Only handle min/max height if the height is independent of the frame's content

            $min_height = $style->min_height;
            $max_height = $style->max_height;

            if (isset($cb["h"])) {
                $min_height = $style->length_in_pt($min_height, $cb["h"]);
                $max_height = $style->length_in_pt($max_height, $cb["h"]);

            } else if (isset($cb["w"])) {
                if (mb_strpos($min_height, "%") !== false) {
                    $min_height = 0;
                } else {
                    $min_height = $style->length_in_pt($min_height, $cb["w"]);
                }
                if (mb_strpos($max_height, "%") !== false) {
                    $max_height = "none";
                } else {
                    $max_height = $style->length_in_pt($max_height, $cb["w"]);
                }
            }

            if ($max_height !== "none" && $min_height > $max_height) {
                // Swap 'em
                list($max_height, $min_height) = array($min_height, $max_height);
            }

            if ($max_height !== "none" && $height > $max_height) {
                $height = $max_height;
            }

            if ($height < $min_height) {
                $height = $min_height;
            }
        } else {
            // Use the content height or the height value, whichever is greater
            if ($height !== "auto") {
                $height = $style->length_in_pt($height, $cb["h"]);

                if ($height <= $content_height) {
                    $height = $content_height;
                } else {
                    $cellmap->set_frame_heights($height, $content_height);
                }
            } else {
                $height = $content_height;
            }
        }

        return $height;
    }
250196
def check_sizes(size, width, height):
    
    if not size:
        return width, height

    if len(size) != 2:
        raise ValueError(
          "size argument should be a pair (width, height)")
    if width is not None and width != size[0]:
        raise ValueError(
          "size[0] (%r) and width (%r) should match when both are used."
          % (size[0], width))
    if height is not None and height != size[1]:
        raise ValueError(
          "size[1] (%r) and height (%r) should match when both are used."
          % (size[1], height))
    return size
114979
def calculate_size(name, id):
    
    data_size = 0
    data_size += calculate_size_str(name)
    data_size += calculate_size_str(id)
    return data_size
352430
protected DimenInfo computeDimens (Container parent, int type) {
        int count = parent.getComponentCount();
        DimenInfo info = new DimenInfo();
        info.dimens = new Dimension[count];

        for (int i = 0; i < count; i++) {
            Component child = parent.getComponent(i);
            if (!child.isVisible()) {
                continue;
            }

            Dimension csize;
            switch  (type) {
            case MINIMUM:
                csize = child.getMinimumSize();
                break;

            case MAXIMUM:
                csize = child.getMaximumSize();
                break;

            default:
                csize = child.getPreferredSize();
                break;
            }

            info.count++;
            info.totwid += csize.width;
            info.tothei += csize.height;

            if (csize.width > info.maxwid) {
                info.maxwid = csize.width;
            }
            if (csize.height > info.maxhei) {
                info.maxhei = csize.height;
            }

            Constraints c = getConstraints(child);
            if (c.isFixed()) {
                info.fixwid += csize.width;
                info.fixhei += csize.height;
                info.numfix++;

            } else {
                info.totweight += c.getWeight();

                if (csize.width > info.maxfreewid) {
                    info.maxfreewid = csize.width;
                }
                if (csize.height > info.maxfreehei) {
                    info.maxfreehei = csize.height;
                }
            }

            info.dimens[i] = csize;
        }

        return info;
    }
518655
def size(self):
        """"""
        width = max(
            map(lambda x: x.size()[0], self.sections.itervalues()))

        height = sum(
            map(lambda x: x.size()[1], self.sections.itervalues()))

        return width, height