Package java.awt

Examples of java.awt.GradientPaint


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

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


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

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

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

    public void testGetCyclic() {
        gp = new GradientPaint(1, 2, Color.green, 3, 4, Color.blue, true);
        assertTrue(gp.isCyclic());
        gp = new GradientPaint(1, 2, Color.green, 3, 4, Color.blue, false);
        assertFalse(gp.isCyclic());
    }
View Full Code Here

    * Graphics2D object.
    */
    private static void applyCurrentGradientPaint(Graphics2D graphics,
        int width, int height, Color startingColor, Color endingColor) {

    GradientPaint gradientPaint = new GradientPaint(0, 0, startingColor,
        width, height, endingColor);

    graphics.setPaint(gradientPaint);
    }
View Full Code Here

    {
      final int heigthIncrement = getHeight() / (gradientColors.length - 1);

      for (int i = 0; i < gradientColors.length - 1; i++)
      {
        final GradientPaint gradientPaint = new GradientPaint(new Point2D.Double(0, heigthIncrement * i),
            gradientColors[i], new Point2D.Double(0, (i + 1) * heigthIncrement), gradientColors[i + 1]);
        graphics2D.setPaint(gradientPaint);
        graphics2D.fillRect(0, i * heigthIncrement, getWidth(), heigthIncrement);
      }
    }
    else if (direction == Direction.DIRECTION_UP)
    {
      final int heigthIncrement = getHeight() / (gradientColors.length - 1);

      for (int i = 0; i < gradientColors.length - 1; i++)
      {
        final Color gc1 = gradientColors[gradientColors.length - i - 1];
        final Color gc2 = gradientColors[gradientColors.length - i - 2];
        final GradientPaint gradientPaint = new GradientPaint(new Point2D.Double(0, heigthIncrement * i), gc1,
            new Point2D.Double(0, (i + 1) * heigthIncrement), gc2);
        graphics2D.setPaint(gradientPaint);
        graphics2D.fillRect(0, i * heigthIncrement, getWidth(), heigthIncrement);
      }
    }
    else if (direction == Direction.DIRECTION_LEFT)
    {
      final int widthIncrement = getWidth() / (gradientColors.length - 1);

      for (int i = 0; i < gradientColors.length - 1; i++)
      {
        final GradientPaint gradientPaint = new GradientPaint(new Point2D.Double(widthIncrement * i, 0),
            gradientColors[i], new Point2D.Double((i + 1) * widthIncrement, 0), gradientColors[i + 1]);
        graphics2D.setPaint(gradientPaint);
        graphics2D.fillRect(i * widthIncrement, 0, widthIncrement, getHeight());
      }
    }
View Full Code Here

      int b = 40;
      if (rollover)
      {
        b = 60;
      }
      final GradientPaint gp = new GradientPaint(0, o,
          new Color(Math.min(164 + b, 255), Math.min(166 + b, 255), Math.min(172 + b, 255)), 0, h + o,
          new Color(Math.min(189 + b, 255), Math.min(192 + b, 255), Math.min(198 + b, 255)), true);
      g.setPaint(gp);
    }
    else
    {
      final int o = -5;
      int b = 0;
      if (rollover)
      {
        b = 60;
      }
      final GradientPaint gp = new GradientPaint(0, o,
          new Color(Math.min(251 + b, 255), Math.min(251 + b, 255), Math.min(252 + b, 255)), 0, h + o,
          new Color(Math.min(215 + b, 255), Math.min(218 + b, 255), Math.min(224 + b, 255)), true);
      g.setPaint(gp);
    }

    final RoundRectangle2D roundRectangle2D = new RoundRectangle2D.Double(0, 0, w - 1, h - 1, 6, 6);

    //if (!selected || rollover)
    {
      g.fill(roundRectangle2D);
    }

    if (selected)
    {
      final GradientPaint gp = new GradientPaint(0, 0,
          new Color(Math.min(125, 255), Math.min(127, 255), Math.min(131, 255)), 0, h,
          new Color(Math.min(162, 255), Math.min(164, 255), Math.min(169, 255)), true);
      g.setPaint(gp);
    }
    else
    {
      final GradientPaint gp = new GradientPaint(0, 0,
          new Color(Math.min(149, 255), Math.min(155, 255), Math.min(158, 255)), 0, h,
          new Color(Math.min(85, 255), Math.min(88, 255), Math.min(94, 255)), true);
      g.setPaint(gp);
    }
View Full Code Here

   * @param stream the outputstream that should receive the object.
   * @throws IOException if an I/O error occured.
   */
  public void writeObject(final Object o, final ObjectOutputStream stream) throws IOException
  {
    final GradientPaint gp = (GradientPaint) o;
    final Point2D point2D1 = gp.getPoint1();
    stream.writeFloat((float) point2D1.getX());
    stream.writeFloat((float) point2D1.getY());
    stream.writeObject(gp.getColor1());
    final Point2D point2D = gp.getPoint2();
    stream.writeFloat((float) point2D.getX());
    stream.writeFloat((float) point2D.getY());
    stream.writeObject(gp.getColor2());
    stream.writeBoolean(gp.isCyclic());
  }
View Full Code Here

    final Color c1 = (Color) stream.readObject();
    final float x2 = stream.readFloat();
    final float y2 = stream.readFloat();
    final Color c2 = (Color) stream.readObject();
    final boolean isCyclic = stream.readBoolean();
    return new GradientPaint(x1, y1, c1, x2, y2, c2, isCyclic);
  }
View Full Code Here

        cb.setColorStroke(color);
      }
    }
    else if (paint instanceof GradientPaint)
    {
      final GradientPaint gp = (GradientPaint) paint;
      final Point2D p1 = gp.getPoint1();
      transform.transform(p1, p1);
      final Point2D p2 = gp.getPoint2();
      transform.transform(p2, p2);
      final Color c1 = gp.getColor1();
      final Color c2 = gp.getColor2();
      final PdfShading shading = PdfShading.simpleAxial(cb.getPdfWriter(), (float) p1.getX(), normalizeY(
          (float) p1.getY()), (float) p2.getX(), normalizeY((float) p2.getY()), c1, c2);
      final PdfShadingPattern pat = new PdfShadingPattern(shading);
      if (fill)
      {
View Full Code Here

    int padding = 3;
    g2d.setColor(Color.black);
    g2d.setStroke(new BasicStroke());
    g2d.draw(new Rectangle2D.Double(xpos, ypos - width / 2 - padding, chartWidth, width + 2 * padding));

    GradientPaint verlauf = new GradientPaint(xpos - length / 2, ypos, Color.white, xpos + length, ypos, col);
    g2d.setPaint(verlauf);
    g2d.fill(new Rectangle2D.Double(xpos + padding, ypos - width / 2, length - 2 * padding, width + 1));

  }
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.