/** * Creates a RenderedImage which represents this RenderableImageOp (including its Renderable * sources) rendered according to the given RenderContext. * * <p>This method supports chaining of either Renderable or RenderedImage operations. If sources * in the ParameterBlock used to construct the RenderableImageOp are RenderableImages, then a * three step process is followed: * * <ol> * <li>mapRenderContext() is called on the associated CRIF for each RenderableImage source; * <li>createRendering() is called on each of the RenderableImage sources using the * backwards-mapped RenderContexts obtained in step 1, resulting in a rendering of each * source; * <li>ContextualRenderedImageFactory.create() is called with a new ParameterBlock containing * the parameters of the RenderableImageOp and the RenderedImages that were created by the * createRendering() calls. * </ol> * * <p>If the elements of the source Vector of the ParameterBlock used to construct the * RenderableImageOp are instances of RenderedImage, then the CRIF.create() method is called * immediately using the original ParameterBlock. This provides a basis case for the recursion. * * <p>The created RenderedImage may have a property identified by the String HINTS_OBSERVED to * indicate which RenderingHints (from the RenderContext) were used to create the image. In * addition any RenderedImages that are obtained via the getSources() method on the created * RenderedImage may have such a property. * * @param renderContext The RenderContext to use to perform the rendering. * @return a RenderedImage containing the desired output image. */ public RenderedImage createRendering(RenderContext renderContext) { RenderedImage image = null; RenderContext rcOut = null; // Clone the original ParameterBlock; if the ParameterBlock // contains RenderableImage sources, they will be replaced by // RenderedImages. ParameterBlock renderedParamBlock = (ParameterBlock) paramBlock.clone(); Vector<? extends Object> sources = getRenderableSources(); try { // This assumes that if there is no renderable source, that there // is a rendered source in paramBlock if (sources != null) { Vector<Object> renderedSources = new Vector<>(); for (int i = 0; i < sources.size(); i++) { rcOut = myCRIF.mapRenderContext( i, renderContext, paramBlock, this); RenderedImage rdrdImage = ((RenderableImage) sources.elementAt(i)).createRendering(rcOut); if (rdrdImage == null) { return null; } // Add this rendered image to the ParameterBlock's // list of RenderedImages. renderedSources.addElement(rdrdImage); } if (renderedSources.size() > 0) { renderedParamBlock.setSources(renderedSources); } } return myCRIF.create(renderContext, renderedParamBlock); } catch (ArrayIndexOutOfBoundsException e) { // This should never happen return null; } }
/** Gets the minimum Y coordinate of the rendering-independent image data. */ public float getMinY() { if (boundingBox == null) { boundingBox = myCRIF.getBounds2D(paramBlock); } return (float) boundingBox.getMinY(); }
/** * Return a list of names recognized by getProperty. * * @return a list of property names. */ public String[] getPropertyNames() { return myCRIF.getPropertyNames(); }
/** * Returns true if successive renderings (that is, calls to createRendering() or * createScaledRendering()) with the same arguments may produce different results. This method may * be used to determine whether an existing rendering may be cached and reused. The CRIF's * isDynamic method will be called. * * @return {@code true} if successive renderings with the same arguments might produce different * results; {@code false} otherwise. */ public boolean isDynamic() { return myCRIF.isDynamic(); }
/** * Gets a property from the property set of this image. If the property name is not recognized, * java.awt.Image.UndefinedProperty will be returned. * * @param name the name of the property to get, as a String. * @return a reference to the property Object, or the value java.awt.Image.UndefinedProperty. */ public Object getProperty(String name) { return myCRIF.getProperty(paramBlock, name); }