public interface CustomRenderer
| Modifier and Type | Method and Description |
|---|---|
void |
draw(java.awt.Graphics2D g2d)
The method called when the element needs to be drawn.
|
void |
drawImage(java.awt.Graphics2D g2d)
The method called when the element needs to draw its background image.
|
void |
fill(java.awt.Graphics2D g2d)
The method called when the element needs to be filled.
|
void draw(java.awt.Graphics2D g2d)
public void draw(java.awt.Graphics2D g2d) {
g2d.draw(this);
}
g2d - the Graphics2D context to be used for drawingvoid fill(java.awt.Graphics2D g2d)
public void fill(java.awt.Graphics2D g2d) {
g2d.fill(this);
}
g2d - the Graphics2D context to be used for drawingvoid drawImage(java.awt.Graphics2D g2d)
public void drawImage(java.awt.Graphics2D g2d) {
Image image = element.getGrappaNexus().getImage();
if (image != null) {
Rectangle sbox = this.getBounds();
Shape clip = g2d.getClip();
// prevent reshaping
double w = ((double) image.getWidth(null)) / (double) sbox.width;
double h = ((double) image.getHeight(null)) / (double) sbox.height;
int width = (int) (((double) image.getWidth(null)) / Math.max(w, h));
int height = (int) (((double) image.getHeight(null)) / Math.max(w, h));
g2d.clip(this);
g2d.drawImage(image, sbox.x + (sbox.width - width) / 2,
sbox.y + (sbox.height - height) / 2, width, height, null);
g2d.setClip(clip);
}
g2d - the Graphics2D context to be used for drawing