当前位置: 首页>>代码示例>>Java>>正文


Java ImageIcon.getIconHeight方法代码示例

本文整理汇总了Java中javax.swing.ImageIcon.getIconHeight方法的典型用法代码示例。如果您正苦于以下问题:Java ImageIcon.getIconHeight方法的具体用法?Java ImageIcon.getIconHeight怎么用?Java ImageIcon.getIconHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.ImageIcon的用法示例。


在下文中一共展示了ImageIcon.getIconHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: assertImageMatch

import javax.swing.ImageIcon; //导入方法依赖的package包/类
/** Samples a trivial number of pixels from an image and compares them with
 *pixels from a component to determine if the image is painted on the
 * component at the exact position specified */
private void assertImageMatch(String msg, Image i, JComponent comp, int xpos, int ypos) throws Exception {
    ImageIcon ic = new ImageIcon(i);
    int width = ic.getIconWidth();
    int height = ic.getIconHeight();
    
    for (int x=2; x < 5; x++) {
        for (int y=2; y < 5; y++) {
            int posX = width / x;
            int posY = height / y;
            System.err.println("  Check " + posX + "," + posY);
            assertPixelFromImage(msg, i, comp, posX, posY, xpos + posX, ypos + posY);
        }
    }
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:EditableDisplayerTest.java

示例2: readIconFromFile

import javax.swing.ImageIcon; //导入方法依赖的package包/类
private Icon readIconFromFile( File iconFile ) {
    try {
        Image img = ImageIO.read( iconFile.toURL() );
        if( null != img ) {
            ImageIcon res = new ImageIcon( img );
            if( res.getIconWidth() > 32 || res.getIconHeight() > 32 )  {
                JOptionPane.showMessageDialog(this, NbBundle.getMessage(TextImporterUI.class, "Err_IconTooBig"), //NOI18N
                        NbBundle.getMessage(TextImporterUI.class, "Err_Title"), JOptionPane.ERROR_MESSAGE  ); //NOI18N
                return null;
            }
            return res;
        }
    } catch( ThreadDeath td ) {
        throw td;
    } catch( Throwable ioE ) {
        //ignore
    }
    JOptionPane.showMessageDialog(this, 
            NbBundle.getMessage(TextImporterUI.class, "Err_CannotLoadIconFromFile", iconFile.getName()), //NOI18N
            NbBundle.getMessage(TextImporterUI.class, "Err_Title"), JOptionPane.ERROR_MESSAGE  ); //NOI18N
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:TextImporterUI.java

示例3: createActivateBreakpointsActionButton

import javax.swing.ImageIcon; //导入方法依赖的package包/类
@NbBundle.Messages({"CTL_DeactivateAllBreakpoints=Deactivate all breakpoints in current session",
                    "CTL_ActivateAllBreakpoints=Activate all breakpoints in current session",
                    "CTL_NoDeactivation=The current session does not allow to deactivate breakpoints",
                    "CTL_NoSession=No debugger session"})
public static AbstractButton createActivateBreakpointsActionButton() {
    ImageIcon icon = ImageUtilities.loadImageIcon(DEACTIVATED_LINE_BREAKPOINT, false);
    final JToggleButton button = new JToggleButton(icon);
    // ensure small size, just for the icon
    Dimension size = new Dimension(icon.getIconWidth() + 8, icon.getIconHeight() + 8);
    button.setPreferredSize(size);
    button.setMargin(new Insets(1, 1, 1, 1));
    button.setBorder(new EmptyBorder(button.getBorder().getBorderInsets(button)));
    button.setToolTipText(Bundle.CTL_DeactivateAllBreakpoints());
    button.setFocusable(false);
    final BreakpointsActivator ba = new BreakpointsActivator(button);
    button.addActionListener(ba);
    DebuggerManager.getDebuggerManager().addDebuggerListener(DebuggerManager.PROP_CURRENT_ENGINE, new DebuggerManagerAdapter() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            DebuggerEngine de = (DebuggerEngine) evt.getNewValue();
            ba.setCurrentEngine(de);
        }
    });
    ba.setCurrentEngine(DebuggerManager.getDebuggerManager().getCurrentEngine());
    return button;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:BreakpointsViewButtons.java

示例4: redimensionaImg

import javax.swing.ImageIcon; //导入方法依赖的package包/类
/**
 * Redimensiona a imagem do caminho passado por parâmetro
 *
 * @param image imagem
 * @param razao proporção do redimensionamento
 * @return retorna a imagem redimensionada
 */
public static ImageIcon redimensionaImg(Image image, double razao) {
    double new_w, new_h;
    ImageIcon img = new ImageIcon(image);
    new_w = img.getIconWidth();
    new_h = img.getIconHeight();
    new_w *= razao;
    new_h *= razao;
    BufferedImage new_img = new BufferedImage((int) new_w, (int) new_h, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = new_img.createGraphics();
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
    g.drawImage(image, 0, 0, (int) new_w, (int) new_h, null);
    g.dispose();
    return new ImageIcon(new_img);
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:24,代码来源:Img.java

示例5: setBackgroundImage

import javax.swing.ImageIcon; //导入方法依赖的package包/类
public void setBackgroundImage(Image image) {
  if (image != null) {
    final ImageIcon icon = new ImageIcon(image);
    logoSize = new Dimension(icon.getIconWidth(), icon.getIconHeight());
    final BufferedImage img =
      ImageUtils.createCompatibleTranslucentImage(logoSize.width,
                                                  logoSize.height);
    Graphics2D g = img.createGraphics();
    g.setColor(Color.white);
    g.fillRect(0, 0, icon.getIconWidth(), icon.getIconHeight());
    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5F));
    icon.paintIcon(null, g, 0, 0);
    g.dispose();
    UIManager.put("wizard.sidebar.image", img); //$NON-NLS-1$
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:17,代码来源:WizardSupport.java

示例6: ReColorBlackImg

import javax.swing.ImageIcon; //导入方法依赖的package包/类
public static Image ReColorBlackImg(ImageIcon im, final Color novaCor) {
    BufferedImage destImage = new BufferedImage(im.getIconWidth(),
            im.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
    
    Graphics2D g = destImage.createGraphics();
    g.drawImage(im.getImage(), 0, 0, null);
    g.dispose();        
    for (int i = 0; i < destImage.getHeight(); i++) {
        for (int j = 0; j < destImage.getWidth(); j++) {
            int rgb = destImage.getRGB(j, i);

            if (rgb != 0 && rgb != -1) {//branco ou transparente
                destImage.setRGB(j, i, novaCor.getRGB());
            }
        }
    }
    return destImage;
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:19,代码来源:TratadorDeImagens.java

示例7: serialize

import javax.swing.ImageIcon; //导入方法依赖的package包/类
@Override
public void serialize(ImageIcon vi, JsonGenerator jgen, SerializerProvider provider)
    throws IOException, JsonProcessingException {
  synchronized (vi) {

    BufferedImage v = new BufferedImage(
      vi.getIconWidth(),
      vi.getIconHeight(),
      BufferedImage.TYPE_INT_RGB);
    Graphics g = v.createGraphics();
    // paint the Icon to the BufferedImage.
    vi.paintIcon(null, g, 0, 0);
    g.dispose();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ImageIO.write(v, "png", baos);
    byte [] data = baos.toByteArray();
    jgen.writeStartObject();
    jgen.writeStringField("type",  "ImageIcon");
    jgen.writeObjectField("imageData", data);
    jgen.writeNumberField("width", v.getWidth());
    jgen.writeNumberField("height", v.getHeight());
    jgen.writeEndObject();
  }
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:26,代码来源:ImageIconSerializer.java

示例8: getCirculo

import javax.swing.ImageIcon; //导入方法依赖的package包/类
/**
 * Retorna um recorte cirular da imagem passada por parâmetro
 *
 * @param imagem imagem a ser recortada
 * @param x início do corte na horizontal
 * @param y início do corte na vertical
 * @param w largura do corte
 * @param h altura do corte
 * @return imagem recortada ou a mesma imagem para valores inválidos
 */
public static ImageIcon getCirculo(ImageIcon imagem, int x, int y, int w, int h) {
    try {
        BufferedImage other = new BufferedImage(imagem.getIconWidth(), imagem.getIconHeight(), TYPE_INT_ARGB);
        Graphics2D g2d = other.createGraphics();
        g2d.setClip(new Ellipse2D.Double(x, y, w, h));
        g2d.drawImage(imagem.getImage(), 0, 0, null);
        g2d.dispose();
        other = other.getSubimage(x, y, w, h);
        return new ImageIcon(other);
    } catch (Exception ex) {
        return imagem;
    }
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:24,代码来源:Img.java

示例9: getCursor

import javax.swing.ImageIcon; //导入方法依赖的package包/类
/**
 * Get a suitable cursor for the given component.
 *
 * @param c The component to consider.
 * @return A suitable {@code Cursor}, or null on failure.
 */
private Cursor getCursor(JComponent c) {
    if (c instanceof JLabel
        && ((JLabel)c).getIcon() instanceof ImageIcon) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        ImageIcon imageIcon = ((ImageIcon)((JLabel)c).getIcon());
        Dimension bestSize = tk.getBestCursorSize(imageIcon.getIconWidth(),
            imageIcon.getIconHeight());
            
        if (bestSize.width == 0 || bestSize.height == 0) return null;
           
        if (bestSize.width > bestSize.height) {
            bestSize.height = (int)((((double)bestSize.width)
                    / ((double)imageIcon.getIconWidth()))
                * imageIcon.getIconHeight());
        } else {
            bestSize.width = (int)((((double)bestSize.height)
                    / ((double)imageIcon.getIconHeight()))
                * imageIcon.getIconWidth());
        }
        BufferedImage scaled = ImageLibrary
            .createResizedImage(imageIcon.getImage(),
                                bestSize.width, bestSize.height);
        Point point = new Point(bestSize.width / 2,
                                bestSize.height / 2);
        try {
            return tk.createCustomCursor(scaled, point,
                                         "freeColDragIcon");
        } catch (Exception ex) {
            ; // Fall through
        }
    }
    return null;
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:40,代码来源:DefaultTransferHandler.java

示例10: colorize

import javax.swing.ImageIcon; //导入方法依赖的package包/类
private ImageIcon colorize(ImageIcon icon, Color color) {
    int[] pixels = new int[icon.getIconHeight() * icon.getIconWidth()];
    try {
        PixelGrabber grabber = new PixelGrabber(icon.getImage(), 0, 0, icon.getIconWidth(),
                                                icon.getIconHeight(), pixels, 0,
                                                icon.getIconWidth());
        grabber.grabPixels();
        int r = color.getRed();
        int g = color.getGreen();
        int b = color.getBlue();

        int pixel;
        for (int i = 0, acm; i < pixels.length; i++) {
        	pixel = pixels[i];
        	int alpha = (pixel >> 24) & 0xff;
            int red   = (pixel >> 16) & 0xff;
            int green = (pixel >>  8) & 0xff;
            int blue  = pixel & 0xff;
            acm = (blue + green + red) / 3;
            int max = 255;
            pixels[i] = (((acm * r)/max) << 16) + (((acm * g)/max) << 8) + ((acm * b)/max) + (alpha << 24);
        }
    } catch (InterruptedException ex) {
        ex.printStackTrace();
    }
    MemoryImageSource mis = new MemoryImageSource(icon.getIconWidth(),
                                                  icon.getIconHeight(),
                                                  pixels, 0,
                                                  icon.getIconWidth());
    return new ImageIcon(component.createImage(mis));
}
 
开发者ID:adbenitez,项目名称:jNotifyOSD,代码行数:32,代码来源:NotifyConfig.java

示例11: colorizeNoWhite

import javax.swing.ImageIcon; //导入方法依赖的package包/类
private ImageIcon colorizeNoWhite(ImageIcon icon, Color color) {
    int[] pixels = new int[icon.getIconHeight() * icon.getIconWidth()];
    try {
        PixelGrabber grabber = new PixelGrabber(icon.getImage(), 0, 0, icon.getIconWidth(),
                                                icon.getIconHeight(), pixels, 0,
                                                icon.getIconWidth());
        grabber.grabPixels();
        int r = color.getRed();
        int g = color.getGreen();
        int b = color.getBlue();

        int pixel;
        for (int i = 0, acm; i < pixels.length; i++) {
        	pixel = pixels[i];
        	int alpha = (pixel >> 24) & 0xff;
            int red   = (pixel >> 16) & 0xff;
            int green = (pixel >>  8) & 0xff;
            int blue  = pixel & 0xff;
            acm = (blue + green + red) / 3;
            int max = 255;
            if (acm < 200) {
                pixels[i] = (((acm * r)/max) << 16) + (((acm * g)/max) << 8) + ((acm * b)/max) + (alpha << 24);
            } else {
                pixels[i] = (acm << 16) + (acm << 8) + acm + (alpha << 24);
            }
        }
    } catch (InterruptedException ex) {
        ex.printStackTrace();
    }
    MemoryImageSource mis = new MemoryImageSource(icon.getIconWidth(),
                                                  icon.getIconHeight(),
                                                  pixels, 0,
                                                  icon.getIconWidth());
    return new ImageIcon(component.createImage(mis));
}
 
开发者ID:adbenitez,项目名称:jNotifyOSD,代码行数:36,代码来源:NotifyConfig.java

示例12: mirrorImage

import javax.swing.ImageIcon; //导入方法依赖的package包/类
/**
 * Rotates image on y axis
 * @param base image to be modified
 * @return mirrored image
 */
protected ImageIcon mirrorImage(ImageIcon base) {
	BufferedImage out = new BufferedImage(base.getIconWidth(), base.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
	Graphics2D g = out.createGraphics();
	g.drawImage(base.getImage(), base.getIconWidth(), 0, 0, base.getIconHeight(), 0, 0, base.getIconWidth(), base.getIconHeight(), null);
	return new ImageIcon(out);
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:12,代码来源:ImageLoader.java

示例13: rescale

import javax.swing.ImageIcon; //导入方法依赖的package包/类
/**
 * Rescales an icon.
 * @param src the original icon.
 * @param newMinSize the minimum size of the new icon. The width and height of
 *                   the returned icon will be at least the width and height
 *                   respectively of newMinSize.
 * @param an ImageObserver.
 * @return the rescaled icon.
 */
public static ImageIcon rescale(ImageIcon src, Dimension newMinSize, ImageObserver observer) {
    double widthRatio =  newMinSize.getWidth() / (double) src.getIconWidth();
    double heightRatio = newMinSize.getHeight() / (double) src.getIconHeight();
    double scale = widthRatio > heightRatio ? widthRatio : heightRatio;
    
    int w = (int) Math.round(scale * src.getIconWidth());
    int h = (int) Math.round(scale * src.getIconHeight());
    BufferedImage dst = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = dst.createGraphics();
    g2.drawImage(src.getImage(), 0, 0, w, h, observer);
    g2.dispose();
    return new ImageIcon(dst);
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:23,代码来源:Utilities.java

示例14: toBufferedImage

import javax.swing.ImageIcon; //导入方法依赖的package包/类
public static BufferedImage toBufferedImage(final ImageIcon icon) {
    if (icon == null) return null;
    final int w = icon.getIconWidth(), h = icon.getIconHeight();
    final BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); 
    final Graphics g = bi.createGraphics();
    icon.paintIcon(null, g, 0,0);
    g.dispose();
    return bi;
}
 
开发者ID:iapafoto,项目名称:DicomViewer,代码行数:10,代码来源:DataLoader.java

示例15: testPropertyMarking

import javax.swing.ImageIcon; //导入方法依赖的package包/类
public void testPropertyMarking() throws Exception{
    if (!canRun) return;
    
    if (!checkGraphicsEnvironment()) {
        System.err.println("  Cannot run this test in a < 16 bit graphics environment");
    }
    custRen.setUpdatePolicy(custRen.UPDATE_ON_CONFIRMATION);
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            try {
                throwMe = null;
                custRen.getProperty().setValue("Value");
                custRen.refresh();
            } catch (Exception e) {
                throwMe = e;
            }
        }
    });
    
    if (throwMe != null) {
        Exception exc = throwMe;
        throwMe = null;
        throw exc;
    }
    
    
    requestFocus(custRen);
    
    typeKey(custRen, KeyEvent.VK_S);
    typeKey(custRen, KeyEvent.VK_N);
    typeKey(custRen, KeyEvent.VK_O);
    typeKey(custRen, KeyEvent.VK_R);
    typeKey(custRen, KeyEvent.VK_K);
    typeKey(custRen, KeyEvent.VK_E);
    typeKey(custRen, KeyEvent.VK_L);
    
    //The property marking image
    Image i = ImageUtilities.loadImage("org/openide/resources/propertysheet/invalid.gif");
    ImageIcon icon = new ImageIcon(i);
    int yOffset = (custRen.getHeight() / 2) - (icon.getIconHeight()/2);
    
    //        assertPixelFromImage(i, custRen, 7, 7, 7, yOffset + 7);
    assertImageMatch("Error icon should be painted for invalid value", i, custRen, 0, yOffset);
    
    requestFocus(custRen);
    
    //        SLEEP_LENGTH=1000;
    sleep();
    typeKey(custRen, KeyEvent.VK_M);
    typeKey(custRen, KeyEvent.VK_R);
    typeKey(custRen, KeyEvent.VK_F);
    typeKey(custRen, KeyEvent.VK_ENTER);
    pressKey(custRen, KeyEvent.VK_ENTER);
    pressKey(custRen, KeyEvent.VK_ENTER);
    custRen.commit();
    sleep();
    sleep();
    
    Icon icon2 = new ValueIcon();
    int yOffset2 = (custRen.getHeight() / 2) - (icon2.getIconHeight()/2);
    
    assertPixel("Supplied value icon should be drawn on panel, not the error marking icon, after committing a valid value.",
            custRen, Color.BLUE, icon2.getIconWidth() / 2, (icon2.getIconHeight() / 2) + yOffset2);
    
    requestFocus(custRen);
    
    typeKey(custRen, KeyEvent.VK_V);
    typeKey(custRen, KeyEvent.VK_A);
    typeKey(custRen, KeyEvent.VK_L);
    typeKey(custRen, KeyEvent.VK_U);
    typeKey(custRen, KeyEvent.VK_E);
    custRen.setEnteredValue("VALUE");
    pressKey(custRen, KeyEvent.VK_ENTER);
    custRen.commit();
    sleep();
    sleep();
    sleep();
    custRen.paintImmediately(0,0,custRen.getWidth(),custRen.getHeight());
    assertImageMatch("After reentering an invalid value, the icon should change back to the error icon", i, custRen, 0, yOffset);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:81,代码来源:EditableDisplayerTest.java


注:本文中的javax.swing.ImageIcon.getIconHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。