Search in sources :

Example 1 with Image

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);
    }
}
Also used : Image(org.apache.pivot.wtk.media.Image)

Example 2 with Image

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);
}
Also used : Image(org.apache.pivot.wtk.media.Image)

Example 3 with Image

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 : "");
}
Also used : Image(org.apache.pivot.wtk.media.Image)

Example 4 with Image

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);
}
Also used : Color(java.awt.Color) Image(org.apache.pivot.wtk.media.Image) Font(java.awt.Font)

Example 5 with Image

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);
    }
}
Also used : Color(java.awt.Color) MenuBar(org.apache.pivot.wtk.MenuBar) Image(org.apache.pivot.wtk.media.Image) Font(java.awt.Font)

Aggregations

Image (org.apache.pivot.wtk.media.Image)35 Color (java.awt.Color)8 ImageView (org.apache.pivot.wtk.ImageView)8 Font (java.awt.Font)6 Component (org.apache.pivot.wtk.Component)5 ImageNode (org.apache.pivot.wtk.text.ImageNode)5 Dimensions (org.apache.pivot.wtk.Dimensions)3 Point (org.apache.pivot.wtk.Point)3 BasicStroke (java.awt.BasicStroke)2 Graphics2D (java.awt.Graphics2D)2 IOException (java.io.IOException)2 DragSource (org.apache.pivot.wtk.DragSource)2 DropAction (org.apache.pivot.wtk.DropAction)2 DropTarget (org.apache.pivot.wtk.DropTarget)2 Insets (org.apache.pivot.wtk.Insets)2 LocalManifest (org.apache.pivot.wtk.LocalManifest)2 Manifest (org.apache.pivot.wtk.Manifest)2 AlphaComposite (java.awt.AlphaComposite)1 Composite (java.awt.Composite)1 GradientPaint (java.awt.GradientPaint)1