use of java.awt.TexturePaint in project gephi by gephi.
the class GradientSliderUI method createCheckerPaint.
private static void createCheckerPaint() {
int k = 4;
BufferedImage bi = new BufferedImage(2 * k, 2 * k, BufferedImage.TYPE_INT_RGB);
Graphics2D g = bi.createGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, 2 * k, 2 * k);
g.setColor(Color.lightGray);
g.fillRect(0, 0, k, k);
g.fillRect(k, k, k, k);
checkerPaint = new TexturePaint(bi, new Rectangle(0, 0, bi.getWidth(), bi.getHeight()));
}
use of java.awt.TexturePaint in project jdk8u_jdk by JetBrains.
the class TexturePaintPrintingTest method doPaint.
public void doPaint(Graphics2D g2d) {
BufferedImage patternImage = new BufferedImage(2, 2, BufferedImage.TYPE_INT_ARGB);
Graphics gImage = patternImage.getGraphics();
gImage.setColor(Color.WHITE);
gImage.drawLine(0, 1, 1, 0);
gImage.setColor(Color.BLACK);
gImage.drawLine(0, 0, 1, 1);
gImage.dispose();
Rectangle2D.Double shape = new Rectangle2D.Double(0, 0, DIM * 6 / 5, DIM * 8 / 5);
g2d.setPaint(new TexturePaint(patternImage, new Rectangle2D.Double(0, 0, DIM * 6 / 50, DIM * 8 / 50)));
g2d.fill(shape);
g2d.setPaint(Color.BLACK);
g2d.draw(shape);
}
use of java.awt.TexturePaint in project jdk8u_jdk by JetBrains.
the class TransformedPaintTest method createPaint.
private Paint createPaint(PaintType type, int startx, int starty, int w, int h) {
// make sure that the blue color doesn't show up when filling a
// w by h rect
w++;
h++;
int endx = startx + w;
int endy = starty + h;
Rectangle2D.Float r = new Rectangle2D.Float(startx, starty, w, h);
switch(type) {
case COLOR:
return Color.red;
case GRADIENT:
return new GradientPaint(startx, starty, Color.red, endx, endy, Color.green);
case LINEAR_GRADIENT:
return new LinearGradientPaint(startx, starty, endx, endy, new float[] { 0.0f, 0.999f, 1.0f }, new Color[] { Color.red, Color.green, Color.blue });
case RADIAL_GRADIENT:
return new RadialGradientPaint(startx, starty, (float) Math.sqrt(w * w + h * h), new float[] { 0.0f, 0.999f, 1.0f }, new Color[] { Color.red, Color.green, Color.blue }, CycleMethod.NO_CYCLE);
case TEXTURE:
{
BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g = (Graphics2D) bi.getGraphics();
g.setPaint(createPaint(PaintType.LINEAR_GRADIENT, 0, 0, w, h));
g.fillRect(0, 0, w, h);
return new TexturePaint(bi, r);
}
}
return Color.green;
}
use of java.awt.TexturePaint in project poi by apache.
the class HwmfGraphics method getHatchedFill.
protected Paint getHatchedFill() {
int dim = 7, mid = 3;
BufferedImage bi = new BufferedImage(dim, dim, BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D g = bi.createGraphics();
Color c = (prop.getBkMode() == HwmfBkMode.TRANSPARENT) ? new Color(0, true) : prop.getBackgroundColor().getColor();
g.setColor(c);
g.fillRect(0, 0, dim, dim);
g.setColor(prop.getBrushColor().getColor());
HwmfHatchStyle h = prop.getBrushHatch();
if (h == HwmfHatchStyle.HS_HORIZONTAL || h == HwmfHatchStyle.HS_CROSS) {
g.drawLine(0, mid, dim, mid);
}
if (h == HwmfHatchStyle.HS_VERTICAL || h == HwmfHatchStyle.HS_CROSS) {
g.drawLine(mid, 0, mid, dim);
}
if (h == HwmfHatchStyle.HS_FDIAGONAL || h == HwmfHatchStyle.HS_DIAGCROSS) {
g.drawLine(0, 0, dim, dim);
}
if (h == HwmfHatchStyle.HS_BDIAGONAL || h == HwmfHatchStyle.HS_DIAGCROSS) {
g.drawLine(0, dim, dim, 0);
}
g.dispose();
return new TexturePaint(bi, new Rectangle(0, 0, dim, dim));
}
use of java.awt.TexturePaint in project jdk8u_jdk by JetBrains.
the class RenderTests method makeTexturePaint.
private TexturePaint makeTexturePaint(int size, boolean alpha) {
int s2 = size / 2;
int type = alpha ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB;
BufferedImage img = new BufferedImage(size, size, type);
Color[] colors = makeGradientColors(4, alpha);
Graphics2D g2d = img.createGraphics();
g2d.setComposite(AlphaComposite.Src);
g2d.setColor(colors[0]);
g2d.fillRect(0, 0, s2, s2);
g2d.setColor(colors[1]);
g2d.fillRect(s2, 0, s2, s2);
g2d.setColor(colors[3]);
g2d.fillRect(0, s2, s2, s2);
g2d.setColor(colors[2]);
g2d.fillRect(s2, s2, s2, s2);
g2d.dispose();
Rectangle2D bounds = new Rectangle2D.Float(0, 0, size, size);
return new TexturePaint(img, bounds);
}
Aggregations