Search in sources :

Example 41 with Name

use of com.codename1.rad.models.Property.Name in project CodenameOne by codenameone.

the class Resources method readTimeline.

Timeline readTimeline(DataInputStream input) throws IOException {
    int duration = input.readInt();
    int width = input.readInt();
    int height = input.readInt();
    AnimationObject[] animations = new AnimationObject[input.readShort()];
    int alen = animations.length;
    for (int iter = 0; iter < alen; iter++) {
        String name = input.readUTF();
        int startTime = input.readInt();
        int animDuration = input.readInt();
        int x = input.readInt();
        int y = input.readInt();
        Image i = getImage(name);
        if (i == null) {
            animations[iter] = AnimationObject.createAnimationImage(name, this, x, y);
        } else {
            animations[iter] = AnimationObject.createAnimationImage(i, x, y);
        }
        animations[iter].setStartTime(startTime);
        animations[iter].setEndTime(startTime + animDuration);
        int frameDelay = input.readInt();
        if (frameDelay > -1) {
            int frameWidth = input.readInt();
            int frameHeight = input.readInt();
            animations[iter].defineFrames(frameWidth, frameHeight, frameDelay);
        }
        if (input.readBoolean()) {
            animations[iter].defineMotionX(input.readInt(), startTime, animDuration, x, input.readInt());
        }
        if (input.readBoolean()) {
            animations[iter].defineMotionY(input.readInt(), startTime, animDuration, y, input.readInt());
        }
        if (input.readBoolean()) {
            animations[iter].defineWidth(input.readInt(), startTime, animDuration, input.readInt(), input.readInt());
        }
        if (input.readBoolean()) {
            animations[iter].defineHeight(input.readInt(), startTime, animDuration, input.readInt(), input.readInt());
        }
        if (input.readBoolean()) {
            animations[iter].defineOpacity(input.readInt(), startTime, animDuration, input.readInt(), input.readInt());
        }
        if (input.readBoolean()) {
            animations[iter].defineOrientation(input.readInt(), startTime, animDuration, input.readInt(), input.readInt());
        }
    }
    Timeline tl = Timeline.createTimeline(duration, animations, new Dimension(width, height));
    return tl;
}
Also used : Timeline(com.codename1.ui.animations.Timeline) AnimationObject(com.codename1.ui.animations.AnimationObject) Dimension(com.codename1.ui.geom.Dimension)

Example 42 with Name

use of com.codename1.rad.models.Property.Name in project CodenameOne by codenameone.

the class LazyValueC method showForm.

/**
 * This method is equivalent to the internal navigation behavior, it adds
 * functionality such as the back command into the given form resource and
 * shows it. If the source command is the back command the showBack() method
 * will run.
 *
 * @param resourceName the name of the resource for the form to show
 * @param sourceCommand the command of the resource (may be null)
 * @return the form thats being shown, notice that you can still manipulate
 * some states of the form before it actually appears
 */
public Form showForm(String resourceName, Command sourceCommand) {
    Form f = (Form) createContainer(fetchResourceFile(), resourceName);
    showForm(f, sourceCommand, null);
    return f;
}
Also used : Form(com.codename1.ui.Form)

Example 43 with Name

use of com.codename1.rad.models.Property.Name in project CodenameOne by codenameone.

the class Table method getPropertyValue.

/**
 * {@inheritDoc}
 */
public Object getPropertyValue(String name) {
    if (name.equals("data")) {
        String[][] result = new String[((DefaultTableModel) model).data.size()][];
        for (int iter = 0; iter < result.length; iter++) {
            Object[] o = ((DefaultTableModel) model).data.get(iter);
            String[] arr = new String[o.length];
            result[iter] = arr;
            for (int ai = 0; ai < arr.length; ai++) {
                Object current = o[ai];
                if (current instanceof String) {
                    arr[ai] = (String) current;
                } else {
                    if (current != null) {
                        arr[iter] = current.toString();
                    }
                }
            }
        }
        return result;
    }
    if (name.equals("header")) {
        return ((DefaultTableModel) model).columnNames;
    }
    return null;
}
Also used : Constraint(com.codename1.ui.validation.Constraint)

Example 44 with Name

use of com.codename1.rad.models.Property.Name in project CodenameOne by codenameone.

the class LazyValueC method createComponentType.

Component createComponentType(String name) throws IllegalAccessException, InstantiationException, RuntimeException {
    Class c = (Class) getComponentRegistry().get(name);
    Component cmp = createComponentInstance(name, c);
    if (cmp == null) {
        if (c == null) {
            throw new RuntimeException("Component not found use UIBuilder.registerCustomComponent(" + name + ", class);");
        }
        cmp = (Component) c.newInstance();
    }
    return cmp;
}
Also used : Component(com.codename1.ui.Component)

Example 45 with Name

use of com.codename1.rad.models.Property.Name in project CodenameOne by codenameone.

the class LazyValueC method postCreateComponents.

/**
 * Invoked after the components were created to allow properties that require the entire
 * tree to exist to update the component. This is useful for properties that point
 * at other components.
 */
private void postCreateComponents(DataInputStream in, Container parent, Resources res) throws Exception {
    // finds the component whose properties need to update
    String name = in.readUTF();
    Component lastComponent = null;
    while (name.length() > 0) {
        if (lastComponent == null || !lastComponent.getName().equals(name)) {
            lastComponent = findByName(name, parent);
        }
        Component c = lastComponent;
        int property = in.readInt();
        modifyingProperty(c, property);
        switch(property) {
            case PROPERTY_COMMAND_LEGACY:
                {
                    readCommand(in, c, parent, res, true);
                    break;
                }
            case PROPERTY_COMMAND:
                {
                    readCommand(in, c, parent, res, false);
                    break;
                }
            case PROPERTY_LABEL_FOR:
                c.setLabelForComponent((Label) findByName(in.readUTF(), parent));
                break;
            case PROPERTY_LEAD_COMPONENT:
                ((Container) c).setLeadComponent(findByName(in.readUTF(), parent));
                break;
            case PROPERTY_NEXT_FOCUS_UP:
                c.setNextFocusUp(findByName(in.readUTF(), parent));
                break;
            case PROPERTY_NEXT_FOCUS_DOWN:
                c.setNextFocusDown(findByName(in.readUTF(), parent));
                break;
            case PROPERTY_NEXT_FOCUS_LEFT:
                c.setNextFocusLeft(findByName(in.readUTF(), parent));
                break;
            case PROPERTY_NEXT_FOCUS_RIGHT:
                c.setNextFocusRight(findByName(in.readUTF(), parent));
                break;
        }
        name = in.readUTF();
    }
}
Also used : Container(com.codename1.ui.Container) Component(com.codename1.ui.Component)

Aggregations

IOException (java.io.IOException)36 Component (com.codename1.ui.Component)17 Hashtable (java.util.Hashtable)17 ArrayList (java.util.ArrayList)16 AnimationObject (com.codename1.ui.animations.AnimationObject)15 File (java.io.File)14 Form (com.codename1.ui.Form)13 ByteArrayInputStream (java.io.ByteArrayInputStream)13 FileInputStream (java.io.FileInputStream)13 InputStream (java.io.InputStream)12 Label (com.codename1.ui.Label)11 Button (com.codename1.ui.Button)10 Container (com.codename1.ui.Container)10 EncodedImage (com.codename1.ui.EncodedImage)10 TextArea (com.codename1.ui.TextArea)10 BorderLayout (com.codename1.ui.layouts.BorderLayout)10 Point (java.awt.Point)10 FileOutputStream (java.io.FileOutputStream)10 Paint (android.graphics.Paint)8 BufferedInputStream (com.codename1.io.BufferedInputStream)7