本文整理匯總了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());
}
}