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

voiddrawDiamond(Graphics2D g2d, int xPos, int yPos)
draw Diamond
String path = new File(recordSheetPath).getAbsolutePath() + File.separatorChar;
Image img = new ImageIcon(path + "shielddiamond.png").getImage();
g2d.drawImage(img, xPos, yPos, 5, 5, null);
voiddrawDisc(Graphics g)
draw Disc
int width = g.getClipBounds().width;
int height = g.getClipBounds().height;
Color theColor = g.getColor();
g.setColor(Color.DARK_GRAY);
g.fillOval(4, 4, width - 8, height - 8);
g.setColor(theColor);
g.fillOval(6, 6, width - 12, height - 12);
voiddrawDot(Graphics g, int x, int y)
draw Dot
g.drawLine(x - 1, y - 1, x, y - 1);
g.drawLine(x - 1, y, x, y);
voiddrawDots(Graphics g, int x0, int y0, int x1, int y1, int interval)
draw Dots
if (y0 == y1) {
    for (int i = x0; i < x1; i += interval) {
        g.drawLine(i, y0, i, y1);
} else {
    for (int i = y0; i < y1; i += interval) {
        g.drawLine(x0, i, x1, i);
voiddrawDottedDashLine(Graphics2D g, int x1, int y1, int x2, int y2)
draw Dotted Dash Line
Stroke thindashed = new BasicStroke(1.0f, 
        BasicStroke.CAP_BUTT, 
        BasicStroke.JOIN_BEVEL, 1.0f, 
        new float[] { 8.0f, 3.0f, 2.0f, 3.0f }, 
        0.0f); 
drawDashedLine(g, thindashed, x1, y1, x2, y2);
voiddrawDottedRect(Graphics g, int x, int y, int w, int h)
draw Dotted Rect
drawDotLine(g, x, y, x + w, y);
drawDotLine(g, x + w, y, x + w, y + h);
drawDotLine(g, x, y + h, x + w, y + h);
drawDotLine(g, x, y, x, y + h);
voiddrawDropshipISPip(Graphics2D g2d, int width, int height, int circleSize, int fillCircleSize)
draw Dropship IS Pip
Dimension circle = new Dimension(circleSize, circleSize);
Dimension fillCircle = new Dimension(fillCircleSize, fillCircleSize);
g2d.setColor(Color.black);
g2d.fillOval(width, height, circle.width, circle.height);
g2d.setColor(Color.white);
g2d.fillOval(width + 1, height + 1, fillCircle.width, fillCircle.height);
voiddrawEdge(Graphics g, int w, int h)
draw Edge
drawEdge(g, 0, 0, w, h);
voiddrawEtchedRect(Graphics g, int x, int y, int width, int height, Color shadow, Color darkShadow, Color highlight, Color lightHighlight)
Draws a rectangle that appears etched into the surface, given four colors that are used for drawing.
Color oldColor;
int x2, y2;
oldColor = g.getColor();
x2 = x + width - 1;
y2 = y + height - 1;
try {
    g.setColor(shadow);
    g.drawLine(x, y, x2 - 1, y); 
...
voiddrawFilledBox(Graphics2D g, int x, int y, int width, int height)
Draw a filled box, with some of the edges beveled
Polygon p = new Polygon();
int bevel_amount = DEFAULT_BEVEL_AMOUNT;
if (width < bevel_amount * 2)
    bevel_amount = width / 2;
if (height < bevel_amount * 2)
    bevel_amount = height / 2;
if ((DEFAULT_BEVEL_CORNERS & BEVEL_CORNER_TOP_LEFT) == BEVEL_CORNER_TOP_LEFT) {
    p.addPoint(x, y + bevel_amount);
...