• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2012 AndroidPlot.com
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 
17 package com.androidplot.xy;
18 
19 import android.graphics.Color;
20 import android.graphics.Paint;
21 import com.androidplot.ui.PositionMetric;
22 
23 /**
24  * Encapsulates a single axis line marker drawn onto an XYPlot at a specified value.
25  * @param <PositionMetricType>
26  */
27 public abstract class ValueMarker<PositionMetricType extends PositionMetric> {
28 
getText()29     public String getText() {
30         return text;
31     }
32 
setText(String text)33     public void setText(String text) {
34         this.text = text;
35     }
36 
37     public enum TextOrientation {
38         HORIZONTAL,
39         VERTICAL
40     }
41     private Number value;
42     private Paint linePaint;
43     private Paint textPaint;
44     //private Paint backgroundPaint;
45     private TextOrientation textOrientation;
46     private int textMargin = 2;
47     private PositionMetricType textPosition;
48     private String text;
49 
50     {
51         linePaint = new Paint();
52         linePaint.setColor(Color.RED);
53         linePaint.setAntiAlias(true);
54         linePaint.setStyle(Paint.Style.STROKE);
55         textPaint = new Paint();
56         textPaint.setAntiAlias(true);
57         textPaint.setColor(Color.RED);
58         //backgroundPaint = new Paint();
59         //backgroundPaint.setColor(Color.argb(100, 100, 100, 100));
60         //backgroundPaint.setColor(Color.DKGRAY);
61 
62     }
63 
ValueMarker(Number value, String text, PositionMetricType textPosition)64     public ValueMarker(Number value, String text, PositionMetricType textPosition) {
65         this.value = value;
66         this.textPosition = textPosition;
67         this.text = text;
68     }
69 
70     /**
71      *
72      * @param value
73      * @param text
74      * @param textPosition
75      * @param linePaint
76      * @param textPaint
77      */
ValueMarker(Number value, String text, PositionMetricType textPosition, Paint linePaint, Paint textPaint)78     public ValueMarker(Number value, String text, PositionMetricType textPosition, Paint linePaint, Paint textPaint) {
79         this(value, text, textPosition);
80 
81         this.linePaint = linePaint;
82         this.textPaint = textPaint;
83         //this.backgroundPaint = backgroundPaint;
84     }
85 
ValueMarker(Number value, String text, PositionMetricType textPosition, int linePaint, int textPaint)86     public ValueMarker(Number value, String text, PositionMetricType textPosition, int linePaint, int textPaint) {
87         this(value, text, textPosition);
88         this.linePaint.setColor(linePaint);
89         this.textPaint.setColor(textPaint);
90     }
91 
getValue()92     public Number getValue() {
93         return value;
94     }
95 
setValue(Number value)96     public void setValue(Number value) {
97         this.value = value;
98     }
99 
getLinePaint()100     public Paint getLinePaint() {
101         return linePaint;
102     }
103 
setLinePaint(Paint linePaint)104     public void setLinePaint(Paint linePaint) {
105         this.linePaint = linePaint;
106     }
107 
getTextPaint()108     public Paint getTextPaint() {
109         return textPaint;
110     }
111 
setTextPaint(Paint textPaint)112     public void setTextPaint(Paint textPaint) {
113         this.textPaint = textPaint;
114     }
115 
116     /*public Paint getBackgroundPaint() {
117         return backgroundPaint;
118     }
119 
120     public void setBackgroundPaint(Paint backgroundPaint) {
121         this.backgroundPaint = backgroundPaint;
122     }*/
123 
getTextOrientation()124     public TextOrientation getTextOrientation() {
125         return textOrientation;
126     }
127 
128     /**
129      * Currently not implemented.  Sets the orientation of the text portion of this
130      * ValueMarker.
131      * @param textOrientation
132      */
setTextOrientation(TextOrientation textOrientation)133     public void setTextOrientation(TextOrientation textOrientation) {
134         this.textOrientation = textOrientation;
135     }
136 
137     /**
138      * Currently not implemented.
139      * @return
140      */
getTextMargin()141     public int getTextMargin() {
142         return textMargin;
143     }
144 
setTextMargin(int textMargin)145     public void setTextMargin(int textMargin) {
146         this.textMargin = textMargin;
147     }
148 
getTextPosition()149     public PositionMetricType getTextPosition() {
150         return textPosition;
151     }
152 
setTextPosition(PositionMetricType textPosition)153     public void setTextPosition(PositionMetricType textPosition) {
154         this.textPosition = textPosition;
155     }
156 }
157