use of com.servoy.j2db.util.gui.MyImageIcon in project servoy-client by Servoy.
the class ComponentFactory method flushCachedItems.
@SuppressWarnings("unchecked")
public static void flushCachedItems(IServiceProvider provider) {
parsedStyles = new ConcurrentHashMap<Style, IStyleSheet>();
if (provider != null) {
provider.getRuntimeProperties().put(IServiceProvider.RT_VALUELIST_CACHE, null);
provider.getRuntimeProperties().put(IServiceProvider.RT_OVERRIDESTYLE_CACHE, null);
provider.getRuntimeProperties().put(PARSED_STYLES, null);
}
Iterator<IconHolder> it = lstIcons.values().iterator();
while (it.hasNext()) {
IconHolder ih = it.next();
Icon icon = ih.icon.get();
if (icon instanceof ImageIcon) {
ImageIcon imageIcon = (ImageIcon) icon;
if (imageIcon.getImage() != null) {
imageIcon.getImage().flush();
}
imageIcon.setImageObserver(null);
} else if (icon instanceof MyImageIcon) {
((MyImageIcon) icon).flush();
}
}
lstIcons = new WeakHashMap<Object, IconHolder>();
}
use of com.servoy.j2db.util.gui.MyImageIcon in project servoy-client by Servoy.
the class AbstractScriptButton method getDisabledIcon.
@Override
public Icon getDisabledIcon() {
if (disabledIcon != null)
return disabledIcon;
if (getIcon() instanceof MyImageIcon) {
MyImageIcon icon = (MyImageIcon) getIcon();
icon.getIconWidth();
ImageIcon scaledIcon = icon.getScaledIcon(0, 0);
if (scaledIcon != null) {
disabledIcon = new IconUIResource(new ImageIcon(GrayFilter.createDisabledImage((scaledIcon).getImage())));
return disabledIcon;
}
}
return super.getDisabledIcon();
}
use of com.servoy.j2db.util.gui.MyImageIcon in project servoy-client by Servoy.
the class AbstractScriptButton method setIcon.
/*
* does not work, when onAction is fired the repaint event is not yet posted public AbstractScriptButton() { addActionListener(new ActionListener() { public
* void actionPerformed(ActionEvent e) { Utils.dispatchEvents(700); } }); }
*
* //We override this method becouse we want first added listners to be notified first! protected void fireActionPerformed(ActionEvent event) { // Guaranteed to
* return a non-null array Object[] listeners = listenerList.getListenerList(); ActionEvent e = null; // Process the listeners first to last, notifying // those
* that are interested in this event for (int i = 0 ; i < listeners.length ; i+=2) { if (listeners[i]==ActionListener.class) { // Lazily create the event: if (e
* == null) { String actionCommand = event.getActionCommand(); if(actionCommand == null) { actionCommand = getActionCommand(); } e = new ActionEvent(this,
* ActionEvent.ACTION_PERFORMED, actionCommand, event.getWhen(), event.getModifiers()); } ((ActionListener)listeners[i+1]).actionPerformed(e); } } }
*/
@Override
public void setIcon(Icon icon) {
Icon prevIcon = getIcon();
if (prevIcon instanceof MyImageIcon) {
Icon rollOver = getRolloverIcon();
if (rollOver instanceof MyImageIcon) {
((MyImageIcon) prevIcon).removeImageIcon((MyImageIcon) rollOver);
}
}
ComponentFactory.deregisterIcon(prevIcon);
if (mediaOption != 1 && icon instanceof ImageIcon) {
// do scaling cropping if needed
icon = new MyImageIcon(application, this, (ImageIcon) icon, mediaOption);
Icon rollOver = getRolloverIcon();
if (rollOver instanceof MyImageIcon) {
((MyImageIcon) icon).addImageIcon((MyImageIcon) rollOver);
}
}
ComponentFactory.registerIcon(icon);
super.setIcon(icon);
}
use of com.servoy.j2db.util.gui.MyImageIcon in project servoy-client by Servoy.
the class AbstractScriptLabel method setIconDirect.
/**
* show processed on background thread, is put on event thread
*/
public void setIconDirect(Icon icon, int seq) {
if (imageSeq == seq) {
ComponentFactory.deregisterIcon(normalIcon);
disabledIcon = null;
// media option 1 == crop so no scaling
if (mediaOption != 1 && icon instanceof ImageIcon) {
normalIcon = new MyImageIcon(application, this, (ImageIcon) icon, mediaOption);
} else {
normalIcon = icon;
}
ComponentFactory.registerIcon(normalIcon);
if (// $NON-NLS-1$
application.getI18NMessage("servoy.imageMedia.loadingImage").equals(getText())) {
setText(null);
}
try {
application.invokeAndWait(new Runnable() {
public void run() {
AbstractScriptLabel.super.setIcon(normalIcon);
}
});
} catch (Exception e) {
Debug.error(e);
}
}
}
use of com.servoy.j2db.util.gui.MyImageIcon in project servoy-client by Servoy.
the class AbstractScriptLabel method setRolloverIcon.
public void setRolloverIcon(ImageIcon icon) {
ComponentFactory.deregisterIcon(rolloverIcon);
if (mediaOption != 1 && icon != null) {
rolloverIcon = new MyImageIcon(application, this, icon, mediaOption);
} else {
rolloverIcon = icon;
}
if (rolloverIcon != null)
ComponentFactory.registerIcon(rolloverIcon);
addRolloverListener();
}
Aggregations