Package java.awt

Examples of java.awt.TexturePaint


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


    public void setFillPattern(URL fillPatternURL) {
        // This is kind of tricky. Look at the list, find out which
        // members are OMGraphic2D objects, and set the Paint for
        // those graphics.

        TexturePaint texture = null;
        try {

            if (fillPatternURL != null) {
                BufferedImage bi = BufferedImageHelper.getBufferedImage(fillPatternURL,
                        0,
                        0,
                        -1,
                        -1);
                texture = new TexturePaint(bi, new Rectangle(0, 0, bi.getWidth(), bi.getHeight()));
            }
        } catch (InterruptedException ie) {
            Debug.error("PoliticalArea.setFillPattern(): error getting texture image - \n"
                    + ie);
        }
View Full Code Here

            String texturePaintKey = "fill" + fillPaintString + fillPatternString;

            if (fillPaintString == null) {
                fillPaint = Color.black;

                TexturePaint ret = (TexturePaint) renderAttributesCache.get("fill" + fillPaint + fillPatternString);

                if (ret != null) {
                    return ret;
                } else {
                    ret = (TexturePaint) renderAttributesCache.get(texturePaintKey);

                    if (ret != null) {
                        return ret;
                    }
                }
            }

            BufferedImage bi = new BufferedImage(8, 8, BufferedImage.TYPE_INT_ARGB);
            Graphics2D big = bi.createGraphics();
            big.setColor(new Color(0, true)); // clear
            big.fillRect(0, 0, 8, 8);
            big.setPaint(fillPaint);

            if (fillPatternString.equalsIgnoreCase(LPC_HORIZONTAL_PATTERN)) {
                big.draw(new Line2D.Double(0, 0, 7, 0));
                big.draw(new Line2D.Double(0, 4, 7, 4));
            } else if (fillPatternString.equalsIgnoreCase(LPC_VERTICAL_PATTERN)) {
                big.draw(new Line2D.Double(0, 0, 0, 7));
                big.draw(new Line2D.Double(4, 0, 4, 7));
            } else if (fillPatternString.equalsIgnoreCase(LPC_CROSS_PATTERN)) {
                big.draw(new Line2D.Double(0, 0, 7, 0));
                big.draw(new Line2D.Double(0, 4, 7, 4));
                big.draw(new Line2D.Double(0, 0, 0, 7));
                big.draw(new Line2D.Double(4, 0, 4, 7));
            } else if (fillPatternString.equalsIgnoreCase(LPC_DIAG_CROSS_PATTERN)) {
                big.draw(new Line2D.Double(0, 0, 7, 7));
                big.draw(new Line2D.Double(0, 4, 3, 7));
                big.draw(new Line2D.Double(4, 0, 7, 3));
                big.draw(new Line2D.Double(0, 7, 7, 0));
                big.draw(new Line2D.Double(0, 3, 3, 0));
                big.draw(new Line2D.Double(4, 7, 7, 4));
            } else if (fillPatternString.equalsIgnoreCase(LPC_BACKWARD_DIAG_PATTERN)) {
                big.draw(new Line2D.Double(0, 0, 7, 7));
                big.draw(new Line2D.Double(0, 4, 3, 7));
                big.draw(new Line2D.Double(4, 0, 7, 3));
            } else if (fillPatternString.equalsIgnoreCase(LPC_FORWARD_DIAG_PATTERN)) {
                big.draw(new Line2D.Double(0, 7, 7, 0));
                big.draw(new Line2D.Double(0, 3, 3, 0));
                big.draw(new Line2D.Double(4, 7, 7, 4));
            } else {
                // default to solid
                big.fillRect(0, 0, 8, 8);
            }

            Rectangle r = new Rectangle(0, 0, 8, 8);
            TexturePaint texturePaint = new TexturePaint(bi, r);

            renderAttributesCache.put(texturePaintKey, texturePaint);
            return texturePaint;
        }
    }
View Full Code Here

                            0,
                            0,
                            -1,
                            -1);

                    return new TexturePaint(bi, new Rectangle(0, 0, bi.getWidth(), bi.getHeight()));
                } catch (InterruptedException ie) {
                    Debug.error("DrawingAttributes: Interrupted Exception scaling texture paint");
                }
            }
            return fillPattern;
View Full Code Here

                            0,
                            0,
                            -1,
                            -1);

                    fillPattern = new TexturePaint(bi, new Rectangle(0, 0, bi.getWidth(), bi.getHeight()));
                }
            } catch (MalformedURLException murle) {
                Debug.error("DrawingAttributes.init: bad texture URL - \n     "
                        + realPrefix + fillPatternProperty);
                fillPattern = null;
View Full Code Here

    g2D.setPaint(Color.WHITE);
    g2D.fillRect(0, 0, imageSize, imageSize);   
    BufferedImage textureImage = this.imageChoicePreviewComponent.getImage();
    if (textureImage != null) {
      // Draw the texture image as if it will be shown on a 250 x 250 cm wall
      g2D.setPaint(new TexturePaint(textureImage,
          new Rectangle2D.Float(0, 0,
              this.controller.getWidth() / 250 * imageSize,
              this.controller.getHeight() / 250 * imageSize)));
      g2D.fillRect(0, 0, imageSize, imageSize);
    }
View Full Code Here

      imageGraphics.scale(gridScale, gridScale);
     
      paintGridLines(imageGraphics, gridScale, 0, mainGridSize, 0, mainGridSize, gridSize, mainGridSize);   
      imageGraphics.dispose();
     
      g2D.setPaint(new TexturePaint(gridImage, new Rectangle2D.Float(0, 0, mainGridSize, mainGridSize)));
     
      g2D.fill(new Rectangle2D.Float(xMin, yMin, xMax - xMin, yMax - yMin));
    } else {
      paintGridLines(g2D, gridScale, xMin, xMax, yMin, yMax, gridSize, mainGridSize);         
    }
View Full Code Here

                        }
                      });
                }
                textureImage = this.floorTextureImagesCache.get(floorTexture.getImage());
              }
              g2D.setPaint(new TexturePaint(textureImage,
                  new Rectangle2D.Float(0, 0, floorTexture.getWidth(), floorTexture.getHeight())));
            }
          }         
        }
       
View Full Code Here

      this.wallsPatternImageCache = SwingTools.getPatternImage(this.preferences.getWallPattern(),
          backgroundColor, foregroundColor);
      this.wallsPatternBackgroundCache = backgroundColor;
      this.wallsPatternForegroundCache = foregroundColor;
    }
    return new TexturePaint(this.wallsPatternImageCache,
        new Rectangle2D.Float(0, 0, 10 / planScale, 10 / planScale));
  }
View Full Code Here

      // Paint plan icon in an image
      BufferedImage image = new BufferedImage(getIconWidth(), getIconHeight(), BufferedImage.TYPE_INT_ARGB);
      final Graphics2D imageGraphics = (Graphics2D)image.getGraphics();
      PieceOfFurniturePlanIcon.super.paintIcon(c, imageGraphics, 0, 0);                 
      // Fill the pixels of plan icon with texture image
      imageGraphics.setPaint(new TexturePaint(textureImage,
          new Rectangle2D.Float(0, 0, -getIconWidth() / pieceWidth * pieceTexture.getWidth(),
              -getIconHeight() / pieceDepth * pieceTexture.getHeight())));
      imageGraphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_IN));
      imageGraphics.fillRect(0, 0, getIconWidth(), getIconHeight());                 
      imageGraphics.dispose();
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.