@Test public void testPropertyGeneration() { BufferedImage source = new BufferedImage(10, 10, BufferedImage.TYPE_3BYTE_BGR); RenderedOp affine = AffineDescriptor.create( source, new AffineTransform(), Interpolation.getInstance(Interpolation.INTERP_NEAREST), null, null); Object property = new GTAffinePropertyGenerator().getProperty("ROI", (Object) affine); assertEquals(java.awt.Image.UndefinedProperty, property); }
public Object getProperty(String name, Object opNode) { validate(name, opNode); if (opNode instanceof RenderedOp && name.equalsIgnoreCase("roi")) { RenderedOp op = (RenderedOp) opNode; ParameterBlock pb = op.getParameterBlock(); RenderedImage src = pb.getRenderedSource(0); Object property = src.getProperty("ROI"); if (property == null || property.equals(java.awt.Image.UndefinedProperty) || !(property instanceof ROI)) { if (pb.getNumParameters() >= 4 && pb.getObjectParameter(3) != null) { property = pb.getObjectParameter(3); } else { return java.awt.Image.UndefinedProperty; } } ROI srcROI = (ROI) property; Interpolation interp = (Interpolation) pb.getObjectParameter(1); Rectangle srcBounds = null; PlanarImage dst = op.getRendering(); if (dst instanceof GeometricOpImage && ((GeometricOpImage) dst).getBorderExtender() == null) { srcBounds = new Rectangle( src.getMinX() + interp.getLeftPadding(), src.getMinY() + interp.getTopPadding(), src.getWidth() - interp.getWidth() + 1, src.getHeight() - interp.getHeight() + 1); } else { srcBounds = new Rectangle( src.getMinX(), src.getMinY(), src.getWidth(), src.getHeight()); } if (!srcBounds.contains(srcROI.getBounds())) { srcROI = srcROI.intersect(new ROIShape(srcBounds)); } AffineTransform transform = (AffineTransform) pb.getObjectParameter(0); ROI dstROI; if (srcROI.getClass().equals(ROI.class)) { ParameterBlock paramBlock = new ParameterBlock(); paramBlock.add(transform); paramBlock.add(Interpolation.getInstance(Interpolation.INTERP_NEAREST)); Hints localHints = new Hints(op.getRenderingHints()); localHints.remove(JAI.KEY_IMAGE_LAYOUT); ImageLayout il = new ImageLayout(); Rectangle dstBounds = op.getBounds(); il.setMinX(dstBounds.x); il.setMinY(dstBounds.y); il.setWidth(dstBounds.width); il.setHeight(dstBounds.height); il.setTileWidth(op.getTileWidth()); il.setTileWidth(op.getTileHeight()); localHints.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il)); dstROI = srcROI.performImageOp("Affine", paramBlock, 0, localHints); } else { dstROI = srcROI.transform((AffineTransform) transform); } Rectangle dstBounds = op.getBounds(); if (!dstBounds.contains(dstROI.getBounds())) { dstROI = dstROI.intersect(new ROIShape(dstBounds)); } return dstROI; } return java.awt.Image.UndefinedProperty; }
GTAffinePropertyGenerator extends PropertyGeneratorImpl { public Object getProperty(String name, Object opNode) { validate(name, opNode); if (opNode instanceof RenderedOp && name.equalsIgnoreCase("roi")) { RenderedOp op = (RenderedOp) opNode; ParameterBlock pb = op.getParameterBlock(); RenderedImage src = pb.getRenderedSource(0); Object property = src.getProperty("ROI"); if (property == null || property.equals(java.awt.Image.UndefinedProperty) || !(property instanceof ROI)) { if (pb.getNumParameters() >= 4 && pb.getObjectParameter(3) != null) { property = pb.getObjectParameter(3); } else { return java.awt.Image.UndefinedProperty; } } ROI srcROI = (ROI) property; Interpolation interp = (Interpolation) pb.getObjectParameter(1); Rectangle srcBounds = null; PlanarImage dst = op.getRendering(); if (dst instanceof GeometricOpImage && ((GeometricOpImage) dst).getBorderExtender() == null) { srcBounds = new Rectangle( src.getMinX() + interp.getLeftPadding(), src.getMinY() + interp.getTopPadding(), src.getWidth() - interp.getWidth() + 1, src.getHeight() - interp.getHeight() + 1); } else { srcBounds = new Rectangle( src.getMinX(), src.getMinY(), src.getWidth(), src.getHeight()); } if (!srcBounds.contains(srcROI.getBounds())) { srcROI = srcROI.intersect(new ROIShape(srcBounds)); } AffineTransform transform = (AffineTransform) pb.getObjectParameter(0); ROI dstROI; if (srcROI.getClass().equals(ROI.class)) { ParameterBlock paramBlock = new ParameterBlock(); paramBlock.add(transform); paramBlock.add(Interpolation.getInstance(Interpolation.INTERP_NEAREST)); Hints localHints = new Hints(op.getRenderingHints()); localHints.remove(JAI.KEY_IMAGE_LAYOUT); ImageLayout il = new ImageLayout(); Rectangle dstBounds = op.getBounds(); il.setMinX(dstBounds.x); il.setMinY(dstBounds.y); il.setWidth(dstBounds.width); il.setHeight(dstBounds.height); il.setTileWidth(op.getTileWidth()); il.setTileWidth(op.getTileHeight()); localHints.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il)); dstROI = srcROI.performImageOp("Affine", paramBlock, 0, localHints); } else { dstROI = srcROI.transform((AffineTransform) transform); } Rectangle dstBounds = op.getBounds(); if (!dstBounds.contains(dstROI.getBounds())) { dstROI = dstROI.intersect(new ROIShape(dstBounds)); } return dstROI; } return java.awt.Image.UndefinedProperty; } }
GTAffinePropertyGenerator extends PropertyGeneratorImpl { public Object getProperty(String name, Object opNode) { validate(name, opNode); if (opNode instanceof RenderedOp && name.equalsIgnoreCase("roi")) { RenderedOp op = (RenderedOp) opNode; ParameterBlock pb = op.getParameterBlock(); RenderedImage src = pb.getRenderedSource(0); Object property = src.getProperty("ROI"); if (property == null || property.equals(java.awt.Image.UndefinedProperty) || !(property instanceof ROI)) { if (pb.getNumParameters() >= 4 && pb.getObjectParameter(3) != null) { property = pb.getObjectParameter(3); } else { return java.awt.Image.UndefinedProperty; } } ROI srcROI = (ROI) property; Interpolation interp = (Interpolation) pb.getObjectParameter(1); Rectangle srcBounds = null; PlanarImage dst = op.getRendering(); if (dst instanceof GeometricOpImage && ((GeometricOpImage) dst).getBorderExtender() == null) { srcBounds = new Rectangle( src.getMinX() + interp.getLeftPadding(), src.getMinY() + interp.getTopPadding(), src.getWidth() - interp.getWidth() + 1, src.getHeight() - interp.getHeight() + 1); } else { srcBounds = new Rectangle( src.getMinX(), src.getMinY(), src.getWidth(), src.getHeight()); } if (!srcBounds.contains(srcROI.getBounds())) { srcROI = srcROI.intersect(new ROIShape(srcBounds)); } AffineTransform transform = (AffineTransform) pb.getObjectParameter(0); ROI dstROI; if (srcROI.getClass().equals(ROI.class)) { ParameterBlock paramBlock = new ParameterBlock(); paramBlock.add(transform); paramBlock.add(Interpolation.getInstance(Interpolation.INTERP_NEAREST)); Hints localHints = new Hints(op.getRenderingHints()); localHints.remove(JAI.KEY_IMAGE_LAYOUT); ImageLayout il = new ImageLayout(); Rectangle dstBounds = op.getBounds(); il.setMinX(dstBounds.x); il.setMinY(dstBounds.y); il.setWidth(dstBounds.width); il.setHeight(dstBounds.height); il.setTileWidth(op.getTileWidth()); il.setTileWidth(op.getTileHeight()); localHints.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il)); dstROI = srcROI.performImageOp("Affine", paramBlock, 0, localHints); } else { dstROI = srcROI.transform((AffineTransform) transform); } Rectangle dstBounds = op.getBounds(); if (!dstBounds.contains(dstROI.getBounds())) { dstROI = dstROI.intersect(new ROIShape(dstBounds)); } return dstROI; } return java.awt.Image.UndefinedProperty; } GTAffinePropertyGenerator(); }
GTAffinePropertyGenerator extends PropertyGeneratorImpl { public Object getProperty(String name, Object opNode) { validate(name, opNode); if (opNode instanceof RenderedOp && name.equalsIgnoreCase("roi")) { RenderedOp op = (RenderedOp) opNode; ParameterBlock pb = op.getParameterBlock(); RenderedImage src = pb.getRenderedSource(0); Object property = src.getProperty("ROI"); if (property == null || property.equals(java.awt.Image.UndefinedProperty) || !(property instanceof ROI)) { if (pb.getNumParameters() >= 4 && pb.getObjectParameter(3) != null) { property = pb.getObjectParameter(3); } else { return java.awt.Image.UndefinedProperty; } } ROI srcROI = (ROI) property; Interpolation interp = (Interpolation) pb.getObjectParameter(1); Rectangle srcBounds = null; PlanarImage dst = op.getRendering(); if (dst instanceof GeometricOpImage && ((GeometricOpImage) dst).getBorderExtender() == null) { srcBounds = new Rectangle( src.getMinX() + interp.getLeftPadding(), src.getMinY() + interp.getTopPadding(), src.getWidth() - interp.getWidth() + 1, src.getHeight() - interp.getHeight() + 1); } else { srcBounds = new Rectangle( src.getMinX(), src.getMinY(), src.getWidth(), src.getHeight()); } if (!srcBounds.contains(srcROI.getBounds())) { srcROI = srcROI.intersect(new ROIShape(srcBounds)); } AffineTransform transform = (AffineTransform) pb.getObjectParameter(0); ROI dstROI; if (srcROI.getClass().equals(ROI.class)) { ParameterBlock paramBlock = new ParameterBlock(); paramBlock.add(transform); paramBlock.add(Interpolation.getInstance(Interpolation.INTERP_NEAREST)); Hints localHints = new Hints(op.getRenderingHints()); localHints.remove(JAI.KEY_IMAGE_LAYOUT); ImageLayout il = new ImageLayout(); Rectangle dstBounds = op.getBounds(); il.setMinX(dstBounds.x); il.setMinY(dstBounds.y); il.setWidth(dstBounds.width); il.setHeight(dstBounds.height); il.setTileWidth(op.getTileWidth()); il.setTileWidth(op.getTileHeight()); localHints.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il)); dstROI = srcROI.performImageOp("Affine", paramBlock, 0, localHints); } else { dstROI = srcROI.transform((AffineTransform) transform); } Rectangle dstBounds = op.getBounds(); if (!dstBounds.contains(dstROI.getBounds())) { dstROI = dstROI.intersect(new ROIShape(dstBounds)); } return dstROI; } return java.awt.Image.UndefinedProperty; } GTAffinePropertyGenerator(); static synchronized void register(boolean force); Object getProperty(String name, Object opNode); }
GTAffinePropertyGenerator extends PropertyGeneratorImpl { public Object getProperty(String name, Object opNode) { validate(name, opNode); if (opNode instanceof RenderedOp && name.equalsIgnoreCase("roi")) { RenderedOp op = (RenderedOp) opNode; ParameterBlock pb = op.getParameterBlock(); RenderedImage src = pb.getRenderedSource(0); Object property = src.getProperty("ROI"); if (property == null || property.equals(java.awt.Image.UndefinedProperty) || !(property instanceof ROI)) { if (pb.getNumParameters() >= 4 && pb.getObjectParameter(3) != null) { property = pb.getObjectParameter(3); } else { return java.awt.Image.UndefinedProperty; } } ROI srcROI = (ROI) property; Interpolation interp = (Interpolation) pb.getObjectParameter(1); Rectangle srcBounds = null; PlanarImage dst = op.getRendering(); if (dst instanceof GeometricOpImage && ((GeometricOpImage) dst).getBorderExtender() == null) { srcBounds = new Rectangle( src.getMinX() + interp.getLeftPadding(), src.getMinY() + interp.getTopPadding(), src.getWidth() - interp.getWidth() + 1, src.getHeight() - interp.getHeight() + 1); } else { srcBounds = new Rectangle( src.getMinX(), src.getMinY(), src.getWidth(), src.getHeight()); } if (!srcBounds.contains(srcROI.getBounds())) { srcROI = srcROI.intersect(new ROIShape(srcBounds)); } AffineTransform transform = (AffineTransform) pb.getObjectParameter(0); ROI dstROI; if (srcROI.getClass().equals(ROI.class)) { ParameterBlock paramBlock = new ParameterBlock(); paramBlock.add(transform); paramBlock.add(Interpolation.getInstance(Interpolation.INTERP_NEAREST)); Hints localHints = new Hints(op.getRenderingHints()); localHints.remove(JAI.KEY_IMAGE_LAYOUT); ImageLayout il = new ImageLayout(); Rectangle dstBounds = op.getBounds(); il.setMinX(dstBounds.x); il.setMinY(dstBounds.y); il.setWidth(dstBounds.width); il.setHeight(dstBounds.height); il.setTileWidth(op.getTileWidth()); il.setTileWidth(op.getTileHeight()); localHints.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il)); dstROI = srcROI.performImageOp("Affine", paramBlock, 0, localHints); } else { dstROI = srcROI.transform((AffineTransform) transform); } Rectangle dstBounds = op.getBounds(); if (!dstBounds.contains(dstROI.getBounds())) { dstROI = dstROI.intersect(new ROIShape(dstBounds)); } return dstROI; } return java.awt.Image.UndefinedProperty; } GTAffinePropertyGenerator(); static synchronized void register(boolean force); Object getProperty(String name, Object opNode);  }