use of org.loboevolution.info.BorderInfo in project LoboEvolution by LoboEvolution.
the class BaseElementRenderable method prePaintBorder.
private void prePaintBorder(Graphics g, int totalWidth, int totalHeight, int startX, int startY) {
final Insets borderInsets = this.borderInsets;
if (borderInsets != null) {
final int btop = borderInsets.top;
final int bleft = borderInsets.left;
final int bright = borderInsets.right;
final int bbottom = borderInsets.bottom;
final int newTotalWidth = totalWidth - (bleft + bright);
final int newTotalHeight = totalHeight - (btop + bbottom);
final int newStartX = startX + bleft;
final int newStartY = startY + btop;
final Rectangle clientRegion = new Rectangle(newStartX, newStartY, newTotalWidth, newTotalHeight);
// Paint borders if the clip bounds are not contained
// by the content area.
final Rectangle clipBounds = g.getClipBounds();
if (!clientRegion.contains(clipBounds)) {
final BorderInfo borderInfo = this.borderInfo;
int x1;
int y1;
int x2;
int y2;
int dashSize;
if (btop > 0) {
g.setColor(getBorderTopColor());
final int borderStyle = borderInfo == null ? BorderInsets.BORDER_STYLE_SOLID : borderInfo.getTopStyle();
for (int i = 0; i < btop; i++) {
final int leftOffset = i * bleft / btop;
final int rightOffset = i * bright / btop;
x1 = startX + leftOffset;
y1 = startY + i;
x2 = startX + totalWidth - rightOffset - 1;
y2 = startY + i;
dashSize = 10 + btop;
paintBorder(g, x1, y1, x2, y2, dashSize, btop, borderStyle);
}
}
if (bright > 0) {
final int borderStyle = borderInfo == null ? BorderInsets.BORDER_STYLE_SOLID : borderInfo.getRightStyle();
g.setColor(getBorderRightColor());
final int lastX = startX + totalWidth - 1;
for (int i = 0; i < bright; i++) {
final int topOffset = i * btop / bright;
final int bottomOffset = i * bbottom / bright;
x1 = lastX - i;
y1 = startY + topOffset;
x2 = lastX - i;
y2 = startY + totalHeight - bottomOffset - 1;
dashSize = 10 + bright;
paintBorder(g, x1, y1, x2, y2, dashSize, bright, borderStyle);
}
}
if (bbottom > 0) {
final int borderStyle = borderInfo == null ? BorderInsets.BORDER_STYLE_SOLID : borderInfo.getBottomStyle();
g.setColor(getBorderBottomColor());
final int lastY = startY + totalHeight - 1;
for (int i = 0; i < bbottom; i++) {
final int leftOffset = i * bleft / bbottom;
final int rightOffset = i * bright / bbottom;
x1 = startX + leftOffset;
y1 = lastY - i;
x2 = startX + totalWidth - rightOffset - 1;
y2 = lastY - i;
dashSize = 10 + bbottom;
paintBorder(g, x1, y1, x2, y2, dashSize, bbottom, borderStyle);
}
}
if (bleft > 0) {
final int borderStyle = borderInfo == null ? BorderInsets.BORDER_STYLE_SOLID : borderInfo.getLeftStyle();
g.setColor(getBorderLeftColor());
for (int i = 0; i < bleft; i++) {
final int topOffset = i * btop / bleft;
final int bottomOffset = i * bbottom / bleft;
x1 = startX + i;
y1 = startY + topOffset;
x2 = startX + i;
y2 = startY + totalHeight - bottomOffset - 1;
dashSize = 10 + bleft;
paintBorder(g, x1, y1, x2, y2, dashSize, bleft, borderStyle);
}
}
}
}
}
use of org.loboevolution.info.BorderInfo in project LoboEvolution by LoboEvolution.
the class TableRenderState method getBorderInfo.
/**
* {@inheritDoc}
*/
@Override
public BorderInfo getBorderInfo() {
BorderInfo binfo = this.borderInfo;
if (binfo != INVALID_BORDER_INFO) {
return binfo;
}
binfo = super.getBorderInfo();
if (binfo == null || binfo.getTopStyle() == BorderInsets.BORDER_STYLE_NONE && binfo.getBottomStyle() == BorderInsets.BORDER_STYLE_NONE && binfo.getLeftStyle() == BorderInsets.BORDER_STYLE_NONE && binfo.getRightStyle() == BorderInsets.BORDER_STYLE_NONE) {
if (binfo == null) {
binfo = new BorderInfo();
}
final HTMLElementImpl element = this.element;
if (element != null) {
String border = element.getAttribute("border");
if (border != null) {
border = border.trim();
int value;
int valueType;
if (border.endsWith("%")) {
valueType = HtmlInsets.TYPE_PERCENT;
try {
value = Integer.parseInt(border.substring(0, border.length() - 1));
} catch (final NumberFormatException nfe) {
value = 0;
}
} else {
valueType = HtmlInsets.TYPE_PIXELS;
try {
value = Integer.parseInt(border);
} catch (final NumberFormatException nfe) {
value = 0;
}
}
final HtmlInsets borderInsets = new HtmlInsets();
borderInsets.top = borderInsets.left = borderInsets.right = borderInsets.bottom = value;
borderInsets.topType = borderInsets.leftType = borderInsets.rightType = borderInsets.bottomType = valueType;
binfo.setInsets(borderInsets);
if (binfo.getTopColor() == null) {
binfo.setTopColor(Color.DARK_GRAY);
}
if (binfo.getLeftColor() == null) {
binfo.setLeftColor(Color.DARK_GRAY);
}
if (binfo.getRightColor() == null) {
binfo.setRightColor(Color.LIGHT_GRAY);
}
if (binfo.getBottomColor() == null) {
binfo.setBottomColor(Color.LIGHT_GRAY);
}
if (value != 0) {
binfo.setTopStyle(BorderInsets.BORDER_STYLE_SOLID);
binfo.setLeftStyle(BorderInsets.BORDER_STYLE_SOLID);
binfo.setRightStyle(BorderInsets.BORDER_STYLE_SOLID);
binfo.setBottomStyle(BorderInsets.BORDER_STYLE_SOLID);
}
}
}
}
this.borderInfo = binfo;
return binfo;
}
use of org.loboevolution.info.BorderInfo in project LoboEvolution by LoboEvolution.
the class BorderInsets method getBorderInfo.
/**
* <p>getBorderInfo.</p>
*
* @param properties a {@link org.loboevolution.html.node.css.CSS3Properties} object.
* @param element a {@link org.loboevolution.html.dom.domimpl.HTMLElementImpl} object.
* @param renderState a {@link org.loboevolution.html.renderstate.RenderState} object.
* @return a {@link org.loboevolution.info.BorderInfo} object.
*/
public static BorderInfo getBorderInfo(CSS3Properties properties, HTMLElementImpl element, RenderState renderState) {
final BorderInfo binfo = new BorderInfo();
final int topStyle = getBorderStyle(element, properties.getBorderTopStyle());
final int rightStyle = getBorderStyle(element, properties.getBorderRightStyle());
final int bottomStyle = getBorderStyle(element, properties.getBorderBottomStyle());
final int leftStyle = getBorderStyle(element, properties.getBorderLeftStyle());
final Color topColor = getBorderColor(element, properties.getBorderTopColor(), renderState);
final Color rightColor = getBorderColor(element, properties.getBorderRightColor(), renderState);
final Color bottomColor = getBorderColor(element, properties.getBorderBottomColor(), renderState);
final Color leftColor = getBorderColor(element, properties.getBorderLeftColor(), renderState);
binfo.setTopStyle(topStyle);
binfo.setRightStyle(rightStyle);
binfo.setBottomStyle(bottomStyle);
binfo.setLeftStyle(leftStyle);
binfo.setTopColor(topColor);
binfo.setRightColor(rightColor);
binfo.setBottomColor(bottomColor);
binfo.setLeftColor(leftColor);
populateBorderInsets(binfo, properties, element, renderState);
return binfo;
}
use of org.loboevolution.info.BorderInfo in project LoboEvolution by LoboEvolution.
the class StyleSheetRenderState method getBorderInfo.
/**
* {@inheritDoc}
*/
@Override
public BorderInfo getBorderInfo() {
BorderInfo binfo = this.borderInfo;
if (binfo != INVALID_BORDER_INFO) {
return binfo;
}
final AbstractCSSProperties props = getCssProperties();
if (props != null) {
binfo = BorderInsets.getBorderInfo(props, element, this);
} else {
binfo = null;
}
this.borderInfo = binfo;
return binfo;
}
use of org.loboevolution.info.BorderInfo in project LoboEvolution by LoboEvolution.
the class FieldsetRenderState method getBorderInfo.
/**
* {@inheritDoc}
*/
@Override
public BorderInfo getBorderInfo() {
BorderInfo binfo = this.borderInfo;
if (binfo != INVALID_BORDER_INFO) {
return binfo;
}
binfo = super.getBorderInfo();
if (binfo == null || binfo.getTopStyle() == BorderInsets.BORDER_STYLE_NONE && binfo.getBottomStyle() == BorderInsets.BORDER_STYLE_NONE && binfo.getLeftStyle() == BorderInsets.BORDER_STYLE_NONE && binfo.getRightStyle() == BorderInsets.BORDER_STYLE_NONE) {
if (binfo == null) {
binfo = new BorderInfo();
}
binfo.setInsets(getDefaultBordernsets());
binfo.setTopColor(Color.DARK_GRAY);
binfo.setLeftColor(Color.DARK_GRAY);
binfo.setRightColor(Color.DARK_GRAY);
binfo.setBottomColor(Color.DARK_GRAY);
binfo.setTopStyle(BorderInsets.BORDER_STYLE_SOLID);
binfo.setLeftStyle(BorderInsets.BORDER_STYLE_SOLID);
binfo.setRightStyle(BorderInsets.BORDER_STYLE_SOLID);
binfo.setBottomStyle(BorderInsets.BORDER_STYLE_SOLID);
}
this.borderInfo = binfo;
return binfo;
}
Aggregations