org.cdlib.xtf.saxonExt.image
Class OutputElement.OutputInstruction

Object
  extended by Expression
      extended by Instruction
          extended by InstructionWithContent
              extended by OutputElement.OutputInstruction
All Implemented Interfaces:
Serializable, SourceLocator, Container, EvaluableItem, SequenceIterable, TailCallReturner, InstructionInfoProvider
Enclosing class:
OutputElement

private static class OutputElement.OutputInstruction
extends InstructionWithContent


Field Summary
private  int cropOffX
           
private  int cropOffY
           
private  boolean flipY
           
private  int origHeight
           
private  float xBias
           
private  float xScale
           
private  float yBias
           
private  float yScale
           
 
Fields inherited from class InstructionWithContent
attribs, content, name
 
Fields inherited from class Expression
EVALUATE_METHOD, ITERATE_METHOD, locationId, PROCESS_METHOD, staticProperties
 
Constructor Summary
OutputElement.OutputInstruction(HashMap<String,Expression> attribs, boolean flipY, Expression content)
           
 
Method Summary
private  float getFloatAttrib(XPathContext context, String attName, float defaultVal)
          Get an attribute value and convert to floating point.
private  void makeBackgroundYellow(BufferedImage bi, OutputElement.Rect rect)
          Change white background to yellow in the given area of an image
private  void makeForegroundRed(BufferedImage bi, OutputElement.Rect rect)
          Change black foreground to red in the given area of an image
private  OutputElement.Rect parseRect(XPathContext context, NodeInfo node, int imgWidth, int imgHeight)
          Parse the "left", "top", "right", and "bottom" attributes from a "highlight" element.
 TailCall processLeavingTail(XPathContext context)
          This is where the main work should be performed.
 
Methods inherited from class InstructionWithContent
createsNewNodes, display, dynamicError, getAttribBool, getAttribStr, getAttribStr, getCardinality, getInstructionNameCode, getItemType, iterateSubExpressions, optimize, promoteInst, replaceSubExpression, sequenceToString, simplify, typeCheck
 
Methods inherited from class Instruction
appendItem, assembleParams, assembleTunnelParams, computeCardinality, computeSpecialProperties, dynamicError, evaluateAsString, evaluateItem, getImplementationMethod, getInstructionInfo, getSourceLocator, isXSLT, iterate, process, promote
 
Methods inherited from class Expression
adoptChildExpression, checkPermittedContents, computeDependencies, computeStaticProperties, doPromotion, dynamicError, effectiveBooleanValue, getColumnNumber, getConstructType, getContainingProcedure, getDependencies, getExecutable, getHostLanguage, getIntrinsicDependencies, getLineNumber, getLocationId, getLocationProvider, getParentExpression, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, hasBadParentPointer, markTailFunctionCalls, resetStaticProperties, setLocationId, setParentExpression, setParentExpression, suppressValidation, typeError
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface SourceLocator
getColumnNumber, getLineNumber, getPublicId, getSystemId
 

Field Detail

flipY

private boolean flipY

xBias

private float xBias

xScale

private float xScale

yBias

private float yBias

yScale

private float yScale

origHeight

private int origHeight

cropOffX

private int cropOffX

cropOffY

private int cropOffY
Constructor Detail

OutputElement.OutputInstruction

public OutputElement.OutputInstruction(HashMap<String,Expression> attribs,
                                       boolean flipY,
                                       Expression content)
Method Detail

processLeavingTail

public TailCall processLeavingTail(XPathContext context)
                            throws XPathException
Description copied from class: InstructionWithContent
This is where the main work should be performed. Subclasses must implement this method.

Specified by:
processLeavingTail in interface TailCallReturner
Specified by:
processLeavingTail in class InstructionWithContent
Throws:
XPathException

getFloatAttrib

private float getFloatAttrib(XPathContext context,
                             String attName,
                             float defaultVal)
                      throws XPathException
Get an attribute value and convert to floating point. If not present, the default value is used instead.

Throws:
XPathException

parseRect

private OutputElement.Rect parseRect(XPathContext context,
                                     NodeInfo node,
                                     int imgWidth,
                                     int imgHeight)
                              throws DynamicError
Parse the "left", "top", "right", and "bottom" attributes from a "highlight" element.

Parameters:
node - The element containing the attributes
imgHeight - The height to use when flipping
Returns:
A rectangle containing the coordinates (flipped if necessary)
Throws:
DynamicError

makeBackgroundYellow

private void makeBackgroundYellow(BufferedImage bi,
                                  OutputElement.Rect rect)
Change white background to yellow in the given area of an image


makeForegroundRed

private void makeForegroundRed(BufferedImage bi,
                               OutputElement.Rect rect)
Change black foreground to red in the given area of an image