Java Utililty Methods Draw Shadow

List of utility methods to do Draw Shadow

Description

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

Method

voiddrawShadedLine(java.awt.Graphics2D g2, float x0, float y0, float x1, float y1, java.awt.Paint topLeftPaint, java.awt.Paint otherPaint, java.awt.Paint bottomRightPaint, java.awt.geom.GeneralPath buffer)
draw Shaded Line
float xDelta = x0 - x1;
float yDelta = y0 - y1;
if (xDelta > 0) {
    if (yDelta > 0) {
        g2.setPaint(otherPaint);
    } else if (yDelta < 0) {
        g2.setPaint(topLeftPaint);
    } else {
...
voiddrawShadow(Graphics2D g2d, Color topColor, float opacity, int shadowWidth, int cornerRadius, int x, int y, int width, int height)
draw Shadow
if (shadowWidth == 0) {
    return;
g2d.setColor(new Color(topColor.getRed(), topColor.getGreen(), topColor.getBlue(),
        ((int) (opacity * 255)) & 0xFF));
float alpha = 0.1f;
float step = (float) (0.9 / shadowWidth);
for (int i = 1; i <= shadowWidth; i++) {
...
voiddrawShadowedShape(Shape shape, Graphics2D g2d)
draw Shadowed Shape
Color holdColor = g2d.getColor();
g2d.setColor(Color.black);
AffineTransform holdTransform = g2d.getTransform();
float lineWidth = g2d.getStroke() instanceof BasicStroke ? ((BasicStroke) (g2d.getStroke())).getLineWidth()
        : 1.0f;
g2d.translate(lineWidth, lineWidth);
g2d.draw(shape);
g2d.setColor(holdColor);
...
voiddrawShadowedString(Graphics2D g2d, String label, Color textColor, Color shadowColor, int x, int y)
draw Shadowed String
g2d.setColor(shadowColor);
g2d.drawString(label, x + 0.8f, y + 0.8f);
g2d.setColor(textColor);
g2d.drawString(label, x, y);
voiddrawShadowedString(String string, int x, int y, Graphics2D g2d)
draw Shadowed String
Color holdColor = g2d.getColor();
g2d.setColor(Color.black);
g2d.drawString(string, x + 1, y + 1);
g2d.setColor(holdColor);
g2d.drawString(string, x, y);