Search in sources :

Example 1 with Label

use of com.codename1.ui.Label in project codenameone-google-maps by codenameone.

the class MapInfoPanel method createMarkerButton.

private Button createMarkerButton(MapObject mo, String label, Image icon, final Coord location) {
    Button b = new Button(label, icon);
    b.addActionListener(e -> {
        map.zoom(location, (int) map.getZoom());
    });
    return b;
}
Also used : Button(com.codename1.ui.Button)

Example 2 with Label

use of com.codename1.ui.Label in project codenameone-google-maps by codenameone.

the class MapInfoPanel method styleLabels.

private void styleLabels(Component... roots) {
    for (Component c : roots) {
        if (c instanceof Label) {
            Label l = (Label) c;
            l.getAllStyles().setFgColor(0xffffff);
            l.getAllStyles().setBgTransparency(0);
            l.getAllStyles().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL));
        }
        if (c instanceof Container) {
            Container cnt = (Container) c;
            for (Component child : cnt) {
                styleLabels(child);
            }
        }
    }
}
Also used : Container(com.codename1.ui.Container) MapContainer(com.codename1.googlemaps.MapContainer) Label(com.codename1.ui.Label) Component(com.codename1.ui.Component)

Example 3 with Label

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

the class GenericListCellRenderer method findComponentsOfInterest.

private void findComponentsOfInterest(Component cmp, ArrayList dest) {
    if (cmp instanceof Container) {
        Container c = (Container) cmp;
        int count = c.getComponentCount();
        for (int iter = 0; iter < count; iter++) {
            findComponentsOfInterest(c.getComponentAt(iter), dest);
        }
        return;
    }
    // performance optimization for fixed images in lists
    if (cmp.getName() != null) {
        if (cmp instanceof Label) {
            Label l = (Label) cmp;
            if (l.getName().toLowerCase().endsWith("fixed") && l.getIcon() != null) {
                l.getIcon().lock();
            }
            dest.add(cmp);
            return;
        }
        if (cmp instanceof TextArea) {
            dest.add(cmp);
            return;
        }
    }
}
Also used : Container(com.codename1.ui.Container) TextArea(com.codename1.ui.TextArea) Label(com.codename1.ui.Label)

Example 4 with Label

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

the class GenericListCellRenderer method setComponentValue.

/**
 * Initializes the given component with the given value
 *
 * @param cmp one of the components that is or is a part of the renderer
 * @param value the value to install into the component
 */
private void setComponentValue(Component cmp, Object value, Component parent, Component rootRenderer) {
    // process so renderer selected/unselected styles are applied
    if (cmp.getName().toLowerCase().endsWith("fixed")) {
        return;
    }
    if (cmp instanceof Label) {
        if (value instanceof Image) {
            Image i = (Image) value;
            if (i.isAnimation()) {
                if (pendingAnimations == null) {
                    pendingAnimations = new ArrayList<Image>();
                }
                if (!pendingAnimations.contains(i)) {
                    pendingAnimations.add(i);
                    if (parentList == null) {
                        parentList = parent;
                    }
                    if (parentList != null) {
                        Form f = parentList.getComponentForm();
                        if (f != null) {
                            f.registerAnimated(mon);
                            waitingForRegisterAnimation = false;
                        } else {
                            waitingForRegisterAnimation = true;
                        }
                    }
                } else {
                    if (waitingForRegisterAnimation) {
                        if (parentList != null) {
                            Form f = parentList.getComponentForm();
                            if (f != null) {
                                f.registerAnimated(mon);
                                waitingForRegisterAnimation = false;
                            }
                        }
                    }
                }
            }
            Image oldImage = ((Label) cmp).getIcon();
            ((Label) cmp).setIcon(i);
            ((Label) cmp).setText("");
            if (oldImage == null || oldImage.getWidth() != i.getWidth() || oldImage.getHeight() != i.getHeight()) {
                ((Container) rootRenderer).revalidate();
            }
            return;
        } else {
            ((Label) cmp).setIcon(null);
        }
        if (cmp instanceof CheckBox) {
            ((CheckBox) cmp).setSelected(isSelectedValue(value));
            return;
        }
        if (cmp instanceof RadioButton) {
            ((RadioButton) cmp).setSelected(isSelectedValue(value));
            return;
        }
        if (cmp instanceof Slider) {
            ((Slider) cmp).setProgress(((Integer) value).intValue());
            return;
        }
        Label l = (Label) cmp;
        if (value == null) {
            l.setText("");
        } else {
            if (value instanceof Label) {
                l.setText(((Label) value).getText());
                l.setIcon(((Label) value).getIcon());
            } else {
                l.setText(value.toString());
            }
        }
        if (firstCharacterRTL) {
            String t = l.getText();
            if (t.length() > 0) {
                l.setRTL(Display.getInstance().isRTL(t.charAt(0)));
            }
        }
        return;
    }
    if (cmp instanceof TextArea) {
        if (value == null) {
            ((TextArea) cmp).setText("");
        } else {
            ((TextArea) cmp).setText(value.toString());
        }
    }
}
Also used : Container(com.codename1.ui.Container) Slider(com.codename1.ui.Slider) Form(com.codename1.ui.Form) TextArea(com.codename1.ui.TextArea) CheckBox(com.codename1.ui.CheckBox) Label(com.codename1.ui.Label) RadioButton(com.codename1.ui.RadioButton) Image(com.codename1.ui.Image) EncodedImage(com.codename1.ui.EncodedImage) URLImage(com.codename1.ui.URLImage)

Example 5 with Label

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

the class GenericListCellRenderer method setComponentValueWithTickering.

private void setComponentValueWithTickering(Component cmp, Object value, Component l, Component rootRenderer) {
    setComponentValue(cmp, value, l, rootRenderer);
    if (cmp instanceof Label) {
        if (selectionListener) {
            if (l instanceof List) {
                ((List) l).addActionListener(mon);
            }
            parentList = l;
        }
        Label label = (Label) cmp;
        if (label.shouldTickerStart() && Display.getInstance().shouldRenderSelection()) {
            if (!label.isTickerRunning()) {
                parentList = l;
                if (parentList != null) {
                    Form f = parentList.getComponentForm();
                    if (f != null) {
                        f.registerAnimated(mon);
                        label.startTicker(cmp.getUIManager().getLookAndFeel().getTickerSpeed(), true);
                    }
                }
            }
        } else {
            if (label.isTickerRunning()) {
                label.stopTicker();
            }
            label.setTextPosition(0);
        }
    }
}
Also used : Form(com.codename1.ui.Form) Label(com.codename1.ui.Label) List(com.codename1.ui.List) ArrayList(java.util.ArrayList)

Aggregations

Label (com.codename1.ui.Label)41 BorderLayout (com.codename1.ui.layouts.BorderLayout)22 Container (com.codename1.ui.Container)21 Component (com.codename1.ui.Component)16 Form (com.codename1.ui.Form)15 Button (com.codename1.ui.Button)14 TextArea (com.codename1.ui.TextArea)14 Style (com.codename1.ui.plaf.Style)13 ActionListener (com.codename1.ui.events.ActionListener)12 ActionEvent (com.codename1.ui.events.ActionEvent)11 Image (com.codename1.ui.Image)10 Dimension (com.codename1.ui.geom.Dimension)10 Vector (java.util.Vector)10 BoxLayout (com.codename1.ui.layouts.BoxLayout)9 EncodedImage (com.codename1.ui.EncodedImage)8 RadioButton (com.codename1.ui.RadioButton)7 LayeredLayout (com.codename1.ui.layouts.LayeredLayout)6 Hashtable (java.util.Hashtable)6 Paint (com.codename1.charts.compat.Paint)5 Font (com.codename1.ui.Font)5