Back to project page AndroidGraph.
The source code is released under:
MIT License
If you think the Android project AndroidGraph listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.nimble.android_graph.Graph_Base; /*from ww w . j a va 2 s. c om*/ import android.content.Context; import android.graphics.Color; import android.graphics.Paint; import android.util.AttributeSet; import android.view.SurfaceView; /** * Created by Mike on 25/07/2014. */ public abstract class GraphDataSettings extends SurfaceView { protected int axisColour; protected int gridColour; protected int labelColour; protected int backgroundColour; protected boolean useGrid; protected Coord2d<String> axisLabels; protected int labelSize; protected boolean useLabels; protected Range2d margin; protected Coord2d<Float> gridSpacing; protected Range2d gridSize; protected Paint paint; protected final static float delta = 0.001f; public GraphDataSettings(Context context) { super(context); gridSpacing = new Coord2d<Float>(0f, 0f); axisLabels = new Coord2d<String>("", ""); paint = new Paint(); setupDefaults(); } public GraphDataSettings(Context context, AttributeSet attr) { super(context, attr); gridSpacing = new Coord2d<Float>(0f, 0f); axisLabels = new Coord2d<String>("", ""); paint = new Paint(); setupDefaults(); } protected void setupDefaults() { paint.setAntiAlias(true); paint.setStrokeWidth(0); useLabels = false; labelSize = 30; gridSize = new Range2d(20, 20); margin = new Range2d(20, 20); axisColour = Color.BLACK; gridColour = Color.LTGRAY; labelColour = Color.WHITE; backgroundColour = Color.WHITE; } public void setGridSize(Range2d value) { gridSize = value; onSizeChanged(getWidth(), getHeight(), 0, 0); } public void setAxisColour(int colour) { axisColour = colour; } public void setGridColour(int colour) { gridColour = colour; } public void setLabelColour(int colour) { labelColour = colour; } public void setBackgroundColour(int colour) { backgroundColour = colour; } public void setLabels(String x, String y) { paint.setTextSize(labelSize); axisLabels.update(x, y); useLabels = true; onSizeChanged(getWidth(), getHeight(), 0, 0); } public void updateLabelSize(int size) { labelSize = size; paint.setTextSize(labelSize); onSizeChanged(getWidth(), getHeight(), 0, 0); } public void setLabels(String x, String y, int size) { labelSize = size; setLabels(x, y); } public void prepForDrawing() {} }