List of usage examples for java.awt Graphics fillPolygon
public void fillPolygon(Polygon p)
From source file:tilt.image.page.Line.java
/** * Print the shapes onto the original image * @param g the graphics environment//from w ww . j a va2 s .c om * @param wr the raster to write on * @param n the number of the line */ public void print(Graphics g, WritableRaster wr, int n) { Color tColour; if (n % 3 == 0) tColour = new Color(255, 0, 0, 128); else if (n % 3 == 1) tColour = new Color(0, 255, 0, 128); else tColour = new Color(0, 0, 255, 128); Color old = g.getColor(); if (shapes.size() > 0) { Rectangle bounds = shapes.get(0).getBounds(); g.setColor(Color.black); g.drawString(Integer.toString(n), bounds.x - 20, (bounds.y * 2 + bounds.height) / 2); } for (int i = 0; i < shapes.size(); i++) { Shape s = shapes.get(i); g.setColor(tColour); if (s instanceof Polygon) g.fillPolygon((Polygon) s); else if (s instanceof Rectangle) { Rectangle r = (Rectangle) s; g.fillRect(r.x, r.y, r.width, r.height); } } g.setColor(old); }