1. sbgapps
  2. HoloGraphLibrary

Commits

Chayoung You  committed b6bdd2a

Add mShowAxisLabel and mShowPopup for user customization

  • Participants
  • Parent commits 158b0b0
  • Branches master

Comments (0)

Files changed (2)

File HoloGraphLibrary/res/values/attrs.xml

View file
  • Ignore whitespace
             <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>

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

View file
  • Ignore whitespace
     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);
                     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())) {