Package java.awt.image

Examples of java.awt.image.ImageFilter


                            | (grey & 0xff);

                    spectrogram.setRGB(i, maxYIndex - j, pixel);
                }
            }
            ImageFilter scaleFilter =
                    new ReplicateScaleFilter((int) (zoom * width), height);
            scaledSpectrogram =
                    createImage(new FilteredImageSource(spectrogram.getSource(),
                            scaleFilter));
            Dimension sz = getSize();
View Full Code Here


        this.zoom = zoom;
        if (spectrogram != null) {
            int width = spectrogram.getWidth();
            int height = spectrogram.getHeight();

            ImageFilter scaleFilter =
                    new ReplicateScaleFilter((int) (zoom * width), height);
            scaledSpectrogram =
                    createImage(new FilteredImageSource(spectrogram.getSource(),
                            scaleFilter));
            Dimension d = new Dimension((int) (width * zoom), height);
View Full Code Here

    }

    public Icon getIcon(String typeAgent) {
      Image image = getToolkit().getImage(getClass().getResource(getIconAgent(typeAgent)));
      if (greyOut) {
        ImageFilter colorfilter = new MyFilterImage();
        Image imageFiltered=createImage(new FilteredImageSource(image.getSource(),colorfilter));
        return new ImageIcon(imageFiltered);
      }
      else
        return new ImageIcon(image);
View Full Code Here

                && icon.getIconWidth() > 0
                && icon.getIconHeight() > 0) {
            BufferedImage img = new BufferedImage(icon.getIconWidth(),
                    icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
            icon.paintIcon(component, img.getGraphics(), 0, 0);
            ImageFilter filter = new RGBGrayFilter();
            ImageProducer producer = new FilteredImageSource(img.getSource(), filter);
            Image resultImage = component.createImage(producer);
            return new ImageIconUIResource(resultImage);
        }
        return super.getDisabledIcon(component, icon);
View Full Code Here

     * @see        java.awt.Image#SCALE_REPLICATE
     * @see        java.awt.Image#SCALE_AREA_AVERAGING
     * @since      JDK1.1
     */
    public Image getScaledInstance(int width, int height, int hints) {
        ImageFilter filter;
        if ((hints & (SCALE_SMOOTH | SCALE_AREA_AVERAGING)) != 0) {
            filter = new AreaAveragingScaleFilter(width, height);
        } else {
            filter = new ReplicateScaleFilter(width, height);
        }
View Full Code Here

        int iheight = icon.getHeight(this);
        int x = (width - iwidth) / 2;
        int y = (height - iheight) / 2;
        if (highlighted) {
          if (highlightedIcon == null) {
            ImageFilter filter = new HighlightedFilter();
            ImageProducer producer = new FilteredImageSource(icon.getSource(), filter);
            highlightedIcon = createImage(producer);
          }
          g.drawImage(highlightedIcon, x, y, this);
        } else
          g.drawImage(icon, x, y, this);
      }
      int[] lineBreaks = new int[3];
      int[] offx = new int[lineBreaks.length];
      int lbi = 0;
      Font font = new Font("SansSerif", Font.PLAIN, 11);
      g.setFont(font);
      FontMetrics fm = g.getFontMetrics();
      int em = fm.charWidth('m');
      int emlen = width / em;
      char[] nameChars = name.toCharArray();
      int chi = 0;
      while (chi < nameChars.length && lbi < lineBreaks.length) {
        int len = emlen;
        if (chi + len > nameChars.length)
          len = nameChars.length - chi;
        int chw = fm.charsWidth(nameChars, chi, len);
        if (chw > width) {
          while (len > 1) {
            len--;
            chw = fm.charsWidth(nameChars, chi, len);
            if (chw <= width)
              break;
          }
        } else {
          while (chi + len < nameChars.length) {
            len++;
            int chw1 = fm.charsWidth(nameChars, chi, len);
            if (chw1 > width) {
              len--;
              break;
            }
            chw = chw1;
          }
        }
        chi += len;
        offx[lbi] = (width - chw) / 2;
        lineBreaks[lbi++] = chi;
      }
      chi = 0;
      if (highlighted) {
        // g.setColor(new Color(0x4070C0));
        g2d.setPaint(new Color(0, 0.2f, 0.8f, 0.75f));
        Rectangle rect = new Rectangle(0, getHeight() - lineBreaks.length * fm.getHeight(), width, lbi
            * fm.getHeight());
        g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
        g2d.fill(rect);
        g.setColor(Color.white);
      }
      for (int line = 0; line < lbi; line++) {
        int chi1 = lineBreaks[line];
        int ty = getHeight() - fm.getDescent() - (lineBreaks.length - 1 - line) * fm.getHeight();
        g.drawString(name.substring(chi, chi1), offx[line], ty);
        chi = chi1;
      }
      if (group != null) {
        g.dispose();
        AlphaFilter filter = new AlphaFilter();
        filter.setLevel(0.5f);
        ImageProducer producer = new FilteredImageSource(group.getSource(), filter);
        Image filtered = createImage(producer);
        baseG.drawImage(filtered, 0, 0, null);
      }
    }
View Full Code Here

     * @see #isTransparencyForced
     */
    public static BufferedImage makeImageTransparent(BufferedImage bi, Color color) {
        // the color we are looking for. Alpha bits are set to opaque
        final int markerRGB = color.getRGB() | 0xFFFFFFFF;
        ImageFilter filter = new RGBImageFilter() {
            @Override
            public int filterRGB(int x, int y, int rgb) {
                if ((rgb | 0xFF000000) == markerRGB) {
                   // Mark the alpha bits as zero - transparent
                   return 0x00FFFFFF & rgb;
View Full Code Here

TOP

Related Classes of java.awt.image.ImageFilter

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.