本文整理了Java中javax.swing.Icon.getIconWidth()
方法的一些代码示例,展示了Icon.getIconWidth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Icon.getIconWidth()
方法的具体详情如下:
包路径:javax.swing.Icon
类名称:Icon
方法名:getIconWidth
暂无
代码示例来源: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: otros-systems/otroslogviewer
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
int xPos = x;
for (Icon icon : icons) {
icon.paintIcon(c, g, xPos, y);
xPos += icon.getIconWidth();
}
}
代码示例来源: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: freeplane/freeplane
public void paintIcon(final Component c, final Graphics g, final int x, final int y) {
int myX = x;
for (final Icon icon : mIcons) {
icon.paintIcon(c, g, myX, y);
myX += icon.getIconWidth();
}
}
代码示例来源: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: Audiveris/audiveris
@Override
public void paintIcon (Component c,
Graphics g,
int x,
int y)
{
int w = icon.getIconWidth();
icon.paintIcon(c, g, x + ((width - w) / 2), y);
}
}
代码示例来源: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: geotools/geotools
if (icon.getIconHeight() < size && icon.getIconWidth() < size) {
return icon;
} else {
代码示例来源:origin: org.gephi/ui-components
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
orig.paintIcon(c, g, x, y);
if (decorationController == null || decorationController.isDecorated()) {
decoration.paintIcon(c, g, x + orig.getIconWidth() - decoration.getIconWidth(), y);
}
}
代码示例来源: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: 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: org.gephi/ui-components
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
origIcon.paintIcon(c, g, x, y);
g.setColor(UIManager.getColor("controlHighlight")); //NOI18N
g.drawLine(x + origIcon.getIconWidth() - arrowWidth - 2, y,
x + origIcon.getIconWidth() - arrowWidth - 2, y + getIconHeight());
g.setColor(UIManager.getColor("controlShadow")); //NOI18N
g.drawLine(x + origIcon.getIconWidth() - arrowWidth - 3, y,
x + origIcon.getIconWidth() - arrowWidth - 3, y + getIconHeight());
}
代码示例来源: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: tinyMediaManager/tinyMediaManager
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (this.hintIcon != null) {
int iconWidth = hintIcon.getIconWidth();
int x = getWidth() - iconWidth - 2;
int y = 0;
hintIcon.paintIcon(this, g, x, y);
}
}
}
代码示例来源: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);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!