Search in sources :

Example 1 with FontImage

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

the class DefaultLookAndFeel method updateRadioButtonConstants.

private void updateRadioButtonConstants(UIManager m, boolean focus, String append) {
    Image radioSel = m.getThemeImageConstant("radioSelected" + append + "Image");
    if (radioSel != null) {
        Image radioUnsel = m.getThemeImageConstant("radioUnselected" + append + "Image");
        if (radioUnsel != null) {
            Image disUnsel = m.getThemeImageConstant("radioUnselectedDis" + append + "Image");
            Image disSel = m.getThemeImageConstant("radioSelectedDis" + append + "Image");
            if (disUnsel == null) {
                disUnsel = radioUnsel;
            }
            if (disSel == null) {
                disSel = radioSel;
            }
            if (focus) {
                setRadioButtonFocusImages(radioSel, radioUnsel, disSel, disUnsel);
            } else {
                setRadioButtonImages(radioSel, radioUnsel, disSel, disUnsel);
            }
        }
    } else {
        if (!Font.isTrueTypeFileSupported()) {
            return;
        }
        UIManager uim = UIManager.getInstance();
        Style unsel = uim.createStyle("RadioButton.", "", false);
        Style sel = uim.createStyle("RadioButton.", "sel#", true);
        Style dis = uim.createStyle("RadioButton.", "dis#", false);
        FontImage checkedDis = FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_CHECKED, dis);
        FontImage uncheckedDis = FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_UNCHECKED, sel);
        if (focus) {
            FontImage checkedSelected = FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_CHECKED, sel);
            FontImage uncheckedSelected = FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_UNCHECKED, sel);
            setRadioButtonFocusImages(checkedSelected, uncheckedSelected, checkedDis, uncheckedDis);
        } else {
            FontImage checkedUnselected = FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_CHECKED, unsel);
            FontImage uncheckedUnselected = FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_UNCHECKED, unsel);
            setRadioButtonImages(checkedUnselected, uncheckedUnselected, checkedDis, uncheckedDis);
        }
    }
}
Also used : Image(com.codename1.ui.Image) FontImage(com.codename1.ui.FontImage) FontImage(com.codename1.ui.FontImage)

Example 2 with FontImage

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

the class InfiniteProgress method paint.

/**
 * {@inheritDoc}
 */
public void paint(Graphics g) {
    if (this.getComponentForm() != null && Display.getInstance().getCurrent() != this.getComponentForm()) {
        return;
    }
    super.paint(g);
    if (animation == null) {
        return;
    }
    int v = angle % 360;
    Style s = getStyle();
    /*if(g.isAffineSupported()) {
            g.rotate(((float)v) / 57.2957795f, getAbsoluteX() + s.getPadding(LEFT) + getWidth() / 2, getAbsoluteY() + s.getPadding(TOP) + getHeight() / 2);
            g.drawImage(getAnimation(), getX() + s.getPadding(LEFT), getY() + s.getPadding(TOP));
            g.resetAffine();
        } else {*/
    Image rotated;
    if (animation instanceof FontImage) {
        rotated = animation.rotate(v);
    } else {
        Integer angle = new Integer(v);
        rotated = cache.get(angle);
        if (rotated == null) {
            rotated = animation.rotate(v);
            cache.put(v, rotated);
        }
    }
    g.drawImage(rotated, getX() + s.getPaddingLeftNoRTL(), getY() + s.getPaddingTop());
// }
}
Also used : Style(com.codename1.ui.plaf.Style) Image(com.codename1.ui.Image) FontImage(com.codename1.ui.FontImage) FontImage(com.codename1.ui.FontImage)

Example 3 with FontImage

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

the class ComponentSelector method setIcon.

/**
 * Sets the icon of all elements in this set to a material icon.  This will use
 * the foreground color of each label as the icon's foreground color.
 * @param materialIcon The icon charcode.
 * @param size The size of the icon (in mm)
 * @return Self for chaining
 * @see FontImage#createMaterial(char, com.codename1.ui.plaf.Style, float)
 */
public ComponentSelector setIcon(char materialIcon, float size) {
    for (Component c : this) {
        if (c instanceof Label) {
            Label l = (Label) c;
            Style style = new Style();
            Style cStyle = c.getUnselectedStyle();
            style.setBgTransparency(0);
            style.setFgColor(cStyle.getFgColor());
            l.setIcon(FontImage.createMaterial(materialIcon, style, size));
            if (c instanceof Button) {
                Button b = (Button) c;
                style = new Style();
                cStyle = c.getPressedStyle();
                style.setBgTransparency(0);
                style.setFgColor(cStyle.getFgColor());
                b.setPressedIcon(FontImage.createMaterial(materialIcon, style, size));
            }
        }
    }
    return this;
}
Also used : SpanButton(com.codename1.components.SpanButton) SpanLabel(com.codename1.components.SpanLabel) Style(com.codename1.ui.plaf.Style)

Example 4 with FontImage

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

the class FloatingActionButton method styleChanged.

/**
 * We override this method to track style changes to the background color and map them to the border
 *
 * {@inheritDoc}
 */
@Override
public void styleChanged(String propertyName, Style source) {
    if (propertyName.equals(Style.BG_COLOR)) {
        updateBorder();
    }
    if (getIcon() instanceof FontImage && propertyName.equals(Style.FG_COLOR)) {
        FontImage i = (FontImage) getIcon();
        FontImage image = FontImage.createMaterial(i.getText().charAt(0), "FloatingActionButton", sizeMm);
        setIcon(image);
    }
}
Also used : FontImage(com.codename1.ui.FontImage)

Example 5 with FontImage

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

the class FloatingActionButton method setUIID.

/**
 * Overriden to update the icon
 * {@inheritDoc}
 */
@Override
public void setUIID(String id) {
    super.setUIID(id);
    FontImage i = (FontImage) getIcon();
    if (i != null) {
        Style all = getAllStyles();
        all.setAlignment(CENTER);
        updateBorder();
        FontImage image = FontImage.createMaterial(i.getText().charAt(0), id, sizeMm);
        setIcon(image);
    }
}
Also used : Style(com.codename1.ui.plaf.Style) FontImage(com.codename1.ui.FontImage)

Aggregations

FontImage (com.codename1.ui.FontImage)7 Style (com.codename1.ui.plaf.Style)6 Image (com.codename1.ui.Image)3 FloatingActionButton (com.codename1.components.FloatingActionButton)1 InteractionDialog (com.codename1.components.InteractionDialog)1 SpanButton (com.codename1.components.SpanButton)1 SpanLabel (com.codename1.components.SpanLabel)1 ToastBar (com.codename1.components.ToastBar)1 MapContainer (com.codename1.googlemaps.MapContainer)1 MapObject (com.codename1.googlemaps.MapContainer.MapObject)1 Util (com.codename1.io.Util)1 BoundingBox (com.codename1.maps.BoundingBox)1 Coord (com.codename1.maps.Coord)1 MapListener (com.codename1.maps.MapListener)1 Button (com.codename1.ui.Button)1 Component (com.codename1.ui.Component)1 ComponentSelector.$ (com.codename1.ui.ComponentSelector.$)1 Container (com.codename1.ui.Container)1 Display (com.codename1.ui.Display)1 EncodedImage (com.codename1.ui.EncodedImage)1