List of utility methods to do Draw Image
void | drawSquare(BufferedImage image, int x, int y, int size, int pixel) draw Square for (int px = 0; px < size; ++px) { for (int py = 0; py < size; ++py) { image.setRGB(x + px, y + py, pixel); |
void | drawStretchedImage(Rectangle2D bounds, Graphics2D g2, Image image, ImageObserver observer) draw Stretched Image drawStretchedImage(bounds, g2, image, observer, false); |
void | drawTiledImage(Rectangle2D bounds, Graphics2D g2, Image image, ImageObserver observer, int imageWidth, int imageHeight, int tilePadding) draw Tiled Image int x = (int) bounds.getX(); int y = (int) bounds.getY(); int w = imageWidth; int h = imageHeight; int cols = (int) Math.ceil(bounds.getWidth() / imageWidth); int rows = (int) Math.ceil(bounds.getHeight() / imageHeight); for (int row = 0; row < rows; row++) { if ((y + imageHeight) > bounds.getMaxY()) { ... |
void | drawTransparentImageInOval(Graphics2D gr, Image img, Rectangle r, boolean noShrink, double transparency) draw an image in a rectangle Composite oldComposite = gr.getComposite();
gr.setComposite(oldComposite);
Composite newComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) transparency);
gr.setComposite(newComposite);
drawImageInOval(gr, img, r, noShrink);
gr.setComposite(oldComposite);
|
void | drawVerticalBar(final BufferedImage image, final double max, final double min) draw Vertical Bar final int height = image.getHeight(); final Graphics2D g = image.createGraphics(); final FontMetrics metrics = g.getFontMetrics(g.getFont()); final int x = image.getWidth() - 1 - BAR_SIZE_VERT; final double middle = (max + min) / 2.0; final double quarter = (max - middle) / 2.0; final int width = image.getWidth(); for (int y = 0; y < height; y++) { ... |
void | drawVerticalLineAt(int x, int dottedLine, Color color, BufferedImage displayMap) draw Vertical Line At for (int y = 0; y < displayMap.getHeight(); y += dottedLine) { drawPixel(x, y, color, displayMap); |
VolatileImage | drawVolatileImage(Graphics2D g, VolatileImage volatileImage, int x, int y, Image orig) From The Java Developers Almanac 1.4 e674. final boolean VERBOSE = false; final int MAX_TRIES = 5; for (int i = 0; i < MAX_TRIES; i++) { if (VERBOSE) { System.out.println("try " + (i + 1)); if (volatileImage == null) { final int imageWidth = orig.getWidth(null); ... |