javax.swing.Icon.getIconHeight()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(186)

本文整理了Java中javax.swing.Icon.getIconHeight()方法的一些代码示例,展示了Icon.getIconHeight()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Icon.getIconHeight()方法的具体详情如下:
包路径:javax.swing.Icon
类名称:Icon
方法名:getIconHeight

Icon.getIconHeight介绍

暂无

代码示例

代码示例来源:origin: skylot/jadx

@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
  int w = getIconWidth();
  int h = getIconHeight();
  icon.paintIcon(c, g, x, y);
  int k = 0;
  for (Icon subIcon : icons) {
    int dx = (int) (OVERLAY_POS[k++] * (w - subIcon.getIconWidth()));
    int dy = (int) (OVERLAY_POS[k++] * (h - subIcon.getIconHeight()));
    subIcon.paintIcon(c, g, x + dx, y + dy);
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-filesystems

MergedIcon(Icon icon1, Icon icon2, int xMerge, int yMerge) {
  assert icon1 != null;
  assert icon2 != null;
  this.icon1 = icon1;
  this.icon2 = icon2;
  if (xMerge == -1) {
    xMerge = icon1.getIconWidth() - icon2.getIconWidth();
  }
  if (yMerge == -1) {
    yMerge = icon1.getIconHeight() - icon2.getIconHeight();
  }
  this.xMerge = xMerge;
  this.yMerge = yMerge;
}

代码示例来源:origin: nodebox/nodebox

public Icon getHostIcon() {
  if (hostIcon != null) return hostIcon;
  BufferedImage img = new BufferedImage(64, 64, BufferedImage.TYPE_INT_ARGB);
  Graphics2D g = (Graphics2D) img.getGraphics();
  Icon icon = new ImageIcon(host.getIconFile());
  float factor = 64f / icon.getIconHeight();
  g.scale(factor, factor);
  icon.paintIcon(null, g, 0, 0);
  hostIcon = new ImageIcon(img);
  return hostIcon;
}

代码示例来源:origin: plantuml/plantuml

public BufferedImage getImage(double scale, Color foregroundColor, Color backgroundColor)
    throws ClassNotFoundException, NoSuchMethodException, SecurityException, InstantiationException,
    IllegalAccessException, IllegalArgumentException, InvocationTargetException {
  final Icon icon = buildIcon(foregroundColor);
  final BufferedImage image = new BufferedImage((int) (icon.getIconWidth() * scale),
      (int) (icon.getIconHeight() * scale), BufferedImage.TYPE_INT_ARGB);
  final Graphics2D g2 = image.createGraphics();
  g2.scale(scale, scale);
  if (backgroundColor != null) {
    g2.setColor(backgroundColor);
    g2.fillRect(0, 0, icon.getIconWidth(), icon.getIconHeight());
  }
  icon.paintIcon(null, g2, 0, 0);
  return image;
}

代码示例来源:origin: skylot/jadx

public ProgressPanel(final MainWindow mainWindow, boolean showCancelButton) {
  progressLabel = new JLabel();
  progressBar = new JProgressBar(0, 100);
  progressBar.setIndeterminate(true);
  progressBar.setStringPainted(false);
  progressLabel.setLabelFor(progressBar);
  setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
  setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
  setVisible(false);
  add(progressLabel);
  add(progressBar);
  if (showCancelButton) {
    JButton cancelButton = new JButton(ICON_CANCEL);
    cancelButton.setPreferredSize(new Dimension(ICON_CANCEL.getIconWidth(), ICON_CANCEL.getIconHeight()));
    cancelButton.setToolTipText("Cancel background jobs");
    cancelButton.setBorderPainted(false);
    cancelButton.setFocusPainted(false);
    cancelButton.setContentAreaFilled(false);
    cancelButton.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        mainWindow.cancelBackgroundJobs();
      }
    });
    add(cancelButton);
  }
}

代码示例来源:origin: nodebox/nodebox

Graphics2D g = (Graphics2D) img.getGraphics();
Icon icon = new ImageIcon(updater.getHost().getIconFile());
float factor = 64f / icon.getIconHeight();
g.scale(factor, factor);
icon.paintIcon(this, g, 0, 0);
ImageIcon scaledIcon = new ImageIcon(img);
JLabel iconLabel = new JLabel(scaledIcon);

代码示例来源:origin: 4thline/cling

public void paintComponent(Graphics g) {
  Dimension dim = getSize();
  int x, y;
  if (isOpaque()) {
    super.paintComponent(g);
  }
  for (y = 0; y < dim.height; y += ditherBackground.getIconHeight()) {
    for (x = 0; x < dim.width; x += ditherBackground.getIconWidth()) {
      ditherBackground.paintIcon(this, g, x, y);
    }
  }
}

代码示例来源:origin: geotools/geotools

/**
 * Builds a new transformed icon
 *
 * @param icon The icon to be rescaled
 * @param transformation The icon transformation
 */
public TransformedIcon(Icon icon, AffineTransform at) {
  this.icon = icon;
  this.at = at;
  Rectangle2D bounds =
      new Rectangle2D.Double(0, 0, icon.getIconWidth(), icon.getIconHeight());
  bounds = at.createTransformedShape(bounds).getBounds2D();
  this.width = (int) Math.round(bounds.getWidth());
  this.height = (int) Math.round(bounds.getHeight());
}

代码示例来源:origin: bobbylight/RSyntaxTextArea

if (icon!=null) {
  int y2 = y + (line-topLine)*cellHeight;
  y2 += (cellHeight-icon.getIconHeight())/2;
  ti.getIcon().paintIcon(this, g, 0, y2);
  lastLine = line-1; // Paint only 1 icon per line

代码示例来源:origin: org.netbeans.api/org-openide-util

/**
 * Converts given icon to a {@link java.awt.Image}.
 *
 * @param icon {@link javax.swing.Icon} to be converted.
 */
public static final Image icon2Image(Icon icon) {
  if (icon instanceof ImageIcon) {
    return ((ImageIcon) icon).getImage();
  } else {
    ToolTipImage image = new ToolTipImage("", icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics g = image.getGraphics();
    icon.paintIcon(new JLabel(), g, 0, 0);
    g.dispose();
    return image;
  }
}

代码示例来源:origin: geotools/geotools

if (icon.getIconHeight() < size && icon.getIconWidth() < size) {
  return icon;
} else {

代码示例来源:origin: bobbylight/RSyntaxTextArea

Icon icon = ti.getIcon();
if (icon!=null) {
  int iconH = icon.getIconHeight();
  int offs = ti.getMarkedOffset();
  if (offs>=0 && offs<=doc.getLength()) {
        if (lineY<=bottomY && (lineY+iconH>=topY)) {
          int y2 = lineY + (cellHeight-iconH)/2;
          ti.getIcon().paintIcon(this, g, 0, y2);
          lastLine = line-1; // Paint only 1 icon per line

代码示例来源:origin: plantuml/plantuml

.newInstance(ctx, fontAsShapes);
dimension = new Dimension(icon.getIconWidth(), icon.getIconHeight());
  g2.fillRect(0, 0, icon.getIconWidth(), icon.getIconHeight());
icon.paintIcon(null, g2, 0, 0);

代码示例来源:origin: haraldk/TwelveMonkeys

public void actionPerformed(final ActionEvent e) {
    if (zoomFactor <= 0) {
      setIcon(new BufferedImageIcon(image));
    }
    else {
      Icon current = getIcon();
      int w = (int) Math.max(Math.min(current.getIconWidth() * zoomFactor, image.getWidth() * 16), image.getWidth() / 16);
      int h = (int) Math.max(Math.min(current.getIconHeight() * zoomFactor, image.getHeight() * 16), image.getHeight() / 16);
      setIcon(new BufferedImageIcon(image, Math.max(w, 2), Math.max(h, 2), w > image.getWidth() || h > image.getHeight()));
    }
  }
}

代码示例来源:origin: bobbylight/RSyntaxTextArea

int topLine = (visibleRect.y-textAreaInsets.top)/cellHeight;
int y = topLine*cellHeight +
  (cellHeight-collapsedFoldIcon.getIconHeight())/2;
y += textAreaInsets.top;
      collapsedFoldIcon.paintIcon(this, g, x, y);
      expandedFoldIcon.paintIcon(this, g, x, y);

代码示例来源:origin: kiegroup/optaplanner

Icon errorIcon = UIManager.getIcon("OptionPane.errorIcon");
BufferedImage errorImage = new BufferedImage(
    errorIcon.getIconWidth(), errorIcon.getIconHeight(), BufferedImage.TYPE_INT_RGB);
errorIcon.paintIcon(null, errorImage.getGraphics(), 0, 0);
exceptionFrame.setIconImage(errorImage);
exceptionFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

代码示例来源:origin: bobbylight/RSyntaxTextArea

/**
 * Returns the icon from this icon group with the specified name.
 *
 * @param name The name of the icon.  For example, if you want the icon
 * specified in <code>new.gif</code>, this value should be
 * <code>new</code>.
 * @return The icon, or <code>null</code> if it could not be found or
 *         loaded.
 * @see #getLargeIcon
 */
public Icon getIcon(String name) {
  Icon icon = getIconImpl(path + name + "." + extension);
  // JDK 6.0 b74 returns icons with width/height==-1 in certain error
  // cases (new ImageIcon(url) where url is not resolved?).  We'll
  // just return null in this case as Swing AbstractButtons throw
  // exceptions when expected to paint an icon with width or height
  // is less than 1.
  if (icon!=null && (icon.getIconWidth()<1 || icon.getIconHeight()<1)) {
    icon = null;
  }
  return icon;
}

代码示例来源:origin: bobbylight/RSyntaxTextArea

visibleEditorRect);
int y = r.y;
y += (cellHeight-collapsedFoldIcon.getIconHeight())/2;
      collapsedFoldIcon.paintIcon(this, g, x, y);
      y += LineNumberList.getChildViewBounds(v, line,
            visibleEditorRect).height;
      expandedFoldIcon.paintIcon(this, g, x, y);
      y += curLineH;
      line++;

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

public static Image getImage(Icon icon) {

    if (icon instanceof ImageIcon) {
      return ((ImageIcon)icon).getImage();
    }

    int width = icon.getIconWidth();
    int height = icon.getIconHeight();
    BufferedImage image = UIUtil.createImage(width, height, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = (Graphics2D) image.getGraphics();
    icon.paintIcon(null, g2, 0, 0);
    return image;
  }
}

代码示例来源:origin: winterDroid/android-drawable-importer-intellij-plugin

@Override
  public void customize(JList list, ImageAsset imageAsset, int index, boolean selected, boolean hasFocus) {
    LayeredIcon layeredIcon = new LayeredIcon(2);
    File imageFile = controller.getThumbnailFile(imageAsset);
    if (imageFile != null && imageFile.exists()) {
      final ImageIcon icon = new ImageIcon(imageFile.getAbsolutePath());
      layeredIcon.setIcon(icon, 1, (- icon.getIconWidth() + EMPTY_ICON.getIconWidth())/2, (EMPTY_ICON.getIconHeight() - icon.getIconHeight())/2);
    }
    setIcon(layeredIcon);
    final String searchQuery = comboboxSpeedSearch.getEnteredPrefix();
    if (searchQuery != null &&
      searchQuery.trim().length() > 0 &&
      imageAsset.getName().contains(searchQuery)) {
      setBackground(JBColor.YELLOW);
    } else {
      setBackground(null);
    }
  }
}

相关文章