Search in sources :

Example 1 with RadialGradientPaint

use of java.awt.RadialGradientPaint in project jdk8u_jdk by JetBrains.

the class RadialGradientPrintingTest method doPaint.

public void doPaint(Graphics2D g2d) {
    g2d.translate(DIM * 0.2, DIM * 0.2);
    Shape s = new Rectangle2D.Float(0, 0, DIM * 2, DIM * 2);
    // RadialGradientPaint
    Point2D centre = new Point2D.Float(DIM / 2.0f, DIM / 2.0f);
    float radius = DIM / 2.0f;
    Point2D focus = new Point2D.Float(DIM / 3.0f, DIM / 3.0f);
    float[] stops = { 0.0f, 1.0f };
    Color[] colors = { Color.red, Color.white };
    RadialGradientPaint rgp = new RadialGradientPaint(centre, radius, focus, stops, colors, RadialGradientPaint.CycleMethod.NO_CYCLE);
    g2d.setPaint(rgp);
    g2d.fill(s);
    g2d.translate(DIM * 2.2, 0);
    Color[] colors1 = { Color.red, Color.blue, Color.green };
    float[] stops1 = { 0.0f, 0.5f, 1.0f };
    RadialGradientPaint rgp1 = new RadialGradientPaint(centre, radius, focus, stops1, colors1, RadialGradientPaint.CycleMethod.REFLECT);
    g2d.setPaint(rgp1);
    g2d.fill(s);
    g2d.translate(-DIM * 2.2, DIM * 2.2);
    Color[] colors2 = { Color.red, Color.blue, Color.green, Color.white };
    float[] stops2 = { 0.0f, 0.3f, 0.6f, 1.0f };
    RadialGradientPaint rgp2 = new RadialGradientPaint(centre, radius, focus, stops2, colors2, RadialGradientPaint.CycleMethod.REPEAT);
    g2d.setPaint(rgp2);
    g2d.fill(s);
}
Also used : Shape(java.awt.Shape) Point2D(java.awt.geom.Point2D) Color(java.awt.Color) RadialGradientPaint(java.awt.RadialGradientPaint)

Example 2 with RadialGradientPaint

use of java.awt.RadialGradientPaint in project jdk8u_jdk by JetBrains.

the class MlibOpsTest method createSrcImage.

private static BufferedImage createSrcImage() {
    BufferedImage img = createImage();
    Graphics2D g = img.createGraphics();
    Color[] colors = { Color.red, Color.green, Color.blue };
    float[] dist = { 0.0f, 0.5f, 1.0f };
    Point2D center = new Point2D.Float(0.5f * w, 0.5f * h);
    RadialGradientPaint p = new RadialGradientPaint(center, 0.5f * w, dist, colors);
    g.setPaint(p);
    g.fillRect(0, 0, w, h);
    g.dispose();
    return img;
}
Also used : Point2D(java.awt.geom.Point2D) Color(java.awt.Color) RadialGradientPaint(java.awt.RadialGradientPaint) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Example 3 with RadialGradientPaint

use of java.awt.RadialGradientPaint in project jdk8u_jdk by JetBrains.

the class WritingInterruptionTest method createTestImage.

private static BufferedImage createTestImage() {
    int w = 1024;
    int h = 768;
    BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = img.createGraphics();
    Color[] colors = { Color.red, Color.green, Color.blue };
    float[] dist = { 0.0f, 0.5f, 1.0f };
    Point2D center = new Point2D.Float(0.5f * w, 0.5f * h);
    RadialGradientPaint p = new RadialGradientPaint(center, 0.5f * w, dist, colors);
    g.setPaint(p);
    g.fillRect(0, 0, w, h);
    g.dispose();
    return img;
}
Also used : Point2D(java.awt.geom.Point2D) Color(java.awt.Color) RadialGradientPaint(java.awt.RadialGradientPaint) RadialGradientPaint(java.awt.RadialGradientPaint) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Example 4 with RadialGradientPaint

use of java.awt.RadialGradientPaint in project poi by apache.

the class DrawPaint method createRadialGradientPaint.

protected Paint createRadialGradientPaint(GradientPaint fill, Graphics2D graphics) {
    Rectangle2D anchor = DrawShape.getAnchor(graphics, shape);
    Point2D pCenter = new Point2D.Double(anchor.getX() + anchor.getWidth() / 2, anchor.getY() + anchor.getHeight() / 2);
    float radius = (float) Math.max(anchor.getWidth(), anchor.getHeight());
    float[] fractions = fill.getGradientFractions();
    Color[] colors = new Color[fractions.length];
    int i = 0;
    for (ColorStyle fc : fill.getGradientColors()) {
        colors[i++] = applyColorTransform(fc);
    }
    return new RadialGradientPaint(pCenter, radius, fractions, colors);
}
Also used : Point2D(java.awt.geom.Point2D) ColorStyle(org.apache.poi.sl.usermodel.ColorStyle) Color(java.awt.Color) Rectangle2D(java.awt.geom.Rectangle2D) RadialGradientPaint(java.awt.RadialGradientPaint) SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) GradientPaint(org.apache.poi.sl.usermodel.PaintStyle.GradientPaint) TexturePaint(org.apache.poi.sl.usermodel.PaintStyle.TexturePaint) LinearGradientPaint(java.awt.LinearGradientPaint) RadialGradientPaint(java.awt.RadialGradientPaint) Paint(java.awt.Paint)

Example 5 with RadialGradientPaint

use of java.awt.RadialGradientPaint in project playn by threerings.

the class JavaGradient method createRadial.

static JavaGradient createRadial(float x, float y, float r, float[] positions, int[] colors) {
    Point2D.Float center = new Point2D.Float(x, y);
    RadialGradientPaint p = new RadialGradientPaint(center, r, positions, convertColors(colors));
    return new JavaGradient(p);
}
Also used : Point2D(java.awt.geom.Point2D) RadialGradientPaint(java.awt.RadialGradientPaint)

Aggregations

RadialGradientPaint (java.awt.RadialGradientPaint)32 Color (java.awt.Color)27 Point2D (java.awt.geom.Point2D)26 Graphics2D (java.awt.Graphics2D)18 Paint (java.awt.Paint)13 LinearGradientPaint (java.awt.LinearGradientPaint)10 Ellipse2D (java.awt.geom.Ellipse2D)9 BufferedImage (java.awt.image.BufferedImage)8 GradientPaint (java.awt.GradientPaint)6 Stroke (java.awt.Stroke)4 Rectangle2D (java.awt.geom.Rectangle2D)4 RbmModelContainer (cbit.vcell.model.Model.RbmModelContainer)3 BasicStroke (java.awt.BasicStroke)3 Point (java.awt.Point)3 Rectangle (java.awt.Rectangle)3 Shape (java.awt.Shape)3 TexturePaint (java.awt.TexturePaint)3 Area (java.awt.geom.Area)3 RoundRectangle2D (java.awt.geom.RoundRectangle2D)3 MolecularType (org.vcell.model.rbm.MolecularType)3