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


Java GraphicsUtil.wrap方法代码示例

本文整理汇总了Java中org.apache.batik.ext.awt.image.GraphicsUtil.wrap方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsUtil.wrap方法的具体用法?Java GraphicsUtil.wrap怎么用?Java GraphicsUtil.wrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.batik.ext.awt.image.GraphicsUtil的用法示例。


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

示例1: renderGNR

import org.apache.batik.ext.awt.image.GraphicsUtil; //导入方法依赖的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

示例2: getBrokenLinkImage

import org.apache.batik.ext.awt.image.GraphicsUtil; //导入方法依赖的package包/类
public Filter getBrokenLinkImage(Object base,
                                 String code, Object [] params) {
    synchronized (DefaultBrokenLinkProvider.class) {
        if (brokenLinkImg != null)
            return brokenLinkImg;

        BufferedImage bi;
        bi = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);

        // Put the broken link property in the image so people know
        // This isn't the "real" image.
        Hashtable ht = new Hashtable();
        ht.put(BROKEN_LINK_PROPERTY,
               formatMessage(base, code, params));
        bi = new BufferedImage(bi.getColorModel(), bi.getRaster(),
                               bi.isAlphaPremultiplied(),
                               ht);
        Graphics2D g2d = bi.createGraphics();

        g2d.setColor( BROKEN_LINK_COLOR );
        g2d.fillRect(0, 0, 100, 100);
        g2d.setColor(Color.black);
        g2d.drawRect(2, 2, 96, 96);
        g2d.drawString("Broken Image", 6, 50);
        g2d.dispose();

        brokenLinkImg = new RedRable(GraphicsUtil.wrap(bi));
        return brokenLinkImg;
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:31,代码来源:DefaultBrokenLinkProvider.java

示例3: createRendering

import org.apache.batik.ext.awt.image.GraphicsUtil; //导入方法依赖的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

示例4: getResRed

import org.apache.batik.ext.awt.image.GraphicsUtil; //导入方法依赖的package包/类
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;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:40,代码来源:FilterResRable8Bit.java

示例5: handleURL

import org.apache.batik.ext.awt.image.GraphicsUtil; //导入方法依赖的package包/类
/**
 * Statically handle the URL access.
 *
 * @param url URL to access
 * @return Image, or null
 */
public static Filter handleURL(ParsedURL url) {
  if(LOG.isDebuggingFiner()) {
    LOG.debugFiner("handleURL " + url.toString());
  }
  if(!isCompatibleURLStatic(url)) {
    return null;
  }
  int id;
  try {
    id = ParseUtil.parseIntBase10(url.getPath());
  }
  catch(NumberFormatException e) {
    return null;
  }
  SoftReference<RenderedImage> ref = images.get(id);
  if(ref != null) {
    RenderedImage ri = ref.get();
    if(ri == null) {
      LOG.warning("Referenced image has expired from the cache!");
    }
    else {
      return new RedRable(GraphicsUtil.wrap(ri));
    }
  }
  // Image not found in registry.
  return null;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:34,代码来源:ThumbnailRegistryEntry.java

示例6: PatternPaintContext

import org.apache.batik.ext.awt.image.GraphicsUtil; //导入方法依赖的package包/类
/**
 * @param destCM     ColorModel that receives the paint data
 * @param usr2dev    user space to device space transform
 * @param hints      RenderingHints
 * @param patternRegion region tiled by this paint. In user space.
 * @param overflow   controls whether the pattern region clips the
 *                   pattern tile
 */
public PatternPaintContext(ColorModel      destCM,
                           AffineTransform usr2dev,
                           RenderingHints  hints,
                           Filter          tile,
                           Rectangle2D     patternRegion,
                           boolean         overflow) {

    if(usr2dev == null){
        throw new IllegalArgumentException();
    }

    if(hints == null){
        hints = new RenderingHints(null);
    }

    if(tile == null){
        throw new IllegalArgumentException();
    }

    this.usr2dev    = usr2dev;

    // System.out.println("PatB: " + patternRegion);
    // System.out.println("Tile: " + tile);

    TileRable tileRable = new TileRable8Bit(tile,
                                            EVERYTHING,
                                            patternRegion,
                                            overflow);
    ColorSpace destCS = destCM.getColorSpace();
    if (destCS == ColorSpace.getInstance(ColorSpace.CS_sRGB))
        tileRable.setColorSpaceLinear(false);
    else if (destCS == ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB))
        tileRable.setColorSpaceLinear(true);

    RenderContext rc = new RenderContext(usr2dev,  EVERYTHING, hints);
    tiled = tileRable.createRendering(rc);
    // System.out.println("tileRed: " + tiled);
    // org.apache.batik.test.gvt.ImageDisplay.showImage("Tiled: ", tiled);

    //System.out.println("Created rendering");
    if(tiled != null) {
        Rectangle2D devRgn = usr2dev.createTransformedShape
            (patternRegion).getBounds();
        if ((devRgn.getWidth() > 128) ||
            (devRgn.getHeight() > 128))
            tiled = new TileCacheRed(GraphicsUtil.wrap(tiled), 256, 64);
    } else {
        //System.out.println("Tile was null");
        rasterCM = ColorModel.getRGBdefault();
        WritableRaster wr;
        wr = rasterCM.createCompatibleWritableRaster(32, 32);
        tiled = GraphicsUtil.wrap
            (new BufferedImage(rasterCM, wr, false, null));
        return;
    }

    rasterCM = tiled.getColorModel();
    if (rasterCM.hasAlpha()) {
        if (destCM.hasAlpha()) 
            rasterCM = GraphicsUtil.coerceColorModel
                (rasterCM, destCM.isAlphaPremultiplied());
        else 
            rasterCM = GraphicsUtil.coerceColorModel(rasterCM, false);
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:74,代码来源:PatternPaintContext.java

示例7: createRendering

import org.apache.batik.ext.awt.image.GraphicsUtil; //导入方法依赖的package包/类
public RenderedImage createRendering(RenderContext rc) {
    //
    // Get the mask content
    //
    Filter   maskSrc = getMaskNode().getGraphicsNodeRable(true);
    PadRable maskPad = new PadRable8Bit(maskSrc, getBounds2D(),
                                            PadMode.ZERO_PAD);
    maskSrc = new FilterAsAlphaRable(maskPad);
    RenderedImage ri = maskSrc.createRendering(rc);
    if (ri == null)
        return null;

    CachableRed maskCr = RenderedImageCachableRed.wrap(ri);

    //
    // Get the masked content
    //
    PadRable maskedPad = new PadRable8Bit(getSource(),
                                              getBounds2D(),
                                              PadMode.ZERO_PAD);

    ri = maskedPad.createRendering(rc);
    if (ri == null)
        return null;

    CachableRed cr;
    cr = GraphicsUtil.wrap(ri);
    cr = GraphicsUtil.convertToLsRGB(cr);

    // org.apache.batik.test.gvt.ImageDisplay.showImage("Src: ", cr);
    // org.apache.batik.test.gvt.ImageDisplay.showImage("Mask: ", maskCr);

    CachableRed ret = new MultiplyAlphaRed(cr, maskCr);

    // org.apache.batik.test.gvt.ImageDisplay.showImage("Masked: ", ret);


    // ret = new PadRed(ret, cr.getBounds(), PadMode.ZERO_PAD, rh);

    return ret;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:42,代码来源:MaskRable8Bit.java

示例8: createRendering

import org.apache.batik.ext.awt.image.GraphicsUtil; //导入方法依赖的package包/类
public RenderedImage createRendering(RenderContext rc) {
    RenderingHints rh = rc.getRenderingHints();
    if (rh == null) rh = new RenderingHints(null);

    Filter src = getSource();
    Shape aoi = rc.getAreaOfInterest();

    if(aoi == null){
        aoi = getBounds2D();
    }

    AffineTransform usr2dev = rc.getTransform();

    // We only depend on our source for stuff that is inside
    // our bounds and his bounds (remember our bounds may be
    // tighter than his in one or both directions).
    Rectangle2D srect = src.getBounds2D();
    Rectangle2D rect  = getBounds2D();
    Rectangle2D arect = aoi.getBounds2D();

    // System.out.println("Rects Src:" + srect +
    //                    "My: " + rect +
    //                    "AOI: " + arect);
    if ( ! arect.intersects(rect) )
        return null;
    Rectangle2D.intersect(arect, rect, arect);

    RenderedImage ri = null;
    if ( arect.intersects(srect) ) {
        srect = (Rectangle2D)srect.clone();
        Rectangle2D.intersect(srect, arect, srect);

        RenderContext srcRC = new RenderContext(usr2dev, srect, rh);
        ri = src.createRendering(srcRC);

        // System.out.println("Pad filt: " + src + " R: " +
        //                    src.getBounds2D());
    }

    // No source image so create a 1,1 transparent one...
    if (ri == null)
        ri = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);

    // org.apache.batik.test.gvt.ImageDisplay.showImage("Paded: ", ri);
    // System.out.println("RI: " + ri + " R: " + srect);

    CachableRed cr = GraphicsUtil.wrap(ri);

    arect = usr2dev.createTransformedShape(arect).getBounds2D();

    // System.out.println("Pad rect : " + arect);
    // Use arect (my bounds intersect area of interest)
    cr = new PadRed(cr, arect.getBounds(), padMode, rh);
    return cr;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:56,代码来源:PadRable8Bit.java

示例9: createRendering

import org.apache.batik.ext.awt.image.GraphicsUtil; //导入方法依赖的package包/类
/**
 *
 */
public RenderedImage createRendering(RenderContext renderContext) {
    // Get user space to device space transform
    AffineTransform usr2dev = renderContext.getTransform();
    if(usr2dev == null){
        usr2dev = new AffineTransform();
    }

    RenderingHints hints = renderContext.getRenderingHints();

    // As per specification, a value of zero for the
    // x-axis or y-axis causes the filter to produce
    // nothing.
    // The processing is done as follows:
    // + if the x resolution is zero, this is a no-op
    //   else compute the x scale.
    // + if the y resolution is zero, this is a no-op
    //   else compute the y resolution from the x scale
    //   and compute the corresponding y scale.
    // + if the y or x scale is less than one, insert
    //   an AffineRable.
    //   Else, return the source as is.
    int filterResolutionX = getFilterResolutionX();
    int filterResolutionY = getFilterResolutionY();
    // System.out.println("FilterResRable: " + filterResolutionX + "x" +
    //                    filterResolutionY);

    if ((filterResolutionX <= 0) || (filterResolutionY == 0))
        return null;

    // Find out the renderable area
    Rectangle2D imageRect = getBounds2D();
    Rectangle   devRect;
    devRect = usr2dev.createTransformedShape(imageRect).getBounds();

    // Now, compare the devRect with the filter
    // resolution hints
    float scaleX = 1;
    if(filterResolutionX < devRect.width)
        scaleX = filterResolutionX / (float)devRect.width;

    float scaleY = 1;
    if(filterResolutionY < 0)
        scaleY = scaleX;
    else if(filterResolutionY < devRect.height)
        scaleY = filterResolutionY / (float)devRect.height;

    // Only resample if either scaleX or scaleY is
    // smaller than 1
    if ((scaleX >= 1) && (scaleY >= 1))
        return getSource().createRendering(renderContext);

    // System.out.println("Using Fixed Resolution...");

    // Using fixed resolution image since we need an image larger
    // than this.
    RenderedImage resRed   = getResRed(hints);
    float         resScale = getResScale();

    AffineTransform residualAT;
    residualAT = new AffineTransform(usr2dev.getScaleX()/resScale,
                                     usr2dev.getShearY()/resScale,
                                     usr2dev.getShearX()/resScale,
                                     usr2dev.getScaleY()/resScale,
                                     usr2dev.getTranslateX(),
                                     usr2dev.getTranslateY());

    // org.ImageDisplay.showImage("AT: " + newUsr2Dev, result);

    return new AffineRed(GraphicsUtil.wrap(resRed), residualAT, hints);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:74,代码来源:FilterResRable8Bit.java

示例10: TileRed

import org.apache.batik.ext.awt.image.GraphicsUtil; //导入方法依赖的package包/类
public TileRed(RenderedImage tile, 
               Rectangle tiledRegion,
               int xStep, int yStep,
               RenderingHints hints) {
    if(tiledRegion == null){
        throw new IllegalArgumentException();
    }

    if(tile == null){
        throw new IllegalArgumentException();
    }

    // org.apache.batik.test.gvt.ImageDisplay.showImage("Tile: ", tile);
    this.tiledRegion  = tiledRegion;
    this.xStep        = xStep;
    this.yStep        = yStep;
    this.hints        = hints;

    SampleModel sm = fixSampleModel(tile, xStep, yStep, 
                                    tiledRegion.width,
                                    tiledRegion.height);
    ColorModel cm  = tile.getColorModel();

    double smSz   = AbstractTiledRed.getDefaultTileSize();
    smSz = smSz*smSz;

    double stepSz = (xStep*(double)yStep);
    // be prepaired to grow the default tile size quite a bit if
    // it means the image tile will fit in it...
    if (16.1*smSz > stepSz) {
        int xSz = xStep;
        int ySz = yStep;

        // If the pattern size is small then have multiple copies
        // in our tile.
        if (4*stepSz <= smSz) {
            int mult = (int)Math.ceil(Math.sqrt(smSz/stepSz));
            xSz *= mult;
            ySz *= mult;
        }
        // System.out.println("Using Raster for pattern");
        sm = sm.createCompatibleSampleModel(xSz, ySz);
        raster = Raster.createWritableRaster
            (sm, new Point(tile.getMinX(), tile.getMinY()));
    }
    
    is_INT_PACK = GraphicsUtil.is_INT_PACK_Data(sm, false);
    // System.out.println("Is INT PACK: " + is_INT_PACK);

    // Initialize our base class We set our bounds be we will
    // respond with data for any area we cover.  This is needed
    // because the userRegion passed into PatterPaintContext
    // doesn't account for stroke So we use that as a basis but
    // when the context asks us for stuff outside that region we
    // complie.
    init((CachableRed)null, tiledRegion, cm, sm, 
         tile.getMinX(), tile.getMinY(), null);

    if (raster != null) {
        WritableRaster fromRaster = raster.createWritableChild
            (tile.getMinX(), tile.getMinY(), 
             xStep, yStep, tile.getMinX(), tile.getMinY(), null);

        // Fill one 'tile' of the input....
        fillRasterFrom(fromRaster, tile);
        fillOutRaster(raster);
    }
    else {
        this.tile        = new TileCacheRed(GraphicsUtil.wrap(tile));
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:72,代码来源:TileRed.java


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