@Override public SWTGraphics graphics () { return (SWTGraphics)super.graphics(); }
@Override public SWTGraphics graphics () { return (SWTGraphics)super.graphics(); }
@Override protected AsyncImage<BufferedImage> createAsyncImage(float width, float height) { return platform.graphics().createAsyncImage(width, height); }
@Override protected Image createStaticImage(BufferedImage bufimg, Scale scale) { return platform.graphics().createStaticImage(bufimg, scale); }
/** Sets the title of the window to {@code title}. */ public void setTitle(String title) { graphics().setTitle(title); }
@Override protected Image createStaticImage(BufferedImage bufimg, Scale scale) { return platform.graphics().createStaticImage(bufimg, scale); }
@Override protected AsyncImage<BufferedImage> createAsyncImage(float width, float height) { return platform.graphics().createAsyncImage(width, height); }
/** Sets the title of the window to {@code title}. */ public void setTitle(String title) { graphics().setTitle(title); }
protected Scale assetScale() { return (assetScale != null) ? assetScale : platform.graphics().ctx().scale; }
protected Scale assetScale() { return (assetScale != null) ? assetScale : plat.graphics().scale(); }
protected Scale assetScale() { return (assetScale != null) ? assetScale : plat.graphics().scale(); }
protected Scale assetScale() { return (assetScale != null) ? assetScale : platform.graphics().ctx().scale; }
@Override public Image getRemoteImage(final String url, float width, float height) { final JavaAsyncImage image = platform.graphics().createAsyncImage(width, height); platform.invokeAsync(new Runnable() { public void run () { try { setImageLater(image, ImageIO.read(new URL(url)), Scale.ONE); } catch (Exception error) { setErrorLater(image, error); } } }); return image; }
@Override public Image getRemoteImage(final String url, float width, float height) { final JavaAsyncImage image = platform.graphics().createAsyncImage(width, height); platform.invokeAsync(new Runnable() { public void run () { try { setImageLater(image, ImageIO.read(new URL(url)), Scale.ONE); } catch (Exception error) { setErrorLater(image, error); } } }); return image; }
@Override protected ImageImpl.Data load (String path) throws Exception { Exception error = null; for (Scale.ScaledResource rsrc : assetScale().getScaledResources(path)) { try { BufferedImage image = requireResource(rsrc.path).readImage(); // if image is at a higher scale factor than the view, scale to the view display factor Scale viewScale = plat.graphics().scale(), imageScale = rsrc.scale; float viewImageRatio = viewScale.factor / imageScale.factor; if (viewImageRatio < 1) { image = scaleImage(image, viewImageRatio); imageScale = viewScale; } if (plat.config.convertImagesOnLoad) { BufferedImage convertedImage = JavaGraphics.convertImage(image); if (convertedImage != image) { plat.log().debug("Converted image: " + path + " [type=" + image.getType() + "]"); image = convertedImage; } } return new ImageImpl.Data(imageScale, image, image.getWidth(), image.getHeight()); } catch (FileNotFoundException fnfe) { error = fnfe; // keep going, checking for lower resolution images } } plat.log().warn("Could not load image: " + path + " [error=" + error + "]"); throw error != null ? error : new FileNotFoundException(path); }
@Override protected ImageImpl.Data load (String path) throws Exception { Exception error = null; for (Scale.ScaledResource rsrc : assetScale().getScaledResources(path)) { try { BufferedImage image = requireResource(rsrc.path).readImage(); // if image is at a higher scale factor than the view, scale to the view display factor Scale viewScale = plat.graphics().scale(), imageScale = rsrc.scale; float viewImageRatio = viewScale.factor / imageScale.factor; if (viewImageRatio < 1) { image = scaleImage(image, viewImageRatio); imageScale = viewScale; } if (plat.config.convertImagesOnLoad) { BufferedImage convertedImage = JavaGraphics.convertImage(image); if (convertedImage != image) { plat.log().debug("Converted image: " + path + " [type=" + image.getType() + "]"); image = convertedImage; } } return new ImageImpl.Data(imageScale, image, image.getWidth(), image.getHeight()); } catch (FileNotFoundException fnfe) { error = fnfe; // keep going, checking for lower resolution images } } plat.log().warn("Could not load image: " + path + " [error=" + error + "]"); throw error != null ? error : new FileNotFoundException(path); }
BufferedImage image = requireResource(rsrc.path).readImage(); Scale viewScale = platform.graphics().ctx().scale, imageScale = rsrc.scale; float viewImageRatio = viewScale.factor / imageScale.factor; if (viewImageRatio < 1) {
BufferedImage image = requireResource(rsrc.path).readImage(); Scale viewScale = platform.graphics().ctx().scale, imageScale = rsrc.scale; float viewImageRatio = viewScale.factor / imageScale.factor; if (viewImageRatio < 1) {
@Override void update() { while (Mouse.next()) { double time = (double) (Mouse.getEventNanoseconds() / 1000000); int btn = getButton(Mouse.getEventButton()); Point m = new Point(Mouse.getEventX(), Display.getHeight() - Mouse.getEventY() - 1); platform.graphics().transformMouse(m); int dx = Mouse.getEventDX(), dy = -Mouse.getEventDY(); if (btn != -1) { if (Mouse.getEventButtonState()) { onMouseDown(time, m.x, m.y, btn); } else { onMouseUp(time, m.x, m.y, btn); } } else if (Mouse.getEventDWheel() != 0) { int delta = Mouse.getEventDWheel() > 0 ? -1 : 1; onMouseWheelScroll(time, m.x, m.y, delta); } else { onMouseMove(time, m.x, m.y, dx, dy); } } }
@Override void update() { while (Mouse.next()) { double time = (double) (Mouse.getEventNanoseconds() / 1000000); int btn = getButton(Mouse.getEventButton()); Point m = new Point(Mouse.getEventX(), Display.getHeight() - Mouse.getEventY() - 1); platform.graphics().transformMouse(m); int dx = Mouse.getEventDX(), dy = -Mouse.getEventDY(); if (btn != -1) { if (Mouse.getEventButtonState()) { onMouseDown(time, m.x, m.y, btn); } else { onMouseUp(time, m.x, m.y, btn); } } else if (Mouse.getEventDWheel() != 0) { int delta = Mouse.getEventDWheel() > 0 ? -1 : 1; onMouseWheelScroll(time, m.x, m.y, delta); } else { onMouseMove(time, m.x, m.y, dx, dy); } } }