public void paint( final IFigure figure, final Graphics graphics, final Insets insets )
{
Rectangle rectangle = new Rectangle();
rectangle.setBounds(getPaintRectangle(figure, insets));
BorderComponent borderDef = this.rectPresentation.getTopBorder();
if (this.hasUniformBorders && borderDef.getWeight().content() > 0)
{
int w = borderDef.getWeight().content();
rectangle = FigureUtil.getAdjustedRectangle(rectangle, 1.0, w);
int cornerRadius = this.rectPresentation.getCornerRadius();
float cornerWidth = cornerRadius;
float cornerHeight = cornerRadius;
// adjust corner for the inner path (formula found by experimenting)
if (cornerRadius > 0) {
cornerHeight = Math.max(1, cornerHeight - (w + cornerHeight / 64));
cornerWidth = Math.max(1, cornerWidth - (w + cornerWidth / 64));
}
graphics.setLineWidth(borderDef.getWeight().content());
graphics.setForegroundColor(resourceCache.getColor(borderDef.getColor().content()));
graphics.setLineStyle(FigureUtil.convertLineStyle(borderDef.getStyle().content()));
graphics.drawRoundRectangle(rectangle,
Math.max(0, (int)cornerWidth),
Math.max(0, (int)cornerHeight));
}
else
{
if( borderDef.getWeight().content() > 0 )
{
int w = borderDef.getWeight().content();
graphics.setLineWidth(w);
graphics.setForegroundColor(resourceCache.getColor(borderDef.getColor().content()));
graphics.setLineStyle(FigureUtil.convertLineStyle(borderDef.getStyle().content()));
int inset = Math.max(1, w >> 1);
int x = rectangle.x;
int y = rectangle.y + inset;
int x2 = rectangle.x + rectangle.width;
graphics.drawLine(x, y, x2, y);
}
borderDef = this.rectPresentation.getBottomBorder();
if( borderDef.getWeight().content() > 0 )
{
int w = borderDef.getWeight().content();
graphics.setLineWidth(w);
graphics.setForegroundColor(resourceCache.getColor(borderDef.getColor().content()));
graphics.setLineStyle(FigureUtil.convertLineStyle(borderDef.getStyle().content()));
int inset = Math.max(1, w >> 1);
int x = rectangle.x;
int y = rectangle.y + rectangle.height - inset;
int x2 = rectangle.x + rectangle.width;
graphics.drawLine(x, y, x2, y);
}
borderDef = this.rectPresentation.getLeftBorder();
if( borderDef.getWeight().content() > 0 )
{
int w = borderDef.getWeight().content();
graphics.setLineWidth(w);
graphics.setForegroundColor(resourceCache.getColor(borderDef.getColor().content()));
graphics.setLineStyle(FigureUtil.convertLineStyle(borderDef.getStyle().content()));
int inset = Math.max(1, w >> 1);
int x = rectangle.x + inset;
int y = rectangle.y;
int y2 = rectangle.y + rectangle.height;
graphics.drawLine(x, y, x, y2);
}
borderDef = this.rectPresentation.getRightBorder();
if( borderDef.getWeight().content() > 0 )
{
int w = borderDef.getWeight().content();
graphics.setLineWidth(w);
graphics.setForegroundColor(resourceCache.getColor(borderDef.getColor().content()));
graphics.setLineStyle(FigureUtil.convertLineStyle(borderDef.getStyle().content()));
int inset = Math.max(1, w >> 1);
int x = rectangle.x + rectangle.width - inset;
int y = rectangle.y;
int y2 = rectangle.y + rectangle.height;
graphics.drawLine(x, y, x, y2);