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