本文整理匯總了Java中org.json.JSONArray.optDouble方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONArray.optDouble方法的具體用法?Java JSONArray.optDouble怎麽用?Java JSONArray.optDouble使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.json.JSONArray
的用法示例。
在下文中一共展示了JSONArray.optDouble方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: valueFromObject
import org.json.JSONArray; //導入方法依賴的package包/類
@Override public Integer valueFromObject(Object object, float scale) {
JSONArray colorArray = (JSONArray) object;
if (colorArray.length() == 4) {
boolean shouldUse255 = true;
for (int i = 0; i < colorArray.length(); i++) {
double colorChannel = colorArray.optDouble(i);
if (colorChannel > 1f) {
shouldUse255 = false;
}
}
float multiplier = shouldUse255 ? 255f : 1f;
return Color.argb(
(int) (colorArray.optDouble(3) * multiplier),
(int) (colorArray.optDouble(0) * multiplier),
(int) (colorArray.optDouble(1) * multiplier),
(int) (colorArray.optDouble(2) * multiplier));
}
return Color.BLACK;
}
示例2: parseWith
import org.json.JSONArray; //導入方法依賴的package包/類
@Override
public void parseWith(JSONObject data) {
super.parseWith(data);
if (data != null) {
column = data.optInt(KEY_COLUMN, 0);
autoExpand = data.optBoolean(KEY_AUTO_EXPAND, false);
JSONArray jsonCols = data.optJSONArray(KEY_COLS);
if (jsonCols != null) {
cols = new float[jsonCols.length()];
for (int i = 0; i < cols.length; i++) {
cols[i] = (float) jsonCols.optDouble(i, 0);
}
} else {
cols = new float[0];
}
hGap = Style.dp2px(data.optDouble(KEY_H_GAP, 0.0f));
vGap = Style.dp2px(data.optDouble(KEY_V_GAP, 0.0f));
}
}
示例3: parseWith
import org.json.JSONArray; //導入方法依賴的package包/類
@Override
public void parseWith(JSONObject data) {
super.parseWith(data);
if (data != null) {
JSONArray jsonCols = data.optJSONArray(KEY_COLS);
if (jsonCols != null) {
cols = new float[jsonCols.length()];
for (int i = 0; i < cols.length; i++) {
cols[i] = (float) jsonCols.optDouble(i, 0);
}
} else {
cols = new float[0];
}
JSONArray jsonRows = data.optJSONArray(KEY_ROWS);
if (jsonRows != null) {
rows = new float[jsonRows.length()];
for (int i = 0; i < rows.length; i++) {
rows[i] = (float) jsonRows.optDouble(i, 0);
}
} else {
rows = new float[0];
}
}
}
示例4: pointFromJsonArray
import org.json.JSONArray; //導入方法依賴的package包/類
static PointF pointFromJsonArray(JSONArray values, float scale) {
if (values.length() < 2) {
throw new IllegalArgumentException("Unable to parse point for " + values);
}
return new PointF(
(float) values.optDouble(0, 1) * scale,
(float) values.optDouble(1, 1) * scale);
}
示例5: getFloatArray
import org.json.JSONArray; //導入方法依賴的package包/類
public float[] getFloatArray(String key) {
try {
JSONArray array = data.getJSONArray(key);
int length = array.length();
float[] result = new float[length];
for (int i = 0; i < length; i++) {
result[i] = (float) array.optDouble(i, 0.0);
}
return result;
} catch (JSONException e) {
reportException(e);
return null;
}
}
示例6: parse
import org.json.JSONArray; //導入方法依賴的package包/類
public static GeoOri parse(JSONObject object) {
GeoOri geoOri = null;
if (object != null) {
geoOri = new GeoOri();
geoOri.type = object.optString("type");
JSONArray array = object.optJSONArray("coordinates");
geoOri.latitude = array.optDouble(0);
geoOri.longitude = array.optDouble(1);
}
return geoOri;
}
示例7: valueFromObject
import org.json.JSONArray; //導入方法依賴的package包/類
@Override public ScaleXY valueFromObject(Object object, float scale) {
JSONArray array = (JSONArray) object;
return new ScaleXY(
(float) array.optDouble(0, 1) / 100f * scale,
(float) array.optDouble(1, 1) / 100f * scale);
}