?? processdata.java
字號:
package com.shfe.mail;
import java.util.*;
import java.text.*;
import com.shfe.mail.*;
public class ProcessData {
final int yLength = 200; //y scale length
final int xLength = 500; //x scale length
final int amountLength = 100; //amount y scale length
final long maxOptionSecond = 16200; //4.5 hours
final long maxStockSecond = 14400; //4 hours
public ScaleBean computScale(List data, double closePrice) {
if (data.size() < 1)return null;
double maxPrice = 0.0;
double minPrice = ((GraphBean) data.get(0)).getPrice();
long maxAmount = 0;
for (int i = 0; i < data.size(); i++) {
GraphBean graph = (GraphBean) data.get(i);
double price = graph.getPrice();
long amount = graph.getAmount();
if (price > maxPrice) maxPrice = price;
if (price < minPrice) minPrice = price;
if (amount > maxAmount) maxAmount = amount;
}
if (Math.abs(maxPrice - closePrice) >= Math.abs(closePrice - minPrice)) {
minPrice = closePrice - Math.abs(maxPrice - closePrice);
} else {
maxPrice = closePrice + Math.abs(closePrice - minPrice);
}
double priceYLength = maxPrice - minPrice;
if (priceYLength == 0) priceYLength = 1;
ScaleBean scale = new ScaleBean();
scale.setClosePrice(closePrice);
scale.setMaxPrice(maxPrice);
scale.setMinPrice(minPrice);
scale.setPriceYLength(priceYLength);
scale.setMaxAmount(maxAmount);
return scale;
}
public List computePoint(List quotes, double openPrice, ScaleBean scale) {
if (quotes == null || quotes.size() < 1)return null;
List points = new ArrayList();
for (int i = 0; i < quotes.size(); i++) {
GraphBean graph = (GraphBean) quotes.get(i);
String tradeTime = graph.getTime();
GregorianCalendar tempDate = ProcessTime.convertTime(tradeTime);
double tempPrice = graph.getPrice();
long tempAmount = graph.getAmount();
//the first point
if (i == 0) {
tempDate = ProcessTime.getCaleDate(9, 15);
tempPrice = openPrice;
}
long tempLong = ProcessTime.judgeTime(tempDate);
if (i > 0 && tempLong == 0) continue; //except break time;
PointBean point = new PointBean();
point.setPointTime(tempLong);
point.setPointPrice(tempPrice);
point.setPointAmount(tempAmount);
points.add(point);
}
return points;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -