Java Code Examples for com.apple.jobjc.foundation.NSPoint

The following examples show how to use com.apple.jobjc.foundation.NSPoint. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: dragonwell8_jdk   Source File: StructTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testSTRET(){
    NSPoint point = JObjC.getInstance().Foundation().NSMakePoint(3, 4);
    assertTrue(point.x() == 3);
    assertTrue(point.y() == 4);

    NSRect rect = JObjC.getInstance().Foundation().NSMakeRect(0, 1, 2, 3);
    assertTrue(rect.origin().x() == 0);
    assertTrue(rect.origin().y() == 1);
    assertTrue(rect.size().width() == 2);
    assertTrue(rect.size().height() == 3);
}
 
Example 2
public void testStructStructMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    NSPoint p = JObjC.getInstance().Foundation().NSMakePoint(3, 3);

    MsgSend sel2 = new MsgSend(runtime, "doubleIt:", p.getCoder(), p.getCoder());
    sel2.init(ctx, instObj);
    p.getCoder().push(ctx, p);
    sel2.invoke(ctx, p);

    assertEquals(6.0, p.x());
}
 
Example 3
Source Project: TencentKona-8   Source File: StructTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testSTRET(){
    NSPoint point = JObjC.getInstance().Foundation().NSMakePoint(3, 4);
    assertTrue(point.x() == 3);
    assertTrue(point.y() == 4);

    NSRect rect = JObjC.getInstance().Foundation().NSMakeRect(0, 1, 2, 3);
    assertTrue(rect.origin().x() == 0);
    assertTrue(rect.origin().y() == 1);
    assertTrue(rect.size().width() == 2);
    assertTrue(rect.size().height() == 3);
}
 
Example 4
public void testStructStructMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    NSPoint p = JObjC.getInstance().Foundation().NSMakePoint(3, 3);

    MsgSend sel2 = new MsgSend(runtime, "doubleIt:", p.getCoder(), p.getCoder());
    sel2.init(ctx, instObj);
    p.getCoder().push(ctx, p);
    sel2.invoke(ctx, p);

    assertEquals(6.0, p.x());
}
 
Example 5
Source Project: jdk8u60   Source File: StructTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testSTRET(){
    NSPoint point = JObjC.getInstance().Foundation().NSMakePoint(3, 4);
    assertTrue(point.x() == 3);
    assertTrue(point.y() == 4);

    NSRect rect = JObjC.getInstance().Foundation().NSMakeRect(0, 1, 2, 3);
    assertTrue(rect.origin().x() == 0);
    assertTrue(rect.origin().y() == 1);
    assertTrue(rect.size().width() == 2);
    assertTrue(rect.size().height() == 3);
}
 
Example 6
Source Project: jdk8u60   Source File: SubclassingTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testStructStructMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    NSPoint p = JObjC.getInstance().Foundation().NSMakePoint(3, 3);

    MsgSend sel2 = new MsgSend(runtime, "doubleIt:", p.getCoder(), p.getCoder());
    sel2.init(ctx, instObj);
    p.getCoder().push(ctx, p);
    sel2.invoke(ctx, p);

    assertEquals(6.0, p.x());
}
 
Example 7
Source Project: openjdk-jdk8u   Source File: StructTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testSTRET(){
    NSPoint point = JObjC.getInstance().Foundation().NSMakePoint(3, 4);
    assertTrue(point.x() == 3);
    assertTrue(point.y() == 4);

    NSRect rect = JObjC.getInstance().Foundation().NSMakeRect(0, 1, 2, 3);
    assertTrue(rect.origin().x() == 0);
    assertTrue(rect.origin().y() == 1);
    assertTrue(rect.size().width() == 2);
    assertTrue(rect.size().height() == 3);
}
 
Example 8
public void testStructStructMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    NSPoint p = JObjC.getInstance().Foundation().NSMakePoint(3, 3);

    MsgSend sel2 = new MsgSend(runtime, "doubleIt:", p.getCoder(), p.getCoder());
    sel2.init(ctx, instObj);
    p.getCoder().push(ctx, p);
    sel2.invoke(ctx, p);

    assertEquals(6.0, p.x());
}
 
Example 9
public void testSTRET(){
    NSPoint point = JObjC.getInstance().Foundation().NSMakePoint(3, 4);
    assertTrue(point.x() == 3);
    assertTrue(point.y() == 4);

    NSRect rect = JObjC.getInstance().Foundation().NSMakeRect(0, 1, 2, 3);
    assertTrue(rect.origin().x() == 0);
    assertTrue(rect.origin().y() == 1);
    assertTrue(rect.size().width() == 2);
    assertTrue(rect.size().height() == 3);
}
 
Example 10
public void testStructStructMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    NSPoint p = JObjC.getInstance().Foundation().NSMakePoint(3, 3);

    MsgSend sel2 = new MsgSend(runtime, "doubleIt:", p.getCoder(), p.getCoder());
    sel2.init(ctx, instObj);
    p.getCoder().push(ctx, p);
    sel2.invoke(ctx, p);

    assertEquals(6.0, p.x());
}
 
Example 11
Source Project: jdk8u-jdk   Source File: StructTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testSTRET(){
    NSPoint point = JObjC.getInstance().Foundation().NSMakePoint(3, 4);
    assertTrue(point.x() == 3);
    assertTrue(point.y() == 4);

    NSRect rect = JObjC.getInstance().Foundation().NSMakeRect(0, 1, 2, 3);
    assertTrue(rect.origin().x() == 0);
    assertTrue(rect.origin().y() == 1);
    assertTrue(rect.size().width() == 2);
    assertTrue(rect.size().height() == 3);
}
 
Example 12
Source Project: jdk8u-jdk   Source File: SubclassingTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testStructStructMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    NSPoint p = JObjC.getInstance().Foundation().NSMakePoint(3, 3);

    MsgSend sel2 = new MsgSend(runtime, "doubleIt:", p.getCoder(), p.getCoder());
    sel2.init(ctx, instObj);
    p.getCoder().push(ctx, p);
    sel2.invoke(ctx, p);

    assertEquals(6.0, p.x());
}
 
Example 13
Source Project: hottub   Source File: StructTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testSTRET(){
    NSPoint point = JObjC.getInstance().Foundation().NSMakePoint(3, 4);
    assertTrue(point.x() == 3);
    assertTrue(point.y() == 4);

    NSRect rect = JObjC.getInstance().Foundation().NSMakeRect(0, 1, 2, 3);
    assertTrue(rect.origin().x() == 0);
    assertTrue(rect.origin().y() == 1);
    assertTrue(rect.size().width() == 2);
    assertTrue(rect.size().height() == 3);
}
 
Example 14
Source Project: hottub   Source File: SubclassingTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testStructStructMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    NSPoint p = JObjC.getInstance().Foundation().NSMakePoint(3, 3);

    MsgSend sel2 = new MsgSend(runtime, "doubleIt:", p.getCoder(), p.getCoder());
    sel2.init(ctx, instObj);
    p.getCoder().push(ctx, p);
    sel2.invoke(ctx, p);

    assertEquals(6.0, p.x());
}
 
Example 15
Source Project: openjdk-8-source   Source File: StructTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testSTRET(){
    NSPoint point = JObjC.getInstance().Foundation().NSMakePoint(3, 4);
    assertTrue(point.x() == 3);
    assertTrue(point.y() == 4);

    NSRect rect = JObjC.getInstance().Foundation().NSMakeRect(0, 1, 2, 3);
    assertTrue(rect.origin().x() == 0);
    assertTrue(rect.origin().y() == 1);
    assertTrue(rect.size().width() == 2);
    assertTrue(rect.size().height() == 3);
}
 
Example 16
public void testStructStructMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    NSPoint p = JObjC.getInstance().Foundation().NSMakePoint(3, 3);

    MsgSend sel2 = new MsgSend(runtime, "doubleIt:", p.getCoder(), p.getCoder());
    sel2.init(ctx, instObj);
    p.getCoder().push(ctx, p);
    sel2.invoke(ctx, p);

    assertEquals(6.0, p.x());
}
 
Example 17
Source Project: openjdk-8   Source File: StructTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testSTRET(){
    NSPoint point = JObjC.getInstance().Foundation().NSMakePoint(3, 4);
    assertTrue(point.x() == 3);
    assertTrue(point.y() == 4);

    NSRect rect = JObjC.getInstance().Foundation().NSMakeRect(0, 1, 2, 3);
    assertTrue(rect.origin().x() == 0);
    assertTrue(rect.origin().y() == 1);
    assertTrue(rect.size().width() == 2);
    assertTrue(rect.size().height() == 3);
}
 
Example 18
Source Project: openjdk-8   Source File: SubclassingTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testStructStructMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    NSPoint p = JObjC.getInstance().Foundation().NSMakePoint(3, 3);

    MsgSend sel2 = new MsgSend(runtime, "doubleIt:", p.getCoder(), p.getCoder());
    sel2.init(ctx, instObj);
    p.getCoder().push(ctx, p);
    sel2.invoke(ctx, p);

    assertEquals(6.0, p.x());
}
 
Example 19
Source Project: jdk8u_jdk   Source File: StructTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testSTRET(){
    NSPoint point = JObjC.getInstance().Foundation().NSMakePoint(3, 4);
    assertTrue(point.x() == 3);
    assertTrue(point.y() == 4);

    NSRect rect = JObjC.getInstance().Foundation().NSMakeRect(0, 1, 2, 3);
    assertTrue(rect.origin().x() == 0);
    assertTrue(rect.origin().y() == 1);
    assertTrue(rect.size().width() == 2);
    assertTrue(rect.size().height() == 3);
}
 
Example 20
Source Project: jdk8u_jdk   Source File: SubclassingTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testStructStructMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    NSPoint p = JObjC.getInstance().Foundation().NSMakePoint(3, 3);

    MsgSend sel2 = new MsgSend(runtime, "doubleIt:", p.getCoder(), p.getCoder());
    sel2.init(ctx, instObj);
    p.getCoder().push(ctx, p);
    sel2.invoke(ctx, p);

    assertEquals(6.0, p.x());
}
 
Example 21
Source Project: jdk8u-jdk   Source File: StructTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testSTRET(){
    NSPoint point = JObjC.getInstance().Foundation().NSMakePoint(3, 4);
    assertTrue(point.x() == 3);
    assertTrue(point.y() == 4);

    NSRect rect = JObjC.getInstance().Foundation().NSMakeRect(0, 1, 2, 3);
    assertTrue(rect.origin().x() == 0);
    assertTrue(rect.origin().y() == 1);
    assertTrue(rect.size().width() == 2);
    assertTrue(rect.size().height() == 3);
}
 
Example 22
Source Project: jdk8u-jdk   Source File: SubclassingTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testStructStructMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    NSPoint p = JObjC.getInstance().Foundation().NSMakePoint(3, 3);

    MsgSend sel2 = new MsgSend(runtime, "doubleIt:", p.getCoder(), p.getCoder());
    sel2.init(ctx, instObj);
    p.getCoder().push(ctx, p);
    sel2.invoke(ctx, p);

    assertEquals(6.0, p.x());
}
 
Example 23
Source Project: jdk8u-dev-jdk   Source File: StructTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testSTRET(){
    NSPoint point = JObjC.getInstance().Foundation().NSMakePoint(3, 4);
    assertTrue(point.x() == 3);
    assertTrue(point.y() == 4);

    NSRect rect = JObjC.getInstance().Foundation().NSMakeRect(0, 1, 2, 3);
    assertTrue(rect.origin().x() == 0);
    assertTrue(rect.origin().y() == 1);
    assertTrue(rect.size().width() == 2);
    assertTrue(rect.size().height() == 3);
}
 
Example 24
public void testStructStructMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    NSPoint p = JObjC.getInstance().Foundation().NSMakePoint(3, 3);

    MsgSend sel2 = new MsgSend(runtime, "doubleIt:", p.getCoder(), p.getCoder());
    sel2.init(ctx, instObj);
    p.getCoder().push(ctx, p);
    sel2.invoke(ctx, p);

    assertEquals(6.0, p.x());
}
 
Example 25
Source Project: dragonwell8_jdk   Source File: IntroTest.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
Example 26
public NSPoint doubleIt(NSPoint p){
    System.out.println("Doubling NSPoint(" + p.x() + ", " + p.y() + ").");
    p.setX(p.x() * 2);
    p.setY(p.y() * 2);
    return p;
}
 
Example 27
Source Project: TencentKona-8   Source File: IntroTest.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
Example 28
public NSPoint doubleIt(NSPoint p){
    System.out.println("Doubling NSPoint(" + p.x() + ", " + p.y() + ").");
    p.setX(p.x() * 2);
    p.setY(p.y() * 2);
    return p;
}
 
Example 29
Source Project: jdk8u60   Source File: IntroTest.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void testFrameworks(){
        // First, get an instance of JObjC:
        final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance();

        // It's your gateway to the frameworks.
        final FoundationFramework FND = JOBJC.Foundation();
        final AppKitFramework APP = JOBJC.AppKit();

        // From which you can then access...

        // enums, defines, constants
        int nsmye = FND.NSMaxYEdge();
        boolean debug = FND.NSDebugEnabled();

        // structs
        NSPoint p = FND.makeNSPoint();
        p.setX(3);
        assertEquals(3.0, p.x());

        // C functions
        NSPoint p2 = FND.NSMakePoint(12, 34);
        assertEquals(12.0, p2.x());

        // ... Let's create an AutoreleasePool before we go on
        NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init();

        // Objective-C classes
        NSStringClass nsc = FND.NSString();

        // class-methods
        NSString nsStringClassDescr = nsc.description();

        // instances
        NSString nsi = ((NSString) FND.NSString().alloc()).init();

        // instance methods
        NSString d = nsi.description();

        // The bridge marshals some types for you, but it doesn't
        // convert between NSString and Java String automatically.
        // For that we use Utils.get().strings().nsString(String)
        // and Utils.get().strings().javaString(NSString);

        assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr));

        NSString format = Utils.get().strings().nsString("Foo bar %d baz");

        NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34);
        String jformatted = Utils.get().strings().javaString(formatted);

        assertEquals("Foo bar 34 baz", jformatted);

        // Reveal in Finder
//        NSString file = Utils.get().strings().nsString(
//                "/Applications/Calculator.app/Contents/Resources/Calculator.icns");
//        APP.NSWorkspace().sharedWorkspace()
//           .selectFile_inFileViewerRootedAtPath(file, null);

        pool.drain();
    }
 
Example 30
Source Project: jdk8u60   Source File: SubclassingTest.java    License: GNU General Public License v2.0 4 votes vote down vote up
public NSPoint doubleIt(NSPoint p){
    System.out.println("Doubling NSPoint(" + p.x() + ", " + p.y() + ").");
    p.setX(p.x() * 2);
    p.setY(p.y() * 2);
    return p;
}