目前分類:繪圖類(Draw) (106)

瀏覽方式: 標題列表 簡短摘要

1728_140626091951_1  

程式碼下載


shadow 發表在 痞客邦 PIXNET 留言(0) 人氣()

1728_140705104027_2  

程式碼下載


shadow 發表在 痞客邦 PIXNET 留言(0) 人氣()

1728_140716153418_1  

程式碼下載


shadow 發表在 痞客邦 PIXNET 留言(0) 人氣()

1728_140804174442_1  

程式碼下載


shadow 發表在 痞客邦 PIXNET 留言(0) 人氣()

1728_140903170714_1  

程式碼下載


shadow 發表在 痞客邦 PIXNET 留言(0) 人氣()

1728_141029115304_1  

程式碼下載


shadow 發表在 痞客邦 PIXNET 留言(0) 人氣()

1728_140804175718_2  

程式碼下載


shadow 發表在 痞客邦 PIXNET 留言(1) 人氣()

1728_141217164840_1  

程式碼下載


shadow 發表在 痞客邦 PIXNET 留言(0) 人氣()

1728_141225163342_1  

 

程式碼下載

shadow 發表在 痞客邦 PIXNET 留言(0) 人氣()

20141106192108428  

 

package com.example.testxyjar;

import utils.XYViewDrawBitmap;
import utils.XYViewDrawLine;
import utils.XYViewDrawPointer;
import utils.XYViewDrawText;
import view.XYView;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.Menu;
import bean.XYViewBitmapBean;
import bean.XYViewLineBean;
import bean.XYViewPointerBean;
import bean.XYViewTextBean;

public class MainActivity extends Activity {
    private XYView xyview;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initCache();
        initView();
        initData();
    }

    private void initCache() {
    }

    private void initView() {
        xyview = (XYView) findViewById(R.id.main_page_view_xyview);

    }

    private void initData() {
        // 第一个点
        XYViewPointerBean xyPointer = new XYViewPointerBean();
        float data[] = { 10.0f, 20.0f, -10.0f, 40.0f, 20.0f, 50.0f };
        xyPointer.setData(data);
        xyPointer.setColor(Color.RED);
        xyPointer.setStrokeWidth(20.0f);
        XYViewDrawPointer xyViewDrawPointer = new XYViewDrawPointer(xyPointer);
        xyview.addXYViewDrawable(xyViewDrawPointer);
        // 画图
        XYViewBitmapBean xybitmap = new XYViewBitmapBean();
        float dataBitmap[] = { 10.0f, 20.0f, -10.0f, 40.0f, 20.0f, 50.0f };
        Drawable d = getResources().getDrawable(
                R.drawable.weather_temperature_point_icon_high);
        BitmapDrawable bd = (BitmapDrawable) d;
        Bitmap b = bd.getBitmap();
        Bitmap[] bs = { b, b, b, b, b, b };
        xybitmap.setY_away(40);
        xybitmap.setData(dataBitmap);
        xybitmap.setBitmapData(bs);
        XYViewDrawBitmap xyViewDrawBitmap = new XYViewDrawBitmap(xybitmap);
        xyview.addXYViewDrawable(xyViewDrawBitmap);
        // 第一个线
        XYViewLineBean xyLineBean = new XYViewLineBean();
        xyLineBean.setData(data);
        xyLineBean.setColor(Color.BLACK);
        xyLineBean.setStrokeWidth(2.0f);
        XYViewDrawLine xyViewLine = new XYViewDrawLine(xyLineBean);
        xyview.addXYViewDrawable(xyViewLine);
        //
        XYViewTextBean xyTexter = new XYViewTextBean();
        float dataText[] = { 10.0f, 20.0f, -10.0f, 40.0f, 20.0f, 50.0f };
        String [] dataStrs={"大娃","二娃","三娃","四娃","五娃","六娃"};
        xyTexter.setData(dataText);
        xyTexter.setColor(Color.RED);
        xyTexter.setStrokeWidth(1.0f);
        xyTexter.setTextSize(18.0f);
        xyTexter.setTextData(dataStrs);
        XYViewDrawText xyViewTexter = new XYViewDrawText(xyTexter);
        xyview.addXYViewDrawable(xyViewTexter);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

}

shadow 發表在 痞客邦 PIXNET 留言(0) 人氣()

未命名  

程式碼下載


shadow 發表在 痞客邦 PIXNET 留言(0) 人氣()

public Bitmap drawRect(Bitmap bitmap) {
Paint paint = new Paint();
paint.setColor(Color.RED);

shadow 發表在 痞客邦 PIXNET 留言(0) 人氣()

public Bitmap convert(Bitmap mBitmap, int width, int height) {
                int w = mBitmap.getWidth();
                int h = mBitmap.getHeight();

                Bitmap newBitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
                Canvas mCanvas = new Canvas(newBitmap);
                Matrix matrix = new Matrix();
                matrix.postScale(1, -1);
                matrix.postRotate(-90);
                Bitmap mBitmap2 = Bitmap.createBitmap(mBitmap, 0, 0, w, h, matrix, true);
                mCanvas.drawBitmap(mBitmap2, new Rect(0, 0, mBitmap2.getWidth(), mBitmap2.getHeight()), new Rect(0, 0, width, height), null);
                return newBitmap;
        }

shadow 發表在 痞客邦 PIXNET 留言(0) 人氣()

public void drawAL(int fx, int fy, int sx, int sy) {
double H = 8;
double L = 3.5;

shadow 發表在 痞客邦 PIXNET 留言(0) 人氣()

1.定義顏色:

<color name="transparent">#00000000</color>
2設置canvas顏色:

shadow 發表在 痞客邦 PIXNET 留言(0) 人氣()

package com.example.test.achartengine;

import java.util.ArrayList;
import java.util.List;

import org.achartengine.ChartFactory;
import org.achartengine.chart.PointStyle;
import org.achartengine.model.XYMultipleSeriesDataset;
import org.achartengine.renderer.XYMultipleSeriesRenderer;
import org.achartengine.renderer.XYSeriesRenderer;

import android.content.Context;
import android.graphics.Color;
import android.graphics.Paint.Align;
import android.view.View;

public class LinearChart {

        public AbstractDemoChart abstractDemoChart;
        public XYMultipleSeriesRenderer renderer;
        public XYMultipleSeriesDataset dataset;

        private String[] titles;
        private List<double[]> Xvalues = new ArrayList<double[]>();
        private List<double[]> Yvalues = new ArrayList<double[]>();
        private int[] colors;
        private PointStyle[] styles;

        public LinearChart(Context context) {
                abstractDemoChart = new AbstractDemoChart();

                init();
        }

        private void init() {
                titles = new String[] { "Monday", "Tuesday", "Wednesday", "Thursday" };
                for (int i = 0; i < titles.length; i++) {
                        Xvalues.add(new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 });
                }

                Yvalues.add(new double[] { 12.3, 12.5, 13.8, 16.8, 20.4, 24.4, 26.4, 26.1, 23.6, 20.3, 17.2, 13.9 });
                Yvalues.add(new double[] { 10, 10, 12, 15, 20, 24, 26, 26, 23, 18, 14, 11 });
                Yvalues.add(new double[] { 5, 5.3, 8, 12, 17, 22, 24.2, 24, 19, 15, 9, 6 });
                Yvalues.add(new double[] { 9, 10, 11, 15, 19, 23, 26, 25, 22, 18, 13, 10 });

                colors = new int[] { Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW };

                styles = new PointStyle[] { PointStyle.CIRCLE, PointStyle.DIAMOND, PointStyle.TRIANGLE, PointStyle.SQUARE };

                renderer = abstractDemoChart.buildRenderer(colors, styles);

                dataset = abstractDemoChart.buildDataset(titles, Xvalues, Yvalues);
                
//              dataset.addSeries(series);
        }

        public View execute(Context context) {

                int lenght = renderer.getSeriesRendererCount();
                for (int i = 0; i < lenght; i++) {
                        ((XYSeriesRenderer) renderer.getSeriesRendererAt(i)).setFillPoints(true);
                }
                abstractDemoChart.setChartSettings(renderer, "Temperatuer", "Week", "Temp", 0, 13, -10, 30, Color.LTGRAY, Color.LTGRAY);
                renderer.setXLabels(12);
                renderer.setYLabels(10);
                renderer.setShowGrid(true);
                renderer.setXLabelsAlign(Align.RIGHT);
                renderer.setYLabelsAlign(Align.RIGHT);
                renderer.setZoomButtonsVisible(false);
                renderer.setPanEnabled(true, false); // 左右移动
                renderer.setPanLimits(new double[] { -10, 20, -10, 40 });
                renderer.setZoomLimits(new double[] { -10, 20, -10, 40 });

                // XYSeries series = dataset.getSeriesAt(0);
                // series.addAnnotation("Vacation", 6, 30);
                return ChartFactory.getLineChartView(context, dataset, renderer);
        }
}

shadow 發表在 痞客邦 PIXNET 留言(0) 人氣()

20131125141332_855  

第一步:

获取Android设备的屏幕大小

shadow 發表在 痞客邦 PIXNET 留言(0) 人氣()

开源代码 链接:https://github.com/jondwillis/AChartEngine/tree/master/achartengine
设置Linechart Point style 设置为圆点 实心
XYSeriesRenderer r = new XYSeriesRenderer();

shadow 發表在 痞客邦 PIXNET 留言(0) 人氣()

17-51-35_xqw4fx7wfq  

17-51-52_blclfl6mwi  

 程式碼及開發工具下載

shadow 發表在 痞客邦 PIXNET 留言(0) 人氣()

140216183180141  

/*
 * BaseChart.java

shadow 發表在 痞客邦 PIXNET 留言(0) 人氣()