Java Utililty Methods Graphics Draw

List of utility methods to do Graphics Draw

Description

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

Method

voidpaint3DRectEffect(Graphics graphics, int x, int y, int width, int height)
Paint a 3D effect to a Rectangle
paint3DRectEffect(graphics, x, y, width, height, 5);
voidpaint3DRoundRectEffect(Graphics g, int x, int y, int width, int height, int radius)
Paint a 3D effect to a RoundRect.
paint3DRoundRectEffect(g, x, y, width, height, radius, 5);
voidpaintBall(Graphics2D g2, Color c)
paint Ball
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
int diameter = 16;
Paint oldPaint = g2.getPaint();
g2.setColor(c);
g2.fillOval(0, 0, diameter - 1, diameter - 1);
Paint p;
p = new GradientPaint(0, 0, new Color(0.0f, 0.0f, 0.0f, 0.4f), 0, diameter,
        new Color(0.0f, 0.0f, 0.0f, 0.0f));
...
ImagepaintColorImageFromAlphaImage(Image alphaImage, Image out, Color color)
Paint the specified color in 'out' image depending original alpha intensity from 'alphaImage'
final int w;
final int h;
final Image result;
if (out == null) {
    w = alphaImage.getWidth(null);
    h = alphaImage.getHeight(null);
    if ((w == -1) || (h == -1))
        return null;
...
voidpaintComponent(Graphics g, Component c, Container p, Rectangle r)
This method paints the given component in the given rectangle.
paintComponent(g, c, p, r.x, r.y, r.width, r.height);
voidpaintCross(Graphics g, Color color, int centerX, int centerY, int size, int width)
paint Cross
g.setColor(color);
size /= 2;
for (int i = 0; i < width; i++) {
    g.drawLine(centerX - size, centerY - size, centerX + size, centerY + size);
    g.drawLine(centerX + size, centerY - size, centerX - size, centerY + size);
    centerX++;
voidpaintFilthyPanel(Graphics g, int width, int height)
Paint a filthy panel.
Graphics2D g2 = (Graphics2D) g;
Composite composite = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f));
g2.setColor(Color.white);
RoundRectangle2D background;
background = new RoundRectangle2D.Double(3.0, 3.0, (double) width - 10.0 - 3.0, (double) height - 6.0, 12,
        12);
g2.fill(background);
...
voidpaintFocus(Graphics g, int x, int y, int width, int height, int r1, int r2, float grosor, Color color)
paint Focus
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Stroke oldStroke = g2d.getStroke();
g2d.setColor(color);
g2d.setStroke(new BasicStroke(grosor));
if (r1 == 0 && r2 == 0) {
    g.drawRect(x, y, width, height);
} else {
...
voidpaintKnurl3(java.awt.Graphics g2, float x, float y, float width, float height)
paint Knurl
int xPixel0 = (int) x;
int xPixelA = (int) (x + (width * 0.5f));
int xPixel1 = (int) (x + width);
int yPixel = (int) y;
float yPixelMax = yPixel + height;
while (yPixel < yPixelMax) {
    paintPoint(g2, xPixelA, yPixel);
    if ((yPixel + 2) < yPixelMax) {
...
voidpaintLine(Graphics2D g2, Point2D.Double from, Point2D.Double to)
paint Line
Line2D.Double line = new Line2D.Double(from, to);
g2.setColor(Color.BLACK);
g2.draw(line);