/// <summary> /// Returns a unique instance of an ImageFilter object which will /// actually perform the filtering for the specified ImageConsumer. /// The default implementation just clones this object. /// <para> /// Note: This method is intended to be called by the ImageProducer /// of the Image whose pixels are being filtered. Developers using /// this class to filter pixels from an image should avoid calling /// this method directly since that operation could interfere /// with the filtering operation. /// </para> /// </summary> /// <param name="ic"> the specified <code>ImageConsumer</code> </param> /// <returns> an <code>ImageFilter</code> used to perform the /// filtering for the specified <code>ImageConsumer</code>. </returns> public virtual ImageFilter GetFilterInstance(ImageConsumer ic) { ImageFilter instance = (ImageFilter)Clone(); instance.Consumer = ic; return(instance); }
/// <summary> /// Requests that a given ImageConsumer have the image data delivered /// one more time in top-down, left-right order. The request is /// handed to the ImageFilter for further processing, since the /// ability to preserve the pixel ordering depends on the filter. /// /// <para> /// This method is public as a side effect /// of this class implementing /// the <code>ImageProducer</code> interface. /// It should not be called from user code, /// and its behavior if called from user code is unspecified. /// /// </para> /// </summary> /// <seealso cref= ImageConsumer </seealso> public virtual void RequestTopDownLeftRightResend(ImageConsumer ic) { if (Proxies != null) { ImageFilter imgf = (ImageFilter)Proxies[ic]; if (imgf != null) { imgf.ResendTopDownLeftRight(Src); } } }
/// <summary> /// Starts production of the filtered image. /// If the specified <code>ImageConsumer</code> /// isn't already a consumer of the filtered image, /// an instance of the original <code>ImageFilter</code> /// is created /// (using the filter's <code>getFilterInstance</code> method) /// to manipulate the image data /// for the <code>ImageConsumer</code>. /// The filter instance for the <code>ImageConsumer</code> /// is then passed to the <code>startProduction</code> method /// of the original <code>ImageProducer</code>. /// /// <para> /// This method is public as a side effect /// of this class implementing /// the <code>ImageProducer</code> interface. /// It should not be called from user code, /// and its behavior if called from user code is unspecified. /// /// </para> /// </summary> /// <param name="ic"> the consumer for the filtered image </param> /// <seealso cref= ImageConsumer </seealso> public virtual void StartProduction(ImageConsumer ic) { if (Proxies == null) { Proxies = new Hashtable(); } ImageFilter imgf = (ImageFilter)Proxies[ic]; if (imgf == null) { imgf = Filter.GetFilterInstance(ic); Proxies[ic] = imgf; } Src.StartProduction(imgf); }
/// <summary> /// Adds the specified <code>ImageConsumer</code> /// to the list of consumers interested in data for the filtered image. /// An instance of the original <code>ImageFilter</code> /// is created /// (using the filter's <code>getFilterInstance</code> method) /// to manipulate the image data /// for the specified <code>ImageConsumer</code>. /// The newly created filter instance /// is then passed to the <code>addConsumer</code> method /// of the original <code>ImageProducer</code>. /// /// <para> /// This method is public as a side effect /// of this class implementing /// the <code>ImageProducer</code> interface. /// It should not be called from user code, /// and its behavior if called from user code is unspecified. /// /// </para> /// </summary> /// <param name="ic"> the consumer for the filtered image </param> /// <seealso cref= ImageConsumer </seealso> public virtual void AddConsumer(ImageConsumer ic) { lock (this) { if (Proxies == null) { Proxies = new Hashtable(); } if (!Proxies.ContainsKey(ic)) { ImageFilter imgf = Filter.GetFilterInstance(ic); Proxies[ic] = imgf; Src.AddConsumer(imgf); } } }
/// <summary> /// Removes an ImageConsumer from the list of consumers interested in /// data for this image. /// /// <para> /// This method is public as a side effect /// of this class implementing /// the <code>ImageProducer</code> interface. /// It should not be called from user code, /// and its behavior if called from user code is unspecified. /// /// </para> /// </summary> /// <seealso cref= ImageConsumer </seealso> public virtual void RemoveConsumer(ImageConsumer ic) { lock (this) { if (Proxies != null) { ImageFilter imgf = (ImageFilter)Proxies[ic]; if (imgf != null) { Src.RemoveConsumer(imgf); Proxies.Remove(ic); if (Proxies.Count == 0) { Proxies = null; } } } } }
/// <summary> /// Constructs an ImageProducer object from an existing ImageProducer /// and a filter object. </summary> /// <param name="orig"> the specified <code>ImageProducer</code> </param> /// <param name="imgf"> the specified <code>ImageFilter</code> </param> /// <seealso cref= ImageFilter </seealso> /// <seealso cref= java.awt.Component#createImage </seealso> public FilteredImageSource(ImageProducer orig, ImageFilter imgf) { Src = orig; Filter = imgf; }