本文整理汇总了Java中javax.swing.Icon.getIconHeight方法的典型用法代码示例。如果您正苦于以下问题:Java Icon.getIconHeight方法的具体用法?Java Icon.getIconHeight怎么用?Java Icon.getIconHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.Icon
的用法示例。
在下文中一共展示了Icon.getIconHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MergedIcon
import javax.swing.Icon; //导入方法依赖的package包/类
MergedIcon( Icon icon1, Icon icon2, int xMerge, int yMerge ) {
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;
}
示例2: iconToImage
import javax.swing.Icon; //导入方法依赖的package包/类
public static Image iconToImage(Icon icon) {
if (icon instanceof ImageIcon) {
return ((ImageIcon) icon).getImage();
} else {
int w = icon.getIconWidth();
int h = icon.getIconHeight();
GraphicsEnvironment ge
= GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gd.getDefaultConfiguration();
BufferedImage image = gc.createCompatibleImage(w, h);
Graphics2D g = image.createGraphics();
icon.paintIcon(null, g, 0, 0);
g.dispose();
return image;
}
}
示例3: createToggleButton
import javax.swing.Icon; //导入方法依赖的package包/类
private static JToggleButton createToggleButton (final String id, String iconName, String tooltip) {
Icon icon = loadIcon(iconName);
boolean isSelected = isButtonSelected(id);
final JToggleButton toggleButton = new JToggleButton(icon, isSelected);
// ensure small size, just for the icon
Dimension size = new Dimension(icon.getIconWidth() + 8, icon.getIconHeight() + 8);
toggleButton.setPreferredSize(size);
toggleButton.setMargin(new Insets(1, 1, 1, 1));
if (!"Aqua".equals(UIManager.getLookAndFeel().getID())) { //NOI18N
// We do not want an ugly border with the exception of Mac, where it paints the toggle state!
toggleButton.setBorder(new EmptyBorder(toggleButton.getBorder().getBorderInsets(toggleButton)));
}
toggleButton.setToolTipText(tooltip);
toggleButton.setFocusable(false);
return toggleButton;
}
示例4: paintIconForVertex
import javax.swing.Icon; //导入方法依赖的package包/类
public void paintIconForVertex(Graphics g, Vertex v, int x, int y) {
boolean outlineImages = false;
if(vertexIconFunction instanceof DemoVertexImageShapeFunction) {
outlineImages = ((DemoVertexImageShapeFunction)vertexIconFunction).isOutlineImages();
}
Icon icon = vertexIconFunction.getIcon(v);
if(icon == null || outlineImages) {
Shape s = AffineTransform.getTranslateInstance(x,y).
createTransformedShape(getVertexShapeFunction().getShape(v));
paintShapeForVertex((Graphics2D)g, v, s);
}
if(icon != null) {
int xLoc = x - icon.getIconWidth()/2;
int yLoc = y - icon.getIconHeight()/2;
icon.paintIcon(screenDevice, g, xLoc, yLoc);
}
}
示例5: getCloseButtonRectangle
import javax.swing.Icon; //导入方法依赖的package包/类
public void getCloseButtonRectangle(JComponent jc, Rectangle rect, Rectangle bounds) {
boolean rightClip = ((NimbusEditorTabCellRenderer) jc).isClipRight();
boolean leftClip = ((NimbusEditorTabCellRenderer) jc).isClipLeft();
boolean notSupported = !((NimbusEditorTabCellRenderer) jc).isShowCloseButton();
if (leftClip || rightClip || notSupported) {
rect.x = -100;
rect.y = -100;
rect.width = 0;
rect.height = 0;
} else {
String iconPath = findIconPath((NimbusEditorTabCellRenderer) jc);
Icon icon = TabControlButtonFactory.getIcon(iconPath);
int iconWidth = icon.getIconWidth();
int iconHeight = icon.getIconHeight();
rect.x = bounds.x + bounds.width - iconWidth - 2;
rect.y = bounds.y + (Math.max(0, bounds.height / 2 - iconHeight / 2));
rect.width = iconWidth;
rect.height = iconHeight;
}
}
示例6: drawCentered
import javax.swing.Icon; //导入方法依赖的package包/类
protected void drawCentered(Component c, Graphics graphics, Icon icon,
int x, int y) {
int w = icon.getIconWidth();
int h = icon.getIconHeight();
image[0] = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
super.drawCentered(c, image[0].getGraphics(), icon, w / 2, h / 2);
}
示例7: AbstractLogModel
import javax.swing.Icon; //导入方法依赖的package包/类
/**
* Creates a new log model with the defined size of log entries. If the size is exceeded old
* entries will be overwritten.
*
* @param modelIcon
* can be <code>null</code>. If not <code>null</code>, must be 16x16 pixel
* @param modelName
* cannot be <code>null</code> or empty. Must not exceed
* {@link LogModel#MAX_NAME_LENGTH} characters
* @param logMode
* see {@link LogMode#PULL} and {@link LogMode#PUSH}
* @param isClosable
* if <code>true</code>, the user can close the log via a button in the GUI
* @param maxLogEntries
* the maximum size of log entries
*/
public AbstractLogModel(Icon modelIcon, String modelName, LogMode logMode, boolean isClosable, int maxLogEntries) {
if (modelName == null || "".equals(modelName.trim())) {
throw new IllegalArgumentException("modelName must not be null or empty!");
}
if (logMode == null) {
throw new IllegalArgumentException("logMode must not be null!");
}
// enforce max length of name to avoid ugly GUI
if (modelName.length() > MAX_NAME_LENGTH) {
throw new IllegalArgumentException("modelName must not exeeed " + MAX_NAME_LENGTH + " characters!");
}
// enforce correct icon size (if icon is set)
if (modelIcon != null) {
if (!(modelIcon instanceof ScaledImageIcon) && modelIcon.getIconHeight() != ICON_SIZE
|| modelIcon.getIconWidth() != ICON_SIZE) {
throw new IllegalArgumentException("if modelIcon is not null it must be 16x16 pixel!");
}
this.modelIcon = modelIcon;
} else {
this.modelIcon = FALLBACK_ICON;
}
// this is important as we read the entries in reverse order in the LogViewer
// with a LinkedList the performance would become abysmal for huge logs
// where ArrayList takes constant time
logs = new CircularArrayList<>(maxLogEntries);
this.modelName = modelName;
this.logMode = logMode;
this.isClosable = isClosable;
this.logLevel = Level.INFO;
}
示例8: paintIcon
import javax.swing.Icon; //导入方法依赖的package包/类
public void paintIcon(Component c, Graphics g, int x, int y) {
super.paintIcon(c, g, x, y);
Dimension d = new Dimension(getIconWidth(), getIconHeight());
for (Iterator iterator = iconSet.iterator(); iterator.hasNext();) {
Icon icon = (Icon) iterator.next();
Dimension id = new Dimension(icon.getIconWidth(), icon.getIconHeight());
int dx = (d.width - id.width)/2;
int dy = (d.height - id.height)/2;
icon.paintIcon(c, g, x+dx, y+dy);
}
}
示例9: createButton
import javax.swing.Icon; //导入方法依赖的package包/类
public static JButton createButton (Icon icon, String tooltip) {
final JButton button = new JButton(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(tooltip);
button.setFocusable(false);
return button;
}
示例10: getInPortOffset
import javax.swing.Icon; //导入方法依赖的package包/类
protected Point getInPortOffset(Icon icon, Dimension cellDimension) {
int iconHeight = icon.getIconHeight();
int iconWidth = icon.getIconWidth();
int xOff = (cellDimension.width - iconWidth) / 2 * 1000 / cellDimension.width;
int yOff = iconHeight / 2 * 1000 / cellDimension.height;
return new Point(xOff, yOff);
}
示例11: paintBorder
import javax.swing.Icon; //导入方法依赖的package包/类
@Override
public void paintBorder(Component c, java.awt.Graphics g, int x, int y, int width, int height) {
DefaultOutlineCellRenderer ren = (DefaultOutlineCellRenderer)
((JComponent) c).getClientProperty(DefaultOutlineCellRenderer.class);
if (ren == null) {
ren = (DefaultOutlineCellRenderer) c;
}
if (ren.isShowHandle() && !ren.isLeaf()) {
Icon icon = ren.isExpanded() ? getExpandedIcon() : getCollapsedIcon();
int iconY;
int iconX = ren.getNestingDepth() * getNestingWidth();
if (icon.getIconHeight() < height) {
iconY = (height / 2) - (icon.getIconHeight() / 2);
} else {
iconY = 0;
}
if (isNimbus) {
iconX += icon.getIconWidth()/3; // To look good
}
if (isGtk) {
JLabel lbl = ren.isExpanded () ? lExpandedIcon : lCollapsedIcon;
lbl.setSize (Math.max (getExpansionHandleWidth (), iconX + getExpansionHandleWidth ()), height);
lbl.paint (g);
} else {
icon.paintIcon(c, g, iconX, iconY);
}
}
JCheckBox chBox = ren.getCheckBox();
if (chBox != null) {
int chBoxX = getExpansionHandleWidth() + ren.getNestingDepth() * getNestingWidth();
Rectangle bounds = chBox.getBounds();
int chBoxY;
if (bounds.getHeight() < height) {
chBoxY = (height / 2) - (((int) bounds.getHeight()) / 2);
} else {
if (isNimbus) {
chBoxY = 1;
} else {
chBoxY = 0;
}
}
Dimension chDim = chBox.getSize();
java.awt.Graphics gch = g.create(chBoxX, chBoxY, chDim.width, chDim.height);
chBox.paint(gch);
}
}
示例12: paintIconAndTextCentered
import javax.swing.Icon; //导入方法依赖的package包/类
private void paintIconAndTextCentered(Graphics g, HtmlRendererImpl r) {
Insets ins = r.getInsets();
Icon ic = r.getIcon();
int w = r.getWidth() - (ins.left + ins.right);
int txtX = ins.left;
int txtY = 0;
if ((ic != null) && (ic.getIconWidth() > 0) && (ic.getIconHeight() > 0)) {
int iconx = (w > ic.getIconWidth()) ? ((w / 2) - (ic.getIconWidth() / 2)) : txtX;
int icony = 0;
ic.paintIcon(r, g, iconx, icony);
txtY += (ic.getIconHeight() + r.getIconTextGap());
}
int txtW = r.getPreferredSize().width;
txtX = (txtW < r.getWidth()) ? ((r.getWidth() / 2) - (txtW / 2)) : 0;
int txtH = r.getHeight() - txtY;
Font f = r.getFont();
g.setFont(f);
FontMetrics fm = g.getFontMetrics(f);
txtY += fm.getMaxAscent();
Color background = getBackgroundFor(r);
Color foreground = ensureContrastingColor(getForegroundFor(r), background);
if (r.isHtml()) {
HtmlRenderer._renderHTML(
r.getText(), 0, g, txtX, txtY, txtW, txtH, f, foreground, r.getRenderStyle(), true, background, r.isSelected()
);
} else {
HtmlRenderer.renderString(
r.getText(), g, txtX, txtY, txtW, txtH, r.getFont(), foreground, r.getRenderStyle(), true
);
}
}
示例13: mergeIcons
import javax.swing.Icon; //导入方法依赖的package包/类
/**
* Utility method merging 2 icons.
*/
private static Icon mergeIcons(Icon icon1, Icon icon2, int x, int y, Component c) {
int w = 0, h = 0;
if (icon1 != null) {
w = icon1.getIconWidth();
h = icon1.getIconHeight();
}
if (icon2 != null) {
w = icon2.getIconWidth() + x > w ? icon2.getIconWidth() + x : w;
h = icon2.getIconHeight() + y > h ? icon2.getIconHeight() + y : h;
}
if (w < 1) w = 16;
if (h < 1) h = 16;
java.awt.image.ColorModel model = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment ().
getDefaultScreenDevice ().getDefaultConfiguration ().
getColorModel (java.awt.Transparency.BITMASK);
java.awt.image.BufferedImage buffImage = new java.awt.image.BufferedImage (model,
model.createCompatibleWritableRaster (w, h), model.isAlphaPremultiplied (), null);
java.awt.Graphics g = buffImage.createGraphics ();
if (icon1 != null) {
icon1.paintIcon(c, g, 0, 0);
}
if (icon2 != null) {
icon2.paintIcon(c, g, x, y);
}
g.dispose();
return new ImageIcon(buffImage);
}
示例14: getScaledImageIcon
import javax.swing.Icon; //导入方法依赖的package包/类
/**
* Scale the given icon to the given dimensions
*
* @param label
* @return
*/
public ImageIcon getScaledImageIcon(Icon icon, int width, int height) {
if (icon != null) {
BufferedImage buf = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(),
BufferedImage.TYPE_INT_RGB);
Graphics graphics = buf.createGraphics();
icon.paintIcon(null, graphics, 0, 0);
graphics.dispose();
Image dimg = buf.getScaledInstance(width, height, Image.SCALE_SMOOTH);
return new ImageIcon(dimg);
}
return null;
}
示例15: createToggle
import javax.swing.Icon; //导入方法依赖的package包/类
private JToggleButton createToggle (Map<String,Boolean> fStates, int index) {
boolean isSelected = filtersDesc.isSelected(index);
Icon icon = filtersDesc.getSelectedIcon(index);
// ensure small size, just for the icon
JToggleButton result = new JToggleButton(icon, isSelected);
Dimension size = new Dimension(icon.getIconWidth() + 6, icon.getIconHeight() + 4);
result.setPreferredSize(size);
result.setMargin(new Insets(2,3,2,3));
result.setToolTipText(filtersDesc.getTooltip(index));
fStates.put(filtersDesc.getName(index), Boolean.valueOf(isSelected));
return result;
}