Point deviceCoordinate(DeviceDisplay deviceDisplay, Point p) { if (deviceDisplay.isFullScreenMode()) { return p; } else { org.microemu.device.impl.Rectangle pb = ((J2SEDeviceDisplay) deviceDisplay).getDisplayPaintable(); return new Point(p.x - pb.x, p.y - pb.y); } }
public Image createImage(String name) throws IOException { return getImage(name); }
public void repaintRequest(int x, int y, int width, int height) { MIDletAccess ma = MIDletBridge.getMIDletAccess(); if (ma == null) { return; } DisplayAccess da = ma.getDisplayAccess(); if (da == null) { return; } Displayable current = da.getCurrent(); if (current == null) { return; } Device device = DeviceFactory.getDevice(); if (device != null) { if (displayImage == null) { displayImage = new J2SEMutableImage( device.getDeviceDisplay().getFullWidth(), device.getDeviceDisplay().getFullHeight()); } Graphics gc = displayImage.getImage().getGraphics(); J2SEDeviceDisplay deviceDisplay = (J2SEDeviceDisplay) device.getDeviceDisplay(); if (!deviceDisplay.isFullScreenMode()) { deviceDisplay.paintControls(gc); } deviceDisplay.paintDisplayable(gc, x, y, width, height); fireDisplayRepaint(displayImage); } }
public int filterRGB (int x, int y, int rgb) { int a = (rgb & 0xFF000000); int r = (rgb & 0x00FF0000) >>> 16; int g = (rgb & 0x0000FF00) >>> 8; int b = (rgb & 0x000000FF); int Y = (int)(Yr * r + Yg * g + Yb * b); if (Y > 127) { return a | ((J2SEDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getBackgroundColor().getRGB(); } else { return a | ((J2SEDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getForegroundColor().getRGB(); } }
private DeviceDisplay deviceDisplay = new J2SEDeviceDisplay(this);
image = null; return createRGBImage(rgbTransformedData, width, height, true);
public int filterRGB (int x, int y, int rgb) { int a = (rgb & 0xFF000000); int r = (rgb & 0x00FF0000) >>> 16; int g = (rgb & 0x0000FF00) >>> 8; int b = (rgb & 0x000000FF); int Y = (int)(Yr * r + Yg * g + Yb * b) % 256; if (Y > 255) { Y = 255; } Color foregroundColor = ((J2SEDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getForegroundColor(); r = (int) (Rr * Y) + foregroundColor.getRed(); g = (int) (Rg * Y) + foregroundColor.getGreen(); b = (int) (Rb * Y) + foregroundColor.getBlue(); return a | (r << 16) | (g << 8) | b; }
public void init() { dc.init(); remove(dc); Rectangle r = ((J2SEDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getDisplayRectangle(); add(dc, new XYConstraints(r.x, r.y, -1, -1)); revalidate(); }
public void paintDisplayable(Graphics g, int x, int y, int width, int height) { MIDletAccess ma = MIDletBridge.getMIDletAccess(); if (ma == null) { return; } DisplayAccess da = ma.getDisplayAccess(); if (da == null) { return; } Displayable current = da.getCurrent(); if (current == null) { return; } g.setColor(foregroundColor); java.awt.Shape oldclip = g.getClip(); if (!(current instanceof Canvas) || ((Canvas) current).getWidth() != displayRectangle.width || ((Canvas) current).getHeight() != displayRectangle.height) { g.translate(displayPaintable.x, displayPaintable.y); } g.setClip(x, y, width, height); Font oldf = g.getFont(); ma.getDisplayAccess().paint(new J2SEDisplayGraphics((java.awt.Graphics2D) g, getDisplayImage())); g.setFont(oldf); if (!(current instanceof Canvas) || ((Canvas) current).getWidth() != displayRectangle.width || ((Canvas) current).getHeight() != displayRectangle.height) { g.translate(-displayPaintable.x, -displayPaintable.y); } g.setClip(oldclip); }
deviceDisplay.paintDisplayable(displayGraphics, x, y, width, height); if (!deviceDisplay.isFullScreenMode()) { deviceDisplay.paintControls(displayGraphics); if (deviceDisplay.isFullScreenMode()) { repaint(x, y, width, height); } else {
public GrayImageFilter (double Yr, double Yg, double Yb) { this.Yr = Yr; this.Yg = Yg; this.Yb = Yb; canFilterIndexColorModel = true; Color backgroundColor = ((J2SEDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getBackgroundColor(); Color foregroundColor = ((J2SEDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getForegroundColor(); Rr = (backgroundColor.getRed() - foregroundColor.getRed()) / 256d; Rg = (backgroundColor.getGreen() - foregroundColor.getGreen()) / 256d; Rb = (backgroundColor.getBlue() - foregroundColor.getBlue()) / 256d; }
public J2SEDisplayGraphics(java.awt.Graphics2D a_g, MutableImage a_image) // Andres Navarro { this.g = a_g; this.image = a_image; this.clip = a_g.getClipBounds(); Device device = DeviceFactory.getDevice(); J2SEFontManager fontManager = (J2SEFontManager) device.getFontManager(); J2SEFont tmpFont = (J2SEFont) fontManager.getFont(currentFont); this.g.setFont(tmpFont.getFont()); if (fontManager.getAntialiasing()) { this.g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } else { this.g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); } J2SEDeviceDisplay display = (J2SEDeviceDisplay) device.getDeviceDisplay(); if (display.isColor()) { if (display.backgroundColor.getRed() != 255 || display.backgroundColor.getGreen() != 255 || display.backgroundColor.getBlue() != 255 || display.foregroundColor.getRed() != 0 || display.foregroundColor.getGreen() != 0 || display.foregroundColor.getBlue() != 0) { this.filter = new RGBImageFilter(); } } else { if (display.numColors() == 2) { this.filter = new BWImageFilter(); } else { this.filter = new GrayImageFilter(); } } }
public RGBImageFilter() { canFilterIndexColorModel = true; backgroundColor = ((J2SEDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getBackgroundColor(); foregroundColor = ((J2SEDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getForegroundColor(); Rr = foregroundColor.getRed() - backgroundColor.getRed(); Rg = foregroundColor.getGreen() - backgroundColor.getGreen(); Rb = foregroundColor.getBlue() - backgroundColor.getBlue(); }
public Image createImage(InputStream is) throws IOException { if (is == null) { throw new IOException(); } return getImage(is); }
public Image createImage(byte[] imageData, int imageOffset, int imageLength) { ByteArrayInputStream is = new ByteArrayInputStream(imageData, imageOffset, imageLength); try { return getImage(is); } catch (IOException ex) { throw new IllegalArgumentException(ex.toString()); } }
private Image getImage(String str) throws IOException { // TODO not always true, there could be some loading images before // invoke startApp, right now getCurrentMIDlet returns prevoius MIDlet Object midlet = MIDletBridge.getCurrentMIDlet(); if (midlet == null) { midlet = getClass(); } InputStream is = midlet.getClass().getResourceAsStream(str); if (is == null) { throw new IOException(str + " could not be found."); } try { return getImage(is); } finally { IOUtils.closeQuietly(is); } }