本文整理汇总了Java中org.xclcharts.common.DensityUtil类的典型用法代码示例。如果您正苦于以下问题:Java DensityUtil类的具体用法?Java DensityUtil怎么用?Java DensityUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DensityUtil类属于org.xclcharts.common包,在下文中一共展示了DensityUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initView
import org.xclcharts.common.DensityUtil; //导入依赖的package包/类
private void initView()
{
mOffset = DensityUtil.dip2px(getContext(), 45);
chartLabels();
chartDataSet();
chartDataSet2();
chartRender();
chartRender2();
//綁定手势滑动事件
this.bindTouch(this,chart);
this.bindTouch(this,chart2);
}
示例2: onSizeChanged
import org.xclcharts.common.DensityUtil; //导入依赖的package包/类
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
// android:layout_height="600dip"
float spad = DensityUtil.dip2px(getContext(), 15);
float top = DensityUtil.dip2px(getContext(), 5);
float viewHeight = DensityUtil.dip2px(getContext(),h);
viewHeight /=2;
float chart1Height = viewHeight / 5 * 3;
float row = DensityUtil.dip2px(getContext(), 20);
chart1Height -= top;
chart1Height -= row;
chart1.setChartRange(0, top,w,chart1Height);
float chart2Height = viewHeight / 5 * 2;
chart2.setChartRange(0,row+chart1Height,w,chart2Height);
chart1.setPadding(spad, 0.f, spad, 0.f);
chart2.setPadding(spad, 0.f, spad, 0.f);
}
示例3: renderChart
import org.xclcharts.common.DensityUtil; //导入依赖的package包/类
private void renderChart(int position)
{
int width = DensityUtil.dip2px(getApplicationContext(), 300);
int height = DensityUtil.dip2px(getApplicationContext(), 400);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(width, height);
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
mLaychart.removeAllViews();
if(0 == mSelected )
{
SpinnerBarChart01View barChart01= new SpinnerBarChart01View(this,position,mMoveHeight);
mLaychart.addView(barChart01,layoutParams);
}else{
SpinnerPieChart01View pieChart01= new SpinnerPieChart01View(this,position,mMoveHeight);
mLaychart.addView(pieChart01,layoutParams);
}
}
示例4: getBarLnDefaultSpadding
import org.xclcharts.common.DensityUtil; //导入依赖的package包/类
protected int[] getBarLnDefaultSpadding()
{
int [] ltrb = new int[4];
ltrb[0] = DensityUtil.dip2px(getContext(), 40); //left
ltrb[1] = DensityUtil.dip2px(getContext(), 60); //top
ltrb[2] = DensityUtil.dip2px(getContext(), 20); //right
ltrb[3] = DensityUtil.dip2px(getContext(), 40); //bottom
return ltrb;
}
示例5: getPieDefaultSpadding
import org.xclcharts.common.DensityUtil; //导入依赖的package包/类
protected int[] getPieDefaultSpadding()
{
int [] ltrb = new int[4];
ltrb[0] = DensityUtil.dip2px(getContext(), 20); //left
ltrb[1] = DensityUtil.dip2px(getContext(), 65); //top
ltrb[2] = DensityUtil.dip2px(getContext(), 20); //right
ltrb[3] = DensityUtil.dip2px(getContext(), 20); //bottom
return ltrb;
}
示例6: getBarLnDefaultSpadding
import org.xclcharts.common.DensityUtil; //导入依赖的package包/类
protected int[] getBarLnDefaultSpadding()
{
int[] ltrb = new int[4];
ltrb[0] = DensityUtil.dip2px(getContext(), 40); //left
ltrb[1] = DensityUtil.dip2px(getContext(), 60); //top
ltrb[2] = DensityUtil.dip2px(getContext(), 20); //right
ltrb[3] = DensityUtil.dip2px(getContext(), 40); //bottom
return ltrb;
}
示例7: getPieDefaultSpadding
import org.xclcharts.common.DensityUtil; //导入依赖的package包/类
protected int[] getPieDefaultSpadding()
{
int[] ltrb = new int[4];
ltrb[0] = DensityUtil.dip2px(getContext(), 20); //left
ltrb[1] = DensityUtil.dip2px(getContext(), 65); //top
ltrb[2] = DensityUtil.dip2px(getContext(), 20); //right
ltrb[3] = DensityUtil.dip2px(getContext(), 20); //bottom
return ltrb;
}
示例8: chartRender
import org.xclcharts.common.DensityUtil; //导入依赖的package包/类
public void chartRender()
{
try {
chart.setPadding(0, DensityUtil.dip2px(getContext(), 100), 0, 0);
//设置标题背景
chart.setApplyBackgroundColor(true);
chart.setBackgroundColor( Color.rgb(28, 129, 243) );
//绘制边框
chart.showRoundBorder();
chart.setTotalAngle(270f);
//设置当前百分比
chart.getPointer().setPercentage(mPercentage);
//设置指针长度
chart.getPointer().setLength(0.65f,0.2f);
//增加轴
addAxis();
/////////////////////////////////////////////////////////////
//增加指针
addPointer();
//设置附加信息
addAttrInfo();
/////////////////////////////////////////////////////////////
} catch (Exception e) {
// TODO Auto-generated catch block
Log.e(TAG, e.toString());
}
}
示例9: chartRender90
import org.xclcharts.common.DensityUtil; //导入依赖的package包/类
public void chartRender90()
{
try {
chart90.setPadding(DensityUtil.dip2px(getContext(), 150),0, 0, 0);
chart90.setTotalAngle(90f);
chart90.setStartAngle(270f);
List<Float> ringPercentage = new ArrayList<Float>();
float rper = MathHelper.getInstance().div(1, 2); //相当于40% //270, 4
ringPercentage.add(rper);
ringPercentage.add(rper);
List<Integer> rcolor = new ArrayList<Integer>();
rcolor.add(Color.rgb(242, 110, 131));
rcolor.add(Color.rgb(238, 204, 71));
chart90.addStrokeRingAxis(0.75f,0.6f, ringPercentage, rcolor);
chart90.getPlotAxis().get(0).getFillAxisPaint().setColor(Color.rgb(28, 129, 243) );
chart90.getPointer().setLength(0.65f);
Paint paintTB = new Paint();
paintTB.setColor(Color.WHITE);
paintTB.setTextAlign(Align.CENTER);
paintTB.setTextSize(22);
paintTB.setAntiAlias(true);
chart90.getPlotAttrInfo().addAttributeInfo(XEnum.Location.BOTTOM, "90度仪表盘", 0.5f, paintTB);
} catch (Exception e) {
// TODO Auto-generated catch block
Log.e(TAG, e.toString());
}
}
示例10: getBarLnDefaultSpadding
import org.xclcharts.common.DensityUtil; //导入依赖的package包/类
@Override
protected int[] getBarLnDefaultSpadding()
{
int [] ltrb = new int[4];
ltrb[0] = DensityUtil.dip2px(getContext(), 40); //left
ltrb[1] = DensityUtil.dip2px(getContext(), 56); //top
ltrb[2] = DensityUtil.dip2px(getContext(), 40); //right
ltrb[3] = DensityUtil.dip2px(getContext(), 36); //bottom
return ltrb;
}
示例11: onSizeChanged
import org.xclcharts.common.DensityUtil; //导入依赖的package包/类
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
//图所占范围大小
chart.setChartRange(w ,h);
chartLn.setChartRange(w ,h);
chartLnAxes.setChartRange(w ,h);
float left = DensityUtil.dip2px(getContext(), 42);
float top = DensityUtil.dip2px(getContext(),62);
float piewidth = Math.min(w, h) / 4;//1.5f;
chartPie.setChartRange(left, top, piewidth, piewidth);
}
示例12: drawLast
import org.xclcharts.common.DensityUtil; //导入依赖的package包/类
private void drawLast()
{
//标题
chart.setTitle("数据库统计");
chart.addSubtitle("(XCL-Charts Demo)");
chart.getPlotTitle().getTitlePaint().setColor(colorTitalAxes);
chart.getPlotTitle().getSubtitlePaint().setColor(colorTitalAxes);
//激活点击监听
chart.ActiveListenItemClick();
chart.showClikedFocus();
//扩展横向显示范围,当数据太多时可用这个扩展实际绘图面积
//chart.getPlotArea().extWidth(200f);
//禁用平移模式
chart.disablePanMode();
//限制只能左右滑动
//chart.setPlotPanMode(XEnum.PanMode.HORIZONTAL);
//禁用双指缩放
//chart.disableScale();
chart.getDataAxis().show();
chart.getPlotLegend().show();
//当值与轴最小值相等时,不显示轴
chart.hideBarEqualAxisMin();
//批注
List<AnchorDataPoint> mAnchorSet = new ArrayList<AnchorDataPoint>();
AnchorDataPoint an1 = new AnchorDataPoint(2,0,XEnum.AnchorStyle.CIRCLE);
an1.setAlpha(200);
an1.setBgColor(Color.rgb(203, 189, 231));
//an1.setAreaStyle(XEnum.DataAreaStyle.FILL);
AnchorDataPoint an2 = new AnchorDataPoint(1,1,XEnum.AnchorStyle.CIRCLE); //CIRCLE
an2.setBgColor(Color.GRAY);
AnchorDataPoint an3 = new AnchorDataPoint(0,2,XEnum.AnchorStyle.RECT); //CAPROUNDRECT RECT
an3.setBgColor(Color.rgb(255, 145, 126));
AnchorDataPoint an4 = new AnchorDataPoint(0,1,XEnum.AnchorStyle.CAPRECT);
an4.setBgColor(Color.rgb(255, 145, 126));
an4.setAnchor("我是批注");
mAnchorSet.add(an1);
mAnchorSet.add(an2);
mAnchorSet.add(an3);
mAnchorSet.add(an4);
chart.setAnchorDataPoint(mAnchorSet);
chart.setApplyBackgroundColor(true);
chart.setBackgroundColor(XEnum.Direction.VERTICAL,Color.rgb(69, 117, 180),Color.rgb(224, 243, 248)); //Color.rgb(17, 162, 255),Color.rgb(163, 219, 254));//Color.WHITE);
chart.getBorder().setBorderLineColor(Color.rgb(181, 64, 1));
chart.getBorder().getLinePaint().setStrokeWidth(3);
chart.getPlotArea().setBackgroundColor(true, colorPlotArea);
//chart.getPlotArea().setApplayGradient(true);
//chart.getPlotArea().setGradientDirection(XEnum.Direction.VERTICAL);
//chart.getPlotArea().setBeginColor(Color.rgb(116, 174, 210));
//chart.getPlotArea().setEndColor(Color.WHITE);
chart.showRoundBorder();
CustomLineData line1 = new CustomLineData("分界",60d,Color.rgb(218, 198, 61),7);
line1.setCustomLineCap(XEnum.DotStyle.HIDE);
line1.setLabelHorizontalPostion(Align.RIGHT);
//line1.setLabelOffset(15);
line1.getLineLabelPaint().setColor(Color.RED);
mCustomLineDataset.add(line1);
chart.setCustomLines(mCustomLineDataset);
//饼图
float pieWH = DensityUtil.dip2px(getContext(), 70);
float pieX = chart.getPlotArea().getRight() - pieWH * 3;
chartPie.setChartRange(pieX,pieWH, pieWH,pieWH);
}
示例13: chartRender
import org.xclcharts.common.DensityUtil; //导入依赖的package包/类
private void chartRender()
{
try {
//标签显示(隐藏,显示在中间,显示在扇区外面,折线注释方式)
chart.setLabelStyle(XEnum.SliceLabelStyle.BROKENLINE);
chart.getLabelBrokenLine().setLinePointStyle(XEnum.LabelLinePoint.END);
chart.syncLabelColor();
chart.syncLabelPointColor();
//图的内边距
//注释折线较长,缩进要多些
int [] ltrb = new int[4];
ltrb[0] = DensityUtil.dip2px(getContext(), 60); //left
ltrb[1] = DensityUtil.dip2px(getContext(), 65); //top
ltrb[2] = DensityUtil.dip2px(getContext(), 60); //right
ltrb[3] = DensityUtil.dip2px(getContext(), 50); //bottom
chart.setPadding(ltrb[0], ltrb[1], ltrb[2], ltrb[3]);
//设定数据源
//chart.setDataSource(chartData);
//标题
chart.setTitle("擂茶配方比");
chart.addSubtitle("(XCL-Charts Demo)");
//chart.setTitleVerticalAlign(XEnum.VerticalAlign.MIDDLE);
//隐藏渲染效果
chart.hideGradient();
//显示边框
//chart.showRoundBorder();
/*
//激活点击监听
chart.ActiveListenItemClick();
chart.showClikedFocus();
chart.disablePanMode();
//显示图例
PlotLegend legend = chart.getPlotLegend();
legend.show();
legend.setHorizontalAlign(XEnum.HorizontalAlign.CENTER);
legend.setVerticalAlign(XEnum.VerticalAlign.BOTTOM);
legend.showBox();
*/
chart.disablePanMode();
} catch (Exception e) {
// TODO Auto-generated catch block
Log.e(TAG, e.toString());
}
}
示例14: chartRender
import org.xclcharts.common.DensityUtil; //导入依赖的package包/类
private void chartRender()
{
try {
//设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....
int [] ltrb = getBarLnDefaultSpadding();
chart.setPadding(ltrb[0] + DensityUtil.dip2px(this.getContext(), 10), ltrb[1],
ltrb[2]+DensityUtil.dip2px(this.getContext(), 20), ltrb[3]);
//标题
chart.setTitle("New GitHub repositories");
chart.addSubtitle("(XCL-Charts Demo)");
chart.getAxisTitle().setLeftTitle("Percentage (annual)");
chart.getAxisTitle().getLeftTitlePaint().setColor(Color.BLACK);
//显示边框
chart.showRoundBorder();
//数据源
chart.setCategories(labels);
chart.setDataSource(chartData);
chart.setCustomLines(mCustomLineDataset);
//坐标系
//数据轴最大值
chart.getDataAxis().setAxisMax(20);
//chart.getDataAxis().setAxisMin(0);
//数据轴刻度间隔
chart.getDataAxis().setAxisSteps(5);
//标签轴最大值
chart.setCategoryAxisMax(6);
//标签轴最小值
chart.setCategoryAxisMin(0);
//背景网格
PlotGrid plot = chart.getPlotGrid();
plot.hideHorizontalLines();
plot.hideVerticalLines();
chart.getDataAxis().getAxisPaint().setColor(Color.rgb(127, 204, 204));
chart.getCategoryAxis().getAxisPaint().setColor(Color.rgb(127, 204, 204));
chart.getDataAxis().getTickMarksPaint().setColor(Color.rgb(127, 204, 204));
chart.getCategoryAxis().getTickMarksPaint().setColor(Color.rgb(127, 204, 204));
//定义数据轴标签显示格式
chart.getDataAxis().setLabelFormatter(new IFormatterTextCallBack(){
@Override
public String textFormatter(String value) {
// TODO Auto-generated method stub
Double tmp = Double.parseDouble(value);
DecimalFormat df=new DecimalFormat("#0");
String label = df.format(tmp).toString();
return (label);
}
});
//不使用精确计算,忽略Java计算误差,提高性能
chart.disableHighPrecision();
chart.disablePanMode();
chart.hideBorder();
chart.getPlotLegend().hide();
//chart.getCategoryAxis().setLabelLineFeed(XEnum.LabelLineFeed.ODD_EVEN);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.e(TAG, e.toString());
}
}
示例15: chartRender
import org.xclcharts.common.DensityUtil; //导入依赖的package包/类
private void chartRender()
{
try {
//标签显示(隐藏,显示在中间,显示在扇区外面,折线注释方式)
chart.setLabelStyle(XEnum.SliceLabelStyle.INSIDE);
//图的内边距
//注释折线较长,缩进要多些
int [] ltrb = new int[4];
ltrb[0] = DensityUtil.dip2px(getContext(), 30); //left
ltrb[1] = DensityUtil.dip2px(getContext(), 55); //top
ltrb[2] = DensityUtil.dip2px(getContext(), 30); //right
ltrb[3] = DensityUtil.dip2px(getContext(), 30); //bottom
chart.setPadding(ltrb[0], ltrb[1], ltrb[2], ltrb[3]);
//设定数据源
chart.setDataSource(chartData);
//标题
chart.setTitle("图表点击演示");
chart.addSubtitle("(XCL-Charts Demo)");
chart.setTitleVerticalAlign(XEnum.VerticalAlign.BOTTOM);
chart.getLabelPaint().setTextSize(30);
chart.getLabelPaint().setFakeBoldText(true);
chart.getLabelPaint().setColor(Color.WHITE);
//激活点击监听
chart.ActiveListenItemClick();
//显示标签框
chart.getPlotLabel().setLabelBoxStyle(XEnum.LabelBoxStyle.RECT);
// chart.getPlotLabel().setLabelBoxStyle(XEnum.LabelBoxStyle.RECT)
chart.getPlotLabel().getBox().setBorderLineColor(Color.rgb(0, 126, 231));
} catch (Exception e) {
// TODO Auto-generated catch block
Log.e(TAG, e.toString());
}
}