Package java.awt

Examples of java.awt.GradientPaint


        curveShape.lineTo(0, h);
        curveShape.lineTo(0, h * .8f);
        curveShape.closePath();

        // draw into the buffer a gradient (bottom to top), and the text "Login"
        GradientPaint gp = new GradientPaint(0, h, UIManager
                .getColor("JXLoginPane.banner.darkBackground"), 0, 0, UIManager
                .getColor("JXLoginPane.banner.lightBackground"));
        g2.setPaint(gp);
        g2.fill(curveShape);
        Image image = (Image) UIManager.get("JXLoginPane.banner.image");
View Full Code Here


  @Override
  protected void paintComponent(Graphics g)
  {
    int w = getWidth();
    int h = getHeight();
    GradientPaint gp;
    width(w);

    // Gradient fill panel
    if (online())
      gp = new GradientPaint(50, 0, topleft_online, 140, h,
          bottomright_online);
    else
      gp = new GradientPaint(130, 0, topleft_offline, 140, h,
          bottomright_offline);

    ((Graphics2D) g).setPaint(gp);
    g.fillRect(0, 0, w, h);
View Full Code Here

        if (paint instanceof Color) {
            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'.
View Full Code Here

  return getDimensions(null, restoreData(resourceContext));
    }

    private void drawGradient(Graphics2D g2d, Rectangle2D rectangle, BiColor colors, int height) {
  if (colors != null) {
      GradientPaint gragient = new GradientPaint(0, 0, colors.getTopColor(), 0, height, colors.getBottomColor());
      g2d.setPaint(gragient);
      g2d.fill(rectangle);
  }
    }
View Full Code Here

     * @return The transformed paint.
     */
    public GradientPaint transform(final GradientPaint paint,
                                   final Shape target) {
       
        GradientPaint result = paint;
        final Rectangle2D bounds = target.getBounds2D();
       
        if (this.type.equals(GradientPaintTransformType.VERTICAL)) {
            result = new GradientPaint(
                (float) bounds.getCenterX(), (float) bounds.getMinY(),
                paint.getColor1(), (float) bounds.getCenterX(),
                (float) bounds.getMaxY(), paint.getColor2()   
            );
        }
        else if (this.type.equals(GradientPaintTransformType.HORIZONTAL)) {
            result = new GradientPaint(
                (float) bounds.getMinX(), (float) bounds.getCenterY(),
                paint.getColor1(), (float) bounds.getMaxX(),
                (float) bounds.getCenterY(), paint.getColor2()   
            );           
        }
        else if (this.type.equals(GradientPaintTransformType.CENTER_HORIZONTAL))
        {
            result = new GradientPaint(
                (float) bounds.getCenterX(), (float) bounds.getCenterY(),
                paint.getColor1(), (float) bounds.getMaxX(),
                (float) bounds.getCenterY(), paint.getColor2(), true
            );           
        }
        else if (this.type.equals(GradientPaintTransformType.CENTER_VERTICAL)) {
            result = new GradientPaint(
                (float) bounds.getCenterX(), (float) bounds.getMinY(),
                paint.getColor1(), (float) bounds.getCenterX(),
                (float) bounds.getCenterY(), paint.getColor2(), true
            );           
        }
View Full Code Here

        // disable bar outlines...
        BarRenderer renderer = (BarRenderer) plot.getRenderer();
        // renderer.setDrawBarOutline(false);

        // set up gradient paints for series...
        GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f,
                0.0f, new Color(0, 0, 64));
        GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f,
                0.0f, new Color(0, 64, 0));
        GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f,
                0.0f, new Color(64, 0, 0));
        renderer.setSeriesPaint(0, gp0);
        renderer.setSeriesPaint(1, gp1);
        renderer.setSeriesPaint(2, gp2);
View Full Code Here

            setColor((Color)paint);
        } else {
            this.paint = paint;
            nativeBrush = false;
            if (paint instanceof GradientPaint) {
                GradientPaint p = (GradientPaint)paint;
                if (!p.isCyclic()) {
                    return;
                }
                Color c1 = p.getColor1();
                Color c2 = p.getColor2();
                Point2D p1 = transform.transform(p.getPoint1(), null);
                Point2D p2 = transform.transform(p.getPoint2(), null);
                setLinearGradientBrush(gi, (int)Math.round(p1.getX()), (int)Math.round(p1.getY()), c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha(),
                                           (int)Math.round(p2.getX()), (int)Math.round(p2.getY()), c2.getRed(), c2.getGreen(), c2.getBlue(), c2.getAlpha(), p.isCyclic());
                nativeBrush = true;
            }
            setStroke(getStroke());
        }
    }
View Full Code Here

    GradientPaint gp;

    public void testContructorBad() {
        // Regression for HARMONY-1470
        try {
            new GradientPaint(1, 2, null, 3, 4, new Color(255), false);
            fail("expected NPE");
        } catch (NullPointerException e) {
            // expected
        }
        try {
            new GradientPaint(1, 2, new Color(255), 3, 4, null, false);
            fail("expected NPE");
        } catch (NullPointerException e) {
            // expected
        }
        try {
            new GradientPaint(1, 2, null, 4, 5, new Color(255));
            fail("expected NPE");
        } catch (NullPointerException e) {
            // expected
        }
        try {
            new GradientPaint(1, 2, new Color(255), 4, 5, null);
            fail("expected NPE");
        } catch (NullPointerException e) {
            // expected
        }
        try {
            new GradientPaint(null, new Color(255), new Point2D.Float(),
                    new Color(255));
            fail("expected NPE");
        } catch (NullPointerException e) {
            // expected
        }
        try {
            new GradientPaint(new Point2D.Float(), null, new Point2D.Float(),
                    new Color(255));
            fail("expected NPE");
        } catch (NullPointerException e) {
            // expected
        }
        try {
            new GradientPaint(new Point2D.Float(), new Color(255), null,
                    new Color(255));
            fail("expected NPE");
        } catch (NullPointerException e) {
            // expected
        }
        try {
            new GradientPaint(new Point2D.Float(), new Color(255),
                    new Point2D.Float(), null);
            fail("expected NPE");
        } catch (NullPointerException e) {
            // expected
        }
View Full Code Here

            // expected
        }
    }

    public void testGetPoint1() {
        gp = new GradientPaint(1, 2, Color.green, 3, 4, Color.blue, true);
        assertEquals(new Point2D.Float(1, 2), gp.getPoint1());
    }
View Full Code Here

        gp = new GradientPaint(1, 2, Color.green, 3, 4, Color.blue, true);
        assertEquals(new Point2D.Float(1, 2), gp.getPoint1());
    }

    public void testGetPoint2() {
        gp = new GradientPaint(1, 2, Color.green, 3, 4, Color.blue, true);
        assertEquals(new Point2D.Float(3, 4), gp.getPoint2());
    }
View Full Code Here

TOP

Related Classes of java.awt.GradientPaint

Copyright © 2018 www.massapicom. 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.