Long imageId = Long.valueOf(request.getPathInfo().substring(1)); // 123 Image image = imageDAO.find(imageId); // Get Image from DB. // Image class is just a Javabean with the following properties: // private String filename; // private Long length; // private InputStream content; response.setHeader("Content-Type", getServletContext().getMimeType(image.getFilename())); response.setHeader("Content-Length", String.valueOf(image.getLength())); response.setHeader("Content-Disposition", "inline; filename=\"" + image.getFilename() + "\""); BufferedInputStream input = null; BufferedOutputStream output = null; try { input = new BufferedInputStream(image.getContent()); output = new BufferedOutputStream(response.getOutputStream()); byte[] buffer = new byte[8192]; for (int length = 0; (length = input.read(buffer)) > 0) { output.write(buffer, 0, length); } } finally { if (output != null) try { output.close(); } catch (IOException logOrIgnore) {} if (input != null) try { input.close(); } catch (IOException logOrIgnore) {} }
/** * stores the lastScreenImage in the current bundle path with the given name * * @param name file name (.png is added if not there) * @return the absolute file name * @throws java.io.IOException if not possible */ public String getLastScreenImageFile(String name) throws IOException { return getScreen().getLastScreenImageFromScreen().getFile(ImagePath.getBundlePath(), name); }
public static Boolean popError(Object... args) { if (SX.isHeadless()) { log.error("running headless: popError"); } else { return (Boolean) doPop(PopType.POPERROR, args); } return false; }
private IRobot getRobotForRegion() { if (getScreen() == null || isScreenUnion) { return Screen.getPrimaryScreen().getRobot(); } return getScreen().getRobot(); }
protected static IRobot getRobot(Region reg) { if (reg == null || null == reg.getScreen()) { return getPrimaryScreen().getMouseRobot(); } else { return reg.getScreen().getRobot(); } }
/** * stop and remove all observers registered for this region from the list <br> * events for those observers are removed as well * @param reg */ public static void remove(Region reg) { for (String name : reg.getObserver().getNames()) { remove(name); } }
/** * stores the lastScreenImage in the current bundle path with a created unique name * * @return the absolute file name * @throws java.io.IOException if not possible */ public String getLastScreenImageFile() throws IOException { return getScreen().getLastScreenImageFile(ImagePath.getBundlePath(), null); }
/** * stores the lastScreenImage in the given path with the given name * * @param path path to use * @param name file name (.png is added if not there) * @return the absolute file name * @throws java.io.IOException if not possible */ public String getLastScreenImageFile(String path, String name) throws IOException { return getScreen().getLastScreenImageFromScreen().getFile(path, name); }
public void saveLastScreenImage() { ScreenImage simg = getScreen().getLastScreenImageFromScreen(); if (simg != null) { simg.saveLastScreenImage(runTime.fSikulixStore); } } //</editor-fold>
/** * Get the color at the given Point for details: see java.awt.Robot and ...Color * * @return The Color of the Point */ public Color getColor() { if (getScreen() == null) { return null; } return getScreen().getRobot().getColorAt(x, y); }
/** * tell the observer to repeat this event's observe action after given time in secs * after returning from this handler (APPEAR, VANISH) * @param secs seconds */ public void repeat(long secs) { region.getObserver().repeat(name, secs); }
private Location checkAndSetRemote(Location loc) { if (!isOtherScreen()) { return loc; } return loc.setOtherScreen(scr); }
/** * negative offset goes towards top of screen <br>might be off current screen * * @param offset pixels * @return point with given offset vertically to middle point on top edge */ public Location aboveAt(int offset) { return checkAndSetRemote(new Location(x + w / 2, y + offset)); }
public static Boolean popAsk(Object... args) { if (SX.isHeadless()) { log.error("running headless: popAsk"); } else { return (Boolean) doPop(PopType.POPASK, args); } return false; }