Example usage for com.lowagie.text Image UNDERLYING

List of usage examples for com.lowagie.text Image UNDERLYING

Introduction

In this page you can find the example usage for com.lowagie.text Image UNDERLYING.

Prototype

int UNDERLYING

To view the source code for com.lowagie.text Image UNDERLYING.

Click Source Link

Document

this is a kind of image alignment.

Usage

From source file:org.nuxeo.ecm.platform.ui.web.component.seam.UIImage.java

License:Open Source License

@Override
public void createITextObject(FacesContext context) throws IOException, DocumentException {
    value = valueBinding(context, "value", value);

    // instance() doesn't work here - we need a new instance
    org.jboss.seam.ui.graphicImage.Image seamImage = new org.jboss.seam.ui.graphicImage.Image();
    try {//from  w ww .  jav  a  2  s .  c  o  m
        if (value instanceof BufferedImage) {
            seamImage.setBufferedImage((BufferedImage) value);
        } else {
            seamImage.setInput(value);
        }
    } catch (Exception e) {
        log.error("Cannot resolve image for value " + value, e);
        return;
    }

    for (UIComponent cmp : this.getChildren()) {
        if (cmp instanceof ImageTransform) {
            ImageTransform imageTransform = (ImageTransform) cmp;
            imageTransform.applyTransform(seamImage);
        }
    }

    byte[] data = seamImage.getImage();
    if (data == null) {
        log.error("Cannot resolve image for value " + value);
        return;
    }
    image = Image.getInstance(data);

    rotation = (Float) valueBinding(context, "rotation", rotation);
    if (rotation != 0) {
        image.setRotationDegrees(rotation);
    }

    height = (Float) valueBinding(context, "height", height);
    width = (Float) valueBinding(context, "width", width);
    if (height > 0 || width > 0) {
        image.scaleAbsolute(width, height);
    }

    int alignmentValue = 0;

    alignment = (String) valueBinding(context, "alignment", alignment);
    if (alignment != null) {
        alignmentValue = (ITextUtils.alignmentValue(alignment));
    }

    wrap = (Boolean) valueBinding(context, "wrap", wrap);
    if (wrap != null && wrap.booleanValue()) {
        alignmentValue |= Image.TEXTWRAP;
    }

    underlying = (Boolean) valueBinding(context, "underlying", underlying);
    if (underlying != null && underlying.booleanValue()) {
        alignmentValue |= Image.UNDERLYING;
    }

    image.setAlignment(alignmentValue);

    alt = (String) valueBinding(context, "alt", alt);
    if (alt != null) {
        image.setAlt(alt);
    }

    indentationLeft = (Float) valueBinding(context, "indentationLeft", indentationLeft);
    if (indentationLeft != null) {
        image.setIndentationLeft(indentationLeft);
    }

    indentationRight = (Float) valueBinding(context, "indentationRight", indentationRight);
    if (indentationRight != null) {
        image.setIndentationRight(indentationRight);
    }

    spacingBefore = (Float) valueBinding(context, "spacingBefore", spacingBefore);
    if (spacingBefore != null) {
        image.setSpacingBefore(spacingBefore);
    }

    spacingAfter = (Float) valueBinding(context, "spacingAfter", spacingAfter);
    if (spacingAfter != null) {
        image.setSpacingAfter(spacingAfter);
    }
    widthPercentage = (Float) valueBinding(context, "widthPercentage", widthPercentage);
    if (widthPercentage != null) {
        image.setWidthPercentage(widthPercentage);
    }

    initialRotation = (Float) valueBinding(context, "initialRotation", initialRotation);
    if (initialRotation != null) {
        image.setInitialRotation(initialRotation);
    }

    dpi = (String) valueBinding(context, "dpi", dpi);
    if (dpi != null) {
        int[] dpiValues = ITextUtils.stringToIntArray(dpi);
        image.setDpi(dpiValues[0], dpiValues[1]);
    }

    applyRectangleProperties(context, image);

    scalePercent = (String) valueBinding(context, "scalePercent", scalePercent);
    if (scalePercent != null) {
        float[] scale = ITextUtils.stringToFloatArray(scalePercent);
        if (scale.length == 1) {
            image.scalePercent(scale[0]);
        } else if (scale.length == 2) {
            image.scalePercent(scale[0], scale[1]);
        } else {
            throw new RuntimeException("scalePercent must contain one or two scale percentages");
        }
    }
}