java.awt.RadialGradientPaint Java Examples
The following examples show how to use
java.awt.RadialGradientPaint.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConcurrentWritingTest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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; }
Example #2
Source File: WritingInterruptionTest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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; }
Example #3
Source File: MlibOpsTest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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; }
Example #4
Source File: MlibOpsTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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; }
Example #5
Source File: MlibOpsTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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; }
Example #6
Source File: ConcurrentWritingTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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; }
Example #7
Source File: ConcurrentWritingTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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; }
Example #8
Source File: MlibOpsTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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; }
Example #9
Source File: MlibOpsTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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; }
Example #10
Source File: MlibOpsTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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; }
Example #11
Source File: WritingInterruptionTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
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; }
Example #12
Source File: ConcurrentWritingTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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; }
Example #13
Source File: WritingInterruptionTest.java From hottub with GNU General Public License v2.0 | 6 votes |
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; }
Example #14
Source File: MlibOpsTest.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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; }
Example #15
Source File: MlibOpsTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
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; }
Example #16
Source File: ConcurrentWritingTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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; }
Example #17
Source File: RenderTests.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private RadialGradientPaint makeRadial(int numColors, boolean alpha) { float interval = 1.0f / (numColors - 1); float[] fractions = new float[numColors]; for (int i = 0; i < fractions.length; i++) { fractions[i] = i * interval; } Color[] colors = makeGradientColors(numColors, alpha); return new RadialGradientPaint(0.0f, 0.0f, 10.0f, fractions, colors, CycleMethod.REFLECT); }
Example #18
Source File: ConcurrentReadingTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private static void createTestFile() { int w = 1280; int h = 1024; 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(); 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); } }
Example #19
Source File: TrafficLight.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public BufferedImage createRedOnImage(final int WIDTH, final int HEIGHT) { final GraphicsConfiguration GFX_CONF = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration(); if (WIDTH <= 0 || HEIGHT <= 0) { return GFX_CONF.createCompatibleImage(1, 1, java.awt.Transparency.TRANSLUCENT); } final BufferedImage IMAGE = GFX_CONF.createCompatibleImage(WIDTH, HEIGHT, Transparency.TRANSLUCENT); final Graphics2D G2 = IMAGE.createGraphics(); G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); G2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); final int IMAGE_WIDTH = IMAGE.getWidth(); final int IMAGE_HEIGHT = IMAGE.getHeight(); final Ellipse2D LIGHT_ON = new Ellipse2D.Double(0.17346938775510204 * IMAGE_WIDTH, 0.07553956834532374 * IMAGE_HEIGHT, 0.6530612244897959 * IMAGE_WIDTH, 0.2302158273381295 * IMAGE_HEIGHT); G2.setPaint(new RadialGradientPaint(new Point2D.Double(0.5 * IMAGE_WIDTH, 0.1906474820143885 * IMAGE_HEIGHT), (0.32653061224489793f * IMAGE_WIDTH), new float[]{0.0f, 1.0f}, new Color[]{new Color(1f, 0f, 0f, 1f), new Color(0.2549019608f, 0f, 0.0156862745f, 1f)})); G2.fill(LIGHT_ON); final GeneralPath GLOW = new GeneralPath(); GLOW.setWindingRule(Path2D.WIND_EVEN_ODD); GLOW.moveTo(0.0 * IMAGE_WIDTH, 0.19424460431654678 * IMAGE_HEIGHT); GLOW.curveTo(0.0 * IMAGE_WIDTH, 0.29136690647482016 * IMAGE_HEIGHT, 0.22448979591836735 * IMAGE_WIDTH, 0.37050359712230213 * IMAGE_HEIGHT, 0.5 * IMAGE_WIDTH, 0.37050359712230213 * IMAGE_HEIGHT); GLOW.curveTo(0.7755102040816326 * IMAGE_WIDTH, 0.37050359712230213 * IMAGE_HEIGHT, 1.0 * IMAGE_WIDTH, 0.29136690647482016 * IMAGE_HEIGHT, 1.0 * IMAGE_WIDTH, 0.1906474820143885 * IMAGE_HEIGHT); GLOW.curveTo(0.9081632653061225 * IMAGE_WIDTH, 0.13309352517985612 * IMAGE_HEIGHT, 0.7040816326530612 * IMAGE_WIDTH, 0.0683453237410072 * IMAGE_HEIGHT, 0.5 * IMAGE_WIDTH, 0.0683453237410072 * IMAGE_HEIGHT); GLOW.curveTo(0.2857142857142857 * IMAGE_WIDTH, 0.0683453237410072 * IMAGE_HEIGHT, 0.08163265306122448 * IMAGE_WIDTH, 0.13309352517985612 * IMAGE_HEIGHT, 0.0 * IMAGE_WIDTH, 0.19424460431654678 * IMAGE_HEIGHT); GLOW.closePath(); G2.setPaint(new RadialGradientPaint(new Point2D.Double(0.5 * IMAGE_WIDTH, 0.1906474820143885 * IMAGE_HEIGHT), (0.5153061224489796f * IMAGE_WIDTH), new float[]{0.0f, 1.0f}, new Color[]{new Color(1f, 0f, 0f, 1f), new Color(0.4627450980f, 0.0196078431f, 0.0039215686f, 0f)})); G2.fill(GLOW); G2.dispose(); return IMAGE; }
Example #20
Source File: PaintAlpha.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Create a new (if possible, darker) <code>Paint</code> of the same Type. * If the Type is not supported, the original <code>Paint</code> is returned. * <p> * @param paint a <code>Paint</code> implementation * (e.g. {@link Color}, {@link GradientPaint}, {@link TexturePaint},..) * <p> * @return a (usually new, see above) <code>Paint</code> */ public static Paint darker(Paint paint) { if (paint instanceof Color) { return darker((Color) paint); } if (legacyAlpha == true) { /* * Legacy? Just return the original Paint. * (this corresponds EXACTLY to how Paints used to be darkened) */ return paint; } if (paint instanceof GradientPaint) { return darker((GradientPaint) paint); } if (paint instanceof LinearGradientPaint) { return darkerLinearGradientPaint((LinearGradientPaint) paint); } if (paint instanceof RadialGradientPaint) { return darkerRadialGradientPaint((RadialGradientPaint) paint); } if (paint instanceof TexturePaint) { try { return darkerTexturePaint((TexturePaint) paint); } catch (Exception e) { /* * Lots can go wrong while fiddling with Images, Color Models * & such! If anything at all goes awry, just return the original * TexturePaint. (TexturePaint's are immutable anyway, so no harm * done) */ return paint; } } return paint; }
Example #21
Source File: SunGraphics2D.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Sets the Paint in the current graphics state. * @param paint The Paint object to be used to generate color in * the rendering process. * @see java.awt.Graphics#setColor * @see GradientPaint * @see TexturePaint */ public void setPaint(Paint paint) { if (paint instanceof Color) { setColor((Color) paint); return; } if (paint == null || this.paint == paint) { return; } this.paint = paint; if (imageComp == CompositeType.SrcOverNoEa) { // special case where compState depends on opacity of paint if (paint.getTransparency() == Transparency.OPAQUE) { if (compositeState != COMP_ISCOPY) { compositeState = COMP_ISCOPY; } } else { if (compositeState == COMP_ISCOPY) { compositeState = COMP_ALPHA; } } } Class<? extends Paint> paintClass = paint.getClass(); if (paintClass == GradientPaint.class) { paintState = PAINT_GRADIENT; } else if (paintClass == LinearGradientPaint.class) { paintState = PAINT_LIN_GRADIENT; } else if (paintClass == RadialGradientPaint.class) { paintState = PAINT_RAD_GRADIENT; } else if (paintClass == TexturePaint.class) { paintState = PAINT_TEXTURE; } else { paintState = PAINT_CUSTOM; } validFontInfo = false; invalidatePipe(); }
Example #22
Source File: BufferedPaints.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
static void setPaint(RenderQueue rq, SunGraphics2D sg2d, Paint paint, int ctxflags) { if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) { setColor(rq, sg2d.pixel); } else { boolean useMask = (ctxflags & BufferedContext.USE_MASK) != 0; switch (sg2d.paintState) { case SunGraphics2D.PAINT_GRADIENT: setGradientPaint(rq, sg2d, (GradientPaint)paint, useMask); break; case SunGraphics2D.PAINT_LIN_GRADIENT: setLinearGradientPaint(rq, sg2d, (LinearGradientPaint)paint, useMask); break; case SunGraphics2D.PAINT_RAD_GRADIENT: setRadialGradientPaint(rq, sg2d, (RadialGradientPaint)paint, useMask); break; case SunGraphics2D.PAINT_TEXTURE: setTexturePaint(rq, sg2d, (TexturePaint)paint, useMask); break; default: break; } } }
Example #23
Source File: RenderTests.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private RadialGradientPaint makeRadial(int numColors, boolean alpha) { float interval = 1.0f / (numColors - 1); float[] fractions = new float[numColors]; for (int i = 0; i < fractions.length; i++) { fractions[i] = i * interval; } Color[] colors = makeGradientColors(numColors, alpha); return new RadialGradientPaint(0.0f, 0.0f, 10.0f, fractions, colors, CycleMethod.REFLECT); }
Example #24
Source File: PaintAlpha.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Create a new (if possible, darker) <code>Paint</code> of the same Type. * If the Type is not supported, the original <code>Paint</code> is returned. * <p> * @param paint a <code>Paint</code> implementation * (e.g. {@link Color}, {@link GradientPaint}, {@link TexturePaint},..) * <p> * @return a (usually new, see above) <code>Paint</code> */ public static Paint darker(Paint paint) { if (paint instanceof Color) { return darker((Color) paint); } if (legacyAlpha == true) { /* * Legacy? Just return the original Paint. * (this corresponds EXACTLY to how Paints used to be darkened) */ return paint; } if (paint instanceof GradientPaint) { return darker((GradientPaint) paint); } if (paint instanceof LinearGradientPaint) { return darkerLinearGradientPaint((LinearGradientPaint) paint); } if (paint instanceof RadialGradientPaint) { return darkerRadialGradientPaint((RadialGradientPaint) paint); } if (paint instanceof TexturePaint) { try { return darkerTexturePaint((TexturePaint) paint); } catch (Exception e) { /* * Lots can go wrong while fiddling with Images, Color Models * & such! If anything at all goes awry, just return the original * TexturePaint. (TexturePaint's are immutable anyway, so no harm * done) */ return paint; } } return paint; }
Example #25
Source File: TransformedPaintTest.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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; }
Example #26
Source File: TransformedPaintTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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; }
Example #27
Source File: ReadingInterruptionTest.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static void createTestFile() { int w = 1280; int h = 1024; 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(); 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); } }
Example #28
Source File: LinearBargraph.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public LinearBargraph() { super(); barGraphColor = getModel().getValueColor(); LED_FRACTIONS = new float[]{ 0.0f, 1.0f }; LED_INACTIVE_COLORS = new Color[]{ new Color(60, 60, 60, 255), new Color(50, 50, 50, 255) }; sectionGradients = new java.util.HashMap<Section, RadialGradientPaint>(4); sectionOffsets = new java.util.HashMap<Section, Point2D>(4); // The value background VALUE_BACKGROUND_TRACK = new Rectangle2D.Double(0, 0, 10, 10); VALUE_BACKGROUND_VERTICAL_START = new Point2D.Double(0, 0); VALUE_BACKGROUND_VERTICAL_STOP = new Point2D.Double(0, 0); VALUE_BACKGROUND_TRACK_FRACTIONS = new float[]{ 0.0f, 0.48f, 0.49f, 1.0f }; // Value track border VALUE_LEFT_BORDER = new Rectangle2D.Double(0, 0, 10, 10); VALUE_RIGHT_BORDER = new Rectangle2D.Double(0, 0, 10, 10); VALUE_BORDER_START = new Point2D.Double(0, 0); VALUE_BORDER_STOP = new Point2D.Double(0, 0); VALUE_BORDER_FRACTIONS = new float[]{ 0.0f, 0.48f, 0.49f, 1.0f }; prepareBargraph(getInnerBounds().width, getInnerBounds().height); init(getInnerBounds().width, getInnerBounds().height); }
Example #29
Source File: java_awt_RadialGradientPaint.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
protected RadialGradientPaint getAnotherObject() { return null; /* TODO: could not update property float[] f = { 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f }; Color[] c = { Color.RED, Color.GREEN, Color.BLUE, Color.RED, Color.GREEN, Color.BLUE }; return new RadialGradientPaint( new Point2D.Float(f[0], f[1]), 100.0f, new Point2D.Float(f[2], f[3]), f, c, REFLECT, LINEAR_RGB, new AffineTransform(f));*/ }
Example #30
Source File: ConcurrentReadingTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void createTestFile() { int w = 1280; int h = 1024; 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(); 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); } }