本文整理汇总了Java中com.db.chart.Tools类的典型用法代码示例。如果您正苦于以下问题:Java Tools类的具体用法?Java Tools怎么用?Java Tools使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tools类属于com.db.chart包,在下文中一共展示了Tools类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populateChart
import com.db.chart.Tools; //导入依赖的package包/类
private void populateChart(String[] labels, float[] values, LineChartView graphView) {
LineSet dataSet = new LineSet(labels, values);
int maxValue = detailBreakDownPresenter.getMaxHeight(values);
dataSet.setColor(ContextCompat.getColor(context, R.color.colorGrey))
.setFill(ContextCompat.getColor(context, android.R.color.transparent))
.setDotsColor(ContextCompat.getColor(context, R.color.colorGrey))
.setThickness(4)
.setDashed(new float[] { 10f, 10f })
.beginAt(0);
// Chart
graphView.setBorderSpacing(Tools.fromDpToPx(15))
.setYLabels(AxisRenderer.LabelPosition.NONE)
.setLabelsColor(ContextCompat.getColor(context, R.color.colorGrey))
.setXAxis(false)
.setAxisBorderValues(0, maxValue, 2)
.setYAxis(false);
graphView.reset();
graphView.addData(dataSet);
graphView.animate();
graphView.show();
}
示例2: StatsGraph
import com.db.chart.Tools; //导入依赖的package包/类
public StatsGraph(Fragment f, ProgressBar prog) {
mLineChart = (LineChartView)f.getActivity().findViewById(R.id.rockStats);
mLineChart.setOnEntryClickListener(lineEntryListener);
mLineChart.setOnClickListener(lineClickListener);
mLineGridPaint = new Paint();
mLineGridPaint.setColor(LINES);
mLineGridPaint.setPathEffect(new DashPathEffect(new float[] {5,0}, 0));
mLineGridPaint.setStyle(Paint.Style.STROKE);
mLineGridPaint.setAntiAlias(true);
mLineGridPaint.setStrokeWidth(Tools.fromDpToPx(.75f));
this.prog = prog;
this.range = WEEK;
this.column = POINTS;
this.stats = new HashMap<Long, Stat>();
this.dbh = new DatabaseHelper(f.getActivity(), null);
this.db = dbh.getReadableDatabase();
refresh();
}
示例3: temperatureGraph
import com.db.chart.Tools; //导入依赖的package包/类
private void temperatureGraph() {
LineChartView lineChartView = (LineChartView) findViewById(R.id.graph_temperature);
// Data
LineSet dataset = new LineSet();
for (int i = 0; i < weatherList.size(); i++) {
float temperature = UnitConvertor.convertTemperature(Float.parseFloat(weatherList.get(i).getTemperature()), sp);
if (temperature < minTemp) {
minTemp = temperature;
}
if (temperature > maxTemp) {
maxTemp = temperature;
}
dataset.addPoint(getDateLabel(weatherList.get(i), i), (float) ((Math.ceil(temperature / 2)) * 2));
}
dataset.setSmooth(false);
dataset.setColor(Color.parseColor("#FF5722"));
dataset.setThickness(4);
lineChartView.addData(dataset);
// Grid
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setAntiAlias(true);
paint.setColor(Color.parseColor("#333333"));
paint.setPathEffect(new DashPathEffect(new float[]{10, 10}, 0));
paint.setStrokeWidth(1);
lineChartView.setGrid(ChartView.GridType.HORIZONTAL, paint);
lineChartView.setBorderSpacing(Tools.fromDpToPx(10));
lineChartView.setAxisBorderValues((int) minTemp - 2, (int) maxTemp + 2);
lineChartView.setStep(2);
lineChartView.setXAxis(false);
lineChartView.setYAxis(false);
lineChartView.show();
}
示例4: rainGraph
import com.db.chart.Tools; //导入依赖的package包/类
private void rainGraph() {
LineChartView lineChartView = (LineChartView) findViewById(R.id.graph_rain);
// Data
LineSet dataset = new LineSet();
for (int i = 0; i < weatherList.size(); i++) {
float rain = Float.parseFloat(weatherList.get(i).getRain());
if (rain < minRain) {
minRain = rain;
}
if (rain > maxRain) {
maxRain = rain;
}
dataset.addPoint(getDateLabel(weatherList.get(i), i), rain);
}
dataset.setSmooth(false);
dataset.setColor(Color.parseColor("#2196F3"));
dataset.setThickness(4);
lineChartView.addData(dataset);
// Grid
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setAntiAlias(true);
paint.setColor(Color.parseColor("#333333"));
paint.setPathEffect(new DashPathEffect(new float[]{10, 10}, 0));
paint.setStrokeWidth(1);
lineChartView.setGrid(ChartView.GridType.HORIZONTAL, paint);
lineChartView.setBorderSpacing(Tools.fromDpToPx(10));
lineChartView.setAxisBorderValues((int) minRain - 1, (int) maxRain + 2);
lineChartView.setStep(1);
lineChartView.setXAxis(false);
lineChartView.setYAxis(false);
lineChartView.show();
}
示例5: pressureGraph
import com.db.chart.Tools; //导入依赖的package包/类
private void pressureGraph() {
LineChartView lineChartView = (LineChartView) findViewById(R.id.graph_pressure);
// Data
LineSet dataset = new LineSet();
for (int i = 0; i < weatherList.size(); i++) {
float pressure = UnitConvertor.convertPressure(Float.parseFloat(weatherList.get(i).getPressure()), sp);
if (pressure < minPressure) {
minPressure = pressure;
}
if (pressure > maxPressure) {
maxPressure = pressure;
}
dataset.addPoint(getDateLabel(weatherList.get(i), i), pressure);
}
dataset.setSmooth(true);
dataset.setColor(Color.parseColor("#4CAF50"));
dataset.setThickness(4);
lineChartView.addData(dataset);
// Grid
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setAntiAlias(true);
paint.setColor(Color.parseColor("#333333"));
paint.setPathEffect(new DashPathEffect(new float[]{10, 10}, 0));
paint.setStrokeWidth(1);
lineChartView.setGrid(ChartView.GridType.HORIZONTAL, paint);
lineChartView.setBorderSpacing(Tools.fromDpToPx(10));
lineChartView.setAxisBorderValues((int) minPressure - 1, (int) maxPressure + 1);
lineChartView.setStep(2);
lineChartView.setXAxis(false);
lineChartView.setYAxis(false);
lineChartView.show();
}
示例6: buildChart
import com.db.chart.Tools; //导入依赖的package包/类
private void buildChart(ChartView chart, int r, int c) {
Paint mGridPaint = new Paint();
mGridPaint.setColor(Color.GRAY);
mGridPaint.setStyle(Paint.Style.STROKE);
mGridPaint.setAntiAlias(true);
mGridPaint.setStrokeWidth(Tools.fromDpToPx(1));
chart.setGrid(ChartView.GridType.FULL, r, c, mGridPaint);
}
示例7: renderChart
import com.db.chart.Tools; //导入依赖的package包/类
public void renderChart(Cursor data) {
LineSet lineSet = new LineSet();
float minimumPrice = Float.MAX_VALUE;
float maximumPrice = Float.MIN_VALUE;
for (data.moveToFirst(); !data.isAfterLast(); data.moveToNext()) {
String label = data.getString(data.getColumnIndexOrThrow(QuoteColumns.BIDPRICE));
float price = Float.parseFloat(label);
lineSet.addPoint(label, price);
minimumPrice = Math.min(minimumPrice, price);
maximumPrice = Math.max(maximumPrice, price);
}
lineSet.setColor(Color.parseColor("#758cbb"))
.setFill(Color.parseColor("#2d374c"))
.setDotsColor(Color.parseColor("#758cbb"))
.setThickness(4)
.setDashed(new float[]{10f, 10f});
lineChartView.setBorderSpacing(Tools.fromDpToPx(15))
.setYLabels(AxisController.LabelPosition.OUTSIDE)
.setXLabels(AxisController.LabelPosition.NONE)
.setLabelsColor(Color.parseColor("#6a84c3"))
.setXAxis(false)
.setYAxis(false)
.setAxisBorderValues(Math.round(Math.max(0f, minimumPrice - 5f)), Math.round(maximumPrice + 5f))
.addData(lineSet);
Animation anim = new Animation();
if (lineSet.size() > 1)
lineChartView.show(anim);
else
Toast.makeText(this, "No data", Toast.LENGTH_SHORT).show();
}
示例8: setBorderValues
import com.db.chart.Tools; //导入依赖的package包/类
/**
*
* @param minValue The minimum value that Y axis will have as a label
* @param maxValue The maximum value that Y axis will have as a label
*/
public void setBorderValues(int minValue, int maxValue){
if(minValue > 0)
step = Tools.GCD(minValue, maxValue);
maxLabelValue = maxValue;
minLabelValue = minValue;
}
示例9: produceThree
import com.db.chart.Tools; //导入依赖的package包/类
/**
*
* Chart 3
*
*/
public void produceThree(ChartView chart, Runnable action){
BarChartView barChart = (BarChartView) chart;
Tooltip tip = new Tooltip(BarActivity.this, R.layout.barchart_three_tooltip);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 1);
tip.setEnterAnimation(alpha);
alpha = PropertyValuesHolder.ofFloat(View.ALPHA,0);
tip.setExitAnimation(alpha);
}
barChart.setTooltips(tip);
BarSet dataset = new BarSet(mLabelsThree, mValuesThree);
dataset.setColor(Color.parseColor("#eb993b"));
barChart.addData(dataset);
barChart.setBarSpacing(Tools.fromDpToPx(3));
barChart.setXLabels(AxisController.LabelPosition.NONE)
.setYLabels(AxisController.LabelPosition.NONE)
.setXAxis(false)
.setYAxis(false);
Animation anim = new Animation()
.setEasing(new ElasticEase())
.setEndAction(action);
chart.show(anim);
}
示例10: temperatureGraph
import com.db.chart.Tools; //导入依赖的package包/类
private void temperatureGraph() {
LineChartView lineChartView = (LineChartView) findViewById(R.id.graph_temperature);
// Data
LineSet dataset = new LineSet();
for (int i = 0; i < weatherList.size(); i++) {
float temperature = UnitConvertor.convertTemperature(Float.parseFloat(weatherList.get(i).getTemperature()), sp);
if (temperature < minTemp) {
minTemp = temperature;
}
if (temperature > maxTemp) {
maxTemp = temperature;
}
dataset.addPoint(getDateLabel(weatherList.get(i), i), (float) temperature);
}
dataset.setSmooth(false);
dataset.setColor(Color.parseColor("#FF5722"));
dataset.setThickness(4);
lineChartView.addData(dataset);
// Grid
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setAntiAlias(true);
paint.setColor(Color.parseColor("#333333"));
paint.setPathEffect(new DashPathEffect(new float[]{10, 10}, 0));
paint.setStrokeWidth(1);
lineChartView.setGrid(ChartView.GridType.HORIZONTAL, paint);
lineChartView.setBorderSpacing(Tools.fromDpToPx(10));
lineChartView.setAxisBorderValues((int) (Math.round(minTemp)) - 1, (int) (Math.round(maxTemp)) + 1);
lineChartView.setStep(2);
lineChartView.setXAxis(false);
lineChartView.setYAxis(false);
lineChartView.show();
}
示例11: rainGraph
import com.db.chart.Tools; //导入依赖的package包/类
private void rainGraph() {
LineChartView lineChartView = (LineChartView) findViewById(R.id.graph_rain);
// Data
LineSet dataset = new LineSet();
for (int i = 0; i < weatherList.size(); i++) {
float rain = Float.parseFloat(weatherList.get(i).getRain());
if (rain < minRain) {
minRain = rain;
}
if (rain > maxRain) {
maxRain = rain;
}
dataset.addPoint(getDateLabel(weatherList.get(i), i), rain);
}
dataset.setSmooth(false);
dataset.setColor(Color.parseColor("#2196F3"));
dataset.setThickness(4);
lineChartView.addData(dataset);
// Grid
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setAntiAlias(true);
paint.setColor(Color.parseColor("#333333"));
paint.setPathEffect(new DashPathEffect(new float[]{10, 10}, 0));
paint.setStrokeWidth(1);
lineChartView.setGrid(ChartView.GridType.HORIZONTAL, paint);
lineChartView.setBorderSpacing(Tools.fromDpToPx(10));
lineChartView.setAxisBorderValues(0, (int) (Math.round(maxRain)) + 1);
lineChartView.setStep(1);
lineChartView.setXAxis(false);
lineChartView.setYAxis(false);
lineChartView.show();
}
示例12: initChart
import com.db.chart.Tools; //导入依赖的package包/类
private void initChart(){
final Tooltip tooltip = new Tooltip(getActivity(), R.layout.tool_tip_chart, R.id.value);
tooltip.setVerticalAlignment(Tooltip.Alignment.BOTTOM_TOP);
tooltip.setDimensions((int) Tools.fromDpToPx(65), (int) Tools.fromDpToPx(25));
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
tooltip.setEnterAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 1),
PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f),
PropertyValuesHolder.ofFloat(View.SCALE_X, 1f)).setDuration(200);
tooltip.setExitAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 0),
PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f),
PropertyValuesHolder.ofFloat(View.SCALE_X, 0f)).setDuration(200);
tooltip.setPivotX(Tools.fromDpToPx(65) / 2);
tooltip .setPivotY(Tools.fromDpToPx(25));
}
amountChart.setTooltips(tooltip);
LineSet dataset = new LineSet(ChartDetailHelper.getInstance().getLabels(), ChartDetailHelper.getInstance().getValues());
dataset.setColor(Color.WHITE)
.setFill(getResources().getColor(android.R.color.holo_orange_light))
.setDotsColor(Color.WHITE)
.setThickness(4)
.setDashed(new float[]{10f,10f})
.beginAt(1)
.endAt(8);
amountChart.addData(dataset);
Log.d(getClass().getName(), "initChart: "+Math.round(max/10));
amountChart.setStep(ChartDetailHelper.getInstance().getMaxRatio());
amountChart.setFontSize((int) (getResources().getDimension(R.dimen.dp_30)/getResources().getDisplayMetrics().density));
amountChart.setLabelsColor(Color.WHITE);
Runnable chartAction = new Runnable() {
@Override
public void run() {
tooltip.prepare(amountChart.getEntriesArea(0).get(3), values[0]);
amountChart.showTooltip(tooltip, true);
}
};
Animation anim = new Animation()
.setEasing(new BounceEase())
.setEndAction(chartAction);
amountChart.show(anim);
}
示例13: produceOne
import com.db.chart.Tools; //导入依赖的package包/类
public void produceOne(ChartView chart, Runnable action){
if(getActivity()==null) {
return;
}
int currentColor;
int preClor;
preClor=mShowDaily?PRECOLOR:mCurrentColor;
currentColor=mShowDaily?mCurrentColor:PRECOLOR;
prepareStat();
AnimatorUtils.showCardBackgroundColorAnimation(mCardItem, preClor, currentColor, 400);
if(mLables.length<5||mStatValues.length<5) {
return;
}
barChart = (BarChartView) chart;
barChart.setOnEntryClickListener(new OnEntryClickListener() {
@Override
public void onClick(int setIndex, int entryIndex, Rect rect) {
new FinestWebView.Builder(getActivity())
.gradientDivider(false)
.show(mPlayerUrls[entryIndex]);
}
});
Tooltip tooltip = new Tooltip(getActivity(), R.layout.barchart_one_tooltip);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
tooltip.setEnterAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 1));
tooltip.setExitAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 0));
}
barChart.setTooltips(tooltip);
BarSet barSet = new BarSet(mLables, mStatValues);
barSet.setColor(preClor);
barChart.addData(barSet);
barChart.setSetSpacing(Tools.fromDpToPx(-15));
barChart.setBarSpacing(Tools.fromDpToPx(20));
barChart.setRoundCorners(Tools.fromDpToPx(4));
gridPaint = new Paint();
gridPaint.setColor(CHART_TEXT_COLOR);
gridPaint.setStyle(Paint.Style.STROKE);
gridPaint.setAntiAlias(true);
gridPaint.setStrokeWidth(Tools.fromDpToPx(.75f));
barChart.setBorderSpacing(5)
.setAxisBorderValues(0, mMax, STEP)
.setGrid(BarChartView.GridType.FULL, mMax, 6, gridPaint)
.setYAxis(false)
.setXLabels(XController.LabelPosition.OUTSIDE)
.setYLabels(YController.LabelPosition.OUTSIDE)
.setLabelsColor(CHART_TEXT_COLOR)
.setAxisColor(CHART_TEXT_COLOR);
int[] order = {2, 1, 3, 0, 4};
final Runnable auxAction = action;
Runnable chartOneAction = new Runnable() {
@Override
public void run() {
showTooltipOne();
auxAction.run();
}
};
barChart.show(new Animation()
.setOverlap(.5f, order)
.setEndAction(chartOneAction));
}