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