Examples of LinearGradientPaint


Examples of java.awt.LinearGradientPaint

    private static class LinearGradient extends MultiGradient {
        private LinearGradient() {}

        @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;
            }
View Full Code Here

Examples of java.awt.LinearGradientPaint

            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),
 
View Full Code Here

Examples of java.awt.LinearGradientPaint

    private static class LinearGradient extends MultiGradient {
        private LinearGradient() {}

        @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)) {
View Full Code Here

Examples of java.awt.LinearGradientPaint

    for (int i = 0; i < cnt; i++) {
      fractions[i] = ((Number) params.get(4 + i * 2)).floatValue();
      colors[i] = (Color) params.get(5 + i * 2);
    }

    return new LinearGradientPaint(x1, y1, x2, y2, fractions, colors);
  }
View Full Code Here

Examples of java.awt.LinearGradientPaint

  public static Paint buildPaint(Paint p, double x, double y, double w, double h) {
    if (p instanceof Color) return p;

    if (p instanceof LinearGradientPaint) {
      LinearGradientPaint gp = (LinearGradientPaint) p;
      double x1 = gp.getStartPoint().getX() * w + x;
      double y1 = gp.getStartPoint().getY() * h + y;
      double x2 = gp.getEndPoint().getX() * w + x;
      double y2 = gp.getEndPoint().getY() * h + y;
      return new LinearGradientPaint(new Point2D.Double(x1, y1), new Point2D.Double(x2, y2), gp.getFractions(), gp.getColors());
    }

    assert false;
    return null;
  }
View Full Code Here

Examples of java.awt.LinearGradientPaint

                    Color color = decodeColor(JSON.getString(stop, COLOR_KEY));
                    colors[i] = color;
                }

                paint = new LinearGradientPaint(startX, startY, endX, endY, fractions, colors);
                break;
            }

            case RADIAL_GRADIENT: {
                float centerX = JSON.getFloat(dictionary, CENTER_X_KEY);
View Full Code Here

Examples of java.awt.LinearGradientPaint

              .getUltraLightColor()
              : scheme.getLightColor();
          Color rightColor = ((fillKind == MenuGutterFillKind.SOFT_FILL) || (fillKind == MenuGutterFillKind.SOFT)) ? scheme
              .getUltraLightColor()
              : scheme.getLightColor();
          LinearGradientPaint gp = new LinearGradientPaint(0, 0,
              textOffset, 0, new float[] { 0.0f, 1.0f },
              new Color[] { leftColor, rightColor },
              CycleMethod.REPEAT);
          graphics.setComposite(LafWidgetUtilities.getAlphaComposite(
              menuItem, 0.7f, g));

          // System.out.println(menuItem.getText()
          // + "["
          // + menuItem.isEnabled()
          // + "] : "
          // + ((AlphaComposite) graphics.getComposite())
          // .getAlpha() + ", " + leftColor + "->"
          // + rightColor);
          //
          graphics.setPaint(gp);
          graphics.fillRect(0, 0, textOffset - 2, menuHeight);
        }
      } else {
        // fix for defect 125 - support of RTL menus
        MenuGutterFillKind fillKind = SubstanceCoreUtilities
            .getMenuGutterFillKind();
        if (fillKind != MenuGutterFillKind.NONE) {
          SubstanceColorScheme scheme = SubstanceColorSchemeUtilities
              .getColorScheme(menuItem, ComponentState.ENABLED);
          Color leftColor = ((fillKind == MenuGutterFillKind.HARD_FILL) || (fillKind == MenuGutterFillKind.HARD)) ? scheme
              .getLightColor()
              : scheme.getUltraLightColor();
          Color rightColor = ((fillKind == MenuGutterFillKind.HARD_FILL) || (fillKind == MenuGutterFillKind.SOFT)) ? scheme
              .getLightColor()
              : scheme.getUltraLightColor();

          LinearGradientPaint gp = new LinearGradientPaint(
              textOffset, 0, menuWidth, 0, new float[] { 0.0f,
                  1.0f },
              new Color[] { leftColor, rightColor },
              CycleMethod.REPEAT);
          graphics.setComposite(LafWidgetUtilities.getAlphaComposite(
View Full Code Here

Examples of org.apache.batik.ext.awt.LinearGradientPaint

  // as a single color using the color and opacity of the last gradient
  // stop.
        if (p1.getX() == p2.getX() && p1.getY() == p2.getY()) {
            return colors[colors.length-1];
  } else {
      return new LinearGradientPaint(p1,
             p2,
             offsets,
             colors,
             spreadMethod,
             colorSpace,
View Full Code Here

Examples of org.apache.batik.ext.awt.LinearGradientPaint

            return true;
        }
        // convert java.awt.GradientPaint to LinearGradientPaint to avoid rasterization
        if (paint instanceof GradientPaint) {
            GradientPaint gpaint = (GradientPaint) paint;
            paint = new LinearGradientPaint(
                    (float) gpaint.getPoint1().getX(),
                    (float) gpaint.getPoint1().getY(),
                    (float) gpaint.getPoint2().getX(),
                    (float) gpaint.getPoint2().getY(),
                    new float[] {0, 1},
                    new Color[] {gpaint.getColor1(), gpaint.getColor2()},
                    gpaint.isCyclic() ? LinearGradientPaint.REPEAT : LinearGradientPaint.NO_CYCLE);
        }
        if (paint instanceof LinearGradientPaint) {
            LinearGradientPaint gp = (LinearGradientPaint)paint;

            // This code currently doesn't support 'repeat'.
            // For linear gradients it is possible to construct
            // a 'tile' that is repeated with a PDF pattern, but
            // it would be very tricky as you would have to rotate
            // the coordinate system so the repeat was axially
            // aligned.  At this point I'm just going to rasterize it.
            MultipleGradientPaint.CycleMethodEnum cycle = gp.getCycleMethod();
            if (cycle != MultipleGradientPaint.NO_CYCLE) {
                return false;
            }

            Color[] cols = gp.getColors();
            float[] fractions = gp.getFractions();

            // Build proper transform from gradient space to page space
            // ('Patterns' don't get userspace transform).
            AffineTransform transform;
            transform = new AffineTransform(getBaseTransform());
            transform.concatenate(getTransform());
            transform.concatenate(gp.getTransform());

            List theMatrix = new java.util.ArrayList();
            double [] mat = new double[6];
            transform.getMatrix(mat);
            for (int idx = 0; idx < mat.length; idx++) {
                theMatrix.add(new Double(mat[idx]));
            }

            Point2D p1 = gp.getStartPoint();
            Point2D p2 = gp.getEndPoint();
            List theCoords = new java.util.ArrayList();
            theCoords.add(new Double(p1.getX()));
            theCoords.add(new Double(p1.getY()));
            theCoords.add(new Double(p2.getX()));
            theCoords.add(new Double(p2.getY()));
View Full Code Here

Examples of org.apache.batik.ext.awt.LinearGradientPaint

  // as a single color using the color and opacity of the last gradient
  // stop.
        if (p1.getX() == p2.getX() && p1.getY() == p2.getY()) {
            return colors[colors.length-1];
  } else {
      return new LinearGradientPaint(p1,
             p2,
             offsets,
             colors,
             spreadMethod,
             colorSpace,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.