604 public final MenuItem createMenuItem(String title) { 605 return createMenuItem(title, null); 606 } 607 608 public final MenuItem createMenuItem(String title, MenuItem.Callback callback) { 609 return createMenuItem(title, callback, KeyEvent.VK_UNDEFINED, KeyEvent.MODIFIER_NONE); 610 } 611 612 public final MenuItem createMenuItem(String title, MenuItem.Callback callback, 613 int shortcutKey, int shortcutModifiers) { 614 return createMenuItem(title, callback, shortcutKey, shortcutModifiers, null); 615 } 616 617 public final MenuItem createMenuItem(String title, MenuItem.Callback callback, 618 int shortcutKey, int shortcutModifiers, Pixels pixels) { 619 return new MenuItem(title, callback, shortcutKey, shortcutModifiers, pixels); 620 } 621 622 public abstract Pixels createPixels(int width, int height, ByteBuffer data); 623 public abstract Pixels createPixels(int width, int height, IntBuffer data); 624 public abstract Pixels createPixels(int width, int height, IntBuffer data, float scale); 625 protected abstract int staticPixels_getNativeFormat(); 626 627 /* utility method called from native code */ 628 static Pixels createPixels(int width, int height, int[] data, float scale) { 629 return Application.GetApplication().createPixels(width, height, IntBuffer.wrap(data), scale); 630 } 631 632 /* utility method called from native code */ 633 static float getScaleFactor(final int x, final int y, final int w, final int h) { 634 float scale = 0.0f; 635 // Find the maximum scale for screens this area overlaps 636 for (Screen s : Screen.getScreens()) { 637 final int sx = s.getX(), sy = s.getY(), sw = s.getWidth(), sh = s.getHeight(); 638 if (x < (sx + sw) && (x + w) > sx && y < (sy + sh) && (y + h) > sy) { 639 if (scale < s.getRenderScale()) { 640 scale = s.getRenderScale(); 641 } 642 } 643 } 644 return scale == 0.0f ? 1.0f : scale; 645 } 646 647 648 public abstract Robot createRobot(); 649 650 protected abstract double staticScreen_getVideoRefreshPeriod(); 651 protected abstract Screen[] staticScreen_getScreens(); 652 653 public abstract Timer createTimer(Runnable runnable); 654 protected abstract int staticTimer_getMinPeriod(); 655 protected abstract int staticTimer_getMaxPeriod(); 656 657 public final EventLoop createEventLoop() { 658 return new EventLoop(); 659 } 660 | 604 public final MenuItem createMenuItem(String title) { 605 return createMenuItem(title, null); 606 } 607 608 public final MenuItem createMenuItem(String title, MenuItem.Callback callback) { 609 return createMenuItem(title, callback, KeyEvent.VK_UNDEFINED, KeyEvent.MODIFIER_NONE); 610 } 611 612 public final MenuItem createMenuItem(String title, MenuItem.Callback callback, 613 int shortcutKey, int shortcutModifiers) { 614 return createMenuItem(title, callback, shortcutKey, shortcutModifiers, null); 615 } 616 617 public final MenuItem createMenuItem(String title, MenuItem.Callback callback, 618 int shortcutKey, int shortcutModifiers, Pixels pixels) { 619 return new MenuItem(title, callback, shortcutKey, shortcutModifiers, pixels); 620 } 621 622 public abstract Pixels createPixels(int width, int height, ByteBuffer data); 623 public abstract Pixels createPixels(int width, int height, IntBuffer data); 624 public abstract Pixels createPixels(int width, int height, IntBuffer data, float scalex, float scaley); 625 protected abstract int staticPixels_getNativeFormat(); 626 627 /* utility method called from native code */ 628 static Pixels createPixels(int width, int height, int[] data, float scalex, float scaley) { 629 return Application.GetApplication().createPixels(width, height, IntBuffer.wrap(data), scalex, scaley); 630 } 631 632 /* utility method called from native code */ 633 static float getScaleFactor(final int x, final int y, final int w, final int h) { 634 float scale = 0.0f; 635 // Find the maximum scale for screens this area overlaps 636 for (Screen s : Screen.getScreens()) { 637 final int sx = s.getX(), sy = s.getY(), sw = s.getWidth(), sh = s.getHeight(); 638 if (x < (sx + sw) && (x + w) > sx && y < (sy + sh) && (y + h) > sy) { 639 if (scale < s.getRecommendedOutputScaleX()) { 640 scale = s.getRecommendedOutputScaleX(); 641 } 642 if (scale < s.getRecommendedOutputScaleY()) { 643 scale = s.getRecommendedOutputScaleY(); 644 } 645 } 646 } 647 return scale == 0.0f ? 1.0f : scale; 648 } 649 650 651 public abstract Robot createRobot(); 652 653 protected abstract double staticScreen_getVideoRefreshPeriod(); 654 protected abstract Screen[] staticScreen_getScreens(); 655 656 public abstract Timer createTimer(Runnable runnable); 657 protected abstract int staticTimer_getMinPeriod(); 658 protected abstract int staticTimer_getMaxPeriod(); 659 660 public final EventLoop createEventLoop() { 661 return new EventLoop(); 662 } 663 |