private void applyImageAttributes(Attributes attributes) {
int border = 0;
Align align = null;
if (attributes instanceof ImageAttributes) {
ImageAttributes imageAttributes = (ImageAttributes) attributes;
border = imageAttributes.getBorder();
align = imageAttributes.getAlign();
}
if (xhtmlStrict) {
String borderStyle = String.format("border-width: %spx;",border);
String alignStyle = null;
if (align != null) {
switch (align) {
case Center:
case Right:
case Left:
alignStyle = "text-align: "+align.name().toLowerCase()+";";
break;
case Bottom:
case Baseline:
case Top:
case Middle:
alignStyle = "vertical-align: "+align.name().toLowerCase()+";";
break;
case Texttop:
alignStyle = "vertical-align: text-top;";
break;
case Absmiddle:
alignStyle = "vertical-align: middle;";
break;
case Absbottom:
alignStyle = "vertical-align: bottom;";
break;
}
}
String additionalStyles = borderStyle;
if (alignStyle != null) {
additionalStyles += alignStyle;
}
if (attributes.getCssStyle() == null || attributes.getCssStyle().length() == 0) {
attributes.setCssStyle(additionalStyles);
} else {
attributes.setCssStyle(additionalStyles+attributes.getCssStyle());
}
}
applyAttributes(attributes);
boolean haveAlt = false;
if (attributes instanceof ImageAttributes) {
ImageAttributes imageAttributes = (ImageAttributes) attributes;
if (imageAttributes.getHeight() != -1) {
writer.writeAttribute("height", Integer.toString(imageAttributes.getHeight()));
}
if (imageAttributes.getWidth() != -1) {
writer.writeAttribute("width", Integer.toString(imageAttributes.getWidth()));
}
if (!xhtmlStrict && align != null) {
writer.writeAttribute("align", align.name().toLowerCase());
}
if (imageAttributes.getAlt() != null) {
haveAlt = true;
writer.writeAttribute("alt", imageAttributes.getAlt());
}
}
if (attributes.getTitle() != null) {
writer.writeAttribute("title", attributes.getTitle());
if (!haveAlt) {