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


Java CGSize.getWidth方法代码示例

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


在下文中一共展示了CGSize.getWidth方法的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: padString

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
protected static String padString(String string, UIFont font, double width) {
    // Find number of spaces to pad
    StringBuilder sb = new StringBuilder();
    CGSize size = new CGSize(Float.MAX_VALUE, Float.MAX_VALUE);
    NSStringDrawingOptions options = NSStringDrawingOptions.with(NSStringDrawingOptions.TruncatesLastVisibleLine,
            NSStringDrawingOptions.UsesLineFragmentOrigin);
    NSAttributedStringAttributes attr = new NSAttributedStringAttributes().setFont(font);
    while (true) {
        sb.append(" ");
        CGSize resultSize = NSString.getBoundingRect(sb.toString(), size, options, attr, null).getSize();
        if (resultSize.getWidth() >= width) {
            break;
        }
    }

    // Add final spaces to be ready for first word
    sb.append(String.format(" %s", string));
    return sb.toString();
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:20,代码来源:PAPBaseTextCell.java

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: viewDidLoad

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

    getTableView().setSeparatorStyle(UITableViewCellSeparatorStyle.None);
    getTableView().setBackgroundColor(UIColor.black());

    getNavigationItem().setTitleView(new UIImageView(UIImage.getImage("TitleFindFriends")));

    if (getNavigationController().getViewControllers().first() == this) {
        UIBarButtonItem dismissLeftBarButtonItem = new UIBarButtonItem("Back", UIBarButtonItemStyle.Plain,
                new UIBarButtonItem.OnClickListener() {
                    @Override
                    public void onClick(UIBarButtonItem barButtonItem) {
                        getNavigationController().dismissViewController(true, null);
                    }
                });
        getNavigationItem().setLeftBarButtonItem(dismissLeftBarButtonItem);
    } else {
        getNavigationItem().setLeftBarButtonItem(null);
    }

    if (MFMailComposeViewController.canSendMail() || MFMessageComposeViewController.canSendText()) {
        headerView = new UIView(new CGRect(0, 0, 320, 67));
        headerView.setBackgroundColor(UIColor.black());
        UIButton clearButton = new UIButton(UIButtonType.Custom);
        clearButton.setBackgroundColor(UIColor.clear());
        clearButton.addOnTouchUpInsideListener(inviteFriendsButtonAction);
        clearButton.setFrame(headerView.getFrame());
        headerView.addSubview(clearButton);
        String inviteString = "Invite friends";
        CGRect boundingRect = NSString.getBoundingRect(inviteString, new CGSize(310, Float.MAX_VALUE),
                NSStringDrawingOptions.with(NSStringDrawingOptions.TruncatesLastVisibleLine,
                        NSStringDrawingOptions.UsesLineFragmentOrigin),
                new NSAttributedStringAttributes().setFont(UIFont.getBoldSystemFont(18)), null);
        CGSize inviteStringSize = boundingRect.getSize();

        UILabel inviteLabel = new UILabel(new CGRect(10,
                (headerView.getFrame().getSize().getHeight() - inviteStringSize.getHeight()) / 2,
                inviteStringSize.getWidth(), inviteStringSize.getHeight()));
        inviteLabel.setText(inviteString);
        inviteLabel.setFont(UIFont.getBoldSystemFont(18));
        inviteLabel.setTextColor(UIColor.white());
        inviteLabel.setBackgroundColor(UIColor.clear());
        headerView.addSubview(inviteLabel);
        getTableView().setTableHeaderView(headerView);
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:49,代码来源:PAPFindFriendsViewController.java

示例15: setMaxMinZoomScalesForCurrentBounds

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
private void setMaxMinZoomScalesForCurrentBounds() {
    CGSize boundsSize = getBounds().getSize();

    // calculate min/max zoomscale
    double xScale = boundsSize.getWidth() / imageSize.getWidth(); // the
                                                                  // scale
                                                                  // needed
                                                                  // to
                                                                  // perfectly
                                                                  // fit the
                                                                  // image
                                                                  // width-wise
    double yScale = boundsSize.getHeight() / imageSize.getHeight(); // the
                                                                    // scale
                                                                    // needed
                                                                    // to
                                                                    // perfectly
                                                                    // fit
                                                                    // the
                                                                    // image
                                                                    // height-wise

    // fill width if the image and phone are both portrait or both
    // landscape; otherwise take smaller scale
    boolean imagePortrait = imageSize.getHeight() > imageSize.getWidth();
    boolean phonePortrait = boundsSize.getHeight() > boundsSize.getWidth();
    double minScale = imagePortrait == phonePortrait ? xScale : Math.min(xScale, yScale);

    // on high resolution screens we have double the pixel density, so we
    // will be seeing every pixel if we limit the
    // maximum zoom scale to 0.5.
    double maxScale = 1.0 / UIScreen.getMainScreen().getScale();

    // don't let minScale exceed maxScale. (If the image is smaller than the
    // screen, we don't want to force it to be zoomed.)
    if (minScale > maxScale) {
        minScale = maxScale;
    }
    setMaximumZoomScale(maxScale);
    setMinimumZoomScale(minScale);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:42,代码来源:ImageScrollView.java


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