Search in sources :

Example 96 with Image

use of com.codename1.ui.Image in project CodenameOne by codenameone.

the class MultiButton method setCheckBox.

/**
 * Turns the multi-button into a checkbox multi-button
 *
 * @param b true for a checkbox multi-button
 */
public void setCheckBox(boolean b) {
    if (b != isCheckBox()) {
        Container par = emblem.getParent();
        Button old = emblem;
        if (b) {
            emblem = new CheckBox();
        } else {
            emblem = new Button();
        }
        emblem.setUIID(old.getUIID());
        emblem.setName(old.getName());
        java.util.List actionListeners = (java.util.List) old.getListeners();
        if (actionListeners != null) {
            for (int iter = 0; iter < actionListeners.size(); iter++) {
                emblem.addActionListener((ActionListener) actionListeners.get(iter));
            }
        }
        if (old.getCommand() != null) {
            Image img = old.getIcon();
            emblem.setCommand(old.getCommand());
            emblem.setText("");
            emblem.setIcon(img);
        } else {
            emblem.setText(old.getText());
            if (old.getIcon() != null) {
                emblem.setIcon(old.getIcon());
            }
        }
        par.replace(old, emblem, null);
        setLeadComponent(emblem);
    }
}
Also used : Container(com.codename1.ui.Container) RadioButton(com.codename1.ui.RadioButton) Button(com.codename1.ui.Button) CheckBox(com.codename1.ui.CheckBox) Image(com.codename1.ui.Image)

Example 97 with Image

use of com.codename1.ui.Image in project CodenameOne by codenameone.

the class MultiButton method setRadioButton.

/**
 * Turns the multi-button into a radio multi-button
 *
 * @param b true for a radio multi-button
 */
public void setRadioButton(boolean b) {
    if (b != isRadioButton()) {
        Container par = emblem.getParent();
        Button old = emblem;
        if (b) {
            emblem = new RadioButton();
            if (group != null) {
                ((RadioButton) emblem).setGroup(group);
            }
        } else {
            emblem = new Button();
        }
        emblem.setName(old.getName());
        emblem.setUIID(old.getUIID());
        java.util.List actionListeners = (java.util.List) old.getListeners();
        if (actionListeners != null) {
            for (int iter = 0; iter < actionListeners.size(); iter++) {
                emblem.addActionListener((ActionListener) actionListeners.get(iter));
            }
        }
        if (old.getCommand() != null) {
            Image img = old.getIcon();
            emblem.setCommand(old.getCommand());
            emblem.setText("");
            emblem.setIcon(img);
        }
        par.replace(old, emblem, null);
        setLeadComponent(emblem);
        emblem.setShowEvenIfBlank(true);
    }
}
Also used : Container(com.codename1.ui.Container) RadioButton(com.codename1.ui.RadioButton) Button(com.codename1.ui.Button) RadioButton(com.codename1.ui.RadioButton) Image(com.codename1.ui.Image)

Example 98 with Image

use of com.codename1.ui.Image in project CodenameOne by codenameone.

the class ScaleImageLabel method calcPreferredSize.

/**
 * {@inheritDoc}
 */
@Override
protected Dimension calcPreferredSize() {
    Image i = getIcon();
    if (i == null) {
        return new Dimension();
    }
    int dw = Display.getInstance().getDisplayWidth();
    int iw = i.getWidth();
    int ih = i.getHeight();
    // a scrollable container the vertical height might be granted providing so much space as to make this unrealistic...
    if (iw > dw) {
        float ratio = ((float) iw) / ((float) dw);
        iw = (int) (((float) iw) / ((float) ratio));
        ih = (int) (((float) ih) / ((float) ratio));
    }
    Style s = getStyle();
    return new Dimension(iw + s.getPaddingLeftNoRTL() + s.getPaddingRightNoRTL(), ih + s.getPaddingTop() + s.getPaddingBottom());
}
Also used : Style(com.codename1.ui.plaf.Style) Dimension(com.codename1.ui.geom.Dimension) Image(com.codename1.ui.Image)

Example 99 with Image

use of com.codename1.ui.Image in project CodenameOne by codenameone.

the class ScaleImageLabel method refreshTheme.

@Override
protected void refreshTheme(String id, boolean merge) {
    byte type = getBackgroundType();
    Image icon = getIcon();
    super.refreshTheme(id, merge);
    setIcon(icon);
    getAllStyles().setBackgroundType(type);
}
Also used : Image(com.codename1.ui.Image)

Example 100 with Image

use of com.codename1.ui.Image in project CodenameOne by codenameone.

the class ScaleImageButton method refreshTheme.

@Override
protected void refreshTheme(String id, boolean merge) {
    byte type = getBackgroundType();
    Image icon = getIcon();
    super.refreshTheme(id, merge);
    setIcon(icon);
    getAllStyles().setBackgroundType(type);
    getAllStyles().setBgTransparency(255);
}
Also used : Image(com.codename1.ui.Image)

Aggregations

Image (com.codename1.ui.Image)82 EncodedImage (com.codename1.ui.EncodedImage)46 IOException (java.io.IOException)29 Hashtable (java.util.Hashtable)19 AnimationObject (com.codename1.ui.animations.AnimationObject)18 BufferedImage (java.awt.image.BufferedImage)18 Style (com.codename1.ui.plaf.Style)16 Form (com.codename1.ui.Form)15 ActionEvent (com.codename1.ui.events.ActionEvent)14 Dimension (com.codename1.ui.geom.Dimension)14 FontImage (com.codename1.ui.FontImage)13 BorderLayout (com.codename1.ui.layouts.BorderLayout)13 Timeline (com.codename1.ui.animations.Timeline)12 ActionListener (com.codename1.ui.events.ActionListener)12 Border (com.codename1.ui.plaf.Border)12 Container (com.codename1.ui.Container)11 InputStream (java.io.InputStream)11 Graphics (com.codename1.ui.Graphics)10 Label (com.codename1.ui.Label)10 Button (com.codename1.ui.Button)9