Java Utililty Methods Graphics Draw Border

List of utility methods to do Graphics Draw Border

Description

The list of methods to do Graphics Draw Border are organized into topic(s).

Method

voidpaintBorderDebugInfo(final Graphics g, final JComponent c, final Color color)
Paints border debug information.
final Insets margin = c.getInsets();
g.setColor(color);
g.drawRect(0, 0, c.getWidth() - 1, c.getHeight() - 1);
g.drawRect(margin.left, margin.top, c.getWidth() - margin.left - margin.right - 1,
        c.getHeight() - margin.top - margin.bottom - 1);
voidpaintBorderGlow(final Graphics2D g2, final Shape shape, final int glowWidth)
paint Border Glow
int gw = glowWidth * 2;
for (int i = gw; i >= 2; i -= 2) {
    float pct = (float) (gw - i) / (gw - 1);
    Color mixHi = getMixedColor(clrGlowInnerHi, pct, clrGlowOuterHi, 1.0f - pct);
    Color mixLo = getMixedColor(clrGlowInnerLo, pct, clrGlowOuterLo, 1.0f - pct);
    g2.setPaint(new GradientPaint(0.0f, 40 * 0.25f, mixHi, 0.0f, 40, mixLo));
    g2.setColor(Color.WHITE);
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, pct));
...
voidpaintBorderGlow(Graphics2D g2, int glowWidth, Shape clipShape, Color glowOuterHigh, Color glowOuterLow)
Paints border glow over the given clipShape with the given glow high and low colors and the given glowWidth.
int gw = glowWidth * 2;
for (int i = gw; i >= 2; i -= 2) {
    float pct = (float) (gw - i) / (gw - 1);
    Color mixHi = getMixedColor(glowOuterHigh, pct, new Color(255, 255, 255, 200), 1.0f - pct);
    Color mixLo = getMixedColor(glowOuterLow, pct, new Color(255, 255, 255, 200), 1.0f - pct);
    g2.setPaint(new GradientPaint(0, clipShape.getBounds().height * 0.25f, mixHi, 0,
            clipShape.getBounds().height, mixLo));
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, pct));
...
voidpaintSequenceMatrix(Graphics2D g2, Rectangle2D rect, String sequence, Function coloring, Function border)
paint Sequence Matrix
Paint p = g2.getPaint();
Rectangle2D tile = (Rectangle2D) rect.clone();
int h = sequence.length() + 2;
int w = sequence.length() + 2;
Point point = new Point();
for (int i = 0; i < sequence.length(); i++) {
    point.y = i;
    for (int j = 0; j < sequence.length(); j++) {
...
voidpaintXpGradientBorder(Graphics g, int x, int y, int width, int height, Color darkC, int borderType)
Paints border of given rectangle, which enhances "light shining" effect
if ((borderType & XP_BORDER_RIGHT) != 0) {
    Color color = adjustColor(darkC, -6, -5, -3);
    g.setColor(color);
    g.drawLine(x + width - 2, y, x + width - 2, y + height - 2);
    color = adjustColor(darkC, -27, -26, -20);
    g.setColor(color);
    g.drawLine(x + width - 1, y, x + width - 1, y + height - 1);
if ((borderType & XP_BORDER_BOTTOM) != 0) {
    Color color = adjustColor(darkC, -6, -5, -3);
    g.setColor(color);
    g.drawLine(x, y + height - 2, x + width - 2, y + height - 2);
    color = adjustColor(darkC, -27, -26, -20);
    g.setColor(color);
    g.drawLine(x, y + height - 1, x + width - 1, y + height - 1);