本文整理汇总了Java中com.lowagie.text.Image.UNDERLYING属性的典型用法代码示例。如果您正苦于以下问题:Java Image.UNDERLYING属性的具体用法?Java Image.UNDERLYING怎么用?Java Image.UNDERLYING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.lowagie.text.Image
的用法示例。
在下文中一共展示了Image.UNDERLYING属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: add
/**
* Adds an image to the document.
* @param image the <CODE>Image</CODE> to add
* @throws PdfException on error
* @throws DocumentException on error
*/
protected void add(Image image) throws PdfException, DocumentException {
if (image.hasAbsoluteY()) {
graphics.addImage(image);
pageEmpty = false;
return;
}
// if there isn't enough room for the image on this page, save it for the next page
if (currentHeight != 0 && indentTop() - currentHeight - image.getScaledHeight() < indentBottom()) {
if (!strictImageSequence && imageWait == null) {
imageWait = image;
return;
}
newPage();
if (currentHeight != 0 && indentTop() - currentHeight - image.getScaledHeight() < indentBottom()) {
imageWait = image;
return;
}
}
pageEmpty = false;
// avoid endless loops
if (image == imageWait)
imageWait = null;
boolean textwrap = (image.getAlignment() & Image.TEXTWRAP) == Image.TEXTWRAP
&& !((image.getAlignment() & Image.MIDDLE) == Image.MIDDLE);
boolean underlying = (image.getAlignment() & Image.UNDERLYING) == Image.UNDERLYING;
float diff = leading / 2;
if (textwrap) {
diff += leading;
}
float lowerleft = indentTop() - currentHeight - image.getScaledHeight() -diff;
float mt[] = image.matrix();
float startPosition = indentLeft() - mt[4];
if ((image.getAlignment() & Image.RIGHT) == Image.RIGHT) startPosition = indentRight() - image.getScaledWidth() - mt[4];
if ((image.getAlignment() & Image.MIDDLE) == Image.MIDDLE) startPosition = indentLeft() + ((indentRight() - indentLeft() - image.getScaledWidth()) / 2) - mt[4];
if (image.hasAbsoluteX()) startPosition = image.getAbsoluteX();
if (textwrap) {
if (imageEnd < 0 || imageEnd < currentHeight + image.getScaledHeight() + diff) {
imageEnd = currentHeight + image.getScaledHeight() + diff;
}
if ((image.getAlignment() & Image.RIGHT) == Image.RIGHT) {
// indentation suggested by Pelikan Stephan
indentation.imageIndentRight += image.getScaledWidth() + image.getIndentationLeft();
}
else {
// indentation suggested by Pelikan Stephan
indentation.imageIndentLeft += image.getScaledWidth() + image.getIndentationRight();
}
}
else {
if ((image.getAlignment() & Image.RIGHT) == Image.RIGHT) startPosition -= image.getIndentationRight();
else if ((image.getAlignment() & Image.MIDDLE) == Image.MIDDLE) startPosition += image.getIndentationLeft() - image.getIndentationRight();
else startPosition += image.getIndentationLeft();
}
graphics.addImage(image, mt[0], mt[1], mt[2], mt[3], startPosition, lowerleft - mt[5]);
if (!(textwrap || underlying)) {
currentHeight += image.getScaledHeight() + diff;
flushLines();
text.moveText(0, - (image.getScaledHeight() + diff));
newLine();
}
}
示例2: getImage
/**
* Creates an Image object based on a list of properties.
* @param attributes
* @return an Image
*/
public static Image getImage(Properties attributes)
throws BadElementException, MalformedURLException, IOException {
String value;
value = attributes.getProperty(ElementTags.URL);
if (value == null)
throw new MalformedURLException("The URL of the image is missing.");
Image image = Image.getInstance(value);
value = attributes.getProperty(ElementTags.ALIGN);
int align = 0;
if (value != null) {
if (ElementTags.ALIGN_LEFT.equalsIgnoreCase(value))
align |= Image.LEFT;
else if (ElementTags.ALIGN_RIGHT.equalsIgnoreCase(value))
align |= Image.RIGHT;
else if (ElementTags.ALIGN_MIDDLE.equalsIgnoreCase(value))
align |= Image.MIDDLE;
}
if ("true".equalsIgnoreCase(attributes
.getProperty(ElementTags.UNDERLYING)))
align |= Image.UNDERLYING;
if ("true".equalsIgnoreCase(attributes
.getProperty(ElementTags.TEXTWRAP)))
align |= Image.TEXTWRAP;
image.setAlignment(align);
value = attributes.getProperty(ElementTags.ALT);
if (value != null) {
image.setAlt(value);
}
String x = attributes.getProperty(ElementTags.ABSOLUTEX);
String y = attributes.getProperty(ElementTags.ABSOLUTEY);
if ((x != null) && (y != null)) {
image.setAbsolutePosition(Float.parseFloat(x + "f"), Float
.parseFloat(y + "f"));
}
value = attributes.getProperty(ElementTags.PLAINWIDTH);
if (value != null) {
image.scaleAbsoluteWidth(Float.parseFloat(value + "f"));
}
value = attributes.getProperty(ElementTags.PLAINHEIGHT);
if (value != null) {
image.scaleAbsoluteHeight(Float.parseFloat(value + "f"));
}
value = attributes.getProperty(ElementTags.ROTATION);
if (value != null) {
image.setRotation(Float.parseFloat(value + "f"));
}
return image;
}