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;
}
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;
}
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];
}
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);
}
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;
}
Aggregations