本文整理汇总了Java中org.apache.batik.ext.awt.image.GraphicsUtil类的典型用法代码示例。如果您正苦于以下问题:Java GraphicsUtil类的具体用法?Java GraphicsUtil怎么用?Java GraphicsUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GraphicsUtil类属于org.apache.batik.ext.awt.image包,在下文中一共展示了GraphicsUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: paintRable
import org.apache.batik.ext.awt.image.GraphicsUtil; //导入依赖的package包/类
/**
* Should perform the equivilent action as
* createRendering followed by drawing the RenderedImage to
* Graphics2D, or return false.
*
* @param g2d The Graphics2D to draw to.
* @return true if the paint call succeeded, false if
* for some reason the paint failed (in which
* case a createRendering should be used).
*/
public boolean paintRable(Graphics2D g2d) {
// This optimization only apply if we are using
// SrcOver. Otherwise things break...
Composite c = g2d.getComposite();
if (!SVGComposite.OVER.equals(c))
return false;
// For the over mode we can just draw them in order...
if (getCompositeRule() != CompositeRule.OVER)
return false;
ColorSpace crCS = getOperationColorSpace();
ColorSpace g2dCS = GraphicsUtil.getDestinationColorSpace(g2d);
if ((g2dCS == null) || (g2dCS != crCS)) {
return false;
}
// System.out.println("drawImage : " + g2dCS +
// crCS);
Iterator i = getSources().iterator();
while (i.hasNext()) {
GraphicsUtil.drawImage(g2d, (Filter)i.next());
}
return true;
}
示例3: paintRable
import org.apache.batik.ext.awt.image.GraphicsUtil; //导入依赖的package包/类
/**
* Should perform the equivilent action as
* createRendering followed by drawing the RenderedImage to
* Graphics2D, or return false.
*
* @param g2d The Graphics2D to draw to.
* @return true if the paint call succeeded, false if
* for some reason the paint failed (in which
* case a createRendering should be used).
*/
public boolean paintRable(Graphics2D g2d) {
// This optimization only apply if we are using
// SrcOver. Otherwise things break...
Composite c = g2d.getComposite();
if (!SVGComposite.OVER.equals(c))
return false;
if (getPadMode() != PadMode.ZERO_PAD)
return false;
Rectangle2D padBounds = getPadRect();
Shape clip = g2d.getClip();
g2d.clip(padBounds);
GraphicsUtil.drawImage(g2d, getSource());
g2d.setClip(clip);
return true;
}
示例4: paintRable
import org.apache.batik.ext.awt.image.GraphicsUtil; //导入依赖的package包/类
/**
* Should perform the equivilent action as
* createRendering followed by drawing the RenderedImage to
* Graphics2D, or return false.
*
* @param g2d The Graphics2D to draw to.
* @return true if the paint call succeeded, false if
* for some reason the paint failed (in which
* case a createRendering should be used).
*/
public boolean paintRable(Graphics2D g2d) {
// This optimization only apply if we are using
// SrcOver. Otherwise things break...
Composite c = g2d.getComposite();
if (!SVGComposite.OVER.equals(c))
return false;
GraphicsUtil.drawImage(g2d, getSource());
return true;
}
示例5: copyData
import org.apache.batik.ext.awt.image.GraphicsUtil; //导入依赖的package包/类
public WritableRaster copyData(WritableRaster wr) {
int tx0 = getXTile(wr.getMinX());
int ty0 = getYTile(wr.getMinY());
int tx1 = getXTile(wr.getMinX()+wr.getWidth() -1);
int ty1 = getYTile(wr.getMinY()+wr.getHeight()-1);
final boolean is_INT_PACK =
GraphicsUtil.is_INT_PACK_Data(getSampleModel(), false);
for (int y=ty0; y<=ty1; y++)
for (int x=tx0; x<=tx1; x++) {
Raster r = getTile(x, y);
if (is_INT_PACK)
GraphicsUtil.copyData_INT_PACK(r, wr);
else
GraphicsUtil.copyData_FALLBACK(r, wr);
}
return wr;
}
示例6: ComponentTransferRed
import org.apache.batik.ext.awt.image.GraphicsUtil; //导入依赖的package包/类
/**
* The constructor will instantiate a LookupOp instance using
* a LookupOp, which is built using the four LUT
* data obtained by the TransferFunction objects
* funcs[0] : Alpha component transfer function
* funcs[1] : Red component transfer function
* funcs[2] : Green component transfer function
* funcs[3] : Blue component transfer function
*/
public ComponentTransferRed(CachableRed src,
TransferFunction [] funcs,
RenderingHints hints) {
super(src, src.getBounds(),
GraphicsUtil.coerceColorModel(src.getColorModel(), false),
src.getSampleModel(),
null);
byte [][] tableData = {funcs[1].getLookupTable(),
funcs[2].getLookupTable(),
funcs[3].getLookupTable(),
funcs[0].getLookupTable()};
// Note that we create an anonymous subclass here.
// For what ever reason this makes the Op work correctly.
// If you remove this, it seems to get the color channels messed
// up. The downside is that I suspect that this means we are
// falling into a more general, and hence slower case, but
// at least it works....
operation = new LookupOp(new ByteLookupTable(0, tableData), hints)
{ };
}
示例7: ColorMatrixRed
import org.apache.batik.ext.awt.image.GraphicsUtil; //导入依赖的package包/类
public ColorMatrixRed(CachableRed src, float[][] matrix){
setMatrix(matrix);
ColorModel srcCM = src.getColorModel();
ColorSpace srcCS = null;
if (srcCM != null)
srcCS = srcCM.getColorSpace();
ColorModel cm;
if (srcCS == null)
cm = GraphicsUtil.Linear_sRGB_Unpre;
else {
if (srcCS == ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB))
cm = GraphicsUtil.Linear_sRGB_Unpre;
else
cm = GraphicsUtil.sRGB_Unpre;
}
SampleModel sm =
cm.createCompatibleSampleModel(src.getWidth(),
src.getHeight());
init(src, src.getBounds(), cm, sm,
src.getTileGridXOffset(), src.getTileGridYOffset(), null);
}
示例8: copyToRaster
import org.apache.batik.ext.awt.image.GraphicsUtil; //导入依赖的package包/类
/**
* Copies data from this images tile grid into wr. wr may
* extend outside the bounds of this image in which case the
* data in wr outside the bounds will not be touched.
* @param wr Raster to fill with image data.
*/
public void copyToRaster(WritableRaster wr) {
int tx0 = getXTile(wr.getMinX());
int ty0 = getYTile(wr.getMinY());
int tx1 = getXTile(wr.getMinX()+wr.getWidth() -1);
int ty1 = getYTile(wr.getMinY()+wr.getHeight()-1);
if (tx0 < minTileX) tx0 = minTileX;
if (ty0 < minTileY) ty0 = minTileY;
if (tx1 >= minTileX+numXTiles) tx1 = minTileX+numXTiles-1;
if (ty1 >= minTileY+numYTiles) ty1 = minTileY+numYTiles-1;
final boolean is_INT_PACK =
GraphicsUtil.is_INT_PACK_Data(getSampleModel(), false);
for (int y=ty0; y<=ty1; y++)
for (int x=tx0; x<=tx1; x++) {
Raster r = getTile(x, y);
if (is_INT_PACK)
GraphicsUtil.copyData_INT_PACK(r, wr);
else
GraphicsUtil.copyData_FALLBACK(r, wr);
}
}
示例9: fixColorModel
import org.apache.batik.ext.awt.image.GraphicsUtil; //导入依赖的package包/类
protected static ColorModel fixColorModel(CachableRed src) {
ColorModel cm = src.getColorModel();
if (cm.hasAlpha()) {
if (!cm.isAlphaPremultiplied())
cm = GraphicsUtil.coerceColorModel(cm, true);
return cm;
}
int b = src.getSampleModel().getNumBands()+1;
if (b > 4)
throw new IllegalArgumentException
("CompositeRed can only handle up to three band images");
int [] masks = new int[4];
for (int i=0; i < b-1; i++)
masks[i] = 0xFF0000 >> (8*i);
masks[3] = 0xFF << (8*(b-1));
ColorSpace cs = cm.getColorSpace();
return new DirectColorModel(cs, 8*b, masks[0], masks[1],
masks[2], masks[3],
true, DataBuffer.TYPE_INT);
}
示例10: copyData
import org.apache.batik.ext.awt.image.GraphicsUtil; //导入依赖的package包/类
public WritableRaster copyData(WritableRaster wr) {
int xOff = ((int)Math.floor(wr.getMinX()/xStep))*xStep;
int yOff = ((int)Math.floor(wr.getMinY()/yStep))*yStep;
int x0 = wr.getMinX()-xOff;
int y0 = wr.getMinY()-yOff;
int tx0 = getXTile(x0);
int ty0 = getYTile(y0);
int tx1 = getXTile(x0+wr.getWidth() -1);
int ty1 = getYTile(y0+wr.getHeight()-1);
for (int y=ty0; y<=ty1; y++)
for (int x=tx0; x<=tx1; x++) {
Raster r = getTile(x, y);
r = r.createChild(r.getMinX(), r.getMinY(),
r.getWidth(), r.getHeight(),
r.getMinX()+xOff, r.getMinY()+yOff, null);
if (is_INT_PACK)
GraphicsUtil.copyData_INT_PACK(r, wr);
else
GraphicsUtil.copyData_FALLBACK(r, wr);
}
return wr;
}
示例11: copyData
import org.apache.batik.ext.awt.image.GraphicsUtil; //导入依赖的package包/类
public WritableRaster copyData(WritableRaster wr) {
ColorModel cm = getColorModel();
CachableRed cr = getSource();
ColorModel srcCM = cr.getColorModel();
SampleModel srcSM = cr.getSampleModel();
srcSM = srcSM.createCompatibleSampleModel(wr.getWidth(),
wr.getHeight());
WritableRaster srcWR;
srcWR = Raster.createWritableRaster(srcSM, new Point(wr.getMinX(),
wr.getMinY()));
getSource().copyData(srcWR);
BufferedImage srcBI = new BufferedImage
(srcCM, srcWR.createWritableTranslatedChild(0,0),
srcCM.isAlphaPremultiplied(), null);
BufferedImage dstBI = new BufferedImage
(cm, wr.createWritableTranslatedChild(0,0),
cm.isAlphaPremultiplied(), null);
GraphicsUtil.copyData(srcBI, dstBI);
return wr;
}
示例12: createGraphics
import org.apache.batik.ext.awt.image.GraphicsUtil; //导入依赖的package包/类
@Override
public Graphics2D createGraphics(BufferedImage bi)
{
Graphics2D graphics = GraphicsUtil.createGraphics(bi);
if (isAntiAlias())
{
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
//FIXME use JPG instead of PNG for smaller size?
}
return graphics;
}
示例13: createGraphics
import org.apache.batik.ext.awt.image.GraphicsUtil; //导入依赖的package包/类
@Override
public Graphics2D createGraphics(BufferedImage bi)
{
Graphics2D graphics = GraphicsUtil.createGraphics(bi);
if (antiAlias)
{
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
//FIXME use JPG instead of PNG for smaller size?
}
return graphics;
}
示例14: getRaster
import org.apache.batik.ext.awt.image.GraphicsUtil; //导入依赖的package包/类
public Raster getRaster(int x, int y, int width, int height){
// System.out.println("GetRaster: [" + x + ", " + y + ", "
// + width + ", " + height + "]");
if ((raster == null) ||
(raster.getWidth() < width) ||
(raster.getHeight() < height)) {
raster = rasterCM.createCompatibleWritableRaster(width, height);
}
WritableRaster wr
= raster.createWritableChild(0, 0, width, height, x, y, null);
tiled.copyData(wr);
GraphicsUtil.coerceData(wr, tiled.getColorModel(),
rasterCM.isAlphaPremultiplied());
// On Mac OS X it always wants the raster at 0,0 if the
// requested width and height matches raster we can just
// return it. Otherwise we create a translated child that
// lives at 0,0.
if ((raster.getWidth() == width) &&
(raster.getHeight() == height))
return raster;
return wr.createTranslatedChild(0,0);
}
示例15: paintRable
import org.apache.batik.ext.awt.image.GraphicsUtil; //导入依赖的package包/类
/**
* Should perform the equivilent action as
* createRendering followed by drawing the RenderedImage to
* Graphics2D, or return false.
*
* @param g2d The Graphics2D to draw to.
* @return true if the paint call succeeded, false if
* for some reason the paint failed (in which
* case a createRendering should be used).
*/
public boolean paintRable(Graphics2D g2d) {
// This optimization only apply if we are using
// SrcOver. Otherwise things break...
Composite c = g2d.getComposite();
if (!SVGComposite.OVER.equals(c))
return false;
ColorSpace g2dCS = GraphicsUtil.getDestinationColorSpace(g2d);
if ((g2dCS == null) ||
(g2dCS != ColorSpace.getInstance(ColorSpace.CS_sRGB))){
// Only draw directly into sRGB destinations...
return false;
}
// System.out.println("drawImage GNR: " + g2dCS);
GraphicsNode gn = getGraphicsNode();
if (getUsePrimitivePaint()){
gn.primitivePaint(g2d);
}
else{
gn.paint(g2d);
}
// Paint did the work...
return true;
}