Java Code Examples for java.awt.LinearGradientPaint#getFractions()
The following examples show how to use
java.awt.LinearGradientPaint#getFractions() .
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: D3DPaints.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Override boolean isPaintValid(SunGraphics2D sg2d) { LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint; if (paint.getFractions().length == 2 && paint.getCycleMethod() != CycleMethod.REPEAT && paint.getColorSpace() != ColorSpaceType.LINEAR_RGB) { D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData; D3DGraphicsDevice gd = (D3DGraphicsDevice) dstData.getDeviceConfiguration().getDevice(); if (gd.isCapPresent(CAPS_LCD_SHADER)) { // we can delegate to the optimized two-color gradient // codepath, which should be faster return true; } } return super.isPaintValid(sg2d); }
Example 2
Source File: D3DPaints.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Override boolean isPaintValid(SunGraphics2D sg2d) { LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint; if (paint.getFractions().length == 2 && paint.getCycleMethod() != CycleMethod.REPEAT && paint.getColorSpace() != ColorSpaceType.LINEAR_RGB) { D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData; D3DGraphicsDevice gd = (D3DGraphicsDevice) dstData.getDeviceConfiguration().getDevice(); if (gd.isCapPresent(CAPS_LCD_SHADER)) { // we can delegate to the optimized two-color gradient // codepath, which should be faster return true; } } return super.isPaintValid(sg2d); }
Example 3
Source File: D3DPaints.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override boolean isPaintValid(SunGraphics2D sg2d) { LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint; if (paint.getFractions().length == 2 && paint.getCycleMethod() != CycleMethod.REPEAT && paint.getColorSpace() != ColorSpaceType.LINEAR_RGB) { D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData; D3DGraphicsDevice gd = (D3DGraphicsDevice) dstData.getDeviceConfiguration().getDevice(); if (gd.isCapPresent(CAPS_LCD_SHADER)) { // we can delegate to the optimized two-color gradient // codepath, which should be faster return true; } } return super.isPaintValid(sg2d); }
Example 4
Source File: D3DPaints.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override boolean isPaintValid(SunGraphics2D sg2d) { LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint; if (paint.getFractions().length == 2 && paint.getCycleMethod() != CycleMethod.REPEAT && paint.getColorSpace() != ColorSpaceType.LINEAR_RGB) { D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData; D3DGraphicsDevice gd = (D3DGraphicsDevice) dstData.getDeviceConfiguration().getDevice(); if (gd.isCapPresent(CAPS_LCD_SHADER)) { // we can delegate to the optimized two-color gradient // codepath, which should be faster return true; } } return super.isPaintValid(sg2d); }
Example 5
Source File: D3DPaints.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override boolean isPaintValid(SunGraphics2D sg2d) { LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint; if (paint.getFractions().length == 2 && paint.getCycleMethod() != CycleMethod.REPEAT && paint.getColorSpace() != ColorSpaceType.LINEAR_RGB) { D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData; D3DGraphicsDevice gd = (D3DGraphicsDevice) dstData.getDeviceConfiguration().getDevice(); if (gd.isCapPresent(CAPS_LCD_SHADER)) { // we can delegate to the optimized two-color gradient // codepath, which should be faster return true; } } return super.isPaintValid(sg2d); }
Example 6
Source File: D3DPaints.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override boolean isPaintValid(SunGraphics2D sg2d) { LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint; if (paint.getFractions().length == 2 && paint.getCycleMethod() != CycleMethod.REPEAT && paint.getColorSpace() != ColorSpaceType.LINEAR_RGB) { D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData; D3DGraphicsDevice gd = (D3DGraphicsDevice) dstData.getDeviceConfiguration().getDevice(); if (gd.isCapPresent(CAPS_LCD_SHADER)) { // we can delegate to the optimized two-color gradient // codepath, which should be faster return true; } } return super.isPaintValid(sg2d); }
Example 7
Source File: CustomLegendGraphic.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
private static LinearGradientPaint getTranslatedLinearGradientPaint(LinearGradientPaint gradient, Point2D startPoint, Point2D endPoint, boolean vertical) { if (vertical) { return new LinearGradientPaint(0f, (float) startPoint.getY(), 0f, (float) endPoint.getY(), gradient.getFractions(), gradient.getColors()); } else { return new LinearGradientPaint((float) startPoint.getX(), 0f, (float) endPoint.getX(), 0f, gradient.getFractions(), gradient.getColors()); } }
Example 8
Source File: OGLPaints.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override boolean isPaintValid(SunGraphics2D sg2d) { LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint; if (paint.getFractions().length == 2 && paint.getCycleMethod() != CycleMethod.REPEAT && paint.getColorSpace() != ColorSpaceType.LINEAR_RGB) { // we can delegate to the optimized two-color gradient // codepath, which does not require fragment shader support return true; } return super.isPaintValid(sg2d); }
Example 9
Source File: OGLPaints.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override boolean isPaintValid(SunGraphics2D sg2d) { LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint; if (paint.getFractions().length == 2 && paint.getCycleMethod() != CycleMethod.REPEAT && paint.getColorSpace() != ColorSpaceType.LINEAR_RGB) { // we can delegate to the optimized two-color gradient // codepath, which does not require fragment shader support return true; } return super.isPaintValid(sg2d); }
Example 10
Source File: OGLPaints.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override boolean isPaintValid(SunGraphics2D sg2d) { LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint; if (paint.getFractions().length == 2 && paint.getCycleMethod() != CycleMethod.REPEAT && paint.getColorSpace() != ColorSpaceType.LINEAR_RGB) { // we can delegate to the optimized two-color gradient // codepath, which does not require fragment shader support return true; } return super.isPaintValid(sg2d); }
Example 11
Source File: OGLPaints.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override boolean isPaintValid(SunGraphics2D sg2d) { LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint; if (paint.getFractions().length == 2 && paint.getCycleMethod() != CycleMethod.REPEAT && paint.getColorSpace() != ColorSpaceType.LINEAR_RGB) { // we can delegate to the optimized two-color gradient // codepath, which does not require fragment shader support return true; } return super.isPaintValid(sg2d); }
Example 12
Source File: OGLPaints.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override boolean isPaintValid(SunGraphics2D sg2d) { LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint; if (paint.getFractions().length == 2 && paint.getCycleMethod() != CycleMethod.REPEAT && paint.getColorSpace() != ColorSpaceType.LINEAR_RGB) { // we can delegate to the optimized two-color gradient // codepath, which does not require fragment shader support return true; } return super.isPaintValid(sg2d); }
Example 13
Source File: OGLPaints.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override boolean isPaintValid(SunGraphics2D sg2d) { LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint; if (paint.getFractions().length == 2 && paint.getCycleMethod() != CycleMethod.REPEAT && paint.getColorSpace() != ColorSpaceType.LINEAR_RGB) { // we can delegate to the optimized two-color gradient // codepath, which does not require fragment shader support return true; } return super.isPaintValid(sg2d); }
Example 14
Source File: OGLPaints.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override boolean isPaintValid(SunGraphics2D sg2d) { LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint; if (paint.getFractions().length == 2 && paint.getCycleMethod() != CycleMethod.REPEAT && paint.getColorSpace() != ColorSpaceType.LINEAR_RGB) { // we can delegate to the optimized two-color gradient // codepath, which does not require fragment shader support return true; } return super.isPaintValid(sg2d); }
Example 15
Source File: OGLPaints.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Override boolean isPaintValid(SunGraphics2D sg2d) { LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint; if (paint.getFractions().length == 2 && paint.getCycleMethod() != CycleMethod.REPEAT && paint.getColorSpace() != ColorSpaceType.LINEAR_RGB) { // we can delegate to the optimized two-color gradient // codepath, which does not require fragment shader support return true; } return super.isPaintValid(sg2d); }
Example 16
Source File: OGLPaints.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override boolean isPaintValid(SunGraphics2D sg2d) { LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint; if (paint.getFractions().length == 2 && paint.getCycleMethod() != CycleMethod.REPEAT && paint.getColorSpace() != ColorSpaceType.LINEAR_RGB) { // we can delegate to the optimized two-color gradient // codepath, which does not require fragment shader support return true; } return super.isPaintValid(sg2d); }
Example 17
Source File: OGLPaints.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override boolean isPaintValid(SunGraphics2D sg2d) { LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint; if (paint.getFractions().length == 2 && paint.getCycleMethod() != CycleMethod.REPEAT && paint.getColorSpace() != ColorSpaceType.LINEAR_RGB) { // we can delegate to the optimized two-color gradient // codepath, which does not require fragment shader support return true; } return super.isPaintValid(sg2d); }
Example 18
Source File: BufferedPaints.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * This method uses techniques that are nearly identical to those * employed in setGradientPaint() above. The primary difference * is that at the native level we use a fragment shader to manually * apply the plane equation constants to the current fragment position * to calculate the gradient position in the range [0,1] (the native * code for GradientPaint does the same, except that it uses OpenGL's * automatic texture coordinate generation facilities). * * One other minor difference worth mentioning is that * setGradientPaint() calculates the plane equation constants * such that the gradient end points are positioned at 0.25 and 0.75 * (for reasons discussed in the comments for that method). In * contrast, for LinearGradientPaint we setup the equation constants * such that the gradient end points fall at 0.0 and 1.0. The * reason for this difference is that in the fragment shader we * have more control over how the gradient values are interpreted * (depending on the paint's CycleMethod). */ private static void setLinearGradientPaint(RenderQueue rq, SunGraphics2D sg2d, LinearGradientPaint paint, boolean useMask) { boolean linear = (paint.getColorSpace() == ColorSpaceType.LINEAR_RGB); Color[] colors = paint.getColors(); int numStops = colors.length; Point2D pt1 = paint.getStartPoint(); Point2D pt2 = paint.getEndPoint(); AffineTransform at = paint.getTransform(); at.preConcatenate(sg2d.transform); if (!linear && numStops == 2 && paint.getCycleMethod() != CycleMethod.REPEAT) { // delegate to the optimized two-color gradient codepath boolean isCyclic = (paint.getCycleMethod() != CycleMethod.NO_CYCLE); setGradientPaint(rq, at, colors[0], colors[1], pt1, pt2, isCyclic, useMask); return; } int cycleMethod = paint.getCycleMethod().ordinal(); float[] fractions = paint.getFractions(); int[] pixels = convertToIntArgbPrePixels(colors, linear); // calculate plane equation constants double x = pt1.getX(); double y = pt1.getY(); at.translate(x, y); // now gradient point 1 is at the origin x = pt2.getX() - x; y = pt2.getY() - y; double len = Math.sqrt(x * x + y * y); at.rotate(x, y); // now gradient point 2 is on the positive x-axis at.scale(len, 1); // now gradient point 1 is at (0.0, 0), point 2 is at (1.0, 0) float p0, p1, p3; try { at.invert(); p0 = (float)at.getScaleX(); p1 = (float)at.getShearX(); p3 = (float)at.getTranslateX(); } catch (java.awt.geom.NoninvertibleTransformException e) { p0 = p1 = p3 = 0.0f; } // assert rq.lock.isHeldByCurrentThread(); rq.ensureCapacity(20 + 12 + (numStops*4*2)); RenderBuffer buf = rq.getBuffer(); buf.putInt(SET_LINEAR_GRADIENT_PAINT); buf.putInt(useMask ? 1 : 0); buf.putInt(linear ? 1 : 0); buf.putInt(cycleMethod); buf.putInt(numStops); buf.putFloat(p0); buf.putFloat(p1); buf.putFloat(p3); buf.put(fractions); buf.put(pixels); }
Example 19
Source File: BufferedPaints.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
/** * This method uses techniques that are nearly identical to those * employed in setGradientPaint() above. The primary difference * is that at the native level we use a fragment shader to manually * apply the plane equation constants to the current fragment position * to calculate the gradient position in the range [0,1] (the native * code for GradientPaint does the same, except that it uses OpenGL's * automatic texture coordinate generation facilities). * * One other minor difference worth mentioning is that * setGradientPaint() calculates the plane equation constants * such that the gradient end points are positioned at 0.25 and 0.75 * (for reasons discussed in the comments for that method). In * contrast, for LinearGradientPaint we setup the equation constants * such that the gradient end points fall at 0.0 and 1.0. The * reason for this difference is that in the fragment shader we * have more control over how the gradient values are interpreted * (depending on the paint's CycleMethod). */ private static void setLinearGradientPaint(RenderQueue rq, SunGraphics2D sg2d, LinearGradientPaint paint, boolean useMask) { boolean linear = (paint.getColorSpace() == ColorSpaceType.LINEAR_RGB); Color[] colors = paint.getColors(); int numStops = colors.length; Point2D pt1 = paint.getStartPoint(); Point2D pt2 = paint.getEndPoint(); AffineTransform at = paint.getTransform(); at.preConcatenate(sg2d.transform); if (!linear && numStops == 2 && paint.getCycleMethod() != CycleMethod.REPEAT) { // delegate to the optimized two-color gradient codepath boolean isCyclic = (paint.getCycleMethod() != CycleMethod.NO_CYCLE); setGradientPaint(rq, at, colors[0], colors[1], pt1, pt2, isCyclic, useMask); return; } int cycleMethod = paint.getCycleMethod().ordinal(); float[] fractions = paint.getFractions(); int[] pixels = convertToIntArgbPrePixels(colors, linear); // calculate plane equation constants double x = pt1.getX(); double y = pt1.getY(); at.translate(x, y); // now gradient point 1 is at the origin x = pt2.getX() - x; y = pt2.getY() - y; double len = Math.sqrt(x * x + y * y); at.rotate(x, y); // now gradient point 2 is on the positive x-axis at.scale(len, 1); // now gradient point 1 is at (0.0, 0), point 2 is at (1.0, 0) float p0, p1, p3; try { at.invert(); p0 = (float)at.getScaleX(); p1 = (float)at.getShearX(); p3 = (float)at.getTranslateX(); } catch (java.awt.geom.NoninvertibleTransformException e) { p0 = p1 = p3 = 0.0f; } // assert rq.lock.isHeldByCurrentThread(); rq.ensureCapacity(20 + 12 + (numStops*4*2)); RenderBuffer buf = rq.getBuffer(); buf.putInt(SET_LINEAR_GRADIENT_PAINT); buf.putInt(useMask ? 1 : 0); buf.putInt(linear ? 1 : 0); buf.putInt(cycleMethod); buf.putInt(numStops); buf.putFloat(p0); buf.putFloat(p1); buf.putFloat(p3); buf.put(fractions); buf.put(pixels); }
Example 20
Source File: BufferedPaints.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * This method uses techniques that are nearly identical to those * employed in setGradientPaint() above. The primary difference * is that at the native level we use a fragment shader to manually * apply the plane equation constants to the current fragment position * to calculate the gradient position in the range [0,1] (the native * code for GradientPaint does the same, except that it uses OpenGL's * automatic texture coordinate generation facilities). * * One other minor difference worth mentioning is that * setGradientPaint() calculates the plane equation constants * such that the gradient end points are positioned at 0.25 and 0.75 * (for reasons discussed in the comments for that method). In * contrast, for LinearGradientPaint we setup the equation constants * such that the gradient end points fall at 0.0 and 1.0. The * reason for this difference is that in the fragment shader we * have more control over how the gradient values are interpreted * (depending on the paint's CycleMethod). */ private static void setLinearGradientPaint(RenderQueue rq, SunGraphics2D sg2d, LinearGradientPaint paint, boolean useMask) { boolean linear = (paint.getColorSpace() == ColorSpaceType.LINEAR_RGB); Color[] colors = paint.getColors(); int numStops = colors.length; Point2D pt1 = paint.getStartPoint(); Point2D pt2 = paint.getEndPoint(); AffineTransform at = paint.getTransform(); at.preConcatenate(sg2d.transform); if (!linear && numStops == 2 && paint.getCycleMethod() != CycleMethod.REPEAT) { // delegate to the optimized two-color gradient codepath boolean isCyclic = (paint.getCycleMethod() != CycleMethod.NO_CYCLE); setGradientPaint(rq, at, colors[0], colors[1], pt1, pt2, isCyclic, useMask); return; } int cycleMethod = paint.getCycleMethod().ordinal(); float[] fractions = paint.getFractions(); int[] pixels = convertToIntArgbPrePixels(colors, linear); // calculate plane equation constants double x = pt1.getX(); double y = pt1.getY(); at.translate(x, y); // now gradient point 1 is at the origin x = pt2.getX() - x; y = pt2.getY() - y; double len = Math.sqrt(x * x + y * y); at.rotate(x, y); // now gradient point 2 is on the positive x-axis at.scale(len, 1); // now gradient point 1 is at (0.0, 0), point 2 is at (1.0, 0) float p0, p1, p3; try { at.invert(); p0 = (float)at.getScaleX(); p1 = (float)at.getShearX(); p3 = (float)at.getTranslateX(); } catch (java.awt.geom.NoninvertibleTransformException e) { p0 = p1 = p3 = 0.0f; } // assert rq.lock.isHeldByCurrentThread(); rq.ensureCapacity(20 + 12 + (numStops*4*2)); RenderBuffer buf = rq.getBuffer(); buf.putInt(SET_LINEAR_GRADIENT_PAINT); buf.putInt(useMask ? 1 : 0); buf.putInt(linear ? 1 : 0); buf.putInt(cycleMethod); buf.putInt(numStops); buf.putFloat(p0); buf.putFloat(p1); buf.putFloat(p3); buf.put(fractions); buf.put(pixels); }