本文整理汇总了Java中org.xclcharts.common.DensityUtil.dip2px方法的典型用法代码示例。如果您正苦于以下问题:Java DensityUtil.dip2px方法的具体用法?Java DensityUtil.dip2px怎么用?Java DensityUtil.dip2px使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xclcharts.common.DensityUtil
的用法示例。
在下文中一共展示了DensityUtil.dip2px方法的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: 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;
}
示例9: 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);
}
示例10: 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);
}
示例11: 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());
}
}
示例12: 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());
}
}
示例13: chartRender
import org.xclcharts.common.DensityUtil; //导入方法依赖的package包/类
private void chartRender()
{
try{
//设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....
int [] ltrb = getBarLnDefaultSpadding();
//chart.setPadding(ltrb[0], ltrb[1], ltrb[2], ltrb[3]);
float left = DensityUtil.dip2px(getContext(), 40); //left 40
float right = DensityUtil.dip2px(getContext(), 40); //right 20
chart.setPadding(left, ltrb[1],right, ltrb[3]); //ltrb[2]
//轴数据源
//标签轴
chart.setCategories(mLabels);
//数据轴
chart.setDataSource(mDataset);
//仅横向平移
chart.setPlotPanMode(XEnum.PanMode.HORIZONTAL);
//数据轴最大值
chart.getDataAxis().setAxisMax(300);
chart.getDataAxis().setAxisMin(0);
//数据轴刻度间隔
chart.getDataAxis().setAxisSteps(50);
//网格
chart.getPlotGrid().showHorizontalLines();
chart.getPlotGrid().showVerticalLines();
//把轴线和刻度线给隐藏起来
//chart.getDataAxis().hideAxisLine();
chart.getDataAxis().hideTickMarks();
// chart.getCategoryAxis().hideAxisLine();
chart.getCategoryAxis().hideTickMarks();
chart.getDataAxis().setTickLabelRotateAngle(-90);
chart.getDataAxis().getTickLabelPaint().setColor(Color.RED);
chart.getCategoryAxis().getTickLabelPaint().setColor(Color.RED);
//标题
chart.setTitle("混合图(区域、折线、饼图)");
chart.addSubtitle("(XCL-Charts Demo)");
//轴标题
//chart.getAxisTitle().setLowerAxisTitle("(时间点)");
//透明度
chart.setAreaAlpha(200);
//显示图例
chart.getPlotLegend().hide();
//把轴线设成和横向网络线一样和大小和颜色,演示下定制性,这块问得人较多
PlotGrid plot = chart.getPlotGrid();
chart.getDataAxis().getAxisPaint().setStrokeWidth(
plot.getHorizontalLinePaint().getStrokeWidth());
chart.getCategoryAxis().getAxisPaint().setStrokeWidth(
plot.getHorizontalLinePaint().getStrokeWidth());
chart.getDataAxis().getAxisPaint().setColor(
plot.getHorizontalLinePaint().getColor());
chart.getCategoryAxis().getAxisPaint().setColor(
plot.getHorizontalLinePaint().getColor());
chart.getDataAxis().getTickMarksPaint().setColor(
plot.getHorizontalLinePaint().getColor());
chart.getCategoryAxis().getTickMarksPaint().setColor(
plot.getHorizontalLinePaint().getColor());
plot.hideHorizontalLines();
//激活点击监听
chart.ActiveListenItemClick();
//为了让触发更灵敏,可以扩大5px的点击监听范围
chart.extPointClickRange(10);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.e(TAG, e.toString());
}
}
示例14: chartRenderLn
import org.xclcharts.common.DensityUtil; //导入方法依赖的package包/类
private void chartRenderLn()
{
try {
//设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....
int [] ltrb = getBarLnDefaultSpadding();
float left = DensityUtil.dip2px(getContext(), 40); //left 40
float right = DensityUtil.dip2px(getContext(), 40); //right 20
chartLn.setPadding(left, ltrb[1],right, ltrb[3]); //ltrb[2]
//设定数据源
chartLn.setCategories(mLabels);
chartLn.setDataSource(chartData);
//数据轴最大值
chartLn.getDataAxis().setAxisMax(70);
//数据轴刻度间隔
chartLn.getDataAxis().setAxisSteps(10);
//仅横向平移
chartLn.setPlotPanMode(XEnum.PanMode.HORIZONTAL);
//背景网格
chartLn.getPlotGrid().hideEvenRowBgColor();
chartLn.getPlotGrid().hideHorizontalLines();
chartLn.getPlotGrid().hideOddRowBgColor();
chartLn.getPlotGrid().hideVerticalLines();
//chartLn.getPlotGrid().showHorizontalLines();
//chartLn.getDataAxis().hideAxisLine();
chartLn.getDataAxis().hideTickMarks();
//chartLn.getCategoryAxis().hideAxisLine();
chartLn.getCategoryAxis().hideTickMarks();
chartLn.getDataAxis().setTickLabelRotateAngle(-90);
chartLn.getDataAxis().getTickLabelPaint().setColor(Color.rgb(106, 218, 92));
chartLn.getCategoryAxis().getTickLabelPaint().setColor(Color.rgb(106, 218, 92));
chartLn.getDataAxis().setHorizontalTickAlign(Align.RIGHT);
chartLn.getDataAxis().getTickLabelPaint().setTextAlign(Align.LEFT);
//调整轴显示位置
chartLn.setDataAxisLocation(XEnum.AxisLocation.RIGHT);
chartLn.setCategoryAxisLocation(XEnum.AxisLocation.TOP);
//把轴线设成和横向网络线一样和大小和颜色,演示下定制性,这块问得人较多
PlotGrid plot = chart.getPlotGrid();
chartLn.getDataAxis().getAxisPaint().setStrokeWidth(
plot.getHorizontalLinePaint().getStrokeWidth());
chartLn.getCategoryAxis().getAxisPaint().setStrokeWidth(
plot.getHorizontalLinePaint().getStrokeWidth());
chartLn.getDataAxis().getAxisPaint().setColor(
plot.getHorizontalLinePaint().getColor());
chartLn.getCategoryAxis().getAxisPaint().setColor(
plot.getHorizontalLinePaint().getColor());
chartLn.getDataAxis().getTickMarksPaint().setColor(
plot.getHorizontalLinePaint().getColor());
chartLn.getCategoryAxis().getTickMarksPaint().setColor(
plot.getHorizontalLinePaint().getColor());
//图例显示在正下方
chartLn.getPlotLegend().setVerticalAlign(XEnum.VerticalAlign.BOTTOM);
chartLn.getPlotLegend().setHorizontalAlign(XEnum.HorizontalAlign.CENTER);
} catch (Exception e) {
// TODO Auto-generated catch block
Log.e(TAG, e.toString());
}
}
示例15: chartRenderLnAxes
import org.xclcharts.common.DensityUtil; //导入方法依赖的package包/类
private void chartRenderLnAxes()
{
try {
//设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....
int [] ltrb = getBarLnDefaultSpadding();
float left = DensityUtil.dip2px(getContext(), 20); //left 40
float right = DensityUtil.dip2px(getContext(), 20); //right 20
chartLnAxes.setPadding(left, ltrb[1],right, ltrb[3]); //ltrb[2]
//设定数据源
chartLnAxes.setCategories(mLabelsAxes);
chartLnAxes.setDataSource(chartDataAxes);
//数据轴最大值
chartLnAxes.getDataAxis().setAxisMax(70);
//数据轴刻度间隔
chartLnAxes.getDataAxis().setAxisSteps(10);
//标签轴最大值
chartLnAxes.setCategoryAxisMax(70);
//标签轴最小值
chartLnAxes.setCategoryAxisMin(0);
chartLnAxes.getPlotLegend().hide();
//背景网格
chartLnAxes.getPlotGrid().hideEvenRowBgColor();
chartLnAxes.getPlotGrid().hideHorizontalLines();
chartLnAxes.getPlotGrid().hideOddRowBgColor();
chartLnAxes.getPlotGrid().hideVerticalLines();
chartLnAxes.getDataAxis().hideAxisLine();
chartLnAxes.getDataAxis().hideTickMarks();
chartLnAxes.getCategoryAxis().hideAxisLine();
chartLnAxes.getCategoryAxis().hideTickMarks();
chartLnAxes.getCategoryAxis().setTickLabelRotateAngle(-90);
chartLnAxes.getDataAxis().setTickLabelRotateAngle(-90);
chartLnAxes.getDataAxis().getTickLabelPaint().setColor(Color.rgb(48, 145, 255));
chartLnAxes.getCategoryAxis().getTickLabelPaint().setColor(Color.rgb(199, 64, 219));
chartLnAxes.getDataAxis().setHorizontalTickAlign(Align.RIGHT);
chartLnAxes.getDataAxis().getTickLabelPaint().setTextAlign(Align.LEFT);
//调整轴显示位置
chartLnAxes.setDataAxisLocation(XEnum.AxisLocation.RIGHT);
chartLnAxes.setCategoryAxisLocation(XEnum.AxisLocation.LEFT);
} catch (Exception e) {
// TODO Auto-generated catch block
Log.e(TAG, e.toString());
}
}