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

voiddrawHandles(final Graphics g, final int[] x, final int[] y)
draw Handles
final int sizeOuter = 6;
for (int i = 0; i < y.length; i++)
    g.drawRect(x[i] - sizeOuter / 2, y[i] - sizeOuter / 2, sizeOuter, sizeOuter);
voiddrawIcon(Graphics g, String icon, int x, int y)
draw Icon
if (g == null) {
    return;
int length = icon.length();
int x1, y1, x2, y2;
int pc = 0;
while (true) {
    char command = icon.charAt(pc++);
...
voiddrawInnerButtonDecoration(Graphics g, int x, int y, int w, int h, Color baseColor)
Draws a button border for an xp button with the given colors.
Color lightColor = translucentColor(baseColor, 90);
Color mediumColor = translucentColor(baseColor, 120);
Color darkColor = translucentColor(baseColor, 200);
g.translate(x, y);
g.setColor(lightColor);
g.fillRect(2, 1, w - 4, 1);
g.setColor(mediumColor);
g.fillRect(1, 2, 1, h - 4);
...
voiddrawISPip(Graphics2D g2d, float width, float height)
draw IS Pip
Font font = new Font("Arial", Font.PLAIN, 6);
g2d.setFont(font);
g2d.drawString("O", width, height);
voiddrawLightBeamVertical(Graphics g, Color c, int midx, int y1, int y2)
draw Light Beam Vertical
float[] carr = new float[3];
c.getRGBColorComponents(carr);
for (int i = -beamR; i < beamR; i++) {
    float weight = fmin1((beamR - Math.abs(i)) / (double) beamR);
    g.setColor(new Color(carr[0], carr[1], carr[2], weight));
    g.drawLine(midx + i, y1, midx + i, y2);
voiddrawLoweredBezel(Graphics g, int x, int y, int w, int h, Color shadow, Color darkShadow, Color highlight, Color lightHighlight)
draw Lowered Bezel
g.setColor(darkShadow);
g.drawLine(0, 0, 0, h - 1);
g.drawLine(1, 0, w - 2, 0);
g.setColor(shadow);
g.drawLine(1, 1, 1, h - 2);
g.drawLine(1, 1, w - 3, 1);
g.setColor(lightHighlight);
g.drawLine(0, h - 1, w - 1, h - 1);
...
voiddrawMarker(Graphics2D g, int markerWidth, int markerHeight, Point location)
Draws a circle-marker on the given position
int x = location.x;
int y = location.y;
g.fillOval(x, y, markerWidth - 1, markerHeight - 1);
g.drawOval(x, y, markerWidth - 1, markerHeight - 1);
voiddrawMask(Graphics2D g2, Shape mask)
draw Mask
g2.fill(mask);
voiddrawMovingRect(int x, int y, int width, int height, Graphics g, int seed)
Draws moving rectangle used for cross and borders in cover
if (width > 1) {
    for (int i = x, pos = 0; i < x + width; i += 10, pos++) {
        if (pos % 2 == 0) {
            g.setColor(Color.black);
        } else {
            g.setColor(Color.white);
        int z = i + seed + 10;
...
voiddrawOptimizedLine(Graphics g, int x1, int y1, int x2, int y2)
draw Optimized Line
if (g.getColor().getAlpha() < 255 && (x1 == x2 || y1 == y2))
    g.fillRect(x1 < x2 ? x1 : x2, y1 < y2 ? y1 : y2, Math.abs(x2 - x1) + 1, Math.abs(y2 - y1) + 1);
else
    g.drawLine(x1, y1, x2, y2);