Here's a method I put together that will draw a rectangle, fill it with a color, and put a String at the center of the rectangle.
/**
* <p>This method will draw a rectangle and place the text in the center
* of the rectangle.</p>
* @param g - Graphics instance from a JPanel paintComponent method
* @param r - Rectangle (origin and dimension) of the rectangle.
* @param c - Fill color of the rectangle.
* @param s - String to place at the center of the rectangle.
*/
public void drawBox(Graphics g, Rectangle r, Color c, String s) {
g.setColor(c);
g.fillRect(r.x, r.y, r.width, r.height);
Graphics2D g2d = (Graphics2D) g;
FontRenderContext frc = g2d.getFontRenderContext();
TextLayout layout = new TextLayout(s, g.getFont(), frc);
Rectangle2D bounds = layout.getBounds();
int width = (int) Math.round(bounds.getWidth());
int height = (int) Math.round(bounds.getHeight());
int x = r.x + (r.width - width) / 2;
int y = r.y + height + (r.height - height) / 2;
g.setColor(Color.BLACK);
layout.draw(g2d, (float) x, (float) y);
}
You'll have to figure out where you want the rectangles and how to connect them with skinny rectangles.