Search in sources :

Example 1 with MyImageIcon

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>();
}
Also used : MyImageIcon(com.servoy.j2db.util.gui.MyImageIcon) ImageIcon(javax.swing.ImageIcon) IStyleSheet(com.servoy.j2db.util.IStyleSheet) Style(com.servoy.j2db.persistence.Style) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) MyImageIcon(com.servoy.j2db.util.gui.MyImageIcon) ImageIcon(javax.swing.ImageIcon) Icon(javax.swing.Icon) MyImageIcon(com.servoy.j2db.util.gui.MyImageIcon)

Example 2 with MyImageIcon

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();
}
Also used : ImageIcon(javax.swing.ImageIcon) MyImageIcon(com.servoy.j2db.util.gui.MyImageIcon) IconUIResource(javax.swing.plaf.IconUIResource) MyImageIcon(com.servoy.j2db.util.gui.MyImageIcon)

Example 3 with MyImageIcon

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);
}
Also used : ImageIcon(javax.swing.ImageIcon) MyImageIcon(com.servoy.j2db.util.gui.MyImageIcon) ImageIcon(javax.swing.ImageIcon) MyImageIcon(com.servoy.j2db.util.gui.MyImageIcon) Icon(javax.swing.Icon) MyImageIcon(com.servoy.j2db.util.gui.MyImageIcon)

Example 4 with MyImageIcon

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);
        }
    }
}
Also used : MyImageIcon(com.servoy.j2db.util.gui.MyImageIcon) ImageIcon(javax.swing.ImageIcon) MyImageIcon(com.servoy.j2db.util.gui.MyImageIcon)

Example 5 with MyImageIcon

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();
}
Also used : MyImageIcon(com.servoy.j2db.util.gui.MyImageIcon)

Aggregations

MyImageIcon (com.servoy.j2db.util.gui.MyImageIcon)14 ImageIcon (javax.swing.ImageIcon)11 Icon (javax.swing.Icon)5 ServoyJSONObject (com.servoy.j2db.util.ServoyJSONObject)3 IconUIResource (javax.swing.plaf.IconUIResource)2 DataAdapterList (com.servoy.j2db.dataprocessing.DataAdapterList)1 Style (com.servoy.j2db.persistence.Style)1 IStyleSheet (com.servoy.j2db.util.IStyleSheet)1 JpegEncoder (com.servoy.j2db.util.gui.JpegEncoder)1 Image (java.awt.Image)1 DataFlavor (java.awt.datatransfer.DataFlavor)1 Transferable (java.awt.datatransfer.Transferable)1 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1