Search in sources :

Example 41 with Label

use of com.vaadin.v7.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 42 with Label

use of com.vaadin.v7.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 43 with Label

use of com.vaadin.v7.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)

Example 44 with Label

use of com.vaadin.v7.ui.Label in project CodenameOne by codenameone.

the class InfiniteContainerSafeAreaTest method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("InfiniteContainer", new BorderLayout());
    Style s = UIManager.getInstance().getComponentStyle("MultiLine1");
    FontImage p = FontImage.createMaterial(FontImage.MATERIAL_PORTRAIT, s);
    EncodedImage placeholder = EncodedImage.createFromImage(p.scaled(p.getWidth() * 3, p.getHeight() * 3), false);
    InfiniteContainer ic = new InfiniteContainer() {

        @Override
        public Component[] fetchComponents(int index, int amount) {
            java.util.List<Map<String, Object>> data = fetchPropertyData("Leeds");
            MultiButton[] cmps = new MultiButton[data.size()];
            for (int iter = 0; iter < cmps.length; iter++) {
                Map<String, Object> currentListing = data.get(iter);
                if (currentListing == null) {
                    return null;
                }
                String thumb_url = (String) currentListing.get("thumb_url");
                String guid = (String) currentListing.get("guid");
                String summary = (String) currentListing.get("summary");
                cmps[iter] = new MultiButton(summary);
            // cmps[iter].setIcon(URLImage.createToStorage(placeholder, guid, thumb_url));
            }
            return cmps;
        }
    };
    ic.setUIID("Blue");
    ic.setSafeArea(true);
    ic.addComponent(new Label("This is a test"));
    hi.add(BorderLayout.CENTER, ic);
    hi.show();
}
Also used : Form(com.codename1.ui.Form) Label(com.codename1.ui.Label) Style(com.codename1.ui.plaf.Style) MultiButton(com.codename1.components.MultiButton) HashMap(java.util.HashMap) Map(java.util.Map)

Example 45 with Label

use of com.vaadin.v7.ui.Label in project CodenameOne by codenameone.

the class LandscapeToolbarHiddenSample method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Test 2387", BoxLayout.y());
    hi.add(new Label("Hi World"));
    if (!CN.isPortrait()) {
        hi.getToolbar().hideToolbar();
    }
    Button hide = new Button("Hide");
    Button show = new Button("Show");
    hide.addActionListener(e -> hi.getToolbar().hideToolbar());
    show.addActionListener(e -> hi.getToolbar().showToolbar());
    hi.addOrientationListener(e -> {
        if (CN.isPortrait()) {
            hi.getToolbar().showToolbar();
        } else {
            hi.getToolbar().hideToolbar();
        }
    });
    hi.addAll(hide, show);
    hi.show();
}
Also used : Form(com.codename1.ui.Form) Button(com.codename1.ui.Button) Label(com.codename1.ui.Label)

Aggregations

Label (com.codename1.ui.Label)129 Form (com.codename1.ui.Form)85 Label (com.vaadin.ui.Label)56 Container (com.codename1.ui.Container)45 Button (com.codename1.ui.Button)41 Label (com.vaadin.v7.ui.Label)40 TextField (com.vaadin.v7.ui.TextField)32 BorderLayout (com.codename1.ui.layouts.BorderLayout)31 Button (com.vaadin.ui.Button)31 ComboBox (com.vaadin.v7.ui.ComboBox)31 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)31 Captions (de.symeda.sormas.api.i18n.Captions)29 Strings (de.symeda.sormas.api.i18n.Strings)28 VerticalLayout (com.vaadin.ui.VerticalLayout)26 FacadeProvider (de.symeda.sormas.api.FacadeProvider)26 HorizontalLayout (com.vaadin.ui.HorizontalLayout)24 Window (com.vaadin.ui.Window)24 CssStyles (de.symeda.sormas.ui.utils.CssStyles)24 ValoTheme (com.vaadin.ui.themes.ValoTheme)21 List (java.util.List)21