Java Utililty Methods Graphics Draw Background

List of utility methods to do Graphics Draw Background

Description

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

Method

voiddrawEditableBackground(Graphics2D g2d, Color leftColor, Color rightColor, int width, int height, int iconWidth, boolean isReversed)
Desenez fundalul unei celule editabile
Color oldColor = g2d.getColor();
g2d.setColor(rightColor);
g2d.fillRect(0, 0, width, height);
Color intermediateColor = colorAverage(leftColor, rightColor);
g2d.setColor(intermediateColor);
if (isReversed) {
    g2d.fillRect(width - iconWidth, 0, iconWidth, height);
} else {
...
voiddrawMenuBezel(Graphics g, Color background, int x, int y, int width, int height)
draw Menu Bezel
g.setColor(background);
g.fillRect(x, y, width, height);
g.setColor(background.brighter().brighter());
g.drawLine(x + 1, y + height - 1, x + width - 1, y + height - 1);
g.drawLine(x + width - 1, y + height - 2, x + width - 1, y + 1);
g.setColor(background.darker().darker());
g.drawLine(x, y, x + width - 2, y);
g.drawLine(x, y + 1, x, y + height - 2);
...
voiddrawVistaBackground(Graphics g, Component b, Color start, Color mid, Color end)
draw Vista Background
drawVistaBackground(g, 0, 0, b.getWidth(), b.getHeight(), start, mid, end);
voidfillVisibleBackground(final Graphics g, final JComponent c)
Fills either clipped or visible rect with component background color if its opaque
if (c.isOpaque()) {
    g.setColor(c.getBackground());
    fillVisible(g, c);
voidpaintNoBackground(final Graphics2D g, final Shape bounds)
paint No Background
g.fill(bounds);
voidpaintStretchedAspectRatioBackground(final Graphics2D g, final Rectangle bounds, final Image backgroundImage, final float opacity)
paint Stretched Aspect Ratio Background
final double widthratio = bounds.width / (double) backgroundImage.getWidth(null);
final double heightratio = bounds.height / (double) backgroundImage.getHeight(null);
final double ratio = Math.min(widthratio, heightratio);
final int width = (int) (backgroundImage.getWidth(null) * ratio);
final int height = (int) (backgroundImage.getWidth(null) * ratio);
final int x = bounds.width / 2 - width / 2;
final int y = bounds.height / 2 - height / 2;
final Composite originalComposite = g.getComposite();
...
voidpaintStretchedBackground(final Graphics2D g, final Rectangle bounds, final Image backgroundImage, final float opacity)
paint Stretched Background
final Composite originalComposite = g.getComposite();
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity));
g.drawImage(backgroundImage, 0, 0, bounds.width, bounds.height, null);
g.setComposite(originalComposite);