use of com.servoy.j2db.util.gui.MyImageIcon in project servoy-client by Servoy.
the class AbstractScriptLabel method setRolloverIcon.
public void setRolloverIcon(byte[] data) {
ComponentFactory.deregisterIcon(rolloverIcon);
if (mediaOption != 1 && data != null) {
rolloverIcon = new MyImageIcon(application, this, data, mediaOption);
} else {
rolloverIcon = ImageLoader.getIcon(data, -1, -1, true);
}
if (rolloverIcon != null) {
ComponentFactory.registerIcon(rolloverIcon);
addRolloverListener();
}
}
use of com.servoy.j2db.util.gui.MyImageIcon in project servoy-client by Servoy.
the class AbstractScriptLabel 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 DataImgMediaField method copyToClipboard.
protected void copyToClipboard() {
try {
// we copy to clipboard as byte array and filename/mimetype array used when pasting into another media field and as image icon for external pastes or if byte array is not available (and for external types)
final Icon icon = enclosedComponent.getIcon();
final byte[] bytes = getByteArrayContents(value);
final String[] fileNameAndMime = new String[2];
if (resolver instanceof DataAdapterList) {
DataAdapterList dal = ((DataAdapterList) resolver);
Object tmp = dal.getValueObject(dal.getState(), dataProviderID + IMediaFieldConstants.FILENAME);
fileNameAndMime[0] = (tmp instanceof String) ? (String) tmp : null;
tmp = dal.getValueObject(dal.getState(), dataProviderID + IMediaFieldConstants.MIMETYPE);
fileNameAndMime[1] = (tmp instanceof String) ? (String) tmp : null;
}
if (icon instanceof ImageIcon || icon instanceof MyImageIcon) {
Transferable tr = new Transferable() {
public DataFlavor[] getTransferDataFlavors() {
List<DataFlavor> list = new ArrayList<DataFlavor>(3);
if (bytes != null)
list.add(getByteArrayDataFlavor());
list.add(DataFlavor.imageFlavor);
if (fileNameAndMime[0] != null || fileNameAndMime[1] != null) {
list.add(getStringArrayDataFlavor());
list.add(DataFlavor.stringFlavor);
}
return list.toArray(new DataFlavor[list.size()]);
}
public boolean isDataFlavorSupported(DataFlavor flavor) {
return DataFlavor.imageFlavor.equals(flavor) || (bytes != null && getByteArrayDataFlavor().equals(flavor)) || ((fileNameAndMime[0] != null || fileNameAndMime[1] != null) && (getStringArrayDataFlavor().equals(flavor) || DataFlavor.stringFlavor.equals(flavor)));
}
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
if (!isDataFlavorSupported(flavor)) {
throw new UnsupportedFlavorException(flavor);
}
if (DataFlavor.imageFlavor.equals(flavor)) {
if (icon instanceof ImageIcon) {
return ((ImageIcon) icon).getImage();
} else if (icon instanceof MyImageIcon) {
return ((MyImageIcon) icon).getOriginal().getImage();
}
} else if (getByteArrayDataFlavor().equals(flavor)) {
return bytes;
} else if (getStringArrayDataFlavor().equals(flavor)) {
return fileNameAndMime;
} else if (DataFlavor.stringFlavor.equals(flavor)) {
return (fileNameAndMime[0] != null ? "Filename: '" + fileNameAndMime[0] + "' " : "") + (fileNameAndMime[1] != null ? "Type: '" + fileNameAndMime[1] + "'" : "");
}
return null;
}
};
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(tr, null);
}
} catch (Exception e) {
Debug.error(e);
}
}
use of com.servoy.j2db.util.gui.MyImageIcon in project servoy-client by Servoy.
the class AbstractScriptButton method setIcon.
public void setIcon(byte[] data) {
Icon prevIcon = getIcon();
if (prevIcon instanceof MyImageIcon) {
Icon rollOver = getRolloverIcon();
if (rollOver instanceof MyImageIcon) {
((MyImageIcon) prevIcon).removeImageIcon((MyImageIcon) rollOver);
}
}
ComponentFactory.deregisterIcon(prevIcon);
Icon icon = null;
// media option 1 == crop so no scaling
if (mediaOption != 1 && data != null) {
// do scaling cropping if needed
icon = new MyImageIcon(application, this, data, mediaOption);
Icon rollOver = getRolloverIcon();
if (rollOver instanceof MyImageIcon) {
((MyImageIcon) icon).addImageIcon((MyImageIcon) rollOver);
}
} else {
icon = ImageLoader.getIcon(data, -1, -1, true);
}
ComponentFactory.registerIcon(icon);
super.setIcon(icon);
}
use of com.servoy.j2db.util.gui.MyImageIcon in project servoy-client by Servoy.
the class AbstractScriptButton method setRolloverIcon.
public void setRolloverIcon(byte[] data) {
ComponentFactory.deregisterIcon(getRolloverIcon());
Icon rolloverIcon = null;
// media option 1 == crop so no scaling
if (mediaOption != 1 && data != null) {
// do scaling cropping if needed
rolloverIcon = new MyImageIcon(application, this, data, mediaOption);
Icon icon = getIcon();
if (icon instanceof MyImageIcon) {
((MyImageIcon) icon).addImageIcon((MyImageIcon) rolloverIcon);
}
} else {
rolloverIcon = ImageLoader.getIcon(data, -1, -1, true);
}
super.setRolloverIcon(rolloverIcon);
}
Aggregations