当前位置: 首页>>代码示例>>Java>>正文


Java RenderContext类代码示例

本文整理汇总了Java中java.awt.image.renderable.RenderContext的典型用法代码示例。如果您正苦于以下问题:Java RenderContext类的具体用法?Java RenderContext怎么用?Java RenderContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RenderContext类属于java.awt.image.renderable包,在下文中一共展示了RenderContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawImage

import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:36,代码来源:GraphicsUtil.java

示例2: createRendering

import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:52,代码来源:BackgroundRable8Bit.java

示例3: drawImage

import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:36,代码来源:GraphicsUtil.java

示例4: createRendering

import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
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);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:23,代码来源:BatikHistogramNormalizationFilter8Bit.java

示例5: renderGNR

import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
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;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:25,代码来源:StaticRenderer.java

示例6: createRendering

import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
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));
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:21,代码来源:AffineRable8Bit.java

示例7: createScaledRendering

import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
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);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:18,代码来源:AbstractRable.java

示例8: mapRenderContext

import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
/**
    * 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;
   }
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:30,代码来源:RotateCRIF.java

示例9: mapRenderContext

import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
/**
    * 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;
   }
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:30,代码来源:SubsampleAverageCRIF.java

示例10: create

import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
/**
    * 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());
   }
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:35,代码来源:CompositeCRIF.java

示例11: mapRenderContext

import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
/**
    * 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;
   }
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:32,代码来源:ScaleCRIF.java

示例12: mapRenderContext

import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
/**
    * 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;
   }
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:30,代码来源:SubsampleBinaryToGrayCRIF.java

示例13: createScaledRendering

import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
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));
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:18,代码来源:RenderableGraphics.java

示例14: createRendering

import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
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);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:31,代码来源:FilterAsAlphaRable.java

示例15: createRendering

import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
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);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:13,代码来源:ProfileRable.java


注:本文中的java.awt.image.renderable.RenderContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。