org.jtheque.utils.ui
Class PaintUtils

java.lang.Object
  extended by org.jtheque.utils.ui.PaintUtils

public final class PaintUtils
extends Object

Utility class to paint with Java2D.

The method tileStretchPaint has been recuperated from the Aerith Project.

Author:
Baptiste Wicht, Romain Guy/Chet Haase

Method Summary
static void drawAlphaImage(Graphics2D g2, BufferedImage image, int x, int y, float alpha)
          Draw a translucent image.
static void drawAlphaImage(Graphics2D g2, Image image, int x, int y, int width, int height, float alpha)
          Draw a translucent image with specified size.
static void drawAlphaImage(Graphics2D g2, Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, float alpha)
          Draw a translucent image with specified source and destination rectangles.
static void drawString(Graphics g2, String string, int x, int y, Font font)
          Draw a string.
static void drawString(Graphics g2, String string, int x, int y, Font font, Color color)
          Draw a string.
static void fillRect(Graphics g2, int x, int y, int width, int height, Color color)
          Fill a rectangle.
static void initHints(Graphics2D g2)
          Init the base hints for painting.
static void tileStretchPaint(Graphics g, Component component, BufferedImage image, Insets insets)
          Draws an image on top of a component by doing a 3x3 grid stretch of the image using the specified insets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

initHints

public static void initHints(Graphics2D g2)
Init the base hints for painting.

Parameters:
g2 - The graphics to init.

drawAlphaImage

public static void drawAlphaImage(Graphics2D g2,
                                  BufferedImage image,
                                  int x,
                                  int y,
                                  float alpha)
Draw a translucent image.

Parameters:
g2 - The graphics to paint with.
image - The image to paint.
x - The x position of the image.
y - The y position of the image.
alpha - The alpha value of the image painting.

drawAlphaImage

public static void drawAlphaImage(Graphics2D g2,
                                  Image image,
                                  int x,
                                  int y,
                                  int width,
                                  int height,
                                  float alpha)
Draw a translucent image with specified size.

Parameters:
g2 - The graphics to paint with.
image - The image to paint.
x - The x position of the image.
y - The y position of the image.
width - The width of the image.
height - The height of the image.
alpha - The alpha value of the image painting.

drawAlphaImage

public static void drawAlphaImage(Graphics2D g2,
                                  Image image,
                                  int dx1,
                                  int dy1,
                                  int dx2,
                                  int dy2,
                                  int sx1,
                                  int sy1,
                                  int sx2,
                                  int sy2,
                                  float alpha)
Draw a translucent image with specified source and destination rectangles.

Parameters:
g2 - The graphics to paint with.
image - The image to paint.
dx1 - the x coordinate of the first corner of the destination rectangle.
dy1 - the y coordinate of the first corner of the destination rectangle.
dx2 - the x coordinate of the second corner of the destination rectangle.
dy2 - the y coordinate of the second corner of the destination rectangle.
sx1 - the x coordinate of the first corner of the source rectangle.
sy1 - the y coordinate of the first corner of the source rectangle.
sx2 - the x coordinate of the second corner of the source rectangle.
sy2 - the y coordinate of the second corner of the source rectangle.
alpha - The alpha value of the image painting.

drawString

public static void drawString(Graphics g2,
                              String string,
                              int x,
                              int y,
                              Font font)
Draw a string.

Parameters:
g2 - The graphics to paint with.
string - The string to paint.
x - The x position to paint from.
y - The y position to paint from.
font - The font to use.

drawString

public static void drawString(Graphics g2,
                              String string,
                              int x,
                              int y,
                              Font font,
                              Color color)
Draw a string.

Parameters:
g2 - The graphics to paint with.
string - The string to paint.
x - The x position to paint from.
y - The y position to paint from.
font - The font to use.
color - The color to use.

fillRect

public static void fillRect(Graphics g2,
                            int x,
                            int y,
                            int width,
                            int height,
                            Color color)
Fill a rectangle.

Parameters:
g2 - The graphics to paint with.
x - The x position to paint from.
y - The y position to paint from.
width - The width of the rectangle.
height - The height of the rectangle.
color - The color to use.

tileStretchPaint

public static void tileStretchPaint(Graphics g,
                                    Component component,
                                    BufferedImage image,
                                    Insets insets)
Draws an image on top of a component by doing a 3x3 grid stretch of the image using the specified insets.

Parameters:
g - The graphics object to use.
component - The component.
image - The image.
insets - The insets.


Copyright © 2010 JTheque. All Rights Reserved.