本文整理汇总了Java中org.robovm.apple.coregraphics.CGSize类的典型用法代码示例。如果您正苦于以下问题:Java CGSize类的具体用法?Java CGSize怎么用?Java CGSize使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CGSize类属于org.robovm.apple.coregraphics包,在下文中一共展示了CGSize类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: resizeImage
import org.robovm.apple.coregraphics.CGSize; //导入依赖的package包/类
public UIImage resizeImage(UIImage image, double width, double height) {
CGSize size = new CGSize(width, height);
UIGraphics.beginImageContext(size, false, 0);
CGContext context = UIGraphics.getCurrentContext();
// Draw the original image to the context
context.setBlendMode(CGBlendMode.Copy);
image.draw(new CGRect(0, 0, width, height));
// Retrieve the UIImage from the current context
UIImage imageOut = UIGraphics.getImageFromCurrentImageContext();
UIGraphics.endImageContext();
return imageOut;
}
开发者ID:liraz,项目名称:robolayout,代码行数:18,代码来源:BitmapDrawable.java
示例5: drawInContext
import org.robovm.apple.coregraphics.CGSize; //导入依赖的package包/类
@Override
public void drawInContext(CGContext context) {
ShadowDrawableConstantState state = this.internalConstantState;
context.setAlpha(state.getAlpha());
if(state.getShadowColor() != null) {
context.setShadow(state.getOffset(), state.getBlur(), state.getShadowColor().getCGColor());
} else if(state.getBlur() > 0 || !state.getOffset().equalsTo(CGSize.Zero())) {
context.setShadow(state.getOffset(), state.getBlur());
}
context.beginTransparencyLayer(this.getBounds(), null);
// Draw child
state.getDrawable().drawInContext(context);
context.endTransparencyLayer();
}
开发者ID:liraz,项目名称:robolayout,代码行数:18,代码来源:ShadowDrawable.java
示例6: 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
示例7: 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
示例8: showAds
import org.robovm.apple.coregraphics.CGSize; //导入依赖的package包/类
public void showAds() {
initializeAds();
final CGSize screenSize = UIScreen.getMainScreen().getBounds().size();
double screenWidth = screenSize.height();
double screenHeight = screenSize.width();
final CGSize adSize = adview.getBounds().size();
double adWidth = adSize.width();
double adHeight = adSize.height();
log.debug(String.format("Hidding ad. size[%s, %s]", adWidth, adHeight));
float bannerWidth = (float) screenWidth;
float bannerHeight = (float) (bannerWidth / adWidth * adHeight);
log.debug(String.format("%s, %s, %s", screenWidth, screenHeight, bannerHeight));
adview.setFrame(new CGRect(0,
screenHeight - bannerHeight,
bannerWidth, bannerHeight));
}
开发者ID:pierotofy,项目名称:snappyfrog,代码行数:22,代码来源:RobovmLauncher.java
示例9: 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
示例10: 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
示例11: 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
示例12: setContentText
import org.robovm.apple.coregraphics.CGSize; //导入依赖的package包/类
public void setContentText(String contentString) {
// If we have a user we pad the content with spaces to make room for the
// name
if (user != null) {
CGSize nameSize = NSString.getBoundingRect(
nameButton.getTitleLabel().getText(),
new CGSize(NAME_MAX_WIDTH, Float.MAX_VALUE),
NSStringDrawingOptions.with(NSStringDrawingOptions.TruncatesLastVisibleLine,
NSStringDrawingOptions.UsesLineFragmentOrigin),
new NSAttributedStringAttributes().setFont(UIFont.getBoldSystemFont(13)), null).getSize();
String paddedString = padString(contentString, UIFont.getSystemFont(13), nameSize.getWidth());
contentLabel.setText(paddedString);
} else {
// Otherwise we ignore the padding and we'll add it after we set the
// user
contentLabel.setText(contentString);
}
setNeedsDisplay();
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:20,代码来源:PAPBaseTextCell.java
示例13: newBorderMask
import org.robovm.apple.coregraphics.CGSize; //导入依赖的package包/类
/**
*
* @param borderSize
* @param size
* @return a mask that makes the outer edges transparent and everything else
* opaque The size must include the entire mask (opaque part +
* transparent border)
*/
private static CGImage newBorderMask(int borderSize, CGSize size) {
CGColorSpace colorSpace = CGColorSpace.createDeviceGray();
// Build a context that's the same dimensions as the new size
CGBitmapContext maskContext = CGBitmapContext.create((long) size.getWidth(), (long) size.getHeight(), 8, 0,
colorSpace, new CGBitmapInfo(CGBitmapInfo.ByteOrderDefault.value() | CGImageAlphaInfo.None.value())); // TODO
// easier
// Start with a mask that's entirely transparent
maskContext.setFillColor(UIColor.black().getCGColor());
maskContext.fillRect(new CGRect(0, 0, size.getWidth(), size.getHeight()));
// Make the inner part (within the border) opaque
maskContext.setFillColor(UIColor.white().getCGColor());
maskContext.fillRect(new CGRect(borderSize, borderSize, size.getWidth() - borderSize * 2, size.getHeight()
- borderSize * 2));
// Get an image of the context
CGImage maskImage = maskContext.toImage();
return maskImage;
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:31,代码来源:UIImageUtility.java
示例14: createThumbnail
import org.robovm.apple.coregraphics.CGSize; //导入依赖的package包/类
/**
*
* @param image
* @param thumbnailSize
* @param borderSize
* @param cornerRadius
* @param quality
* @return a copy of this image that is squared to the thumbnail size. If
* transparentBorder is non-zero, a transparent border of the given
* size will be added around the edges of the thumbnail. (Adding a
* transparent border of at least one pixel in size has the
* side-effect of antialiasing the edges of the image when rotating
* it using Core Animation.)
*/
public static UIImage createThumbnail(UIImage image, int thumbnailSize, int borderSize, int cornerRadius,
CGInterpolationQuality quality) {
UIImage resizedImage = resize(image, UIViewContentMode.ScaleAspectFill,
new CGSize(thumbnailSize, thumbnailSize), quality);
// Crop out any part of the image that's larger than the thumbnail size
// The cropped rect must be centered on the resized image
// Round the origin points so that the size isn't altered when
// CGRectIntegral is later invoked
CGRect cropRect = new CGRect(Math.round((resizedImage.getSize().getWidth() - thumbnailSize) / 2),
Math.round((resizedImage.getSize().getHeight() - thumbnailSize) / 2), thumbnailSize, thumbnailSize);
UIImage croppedImage = crop(resizedImage, cropRect);
UIImage transparentBorderImage = borderSize != 0 ? addTransparentBorder(croppedImage, borderSize)
: croppedImage;
return createRoundedCornerImage(transparentBorderImage, cornerRadius, borderSize);
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:33,代码来源:UIImageUtility.java
示例15: resize
import org.robovm.apple.coregraphics.CGSize; //导入依赖的package包/类
/**
*
* @param image
* @param newSize
* @param quality
* @return a rescaled copy of the image, taking into account its orientation
* The image will be scaled disproportionately if necessary to fit
* the bounds specified by the parameter
*/
public static UIImage resize(UIImage image, CGSize newSize, CGInterpolationQuality quality) {
boolean drawTransposed;
switch (image.getOrientation()) {
case Left:
case LeftMirrored:
case Right:
case RightMirrored:
drawTransposed = true;
break;
default:
drawTransposed = false;
break;
}
return resize(image, newSize, getTransformForOrientation(image, newSize), drawTransposed, quality);
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:27,代码来源:UIImageUtility.java
示例16: drawSideAndBottomDropShadow
import org.robovm.apple.coregraphics.CGSize; //导入依赖的package包/类
public static void drawSideAndBottomDropShadow(CGRect rect, CGContext context) {
// Push the context
context.saveGState();
// Set the clipping path to remove the rect drawn by drawing the shadow
CGRect boundingRect = context.getClipBoundingBox();
context.addRect(boundingRect);
context.addRect(rect);
context.clip();
// Also clip the top and bottom
context.clipToRect(new CGRect(rect.getOrigin().getX() - 10, rect.getOrigin().getY(),
rect.getSize().getWidth() + 20, rect.getSize().getHeight() + 10));
// Draw shadow
UIColor.black().setFill();
context.setShadow(CGSize.Zero(), 7);
context.fillRect(new CGRect(rect.getOrigin().getX(), rect.getOrigin().getY() - 5, rect.getSize().getWidth(),
rect.getSize().getHeight() + 5));
// Save context
context.restoreGState();
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:23,代码来源:PAPUtility.java
示例17: drawSideAndTopDropShadow
import org.robovm.apple.coregraphics.CGSize; //导入依赖的package包/类
public static void drawSideAndTopDropShadow(CGRect rect, CGContext context) {
// Push the context
context.saveGState();
// Set the clipping path to remove the rect drawn by drawing the shadow
CGRect boundingRect = context.getClipBoundingBox();
context.addRect(boundingRect);
context.addRect(rect);
context.clip();
// Also clip the top and bottom
context.clipToRect(new CGRect(rect.getOrigin().getX() - 10, rect.getOrigin().getY() - 10, rect.getSize()
.getWidth() + 20, rect.getSize().getHeight() + 10));
// Draw shadow
UIColor.black().setFill();
context.setShadow(CGSize.Zero(), 7);
context.fillRect(new CGRect(rect.getOrigin().getX(), rect.getOrigin().getY(), rect.getSize().getWidth(), rect
.getSize().getHeight() + 10));
// Save context
context.restoreGState();
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:23,代码来源:PAPUtility.java
示例18: drawSideDropShadow
import org.robovm.apple.coregraphics.CGSize; //导入依赖的package包/类
public static void drawSideDropShadow(CGRect rect, CGContext context) {
// Push the context
context.saveGState();
// Set the clipping path to remove the rect drawn by drawing the shadow
CGRect boundingRect = context.getClipBoundingBox();
context.addRect(boundingRect);
context.addRect(rect);
context.clip();
// Also clip the top and bottom
context.clipToRect(new CGRect(rect.getOrigin().getX() - 10, rect.getOrigin().getY(),
rect.getSize().getWidth() + 20, rect.getSize().getHeight()));
// Draw shadow
UIColor.black().setFill();
context.setShadow(CGSize.Zero(), 7);
context.fillRect(new CGRect(rect.getOrigin().getX(), rect.getOrigin().getY() - 5, rect.getSize().getWidth(),
rect.getSize().getHeight() + 10));
// Save context
context.restoreGState();
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:23,代码来源:PAPUtility.java
示例19: 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
示例20: 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
注:本文中的org.robovm.apple.coregraphics.CGSize类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论