public void corrector() { compile(); int max = Math.min(grabbedImageData.size(), grabbedImagePositions.size()); GrabbedImageData gid = null; GrabbedImagePosition gip = null; for (int i = 0; i < max; i++) { for (GrabbedImageData g : grabbedImageData) { if (g != null && g.getSerialnumber() == i) { gid = g; break; } } for (GrabbedImagePosition g : grabbedImagePositions) { if (g != null && g.getSerialnumber() == i) { gip = g; } } if (gid == null || gip == null) { System.out.printf("Error : i = %d, gid = %s, gip = %s", i, gid, gip); } else if (gid.getRownumber() != gip.getRownumber()) { grabbedImagePositions.remove(gip); resetGipSerial(); } } }
public void createClones() { compile(); File dir = new File( getCompileOutputCurrentDir(), ResourceHelper.getGoogleProperty(Constants.KEY_COMPILED_OUTPUT_CLONE_DIR_NAME)); if (dir.mkdirs()) { BufferedImage shot = ResourceHelper.getImageResource(googleScreenShot); Image img; Rectangle rect; File file; String fname; for (GrabbedImagePosition gip : getGrabbedImagePositions()) { GrabbedImageData gid = null; for (GrabbedImageData g : grabbedImageData) { if (g.getSerialnumber() == gip.getSerialnumber()) { gid = g; } } try { rect = gip.getBounds(); img = shot.getSubimage(rect.x, rect.y, rect.width, rect.height); fname = null; file = null; if (gid != null) { fname = gid.getFileName(); if (fname.matches(".+\\..{3,}")) { file = new File(dir, fname); } } try { if (file == null || !file.createNewFile()) { file = new File( dir, String.format( "Clone%d info invalid or not found.png", gip.getSerialnumber())); } } catch (IOException exx) { file = new File( dir, String.format("Clone%d invalid name found.png", gip.getSerialnumber())); } ImageIO.write((RenderedImage) img, "png", file); } catch (Exception ex) { ResourceHelper.errLog("Compiler > createClones() > Error : %s", ex); } } } else { ResourceHelper.errLog("Compiler > createClone() > Unable to create clone"); } }