Java 类java.awt.image.renderable.RenderContext 实例源码

项目:Push2Display    文件:GraphicsUtil.java   
/**
 * Draws a <code>Filter</code> (<code>RenderableImage</code>) into a
 * Graphics 2D.<p>
 *
 * This method also attempts to unwind the rendering chain a bit.
 * So it knows about certain operations (like affine, pad,
 * composite), rather than applying each of these operations in
 * turn it accounts for their affects through modifications to the
 * Graphics2D.  This avoids generating lots of intermediate images.
 *
 * @param g2d    The Graphics to draw into.
 * @param filter The filter to draw
 */
public static void drawImage(Graphics2D g2d,
                             RenderableImage filter) {
    if (filter instanceof PaintRable) {
        PaintRable pr = (PaintRable)filter;
        if (pr.paintRable(g2d))
            // paintRable succeeded so we are done...
            return;
    }

    // Get our sources image...
    // System.out.println("UnOpt: " + filter);
    AffineTransform at = g2d.getTransform();
    RenderedImage ri = filter.createRendering
        (new RenderContext(at, g2d.getClip(), g2d.getRenderingHints()));

    if (ri == null)
        return;

    g2d.setTransform(IDENTITY);
    drawImage(g2d, GraphicsUtil.wrap(ri));
    g2d.setTransform(at);
}
项目:Push2Display    文件:BackgroundRable8Bit.java   
/**
 * Creates a RenderedImage that represented a rendering of this image
 * using a given RenderContext.  This is the most general way to obtain a
 * rendering of a RenderableImage.
 *
 * <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 produce the rendering.
 * @return a RenderedImage containing the rendered data.
 */
public RenderedImage createRendering(RenderContext renderContext){

    Rectangle2D r2d = getBounds2D();

    // System.out.println("Rendering called");

    Shape aoi = renderContext.getAreaOfInterest();
    if (aoi != null) {
        Rectangle2D aoiR2d = aoi.getBounds2D();
        // System.out.println("R2d: " + r2d);
        // System.out.println("AOI: " + aoiR2d);

        if ( ! r2d.intersects(aoiR2d) )
            return null;

        Rectangle2D.intersect(r2d, aoiR2d, r2d);
    }

    Filter background = getBackground(node, null, r2d);
    // System.out.println("BG: " + background);
    if ( background == null)
        return null;

    background = new PadRable8Bit(background, r2d, PadMode.ZERO_PAD);


    RenderedImage ri = background.createRendering
        (new RenderContext(renderContext.getTransform(), r2d,
                           renderContext.getRenderingHints()));
    // System.out.println("RI: [" + ri.getMinX() + ", "
    //                    + ri.getMinY() + ", " +
    //                    + ri.getWidth() + ", " +
    //                    + ri.getHeight() + "]");
    // org.ImageDisplay.showImage("BG: ", ri);
    return ri;
}
项目:Push2Display    文件:GraphicsUtil.java   
/**
 * Draws a <code>Filter</code> (<code>RenderableImage</code>) into a
 * Graphics 2D.<p>
 *
 * This method also attempts to unwind the rendering chain a bit.
 * So it knows about certain operations (like affine, pad,
 * composite), rather than applying each of these operations in
 * turn it accounts for their affects through modifications to the
 * Graphics2D.  This avoids generating lots of intermediate images.
 *
 * @param g2d    The Graphics to draw into.
 * @param filter The filter to draw
 */
public static void drawImage(Graphics2D g2d,
                             RenderableImage filter) {
    if (filter instanceof PaintRable) {
        PaintRable pr = (PaintRable)filter;
        if (pr.paintRable(g2d))
            // paintRable succeeded so we are done...
            return;
    }

    // Get our sources image...
    // System.out.println("UnOpt: " + filter);
    AffineTransform at = g2d.getTransform();
    RenderedImage ri = filter.createRendering
        (new RenderContext(at, g2d.getClip(), g2d.getRenderingHints()));

    if (ri == null)
        return;

    g2d.setTransform(IDENTITY);
    drawImage(g2d, GraphicsUtil.wrap(ri));
    g2d.setTransform(at);
}
项目:feathers-sdk    文件:GraphicsUtil.java   
/**
 * Draws a <tt>Filter</tt> (<tt>RenderableImage</tt>) into a
 * Graphics 2D.<p>
 *
 * This method also attempts to unwind the rendering chain a bit.
 * So it knows about certain operations (like affine, pad,
 * composite), rather than applying each of these operations in
 * turn it accounts for their affects through modifications to the
 * Graphics2D.  This avoids generating lots of intermediate images.
 *
 * @param g2d    The Graphics to draw into.
 * @param filter The filter to draw
 */
public static void drawImage(Graphics2D g2d,
                             RenderableImage filter) {
    if (filter instanceof PaintRable) {
        PaintRable pr = (PaintRable)filter;
        if (pr.paintRable(g2d))
            // paintRable succeeded so we are done...
            return;
    }

    // Get our sources image...
    // System.out.println("UnOpt: " + filter);
    AffineTransform at = g2d.getTransform();
    RenderedImage ri = filter.createRendering
        (new RenderContext(at, g2d.getClip(), g2d.getRenderingHints()));

    if (ri == null)
        return;

    g2d.setTransform(IDENTITY);
    drawImage(g2d, GraphicsUtil.wrap(ri));
    g2d.setTransform(at);
}
项目:Push2Display    文件:BatikHistogramNormalizationFilter8Bit.java   
public RenderedImage createRendering(RenderContext rc) {
    //
    // Get source's rendered image
    //
    RenderedImage srcRI = getSource().createRendering(rc);

    if(srcRI == null)
        return null;

    computeHistogram(rc);

    SampleModel sm = srcRI.getSampleModel();
    int bands = sm.getNumBands();

    // System.out.println("Slope, Intercept: " + slope + ", " + intercept);
    TransferFunction [] tfs = new TransferFunction[bands];
    TransferFunction    tf  = new LinearTransfer(slope, intercept);
    for (int i=0; i<tfs.length; i++)
        tfs[i] = tf;

    return new ComponentTransferRed(convertSourceCS(srcRI), tfs, null);
}
项目:Push2Display    文件:StaticRenderer.java   
protected CachableRed renderGNR() {
    AffineTransform at, rcAT;
    at = usr2dev;
    rcAT = new AffineTransform(at.getScaleX(), at.getShearY(),
                               at.getShearX(), at.getScaleY(),
                               0, 0);

    RenderContext rc = new RenderContext(rcAT, null, renderingHints);

    RenderedImage ri = rootFilter.createRendering(rc);
    if (ri == null)
        return null;

    CachableRed ret;
    ret = GraphicsUtil.wrap(ri);
    ret = setupCache(ret);

    int dx = Math.round((float)at.getTranslateX());
    int dy = Math.round((float)at.getTranslateY());
    ret = new TranslateRed(ret, ret.getMinX()+dx, ret.getMinY()+dy);
    ret = GraphicsUtil.convertTosRGB(ret);

    return ret;
}
项目:Push2Display    文件:AffineRable8Bit.java   
public RenderedImage createRendering(RenderContext rc) {
    // Degenerate Affine no output image..
    if (invAffine == null) return null;

    // Just copy over the rendering hints.
    RenderingHints rh = rc.getRenderingHints();
    if (rh == null) rh = new RenderingHints(null);

    // Map the area of interest to our input...
    Shape aoi = rc.getAreaOfInterest();
    if (aoi != null)
        aoi = invAffine.createTransformedShape(aoi);

    // update the current affine transform
    AffineTransform at = rc.getTransform();
    at.concatenate(affine);

    // Return what our input creates (it should factor in our affine).
    return getSource().createRendering(new RenderContext(at, aoi, rh));
}
项目:Push2Display    文件:AbstractRable.java   
public RenderedImage createScaledRendering(int w, int h,
                                       RenderingHints hints) {
    float sX = w/getWidth();
    float sY = h/getHeight();
    float scale = Math.min(sX, sY);

    AffineTransform at = AffineTransform.getScaleInstance(scale, scale);
    RenderContext rc = new RenderContext(at, hints);

    float dX = (getWidth()*scale)-w;
    float dY = (getHeight()*scale)-h;

    RenderedImage ri = createRendering(rc);
    CachableRed cr = RenderedImageCachableRed.wrap(ri);
    return new PadRed(cr, new Rectangle((int)(dX/2), (int)(dY/2), w, h),
                      PadMode.ZERO_PAD, null);
}
项目:Push2Display    文件:GraphicsUtil.java   
/**
 * Draws a <code>Filter</code> (<code>RenderableImage</code>) into a
 * Graphics 2D after taking into account a particular
 * <code>RenderContext</code>.<p>
 *
 * This method also attempts to unwind the rendering chain a bit.
 * So it knows about certain operations (like affine, pad,
 * composite), rather than applying each of these operations in
 * turn it accounts for their affects through modifications to the
 * Graphics2D. This avoids generating lots of intermediate images.
 *
 * @param g2d    The Graphics to draw into.
 * @param filter The filter to draw
 * @param rc The render context that controls the drawing operation.
 */
public static void drawImage(Graphics2D      g2d,
                             RenderableImage filter,
                             RenderContext   rc) {

    AffineTransform origDev  = g2d.getTransform();
    Shape           origClip = g2d.getClip();
    RenderingHints  origRH   = g2d.getRenderingHints();

    Shape clip = rc.getAreaOfInterest();
    if (clip != null)
        g2d.clip(clip);
    g2d.transform(rc.getTransform());
    g2d.setRenderingHints(rc.getRenderingHints());

    drawImage(g2d, filter);

    g2d.setTransform(origDev);
    g2d.setClip(origClip);
    g2d.setRenderingHints(origRH);
}
项目:Push2Display    文件:BatikHistogramNormalizationFilter8Bit.java   
public RenderedImage createRendering(RenderContext rc) {
    //
    // Get source's rendered image
    //
    RenderedImage srcRI = getSource().createRendering(rc);

    if(srcRI == null)
        return null;

    computeHistogram(rc);

    SampleModel sm = srcRI.getSampleModel();
    int bands = sm.getNumBands();

    // System.out.println("Slope, Intercept: " + slope + ", " + intercept);
    TransferFunction [] tfs = new TransferFunction[bands];
    TransferFunction    tf  = new LinearTransfer(slope, intercept);
    for (int i=0; i<tfs.length; i++)
        tfs[i] = tf;

    return new ComponentTransferRed(convertSourceCS(srcRI), tfs, null);
}
项目:Push2Display    文件:StaticRenderer.java   
protected CachableRed renderGNR() {
    AffineTransform at, rcAT;
    at = usr2dev;
    rcAT = new AffineTransform(at.getScaleX(), at.getShearY(),
                               at.getShearX(), at.getScaleY(),
                               0, 0);

    RenderContext rc = new RenderContext(rcAT, null, renderingHints);

    RenderedImage ri = rootFilter.createRendering(rc);
    if (ri == null)
        return null;

    CachableRed ret;
    ret = GraphicsUtil.wrap(ri);
    ret = setupCache(ret);

    int dx = Math.round((float)at.getTranslateX());
    int dy = Math.round((float)at.getTranslateY());
    ret = new TranslateRed(ret, ret.getMinX()+dx, ret.getMinY()+dy);
    ret = GraphicsUtil.convertTosRGB(ret);

    return ret;
}
项目:Push2Display    文件:AffineRable8Bit.java   
public RenderedImage createRendering(RenderContext rc) {
    // Degenerate Affine no output image..
    if (invAffine == null) return null;

    // Just copy over the rendering hints.
    RenderingHints rh = rc.getRenderingHints();
    if (rh == null) rh = new RenderingHints(null);

    // Map the area of interest to our input...
    Shape aoi = rc.getAreaOfInterest();
    if (aoi != null)
        aoi = invAffine.createTransformedShape(aoi);

    // update the current affine transform
    AffineTransform at = rc.getTransform();
    at.concatenate(affine);

    // Return what our input creates (it should factor in our affine).
    return getSource().createRendering(new RenderContext(at, aoi, rh));
}
项目:Push2Display    文件:AbstractRable.java   
public RenderedImage createScaledRendering(int w, int h,
                                       RenderingHints hints) {
    float sX = w/getWidth();
    float sY = h/getHeight();
    float scale = Math.min(sX, sY);

    AffineTransform at = AffineTransform.getScaleInstance(scale, scale);
    RenderContext rc = new RenderContext(at, hints);

    float dX = (getWidth()*scale)-w;
    float dY = (getHeight()*scale)-h;

    RenderedImage ri = createRendering(rc);
    CachableRed cr = RenderedImageCachableRed.wrap(ri);
    return new PadRed(cr, new Rectangle((int)(dX/2), (int)(dY/2), w, h),
                      PadMode.ZERO_PAD, null);
}
项目:Push2Display    文件:GraphicsUtil.java   
/**
 * Draws a <code>Filter</code> (<code>RenderableImage</code>) into a
 * Graphics 2D after taking into account a particular
 * <code>RenderContext</code>.<p>
 *
 * This method also attempts to unwind the rendering chain a bit.
 * So it knows about certain operations (like affine, pad,
 * composite), rather than applying each of these operations in
 * turn it accounts for their affects through modifications to the
 * Graphics2D. This avoids generating lots of intermediate images.
 *
 * @param g2d    The Graphics to draw into.
 * @param filter The filter to draw
 * @param rc The render context that controls the drawing operation.
 */
public static void drawImage(Graphics2D      g2d,
                             RenderableImage filter,
                             RenderContext   rc) {

    AffineTransform origDev  = g2d.getTransform();
    Shape           origClip = g2d.getClip();
    RenderingHints  origRH   = g2d.getRenderingHints();

    Shape clip = rc.getAreaOfInterest();
    if (clip != null)
        g2d.clip(clip);
    g2d.transform(rc.getTransform());
    g2d.setRenderingHints(rc.getRenderingHints());

    drawImage(g2d, filter);

    g2d.setTransform(origDev);
    g2d.setClip(origClip);
    g2d.setRenderingHints(origRH);
}
项目:feathers-sdk    文件:StaticRenderer.java   
protected CachableRed renderGNR() {
    AffineTransform at, rcAT;
    at = usr2dev;
    rcAT = new AffineTransform(at.getScaleX(), at.getShearY(),
                               at.getShearX(), at.getScaleY(),
                               0, 0);

    RenderContext rc = new RenderContext(rcAT, null, renderingHints);

    RenderedImage ri = rootFilter.createRendering(rc);
    if (ri == null)
        return null;

    CachableRed ret;
    ret = GraphicsUtil.wrap(ri);
    ret = setupCache(ret);

    int dx = Math.round((float)at.getTranslateX());
    int dy = Math.round((float)at.getTranslateY());
    ret = new TranslateRed(ret, ret.getMinX()+dx, ret.getMinY()+dy);
    ret = GraphicsUtil.convertTosRGB(ret);

    return ret;
}
项目:feathers-sdk    文件:AffineRable8Bit.java   
public RenderedImage createRendering(RenderContext rc) {
    // Degenerate Affine no output image..
    if (invAffine == null) return null;

    // Just copy over the rendering hints.
    RenderingHints rh = rc.getRenderingHints();
    if (rh == null) rh = new RenderingHints(null);

    // Map the area of interest to our input...
    Shape aoi = rc.getAreaOfInterest();
    if (aoi != null)
        aoi = invAffine.createTransformedShape(aoi);

    // update the current affine transform
    AffineTransform at = rc.getTransform();
    at.concatenate(affine);

    // Return what our input creates (it should factor in our affine).
    return getSource().createRendering(new RenderContext(at, aoi, rh));
}
项目:feathers-sdk    文件:AbstractRable.java   
public RenderedImage createScaledRendering(int w, int h,
                                       RenderingHints hints) {
    float sX = w/getWidth();
    float sY = h/getHeight();
    float scale = Math.min(sX, sY);

    AffineTransform at = AffineTransform.getScaleInstance(scale, scale);
    RenderContext rc = new RenderContext(at, hints);

    float dX = (getWidth()*scale)-w;
    float dY = (getHeight()*scale)-h;

    RenderedImage ri = createRendering(rc);
    CachableRed cr = RenderedImageCachableRed.wrap(ri);
    return new PadRed(cr, new Rectangle((int)(dX/2), (int)(dY/2), w, h),
                      PadMode.ZERO_PAD, null);
}
项目:feathers-sdk    文件:GraphicsUtil.java   
/**
 * Draws a <tt>Filter</tt> (<tt>RenderableImage</tt>) into a
 * Graphics 2D after taking into account a particular
 * <tt>RenderContext</tt>.<p>
 *
 * This method also attempts to unwind the rendering chain a bit.
 * So it knows about certain operations (like affine, pad,
 * composite), rather than applying each of these operations in
 * turn it accounts for their affects through modifications to the
 * Graphics2D. This avoids generating lots of intermediate images.
 *
 * @param g2d    The Graphics to draw into.
 * @param filter The filter to draw
 * @param rc The render context that controls the drawing operation.
 */
public static void drawImage(Graphics2D      g2d,
                             RenderableImage filter,
                             RenderContext   rc) {

    AffineTransform origDev  = g2d.getTransform();
    Shape           origClip = g2d.getClip();
    RenderingHints  origRH   = g2d.getRenderingHints();

    Shape clip = rc.getAreaOfInterest();
    if (clip != null)
        g2d.clip(clip);
    g2d.transform(rc.getTransform());
    g2d.setRenderingHints(rc.getRenderingHints());

    drawImage(g2d, filter);

    g2d.setTransform(origDev);
    g2d.setClip(origClip);
    g2d.setRenderingHints(origRH);
}
项目:rastertheque    文件:RotateCRIF.java   
/**
    * Maps the output RenderContext into the RenderContext for the ith
    * source.
    * This method satisfies the implementation of CRIF.
    *
    * @param i               The index of the source image.
    * @param renderContext   The renderContext being applied to the operation.
    * @param paramBlock      The ParameterBlock containing the sources
    *                        and the translation factors.
    * @param image           The RenderableImageOp from which this method
    *                        was called.
    */
   public RenderContext mapRenderContext(int i,
                                         RenderContext renderContext,
                  ParameterBlock paramBlock,
                  RenderableImage image) {
       float x_center = paramBlock.getFloatParameter(0);
       float y_center = paramBlock.getFloatParameter(1);
       float angle = paramBlock.getFloatParameter(2);

       AffineTransform rotate =
           AffineTransform.getRotateInstance(angle, x_center, y_center);

       RenderContext RC = (RenderContext)renderContext.clone();
       AffineTransform usr2dev = RC.getTransform();
       usr2dev.concatenate(rotate);
RC.setTransform(usr2dev);
return RC;
   }
项目:rastertheque    文件:SubsampleAverageCRIF.java   
/**
    * Maps the output RenderContext into the RenderContext for the ith
    * source.
    * This method satisfies the implementation of CRIF.
    *
    * @param i               The index of the source image.
    * @param renderContext   The renderContext being applied to the operation.
    * @param paramBlock      The ParameterBlock containing the sources
    *                        and the translation factors.
    * @param image           The RenderableImageOp from which this method
    *                        was called.
    */
   public RenderContext mapRenderContext(int i,
                                         RenderContext renderContext,
                  ParameterBlock paramBlock,
                  RenderableImage image) {

       double scaleX = paramBlock.getDoubleParameter(0);
       double scaleY = paramBlock.getDoubleParameter(1);

       AffineTransform scale =
           new AffineTransform(scaleX, 0.0, 0.0, scaleY, 0.0, 0.0);

       RenderContext RC = (RenderContext)renderContext.clone();
       AffineTransform usr2dev = RC.getTransform();
       usr2dev.concatenate(scale);
RC.setTransform(usr2dev);
return RC;
   }
项目:rastertheque    文件:CompositeCRIF.java   
/**
    * Creates a <Code>RenderedImage</Code> from the renderable layer.
    *
    * @param renderContext The rendering information associated with
    *        this rendering.
    * @param paramBlock The parameters used to create the image.
    * @return A <code>RenderedImage</code>.
    */
   public RenderedImage create(RenderContext renderContext,
                               ParameterBlock paramBlock) {

// Get the two renderable alpha images from the parameter block
RenderableImage alphaImage1 =
    (RenderableImage)paramBlock.getObjectParameter(0);
RenderableImage alphaImage2 = 
    (RenderableImage)paramBlock.getObjectParameter(1);

// Cause the two renderable alpha images to be rendered
RenderedImage rAlphaImage1 = 
    alphaImage1.createRendering(renderContext);
RenderedImage rAlphaImage2 = 
    alphaImage2.createRendering(renderContext);

ParameterBlock newPB = (ParameterBlock)paramBlock.clone();

// Replace the renderable alpha images in the ParameterBlock with
// their renderings
newPB.set(rAlphaImage1, 0);
newPB.set(rAlphaImage2, 1);

// Return JAI.create("composite") 
       return JAI.create("composite", newPB, 
          renderContext.getRenderingHints());
   }
项目:rastertheque    文件:ScaleCRIF.java   
/**
    * Maps the output RenderContext into the RenderContext for the ith
    * source.
    * This method satisfies the implementation of CRIF.
    *
    * @param i               The index of the source image.
    * @param renderContext   The renderContext being applied to the operation.
    * @param paramBlock      The ParameterBlock containing the sources
    *                        and the translation factors.
    * @param image           The RenderableImageOp from which this method
    *                        was called.
    */
   public RenderContext mapRenderContext(int i,
                                         RenderContext renderContext,
                  ParameterBlock paramBlock,
                  RenderableImage image) {

float scale_x = paramBlock.getFloatParameter(0);
       float scale_y = paramBlock.getFloatParameter(1);
       float trans_x = paramBlock.getFloatParameter(2);
       float trans_y = paramBlock.getFloatParameter(3);

       AffineTransform scale = new AffineTransform(scale_x, 0.0, 0.0, scale_y,
                                                   trans_x, trans_y);

       RenderContext RC = (RenderContext)renderContext.clone();
       AffineTransform usr2dev = RC.getTransform();
       usr2dev.concatenate(scale);
RC.setTransform(usr2dev);
return RC;
   }
项目:rastertheque    文件:SubsampleBinaryToGrayCRIF.java   
/**
    * Maps the output RenderContext into the RenderContext for the ith
    * source.
    * This method satisfies the implementation of CRIF.
    *
    * @param i               The index of the source image.
    * @param renderContext   The renderContext being applied to the operation.
    * @param paramBlock      The ParameterBlock containing the sources
    *                        and the translation factors.
    * @param image           The RenderableImageOp from which this method
    *                        was called.
    */
   public RenderContext mapRenderContext(int i,
                                         RenderContext renderContext,
                  ParameterBlock paramBlock,
                  RenderableImage image) {

float scale_x = paramBlock.getFloatParameter(0);
       float scale_y = paramBlock.getFloatParameter(1);

       AffineTransform scale = new AffineTransform(scale_x, 0.0, 0.0, scale_y,
                                                   0.0, 0.0);

       RenderContext RC = (RenderContext)renderContext.clone();
       AffineTransform usr2dev = RC.getTransform();
       usr2dev.concatenate(scale);
RC.setTransform(usr2dev);
return RC;
   }
项目:rastertheque    文件:RenderableGraphics.java   
public RenderedImage createScaledRendering(int w, int h,
                                           RenderingHints hints) {
    if(w <= 0 && h <= 0) {
        throw new IllegalArgumentException(JaiI18N.getString("RenderableGraphics1"));
    } else if(w <= 0) {
        w = (int)Math.round(h*dimensions.getWidth()/dimensions.getHeight());
    } else if(h <= 0) {
        h = (int)Math.round(w*dimensions.getHeight()/dimensions.getWidth());
    }

    double sx = (double)w/dimensions.getWidth();
    double sy = (double)h/dimensions.getHeight();
    AffineTransform usr2dev = new AffineTransform();
    usr2dev.setToScale(sx, sy);

    return createRendering(new RenderContext(usr2dev, hints));
}
项目:Push2Display    文件:BackgroundRable8Bit.java   
/**
 * Creates a RenderedImage that represented a rendering of this image
 * using a given RenderContext.  This is the most general way to obtain a
 * rendering of a RenderableImage.
 *
 * <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 produce the rendering.
 * @return a RenderedImage containing the rendered data.
 */
public RenderedImage createRendering(RenderContext renderContext){

    Rectangle2D r2d = getBounds2D();

    // System.out.println("Rendering called");

    Shape aoi = renderContext.getAreaOfInterest();
    if (aoi != null) {
        Rectangle2D aoiR2d = aoi.getBounds2D();
        // System.out.println("R2d: " + r2d);
        // System.out.println("AOI: " + aoiR2d);

        if ( ! r2d.intersects(aoiR2d) )
            return null;

        Rectangle2D.intersect(r2d, aoiR2d, r2d);
    }

    Filter background = getBackground(node, null, r2d);
    // System.out.println("BG: " + background);
    if ( background == null)
        return null;

    background = new PadRable8Bit(background, r2d, PadMode.ZERO_PAD);


    RenderedImage ri = background.createRendering
        (new RenderContext(renderContext.getTransform(), r2d,
                           renderContext.getRenderingHints()));
    // System.out.println("RI: [" + ri.getMinX() + ", "
    //                    + ri.getMinY() + ", " +
    //                    + ri.getWidth() + ", " +
    //                    + ri.getHeight() + "]");
    // org.ImageDisplay.showImage("BG: ", ri);
    return ri;
}
项目:Push2Display    文件:FilterAsAlphaRable.java   
public RenderedImage createRendering(RenderContext rc) {
    // Source gets my usr2dev transform
    AffineTransform at = rc.getTransform();

    // Just copy over the rendering hints.
    RenderingHints rh = rc.getRenderingHints();
    if (rh == null) rh = new RenderingHints(null);

    // if we didn't have an aoi specify our bounds as the aoi.
    Shape aoi = rc.getAreaOfInterest();
    if (aoi == null) {
        aoi = getBounds2D();
    }

    rh.put(RenderingHintsKeyExt.KEY_COLORSPACE, 
           ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA_CONVERT);

    RenderedImage ri;
    ri = getSource().createRendering(new RenderContext(at, aoi, rh));
    if (ri == null)
        return null;

    CachableRed cr = RenderedImageCachableRed.wrap(ri);

    Object val = cr.getProperty(ColorSpaceHintKey.PROPERTY_COLORSPACE);
    if (val == ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA_CONVERT)
        return cr;

    return new FilterAsAlphaRed(cr);
}
项目:Push2Display    文件:ProfileRable.java   
public RenderedImage createRendering(RenderContext rc) {
    //
    // Get source's rendered image
    //
    RenderedImage srcRI = getSource().createRendering(rc);

    if(srcRI == null)
        return null;

    CachableRed srcCR = GraphicsUtil.wrap(srcRI);
    return new ProfileRed(srcCR, colorSpace);
}
项目:Push2Display    文件:FilterAlphaRable.java   
public RenderedImage createRendering(RenderContext rc) {
    // Source gets my usr2dev transform
    AffineTransform at = rc.getTransform();

    // Just copy over the rendering hints.
    RenderingHints rh = rc.getRenderingHints();
    if (rh == null) rh = new RenderingHints(null);

    // if we didn't have an aoi specify our bounds as the aoi.
    Shape aoi = rc.getAreaOfInterest();
    if (aoi == null)
        aoi = getBounds2D();

    // We only want it's alpha channel...
    rh.put(RenderingHintsKeyExt.KEY_COLORSPACE, 
           ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA);

    RenderedImage ri;
    ri = getSource().createRendering(new RenderContext(at, aoi, rh));

    if(ri == null){
        return null;
    }

    CachableRed cr = RenderedImageCachableRed.wrap(ri);

    Object val = cr.getProperty(ColorSpaceHintKey.PROPERTY_COLORSPACE);
    if (val == ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA) 
        return cr; // It listened to us...

    return new FilterAlphaRed(cr);
}
项目:Push2Display    文件:ComponentTransferRable8Bit.java   
public RenderedImage createRendering(RenderContext rc){
    //
    // Get source's rendered image
    //
    RenderedImage srcRI = getSource().createRendering(rc);

    if(srcRI == null)
        return null;

    return new ComponentTransferRed(convertSourceCS(srcRI),
                                    getTransferFunctions(),
                                    rc.getRenderingHints());
}
项目:Push2Display    文件:FilterResRable8Bit.java   
private RenderedImage getResRed(RenderingHints hints) {
    Rectangle2D imageRect = getBounds2D();
    double resScaleX = getFilterResolutionX()/imageRect.getWidth();
    double resScaleY = getFilterResolutionY()/imageRect.getHeight();


    // System.out.println("filterRes X " + filterResolutionX +
    //                    " Y : " + filterResolutionY);

    float resScale = (float)Math.min(resScaleX, resScaleY);

    RenderedImage ret;
    if (resScale == this.resScale) {
        // System.out.println("Matched");
        ret = (RenderedImage)resRed.get();
        if (ret != null)
            return ret;
    }

    AffineTransform resUsr2Dev;
    resUsr2Dev = AffineTransform.getScaleInstance(resScale, resScale);

    //
    // Create a new RenderingContext
    //
    RenderContext newRC = new RenderContext(resUsr2Dev, null, hints);

    ret = getSource().createRendering(newRC);

    // This is probably justified since the whole reason to use
    // The filterRes attribute is because the filter chain is
    // expensive, otherwise you should let it evaluate at
    // screen resolution always - right?
    ret = new TileCacheRed(GraphicsUtil.wrap(ret));
    this.resScale = resScale;
    this.resRed   = new SoftReference(ret);

    return ret;
}
项目:Push2Display    文件:ColorMatrixRable8Bit.java   
public RenderedImage createRendering(RenderContext rc) {
    //
    // Get source's rendered image
    //
    RenderedImage srcRI = getSource().createRendering(rc);

    if(srcRI == null)
        return null;

    return new ColorMatrixRed(convertSourceCS(srcRI), matrix);
}
项目:Push2Display    文件:FilterAsAlphaRable.java   
public RenderedImage createRendering(RenderContext rc) {
    // Source gets my usr2dev transform
    AffineTransform at = rc.getTransform();

    // Just copy over the rendering hints.
    RenderingHints rh = rc.getRenderingHints();
    if (rh == null) rh = new RenderingHints(null);

    // if we didn't have an aoi specify our bounds as the aoi.
    Shape aoi = rc.getAreaOfInterest();
    if (aoi == null) {
        aoi = getBounds2D();
    }

    rh.put(RenderingHintsKeyExt.KEY_COLORSPACE, 
           ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA_CONVERT);

    RenderedImage ri;
    ri = getSource().createRendering(new RenderContext(at, aoi, rh));
    if (ri == null)
        return null;

    CachableRed cr = RenderedImageCachableRed.wrap(ri);

    Object val = cr.getProperty(ColorSpaceHintKey.PROPERTY_COLORSPACE);
    if (val == ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA_CONVERT)
        return cr;

    return new FilterAsAlphaRed(cr);
}
项目:Push2Display    文件:ProfileRable.java   
public RenderedImage createRendering(RenderContext rc) {
    //
    // Get source's rendered image
    //
    RenderedImage srcRI = getSource().createRendering(rc);

    if(srcRI == null)
        return null;

    CachableRed srcCR = GraphicsUtil.wrap(srcRI);
    return new ProfileRed(srcCR, colorSpace);
}
项目:Push2Display    文件:FilterAlphaRable.java   
public RenderedImage createRendering(RenderContext rc) {
    // Source gets my usr2dev transform
    AffineTransform at = rc.getTransform();

    // Just copy over the rendering hints.
    RenderingHints rh = rc.getRenderingHints();
    if (rh == null) rh = new RenderingHints(null);

    // if we didn't have an aoi specify our bounds as the aoi.
    Shape aoi = rc.getAreaOfInterest();
    if (aoi == null)
        aoi = getBounds2D();

    // We only want it's alpha channel...
    rh.put(RenderingHintsKeyExt.KEY_COLORSPACE, 
           ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA);

    RenderedImage ri;
    ri = getSource().createRendering(new RenderContext(at, aoi, rh));

    if(ri == null){
        return null;
    }

    CachableRed cr = RenderedImageCachableRed.wrap(ri);

    Object val = cr.getProperty(ColorSpaceHintKey.PROPERTY_COLORSPACE);
    if (val == ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA) 
        return cr; // It listened to us...

    return new FilterAlphaRed(cr);
}
项目:Push2Display    文件:ComponentTransferRable8Bit.java   
public RenderedImage createRendering(RenderContext rc){
    //
    // Get source's rendered image
    //
    RenderedImage srcRI = getSource().createRendering(rc);

    if(srcRI == null)
        return null;

    return new ComponentTransferRed(convertSourceCS(srcRI),
                                    getTransferFunctions(),
                                    rc.getRenderingHints());
}
项目:Push2Display    文件:FilterResRable8Bit.java   
private RenderedImage getResRed(RenderingHints hints) {
    Rectangle2D imageRect = getBounds2D();
    double resScaleX = getFilterResolutionX()/imageRect.getWidth();
    double resScaleY = getFilterResolutionY()/imageRect.getHeight();


    // System.out.println("filterRes X " + filterResolutionX +
    //                    " Y : " + filterResolutionY);

    float resScale = (float)Math.min(resScaleX, resScaleY);

    RenderedImage ret;
    if (resScale == this.resScale) {
        // System.out.println("Matched");
        ret = (RenderedImage)resRed.get();
        if (ret != null)
            return ret;
    }

    AffineTransform resUsr2Dev;
    resUsr2Dev = AffineTransform.getScaleInstance(resScale, resScale);

    //
    // Create a new RenderingContext
    //
    RenderContext newRC = new RenderContext(resUsr2Dev, null, hints);

    ret = getSource().createRendering(newRC);

    // This is probably justified since the whole reason to use
    // The filterRes attribute is because the filter chain is
    // expensive, otherwise you should let it evaluate at
    // screen resolution always - right?
    ret = new TileCacheRed(GraphicsUtil.wrap(ret));
    this.resScale = resScale;
    this.resRed   = new SoftReference(ret);

    return ret;
}
项目:Push2Display    文件:ColorMatrixRable8Bit.java   
public RenderedImage createRendering(RenderContext rc) {
    //
    // Get source's rendered image
    //
    RenderedImage srcRI = getSource().createRendering(rc);

    if(srcRI == null)
        return null;

    return new ColorMatrixRed(convertSourceCS(srcRI), matrix);
}
项目:feathers-sdk    文件:BackgroundRable8Bit.java   
/**
 * Creates a RenderedImage that represented a rendering of this image
 * using a given RenderContext.  This is the most general way to obtain a
 * rendering of a RenderableImage.
 *
 * <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 produce the rendering.
 * @return a RenderedImage containing the rendered data.
 */
public RenderedImage createRendering(RenderContext renderContext){

    Rectangle2D r2d = getBounds2D();

    // System.out.println("Rendering called");

    Shape aoi = renderContext.getAreaOfInterest();
    if (aoi != null) {
        Rectangle2D aoiR2d = aoi.getBounds2D();
        // System.out.println("R2d: " + r2d);
        // System.out.println("AOI: " + aoiR2d);

        if ( ! r2d.intersects(aoiR2d) )
            return null;

        Rectangle2D.intersect(r2d, aoiR2d, r2d);
    }

    Filter background = getBackground(node, null, r2d);
    // System.out.println("BG: " + background);
    if ( background == null)
        return null;

    background = new PadRable8Bit(background, r2d, PadMode.ZERO_PAD);


    RenderedImage ri = background.createRendering
        (new RenderContext(renderContext.getTransform(), r2d,
                           renderContext.getRenderingHints()));
    // System.out.println("RI: [" + ri.getMinX() + ", "
    //                    + ri.getMinY() + ", " +
    //                    + ri.getWidth() + ", " +
    //                    + ri.getHeight() + "]");
    // org.ImageDisplay.showImage("BG: ", ri);
    return ri;
}
项目:feathers-sdk    文件:FilterAsAlphaRable.java   
public RenderedImage createRendering(RenderContext rc) {
    // Source gets my usr2dev transform
    AffineTransform at = rc.getTransform();

    // Just copy over the rendering hints.
    RenderingHints rh = rc.getRenderingHints();
    if (rh == null) rh = new RenderingHints(null);

    // if we didn't have an aoi specify our bounds as the aoi.
    Shape aoi = rc.getAreaOfInterest();
    if (aoi == null) {
        aoi = getBounds2D();
    }

    rh.put(RenderingHintsKeyExt.KEY_COLORSPACE, 
           ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA_CONVERT);

    RenderedImage ri;
    ri = getSource().createRendering(new RenderContext(at, aoi, rh));
    if (ri == null)
        return null;

    CachableRed cr = RenderedImageCachableRed.wrap(ri);

    Object val = cr.getProperty(ColorSpaceHintKey.PROPERTY_COLORSPACE);
    if (val == ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA_CONVERT)
        return cr;

    return new FilterAsAlphaRed(cr);
}
项目:feathers-sdk    文件:ProfileRable.java   
public RenderedImage createRendering(RenderContext rc) {
    //
    // Get source's rendered image
    //
    RenderedImage srcRI = getSource().createRendering(rc);

    if(srcRI == null)
        return null;

    CachableRed srcCR = GraphicsUtil.wrap(srcRI);
    return new ProfileRed(srcCR, colorSpace);
}