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


Java CGRect类代码示例

本文整理汇总了Java中org.robovm.apple.coregraphics.CGRect的典型用法代码示例。如果您正苦于以下问题:Java CGRect类的具体用法?Java CGRect怎么用?Java CGRect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: didFinishLaunching

import org.robovm.apple.coregraphics.CGRect; //导入依赖的package包/类
@Override
public boolean didFinishLaunching (UIApplication app, UIApplicationLaunchOptions launchOpts) {
  // create a full-screen window
  CGRect bounds = UIScreen.getMainScreen().getBounds();
  UIWindow window = new UIWindow(bounds);

  // create and initialize the PlayN platform
  RoboPlatform.Config config = new RoboPlatform.Config();
  config.orients = UIInterfaceOrientationMask.All;
  RoboPlatform pf = RoboPlatform.create(window, config);
  addStrongRef(pf);

  // create our game
  new CuteGame(pf);

  // make our main window visible (the platform starts when the window becomes viz)
  window.makeKeyAndVisible();
  addStrongRef(window);
  return true;
}
 
开发者ID:playn,项目名称:playn-samples,代码行数:21,代码来源:CuteGameRoboVM.java

示例2: didFinishLaunching

import org.robovm.apple.coregraphics.CGRect; //导入依赖的package包/类
@Override
public boolean didFinishLaunching (UIApplication app, UIApplicationLaunchOptions launchOpts) {
  // create a full-screen window
  CGRect bounds = UIScreen.getMainScreen().getBounds();
  UIWindow window = new UIWindow(bounds);

  // configure and create the PlayN platform
  RoboPlatform.Config config = new RoboPlatform.Config();
  config.orients = UIInterfaceOrientationMask.All;
  RoboPlatform plat = RoboPlatform.create(window, config);

  // create and initialize our game
  new Drop(plat);

  // make our main window visible (this starts the platform)
  window.makeKeyAndVisible();
  addStrongRef(window);
  return true;
}
 
开发者ID:playn,项目名称:playn-samples,代码行数:20,代码来源:DropRoboVM.java

示例3: didFinishLaunching

import org.robovm.apple.coregraphics.CGRect; //导入依赖的package包/类
@Override
public boolean didFinishLaunching (UIApplication app, UIApplicationLaunchOptions launchOpts) {
  // create a full-screen window
  CGRect bounds = UIScreen.getMainScreen().getBounds();
  UIWindow window = new UIWindow(bounds);

  // create and initialize the PlayN platform
  RoboPlatform.Config config = new RoboPlatform.Config();
  config.orients = UIInterfaceOrientationMask.All;
  RoboPlatform pf = RoboPlatform.create(window, config);
  addStrongRef(pf);

  // create our game
  new HelloGame(pf);

  // make our main window visible (the platform starts when the window becomes viz)
  window.makeKeyAndVisible();
  addStrongRef(window);
  return true;
}
 
开发者ID:playn,项目名称:playn-samples,代码行数:21,代码来源:HelloGameRoboVM.java

示例4: didFinishLaunching

import org.robovm.apple.coregraphics.CGRect; //导入依赖的package包/类
@Override
public boolean didFinishLaunching (UIApplication app, UIApplicationLaunchOptions launchOpts) {
  // create a full-screen window
  CGRect bounds = UIScreen.getMainScreen().getBounds();
  UIWindow window = new UIWindow(bounds);

  // create and initialize the PlayN platform
  RoboPlatform.Config config = new RoboPlatform.Config();
  config.orients = UIInterfaceOrientationMask.Landscape;
  RoboPlatform pf = RoboPlatform.create(window, config);
  addStrongRef(pf);

  new Physics(pf);

  // make our main window visible (the platform starts when the window becomes viz)
  window.makeKeyAndVisible();
  addStrongRef(window);
  return true;
}
 
开发者ID:playn,项目名称:playn-samples,代码行数:20,代码来源:PhysicsRoboVM.java

示例5: draw

import org.robovm.apple.coregraphics.CGRect; //导入依赖的package包/类
@Override public void draw(Object ctx, float dx, float dy, float dw, float dh,
                           float sx, float sy, float sw, float sh) {
  // adjust our source rect to account for the scale factor
  sx *= scale.factor;
  sy *= scale.factor;
  sw *= scale.factor;
  sh *= scale.factor;

  CGImage image = cgImage();
  CGBitmapContext bctx = (CGBitmapContext)ctx;
  float iw = image.getWidth(), ih = image.getHeight();
  float scaleX = dw/sw, scaleY = dh/sh;

  // pesky fiddling to cope with the fact that UIImages are flipped
  bctx.saveGState();
  bctx.translateCTM(dx, dy+dh);
  bctx.scaleCTM(1, -1);
  bctx.clipToRect(new CGRect(0, 0, dw, dh));
  bctx.translateCTM(-sx*scaleX, -(ih-(sy+sh))*scaleY);
  bctx.drawImage(new CGRect(0, 0, iw*scaleX, ih*scaleY), image);
  bctx.restoreGState();
}
 
开发者ID:playn,项目名称:playn,代码行数:23,代码来源:RoboImage.java

示例6: RoboCanvas

import org.robovm.apple.coregraphics.CGRect; //导入依赖的package包/类
public RoboCanvas(Graphics gfx, RoboCanvasImage image) {
  super(gfx, image);

  // if our size is invalid, we'll fail below at CGBitmapContext, so fail here more usefully
  if (width <= 0 || height <= 0) throw new IllegalArgumentException(
    "Invalid size " + width + "x" + height);
  states.addFirst(new RoboCanvasState());

  bctx = image.bctx;
  // clear the canvas before we scale our bitmap context to avoid artifacts
  bctx.clearRect(new CGRect(0, 0, texWidth(), texHeight()));

  // CG coordinate system is OpenGL-style (0,0 in lower left); so we flip it
  Scale scale = image.scale();
  bctx.translateCTM(0, scale.scaled(height));
  bctx.scaleCTM(scale.factor, -scale.factor);
}
 
开发者ID:playn,项目名称:playn,代码行数:18,代码来源:RoboCanvas.java

示例7: didFinishLaunching

import org.robovm.apple.coregraphics.CGRect; //导入依赖的package包/类
@Override
public boolean didFinishLaunching (UIApplication app, UIApplicationLaunchOptions launchOpts) {
  // create a full-screen window
  CGRect bounds = UIScreen.getMainScreen().getBounds();
  UIWindow window = new UIWindow(bounds);

  // configure and register the PlayN platform
  RoboPlatform.Config config = new RoboPlatform.Config();
  config.orients = UIInterfaceOrientationMask.All;
  RoboPlatform pf = RoboPlatform.create(window, config);

  // create and initialize our game
  TestsGame game = new TestsGame(pf, new String[0]);

  // make our main window visible
  window.makeKeyAndVisible();
  addStrongRef(window);
  return true;
}
 
开发者ID:playn,项目名称:playn,代码行数:20,代码来源:TestsGameRoboVM.java

示例8: willShowKeyboard

import org.robovm.apple.coregraphics.CGRect; //导入依赖的package包/类
@Method(selector = "willShowKeyboard:")
public void willShowKeyboard(NSNotification notification) {
    NSValue uiKeyboardFrameEndUserInfoKey = (NSValue) notification.getUserInfo().get(new NSString("UIKeyboardFrameEndUserInfoKey"));
    CGRect keyboardFrame = uiKeyboardFrameEndUserInfoKey.rectValue();
    CGRect kbLocalFrame = convertRectFromView(keyboardFrame, getWindow());

    Foundation.log(String.format("Show: %s", kbLocalFrame.toString()));

    CGRect f = this.getFrame();
    f.getSize().setHeight(kbLocalFrame.getOrigin().getY());
    setFrame(f);

    double duration = notification.getUserInfo().getDouble(new NSString("UIKeyboardAnimationDurationUserInfoKey"));
    UIView.animate(duration, new Runnable() {
        @Override
        public void run() {
            layoutIfNeeded();
        }
    });
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:21,代码来源:LayoutBridge.java

示例9: willHideKeyboard

import org.robovm.apple.coregraphics.CGRect; //导入依赖的package包/类
@Method(selector = "willHideKeyboard:")
public void willHideKeyboard(NSNotification notification) {
    NSValue uiKeyboardFrameEndUserInfoKey = (NSValue) notification.getUserInfo().get(new NSString("UIKeyboardFrameEndUserInfoKey"));
    CGRect keyboardFrame = uiKeyboardFrameEndUserInfoKey.rectValue();
    CGRect kbLocalFrame = convertRectFromView(keyboardFrame, getWindow());

    Foundation.log(String.format("Hide: %s", kbLocalFrame.toString()));

    CGRect f = this.getFrame();
    f.getSize().setHeight(kbLocalFrame.getOrigin().getY());
    setFrame(f);

    double duration = notification.getUserInfo().getDouble(new NSString("UIKeyboardAnimationDurationUserInfoKey"));
    UIView.animate(duration, new Runnable() {
        @Override
        public void run() {
            layoutIfNeeded();
        }
    });
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:21,代码来源:LayoutBridge.java

示例10: resizeImage

import org.robovm.apple.coregraphics.CGRect; //导入依赖的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

示例11: drawInContext

import org.robovm.apple.coregraphics.CGRect; //导入依赖的package包/类
public void drawInContext(CGContext context) {
    BitmapDrawableConstantState state = this.internalConstantState;
    CGRect containerRect = this.getBounds();
    CGRect dstRect = CGRect.Zero();

    UIImage image = state.getImage();

    Gravity.applyGravity(state.getGravity(), image.getSize().getWidth(), image.getSize().getHeight(), containerRect, dstRect);

    if(scaledImageCache == null) {
        //self.scaledImageCache = [self resizeImage:image toWidth:dstRect.size.width height:dstRect.size.height];
    }
    UIGraphics.pushContext(context);
    //[self.scaledImageCache drawInRect:dstRect];
    image.draw(dstRect);

    UIGraphics.popContext();
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:19,代码来源:BitmapDrawable.java

示例12: drawInContext

import org.robovm.apple.coregraphics.CGRect; //导入依赖的package包/类
@Override
public void drawInContext(CGContext context) {
    RotateDrawableConstantState state = this.internalConstantState;
    CGRect bounds = getBounds();

    // Calculate pivot point
    double px = state.isPivotXRelative() ? (bounds.getSize().getWidth() * state.getPivot().getX()) : state.getPivot().getX();
    double py = state.isPivotYRelative() ? (bounds.getSize().getHeight() * state.getPivot().getY()) : state.getPivot().getY();

    // Save context state
    context.saveGState();

    // Rotate
    context.translateCTM(px, py);
    context.rotateCTM(state.getCurrentDegrees() * Math.PI / 180.d);
    context.translateCTM(-px, -py);

    // Draw child
    state.getDrawable().drawInContext(context);

    // Restore context state
    context.restoreGState();
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:24,代码来源:RotateDrawable.java

示例13: onBoundsChangeToRect

import org.robovm.apple.coregraphics.CGRect; //导入依赖的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

示例14: findAndScrollToFirstResponder

import org.robovm.apple.coregraphics.CGRect; //导入依赖的package包/类
public static UIView findAndScrollToFirstResponder(UIView view) {
    UIView result = null;
    if(view.isFirstResponder()) {
        result = view;
    }

    for (UIView subView : view.getSubviews()) {
        UIView firstResponder = findAndScrollToFirstResponder(subView);
        if(firstResponder != null) {
            if(view instanceof UIScrollView) {
                UIScrollView sv = (UIScrollView) view;
                CGRect r = view.convertRectFromView(firstResponder.getFrame(), firstResponder);
                sv.scrollRectToVisible(r, false);

                result = view;
            } else {
                result = firstResponder;
            }
            break;
        }
    }

    return result;
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:25,代码来源:UIViewLayoutBridgeUtil.java

示例15: setUp

import org.robovm.apple.coregraphics.CGRect; //导入依赖的package包/类
@Before
public void setUp() {
    LayoutBridge bridge = new LayoutBridge(new CGRect(0, 0, 100, 100));

    LayoutInflater inflater = new LayoutInflater();
    UIView inflatedView = inflater.inflate("test/framelayout_gravity.xml", bridge, true);

    parent = UIViewLayoutUtil.findViewById(inflatedView, "parent");

    leftView = UIViewLayoutUtil.findViewById(inflatedView, "left");
    rightView = UIViewLayoutUtil.findViewById(inflatedView, "right");
    centerHorizontalView = UIViewLayoutUtil.findViewById(inflatedView, "center_horizontal");

    leftCenterVerticalView = UIViewLayoutUtil.findViewById(inflatedView, "left_center_vertical");
    rightCenterVerticalView = UIViewLayoutUtil.findViewById(inflatedView, "right_center_vertical");
    centerView = UIViewLayoutUtil.findViewById(inflatedView, "center");

    leftBottomView = UIViewLayoutUtil.findViewById(inflatedView, "left_bottom");
    rightBottomView = UIViewLayoutUtil.findViewById(inflatedView, "right_bottom");
    centerHorizontalBottomView = UIViewLayoutUtil.findViewById(inflatedView, "center_horizontal_bottom");
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:22,代码来源:FrameLayoutGravityTest.java


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