Package java.awt

Examples of java.awt.TexturePaint


    if(verticalGradients==null) {
      verticalGradients = new Hashtable<String, TexturePaint>();
    }
   
    String key = name+" "+height+" "+y;
    TexturePaint paint = verticalGradients.get(key);
    if(paint==null) {
      height = Math.max(height, 1); //before a component is laid out, it may be 0x0
      BufferedImage bi = new BufferedImage(1,height,BufferedImage.TYPE_INT_ARGB);
      int[] array = new int[height];
      for(int a = 0; a<array.length; a++) {
        float f = a;
        f = f/((array.length-1));
        boolean hit = false;
        findMatch : for(int b = 1; b<positions.length; b++) {
          if(f>=positions[b-1] && f<positions[b]) {
            float p = (f-positions[b-1])/(positions[b]-positions[b-1]);
            array[a] = tween(colors[b-1],colors[b],p).getRGB();
            hit = true;
            break findMatch;
          }
        }
        if(!hit)
          array[a] = colors[colors.length-1].getRGB();
      }
      bi.getRaster().setDataElements(0, 0, 1, height, array);
      paint = new TexturePaint( bi, new Rectangle(0,y,1,height) );
      verticalGradients.put(key,paint);
    }
    return paint;
  }
View Full Code Here


      g.setColor(Color.white);
      g.fillRect(0,0,2*t,2*t);
      g.setColor(Color.lightGray);
      g.fillRect(0,0,t,t);
      g.fillRect(t,t,t,t);
      checkerPaint = new TexturePaint(bi,new Rectangle(0,0,bi.getWidth(),bi.getHeight()));
    }
    return checkerPaint;
  }
View Full Code Here

    int w2 = Math.min(getWidth(), w);
    int h2 = Math.min(getHeight(), w);
    Rectangle r = new Rectangle(getWidth()/2-w2/2,getHeight()/2-h2/2, w2, h2);
   
    if(c.getAlpha()<255) {
      TexturePaint checkers = getCheckerPaint();
      g.setPaint(checkers);
      g.fillRect(r.x, r.y, r.width, r.height);
    }
    g.setColor(c);
    g.fillRect(r.x, r.y, r.width, r.height);
View Full Code Here

  }
  public static TexturePaint getCheckerBoard(int checkerSize,Color color1,Color color2) {
    String key = checkerSize+" "+color1.toString()+" "+color2.toString();
    if(checkers==null)
      checkers = new Hashtable<String, TexturePaint>();
    TexturePaint paint = checkers.get(key);
    if(paint==null) {
      BufferedImage bi = new BufferedImage(2*checkerSize, 2*checkerSize, BufferedImage.TYPE_INT_RGB);
      Graphics2D g = bi.createGraphics();
      g.setColor(color1);
      g.fillRect(0,0,2*checkerSize,2*checkerSize);
      g.setColor(color2);
      g.fillRect(0,0,checkerSize,checkerSize);
      g.fillRect(checkerSize,checkerSize,checkerSize,checkerSize);
      g.dispose();
      paint = new TexturePaint(bi,new Rectangle(0,0,bi.getWidth(),bi.getHeight()));
      checkers.put(key, paint);
    }
    return paint;
  }
View Full Code Here

    Graphics2D g2 = (Graphics2D) g;

    // Create a texture paint from the buffered image
    Rectangle r = new Rectangle(0, 0, background.getWidth(),
        background.getHeight());
    TexturePaint tp = new TexturePaint(background, r);

    // Add the texture paint to the graphics context.
    g2.setPaint(tp);

    // Create and render a rectangle filled with the texture.
View Full Code Here

            else
                cb.setShadingStroke(pat);
        }
        else if (paint instanceof TexturePaint) {
            try {
                TexturePaint tp = (TexturePaint)paint;
                BufferedImage img = tp.getImage();
                Rectangle2D rect = tp.getAnchorRect();
                com.lowagie.text.LwgImage image = com.lowagie.text.LwgImage.getInstance(img, null);
                PdfPatternPainter pattern = cb.createPattern(image.getWidth(), image.getHeight());
                AffineTransform inverse = this.normalizeMatrix();
                inverse.translate(rect.getX(), rect.getY());
                inverse.scale(rect.getWidth() / image.getWidth(), -rect.getHeight() / image.getHeight());
View Full Code Here

                        (int) sqlength - 1, (int) sqlength - 1);
            } finally {
            gfx.dispose();
            }
           
            checkerPaint = new TexturePaint(image, new Rectangle(0, 0, image.getWidth(), image.getHeight()));
        }
        return checkerPaint;
    }
View Full Code Here

                    } else {
                        area.intersect(new Area(new Rectangle(0, rect.y, width, rect.height)));
                        g.setClip(area);
                    }
                   
                    TexturePaint tp = new TexturePaint(img, rect);
                    g.setPaint(tp);
                    g.fillRect(0,0,width,height);
                    g.setClip(oldClip);
                } else {
                    if(scaleToFit) {
View Full Code Here

       
    if( vertical ) {
      GUIUtil.constrainWidth( this, width );
      imgActive = new BufferedImage( pntExtent, 1, BufferedImage.TYPE_INT_ARGB );
      imgActive.setRGB( 0, 0, pntExtent, 1, bgPixels, 0, pntExtent );
      pntActive = new TexturePaint( imgActive, new Rectangle( 0, 0, pntExtent, 1 ));
    } else {
      GUIUtil.constrainHeight( this, width );
      imgActive = new BufferedImage( 1, pntExtent, BufferedImage.TYPE_INT_ARGB );
      imgActive.setRGB( 0, 0, 1, pntExtent, bgPixels, 0, 1 );
      pntActive = new TexturePaint( imgActive, new Rectangle( 0, 0, 1, pntExtent ));
    }
   
    if( small ) {
      setFont( new Font( "Lucida Grande", Font.PLAIN, 11 ));
    }
View Full Code Here

    synchronized( sync )
    {
      if( pntBackground == null ) {
        final BufferedImage img = new BufferedImage( 4, 4, BufferedImage.TYPE_INT_ARGB );
        img.setRGB( 0, 0, 4, 4, pntBgAquaPixels, 0, 4 );
        pntBackground = new TexturePaint( img, new Rectangle( 0, 0, 4, 4 ));
      }
    }
   
    setOpaque( true );
    setDoubleBuffered( false );
View Full Code Here

TOP

Related Classes of java.awt.TexturePaint

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.