com.apple.jobjc.foundation.NSPoint Java Examples

The following examples show how to use com.apple.jobjc.foundation.NSPoint. 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 File: StructTest.java    From openjdk-jdk8u-backup with 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
Source File: StructTest.java    From openjdk-8 with 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 #3
Source File: SubclassingTest.java    From openjdk-8-source with 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 #4
Source File: StructTest.java    From openjdk-8-source with 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 #5
Source File: SubclassingTest.java    From openjdk-8 with 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 #6
Source File: SubclassingTest.java    From hottub with 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 File: StructTest.java    From hottub with 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
Source File: StructTest.java    From jdk8u_jdk with 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 #9
Source File: SubclassingTest.java    From jdk8u-jdk with 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 #10
Source File: StructTest.java    From jdk8u-jdk with 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 #11
Source File: SubclassingTest.java    From jdk8u_jdk with 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 #12
Source File: SubclassingTest.java    From openjdk-jdk8u-backup with 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 File: StructTest.java    From jdk8u-jdk with 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 File: SubclassingTest.java    From openjdk-jdk8u with 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 File: StructTest.java    From jdk8u-dev-jdk with 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
Source File: StructTest.java    From dragonwell8_jdk with 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 #17
Source File: SubclassingTest.java    From dragonwell8_jdk with 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 #18
Source File: SubclassingTest.java    From jdk8u-dev-jdk with 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 File: StructTest.java    From TencentKona-8 with 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 File: SubclassingTest.java    From TencentKona-8 with 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 File: StructTest.java    From jdk8u60 with 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 File: SubclassingTest.java    From jdk8u60 with 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 File: SubclassingTest.java    From jdk8u-jdk with 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 #24
Source File: StructTest.java    From openjdk-jdk8u with 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 #25
Source File: IntroTest.java    From jdk8u_jdk with 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
Source File: SubclassingTest.java    From jdk8u-jdk with 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;
}
 
Example #27
Source File: IntroTest.java    From jdk8u-jdk with 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
Source File: SubclassingTest.java    From openjdk-8 with 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;
}
 
Example #29
Source File: IntroTest.java    From jdk8u-dev-jdk with 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 File: SubclassingTest.java    From jdk8u_jdk with 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;
}