本文整理汇总了Java中com.jjoe64.graphview.series.DataPoint类的典型用法代码示例。如果您正苦于以下问题:Java DataPoint类的具体用法?Java DataPoint怎么用?Java DataPoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataPoint类属于com.jjoe64.graphview.series包,在下文中一共展示了DataPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createGraph
import com.jjoe64.graphview.series.DataPoint; //导入依赖的package包/类
private void createGraph() {
_graphView.removeAllSeries();
SerializableList<MoneyMeterData> moneyMeterDataList = MoneyMeterListService.getInstance().GetActiveMoneyMeter().GetMoneyMeterDataList();
int moneyMeterDataListSize = moneyMeterDataList.getSize();
DataPoint[] dataPoints = new DataPoint[moneyMeterDataListSize];
Date firstDate = new Date();
Date lastDate = new Date();
for (int index = 0; index < moneyMeterDataListSize; index++) {
SerializableDate saveDate = moneyMeterDataList.getValue(index).GetSaveDate();
Date date = new Date(saveDate.Year(), saveDate.Month() - 1, saveDate.DayOfMonth());
dataPoints[index] = new DataPoint(date, moneyMeterDataList.getValue(index).GetAmount());
if (index == 0) {
firstDate = date;
} else if (index == moneyMeterDataListSize - 1) {
lastDate = date;
}
}
LineGraphSeries<DataPoint> series = new LineGraphSeries<>(dataPoints);
_graphView.addSeries(series);
_graphView.getGridLabelRenderer().setLabelFormatter(new DateAsXAxisLabelFormatter(this));
_graphView.getGridLabelRenderer().setNumHorizontalLabels(3);
_graphView.getViewport().setMinX(firstDate.getTime());
_graphView.getViewport().setMaxX(lastDate.getTime());
_graphView.getViewport().setXAxisBoundsManual(true);
_graphView.getGridLabelRenderer().setHumanRounding(false);
}
示例2: addEntry
import com.jjoe64.graphview.series.DataPoint; //导入依赖的package包/类
private void addEntry(int b) {
// here, we choose to display max 10 points on the viewport and we scroll to end
series.appendData(new DataPoint(lastX++, b), true, 5);
/*LineData data=chart.getLineData();
if(data!=null) {
LineDataSet set = (LineDataSet) data.getDataSetByIndex(0);
if (set == null) {
set = createSet();
data.addDataSet(set);
}
data.addEntry(new Entry(((float) b), set.getEntryCount()), 0);
chart.notifyDataSetChanged();
chart.setVisibleXRange(0f, 6f);
chart.moveViewToX(data.getXMax() - 7);
}*/
}
示例3: plotGraph
import com.jjoe64.graphview.series.DataPoint; //导入依赖的package包/类
/**Plot the graph using Graph.java
* Get the frequency of all letters, and then process it
* */
private DataPoint[] plotGraph(String textOfPeriod) //plot the graph for a given text, the value of the given text should be a string of period N
{
textOfPeriod = framework.format(textOfPeriod).toLowerCase();
final int MAX_DATA_POINTS = 26;
DataPoint[] dp = new DataPoint[MAX_DATA_POINTS];
Integer[] frequency = Graph.displayGraph(framework.clean(textOfPeriod));
//fill series data
for(int x = 0; x < MAX_DATA_POINTS; x++)
dp[x] = new DataPoint(x, frequency[x]);
return dp;
}
示例4: getLineGraph
import com.jjoe64.graphview.series.DataPoint; //导入依赖的package包/类
public LineGraphSeries<DataPoint> getLineGraph(TuneResult result) {
LineGraphSeries<DataPoint> series = new LineGraphSeries<>();
// There are 256 divisor, and the frequency is mapped as:
// freq_khz = 12000 / (n + 1)
// Divisor 95 is 125kHz, and 89 is 133.3 kHz (~134kHz)
//
// The official proxmark3 gui represents these as raw values, but we should represent it in
// frequency order instead.
//
// The number given is volts??
int[] graphData = result.getGraphData();
for (int x=255; x >= 0; x--) {
series.appendData(new DataPoint(-x, graphData[x]), true, 256);
}
return series;
}
示例5: onCreate
import com.jjoe64.graphview.series.DataPoint; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_tune_result);
ActivityTuneResultBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_tune_result);
TuneResult tuneResult = getIntent().getParcelableExtra(TUNE_RESULT_KEY);
binding.setTuneResult(tuneResult);
GraphView gphTuning = (GraphView) findViewById(R.id.gphTuning);
LineGraphSeries<DataPoint> tuningSeries = getLineGraph(tuneResult);
gphTuning.addSeries(tuningSeries);
gphTuning.getViewport().setScalable(true);
gphTuning.getViewport().setScrollable(true);
// Translate the graph around on a pseudo-log scale
gphTuning.getGridLabelRenderer().setLabelFormatter(new FrequencyLabelFormatter());
}
示例6: draw
import com.jjoe64.graphview.series.DataPoint; //导入依赖的package包/类
/**
* translates route data in a format that is easier to work with Graphview
* @return
*/
public LineGraphSeries draw() {
DataPoint[] datapoints = null;
if (this.route != null) {
datapoints = this.drawRoute();
} else if (this.routeHistory != null) {
datapoints = this.drawRouteHistory();
} else {
Log.e("TEST", "both drawable null");
//throw new RuntimeException();
}
Log.d("TEST datapoints length", String.valueOf(datapoints.length));
if (datapoints != null) {
LineGraphSeries<DataPoint> serie = new LineGraphSeries<>(datapoints);
serie.setDrawBackground(true);
serie.setBackgroundColor(R.color.sbb_red);
return serie;
} else {
return new LineGraphSeries<>();
}
}
示例7: pushData
import com.jjoe64.graphview.series.DataPoint; //导入依赖的package包/类
private void pushData(final int seriesID, double value, double time)
{
//apparently GraphView can't render infinity
if(Double.isNaN(value) || Double.isInfinite(value) || value == -1 * Double.MAX_VALUE || value == Double.MAX_VALUE)
return;
final DataPoint p = new DataPoint(time, value);
Handler handler = new Handler(Looper.getMainLooper());
handler.postDelayed(new Runnable()
{
public void run()
{
if(seriesID < _series.size())
_series.get(seriesID).appendData(p, true, _maxPoints[seriesID]);
}
}, 1);
}
示例8: popolaGrafici
import com.jjoe64.graphview.series.DataPoint; //导入依赖的package包/类
public void popolaGrafici(){
final Cursor crs = db.reverseQuery();
if (crs == null) {
// do nothing
} else {
if(crs.moveToFirst()){
for (int i=0;i<crs.getCount();i++) {
String id = crs.getString(0);
light.appendData(new DataPoint(Integer.valueOf(id),crs.getDouble(1)),true,numeroDatiGrafico);
sound.appendData(new DataPoint(Integer.valueOf(id),crs.getDouble(2)),true,numeroDatiGrafico);
movement.appendData(new DataPoint(Integer.valueOf(id),crs.getDouble(3)),true,numeroDatiGrafico);
crs.moveToNext();
currentGraphIndex=Integer.valueOf(id);
}
}
}
}
示例9: getDataPoints
import com.jjoe64.graphview.series.DataPoint; //导入依赖的package包/类
public DataPoint[] getDataPoints(Context context, String filter) {
DataPoint[] points = new DataPoint[FOUR_MONTH];
ExpenseDAO dao = new ExpenseDAO(context);
for (int i = 0, j = 3; i < points.length; i++, j--) {
Calendar date = Calendar.getInstance();
date.set(MONTH, date.get(MONTH) - j);
try {
double total = dao.selectTotalMonth(date.getTime(), filter);
DataPoint point = new DataPoint(i, total);
points[i] = point;
} catch (Exception exception) {
Log.e(getClass().getCanonicalName(), exception.getMessage(), exception);
}
}
dao.close();
return points;
}
示例10: addNowLine
import com.jjoe64.graphview.series.DataPoint; //导入依赖的package包/类
public void addNowLine(GraphView graph, long now) {
LineGraphSeries<DataPoint> seriesNow;
DataPoint[] nowPoints = new DataPoint[]{
new DataPoint(now, 0),
new DataPoint(now, maxY)
};
seriesNow = new LineGraphSeries<>(nowPoints);
seriesNow.setDrawDataPoints(false);
// custom paint to make a dotted line
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(2);
paint.setPathEffect(new DashPathEffect(new float[]{10, 20}, 0));
paint.setColor(Color.WHITE);
seriesNow.setCustomPaint(paint);
addSeriesWithoutInvalidate(graph, seriesNow);
}
示例11: initialize
import com.jjoe64.graphview.series.DataPoint; //导入依赖的package包/类
public void initialize(LineGraphSeries<DataPoint>[] series){
graph = (GraphView) myFragmentView.findViewById(R.id.graphView);
float tmp;
if(!sharedPref.getBoolean("pref_yAutoScale", true)){
graph.getViewport().setYAxisBoundsManual(true);
tmp = Float.parseFloat(sharedPref.getString("pref_y_min", "-200"));
graph.getViewport().setMinY(tmp);
tmp = Float.parseFloat(sharedPref.getString("pref_y_max", "200"));
graph.getViewport().setMaxY(tmp);
}
graph.getViewport().setXAxisBoundsManual(true);
graph.getViewport().setMinX(0);
tmp = Integer.parseInt(sharedPref.getString("pref_windowSize", "200"));
graph.getViewport().setMaxX(tmp);
graph.getGridLabelRenderer().setHorizontalLabelsVisible(sharedPref.getBoolean("pref_xgridlabels", false));//pref_ygridlabels
graph.getGridLabelRenderer().setVerticalLabelsVisible(sharedPref.getBoolean("pref_ygridlabels", true));
int i =0;
for (LineGraphSeries<DataPoint> sery : series) {
if (sery != null) {
sery.setColor(getColor(i));
graph.addSeries(sery);
}
i++;
}
}
示例12: extractValuesSeries
import com.jjoe64.graphview.series.DataPoint; //导入依赖的package包/类
private void extractValuesSeries() {
double[][] data = new double[spectrogram.length][2];
for(int i=0; i < spectrogram.length; i++){
data[i] = meanExtraction(spectrogram[i], CARRIER_IDX, currentHalfCarrierWidth);
}
DataPoint[] dps = new DataPoint[spectrogram.length];
DataPoint[] dps2 = new DataPoint[spectrogram.length];
for(int i=0; i< dps.length; i++){
dps[i] = new DataPoint(i, data[i][0]);
dps2[i] = new DataPoint(i, data[i][1]*-1);
}
LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(dps);
LineGraphSeries<DataPoint> series2 = new LineGraphSeries<DataPoint>(dps2);
//TODO
//imageView.addSeries(series);
//imageView.addSeries(series2);
}
示例13: requestDistanceGraphSeries
import com.jjoe64.graphview.series.DataPoint; //导入依赖的package包/类
/**
* distance DataPoint series DataPoint (x, y) x = increased time, y = increased distance
* <p/>
* Listener will handler the return data
*/
public void requestDistanceGraphSeries() {
new AsyncTask<URL, Integer, DataPoint[][]>() {
protected DataPoint[][] doInBackground(URL... params) {
try {
dBtrackingPoints.open();
DataPoint[][] dp = dBtrackingPoints.getGraphSeries();
dBtrackingPoints.close();
return dp;
} catch (Exception e) {e.printStackTrace();}
return null;
}
protected void onPostExecute(DataPoint[][] dataPoints) {
super.onPostExecute(dataPoints);
broadcast(null, null, null, dataPoints);
}
}.execute();
}
示例14: updateMaxSpeed
import com.jjoe64.graphview.series.DataPoint; //导入依赖的package包/类
/**
* update max speed and broadcast DataPoint for speeds and distances
*
* @param location
*/
private void updateMaxSpeed(Location location) {
if (startLocation != null) {
// velocity: m/s
double velocity =
(startLocation.distanceTo(location)) / ((location.getTime() - startLocation.getTime()) / (1000.0));
double timePoint = (double) (location.getTime() - getTimeStart()) / (1000.0 * 60 * 60); // timePoint hours
DataPoint speed = new DataPoint(timePoint, velocity);
DataPoint distance = new DataPoint(timePoint, this.distance);
broadcast(speed, distance);
// TODO: improve noise reduce (Kalman filter)
// TODO: http://dsp.stackexchange.com/questions/8860/more-on-kalman-filter-for-position-and-velocity
velocity = velocity * (6 * 6 / 10);// velocity: km/h
// if (maxSpeed < velocity && velocity < (maxSpeed + 32) * 10) {
if (maxSpeed < velocity) {
maxSpeed = (float) velocity;
broadcast(null, maxSpeed, null, null);
}
}
}
示例15: broadcast
import com.jjoe64.graphview.series.DataPoint; //导入依赖的package包/类
/**
* set null if do not need to update
*
* @param avgSpeed
* @param maxSpeed
* @param distance
*/
private void broadcast(Double avgSpeed, Double maxSpeed, Double distance, DataPoint[][] dataPoints) {
for (TrackingListener tl : listeners) {
if (avgSpeed != null) {
tl.updateAvgSpeed(avgSpeed);
}
if (maxSpeed != null) {
tl.updateMaxSpeed(maxSpeed);
}
if (distance != null) {
tl.updateDistance(distance);
}
if (dataPoints != null) {
tl.updateDistanceGraphSeries(dataPoints);
}
}
}