예제 #1
0
  protected void doOutputImage(ImageField image) {
    if (image == null || image.getImageURL() == null) return;

    outputCellStart(image);

    ImageIcon icon = image.getImageIcon(); // For width and height
    String url = image.getImageURL().toString();
    if (url.startsWith("file:")) url = url.substring(5);

    // Make an alt attribute from the URL
    String alt = url;
    int pos = alt.lastIndexOf("/");
    if (pos != -1) alt = alt.substring(pos + 1);

    out.print(
        "<img src=\""
            + StringUtils.escapeHTML(url)
            + "\" alt=\""
            + StringUtils.escapeHTML(alt)
            + "\" width=\""
            + icon.getIconWidth()
            + "\" height=\""
            + icon.getIconHeight()
            + "\">");
    outputCellEnd();
  }
예제 #2
0
  protected void doOutputField(Field field) {
    Format format = outputCellStart(field);
    // Style attribute courtesy of Brendon Price <*****@*****.**>
    out.print("<span style=\"");
    if (format.getFontFamilyName() != null)
      out.print("font-family: " + format.getFontFamilyName() + "; ");
    out.print("font-size: " + format.getSize() + "pt; ");
    outputColor(format.getColor());

    // Border code courtesy of Khadiyd Idris <*****@*****.**>
    Border b = field.getBorderOrDefault();
    String bcolor = "black";
    if (b.getColor() != null) {
      bcolor =
          "#"
              + Integer.toHexString(b.getColor().getRed())
              + Integer.toHexString(b.getColor().getGreen())
              + Integer.toHexString(b.getColor().getBlue());
    }

    if (b.getTop() != null)
      out.print("border-top: solid " + bcolor + " " + b.getTop().getThickness() + "pt; ");
    if (b.getLeft() != null)
      out.print("border-left: solid " + bcolor + " " + b.getLeft().getThickness() + "pt; ");
    if (b.getBottom() != null)
      out.print("border-bottom: solid " + bcolor + " " + b.getBottom().getThickness() + "pt; ");
    if (b.getRight() != null)
      out.print("border-right: solid " + bcolor + " " + b.getRight().getThickness() + "pt; ");

    out.print("\">");

    if (format.isBold()) out.print("<b>");
    if (format.isItalic()) out.print("<i>");
    if (format.isUnderline()) out.print("<u>");

    String str = field.toString();
    if (str == null || str.length() == 0) str = "&nbsp;";

    // Fix courtesy of Brendon Price <*****@*****.**>
    if ("&nbsp;".equals(str)) out.print(str);
    else out.print(StringUtils.newlinesToXHTMLBreaks(StringUtils.escapeHTML(str)));

    if (format.isUnderline()) out.print("</u>");
    if (format.isItalic()) out.print("</i>");
    if (format.isBold()) out.print("</b>");
    out.print("</span>");

    outputCellEnd();
  }