Commits

sbgapps committed 85a2444 Merge

Comments (0)

Files changed (3)

HoloGraphLibrary/res/values/attrs.xml

             <enum name="vertical" value="1"/>
         </attr>
         <attr name="barShowAxis" format="boolean"/>
+        <attr name="barShowAxisLabel" format="boolean"/>
         <attr name="barShowText" format="boolean"/>
+        <attr name="barShowPopup" format="boolean"/>
     </declare-styleable>
 
 </resources>

HoloGraphLibrary/src/com/echo/holographlibrary/Bar.java

 
 package com.echo.holographlibrary;
 
+import android.graphics.Color;
 import android.graphics.Path;
 import android.graphics.Region;
 
     private int mColor = 0xFF33B5E5;
     private int mLabelColor = -1;
     private int mSelectedColor = -1;
+    private int mValueColor = Color.WHITE;
     private String mName = null;
     private float mValue;
     private String mValueString = null;
         mSelectedColor = selectedColor;
     }
 
+    public int getValueColor() {
+        return mValueColor;
+    }
+
+    public void setValueColor(int valueColor) {
+        mValueColor = valueColor;
+    }
+
     public String getName() {
         return (null == mName) ? "" : mName;
     }

HoloGraphLibrary/src/com/echo/holographlibrary/BarGraph.java

     private Paint mPaint = new Paint();
     private Rect mBoundsRect = new Rect();
     private Rect mTextRect = new Rect();
-    private boolean mShowBarText;
     private boolean mShowAxis;
+    private boolean mShowAxisLabel;
+    private boolean mShowBarText;
+    private boolean mShowPopup;
     private int mSelectedIndex = -1;
     private OnBarClickedListener mListener;
     private int mAxisColor;
         mOrientation = a.getInt(R.styleable.BarGraph_orientation, ORIENTATION_VERTICAL);
         mAxisColor = a.getColor(R.styleable.BarGraph_barAxisColor, Color.LTGRAY);
         mShowAxis = a.getBoolean(R.styleable.BarGraph_barShowAxis, true);
+        mShowAxisLabel = a.getBoolean(R.styleable.BarGraph_barShowAxisLabel, true);
         mShowBarText = a.getBoolean(R.styleable.BarGraph_barShowText, true);
+        mShowPopup = a.getBoolean(R.styleable.BarGraph_barShowPopup, true);
+    }
+
+    public void setShowAxis(boolean show) {
+        mShowAxis = show;
+    }
+
+    public void setShowAxisLabel(boolean show) {
+        mShowAxisLabel = show;
     }
 
     public void setShowBarText(boolean show) {
         mShowBarText = show;
     }
 
-    public void setShowAxis(boolean show) {
-        mShowAxis = show;
+    public void setShowPopup(boolean show) {
+        mShowPopup = show;
     }
 
     public void setBars(ArrayList<Bar> points) {
         if (mShowBarText) {
             this.mPaint.setTextSize(VALUE_FONT_SIZE * resources.getDisplayMetrics().scaledDensity);
             this.mPaint.getTextBounds("$", 0, 1, mTextRect);
-            usableHeight = getHeight() - bottomPadding - Math.abs(mTextRect.top - mTextRect.bottom)
-                    - 24 * resources.getDisplayMetrics().density;
+            if (mShowPopup) {
+                usableHeight = getHeight() - bottomPadding
+                        - Math.abs(mTextRect.top - mTextRect.bottom)
+                        - 24 * resources.getDisplayMetrics().density;
+            } else {
+                usableHeight = getHeight() - bottomPadding
+                        - Math.abs(mTextRect.top - mTextRect.bottom)
+                        - 18 * resources.getDisplayMetrics().density;
+            }
         } else {
             usableHeight = getHeight() - bottomPadding;
         }
                     mBoundsRect.bottom);
 
             // Draw x-axis label text
-            if (mShowAxis) {
+            if (mShowAxisLabel) {
                 this.mPaint.setColor(bar.getLabelColor());
                 this.mPaint.setTextSize(AXIS_LABEL_FONT_SIZE
                         * resources.getDisplayMetrics().scaledDensity);
             if (mShowBarText) {
                 this.mPaint.setTextSize(VALUE_FONT_SIZE
                         * resources.getDisplayMetrics().scaledDensity);
-                this.mPaint.setColor(Color.WHITE);
+                this.mPaint.setColor(bar.getValueColor());
                 this.mPaint.getTextBounds(bar.getValueString(), 0, 1, mTextRect);
 
                 int boundLeft = (int) (((mBoundsRect.left + mBoundsRect.right) / 2)
                     boundRight = mBoundsRect.right + ((int) padding / 2);
                 }
 
-                popup.setBounds(boundLeft, boundTop, boundRight, mBoundsRect.top);
-                popup.draw(canvas);
+                if (mShowPopup) {
+                    popup.setBounds(boundLeft, boundTop, boundRight, mBoundsRect.top);
+                    popup.draw(canvas);
+                }
 
                 // Check cache to see if we've done this calculation before
                 if (0 > valueTextSizes.indexOfKey(bar.getValueString().length())) {