本文整理汇总了Java中java.awt.image.ConvolveOp.getEdgeCondition方法的典型用法代码示例。如果您正苦于以下问题:Java ConvolveOp.getEdgeCondition方法的具体用法?Java ConvolveOp.getEdgeCondition怎么用?Java ConvolveOp.getEdgeCondition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.ConvolveOp
的用法示例。
在下文中一共展示了ConvolveOp.getEdgeCondition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: enableConvolveOp
import java.awt.image.ConvolveOp; //导入方法依赖的package包/类
private static void enableConvolveOp(RenderQueue rq,
SurfaceData srcData,
ConvolveOp cop)
{
// assert rq.lock.isHeldByCurrentThread();
boolean edgeZero =
cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL;
Kernel kernel = cop.getKernel();
int kernelWidth = kernel.getWidth();
int kernelHeight = kernel.getHeight();
int kernelSize = kernelWidth * kernelHeight;
int sizeofFloat = 4;
int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat);
RenderBuffer buf = rq.getBuffer();
rq.ensureCapacityAndAlignment(totalBytesRequired, 4);
buf.putInt(ENABLE_CONVOLVE_OP);
buf.putLong(srcData.getNativeOps());
buf.putInt(edgeZero ? 1 : 0);
buf.putInt(kernelWidth);
buf.putInt(kernelHeight);
buf.put(kernel.getKernelData(null));
}
示例2: toSVG
import java.awt.image.ConvolveOp; //导入方法依赖的package包/类
/**
* @param convolveOp the ConvolveOp to be converted
* @return a description of the SVG filter corresponding to
* convolveOp. The definition of the feConvolveMatrix
* filter in put in feConvolveMatrixDefSet
*/
public SVGFilterDescriptor toSVG(ConvolveOp convolveOp){
// Reuse definition if convolveOp has already been converted
SVGFilterDescriptor filterDesc =
(SVGFilterDescriptor)descMap.get(convolveOp);
Document domFactory = generatorContext.domFactory;
if (filterDesc == null) {
//
// First time filter is converted: create its corresponding
// SVG filter
//
Kernel kernel = convolveOp.getKernel();
Element filterDef =
domFactory.createElementNS(SVG_NAMESPACE_URI, SVG_FILTER_TAG);
Element feConvolveMatrixDef =
domFactory.createElementNS(SVG_NAMESPACE_URI,
SVG_FE_CONVOLVE_MATRIX_TAG);
// Convert the kernel size
feConvolveMatrixDef.setAttributeNS(null, SVG_ORDER_ATTRIBUTE,
kernel.getWidth() + SPACE +
kernel.getHeight());
// Convert the kernel values
float[] data = kernel.getKernelData(null);
StringBuffer kernelMatrixBuf = new StringBuffer( data.length * 8 );
for(int i=0; i<data.length; i++){
kernelMatrixBuf.append(doubleString(data[i]));
kernelMatrixBuf.append(SPACE);
}
feConvolveMatrixDef.
setAttributeNS(null, SVG_KERNEL_MATRIX_ATTRIBUTE,
kernelMatrixBuf.toString().trim());
filterDef.appendChild(feConvolveMatrixDef);
filterDef.setAttributeNS(null, SVG_ID_ATTRIBUTE,
generatorContext.idGenerator.
generateID(ID_PREFIX_FE_CONVOLVE_MATRIX));
// Convert the edge mode
if(convolveOp.getEdgeCondition() == ConvolveOp.EDGE_NO_OP)
feConvolveMatrixDef.setAttributeNS(null, SVG_EDGE_MODE_ATTRIBUTE,
SVG_DUPLICATE_VALUE);
else
feConvolveMatrixDef.setAttributeNS(null, SVG_EDGE_MODE_ATTRIBUTE,
SVG_NONE_VALUE);
//
// Create a filter descriptor
//
// Process filter attribute
StringBuffer filterAttrBuf = new StringBuffer(URL_PREFIX);
filterAttrBuf.append(SIGN_POUND);
filterAttrBuf.append(filterDef.getAttributeNS(null, SVG_ID_ATTRIBUTE));
filterAttrBuf.append(URL_SUFFIX);
filterDesc = new SVGFilterDescriptor(filterAttrBuf.toString(),
filterDef);
defSet.add(filterDef);
descMap.put(convolveOp, filterDesc);
}
return filterDesc;
}