Search in sources :

Example 11 with Val

use of com.codename1.ui.util.xml.Val in project CodenameOne by codenameone.

the class AnimationObjectEditor method getAnimationObject.

public AnimationObject getAnimationObject() {
    int x = ((Number) startX.getValue()).intValue();
    int y = ((Number) startY.getValue()).intValue();
    AnimationObject anim = AnimationObject.createAnimationImage(res.getImage((String) image.getSelectedItem()), x, y);
    anim.setStartTime(val(startTime));
    anim.setEndTime(val(duration) + val(startTime));
    if (xCheck.isSelected()) {
        anim.defineMotionX(motionTypeX.getSelectedIndex() + 1, val(startTime), val(duration), val(startX), val(destX));
    }
    if (yCheck.isSelected()) {
        anim.defineMotionY(motionTypeY.getSelectedIndex() + 1, val(startTime), val(duration), val(startY), val(destY));
    }
    if (widthCheck.isSelected()) {
        anim.defineWidth(motionTypeWidth.getSelectedIndex() + 1, val(startTime), val(duration), val(startWidth), val(destWidth));
    }
    if (heightCheck.isSelected()) {
        anim.defineHeight(motionTypeHeight.getSelectedIndex() + 1, val(startTime), val(duration), val(startHeight), val(destHeight));
    }
    if (opacityCheck.isSelected()) {
        anim.defineOpacity(motionTypeOpacity.getSelectedIndex() + 1, val(startTime), val(duration), val(startOpacity), val(destOpacity));
    }
    if (orientationCheck.isSelected()) {
        anim.defineOrientation(motionTypeOrientation.getSelectedIndex() + 1, val(startTime), val(duration), val(startOrientation), val(destOrientation));
    }
    if (val(frameDelay) > -1) {
        anim.defineFrames(val(frameWidth), val(frameHeight), val(frameDelay));
    }
    return anim;
}
Also used : AnimationObject(com.codename1.ui.animations.AnimationObject)

Example 12 with Val

use of com.codename1.ui.util.xml.Val in project CodenameOne by codenameone.

the class CodenameOneImplementation method getStorageEntrySize.

/**
 * Returns the size of the entry in bytes
 * @param name the entry name
 * @return the size
 */
public int getStorageEntrySize(String name) {
    long size = -1;
    try {
        InputStream i = createStorageInputStream(name);
        long val = i.skip(1000000);
        if (val > -1) {
            size = 0;
            while (val > -1) {
                size += val;
                val = i.skip(1000000);
            }
        }
        Util.cleanup(i);
    } catch (IOException err) {
        Log.e(err);
    }
    return (int) size;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) DataInputStream(java.io.DataInputStream) TarInputStream(com.codename1.io.tar.TarInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException)

Example 13 with Val

use of com.codename1.ui.util.xml.Val in project CodenameOne by codenameone.

the class Oauth2 method createLoginComponent.

private Component createLoginComponent(final ActionListener al, final Form frm, final Form backToForm, final Dialog progress) {
    String URL = oauth2URL + "?client_id=" + clientId + "&redirect_uri=" + Util.encodeUrl(redirectURI);
    if (scope != null) {
        URL += "&scope=" + scope;
    }
    if (clientSecret != null) {
        URL += "&response_type=code";
    } else {
        URL += "&response_type=token";
    }
    if (additionalParams != null) {
        Enumeration e = additionalParams.keys();
        while (e.hasMoreElements()) {
            String key = (String) e.nextElement();
            String val = additionalParams.get(key).toString();
            URL += "&" + key + "=" + val;
        }
    }
    DocumentInfo.setDefaultEncoding(DocumentInfo.ENCODING_UTF8);
    final WebBrowser[] web = new WebBrowser[1];
    web[0] = new WebBrowser() {

        @Override
        public void onLoad(String url) {
            handleURL(url, this, al, frm, backToForm, progress);
        }

        public void onStart(String url) {
        }
    };
    web[0].setURL(URL);
    return web[0];
}
Also used : Enumeration(java.util.Enumeration) WebBrowser(com.codename1.components.WebBrowser)

Example 14 with Val

use of com.codename1.ui.util.xml.Val in project CodenameOne by codenameone.

the class BlackBerryCanvas method getMenu.

public Menu getMenu(int val) {
    if (Display.getInstance().getCommandBehavior() == Display.COMMAND_BEHAVIOR_NATIVE) {
        m = new Menu();
        if (commands != null) {
            for (int iter = 0; iter < commands.size(); iter++) {
                final Command cmd = (Command) commands.elementAt(iter);
                String txt = UIManager.getInstance().localize(cmd.getCommandName(), cmd.getCommandName());
                MenuItem i = new MenuItem(txt, iter, iter) {

                    public void run() {
                        Display.getInstance().callSerially(new Runnable() {

                            public void run() {
                                impl.getCurrentForm().dispatchCommand(cmd, new ActionEvent(cmd));
                            }
                        });
                    }
                };
                m.add(i);
            }
        }
        return m;
    }
    return super.getMenu(val);
}
Also used : Command(com.codename1.ui.Command) ActionEvent(com.codename1.ui.events.ActionEvent) MenuItem(net.rim.device.api.ui.MenuItem) Menu(net.rim.device.api.ui.component.Menu)

Example 15 with Val

use of com.codename1.ui.util.xml.Val in project CodenameOne by codenameone.

the class TimeChart method getXLabels.

@Override
protected List<Double> getXLabels(double min, double max, int count) {
    final List<Double> result = new ArrayList<Double>();
    if (!mRenderer.isXRoundedLabels()) {
        if (mDataset.getSeriesCount() > 0) {
            XYSeries series = mDataset.getSeriesAt(0);
            int length = series.getItemCount();
            int intervalLength = 0;
            int startIndex = -1;
            for (int i = 0; i < length; i++) {
                double value = series.getX(i);
                if (min <= value && value <= max) {
                    intervalLength++;
                    if (startIndex < 0) {
                        startIndex = i;
                    }
                }
            }
            if (intervalLength < count) {
                for (int i = startIndex; i < startIndex + intervalLength; i++) {
                    result.add(series.getX(i));
                }
            } else {
                float step = (float) intervalLength / count;
                int intervalCount = 0;
                for (int i = 0; i < length && intervalCount < count; i++) {
                    double value = series.getX(Math.round(i * step));
                    if (min <= value && value <= max) {
                        result.add(value);
                        intervalCount++;
                    }
                }
            }
            return result;
        } else {
            return super.getXLabels(min, max, count);
        }
    }
    if (mStartPoint == null) {
        TimeZone tz = TimeZone.getDefault();
        Calendar cal = Calendar.getInstance(tz);
        cal.setTime(new Date(Math.round(min)));
        int offset = getDSTOffset(cal);
        mStartPoint = min - (min % DAY) + DAY + offset * 60 * 60 * 1000;
    }
    if (count > 25) {
        count = 25;
    }
    final double cycleMath = (max - min) / count;
    if (cycleMath <= 0) {
        return result;
    }
    double cycle = DAY;
    if (cycleMath <= DAY) {
        while (cycleMath < cycle / 2) {
            cycle = cycle / 2;
        }
    } else {
        while (cycleMath > cycle) {
            cycle = cycle * 2;
        }
    }
    double val = mStartPoint - Math.floor((mStartPoint - min) / cycle) * cycle;
    int i = 0;
    while (val < max && i++ <= count) {
        result.add(val);
        val += cycle;
    }
    return result;
}
Also used : XYSeries(com.codename1.charts.models.XYSeries) TimeZone(java.util.TimeZone) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) Paint(com.codename1.charts.compat.Paint) Date(java.util.Date)

Aggregations

ArrayList (java.util.ArrayList)8 Hashtable (java.util.Hashtable)8 AnimationObject (com.codename1.ui.animations.AnimationObject)6 File (java.io.File)6 IOException (java.io.IOException)6 Component (com.codename1.ui.Component)5 DataInputStream (java.io.DataInputStream)4 Command (com.codename1.ui.Command)3 Container (com.codename1.ui.Container)3 EditorTTFFont (com.codename1.ui.EditorTTFFont)3 EncodedImage (com.codename1.ui.EncodedImage)3 List (com.codename1.ui.List)3 Border (com.codename1.ui.plaf.Border)3 Point (java.awt.Point)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 FileInputStream (java.io.FileInputStream)3 EventObject (java.util.EventObject)3 HashMap (java.util.HashMap)3 Properties (com.codename1.io.Properties)2 ByteCodeClass (com.codename1.tools.translator.ByteCodeClass)2