Java 8 RadialGradientPaint - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 RadialGradientPaint class.

This code example shows how to use the following methods:sleep
        try { 
            reader.addIIOReadProgressListener(this);
            iis = ImageIO.createImageInputStream(file);
            reader.setInput(iis);
            ImageReadParam p = reader.getDefaultReadParam();
            Thread.sleep(70);
            BufferedImage res = reader.read(0, p);
            Thread.sleep(70);
        } catch (Exception e) {
            /* 
             * we do expect that concurrent attempt to dispose this 
             * instance of image reader will be blocked. So, this image 
             * should be read sucessfuly. Otherwise, something went wrong 
             * and we need to report test failure. 
             */ 
            throw new RuntimeException("Test FAILED", e);
        } finally { 
            /* 
             * it would happen that concurrent invocation of dispose() method 
             * will be successful. Due to race condition it seems to be possible 

5
CodeRank
This code example shows how to use the following methods:
        Object cyclicValue = map.get("cycle");
        if (null != cyclicValue) { 
            cyclicMethod = parseCyclicMethod(map, String.valueOf(cyclicValue));
        } 
 
        super.setValueInternal(new RadialGradientPaint(cx, cy, radius, fx, fy, fractions, colors, cyclicMethod));
    } 
 
    private float[] parseFractions(Object source, Object obj) { 
        if (obj instanceof CharSequence) {
            return parseFractions(source, String.valueOf(obj).trim());
        } else if (obj instanceof List) {
            return parseFractions(source, (List) obj);
        } 
        throw illegalValue(source, RadialGradientPaint.class);
    } 
 
    private float[] parseFractions(Object source, String str) {
        if (!str.startsWith("[") || !str.endsWith("]")) {
            throw illegalValue(source, RadialGradientPaint.class);
5
CodeRank
This code example shows how to use the following methods:
        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;
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
        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();
 
        try { 
            System.out.println("Create test image " + file.getAbsolutePath());
            boolean b = ImageIO.write(img, "JPEG", file);
            if (!b) {
                throw new RuntimeException("Failed to create test image.");
            } 
        } catch (IOException e) {
            throw new RuntimeException("Test failed", e);
        } 
    } 
5
CodeRank
This code example shows how to use the following methods:
        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;
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
    return new JavaGradient(p);
  } 
 
  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);
  } 
 
  private static Color[] convertColors(int[] colors) {
    Color[] javaColors = new Color[colors.length];
    for (int i = 0; i < colors.length; ++i) {
      javaColors[i] = new Color(colors[i], true);
    } 
    return javaColors;
  } 
 
  Paint paint;
 
  private JavaGradient(Paint paint) {
5
CodeRank
This code example shows how to use the following methods:
     */ 
    private static RadialGradientPaint createGradientPaint(Color c1, Color c2) {
        Point2D center = new Point2D.Float(0, 0);
        float radius = 200;
        float[] dist = {0.0f, 1.0f};
        return new RadialGradientPaint(center, radius, dist,
                new Color[] {c1, c2});
    } 
 
    @Override  
    public void start(Stage stage) throws Exception {
        PieDataset dataset = createDataset();
        JFreeChart chart = createChart(dataset); 
        ChartViewer viewer = new ChartViewer(chart);  
        stage.setScene(new Scene(viewer)); 
        stage.setTitle("JFreeChart: PieChartFXDemo1.java"); 
        stage.setWidth(700);
        stage.setHeight(390);
        stage.show(); 
    } 
4
CodeRank
This code example shows how to use the following methods:
		super(img);
 
		this.win = win;
 
		paint = new RadialGradientPaint(new Point2D.Float(0, 0), 3,
				new float[]{0.0f, 1.0f}, new Color[]{new Color(255, 255, 255, 255), new Color(255, 255, 255, 0)});
		brush = new java.awt.geom.Ellipse2D.Float(-5, -5, 11, 11);
 
		imgg = img.createGraphics();
 
		this.addMouseListener(this);
	} 
 
	void drawPaint(double x, double y) {
		Graphics2D gg = (Graphics2D) imgg.create();
 
		gg.translate(x, y);
		gg.setPaint(paint);
		gg.fill(brush);
 
4
CodeRank
This code example shows how to use the following methods:
			this.paintWidth = paintX + ARCRADIUS;
			this.paintHeight = paintY + ARCRADIUS;
			this.fill = new LColor(165, 0, 0, 0);
			this.border = new RadialGradientPaint(0, 0, ARCRADIUS, new float[] {
					0.0f, 0.6f, 1.0f }, new Color[] { new Color(0, 0, 0, 200),
					Color.WHITE, new Color(255, 255, 255, 200) });
			break; 
 
		} 
 
	} 
 
	public void setColor(LColor color) {
		this.color = color;
	} 
 
	public void black() { 
		this.color = defaultBlackColor;
	} 
 
4
CodeRank
This code example shows how to use the following methods:
            final Ellipse2D GREEN_ON = new Ellipse2D.Double(0.1875 * IMAGE_WIDTH, 0.5285714285714286 * IMAGE_HEIGHT, 0.625 * IMAGE_WIDTH, 0.35714285714285715 * IMAGE_HEIGHT);
            G2.setPaint(new RadialGradientPaint(new Point2D.Double(0.5 * IMAGE_WIDTH, 0.8214285714285714 * IMAGE_HEIGHT), (0.59375f * IMAGE_WIDTH), new float[]{0.0f, 0.98f, 0.99f, 1.0f}, new Color[]{new Color(0f, 1f, 0f, 1f), new Color(0.1254901961f, 0.2784313725f, 0.1411764706f, 1f), new Color(0.1254901961f, 0.2705882353f, 0.1411764706f, 1f), new Color(0.1254901961f, 0.2705882353f, 0.1411764706f, 1f)}));
            G2.fill(GREEN_ON);
 
            final Ellipse2D GREEN_HIGHLIGHT_ON = new Ellipse2D.Double(0.2625 * IMAGE_WIDTH, 0.5357142857142857 * IMAGE_HEIGHT, 0.4625 * IMAGE_WIDTH, 0.14285714285714285 * IMAGE_HEIGHT);
            G2.setPaint(new RadialGradientPaint(new Point2D.Double(0.5 * IMAGE_WIDTH, 0.5642857142857143 * IMAGE_HEIGHT), (0.2125f * IMAGE_WIDTH), new float[]{0.0f, 0.98f, 1.0f}, new Color[]{new Color(1f, 1f, 1f, 0.6745098039f), new Color(1f, 1f, 1f, 0.0862745098f), new Color(1f, 1f, 1f, 0.0862745098f)}));
            G2.fill(GREEN_HIGHLIGHT_ON);
        } 
 
        final Ellipse2D GREEN_INNER_SHADOW = new Ellipse2D.Double(0.1875 * IMAGE_WIDTH, 0.5285714285714286 * IMAGE_HEIGHT, 0.625 * IMAGE_WIDTH, 0.35714285714285715 * IMAGE_HEIGHT);
        G2.setPaint(new RadialGradientPaint(new Point2D.Double(0.5 * IMAGE_WIDTH, 0.7071428571428572 * IMAGE_HEIGHT), (0.3125f * IMAGE_WIDTH), new float[]{0.0f, 0.55f, 0.5501f, 0.78f, 0.79f, 1.0f}, new Color[]{new Color(0.0039215686f, 0.0039215686f, 0.0039215686f, 0f), new Color(0f, 0f, 0f, 0f), new Color(0f, 0f, 0f, 0f), new Color(0f, 0f, 0f, 0.1215686275f), new Color(0f, 0f, 0f, 0.1294117647f), new Color(0f, 0f, 0f, 0.4980392157f)}));
        G2.fill(GREEN_INNER_SHADOW);
 
        G2.dispose();
        return IMAGE;
    } 
 
    public BufferedImage create2LightsRedImage(final int WIDTH, final int HEIGHT, final boolean IS_ON) {
        final GraphicsConfiguration GFX_CONF = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
        if (WIDTH <= 0 || HEIGHT <= 0) {
3
CodeRank
See Code Examples for Java 8 RadialGradientPaint Methods: