JScrollPane scrollPane = (JScrollPane) c;
JScrollBar vertical = scrollPane.getVerticalScrollBar();
JScrollBar horizontal = scrollPane.getHorizontalScrollBar();
JViewport columnHeader = scrollPane.getColumnHeader();
StandardBorderPainter painter = new SimplisticSoftBorderPainter();
SubstanceColorScheme scheme = SubstanceColorSchemeUtilities
.getColorScheme(c, ColorSchemeAssociationKind.BORDER, c
.isEnabled() ? ComponentState.DEFAULT
: ComponentState.DISABLED_UNSELECTED);
float borderStrokeWidth = SubstanceSizeUtils
.getBorderStrokeWidth(SubstanceSizeUtils
.getComponentFontSize(c));
int borderDelta = (int) Math.floor(SubstanceSizeUtils
.getBorderStrokeWidth(SubstanceSizeUtils
.getComponentFontSize(c)) / 2.0);
Graphics2D g2d = (Graphics2D) g.create();
g2d.setStroke(new BasicStroke(borderStrokeWidth,
BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER));
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
x += borderDelta;
y += borderDelta;
width -= 2 * borderDelta;
height -= 2 * borderDelta;
boolean horizontalVisible = (horizontal != null)
&& horizontal.isVisible();
boolean verticalVisible = (vertical != null) && vertical.isVisible();
if (scrollPane.getComponentOrientation().isLeftToRight()) {
// top portion
g2d.setColor(painter.getTopBorderColor(scheme, scheme, 0, false));
if (verticalVisible && (columnHeader == null)) {
g2d.drawLine(x, y, x + width - vertical.getWidth(), y);
} else {
g2d.drawLine(x, y, x + width, y);
}
// left portion
g2d.setColor(painter.getTopBorderColor(scheme, scheme, 0, false));
if (horizontalVisible) {
g2d.drawLine(x, y, x, y + height - horizontal.getHeight());
} else {
g2d.drawLine(x, y, x, y + height);
}
// bottom portion
g2d
.setColor(painter.getBottomBorderColor(scheme, scheme, 0,
false));
if (horizontalVisible) {
// g.drawLine(x + horizontal.getWidth(), y + height - 1,
// x + width, y + height - 1);
} else {
if (verticalVisible) {
g2d.drawLine(x, y + height - 1, x + width
- vertical.getWidth(), y + height - 1);
} else {
g2d.drawLine(x, y + height - 1, x + width, y + height - 1);
}
}
// right portion
g2d
.setColor(painter.getBottomBorderColor(scheme, scheme, 0,
false));
if (verticalVisible) {
// g.drawLine(x + width - 1, y + vertical.getHeight(), x + width
// - 1, y + height);
if (columnHeader != null) {
g2d.drawLine(x + width - 1, y, x + width - 1, y
+ columnHeader.getHeight());
}
} else {
if (horizontalVisible)
g2d.drawLine(x + width - 1, y, x + width - 1, y + height
- horizontal.getHeight());
else
g2d.drawLine(x + width - 1, y, x + width - 1, y + height);
}
} else {
// top portion
g2d.setColor(painter.getTopBorderColor(scheme, scheme, 0, false));
if (verticalVisible && (columnHeader == null)) {
g2d.drawLine(x + vertical.getWidth(), y, x + width, y);
} else {
g2d.drawLine(x, y, x + width, y);
}
// left portion
g2d
.setColor(painter.getBottomBorderColor(scheme, scheme, 0,
false));
if (verticalVisible) {
// g.drawLine(x, y, x, y + height - horizontal.getHeight());
if (columnHeader != null) {
g2d.drawLine(x, y, x, y + columnHeader.getHeight());
}
} else {
if (horizontalVisible) {
g2d.drawLine(x, y, x, y + height - horizontal.getHeight());
} else {
g2d.drawLine(x, y, x, y + height - 1);
}
}
// bottom portion
g2d
.setColor(painter.getBottomBorderColor(scheme, scheme, 0,
false));
if (horizontalVisible) {
// g.drawLine(x + horizontal.getWidth(), y + height - 1,
// x + width, y + height - 1);
} else {
if (verticalVisible) {
g2d.drawLine(x + vertical.getWidth(), y + height - 1, x
+ width, y + height - 1);
} else {
g2d.drawLine(x, y + height - 1, x + width, y + height - 1);
}
}
// right portion
g2d.setColor(painter.getTopBorderColor(scheme, scheme, 0, false));
if (horizontalVisible) {
g2d.drawLine(x + width - 1, y, x + width - 1, y + height
- horizontal.getHeight());
} else {
g2d.drawLine(x + width - 1, y, x + width - 1, y + height);