当前位置: 首页>>代码示例>>Java>>正文


Java Image.UNDERLYING属性代码示例

本文整理汇总了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();
    }
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:70,代码来源:PdfDocument.java

示例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;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:57,代码来源:ElementFactory.java


注:本文中的com.lowagie.text.Image.UNDERLYING属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。