use of org.apache.pivot.wtk.media.Image in project pivot by apache.
the class ImageView method setImage.
/**
* Sets the image view's current image.
*
* @param image The image to set, or <tt>null</tt> for no image.
*/
public void setImage(Image image) {
Image previousImage = this.image;
if (previousImage != image) {
this.image = image;
imageViewListeners.imageChanged(this, previousImage);
}
}
use of org.apache.pivot.wtk.media.Image in project pivot by apache.
the class Window method setIcon.
/**
* Sets the window's icon by URL. <p> If the icon already exists in the
* application context resource cache, the cached value will be used.
* Otherwise, the icon will be loaded synchronously and added to the cache.
*
* @param iconURL The location of the icon to set.
*/
public void setIcon(URL iconURL) {
Utils.checkNull(iconURL, "iconURL");
Image icon = Image.loadFromCache(iconURL);
getIcons().remove(0, getIcons().getLength());
getIcons().add(icon);
}
use of org.apache.pivot.wtk.media.Image in project pivot by apache.
the class ListViewItemRenderer method render.
@Override
public void render(Object item, int index, ListView listView, boolean selected, Button.State state, boolean highlighted, boolean disabled) {
renderStyles(listView, selected, highlighted, disabled);
Image icon = null;
String text = null;
if (item instanceof ListItem) {
ListItem listItem = (ListItem) item;
icon = listItem.getIcon();
} else if (item instanceof Image) {
icon = (Image) item;
}
text = toString(item);
imageView.setImage(icon);
label.setText(text != null ? text : "");
}
use of org.apache.pivot.wtk.media.Image in project pivot by apache.
the class LinkButtonDataRenderer method render.
@Override
public void render(Object data, Button button, boolean highlighted) {
Image icon = null;
String text = null;
if (data instanceof BaseContent) {
BaseContent baseContent = (BaseContent) data;
icon = baseContent.getIcon();
} else if (data instanceof Image) {
icon = (Image) data;
}
text = toString(data);
// Update the image view
if (icon == null) {
imageView.setVisible(false);
} else {
imageView.setVisible(true);
imageView.setImage(icon);
imageView.getStyles().put(Style.opacity, button.isEnabled() ? new Float(1.0f) : new Float(0.5f));
}
// Update the label
label.setText(text != null ? text : "");
if (text == null) {
label.setVisible(false);
} else {
label.setVisible(true);
Font font = button.getStyles().getFont(Style.font);
label.getStyles().put(Style.font, font);
Color color;
if (button.isEnabled()) {
color = button.getStyles().getColor(Style.color);
} else {
color = button.getStyles().getColor(Style.disabledColor);
}
label.getStyles().put(Style.color, color);
}
label.getStyles().put(Style.textDecoration, highlighted ? TextDecoration.UNDERLINE : null);
}
use of org.apache.pivot.wtk.media.Image in project pivot by apache.
the class MenuBarItemDataRenderer method render.
@Override
public void render(Object data, Button button, boolean highlighted) {
Image icon = null;
String text = null;
if (data instanceof BaseContent) {
BaseContent baseContent = (BaseContent) data;
icon = baseContent.getIcon();
} else if (data instanceof Image) {
icon = (Image) data;
}
text = toString(data);
// Update the image view
MenuBar.Item menuBarItem = (MenuBar.Item) button;
MenuBar menuBar = (MenuBar) menuBarItem.getParent();
if (icon == null) {
imageView.setVisible(false);
} else {
imageView.setVisible(true);
imageView.setImage(icon);
imageView.getStyles().put(Style.opacity, button.isEnabled() ? 1.0f : 0.5f);
}
// Update the label
label.setText(text != null ? text : "");
if (text == null) {
label.setVisible(false);
} else {
label.setVisible(true);
Font font = menuBar.getStyles().getFont(Style.font);
label.getStyles().put(Style.font, font);
Color color;
if (button.isEnabled()) {
if (highlighted) {
color = menuBar.getStyles().getColor(Style.activeColor);
} else {
color = menuBar.getStyles().getColor(Style.color);
}
} else {
color = menuBar.getStyles().getColor(Style.disabledColor);
}
label.getStyles().put(Style.color, color);
}
}
Aggregations