Java 类com.lowagie.text.Utilities 实例源码

项目:itext2    文件:BidiLine.java   
/** Gets the width of a range of characters.
 * @param startIdx the first index to calculate
 * @param lastIdx the last inclusive index to calculate
 * @return the sum of all widths
 */    
public float getWidth(int startIdx, int lastIdx) {
    char c = 0;
    PdfChunk ck = null;
    float width = 0;
    for (; startIdx <= lastIdx; ++startIdx) {
        boolean surrogate = Utilities.isSurrogatePair(text, startIdx);
        if (surrogate) {
            width += detailChunks[startIdx].getCharWidth(Utilities.convertToUtf32(text, startIdx));
            ++startIdx;
        }
        else {
            c = text[startIdx];
            ck = detailChunks[startIdx];
            if (PdfChunk.noPrint(ck.getUnicodeEquivalent(c)))
                continue;
            width += detailChunks[startIdx].getCharWidth(c);
        }
    }
    return width;
}
项目:DroidText    文件:BidiLine.java   
/** Gets the width of a range of characters.
 * @param startIdx the first index to calculate
 * @param lastIdx the last inclusive index to calculate
 * @return the sum of all widths
 */    
public float getWidth(int startIdx, int lastIdx) {
    char c = 0;
    char uniC;
    PdfChunk ck = null;
    float width = 0;
    for (; startIdx <= lastIdx; ++startIdx) {
        boolean surrogate = Utilities.isSurrogatePair(text, startIdx);
        if (surrogate) {
            width += detailChunks[startIdx].getCharWidth(Utilities.convertToUtf32(text, startIdx));
            ++startIdx;
        }
        else {
            c = text[startIdx];
            ck = detailChunks[startIdx];
            if (PdfChunk.noPrint(ck.getUnicodeEquivalent(c)))
                continue;
            width += detailChunks[startIdx].getCharWidth(c);
        }
    }
    return width;
}
项目:itext2    文件:PdfChunk.java   
int lengthUtf32() {
    if (!BaseFont.IDENTITY_H.equals(encoding))
        return value.length();
    int total = 0;
    int len = value.length();
    for (int k = 0; k < len; ++k) {
        if (Utilities.isSurrogateHigh(value.charAt(k)))
            ++k;
        ++total;
    }
    return total;
}
项目:itext2    文件:ElementFactory.java   
/**
 * Creates a Cell object based on a list of properties.
 * @param attributes
 * @return a Cell
 */
public static Cell getCell(Properties attributes) {
    Cell cell = new Cell();
    String value;

    cell.setHorizontalAlignment(attributes
            .getProperty(ElementTags.HORIZONTALALIGN));
    cell.setVerticalAlignment(attributes
            .getProperty(ElementTags.VERTICALALIGN));

    value = attributes.getProperty(ElementTags.WIDTH);
    if (value != null) {
        cell.setWidth(value);
    }
    value = attributes.getProperty(ElementTags.COLSPAN);
    if (value != null) {
        cell.setColspan(Integer.parseInt(value));
    }
    value = attributes.getProperty(ElementTags.ROWSPAN);
    if (value != null) {
        cell.setRowspan(Integer.parseInt(value));
    }
    value = attributes.getProperty(ElementTags.LEADING);
    if (value != null) {
        cell.setLeading(Float.parseFloat(value + "f"));
    }
    cell.setHeader(Utilities.checkTrueOrFalse(attributes,
            ElementTags.HEADER));
    if (Utilities.checkTrueOrFalse(attributes, ElementTags.NOWRAP)) {
        cell.setMaxLines(1);
    }
    setRectangleProperties(cell, attributes);
    return cell;
}
项目:DroidText    文件:PdfChunk.java   
int lengthUtf32() {
    if (!BaseFont.IDENTITY_H.equals(encoding))
        return value.length();
    int total = 0;
    int len = value.length();
    for (int k = 0; k < len; ++k) {
        if (Utilities.isSurrogateHigh(value.charAt(k)))
            ++k;
        ++total;
    }
    return total;
}
项目:DroidText    文件:ElementFactory.java   
/**
 * Creates a Cell object based on a list of properties.
 * @param attributes
 * @return a Cell
 */
public static Cell getCell(Properties attributes) {
    Cell cell = new Cell();
    String value;

    cell.setHorizontalAlignment(attributes
            .getProperty(ElementTags.HORIZONTALALIGN));
    cell.setVerticalAlignment(attributes
            .getProperty(ElementTags.VERTICALALIGN));

    value = attributes.getProperty(ElementTags.WIDTH);
    if (value != null) {
        cell.setWidth(value);
    }
    value = attributes.getProperty(ElementTags.COLSPAN);
    if (value != null) {
        cell.setColspan(Integer.parseInt(value));
    }
    value = attributes.getProperty(ElementTags.ROWSPAN);
    if (value != null) {
        cell.setRowspan(Integer.parseInt(value));
    }
    value = attributes.getProperty(ElementTags.LEADING);
    if (value != null) {
        cell.setLeading(Float.parseFloat(value + "f"));
    }
    cell.setHeader(Utilities.checkTrueOrFalse(attributes,
            ElementTags.HEADER));
    if (Utilities.checkTrueOrFalse(attributes, ElementTags.NOWRAP)) {
        cell.setMaxLines(1);
    }
    setRectangleProperties(cell, attributes);
    return cell;
}
项目:geomajas-project-server    文件:PdfContext.java   
public Image getImage(String path) {
    try {
        URL url = getClass().getResource(path);
        if (url == null) {
            url = Utilities.toURL(path);
        }
        return Image.getInstance(url);
    } catch (Exception e) { // NOSONAR
        log.warn("could not fetch image", e);
        return null;
    }
}
项目:itext2    文件:InputMeta.java   
public void skip(int len) throws IOException{
    length += len;
    Utilities.skip(in, len);
}
项目:itext2    文件:ElementFactory.java   
/**
 * Creates a List object based on a list of properties.
 * @param attributes
 * @return the List
 */
public static List getList(Properties attributes) {
    List list = new List();

    list.setNumbered(Utilities.checkTrueOrFalse(attributes,
            ElementTags.NUMBERED));
    list.setLettered(Utilities.checkTrueOrFalse(attributes,
            ElementTags.LETTERED));
    list.setLowercase(Utilities.checkTrueOrFalse(attributes,
            ElementTags.LOWERCASE));
    list.setAutoindent(Utilities.checkTrueOrFalse(attributes,
            ElementTags.AUTO_INDENT_ITEMS));
    list.setAlignindent(Utilities.checkTrueOrFalse(attributes,
            ElementTags.ALIGN_INDENTATION_ITEMS));

    String value;

    value = attributes.getProperty(ElementTags.FIRST);
    if (value != null) {
        char character = value.charAt(0);
        if (Character.isLetter(character)) {
            list.setFirst(character);
        } else {
            list.setFirst(Integer.parseInt(value));
        }
    }

    value = attributes.getProperty(ElementTags.LISTSYMBOL);
    if (value != null) {
        list
                .setListSymbol(new Chunk(value, FontFactory
                        .getFont(attributes)));
    }

    value = attributes.getProperty(ElementTags.INDENTATIONLEFT);
    if (value != null) {
        list.setIndentationLeft(Float.parseFloat(value + "f"));
    }

    value = attributes.getProperty(ElementTags.INDENTATIONRIGHT);
    if (value != null) {
        list.setIndentationRight(Float.parseFloat(value + "f"));
    }

    value = attributes.getProperty(ElementTags.SYMBOLINDENT);
    if (value != null) {
        list.setSymbolIndent(Float.parseFloat(value));
    }

    return list;
}
项目:DroidText    文件:InputMeta.java   
public void skip(int len) throws IOException{
    length += len;
    Utilities.skip(in, len);
}
项目:DroidText    文件:ElementFactory.java   
/**
 * Creates a List object based on a list of properties.
 * @param attributes
 * @return the List
 */
public static List getList(Properties attributes) {
    List list = new List();

    list.setNumbered(Utilities.checkTrueOrFalse(attributes,
            ElementTags.NUMBERED));
    list.setLettered(Utilities.checkTrueOrFalse(attributes,
            ElementTags.LETTERED));
    list.setLowercase(Utilities.checkTrueOrFalse(attributes,
            ElementTags.LOWERCASE));
    list.setAutoindent(Utilities.checkTrueOrFalse(attributes,
            ElementTags.AUTO_INDENT_ITEMS));
    list.setAlignindent(Utilities.checkTrueOrFalse(attributes,
            ElementTags.ALIGN_INDENTATION_ITEMS));

    String value;

    value = attributes.getProperty(ElementTags.FIRST);
    if (value != null) {
        char character = value.charAt(0);
        if (Character.isLetter(character)) {
            list.setFirst(character);
        } else {
            list.setFirst(Integer.parseInt(value));
        }
    }

    value = attributes.getProperty(ElementTags.LISTSYMBOL);
    if (value != null) {
        list
                .setListSymbol(new Chunk(value, FontFactory
                        .getFont(attributes)));
    }

    value = attributes.getProperty(ElementTags.INDENTATIONLEFT);
    if (value != null) {
        list.setIndentationLeft(Float.parseFloat(value + "f"));
    }

    value = attributes.getProperty(ElementTags.INDENTATIONRIGHT);
    if (value != null) {
        list.setIndentationRight(Float.parseFloat(value + "f"));
    }

    value = attributes.getProperty(ElementTags.SYMBOLINDENT);
    if (value != null) {
        list.setSymbolIndent(Float.parseFloat(value));
    }

    return list;
}
项目:itext2    文件:BmpImage.java   
/** Reads a BMP from a file.
 * @param file the file
 * @throws IOException on error
 * @return the image
 */    
public static Image getImage(String file) throws IOException {
    return getImage(Utilities.toURL(file));
}
项目:itext2    文件:GifImage.java   
/** Reads gif images from a file.
 * @param file the file
 * @throws IOException on error
 */    
public GifImage(String file) throws IOException {
    this(Utilities.toURL(file));
}
项目:itext2    文件:PngImage.java   
/** Reads a PNG from a file.
 * @param file the file
 * @throws IOException on error
 * @return the image
 */    
public static Image getImage(String file) throws IOException {
    return getImage(Utilities.toURL(file));
}
项目:DroidText    文件:BmpImage.java   
/** Reads a BMP from a file.
 * @param file the file
 * @throws IOException on error
 * @return the image
 */    
public static Image getImage(String file) throws IOException {
    return getImage(Utilities.toURL(file));
}
项目:DroidText    文件:GifImage.java   
/** Reads gif images from a file.
 * @param file the file
 * @throws IOException on error
 */    
public GifImage(String file) throws IOException {
    this(Utilities.toURL(file));
}
项目:DroidText    文件:PngImage.java   
/** Reads a PNG from a file.
 * @param file the file
 * @throws IOException on error
 * @return the image
 */    
public static Image getImage(String file) throws IOException {
    return getImage(Utilities.toURL(file));
}