本文整理汇总了Java中java.awt.image.renderable.ParameterBlock.getNumSources方法的典型用法代码示例。如果您正苦于以下问题:Java ParameterBlock.getNumSources方法的具体用法?Java ParameterBlock.getNumSources怎么用?Java ParameterBlock.getNumSources使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.renderable.ParameterBlock
的用法示例。
在下文中一共展示了ParameterBlock.getNumSources方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBounds2D
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的package包/类
/**
* Returns the bounding box for the output of the operation. The
* implementation in this class computes the bounding box as the
* intersection the bounding boxes of all the (renderable sources).
*
* @param paramBlock A <code>ParameterBlock</code> containing the
* sources and parameters of the operation.
* @return A <code>Rectangle2D</code> specifying the bounding box.
*/
public Rectangle2D getBounds2D(ParameterBlock paramBlock) {
int numSources = paramBlock.getNumSources();
if (numSources == 0) {
return null;
}
RenderableImage src = paramBlock.getRenderableSource(0);
Rectangle2D.Float box1 = new Rectangle2D.Float(src.getMinX(),
src.getMinY(),
src.getWidth(),
src.getHeight());
for (int i = 1; i < numSources; i++) {
src = paramBlock.getRenderableSource(i);
Rectangle2D.Float box2 =
new Rectangle2D.Float(src.getMinX(), src.getMinY(),
src.getWidth(), src.getHeight());
box1 = (Rectangle2D.Float)box1.createIntersection(box2);
if(box1.isEmpty()) {
break;
}
}
return box1;
}
示例2: setSource
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的package包/类
/**
* Sets the specified source stored in the <code>ParameterBlock</code>
* of this node to a new source object.
* This is a convenience method that invokes
* <code>setParameterBlock()</code> and so adheres to the same event
* firing behavior.
*
* <p> The node is added automatically as a sink if the source is a
* <code>PlanarImage</code> or a <code>CollectionImage</code>. If
* appropriate the node is removed as a sink of any previous source
* at the same index.
*
* @param source The Source to be set.
* @param index The Index at which it is to be set.
*
* @throws IllegalArgumentException if
* <code>source</code> is <code>null</code>.
* @throws ArrayIndexOutOfBoundsException if
* <code>index</code> is invalid.
*
* @since JAI 1.1
*/
public synchronized void setSource(Object source, int index) {
if (source == null)
throw new IllegalArgumentException(JaiI18N.getString("Generic0"));
ParameterBlock pb =
(ParameterBlock)nodeSupport.getParameterBlock().clone();
if(index < pb.getNumSources()) {
Object priorSource = pb.getSource(index);
if(priorSource instanceof PlanarImage) {
((PlanarImage)priorSource).removeSink(this);
} else if(priorSource instanceof CollectionImage) {
((CollectionImage)priorSource).removeSink(this);
}
}
pb.setSource(source, index);
nodeSupport.setParameterBlock(pb);
if(source instanceof PlanarImage) {
((PlanarImage)source).addSink(this);
} else if(source instanceof CollectionImage) {
((CollectionImage)source).addSink(this);
}
}
示例3: create
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的package包/类
/**
* Creates a new instance of <code>QuicklookOlciOpImage</code> in the
* rendered layer. This operator could be called by chunks of images.
* A set of additional information are required to compute the pixels
* adjustment such as sun azimuth/elevation and detectors... The methods to
* extract these informations are also provided here before.
*
* @param paramBlock The three R/G/B sources images to be "Merged" together
* to produce the Quicklook.
* @param renderHints Optionally contains destination image layout.
*/
public RenderedImage create(ParameterBlock paramBlock, RenderingHints hints)
{
// Get ImageLayout from renderHints if any.
ImageLayout layout = RIFUtil.getImageLayoutHint(hints);
// Get the number of the sources
int numSources = paramBlock.getNumSources();
// Creation of a source ArrayList (better than a Vector)
List<RenderedImage> sources = new ArrayList<RenderedImage>(numSources);
// Addition of the sources to the List
for (int i = 0; i < numSources; i++)
{
sources.add((RenderedImage)paramBlock.getSource(i));
}
// Extracts parameters
short[][] detectors = (short[][])paramBlock.getObjectParameter(0);
double[][] sza = (double[][])paramBlock.getObjectParameter(1);
float[][] solar_flux = (float[][])paramBlock.getObjectParameter(2);
PixelCorrection[]pc=(PixelCorrection[])paramBlock.getObjectParameter(3);
int[] bands = (int[])paramBlock.getObjectParameter(4);
int[] coefficients = (int[])paramBlock.getObjectParameter(5);
return new QuicklookOlciOpImage(sources, hints, detectors, sza,
solar_flux, pc, bands, coefficients, layout);
}
示例4: getKey
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的package包/类
/** Derives a hash key string for this RenderedOp. */
private static final String getKey(RenderedOp op) {
// Initialize the key string to the RenderedOp hash code.
String key = new String(String.valueOf(op.hashCode()));
// Get the ParameterBlock
ParameterBlock pb = op.getParameterBlock();
// Add the sources.
int numSources = pb.getNumSources();
for(int s = 0; s < numSources; s++) {
RenderedImage src = pb.getRenderedSource(s);
// If the source is a node recurse up the chain.
if(src instanceof RenderedOp) {
key += getKey((RenderedOp)src);
} else {
key += String.valueOf(src.hashCode());
}
}
// Add the parameters.
int numParameters = pb.getNumParameters();
for(int p = 0; p < numParameters; p++) {
// Use toString() instead of hashCode() here because the
// majority of parameters are numerical.
key += pb.getObjectParameter(p).toString();
}
return key;
}
示例5: createInstance
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的package包/类
/**
* This method performs the actions described by the documentation of
* <code>createInstance()</code>. The parameter value selects the method
* used to render the source(s).
*
* @throws RuntimeException if the image factory charged with rendering
* the node is unable to create a rendering.
*/
private synchronized Collection createInstance(boolean isChainFrozen) {
// Get the PB evaluating any DeferredData objects in the process.
ParameterBlock args =
ImageUtil.evaluateParameters(nodeSupport.getParameterBlock());
ParameterBlock pb = new ParameterBlock();
pb.setParameters(args.getParameters());
int numSources = args.getNumSources();
for (int i = 0; i < numSources; i++) {
Object source = args.getSource(i);
Object src = null;
if (source instanceof RenderedOp) {
src = isChainFrozen ?
((RenderedOp)source).getRendering() :
((RenderedOp)source).createInstance();
} else if (source instanceof CollectionOp) {
CollectionOp co = (CollectionOp)source;
src = isChainFrozen ?
co.getCollection() :
co.createInstance();
} else if (source instanceof RenderedImage ||
source instanceof RenderableImage ||
source instanceof Collection) {
src = source;
} else {
// Source is some other type. Pass on (for now).
src = source;
}
pb.addSource(src);
}
Collection instance = null;
if(isRenderable) {
instance = RCIFRegistry.create(nodeSupport.getRegistry(),
nodeSupport.getOperationName(),
pb);
} else {
CollectionImageFactory cif =
CIFRegistry.get(nodeSupport.getRegistry(),
nodeSupport.getOperationName());
instance = cif.create(pb, nodeSupport.getRenderingHints());
// Set the CollectionImageFactory on the result.
if(instance != null) {
((CollectionImage)instance).setImageFactory(cif);
}
}
// Throw an error if the rendering is null.
if (instance == null) {
throw new RuntimeException(JaiI18N.getString("CollectionOp0"));
}
// Save the RenderingHints.
oldHints = nodeSupport.getRenderingHints() == null ?
null : (RenderingHints)nodeSupport.getRenderingHints().clone();
return instance;
}
示例6: getInvalidRegion
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的package包/类
/**
* Calculates the region over which two distinct renderings
* of the "Null" operation may be expected to differ.
*
* <p> The operation returns an empty <code>Shape</code> if the first
* source in each of the two <code>ParameterBlock</code>s are equal
* according to the <code>equals()</code> method of the old source or
* <code>null</code> for all other cases.
*
* @param modeName The name of the mode.
* @param oldParamBlock The previous sources and parameters.
* @param oldHints The previous hints.
* @param newParamBlock The current sources and parameters.
* @param newHints The current hints.
* @param node The affected node in the processing chain (ignored).
*
* @return The region over which the data of two renderings of this
* operation may be expected to be invalid or <code>null</code>
* if there is no common region of validity.
* A non-<code>null</code> empty region indicates that the
* operation would produce identical data over the bounds of the
* old rendering although perhaps not over the area occupied by
* the <i>tiles</i> of the old rendering.
*
* @throws IllegalArgumentException if <code>modeName</code>
* is <code>null</code> or if either <code>oldParamBlock</code>
* or <code>newParamBlock</code> is <code>null</code>.
* @throws IllegalArgumentException if <code>oldParamBlock</code> or
* <code>newParamBlock</code> does not contain at least one source.
*/
public Object getInvalidRegion(String modeName,
ParameterBlock oldParamBlock,
RenderingHints oldHints,
ParameterBlock newParamBlock,
RenderingHints newHints,
OperationNode node) {
if (modeName == null || oldParamBlock == null || newParamBlock == null) {
throw new IllegalArgumentException(JaiI18N.getString("NullDescriptor1"));
}
if (oldParamBlock.getNumSources() < 1 ||
newParamBlock.getNumSources() < 1) {
throw new IllegalArgumentException(JaiI18N.getString("NullDescriptor2"));
}
return oldParamBlock.getSource(0).equals(newParamBlock.getSource(0)) ?
new Rectangle() : null;
}
示例7: validateSources
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的package包/类
private boolean validateSources(Class[] sources,
ParameterBlock args,
StringBuffer msg) {
if ((args == null) || (msg == null))
throw new IllegalArgumentException(JaiI18N.getString("Generic0"));
// The number of sources this operation requires.
int numSources = getNumSources();
// Check for the correct number of sources.
if (args.getNumSources() < numSources) {
msg.append(JaiI18N.formatMsg("OperationDescriptorImpl6",
new Object[] { getName(), new Integer(numSources) }));
return false;
}
for (int i = 0; i < numSources; i++) {
Object s = args.getSource(i);
// Check for null source.
if (s == null) {
msg.append(JaiI18N.formatMsg("OperationDescriptorImpl7",
new Object[] { getName()}));
return false;
}
// Check for the correct class of each supplied source.
Class c = sources[i];
if (!c.isInstance(s)) {
msg.append(JaiI18N.formatMsg("OperationDescriptorImpl8",
new Object[] {
getName(),
new Integer(i),
new String(c.toString()),
new String(s.getClass().toString()) }));
return false;
}
}
return true;
}
示例8: create
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的package包/类
/**
* Returns the first source in the source list in the
* <code>ParameterBlock</code> or the value returned by
* <code>getSourcelessImage()</code> if there are no soures.
*
* @throws ClassCastException if there are sources and the source
* at index zero is not a <code>RenderedImage</code>.
*/
public RenderedImage create(ParameterBlock args,
RenderingHints renderHints) {
return args.getNumSources() == 0 ?
getSourcelessImage() : args.getRenderedSource(0);
}