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


Java CGSize.setWidth方法代码示例

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


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

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

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

示例3: onBoundsChangeToRect

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
@Override
public void onBoundsChangeToRect(CGRect bounds) {
    ShadowDrawableConstantState state = this.internalConstantState;

    CGSize boundsSize = bounds.getSize();
    double offsetWidth = state.getOffset().getWidth();
    double offsetHeight = state.getOffset().getHeight();

    if(offsetWidth > 0) {
        boundsSize.setWidth(boundsSize.getWidth() - offsetWidth);
    } else if(offsetWidth < 0) {
        bounds.getOrigin().setX(bounds.getOrigin().getX() - offsetWidth);
        boundsSize.setWidth(boundsSize.getWidth() + offsetWidth);
    }

    if(offsetHeight > 0) {
        boundsSize.setHeight(boundsSize.getHeight() - offsetHeight);
    } else if(offsetWidth < 0) {
        bounds.getOrigin().setY(bounds.getOrigin().getY() - offsetWidth);
        boundsSize.setHeight(boundsSize.getHeight() + offsetHeight);
    }

    internalConstantState.getDrawable().setBounds(bounds);
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:25,代码来源:ShadowDrawable.java

示例4: getItemSize

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
@Override
public CGSize getItemSize(UICollectionView uiCollectionView, UICollectionViewLayout uiCollectionViewLayout, NSIndexPath nsIndexPath) {
    ExampleCollectionViewCell cell = new ExampleCollectionViewCell();
    cell.setItem(items.get(nsIndexPath.getItem()));

    CGSize size = uiCollectionView.getBounds().getSize();
    UICollectionViewFlowLayout flowLayout = (UICollectionViewFlowLayout) uiCollectionViewLayout;

    if(flowLayout.getScrollDirection() == UICollectionViewScrollDirection.Vertical) {
        size.setHeight(cell.getRequiredHeightForWidth(size.getWidth()));
    } else {
        size.setWidth(cell.getRequiredWidthForHeight(size.getHeight()));
    }

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

示例5: redraw

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
@Method
private void redraw() {
    try (NSAutoreleasePool pool = new NSAutoreleasePool()) {
        if (layerSizeDidUpdate) {
            double nativeScale = getView().getWindow().getScreen().getNativeScale();
            CGSize drawableSize = metalLayer.getBounds().getSize();
            drawableSize.setWidth(drawableSize.getWidth() * nativeScale);
            drawableSize.setHeight(drawableSize.getHeight() * nativeScale);
            metalLayer.setDrawableSize(drawableSize);
            layerSizeDidUpdate = false;
        }

        render();
        ((NSObject) currentDrawable).dispose();
        currentDrawable = null;
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:18,代码来源:MetalBasic2DViewController.java

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

示例7: getMinimumSize

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
public CGSize getMinimumSize() {
    CGSize size = getIntrinsicSize();

    size.setWidth(Math.max(size.getWidth(), 0));
    size.setHeight(Math.max(size.getHeight(), 0));

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

示例8: inflate

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
@Override
public void inflate(Element element) throws ParseException {
    ShadowDrawableConstantState state = this.internalConstantState;

    Map<String, String> attrs = DOMUtil.getAttributesFromElement(element);

    state.setAlpha(ResourceAttributesUtil.getFractionValue(attrs, "alpha", 1));

    CGSize offset = new CGSize(0, 0);
    offset.setWidth(ResourceAttributesUtil.getDimensionValue(attrs, "shadowHorizontalOffset", 0));
    offset.setHeight(ResourceAttributesUtil.getDimensionValue(attrs, "shadowVerticalOffset", 0));
    state.setOffset(offset);

    state.setBlur(Math.abs(ResourceAttributesUtil.getDimensionValue(attrs, "blur", 0)));
    state.setShadowColor(ResourceAttributesUtil.getColorValue(attrs, "shadowColor"));

    String drawableResId = attrs.get("drawables");
    Drawable drawable = null;

    Element firstElementChild = DOMUtil.getFirstElementChild(element);

    if(drawableResId != null) {
        drawable = ResourceManager.getCurrent().getDrawable(drawableResId);
    } else if(firstElementChild != null) {
        drawable = Drawable.create(firstElementChild);
    } else {
        throw new ParseException("<item> tag requires a 'drawable' attribute or child tag defining a drawable", 0);
    }

    if(drawable != null) {
        drawable.setDelegate(this);
        drawable.setState(getState());
        state.setDrawable(drawable);
    }
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:36,代码来源:ShadowDrawable.java

示例9: display

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
public void display() {
    // Create autorelease pool per frame to avoid possible deadlock
    // situations
    // because there are 3 CAMetalDrawables sitting in an autorelease pool.

    try (NSAutoreleasePool pool = new NSAutoreleasePool()) {
        // handle display changes here
        if (layerSizeDidUpdate) {
            // set the metal layer to the drawable size in case orientation
            // or size changes
            CGSize drawableSize = getBounds().getSize();
            drawableSize.setWidth(drawableSize.getWidth() * this.getContentScaleFactor());
            drawableSize.setHeight(drawableSize.getHeight() * this.getContentScaleFactor());

            metalLayer.setDrawableSize(drawableSize);

            // renderer delegate method so renderer can resize anything if
            // needed
            delegate.reshape(this);

            layerSizeDidUpdate = false;
        }

        // rendering delegate method to ask renderer to draw this frame's
        // content
        delegate.render(this);

        // do not retain current drawable beyond the frame.
        // There should be no strong references to this object outside of
        // this view class
        ((NSObject) currentDrawable).dispose();
        currentDrawable = null;
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:35,代码来源:MetalBasic3DView.java

示例10: draw

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
@Override
public void draw(CGRect rect) {
    CGContext context = UIGraphics.getCurrentContext();
    /*
     * get the scale from the context by getting the current transform
     * matrix, then asking for its "a" component, which is one of the two
     * scale components. We could also ask for "d". This assumes (safely)
     * that the view is being scaled equally in both dimensions.
     */

    double scale = context.getCTM().getA();

    CATiledLayer tiledLayer = (CATiledLayer) getLayer();
    CGSize tileSize = tiledLayer.getTileSize();
    /*
     * Even at scales lower than 100%, we are drawing into a rect in the
     * coordinate system of the full image. One tile at 50% covers the width
     * (in original image coordinates) of two tiles at 100%. So at 50% we
     * need to stretch our tiles to double the width and height; at 25% we
     * need to stretch them to quadruple the width and height; and so on.
     * (Note that this means that we are drawing very blurry images as the
     * scale gets low. At 12.5%, our lowest scale, we are stretching about 6
     * small tiles to fill the entire original image area. But this is okay,
     * because the big blurry image we're drawing here will be scaled way
     * down before it is displayed.)
     */
    tileSize.setWidth(tileSize.getWidth() / scale);
    tileSize.setHeight(tileSize.getHeight() / scale);

    // calculate the rows and columns of tiles that intersect the rect we
    // have been asked to draw
    int firstCol = (int) Math.floor(rect.getMinX() / tileSize.getWidth());
    int lastCol = (int) Math.floor((rect.getMaxX() - 1) / tileSize.getWidth());
    int firstRow = (int) Math.floor(rect.getMinY() / tileSize.getHeight());
    int lastRow = (int) Math.floor((rect.getMaxY() - 1) / tileSize.getHeight());

    for (int row = firstRow; row <= lastRow; row++) {
        for (int col = firstCol; col <= lastCol; col++) {
            UIImage tile = getTile(scale, row, col);
            CGRect tileRect = new CGRect(tileSize.getWidth() * col, tileSize.getHeight() * row,
                    tileSize.getWidth(),
                    tileSize.getHeight());
            /*
             * if the tile would stick outside of our bounds, we need to
             * truncate it so as to avoid stretching out the partial tiles
             * at the right and bottom edges
             */
            tileRect = getBounds().intersection(tileRect);

            tile.draw(tileRect);
        }
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:54,代码来源:TilingView.java

示例11: viewWillAppear

import org.robovm.apple.coregraphics.CGSize; //导入方法依赖的package包/类
@Override
public void viewWillAppear (boolean animated) {
    // Start the progress indicator animation.
    loadingProgressIndicator.startAnimating();

    CGSize viewSize = getView().getBounds().getSize();

    // On iPhone/iPod touch we want to see a similar amount of the scene as on iPad.
    // So, we set the size of the scene to be double the size of the view, which is
    // the whole screen, 3.5- or 4- inch. This effectively scales the scene to 50%.
    if (UIDevice.getCurrentDevice().getUserInterfaceIdiom() == UIUserInterfaceIdiom.Phone) {
        viewSize.setHeight(viewSize.getHeight() * 2);
        viewSize.setWidth(viewSize.getWidth() * 2);
    }
    scene = new APAAdventureScene(viewSize);

    // Load the shared assets of the scene.
    scene.loadSceneAssets(new Runnable() {
        @Override
        public void run () {
            scene.setup();

            scene.setScaleMode(SKSceneScaleMode.AspectFill);

            scene.configureGameControllers();

            loadingProgressIndicator.stopAnimating();
            loadingProgressIndicator.setHidden(true);

            skView.presentScene(scene);

            UIView.animate(2, 0, UIViewAnimationOptions.CurveEaseInOut, new Runnable() {
                @Override
                public void run () {
                    archerButton.setAlpha(1);
                    warriorButton.setAlpha(1);
                }
            }, null);
        }
    });

    if (SHOW_DEBUG_INFO) {
        // Show debug information.
        skView.setShowsFPS(true);
        skView.setShowsDrawCount(true);
        skView.setShowsNodeCount(true);
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:49,代码来源:APAViewController.java


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