|
|
@@ -0,0 +1,2325 @@
|
|
|
+package com.desfate.chart;
|
|
|
+
|
|
|
+import android.content.Context;
|
|
|
+import android.graphics.Canvas;
|
|
|
+import android.graphics.Color;
|
|
|
+import android.graphics.DashPathEffect;
|
|
|
+import android.graphics.Paint;
|
|
|
+import android.graphics.PathEffect;
|
|
|
+import android.graphics.PointF;
|
|
|
+import android.graphics.RectF;
|
|
|
+import android.util.AttributeSet;
|
|
|
+import android.view.GestureDetector;
|
|
|
+import android.view.GestureDetector.OnGestureListener;
|
|
|
+import android.view.MotionEvent;
|
|
|
+import android.view.ScaleGestureDetector;
|
|
|
+import android.view.ScaleGestureDetector.OnScaleGestureListener;
|
|
|
+
|
|
|
+import com.desfate.chart.data.ChartLineColors;
|
|
|
+import com.desfate.chart.event.ITouchEventNotify;
|
|
|
+import com.desfate.chart.event.ITouchEventResponse;
|
|
|
+import com.desfate.chart.util.LogUtils;
|
|
|
+
|
|
|
+import java.text.NumberFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * GridChart is base type of all the charts that use a grid to display like
|
|
|
+ * line-chart stick-chart etc. GridChart implemented a simple grid with basic
|
|
|
+ * functions what can be used in it's inherited charts.
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * GridChartは全部グリドチャートのベスクラスです、一部処理は共通化け実現した。
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * GridChart是所有网格图表的基础类对象,它实现了基本的网格图表功能,这些功能将被它的继承类使用
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+public class GridChart extends BaseChart implements OnGestureListener, OnScaleGestureListener, ITouchEventNotify,
|
|
|
+ ITouchEventResponse {
|
|
|
+ private int linesData = 0;
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * default background color
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 背景の色のデフォルト値
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 默认背景色
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final int DEFAULT_BACKGROUND_COLOR = Color.BLACK;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * default color of X axis
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * X軸の色のデフォルト値
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 默认坐标轴X的显示颜色
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final int DEFAULT_AXIS_X_COLOR = Color.RED;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * default color of Y axis
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * Y軸の色のデフォルト値
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 默认坐标轴Y的显示颜色
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final int DEFAULT_AXIS_Y_COLOR = Color.RED;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * default color of grid‘s longitude line
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 経線の色のデフォルト値
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 默认网格经线的显示颜色
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final int DEFAULT_LONGITUDE_COLOR = Color.RED;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * default color of grid‘s latitude line
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 緯線の色のデフォルト値
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 默认网格纬线的显示颜色
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final int DEFAULT_LAITUDE_COLOR = Color.RED;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * default margin of the axis to the left border
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 轴線より左枠線の距離のデフォルト値
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 默认轴线左边距
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final float DEFAULT_AXIS_MARGIN_LEFT = 42f;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * default margin of the axis to the bottom border
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 轴線より下枠線の距離のデフォルト値
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 默认轴线下边距
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final float DEFAULT_AXIS_MARGIN_BOTTOM = 16f;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * default margin of the axis to the top border
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 轴線より上枠線の距離のデフォルト値
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 默认轴线上边距
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final float DEFAULT_AXIS_MARGIN_TOP = 5f;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * default margin of the axis to the right border
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 轴線より右枠線の距離のデフォルト値
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 轴线右边距
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final float DEFAULT_AXIS_MARGIN_RIGHT = 5f;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * default numbers of grid‘s latitude line
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 緯線の数量のデフォルト値
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 网格纬线的数量
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final int DEFAULT_LATITUDE_NUM = 4;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * default numbers of grid‘s longitude line
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 経線の数量のデフォルト値
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 网格经线的数量
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final int DEFAULT_LONGITUDE_NUM = 3;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Should display longitude line?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 経線を表示するか?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 默认经线是否显示
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final boolean DEFAULT_DISPLAY_LONGITUDE = Boolean.TRUE;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Should display longitude as dashed line?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 経線を点線にするか?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 默认经线是否显示为虚线
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final boolean DEFAULT_DASH_LONGITUDE = Boolean.TRUE;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Should display longitude line?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 緯線を表示するか?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 纬线是否显示
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final boolean DEFAULT_DISPLAY_LATITUDE = Boolean.TRUE;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Should display latitude as dashed line?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 緯線を点線にするか?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 纬线是否显示为虚线
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final boolean DEFAULT_DASH_LATITUDE = Boolean.TRUE;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Should display the degrees in X axis?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * X軸のタイトルを表示するか?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * X轴上的标题是否显示
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final boolean DEFAULT_DISPLAY_AXIS_X_TITLE = Boolean.TRUE;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Should display the degrees in Y axis?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * Y軸のタイトルを表示するか?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 默认Y轴上的标题是否显示
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final boolean DEFAULT_DISPLAY_AXIS_Y_TITLE = Boolean.TRUE;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Should display the border?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 枠を表示するか?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 默认控件是否显示边框
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final boolean DEFAULT_DISPLAY_BORDER = Boolean.TRUE;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * default color of text for the longitude degrees display
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 経度のタイトルの色のデフォルト値
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 默认经线刻度字体颜色
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final int DEFAULT_BORDER_COLOR = Color.RED;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * default color of text for the longitude degrees display
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 経度のタイトルの色のデフォルト値
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 经线刻度字体颜色
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final int DEFAULT_LONGITUDE_FONT_COLOR = Color.WHITE;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * default font size of text for the longitude degrees display
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 経度のタイトルのフォントサイズのデフォルト値
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 经线刻度字体大小
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final int DEFAULT_LONGITUDE_FONT_SIZE = 12;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * default color of text for the latitude degrees display
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 緯度のタイトルの色のデフォルト値
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 纬线刻度字体颜色
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final int DEFAULT_LATITUDE_FONT_COLOR = Color.RED;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * default font size of text for the latitude degrees display
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 緯度のタイトルのフォントサイズのデフォルト値
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 默认纬线刻度字体大小
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final int DEFAULT_LATITUDE_FONT_SIZE = 12;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * default titles' max length for display of Y axis
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * Y軸の表示用タイトルの最大文字長さのデフォルト値
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 默认Y轴标题最大文字长度
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final int DEFAULT_AXIS_Y_MAX_TITLE_LENGTH = 5;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * default dashed line type
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 点線タイプのデフォルト値
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 默认虚线效果
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final PathEffect DEFAULT_DASH_EFFECT = new DashPathEffect(
|
|
|
+ new float[]{3, 3, 3, 3}, 1);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Should display the Y cross line if grid is touched?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 默认在控件被点击时,显示十字线
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final boolean ENABLE_CROSS_ON_TOUCH = Boolean.TRUE;
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Should display the Y cross line if grid is touched?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * タッチしたポイントがある場合、十字線の垂直線を表示するか?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 默认在控件被点击时,不显示十字竖线线
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final boolean DEFAULT_DISPLAY_CROSS_X_ON_TOUCH = Boolean.FALSE;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Should display the Y cross line if grid is touched?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * タッチしたポイントがある場合、十字線の水平線を表示するか?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 默认在控件被点击时,不显示十字横线线
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public static final boolean DEFAULT_DISPLAY_CROSS_Y_ON_TOUCH = Boolean.FALSE;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * background color
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 背景の色
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 背景色
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private int backgroundColor = DEFAULT_BACKGROUND_COLOR;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Color of X axis
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * X軸の色
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 坐标轴X的显示颜色
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private int axisXColor = DEFAULT_AXIS_X_COLOR;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Color of Y axis
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * Y軸の色
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 坐标轴Y的显示颜色
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private int axisYColor = DEFAULT_AXIS_Y_COLOR;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Color of grid‘s longitude line
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 経線の色
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 网格经线的显示颜色
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private int longitudeColor = DEFAULT_LONGITUDE_COLOR;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Color of grid‘s latitude line
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 緯線の色
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 网格纬线的显示颜色
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private int latitudeColor = DEFAULT_LAITUDE_COLOR;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * 相关联图表的轴线左边距
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private float notifyAxisMarginLeft = DEFAULT_AXIS_MARGIN_LEFT;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Margin of the axis to the left border
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 轴線より左枠線の距離
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 轴线左边距
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private float axisMarginLeft = DEFAULT_AXIS_MARGIN_LEFT;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Margin of the axis to the bottom border
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 轴線より下枠線の距離
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 轴线下边距
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private float axisMarginBottom = DEFAULT_AXIS_MARGIN_BOTTOM;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Margin of the axis to the top border
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 轴線より上枠線の距離
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 轴线上边距
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private float axisMarginTop = DEFAULT_AXIS_MARGIN_TOP;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Margin of the axis to the right border
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 轴線より右枠線の距離
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 轴线右边距
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private float axisMarginRight = DEFAULT_AXIS_MARGIN_RIGHT;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Should display the degrees in X axis?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * X軸のタイトルを表示するか?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * X轴上的标题是否显示
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private boolean displayAxisXTitle = DEFAULT_DISPLAY_AXIS_X_TITLE;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Should display the degrees in Y axis?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * Y軸のタイトルを表示するか?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * Y轴上的标题是否显示
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private boolean displayAxisYTitle = DEFAULT_DISPLAY_AXIS_Y_TITLE;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Numbers of grid‘s latitude line
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 緯線の数量
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 网格纬线的数量
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private int latitudeNum = DEFAULT_LATITUDE_NUM;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Numbers of grid‘s longitude line
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 経線の数量
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 网格经线的数量
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private int longitudeNum = DEFAULT_LONGITUDE_NUM;
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * 小数位
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private int decimalNum = 2;//!< @brief 小数位
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Should display longitude line?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 経線を表示するか?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 经线是否显示
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private boolean displayLongitude = DEFAULT_DISPLAY_LONGITUDE;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Should display longitude as dashed line?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 経線を点線にするか?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 经线是否显示为虚线
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private boolean dashLongitude = DEFAULT_DASH_LONGITUDE;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Should display longitude line?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 緯線を表示するか?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 纬线是否显示
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private boolean displayLatitude = DEFAULT_DISPLAY_LATITUDE;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Should display latitude as dashed line?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 緯線を点線にするか?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 纬线是否显示为虚线
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private boolean dashLatitude = DEFAULT_DASH_LATITUDE;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * dashed line type
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 点線タイプ?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 虚线效果
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private PathEffect dashEffect = DEFAULT_DASH_EFFECT;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Should display the border?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 枠を表示するか?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 控件是否显示边框
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private boolean displayBorder = DEFAULT_DISPLAY_BORDER;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Color of grid‘s border line
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 枠線の色
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 图边框的颜色
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private int borderColor = DEFAULT_BORDER_COLOR;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Color of text for the longitude degrees display
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 経度のタイトルの色
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 经线刻度字体颜色
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private int longitudeFontColor = DEFAULT_LONGITUDE_FONT_COLOR;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Font size of text for the longitude degrees display
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 経度のタイトルのフォントサイズ
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 经线刻度字体大小
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private int longitudeFontSize = DEFAULT_LONGITUDE_FONT_SIZE;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Color of text for the latitude degrees display
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 緯度のタイトルの色
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 纬线刻度字体颜色
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private int latitudeFontColor = DEFAULT_LATITUDE_FONT_COLOR;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Font size of text for the latitude degrees display
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 緯度のタイトルのフォントサイズ
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 纬线刻度字体大小
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private int latitudeFontSize = DEFAULT_LATITUDE_FONT_SIZE;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Titles Array for display of X axis
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * X軸の表示用タイトル配列
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * X轴标题数组
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private List<String> axisXTitles;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Titles for display of Y axis
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * Y軸の表示用タイトル配列
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * Y轴标题数组
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private List<String> axisYTitles;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Titles' max length for display of Y axis
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * Y軸の表示用タイトルの最大文字長さ
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * Y轴标题最大文字长度
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private int axisYMaxTitleLength = DEFAULT_AXIS_Y_MAX_TITLE_LENGTH;
|
|
|
+
|
|
|
+ private boolean enableCrossOnTouch = ENABLE_CROSS_ON_TOUCH;
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Should display the Y cross line if grid is touched?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * タッチしたポイントがある場合、十字線の垂直線を表示するか?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 在控件被点击时,显示十字竖线线
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private boolean displayCrossXOnTouch = DEFAULT_DISPLAY_CROSS_X_ON_TOUCH;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Should display the Y cross line if grid is touched?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * タッチしたポイントがある場合、十字線の水平線を表示するか?
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 在控件被点击时,显示十字横线线
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private boolean displayCrossYOnTouch = DEFAULT_DISPLAY_CROSS_Y_ON_TOUCH;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Touched point inside of grid
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * タッチしたポイント
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 单点触控的选中点
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private PointF touchPoint;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Touched point inside of grid
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * タッチしたポイント
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 触控的横向滑动距离
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private float touchDistanceX = 0;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Touched point’s X value inside of grid
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * タッチしたポイントのX
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 单点触控的选中点的X
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private float clickPostX = 0f;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Touched point’s Y value inside of grid
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * タッチしたポイントのY
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 单点触控的选中点的Y
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private float clickPostY = 0f;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Event will notify objects' list
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * イベント通知対象リスト
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 事件通知对象列表
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private List<ITouchEventResponse> notifyList;
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * 起始位置
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ private int startIndex = 0;
|
|
|
+
|
|
|
+ private boolean can_move = false;//针对分时图表做的标志位
|
|
|
+
|
|
|
+
|
|
|
+ private GestureDetector mDetector;
|
|
|
+ private ScaleGestureDetector mScaleDetector;
|
|
|
+ /**
|
|
|
+ * 当前行情的最新价
|
|
|
+ */
|
|
|
+ private String tasLastPrice = "";
|
|
|
+// private boolean isOnScale = false;
|
|
|
+
|
|
|
+ private String currentYear = "";//当前年
|
|
|
+
|
|
|
+ private int newPriceColor = 0;
|
|
|
+
|
|
|
+ /*
|
|
|
+ * (non-Javadoc)
|
|
|
+ *
|
|
|
+ * @param context
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public GridChart(Context context) {
|
|
|
+ super(context);
|
|
|
+ mDetector = new GestureDetector(this);
|
|
|
+ mScaleDetector = new ScaleGestureDetector(context, this);
|
|
|
+ initDatas();
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * (non-Javadoc)
|
|
|
+ *
|
|
|
+ * @param context
|
|
|
+ *
|
|
|
+ * @param attrs
|
|
|
+ *
|
|
|
+ * @param defStyle
|
|
|
+ *
|
|
|
+ * AttributeSet, int)
|
|
|
+ */
|
|
|
+ public GridChart(Context context, AttributeSet attrs, int defStyle) {
|
|
|
+ super(context, attrs, defStyle);
|
|
|
+ mDetector = new GestureDetector(this);
|
|
|
+ mScaleDetector = new ScaleGestureDetector(context, this);
|
|
|
+ initDatas();
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * (non-Javadoc)
|
|
|
+ *
|
|
|
+ * @param context
|
|
|
+ *
|
|
|
+ * @param attrs
|
|
|
+ *
|
|
|
+ * AttributeSet)
|
|
|
+ */
|
|
|
+ public GridChart(Context context, AttributeSet attrs) {
|
|
|
+ super(context, attrs);
|
|
|
+ mDetector = new GestureDetector(this);
|
|
|
+ mScaleDetector = new ScaleGestureDetector(context, this);
|
|
|
+ initDatas();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initDatas() {
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTimeInMillis(System.currentTimeMillis());
|
|
|
+ currentYear = String.valueOf(calendar.get(Calendar.YEAR)) + "-";
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * (non-Javadoc)
|
|
|
+ *
|
|
|
+ * <p>Called when is going to draw this chart<p> <p>チャートを書く前、メソッドを呼ぶ<p>
|
|
|
+ * <p>绘制图表时调用<p>
|
|
|
+ *
|
|
|
+ * @param canvas
|
|
|
+ *
|
|
|
+ * @see android.view.View#onDraw(android.graphics.Canvas)
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ protected void onDraw(Canvas canvas) {
|
|
|
+ super.onDraw(canvas);
|
|
|
+
|
|
|
+ super.setBackgroundColor(backgroundColor);
|
|
|
+
|
|
|
+ drawXAxis(canvas);
|
|
|
+// drawYAxis(canvas);
|
|
|
+
|
|
|
+ if (this.displayBorder) {
|
|
|
+ drawBorder(canvas);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (displayLongitude || displayAxisXTitle) {
|
|
|
+ drawAxisGridX(canvas);
|
|
|
+ }
|
|
|
+ if (displayLatitude || displayAxisYTitle) {
|
|
|
+ drawAxisGridY(canvas);
|
|
|
+ }
|
|
|
+
|
|
|
+ drawChart(canvas);
|
|
|
+
|
|
|
+ if (displayCrossXOnTouch || displayCrossYOnTouch) {
|
|
|
+ drawWithFingerClick(canvas);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void drawChart(Canvas canvas) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean checkClickPos(MotionEvent event) {
|
|
|
+ return event.getX() <= this.getWidth() - this.getAxisMarginRight()
|
|
|
+ && event.getY() <= this.getHeight() - this.getAxisMarginBottom();
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean _move = true;
|
|
|
+
|
|
|
+ /*
|
|
|
+ * (non-Javadoc)
|
|
|
+ *
|
|
|
+ * <p>Called when chart is touched<p> <p>チャートをタッチしたら、メソッドを呼ぶ<p>
|
|
|
+ * <p>图表点击时调用<p>
|
|
|
+ *
|
|
|
+ * @param event
|
|
|
+ *
|
|
|
+ * @see android.view.View#onTouchEvent(MotionEvent)
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public boolean onTouchEvent(MotionEvent event) {
|
|
|
+ int action = event.getAction();
|
|
|
+ if (isEnableCrossOnTouch()) {
|
|
|
+ switch (action) {
|
|
|
+ case MotionEvent.ACTION_UP: {
|
|
|
+ displayCrossXOnTouch = displayCrossYOnTouch = true;
|
|
|
+ if (this.getClickPostX() > 0 || this.getClickPostY() > 0) {
|
|
|
+ this.setClickPostX(0);
|
|
|
+ this.setClickPostY(0);
|
|
|
+ this.invalidate();
|
|
|
+ notifyEventAll(ITouchEventNotify.EVENT_UP, this);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case MotionEvent.ACTION_MOVE: {
|
|
|
+ float postX = getClickPostX();
|
|
|
+ float hl = getAxisXPos(postX);
|
|
|
+ if (isCan_move()) {
|
|
|
+ if (linesData > 0 && hl > linesData && _move) {
|
|
|
+ if (postX > event.getX()) {
|
|
|
+ this.setClickPostX(maxDatasLength);
|
|
|
+ _move = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ this.setClickPostX(maxDatasLength);
|
|
|
+ this.setClickPostY(event.getY());
|
|
|
+ this.invalidate();
|
|
|
+ notifyEventAll(ITouchEventNotify.EVENT_CROSSONTOUCH, this);
|
|
|
+ break;
|
|
|
+ } else if ((this.getClickPostX() > 0 || this.getClickPostY() > 0) && checkClickPos(event) && maxDatasLength >= postX) {
|
|
|
+ _move = true;
|
|
|
+ this.setClickPostX(event.getX() > maxDatasLength ? maxDatasLength : event.getX());
|
|
|
+ this.setClickPostY(event.getY());
|
|
|
+ this.invalidate();
|
|
|
+ notifyEventAll(ITouchEventNotify.EVENT_CROSSONTOUCH, this);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ((this.getClickPostX() > 0 || this.getClickPostY() > 0) && checkClickPos(event)) {
|
|
|
+ this.setClickPostX(event.getX());
|
|
|
+ this.setClickPostY(event.getY());
|
|
|
+ this.invalidate();
|
|
|
+ notifyEventAll(ITouchEventNotify.EVENT_CROSSONTOUCH, this);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ boolean ret = this.mScaleDetector.onTouchEvent(event);
|
|
|
+ if (!mScaleDetector.isInProgress()) {
|
|
|
+ ret = this.mDetector.onTouchEvent(event);
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onDown(MotionEvent e) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 监听滑动
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
|
|
|
+ float velocityY) {
|
|
|
+ int startIndex = getStartIndex();
|
|
|
+ if (startIndex == 0 && (e2.getX() - e1.getX()) > 0) {
|
|
|
+ // 判断是否滑到最左边
|
|
|
+ notifyEventAll(ITouchEventNotify.EVENT_LEFTEND, this);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected float getClickPosXOffset() {
|
|
|
+ return 0.0f;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected float getItemWidth() {
|
|
|
+ return 1.0f;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected float getItemShowWidth() {
|
|
|
+ return 1.0f;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onLongPress(MotionEvent e) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ if (isEnableCrossOnTouch() && checkClickPos(e)) {
|
|
|
+ this.setClickPostX(e.getX());
|
|
|
+ this.setClickPostY(e.getY());
|
|
|
+ this.invalidate();
|
|
|
+ notifyEventAll(ITouchEventNotify.EVENT_CROSSONTOUCH, this);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
|
|
|
+ float distanceY) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onShowPress(MotionEvent e) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onSingleTapUp(MotionEvent event) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * draw some text with border
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 文字を書く、枠あり
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 绘制一段文本,并增加外框
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @param ptStart <p>
|
|
|
+ * start point
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 開始ポイント
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 开始点
|
|
|
+ * </p>
|
|
|
+ * @param ptEnd <p>
|
|
|
+ * end point
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 結束ポイント
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 结束点
|
|
|
+ * </p>
|
|
|
+ * @param content <p>
|
|
|
+ * text content
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 文字内容
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 文字内容
|
|
|
+ * </p>
|
|
|
+ * @param fontSize <p>
|
|
|
+ * font size
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 文字フォントサイズ
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 字体大小
|
|
|
+ * </p>
|
|
|
+ * @param canvas
|
|
|
+ */
|
|
|
+ private void drawAlphaTextBox(PointF ptStart, PointF ptEnd, String content,
|
|
|
+ int fontSize, Canvas canvas) {
|
|
|
+
|
|
|
+ Paint mPaintBox = new Paint();
|
|
|
+ mPaintBox.setColor(Color.LTGRAY);
|
|
|
+// mPaintBox.setAlpha(80);
|
|
|
+
|
|
|
+ Paint mPaintBoxLine = new Paint();
|
|
|
+ mPaintBoxLine.setColor(Color.BLACK);
|
|
|
+ mPaintBoxLine.setAntiAlias(true);
|
|
|
+
|
|
|
+ // draw a rectangle
|
|
|
+// canvas.drawRoundRect(new RectF(ptStart.x, ptStart.y, ptEnd.x, ptEnd.y),20.0f, 20.0f, mPaintBox);
|
|
|
+ canvas.drawRect(new RectF(ptStart.x, ptStart.y, ptEnd.x, ptEnd.y), mPaintBox);
|
|
|
+
|
|
|
+ // draw a rectangle' border
|
|
|
+// canvas.drawLine(ptStart.x, ptStart.y, ptStart.x, ptEnd.y, mPaintBoxLine);
|
|
|
+// canvas.drawLine(ptStart.x, ptEnd.y, ptEnd.x, ptEnd.y, mPaintBoxLine);
|
|
|
+// canvas.drawLine(ptEnd.x, ptEnd.y, ptEnd.x, ptStart.y, mPaintBoxLine);
|
|
|
+// canvas.drawLine(ptEnd.x, ptStart.y, ptStart.x, ptStart.y, mPaintBoxLine);
|
|
|
+
|
|
|
+ // draw text
|
|
|
+ canvas.drawText(content, ptStart.x, ptEnd.y, mPaintBoxLine);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void drawTextBox(PointF ptStart, PointF ptEnd, String content,
|
|
|
+ int fontSize, Canvas canvas, Paint textPaint) {
|
|
|
+
|
|
|
+ Paint mPaintBox = new Paint();
|
|
|
+ mPaintBox.setColor(Color.LTGRAY);
|
|
|
+
|
|
|
+ // draw a rectangle
|
|
|
+ canvas.drawRect(new RectF(ptStart.x, ptStart.y, ptEnd.x, ptEnd.y), mPaintBox);
|
|
|
+
|
|
|
+ // draw text
|
|
|
+ canvas.drawText(content, ptStart.x + 1f, ptEnd.y - 2f, textPaint);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * calculate degree title on X axis
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * X軸の目盛を計算する
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 计算X轴上显示的坐标值
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @param value <p>
|
|
|
+ * value for calculate
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 計算有用データ
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 计算用数据
|
|
|
+ * </p>
|
|
|
+ * @return String
|
|
|
+ * <p>
|
|
|
+ * degree
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 目盛
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 坐标值
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ protected float getAxisXGraduate(Object value) {
|
|
|
+
|
|
|
+ float length = super.getWidth() - axisMarginLeft - axisMarginRight - 4f;
|
|
|
+// float valueLength = ((Float) value).floatValue() - axisMarginLeft;
|
|
|
+// - axisMarginRight;
|
|
|
+ float valueLength = ((Float) value).floatValue() - 2f;
|
|
|
+ return valueLength / length;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected String getAxisXValue(Object value) {
|
|
|
+ return String.valueOf(getAxisXGraduate(value));
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getAxisXPos(Object value) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * calculate degree title on Y axis
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * Y軸の目盛を計算する
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 计算Y轴上显示的坐标值
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @param value <p>
|
|
|
+ * value for calculate
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 計算有用データ
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 计算用数据
|
|
|
+ * </p>
|
|
|
+ * @return String
|
|
|
+ * <p>
|
|
|
+ * degree
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 目盛
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 坐标值
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ public String getAxisYGraduate(Object value) {
|
|
|
+
|
|
|
+ float length = super.getHeight() - axisMarginBottom - 2 * axisMarginTop;
|
|
|
+ float valueLength = length
|
|
|
+ - (((Float) value).floatValue() - axisMarginTop);
|
|
|
+
|
|
|
+ return String.valueOf(valueLength / length);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * draw cross line ,called when graph is touched
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 十字線を書く、グラプをタッチたら、メソードを呼び
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 在图表被点击后绘制十字线
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @param canvas
|
|
|
+ */
|
|
|
+ protected void drawWithFingerClick(Canvas canvas) {
|
|
|
+ Paint mPaint = new Paint();
|
|
|
+ mPaint.setColor(Color.LTGRAY);
|
|
|
+
|
|
|
+ float lineHLength = getWidth() - 2f;
|
|
|
+ float lineVLength = getHeight() - 2f;
|
|
|
+
|
|
|
+ if (clickPostX > maxDatasLength && maxDatasLength > 0) {
|
|
|
+ clickPostX = maxDatasLength;
|
|
|
+ }
|
|
|
+ // draw text
|
|
|
+ if (isDisplayAxisXTitle()) {
|
|
|
+ lineVLength = lineVLength - axisMarginBottom;
|
|
|
+
|
|
|
+ if (clickPostX > 0 && clickPostY > 0) {
|
|
|
+ if (displayCrossXOnTouch) {
|
|
|
+ // draw text
|
|
|
+ Paint textPaint = new Paint();
|
|
|
+ textPaint.setColor(Color.BLACK/*ChartLineColors.BORDERCOLOR*/);
|
|
|
+ textPaint.setTextSize(longitudeFontSize);
|
|
|
+ textPaint.setAntiAlias(true);
|
|
|
+
|
|
|
+ // TODO calculate points to draw
|
|
|
+ String content = getAxisXValue(clickPostX);
|
|
|
+ LogUtils.e("chart", content);
|
|
|
+ content = content.replace(currentYear, "");
|
|
|
+ float textWidth = textPaint.measureText(content) + 2f;
|
|
|
+ float PosSX = clickPostX - textWidth / 2f;
|
|
|
+ float PosEX = clickPostX + textWidth / 2f;
|
|
|
+ float PosXMax = this.getWidth() - this.getAxisMarginRight();
|
|
|
+ if (PosEX > PosXMax) {
|
|
|
+ PosEX = PosXMax;
|
|
|
+ PosSX = PosXMax - textWidth;
|
|
|
+ }
|
|
|
+ PointF BoxVS = new PointF(PosSX, lineVLength + 3f);//new PointF(PosSX, lineVLength + 3f);
|
|
|
+ PointF BoxVE = new PointF(PosEX, lineVLength + axisMarginBottom);
|
|
|
+
|
|
|
+ drawTextBox(BoxVS, BoxVE, content, longitudeFontSize, canvas, textPaint);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isDisplayAxisYTitle()) {
|
|
|
+ lineHLength = lineHLength - getAxisMarginLeft();
|
|
|
+
|
|
|
+ if (clickPostX > 0 && clickPostY > 0) {
|
|
|
+ if (displayCrossYOnTouch) {
|
|
|
+ Paint textPaint = new Paint();
|
|
|
+ textPaint.setColor(Color.BLACK);
|
|
|
+ textPaint.setTextSize(latitudeFontSize);
|
|
|
+ textPaint.setAntiAlias(true);
|
|
|
+
|
|
|
+ // TODO calculate points to draw
|
|
|
+ String content = getAxisYGraduate(clickPostY);
|
|
|
+ float textWidth = textPaint.measureText(content) + 2f;
|
|
|
+ PointF BoxHS = new PointF(this.getWidth() - /*textWidth*/axisMarginLeft, clickPostY - latitudeFontSize / 2f);
|
|
|
+ PointF BoxHE = new PointF(this.getWidth() - (axisMarginLeft - textWidth), clickPostY + latitudeFontSize / 2f);
|
|
|
+
|
|
|
+ // draw text
|
|
|
+ drawTextBox(BoxHS, BoxHE, content, latitudeFontSize, canvas, textPaint);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // draw line
|
|
|
+ if (clickPostX > 0 && clickPostY > 0) {
|
|
|
+ if (displayCrossXOnTouch) {
|
|
|
+ float x = (getAxisXPos(clickPostX) - this.getStartIndex()) * this.getItemWidth() + getClickPosXOffset();
|
|
|
+ x += this.getAxisMarginRight();
|
|
|
+ canvas.drawLine(x, 1f, x, lineVLength, mPaint);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (displayCrossYOnTouch) {
|
|
|
+ canvas.drawLine(/*axisMarginLeft*/1f, clickPostY, /*axisMarginLeft*/0f
|
|
|
+ + lineHLength - 1, clickPostY, mPaint);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * draw border
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * グラプのボーダーを書く
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 绘制边框
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @param canvas
|
|
|
+ */
|
|
|
+ protected void drawBorder(Canvas canvas) {
|
|
|
+ float width = super.getWidth() - 2;
|
|
|
+ float height = super.getHeight() - 2;
|
|
|
+
|
|
|
+ Paint mPaint = new Paint();
|
|
|
+ mPaint.setColor(ChartLineColors.BORDERCOLOR);
|
|
|
+ mPaint.setStrokeWidth(1);
|
|
|
+ LogUtils.e("chart", "str" + mPaint.getStrokeWidth());
|
|
|
+ // draw a rectangle
|
|
|
+ canvas.drawLine(1f, 1f, 1f + width, 1f, mPaint);
|
|
|
+ canvas.drawLine(1f + width, 1f, 1f + width, 1f + height, mPaint);
|
|
|
+ canvas.drawLine(1f + width, 1f + height, 1f, 1f + height, mPaint);
|
|
|
+ canvas.drawLine(1f, 1f + height, 1f, 1f, mPaint);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * draw X Axis
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * X軸を書く
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 绘制X轴
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @param canvas
|
|
|
+ */
|
|
|
+ protected void drawXAxis(Canvas canvas) {
|
|
|
+
|
|
|
+ float length = super.getWidth();
|
|
|
+ float postY = super.getHeight() - axisMarginBottom - 1;
|
|
|
+
|
|
|
+ Paint mPaint = new Paint();
|
|
|
+ mPaint.setColor(axisXColor);
|
|
|
+
|
|
|
+ canvas.drawLine(0f, postY, length, postY, mPaint);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * draw Y Axis
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * Y軸を書く
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 绘制Y轴
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @param canvas
|
|
|
+ */
|
|
|
+ protected void drawYAxis(Canvas canvas) {
|
|
|
+
|
|
|
+ float length = super.getHeight() - axisMarginBottom;
|
|
|
+ float postX = axisMarginLeft + 1;
|
|
|
+
|
|
|
+ Paint mPaint = new Paint();
|
|
|
+ mPaint.setColor(axisXColor);
|
|
|
+
|
|
|
+ canvas.drawLine(postX, 0f, postX, length, mPaint);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * draw longitude lines
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 経線を書く
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 绘制经线
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @param canvas
|
|
|
+ */
|
|
|
+ protected void drawAxisGridX(Canvas canvas) {
|
|
|
+
|
|
|
+ if (null != axisXTitles) {
|
|
|
+ int counts = axisXTitles.size();
|
|
|
+ float length = super.getHeight() - axisMarginBottom;
|
|
|
+
|
|
|
+ Paint mPaintLine = new Paint();
|
|
|
+ mPaintLine.setColor(longitudeColor);
|
|
|
+ mPaintLine.setAntiAlias(true);
|
|
|
+ if (dashLongitude) {
|
|
|
+ mPaintLine.setPathEffect(dashEffect);
|
|
|
+ }
|
|
|
+
|
|
|
+ Paint mPaintFont = new Paint();
|
|
|
+ mPaintFont.setColor(longitudeFontColor);
|
|
|
+ mPaintFont.setAntiAlias(true);
|
|
|
+ mPaintFont.setTextSize(longitudeFontSize);
|
|
|
+ if (counts > 1) {
|
|
|
+ float postOffset = (super.getWidth() - axisMarginLeft - 2 * axisMarginRight)
|
|
|
+ / (counts - 1);
|
|
|
+ float offset = axisMarginLeft + axisMarginRight;
|
|
|
+ for (int i = 0; i < counts; i++) {
|
|
|
+ // draw line
|
|
|
+// if (displayLongitude) {
|
|
|
+// float width_x = (this.getWidth() - offset + i * postOffset) / 8;//每条线的宽度
|
|
|
+// for (int j = 0; j < 8 && i == 0; j++) {//画出7条线,使得图表显示区域8等分
|
|
|
+// //FIXME :
|
|
|
+// canvas.drawLine(0 + j * width_x, 1f, 0 + j * width_x, length, mPaintLine);
|
|
|
+// }
|
|
|
+ canvas.drawLine(this.getWidth() - offset + i * postOffset, 1f, this.getWidth() - offset + i * postOffset, length, mPaintLine);
|
|
|
+// }
|
|
|
+ // draw title
|
|
|
+ if (displayAxisXTitle) {
|
|
|
+ if (i == counts - 1) {
|
|
|
+ canvas.drawText(axisXTitles.get(i).replace(currentYear, ""), offset + i
|
|
|
+ * postOffset - 1
|
|
|
+ - mPaintFont.measureText(axisXTitles.get(i).replace(currentYear, "")) - axisMarginLeft, super.getHeight()
|
|
|
+ - axisMarginBottom + longitudeFontSize,
|
|
|
+ mPaintFont);
|
|
|
+ } else if (0 == i) {
|
|
|
+ canvas.drawText(axisXTitles.get(i).replace(currentYear, ""),
|
|
|
+ /*this.axisMarginLeft + */2f, super.getHeight()
|
|
|
+ - axisMarginBottom
|
|
|
+ + longitudeFontSize, mPaintFont);
|
|
|
+ } else {
|
|
|
+ canvas.drawText(axisXTitles.get(i).replace(currentYear, ""), offset + i
|
|
|
+ * postOffset
|
|
|
+ - mPaintFont.measureText(axisXTitles.get(i).replace(currentYear, "")) / 2f, super.getHeight()
|
|
|
+ - axisMarginBottom + longitudeFontSize,
|
|
|
+ mPaintFont);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ canvas.drawLine(super.getWidth() - axisMarginLeft - axisMarginRight, 1f, super.getWidth() - axisMarginRight - axisMarginLeft, length, mPaintLine);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * draw latitude lines
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 緯線を書く
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 绘制纬线
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @param canvas
|
|
|
+ */
|
|
|
+ protected void drawAxisGridY(Canvas canvas) {
|
|
|
+ if (null != axisYTitles) {
|
|
|
+ int counts = axisYTitles.size();
|
|
|
+ float length = super.getWidth() - axisMarginLeft;
|
|
|
+
|
|
|
+ Paint mPaintLine = new Paint();
|
|
|
+ mPaintLine.setColor(latitudeColor);
|
|
|
+ mPaintLine.setAntiAlias(true);
|
|
|
+ if (dashLatitude) {
|
|
|
+ mPaintLine.setPathEffect(dashEffect);
|
|
|
+ }
|
|
|
+
|
|
|
+ Paint mPaintFont = new Paint();
|
|
|
+ mPaintFont.setColor(latitudeFontColor);
|
|
|
+ mPaintFont.setAntiAlias(true);
|
|
|
+ mPaintFont.setTextSize(latitudeFontSize);
|
|
|
+ if (!"".equals(getTasLastPrice())) {// 最新价格在界面上的显示
|
|
|
+ mPaintFont.setColor(getNewPriceColor());
|
|
|
+ String height = axisYTitles.get(axisYTitles.size() - 1);
|
|
|
+ String low = axisYTitles.get(0);
|
|
|
+ double sum = Double.parseDouble(height) - Double.parseDouble(low);// 最高价和最低价的差值
|
|
|
+ double sum_lastPrice = Double.parseDouble(getTasLastPrice()) - Double.parseDouble(low);// 最新价和最底价的差值
|
|
|
+ // 针对每个像素高度占用值
|
|
|
+ double cell = ((this.getHeight() - axisMarginBottom - axisMarginTop) / sum);
|
|
|
+ float _height = (float) (sum_lastPrice * cell);
|
|
|
+ /**
|
|
|
+ * 画出当前的最新价
|
|
|
+ */
|
|
|
+ canvas.drawText(getTasLastPrice(), super.getWidth() - axisMarginLeft,
|
|
|
+ this.getHeight() - _height - axisMarginBottom + latitudeFontSize / 2f, mPaintFont);
|
|
|
+
|
|
|
+
|
|
|
+ mPaintFont.setColor(latitudeFontColor);// 还原颜色
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 画出实时行情的标线
|
|
|
+ */
|
|
|
+ canvas.drawLine(1, this.getHeight() - _height - axisMarginBottom - 1,
|
|
|
+ super.getWidth() - axisMarginLeft - axisMarginRight, this.getHeight() - _height - axisMarginBottom - 1, mPaintFont);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (counts > 1) {
|
|
|
+ float postOffset = (super.getHeight() - axisMarginBottom - 2 * axisMarginTop)
|
|
|
+ / (counts - 1);
|
|
|
+ float offset = super.getHeight() - axisMarginBottom - axisMarginTop;
|
|
|
+ float posX = 0;
|
|
|
+ for (int i = 0; i < counts; i++) {
|
|
|
+ // draw line
|
|
|
+ if (displayLatitude) {
|
|
|
+ if (i != 0 && i != counts - 1) {
|
|
|
+ canvas.drawLine(0,
|
|
|
+ offset - i * postOffset, super.getWidth() - axisMarginLeft, offset - i * postOffset,
|
|
|
+ mPaintLine);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // draw title
|
|
|
+ posX = axisMarginLeft - mPaintFont.measureText(axisYTitles.get(i)) - 1;
|
|
|
+ if (displayAxisYTitle) {
|
|
|
+ if (i == counts - 1) {
|
|
|
+ canvas.drawText(axisYTitles.get(i), super.getWidth() - axisMarginLeft, offset - i
|
|
|
+ * postOffset + latitudeFontSize / 6f + latitudeFontSize / 2f,
|
|
|
+ mPaintFont);
|
|
|
+ } else if (0 == i) {
|
|
|
+ canvas.drawText(axisYTitles.get(i), super.getWidth() - axisMarginLeft,
|
|
|
+ super.getHeight() - this.axisMarginBottom
|
|
|
+ - 2f, mPaintFont);
|
|
|
+ } else {
|
|
|
+ canvas.drawText(axisYTitles.get(i), super.getWidth() - axisMarginLeft, offset - i
|
|
|
+ * postOffset + latitudeFontSize / 2f,
|
|
|
+ mPaintFont);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Zoom in the graph
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 拡大表示する。
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 放大表示
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ protected boolean zoomIn() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <p>
|
|
|
+ * Zoom out the grid
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 縮小表示する。
|
|
|
+ * </p>
|
|
|
+ * <p>
|
|
|
+ * 缩小
|
|
|
+ * </p>
|
|
|
+ */
|
|
|
+ protected boolean zoomOut() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public NumberFormat getNumberFormat() {
|
|
|
+ NumberFormat nf = NumberFormat.getInstance();
|
|
|
+ nf.setGroupingUsed(false);
|
|
|
+ nf.setMaximumFractionDigits(decimalNum);
|
|
|
+ nf.setMinimumFractionDigits(decimalNum);
|
|
|
+
|
|
|
+ return nf;
|
|
|
+ }
|
|
|
+
|
|
|
+ public NumberFormat getNumberFormat(boolean b) {
|
|
|
+ NumberFormat nf = NumberFormat.getInstance();
|
|
|
+ nf.setGroupingUsed(false);
|
|
|
+ if (b == true) {
|
|
|
+ decimalNum = 0;
|
|
|
+ } else {
|
|
|
+ decimalNum = 2;
|
|
|
+ }
|
|
|
+ nf.setMaximumFractionDigits(decimalNum);
|
|
|
+ nf.setMinimumFractionDigits(decimalNum);
|
|
|
+
|
|
|
+ return nf;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * (non-Javadoc)
|
|
|
+ *
|
|
|
+ * @param event
|
|
|
+ *
|
|
|
+ * @see
|
|
|
+ * cn.limc.androidcharts.event.ITouchEventResponse#notifyEvent(GridChart)
|
|
|
+ */
|
|
|
+ public void notifyEvent(int eventId, GridChart chart) {
|
|
|
+ PointF point = chart.getTouchPoint();
|
|
|
+ if (null != point) {
|
|
|
+ clickPostX = point.x;
|
|
|
+ clickPostY = point.y;
|
|
|
+ }
|
|
|
+ touchPoint = new PointF(clickPostX, clickPostY);
|
|
|
+ super.invalidate();
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * (non-Javadoc)
|
|
|
+ *
|
|
|
+ * @param event
|
|
|
+ *
|
|
|
+ * @see
|
|
|
+ * cn.limc.androidcharts.event.ITouchEventNotify#addNotify(ITouchEventResponse
|
|
|
+ * )
|
|
|
+ */
|
|
|
+ public void addNotify(ITouchEventResponse notify) {
|
|
|
+ if (null == notifyList) {
|
|
|
+ notifyList = new ArrayList<ITouchEventResponse>();
|
|
|
+ }
|
|
|
+ notifyList.add(notify);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * (non-Javadoc)
|
|
|
+ *
|
|
|
+ * @param event
|
|
|
+ *
|
|
|
+ * @see cn.limc.androidcharts.event.ITouchEventNotify#removeNotify(int)
|
|
|
+ */
|
|
|
+ public void removeNotify(int i) {
|
|
|
+ if (null != notifyList && notifyList.size() > i) {
|
|
|
+ notifyList.remove(i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * (non-Javadoc)
|
|
|
+ *
|
|
|
+ * @param event
|
|
|
+ *
|
|
|
+ * @see cn.limc.androidcharts.event.ITouchEventNotify#removeNotify()
|
|
|
+ */
|
|
|
+ public void removeAllNotify() {
|
|
|
+ if (null != notifyList) {
|
|
|
+ notifyList.clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void notifyEventAll(int eventId, GridChart chart) {
|
|
|
+ if (null != notifyList) {
|
|
|
+ for (int i = 0; i < notifyList.size(); i++) {
|
|
|
+ ITouchEventResponse ichart = notifyList.get(i);
|
|
|
+ ichart.notifyEvent(eventId, chart);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the axisXColor
|
|
|
+ */
|
|
|
+ public int getAxisXColor() {
|
|
|
+ return axisXColor;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param axisXColor the axisXColor to set
|
|
|
+ */
|
|
|
+ public void setAxisXColor(int axisXColor) {
|
|
|
+ this.axisXColor = axisXColor;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the axisYColor
|
|
|
+ */
|
|
|
+ public int getAxisYColor() {
|
|
|
+ return axisYColor;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param axisYColor the axisYColor to set
|
|
|
+ */
|
|
|
+ public void setAxisYColor(int axisYColor) {
|
|
|
+ this.axisYColor = axisYColor;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the longitudeColor
|
|
|
+ */
|
|
|
+ public int getLongitudeColor() {
|
|
|
+ return longitudeColor;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param longitudeColor the longitudeColor to set
|
|
|
+ */
|
|
|
+ public void setLongitudeColor(int longitudeColor) {
|
|
|
+ this.longitudeColor = longitudeColor;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the latitudeColor
|
|
|
+ */
|
|
|
+ public int getLatitudeColor() {
|
|
|
+ return latitudeColor;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param latitudeColor the latitudeColor to set
|
|
|
+ */
|
|
|
+ public void setLatitudeColor(int latitudeColor) {
|
|
|
+ this.latitudeColor = latitudeColor;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the notifyAxisMarginLeft
|
|
|
+ */
|
|
|
+ public float getNotifyAxisMarginLeft() {
|
|
|
+ return notifyAxisMarginLeft;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param marginLeft the notify AxisMarginLeft to set
|
|
|
+ */
|
|
|
+ public void setNotifyAxisMarginLeft(float marginLeft) {
|
|
|
+ this.notifyAxisMarginLeft = marginLeft;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the axisMarginLeft
|
|
|
+ */
|
|
|
+ public float getAxisMarginLeft() {
|
|
|
+ return axisMarginLeft;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param axisMarginLeft the axisMarginLeft to set
|
|
|
+ */
|
|
|
+ public void setAxisMarginLeft(float axisMarginLeft) {
|
|
|
+ this.axisMarginLeft = axisMarginLeft;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the axisMarginBottom
|
|
|
+ */
|
|
|
+ public float getAxisMarginBottom() {
|
|
|
+ return axisMarginBottom;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param axisMarginBottom the axisMarginBottom to set
|
|
|
+ */
|
|
|
+ public void setAxisMarginBottom(float axisMarginBottom) {
|
|
|
+ this.axisMarginBottom = axisMarginBottom;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the axisMarginTop
|
|
|
+ */
|
|
|
+ public float getAxisMarginTop() {
|
|
|
+ return axisMarginTop;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param axisMarginTop the axisMarginTop to set
|
|
|
+ */
|
|
|
+ public void setAxisMarginTop(float axisMarginTop) {
|
|
|
+ this.axisMarginTop = axisMarginTop;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the axisMarginRight
|
|
|
+ */
|
|
|
+ public float getAxisMarginRight() {
|
|
|
+ return axisMarginRight;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param axisMarginRight the axisMarginRight to set
|
|
|
+ */
|
|
|
+ public void setAxisMarginRight(float axisMarginRight) {
|
|
|
+ this.axisMarginRight = axisMarginRight;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the displayAxisXTitle
|
|
|
+ */
|
|
|
+ public boolean isDisplayAxisXTitle() {
|
|
|
+ return displayAxisXTitle;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param displayAxisXTitle the displayAxisXTitle to set
|
|
|
+ */
|
|
|
+ public void setDisplayAxisXTitle(boolean displayAxisXTitle) {
|
|
|
+ this.displayAxisXTitle = displayAxisXTitle;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the displayAxisYTitle
|
|
|
+ */
|
|
|
+ public boolean isDisplayAxisYTitle() {
|
|
|
+ return displayAxisYTitle;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param displayAxisYTitle the displayAxisYTitle to set
|
|
|
+ */
|
|
|
+ public void setDisplayAxisYTitle(boolean displayAxisYTitle) {
|
|
|
+ this.displayAxisYTitle = displayAxisYTitle;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the latitudeNum
|
|
|
+ */
|
|
|
+ public int getLatitudeNum() {
|
|
|
+ return latitudeNum;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param latitudeNum the latitudeNum to set
|
|
|
+ */
|
|
|
+ public void setLatitudeNum(int latitudeNum) {
|
|
|
+ this.latitudeNum = latitudeNum;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the longitudeNum
|
|
|
+ */
|
|
|
+ public int getLongitudeNum() {
|
|
|
+ return longitudeNum;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param longitudeNum the longitudeNum to set
|
|
|
+ */
|
|
|
+ public void setLongitudeNum(int longitudeNum) {
|
|
|
+ this.longitudeNum = longitudeNum;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the displayLongitude
|
|
|
+ */
|
|
|
+ public boolean isDisplayLongitude() {
|
|
|
+ return displayLongitude;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param displayLongitude the displayLongitude to set
|
|
|
+ */
|
|
|
+ public void setDisplayLongitude(boolean displayLongitude) {
|
|
|
+ this.displayLongitude = displayLongitude;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the dashLongitude
|
|
|
+ */
|
|
|
+ public boolean isDashLongitude() {
|
|
|
+ return dashLongitude;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param dashLongitude the dashLongitude to set
|
|
|
+ */
|
|
|
+ public void setDashLongitude(boolean dashLongitude) {
|
|
|
+ this.dashLongitude = dashLongitude;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the displayLatitude
|
|
|
+ */
|
|
|
+ public boolean isDisplayLatitude() {
|
|
|
+ return displayLatitude;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param displayLatitude the displayLatitude to set
|
|
|
+ */
|
|
|
+ public void setDisplayLatitude(boolean displayLatitude) {
|
|
|
+ this.displayLatitude = displayLatitude;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the dashLatitude
|
|
|
+ */
|
|
|
+ public boolean isDashLatitude() {
|
|
|
+ return dashLatitude;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param dashLatitude the dashLatitude to set
|
|
|
+ */
|
|
|
+ public void setDashLatitude(boolean dashLatitude) {
|
|
|
+ this.dashLatitude = dashLatitude;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the dashEffect
|
|
|
+ */
|
|
|
+ public PathEffect getDashEffect() {
|
|
|
+ return dashEffect;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param dashEffect the dashEffect to set
|
|
|
+ */
|
|
|
+ public void setDashEffect(PathEffect dashEffect) {
|
|
|
+ this.dashEffect = dashEffect;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the displayBorder
|
|
|
+ */
|
|
|
+ public boolean isDisplayBorder() {
|
|
|
+ return displayBorder;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param displayBorder the displayBorder to set
|
|
|
+ */
|
|
|
+ public void setDisplayBorder(boolean displayBorder) {
|
|
|
+ this.displayBorder = displayBorder;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the borderColor
|
|
|
+ */
|
|
|
+ public int getBorderColor() {
|
|
|
+ return borderColor;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param borderColor the borderColor to set
|
|
|
+ */
|
|
|
+ public void setBorderColor(int borderColor) {
|
|
|
+ this.borderColor = borderColor;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the longitudeFontColor
|
|
|
+ */
|
|
|
+ public int getLongitudeFontColor() {
|
|
|
+ return longitudeFontColor;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param longitudeFontColor the longitudeFontColor to set
|
|
|
+ */
|
|
|
+ public void setLongitudeFontColor(int longitudeFontColor) {
|
|
|
+ this.longitudeFontColor = longitudeFontColor;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the longitudeFontSize
|
|
|
+ */
|
|
|
+ public int getLongitudeFontSize() {
|
|
|
+ return longitudeFontSize;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param longitudeFontSize the longitudeFontSize to set
|
|
|
+ */
|
|
|
+ public void setLongitudeFontSize(int longitudeFontSize) {
|
|
|
+ this.longitudeFontSize = longitudeFontSize;
|
|
|
+ if (this.longitudeFontSize > this.axisMarginBottom) {
|
|
|
+ setAxisMarginBottom(longitudeFontSize + longitudeFontSize / 4);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the latitudeFontColor
|
|
|
+ */
|
|
|
+ public int getLatitudeFontColor() {
|
|
|
+ return latitudeFontColor;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param latitudeFontColor the latitudeFontColor to set
|
|
|
+ */
|
|
|
+ public void setLatitudeFontColor(int latitudeFontColor) {
|
|
|
+ this.latitudeFontColor = latitudeFontColor;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the latitudeFontSize
|
|
|
+ */
|
|
|
+ public int getLatitudeFontSize() {
|
|
|
+ return latitudeFontSize;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param latitudeFontSize the latitudeFontSize to set
|
|
|
+ */
|
|
|
+ public void setLatitudeFontSize(int latitudeFontSize) {
|
|
|
+ this.latitudeFontSize = latitudeFontSize;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the axisXTitles
|
|
|
+ */
|
|
|
+ public List<String> getAxisXTitles() {
|
|
|
+ return axisXTitles;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param axisXTitles the axisXTitles to set
|
|
|
+ */
|
|
|
+ public void setAxisXTitles(List<String> axisXTitles) {
|
|
|
+ this.axisXTitles = axisXTitles;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the axisYTitles
|
|
|
+ */
|
|
|
+ public List<String> getAxisYTitles() {
|
|
|
+ return axisYTitles;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param axisYTitles the axisYTitles to set
|
|
|
+ */
|
|
|
+ public void setAxisYTitles(List<String> axisYTitles) {
|
|
|
+ this.axisYTitles = axisYTitles;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the axisYMaxTitleLength
|
|
|
+ */
|
|
|
+ public int getAxisYMaxTitleLength() {
|
|
|
+ return axisYMaxTitleLength;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param axisYMaxTitleLength the axisYMaxTitleLength to set
|
|
|
+ */
|
|
|
+ public void setAxisYMaxTitleLength(int axisYMaxTitleLength) {
|
|
|
+ this.axisYMaxTitleLength = axisYMaxTitleLength;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the displayCrossXOnTouch
|
|
|
+ */
|
|
|
+ public boolean isDisplayCrossXOnTouch() {
|
|
|
+ return displayCrossXOnTouch;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param displayCrossXOnTouch the displayCrossXOnTouch to set
|
|
|
+ */
|
|
|
+ public void setDisplayCrossXOnTouch(boolean displayCrossXOnTouch) {
|
|
|
+ this.displayCrossXOnTouch = displayCrossXOnTouch;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the displayCrossYOnTouch
|
|
|
+ */
|
|
|
+ public boolean isDisplayCrossYOnTouch() {
|
|
|
+ return displayCrossYOnTouch;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param displayCrossYOnTouch the displayCrossYOnTouch to set
|
|
|
+ */
|
|
|
+ public void setDisplayCrossYOnTouch(boolean displayCrossYOnTouch) {
|
|
|
+ this.displayCrossYOnTouch = displayCrossYOnTouch;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * for new: + chart.getAxisMarginLeft() //margin right
|
|
|
+ *
|
|
|
+ * @return the clickPostX
|
|
|
+ */
|
|
|
+ public float getClickPostX() {
|
|
|
+ return clickPostX;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param clickPostX the clickPostX to set
|
|
|
+ */
|
|
|
+ public void setClickPostX(float clickPostX) {
|
|
|
+ this.clickPostX = clickPostX;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the clickPostY
|
|
|
+ */
|
|
|
+ public float getClickPostY() {
|
|
|
+ return clickPostY;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param clickPostY the clickPostY to set
|
|
|
+ */
|
|
|
+ public void setClickPostY(float clickPostY) {
|
|
|
+ this.clickPostY = clickPostY;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the notifyList
|
|
|
+ */
|
|
|
+ public List<ITouchEventResponse> getNotifyList() {
|
|
|
+ return notifyList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param notifyList the notifyList to set
|
|
|
+ */
|
|
|
+ public void setNotifyList(List<ITouchEventResponse> notifyList) {
|
|
|
+ this.notifyList = notifyList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the touchPoint
|
|
|
+ */
|
|
|
+ public PointF getTouchPoint() {
|
|
|
+ return touchPoint;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param touchPoint the touchPoint to set
|
|
|
+ */
|
|
|
+ public void setTouchPoint(PointF touchPoint) {
|
|
|
+ this.touchPoint = touchPoint;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the touchDistanceX
|
|
|
+ */
|
|
|
+ public float getTouchDistanceX() {
|
|
|
+ return touchDistanceX;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param touchDistanceX touch Point2 the touchPoint2 to set
|
|
|
+ */
|
|
|
+ public void setTouchDistanceX(float touchDistanceX) {
|
|
|
+ this.touchDistanceX = touchDistanceX;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return the backgroundColor
|
|
|
+ */
|
|
|
+ public int getBackgroundColor() {
|
|
|
+ return backgroundColor;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param backgroundColor the backgroundColor to set
|
|
|
+ */
|
|
|
+ public void setBackgroundColor(int backgroundColor) {
|
|
|
+ this.backgroundColor = backgroundColor;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getDecimalNum() {
|
|
|
+ return decimalNum;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setDecimalNum(int decimalNum) {
|
|
|
+ this.decimalNum = decimalNum;
|
|
|
+ }
|
|
|
+
|
|
|
+ public ScaleGestureDetector getScaleGestureDetector() {
|
|
|
+ return this.mScaleDetector;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onScale(ScaleGestureDetector detector) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onScaleBegin(ScaleGestureDetector detector) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+// isOnScale = true;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onScaleEnd(ScaleGestureDetector detector) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+// isOnScale = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean isEnableCrossOnTouch() {
|
|
|
+ return enableCrossOnTouch;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setEnableCrossOnTouch(boolean enableCrossOnTouch) {
|
|
|
+ this.enableCrossOnTouch = enableCrossOnTouch;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getStartIndex() {
|
|
|
+ return startIndex;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setStartIndex(int startIndex) {
|
|
|
+ this.startIndex = startIndex;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getTasLastPrice() {
|
|
|
+ return tasLastPrice;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setTasLastPrice(String tasLastPrice) {
|
|
|
+ this.tasLastPrice = tasLastPrice;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void setLinesData(int linesData) {
|
|
|
+ this.linesData = linesData;
|
|
|
+ }
|
|
|
+
|
|
|
+ private float maxDatasLength = 0;
|
|
|
+
|
|
|
+ public void setMaxDatasLength(float maxDatasLength) {
|
|
|
+ this.maxDatasLength = maxDatasLength;
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean isCan_move() {
|
|
|
+ return can_move;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分时图必须设置这个值
|
|
|
+ *
|
|
|
+ * @param can_move
|
|
|
+ */
|
|
|
+ public void setCan_move(boolean can_move) {
|
|
|
+ this.can_move = can_move;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getNewPriceColor() {
|
|
|
+ return newPriceColor;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setNewPriceColor(int newPriceColor) {
|
|
|
+ this.newPriceColor = newPriceColor;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|