|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.fr.design.icon; |
|
|
|
|
|
|
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
|
import com.fr.base.svg.SVGLoader; |
|
|
|
|
import com.fr.design.utils.SvgPaintUtils; |
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
|
|
|
|
|
import javax.swing.GrayFilter; |
|
|
|
@ -15,10 +16,10 @@ import java.awt.image.ImageObserver;
|
|
|
|
|
* @since 2012-3-28下午10:20:29 |
|
|
|
|
*/ |
|
|
|
|
public class WarningIcon extends ImageIcon { |
|
|
|
|
protected final static Component component = new Component() { |
|
|
|
|
protected final static Component COMPONENT = new Component() { |
|
|
|
|
}; |
|
|
|
|
protected final static MediaTracker tracker = new MediaTracker(component); |
|
|
|
|
private final static Image warnighImage = BaseUtils.readImage("/com/fr/design/images/gui/warning.png"); |
|
|
|
|
protected final static MediaTracker TRACKER = new MediaTracker(COMPONENT); |
|
|
|
|
private final static Image WARNING_IMAGE = SVGLoader.load("/com/fr/design/standard/warning.svg"); |
|
|
|
|
|
|
|
|
|
private Image mainImage = null; |
|
|
|
|
private ImageObserver imageObserver; |
|
|
|
@ -35,12 +36,14 @@ public class WarningIcon extends ImageIcon {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public synchronized void paintIcon(Component c, Graphics g, int x, int y) { |
|
|
|
|
SvgPaintUtils.beforePaint((Graphics2D) g); |
|
|
|
|
if (mainImage != null) { |
|
|
|
|
g.drawImage(mainImage, x, y, c); |
|
|
|
|
} |
|
|
|
|
if (warnighImage != null) { |
|
|
|
|
g.drawImage(warnighImage, x, y, c); |
|
|
|
|
if (WARNING_IMAGE != null) { |
|
|
|
|
g.drawImage(WARNING_IMAGE, x, y, c); |
|
|
|
|
} |
|
|
|
|
SvgPaintUtils.afterPaint((Graphics2D) g); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -50,17 +53,17 @@ public class WarningIcon extends ImageIcon {
|
|
|
|
|
* the image |
|
|
|
|
*/ |
|
|
|
|
protected void loadImage(Image image) { |
|
|
|
|
synchronized (tracker) { |
|
|
|
|
tracker.addImage(image, 0); |
|
|
|
|
synchronized (TRACKER) { |
|
|
|
|
TRACKER.addImage(image, 0); |
|
|
|
|
try { |
|
|
|
|
tracker.waitForID(0, 0); |
|
|
|
|
TRACKER.waitForID(0, 0); |
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
tracker.statusID(0, false); |
|
|
|
|
tracker.removeImage(image, 0); |
|
|
|
|
TRACKER.statusID(0, false); |
|
|
|
|
TRACKER.removeImage(image, 0); |
|
|
|
|
|
|
|
|
|
width = image.getWidth(imageObserver); |
|
|
|
|
height = image.getHeight(imageObserver); |
|
|
|
@ -101,6 +104,6 @@ public class WarningIcon extends ImageIcon {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
loadImage(warnighImage); |
|
|
|
|
loadImage(WARNING_IMAGE); |
|
|
|
|
} |
|
|
|
|
} |