@Override public Object getProperty(String name, ImageObserver observer) { if ("url".equals(name)) { // NOI18N if (url != null) { return url; } else { return imageIcon.getImage().getProperty("url", observer); } } return super.getProperty(name, observer); } }
@Override public Object getProperty(String name, ImageObserver observer) { if ("url".equals(name)) { // NOI18N if (url != null) { return url; } else { if (imageIcon == null) { return null; } if (imageIcon.getImage() == this) { return null; } return imageIcon.getImage().getProperty("url", observer); } } return super.getProperty(name, observer); } }
private static final Image doMergeImages(Image image1, Image image2, int x, int y) { ensureLoaded(image1); ensureLoaded(image2); int w = Math.max(image1.getWidth(null), x + image2.getWidth(null)); int h = Math.max(image1.getHeight(null), y + image2.getHeight(null)); boolean bitmask = (image1 instanceof Transparency) && ((Transparency)image1).getTransparency() != Transparency.TRANSLUCENT && (image2 instanceof Transparency) && ((Transparency)image2).getTransparency() != Transparency.TRANSLUCENT; StringBuilder str = new StringBuilder(image1 instanceof ToolTipImage ? ((ToolTipImage)image1).toolTipText : ""); if (image2 instanceof ToolTipImage) { String toolTip = ((ToolTipImage)image2).toolTipText; if (str.length() > 0 && toolTip.length() > 0) { str.append(TOOLTIP_SEPAR); } str.append(toolTip); } Object firstUrl = image1.getProperty("url", null); ColorModel model = colorModel(bitmask? Transparency.BITMASK: Transparency.TRANSLUCENT); ToolTipImage buffImage = new ToolTipImage(str.toString(), model, model.createCompatibleWritableRaster(w, h), model.isAlphaPremultiplied(), null, firstUrl instanceof URL ? (URL)firstUrl : null ); java.awt.Graphics g = buffImage.createGraphics(); g.drawImage(image1, 0, 0, null); g.drawImage(image2, x, y, null); g.dispose(); return buffImage; }
public static ToolTipImage createNew(String toolTipText, Image image, URL url) { ImageUtilities.ensureLoaded(image); boolean bitmask = (image instanceof Transparency) && ((Transparency) image).getTransparency() != Transparency.TRANSLUCENT; ColorModel model = colorModel(bitmask ? Transparency.BITMASK : Transparency.TRANSLUCENT); int w = image.getWidth(null); int h = image.getHeight(null); if (url == null) { Object value = image.getProperty("url", null); url = (value instanceof URL) ? (URL) value : null; } ToolTipImage newImage = new ToolTipImage( toolTipText, model, model.createCompatibleWritableRaster(w, h), model.isAlphaPremultiplied(), null, url ); java.awt.Graphics g = newImage.createGraphics(); g.drawImage(image, 0, 0, null); g.dispose(); return newImage; }
/** Gets a property of this image by name. * <p> * Individual property names are defined by the various image * formats. If a property is not defined for a particular image, this * method returns the <code>UndefinedProperty</code> object. * <p> * If the properties for this image are not yet known, this method * returns <code>null</code>, and the <code>ImageObserver</code> * object is notified later. * <p> * The property name <code>"comment"</code> should be used to store * an optional comment which can be presented to the application as a * description of the image, its source, or its author. * @param name a property name. * @param observer an object waiting for this image to be loaded. * @return the value of the named property. * @see java.awt.image.ImageObserver * @see java.awt.Image#UndefinedProperty * */ public Object getProperty(String name, ImageObserver observer) { return image.getProperty(name, observer); }
/** Gets a property of this image by name. * <p> * Individual property names are defined by the various image * formats. If a property is not defined for a particular image, this * method returns the <code>UndefinedProperty</code> object. * <p> * If the properties for this image are not yet known, this method * returns <code>null</code>, and the <code>ImageObserver</code> * object is notified later. * <p> * The property name <code>"comment"</code> should be used to store * an optional comment which can be presented to the application as a * description of the image, its source, or its author. * @param name a property name. * @param observer an object waiting for this image to be loaded. * @return the value of the named property. * @see java.awt.image.ImageObserver * @see java.awt.Image#UndefinedProperty * */ @Override public Object getProperty(String name, ImageObserver observer) { return image.getProperty(name, observer); }
@Override public Object getProperty(String name, ImageObserver observer) { if ("url".equals(name)) { // NOI18N if (url != null) { return url; } else { return imageIcon.getImage().getProperty("url", observer); } } return super.getProperty(name, observer); } }
/** * Gets the horizontal pixel aspect of the image according to the pixel * aspect policy that is in affect. * * @return Horizontal pixel aspect. */ public double getPixelAspectX() { if (image == null) { return 0; } Object property = image.getProperty("aspect", this); if (property == null) { return 1; } double ratio = (property == null || property == UndefinedProperty) ? 1d : ((Double) property); switch (pixelAspectPolicy) { case IGNORE_PIXEL_ASPECT: return 1d; case EXACT_PIXEL_ASPECT: return ratio >= 1d ? ratio : 1d; case ROUNDED_PIXEL_ASPECT: return ratio >= 1d ? floor(ratio + 0.5d) : 1d; default: throw new InternalError("Invalid pixel aspect policy: " + pixelAspectPolicy); } }
/** * Gets the vertical pixel aspect of the image according to the pixel aspect * policy that is in effect. * * @return Vertical pixel aspect. */ public double getPixelAspectY() { if (image == null) { return 0; } Object property = image.getProperty("aspect", this); if (property == null) { return 1; } double ratio = (property == null || property == UndefinedProperty) ? 1d : ((Double) property); switch (pixelAspectPolicy) { case IGNORE_PIXEL_ASPECT: return 1d; case EXACT_PIXEL_ASPECT: return ratio < 1d ? 1d / ratio : 1d; case ROUNDED_PIXEL_ASPECT: return ratio < 1d ? floor(1d / ratio + 0.5d) : 1d; default: throw new InternalError("Invalid pixel aspect policy: " + pixelAspectPolicy); } }