当前位置: 首页>>代码示例>>Java>>正文


Java CGSize.getHeight方法代码示例

本文整理汇总了Java中org.robovm.apple.coregraphics.CGSize.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java CGSize.getHeight方法的具体用法?Java CGSize.getHeight怎么用?Java CGSize.getHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.robovm.apple.coregraphics.CGSize的用法示例。


在下文中一共展示了CGSize.getHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSizeThatFits

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
@Override
public CGSize getSizeThatFits(CGSize cgSize) {
    UIView lastChild = getSubviews().last();

    MarginLayoutParams layoutParams = (MarginLayoutParams) UIViewLayoutUtil.getLayoutParams(lastChild);
    LayoutMeasureSpec widthSpec = new LayoutMeasureSpec(cgSize.getWidth(), LayoutMeasureSpecMode.Unspecified);
    LayoutMeasureSpec heightSpec = new LayoutMeasureSpec(cgSize.getHeight(), LayoutMeasureSpecMode.Unspecified);

    if(layoutParams.getWidth() == LayoutParamsSize.MatchParent.getValue()) {
        widthSpec.setMode(LayoutMeasureSpecMode.Exactly);
    }
    if(layoutParams.getHeight() == LayoutParamsSize.MatchParent.getValue()) {
        heightSpec.setMode(LayoutMeasureSpecMode.Exactly);
    }

    onMeasure(widthSpec, heightSpec);
    return getMeasuredSize();
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:19,代码来源:LayoutBridge.java

示例2: getIntrinsicSize

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
@Override
public CGSize getIntrinsicSize() {
    CGSize size = new CGSize(-1, -1);
    for (LayerDrawableItem item : internalConstantState.getItems()) {
        UIEdgeInsets insets = item.getInsets();
        CGSize s = item.getDrawable().getIntrinsicSize();

        s.setWidth(s.getWidth() + insets.getLeft() + insets.getRight());
        s.setHeight(s.getHeight() + insets.getTop() + insets.getBottom());

        if(s.getWidth() > size.getWidth()) {
            size.setWidth(s.getWidth());
        }
        if(s.getHeight() > size.getHeight()) {
            size.setHeight(s.getHeight());
        }
    }

    return size;
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:21,代码来源:LayerDrawable.java

示例3: computeConstantSize

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
public void computeConstantSize() {
    CGSize minSize = CGSize.Zero();
    CGSize intrinsicSize = CGSize.Zero();

    for (Drawable drawable : drawables) {
        CGSize min = drawable.getMinimumSize();
        CGSize intrinsic = drawable.getIntrinsicSize();

        if(min.getWidth() > minSize.getWidth()) minSize.setWidth(min.getWidth());
        if(min.getHeight() > minSize.getHeight()) minSize.setHeight(min.getHeight());

        if(intrinsic.getWidth() > intrinsicSize.getWidth()) intrinsicSize.setWidth(intrinsic.getWidth());
        if(intrinsic.getHeight() > intrinsicSize.getHeight()) intrinsicSize.setHeight(intrinsic.getHeight());
    }

    this.constantIntrinsicSize = intrinsicSize;
    this.constantMinimumSize = minSize;
    this.constantSizeComputed = true;
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:20,代码来源:DrawableContainerConstantState.java

示例4: getHeightForCell

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
public static double getHeightForCell(String name, String content, double cellInset) {
    CGSize nameSize = NSString.getBoundingRect(name, new CGSize(200, Float.MAX_VALUE),
            NSStringDrawingOptions.with(NSStringDrawingOptions.TruncatesLastVisibleLine,
                    NSStringDrawingOptions.UsesLineFragmentOrigin),
            new NSAttributedStringAttributes().setFont(UIFont.getBoldSystemFont(13)), null).getSize();

    String paddedString = padString(content, UIFont.getSystemFont(13), nameSize.getWidth());
    double horizontalTextSpace = getHorizontalTextSpaceForInsetWidth(cellInset);

    CGSize contentSize = NSString.getBoundingRect(paddedString, new CGSize(horizontalTextSpace, Float.MAX_VALUE),
            NSStringDrawingOptions.UsesLineFragmentOrigin,
            new NSAttributedStringAttributes().setFont(UIFont.getSystemFont(13)), null).getSize();

    double singleLineHeight = NSString.getBoundingRect("test", new CGSize(Float.MAX_VALUE, Float.MAX_VALUE),
            NSStringDrawingOptions.UsesLineFragmentOrigin,
            new NSAttributedStringAttributes().setFont(UIFont.getSystemFont(13)), null).getSize().getHeight();

    // Calculate the added height necessary for multiline text. Ensure value
    // is not below 0.
    double multilineHeightAddition = contentSize.getHeight() - singleLineHeight;

    return 58 + Math.max(0, multilineHeightAddition);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:24,代码来源:PAPActivityCell.java

示例5: getHeightForCell

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
public static double getHeightForCell(String name, String content, double cellInset) {
    CGSize nameSize = NSString.getBoundingRect(name, new CGSize(200, Float.MAX_VALUE),
            NSStringDrawingOptions.with(NSStringDrawingOptions.TruncatesLastVisibleLine,
                    NSStringDrawingOptions.UsesLineFragmentOrigin),
            new NSAttributedStringAttributes().setFont(UIFont.getBoldSystemFont(13)), null).getSize();

    String paddedString = padString(content, UIFont.getSystemFont(13), nameSize.getWidth());
    double horizontalTextSpace = getHorizontalTextSpaceForInsetWidth(cellInset);

    CGSize contentSize = NSString.getBoundingRect(paddedString, new CGSize(horizontalTextSpace, Float.MAX_VALUE),
            NSStringDrawingOptions.UsesLineFragmentOrigin,
            new NSAttributedStringAttributes().setFont(UIFont.getSystemFont(13)), null).getSize();

    double singleLineHeight = NSString.getBoundingRect("test", new CGSize(Float.MAX_VALUE, Float.MAX_VALUE),
            NSStringDrawingOptions.UsesLineFragmentOrigin,
            new NSAttributedStringAttributes().setFont(UIFont.getSystemFont(13)), null).getSize().getHeight();

    // Calculate the added height necessary for multiline text. Ensure value
    // is not below 0.
    double multilineHeightAddition = (contentSize.getHeight() - singleLineHeight) > 0 ? (contentSize.getHeight() - singleLineHeight)
            : 0;

    return HORI_BORDER_SPACING + AVATAR_DIM + HORI_BORDER_SPACING_BOTTOM + multilineHeightAddition;
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:25,代码来源:PAPBaseTextCell.java

示例6: resize

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
/**
 * Resizes the image according to the given content mode, taking into
 * account the image's orientation
 * 
 * @param image
 * @param contentMode
 * @param bounds
 * @param quality
 * @return
 */
public static UIImage resize(UIImage image, UIViewContentMode contentMode, CGSize bounds,
        CGInterpolationQuality quality) {
    double horizontalRatio = bounds.getWidth() / image.getSize().getWidth();
    double verticalRatio = bounds.getHeight() / image.getSize().getHeight();
    double ratio;

    switch (contentMode) {
    case ScaleAspectFill:
        ratio = Math.max(horizontalRatio, verticalRatio);
        break;
    case ScaleAspectFit:
        ratio = Math.min(horizontalRatio, verticalRatio);
        break;
    default:
        throw new IllegalArgumentException("Unsupported content mode: " + contentMode);
    }

    CGSize newSize = new CGSize(image.getSize().getWidth() * ratio, image.getSize().getHeight() * ratio);
    return resize(image, newSize, quality);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:31,代码来源:UIImageUtility.java

示例7: createAnchorPair

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
private static AAPLGeoAnchorPair createAnchorPair(CLLocationCoordinate2D topLeft,
        CLLocationCoordinate2D bottomRight,
        CGSize imageSize) {
    AAPLGeoAnchor topLeftAnchor = new AAPLGeoAnchor();
    topLeftAnchor.latitudeLongitude = topLeft;
    topLeftAnchor.pixel = new CGPoint(0, 0);

    AAPLGeoAnchor bottomRightAnchor = new AAPLGeoAnchor();
    bottomRightAnchor.latitudeLongitude = bottomRight;
    bottomRightAnchor.pixel = new CGPoint(imageSize.getWidth(), imageSize.getHeight());

    AAPLGeoAnchorPair anchorPair = new AAPLGeoAnchorPair();
    anchorPair.fromAnchor = topLeftAnchor;
    anchorPair.toAnchor = bottomRightAnchor;

    return anchorPair;
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:18,代码来源:AAPLCoordinateConverter.java

示例8: layoutSubviews

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
@Override
public void layoutSubviews() {
    super.layoutSubviews();

    // center the zoom view as it becomes smaller than the size of the
    // screen
    CGSize boundsSize = getBounds().getSize();
    CGRect frameToCenter = zoomView.getFrame();

    // center horizontally
    if (frameToCenter.getSize().getWidth() < boundsSize.getWidth())
        frameToCenter.getOrigin().setX((boundsSize.getWidth() - frameToCenter.getSize().getWidth()) / 2);
    else
        frameToCenter.getOrigin().setX(0);

    // center vertically
    if (frameToCenter.getSize().getHeight() < boundsSize.getHeight())
        frameToCenter.getOrigin().setY((boundsSize.getHeight() - frameToCenter.getSize().getHeight()) / 2);
    else
        frameToCenter.getOrigin().setY(0);

    zoomView.setFrame(frameToCenter);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:24,代码来源:ImageScrollView.java

示例9: onMeasure

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
@Override
public void onMeasure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec) {
    /*for (UIView subView : getSubviews()) {
        if(UIViewLayoutUtil.getVisibility(subView) != ViewVisibility.Gone) {
            UIViewViewGroupUtil.measureChild(this, subView, widthMeasureSpec, 0, heightMeasureSpec, 0);
        }
    }*/

    CGSize lastChildSize = CGSize.Zero();
    UIView lastChild = getSubviews().last();

    if(UIViewLayoutUtil.getVisibility(lastChild) != ViewVisibility.Gone) {
        UIViewViewGroupUtil.measureChild(this, lastChild, widthMeasureSpec, 0, heightMeasureSpec, 0);

        lastChildSize = UIViewLayoutUtil.getMeasuredSize(lastChild);
        LayoutParams layoutParams = UIViewLayoutUtil.getLayoutParams(lastChild);

        if(layoutParams instanceof MarginLayoutParams) {
            MarginLayoutParams marginParams = (MarginLayoutParams) layoutParams;
            lastChildSize.setWidth(lastChildSize.getWidth() + marginParams.getMargin().getLeft() + marginParams.getMargin().getRight());
            lastChildSize.setHeight(lastChildSize.getHeight() + marginParams.getMargin().getTop() + marginParams.getMargin().getBottom());
        }
    }

    double widthSize = lastChildSize.getWidth() + getPadding().getLeft() + getPadding().getRight();
    double heightSize = lastChildSize.getHeight() + getPadding().getTop() + getPadding().getBottom();

    LayoutMeasuredDimension width = new LayoutMeasuredDimension(widthSize, LayoutMeasuredState.None);
    LayoutMeasuredDimension height = new LayoutMeasuredDimension(heightSize, LayoutMeasuredState.None);

    setMeasuredDimensionSize(new LayoutMeasuredSize(width, height));
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:33,代码来源:LayoutBridge.java

示例10: forceUniformHeight

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
private void forceUniformHeight(int count, LayoutMeasureSpec widthMeasureSpec) {
    // Pretend that the linear layout has an exact size. This is the measured height of
    // ourselves. The measured height should be the max height of the children, changed
    // to accomodate the heightMesureSpec from the parent
    CGSize measuredSize = UIViewLayoutUtil.getMeasuredSize(this);
    LayoutMeasureSpec uniformMeasureSpec = new LayoutMeasureSpec(measuredSize.getHeight(), LayoutMeasureSpecMode.Exactly);

    for (int i = 0; i < count; i++) {
        UIView child = getSubviews().get(i);

        if (UIViewLayoutUtil.getVisibility(child) == ViewVisibility.Gone) {
            continue;
        }

        LinearLayoutLayoutParams lp = (LinearLayoutLayoutParams) UIViewLayoutUtil.getLayoutParams(child);

        if(lp.getHeight() == LayoutParamsSize.MatchParent.getValue()) {
            // Temporarily force children to reuse their old measured width
            // FIXME: this may not be right for something like wrapping text?
            double oldWidth = lp.getWidth();
            CGSize childMeasuredSize = UIViewLayoutUtil.getMeasuredSize(child);

            lp.setWidth(childMeasuredSize.getWidth());

            // Remeasure with new dimensions
            UIViewViewGroupUtil.measureChild(this, child, widthMeasureSpec, 0, uniformMeasureSpec, 0);
            lp.setWeight(oldWidth);
        }
    }
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:31,代码来源:LinearLayout.java

示例11: viewDidLayoutSubviews

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
@Override
public void viewDidLayoutSubviews() {
    layerSizeDidUpdate = true;

    CGSize parentSize = getView().getBounds().getSize();
    float minSize = (float) Math.min(parentSize.getWidth(), parentSize.getHeight());
    CGRect frame = new CGRect((parentSize.getWidth() - minSize) / 2,
            (parentSize.getHeight() - minSize) / 2,
            minSize,
            minSize);
    metalLayer.setFrame(frame);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:13,代码来源:MetalBasic2DViewController.java

示例12: viewWillAppear

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
@Override
public void viewWillAppear(boolean animated) {
    super.viewWillAppear(animated);

    double scale = UIScreen.getMainScreen().getScale();
    CGSize cellSize = ((UICollectionViewFlowLayout) getCollectionViewLayout()).getItemSize();
    assetGridThumbnailSize = new CGSize(cellSize.getWidth() * scale, cellSize.getHeight() * scale);

    if (assetCollection == null || assetCollection.canPerformEditOperation(PHCollectionEditOperation.AddContent)) {
        getNavigationItem().setRightBarButtonItem(addButton);
    } else {
        getNavigationItem().setRightBarButtonItem(null);
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:15,代码来源:AAPLAssetGridViewController.java

示例13: LoadingStatus

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
public LoadingStatus(CGRect frame) {
    super(frame);

    setBackgroundColor(UIColor.fromRGBA(0, 0, 0, 0.4));
    String loadingString = "Loading Photos…";

    UIFont loadingFont = UIFont.getBoldSystemFont(17);

    NSAttributedStringAttributes attrs = new NSAttributedStringAttributes().setFont(loadingFont);
    CGRect rect = new NSString(loadingString).getBoundingRect(new CGSize(frame.getWidth(), frame.getHeight()),
            NSStringDrawingOptions.with(NSStringDrawingOptions.UsesLineFragmentOrigin,
                    NSStringDrawingOptions.UsesFontLeading), attrs, null);
    CGSize labelSize = rect.getSize();

    double centerX = Math.floor((frame.getWidth() / 2) - (labelSize.getWidth() / 2));
    double centerY = Math.floor((frame.getHeight() / 2) - (labelSize.getHeight() / 2));
    loadingLabel = new UILabel(new CGRect(centerX, centerY, labelSize.getWidth(), labelSize.getHeight()));
    loadingLabel.setBackgroundColor(UIColor.clear());
    loadingLabel.setTextColor(UIColor.white());
    loadingLabel.setText(loadingString);
    loadingLabel.setFont(loadingFont);

    progress = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White);
    CGRect progressFrame = progress.getFrame();
    progressFrame.getOrigin().setX(centerX - progressFrame.getWidth() - 8);
    progressFrame.getOrigin().setY(centerY);
    progress.setFrame(progressFrame);

    addSubview(progress);
    addSubview(loadingLabel);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:32,代码来源:LoadingStatus.java

示例14: onLayout

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
@Override
public void onLayout(CGRect frame, boolean changed) {
    int count = Math.min(1, getSubviews().size());

    UIEdgeInsets padding = UIViewLayoutUtil.getPadding(this);
    double parentLeft = padding.getLeft();
    double parentRight = frame.getSize().getWidth() - padding.getRight();

    double parentTop = padding.getTop();
    double parentBottom = frame.getSize().getHeight() - padding.getBottom();
    double maxX = 0;
    double maxY = 0;

    for (int i = 0; i < count; i++) {
        UIView child = getSubviews().get(i);

        if (UIViewLayoutUtil.getVisibility(child) != ViewVisibility.Gone && !child.getClass().getSimpleName().equals("UIWebDocumentView")) {
            FrameLayoutLayoutParams lp = (FrameLayoutLayoutParams) UIViewLayoutUtil.getLayoutParams(child);
            UIEdgeInsets lpMargin = lp.getMargin();

            CGSize childMeasureSize = UIViewLayoutUtil.getMeasuredSize(child);
            double width = childMeasureSize.getWidth();
            double height = childMeasureSize.getHeight();

            double childLeft;
            double childTop;

            ViewContentGravity gravity = lp.getGravity();
            if (gravity.value() == -1) {
                gravity = DEFAULT_CHILD_GRAVITY;
            }

            ViewContentGravity verticalGravity = ViewContentGravity.create(gravity.value() & ViewContentGravity.VERTICAL_GRAVITY_MASK);
            ViewContentGravity horizontalGravity = ViewContentGravity.create(gravity.value() & ViewContentGravity.HORIZONTAL_GRAVITY_MASK);

            if(horizontalGravity.equals(ViewContentGravity.Left)) {
                childLeft = parentLeft + lpMargin.getLeft();
            } else if(horizontalGravity.equals(ViewContentGravity.CenterHorizontal)) {
                childLeft = parentLeft + (parentRight - parentLeft - width) / 2 + lpMargin.getLeft() - lpMargin.getRight();
            } else if(horizontalGravity.equals(ViewContentGravity.Right)) {
                childLeft = parentRight - width - lpMargin.getRight();
            } else {
                childLeft = parentLeft + lpMargin.getLeft();
            }

            if(verticalGravity.equals(ViewContentGravity.Top)) {
                childTop = parentTop + lpMargin.getTop();
            } else if(verticalGravity.equals(ViewContentGravity.CenterVertical)) {
                childTop = parentTop + (parentBottom - parentTop - height) / 2 + lpMargin.getTop() - lpMargin.getBottom();
            } else if(verticalGravity.equals(ViewContentGravity.Bottom)) {
                childTop = parentBottom - height - lpMargin.getBottom();
            } else {
                childTop = parentTop + lpMargin.getTop();
            }

            UIViewLayoutUtil.layout(child, new CGRect(childLeft, childTop, width, height));

            maxX = Math.max(maxX, childLeft + width);
            maxY = Math.max(maxY, childTop + height);
        }
    }
    setContentSize(new CGSize(maxX + padding.getRight(), maxY + padding.getBottom()));
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:64,代码来源:ScrollView.java

示例15: setPhoto

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
public void setPhoto(PAPPhoto photo) {
    this.photo = photo;

    // user's avatar
    PAPUser user = photo.getUser();
    if (PAPUtility.userHasProfilePictures(user)) {
        PFFile profilePictureSmall = user.getProfilePicSmall();
        avatarImageView.setFile(profilePictureSmall);
    } else {
        avatarImageView.setImage(PAPUtility.getDefaultProfilePicture());
    }

    avatarImageView.setContentMode(UIViewContentMode.ScaleAspectFill);
    avatarImageView.getLayer().setCornerRadius(17.5);
    avatarImageView.getLayer().setMasksToBounds(true);

    String authorName = user.getDisplayName();
    userButton.setTitle(authorName, UIControlState.Normal);

    double constrainWidth = containerView.getBounds().getSize().getWidth();

    if (buttons.contains(PAPPhotoHeaderButton.User)) {
        userButton.addOnTouchUpInsideListener(didTapUserButton);
    }

    if (buttons.contains(PAPPhotoHeaderButton.Comment)) {
        constrainWidth = commentButton.getFrame().getOrigin().getX();
        commentButton.addOnTouchUpInsideListener(didTapCommentOnPhotoButton);
    }

    if (buttons.contains(PAPPhotoHeaderButton.Like)) {
        constrainWidth = likeButton.getFrame().getOrigin().getX();
        likeButton.addOnTouchUpInsideListener(didTapLikePhotoButton);
    }

    // we resize the button to fit the user's name to avoid having a huge
    // touch area
    CGPoint userButtonPoint = new CGPoint(50, 6);
    constrainWidth -= userButtonPoint.getX();
    CGSize constrainSize = new CGSize(constrainWidth, containerView.getBounds().getSize().getHeight()
            - userButtonPoint.getY() * 2f);

    CGSize userButtonSize = NSString.getBoundingRect(
            userButton.getTitleLabel().getText(),
            constrainSize,
            NSStringDrawingOptions.with(NSStringDrawingOptions.TruncatesLastVisibleLine,
                    NSStringDrawingOptions.UsesLineFragmentOrigin),
            new NSAttributedStringAttributes().setFont(userButton.getTitleLabel().getFont()), null).getSize();

    CGRect userButtonFrame = new CGRect(userButtonPoint.getX(), userButtonPoint.getY(), userButtonSize.getWidth(),
            userButtonSize.getHeight());
    userButton.setFrame(userButtonFrame);

    double timeInterval = photo.getCreatedAt().getTimeIntervalSinceNow();
    String timestamp = timeFormatter.format(timeInterval);
    timestampLabel.setText(timestamp);

    setNeedsDisplay();
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:60,代码来源:PAPPhotoHeaderView.java


注:本文中的org.robovm.apple.coregraphics.CGSize.getHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。