Esempio n. 1
0
        /// <summary>
        /// Change the current ParameterBlock of the operation, allowing
        /// editing of image rendering chains.  The effects of such a
        /// change will be visible when a new rendering is created from
        /// this RenderableImageOp or any dependent RenderableImageOp.
        /// </summary>
        /// <param name="paramBlock"> the new ParameterBlock. </param>
        /// <returns> the old ParameterBlock. </returns>
        /// <seealso cref= #getParameterBlock </seealso>
        public virtual ParameterBlock SetParameterBlock(ParameterBlock paramBlock)
        {
            ParameterBlock oldParamBlock = this.ParamBlock;

            this.ParamBlock = (ParameterBlock)paramBlock.Clone();
            return(oldParamBlock);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a RenderedImage which represents this
        /// RenderableImageOp (including its Renderable sources) rendered
        /// according to the given RenderContext.
        ///
        /// <para> 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>
        ///
        /// </para>
        /// <para> 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.
        ///
        /// </para>
        /// <para> 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.
        ///
        /// </para>
        /// </summary>
        /// <param name="renderContext"> The RenderContext to use to perform the rendering. </param>
        /// <returns> a RenderedImage containing the desired output image. </returns>
        public virtual 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();
            ArrayList      sources            = RenderableSources;

            try
            {
                // This assumes that if there is no renderable source, that there
                // is a rendered source in paramBlock

                if (sources != null)
                {
                    ArrayList renderedSources = new ArrayList();
                    for (int i = 0; i < sources.Count; i++)
                    {
                        rcOut = MyCRIF.MapRenderContext(i, renderContext, ParamBlock, this);
                        RenderedImage rdrdImage = ((RenderableImage)sources[i]).CreateRendering(rcOut);
                        if (rdrdImage == null)
                        {
                            return(null);
                        }

                        // Add this rendered image to the ParameterBlock's
                        // list of RenderedImages.
                        renderedSources.Add(rdrdImage);
                    }

                    if (renderedSources.Count > 0)
                    {
                        renderedParamBlock.Sources = renderedSources;
                    }
                }

                return(MyCRIF.Create(renderContext, renderedParamBlock));
            }
            catch (ArrayIndexOutOfBoundsException)
            {
                // This should never happen
                return(null);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Constructs a RenderedImageOp given a
 /// ContextualRenderedImageFactory object, and
 /// a ParameterBlock containing RenderableImage sources and other
 /// parameters.  Any RenderedImage sources referenced by the
 /// ParameterBlock will be ignored.
 /// </summary>
 /// <param name="CRIF"> a ContextualRenderedImageFactory object </param>
 /// <param name="paramBlock"> a ParameterBlock containing this operation's source
 ///        images and other parameters necessary for the operation
 ///        to run. </param>
 public RenderableImageOp(ContextualRenderedImageFactory CRIF, ParameterBlock paramBlock)
 {
     this.MyCRIF     = CRIF;
     this.ParamBlock = (ParameterBlock)paramBlock.Clone();
 }