本文整理汇总了Java中org.fit.cssbox.layout.LengthSet类的典型用法代码示例。如果您正苦于以下问题:Java LengthSet类的具体用法?Java LengthSet怎么用?Java LengthSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LengthSet类属于org.fit.cssbox.layout包,在下文中一共展示了LengthSet类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderElementBackground
import org.fit.cssbox.layout.LengthSet; //导入依赖的package包/类
public void renderElementBackground(ElementBox eb)
{
Rectangle bb = eb.getAbsoluteBorderBounds();
if (eb instanceof Viewport)
bb = eb.getClippedBounds(); //for the root box (Viewport), use the whole clipped content
Color bg = eb.getBgcolor();
//background color
if (bg != null)
{
String style = "stroke:none;fill-opacity:1;fill:" + colorString(bg);
out.println("<rect x=\"" + bb.x + "\" y=\"" + bb.y + "\" width=\"" + bb.width + "\" height=\"" + bb.height + "\" style=\"" + style + "\" />");
}
//background image
if (eb.getBackgroundImages() != null && eb.getBackgroundImages().size() > 0)
{
for (BackgroundImage bimg : eb.getBackgroundImages())
{
BufferedImage img = bimg.getBufferedImage();
if (img != null)
{
ByteArrayOutputStream os = new ByteArrayOutputStream();
try
{
ImageIO.write(img, "png", os);
} catch (IOException e) {
out.println("<!-- I/O error: " + e.getMessage() + " -->");
}
char[] data = Base64Coder.encode(os.toByteArray());
String imgdata = "data:image/png;base64," + new String(data);
int ix = bb.x + eb.getBorder().left;
int iy = bb.y + eb.getBorder().top;
int iw = bb.width - eb.getBorder().right - eb.getBorder().left;
int ih = bb.height - eb.getBorder().bottom - eb.getBorder().top;
out.println("<image x=\"" + ix + "\" y=\"" + iy + "\" width=\"" + iw + "\" height=\"" + ih + "\" xlink:href=\"" + imgdata + "\" />");
}
}
}
//border
LengthSet borders = eb.getBorder();
if (borders.top > 0)
writeBorderSVG(eb, bb.x, bb.y, bb.x + bb.width, bb.y, "top", borders.top, 0, borders.top/2);
if (borders.right > 0)
writeBorderSVG(eb, bb.x + bb.width, bb.y, bb.x + bb.width, bb.y + bb.height, "right", borders.right, -borders.right/2, 0);
if (borders.bottom > 0)
writeBorderSVG(eb, bb.x, bb.y + bb.height, bb.x + bb.width, bb.y + bb.height, "bottom", borders.bottom, 0, -borders.bottom/2);
if (borders.left > 0)
writeBorderSVG(eb, bb.x, bb.y, bb.x, bb.y + bb.height, "left", borders.left, borders.left/2, 0);
}