Commits

ChaYoung You committed 9454b7a

Align brackets

Comments (0)

Files changed (6)

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

         this.mValue = value;
     }
 
-    public String getValueString()
-    {
+    public String getValueString() {
         if (mValueString != null) {
             return mValueString;
         } else {
         }
     }
 
-    public void setValueString(final String valueString)
-    {
+    public void setValueString(final String valueString) {
         mValueString = valueString;
     }
 

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

         mOrientation = a.getInt(R.styleable.BarGraph_orientation, ORIENTATION_VERTICAL);
     }
 
-    public void setShowBarText(boolean show){
+    public void setShowBarText(boolean show) {
         mShowBarText = show;
     }
 
-    public void setShowAxis(boolean show){
+    public void setShowAxis(boolean show) {
         mShowAxis = show;
     }
 
-    public void setBars(ArrayList<Bar> points){
+    public void setBars(ArrayList<Bar> points) {
         this.mBars = points;
         mShouldUpdate = true;
         postInvalidate();
     }
 
-    public ArrayList<Bar> getBars(){
+    public ArrayList<Bar> getBars() {
         return this.mBars;
     }
 
             }
 
             // Draw x-axis line
-            if (mShowAxis){
+            if (mShowAxis) {
                 mPaint.setColor(Color.BLACK);
                 mPaint.setStrokeWidth(2 * resources.getDisplayMetrics().density);
                 mPaint.setAlpha(50);
                 bar.setRegion(new Region(mRectangle.left-selectPadding, mRectangle.top-selectPadding, mRectangle.right+selectPadding, mRectangle.bottom+selectPadding));
 
                 // Draw x-axis label text
-                if (mShowAxis){
+                if (mShowAxis) {
                     this.mPaint.setColor(bar.getLabelColor());
                     this.mPaint.setTextSize(AXIS_LABEL_FONT_SIZE * resources.getDisplayMetrics().scaledDensity);
                     float textWidth = this.mPaint.measureText(bar.getName());
-                    while (right - left + (padding *LABEL_PADDING_MULTIPLIER)< textWidth)//decrease text size to fit and not overlap with other labels.
-                    {
+                    while (right - left + (padding *LABEL_PADDING_MULTIPLIER)< textWidth) { //decrease text size to fit and not overlap with other labels.
                         this.mPaint.setTextSize(this.mPaint.getTextSize() -  1);
                         textWidth = this.mPaint.measureText(bar.getName());
                     }
                 }
 
                 // Draw value text
-                if (mShowBarText){
+                if (mShowBarText) {
                     this.mPaint.setTextSize(VALUE_FONT_SIZE * resources.getDisplayMetrics().scaledDensity);
                     this.mPaint.setColor(Color.WHITE);
                     Rect r2 = new Rect();
                     int boundTop = (int) (mRectangle.top+(r2.top-r2.bottom)-18 * resources.getDisplayMetrics().density);
                     int boundRight = (int)(((mRectangle.left+mRectangle.right)/2)+(this.mPaint.measureText(bar.getValueString())/2)+10 * resources.getDisplayMetrics().density);
 
-                    if (boundLeft < mRectangle.left) boundLeft = mRectangle.left - ((int)padding /2);//limit popup width to bar width
+                    if (boundLeft < mRectangle.left) boundLeft = mRectangle.left - ((int)padding /2); //limit popup width to bar width
                     if (boundRight > mRectangle.right)boundRight = mRectangle.right + ((int) padding /2);
 
                     popup.setBounds(boundLeft, boundTop, boundRight, mRectangle.top);
                     popup.draw(canvas);
 
-                    if (!valueTextSizes.containsKey(bar.getValueString().length()))//check cache to see if we've done this calculation before
-                    {
-                        while (this.mPaint.measureText(bar.getValueString()) > boundRight - boundLeft)
+                    if (!valueTextSizes.containsKey(bar.getValueString().length())) { //check cache to see if we've done this calculation before
+                        while (this.mPaint.measureText(bar.getValueString()) > boundRight - boundLeft) {
                             this.mPaint.setTextSize(this.mPaint.getTextSize() - (float)1);
+                        }
                         valueTextSizes.put(bar.getValueString().length(), mPaint.getTextSize());
+                    } else {
+                        this.mPaint.setTextSize(valueTextSizes.get(bar.getValueString().length()));
                     }
-                    else this.mPaint.setTextSize(valueTextSizes.get(bar.getValueString().length()));
                     canvas.drawText(bar.getValueString(), (int)(((mRectangle.left+mRectangle.right)/2)-(this.mPaint.measureText(bar.getValueString()))/2), mRectangle.top-(mRectangle.top - boundTop)/2f+(float)Math.abs(r2.top-r2.bottom)/2f*0.7f, this.mPaint);
                 }
                 if (mIndexSelected == count && mListener != null) {
         point.y = (int) event.getY();
 
         int count = 0;
-        for (Bar bar : mBars){
+        for (Bar bar : mBars) {
             Region r = new Region();
             r.setPath(bar.getPath(), bar.getRegion());
-            if (r.contains((int)point.x,(int) point.y) && event.getAction() == MotionEvent.ACTION_DOWN){
+            if (r.contains((int)point.x,(int) point.y) && event.getAction() == MotionEvent.ACTION_DOWN) {
                 mIndexSelected = count;
-            } else if (event.getAction() == MotionEvent.ACTION_UP){
-                if (r.contains((int)point.x,(int) point.y) && mListener != null){
+            } else if (event.getAction() == MotionEvent.ACTION_UP) {
+                if (r.contains((int)point.x,(int) point.y) && mListener != null) {
                     if (mIndexSelected > -1) mListener.onClick(mIndexSelected);
                     mIndexSelected = -1;
                 }
-            }
-            else if(event.getAction() == MotionEvent.ACTION_CANCEL)
+            } else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
                 mIndexSelected = -1;
+            }
 
             count++;
         }
 
-        if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL){
+        if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
             mShouldUpdate = true;
             postInvalidate();
         }
     }
 
     @Override
-    protected void onDetachedFromWindow()
-    {
-        if(mFullImage != null)
+    protected void onDetachedFromWindow() {
+        if (mFullImage != null) {
             mFullImage.recycle();
+        }
 
         super.onDetachedFromWindow();
     }

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

     public void setPoints(ArrayList<LinePoint> points) {
         this.points = points;
     }
-    public void addPoint(LinePoint point){
+    public void addPoint(LinePoint point) {
         LinePoint p;
-        for(int i = 0; i < points.size(); i++){
+        for (int i = 0; i < points.size(); i++) {
             p = points.get(i);
-            if(point.getX() < p.getX()){
+            if (point.getX() < p.getX()) {
                 points.add(i, point);
                 return;
             }
         points.add(point);
     }
 
-    public void removePoint(LinePoint point){
+    public void removePoint(LinePoint point) {
         points.remove(point);
     }
-    public LinePoint getPoint(int index){
+    public LinePoint getPoint(int index) {
         return points.get(index);
     }
 
-    public LinePoint getPoint(float x, float y){
+    public LinePoint getPoint(float x, float y) {
         LinePoint p;
-        for(int i = 0; i < points.size(); i++){
+        for (int i = 0; i < points.size(); i++) {
             p = points.get(i);
-            if(p.getX() == x && p.getY() == y)
+            if (p.getX() == x && p.getY() == y) {
                 return p;
+            }
         }
         return null;
     }
-    public int getSize(){
+    public int getSize() {
         return points.size();
     }
     public boolean isShowingPoints() {

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

     // since this is a new addition, it has to default to false to be backwards compatible
     private boolean isUsingDips;
 
-    public LineGraph(Context context){
+    public LineGraph(Context context) {
         this(context, null);
     }
 
         this.isUsingDips = treatSizesAsDips;
     }
 
-    public void removeAllLines(){
-        while (lines.size() > 0){
+    public void removeAllLines() {
+        while (lines.size() > 0) {
             lines.remove(0);
         }
         shouldUpdate = true;
         shouldUpdate = true;
         postInvalidate();
     }
-    public void addPointToLine(int lineIndex, double x, double y){
+    public void addPointToLine(int lineIndex, double x, double y) {
         addPointToLine(lineIndex, (float) x, (float) y);
     }
-    public void addPointToLine(int lineIndex, float x, float y){
+    public void addPointToLine(int lineIndex, float x, float y) {
         LinePoint p = new LinePoint(x, y);
 
         addPointToLine(lineIndex, p);
     }
 
-    public double getRangeYRatio(){
+    public double getRangeYRatio() {
         return rangeYRatio;
     }
 
-    public void setRangeYRatio(double rr){
+    public void setRangeYRatio(double rr) {
         this.rangeYRatio = rr;
     }
-    public double getRangeXRatio(){
+    public double getRangeXRatio() {
         return rangeXRatio;
     }
 
-    public void setRangeXRatio(double rr){
+    public void setRangeXRatio(double rr) {
         this.rangeXRatio = rr;
     }
-    public void addPointToLine(int lineIndex, LinePoint point){
+    public void addPointToLine(int lineIndex, LinePoint point) {
         Line line = getLine(lineIndex);
         line.addPoint(point);
         lines.set(lineIndex, line);
         postInvalidate();
     }
 
-    public void addPointsToLine(int lineIndex, LinePoint[] points){
+    public void addPointsToLine(int lineIndex, LinePoint[] points) {
         Line line = getLine(lineIndex);
-        for(LinePoint point : points){
+        for (LinePoint point : points) {
             line.addPoint(point);
         }
         lines.set(lineIndex, line);
         postInvalidate();
     }
 
-    public void removeAllPointsAfter(int lineIndex, double x){
+    public void removeAllPointsAfter(int lineIndex, double x) {
         removeAllPointsBetween(lineIndex, x, getMaxX());
     }
-    public void removeAllPointsBefore(int lineIndex, double x){
+    public void removeAllPointsBefore(int lineIndex, double x) {
         removeAllPointsBetween(lineIndex, getMinX(), x);
     }
 
-    public void removeAllPointsBetween(int lineIndex, double startX, double finishX){
+    public void removeAllPointsBetween(int lineIndex, double startX, double finishX) {
         Line line = getLine(lineIndex);
         LinePoint[] pts = new LinePoint[line.getPoints().size()];
         pts = line.getPoints().toArray(pts);
-        for(LinePoint point : pts){
-            if(point.getX() >= startX && point.getX() <= finishX)
+        for (LinePoint point : pts) {
+            if (point.getX() >= startX && point.getX() <= finishX) {
                 line.removePoint(point);
+            }
         }
         lines.set(lineIndex, line);
         resetLimits();
         shouldUpdate = true;
         postInvalidate();
     }
-    public void removePointsFromLine(int lineIndex, LinePoint[] points){
+    public void removePointsFromLine(int lineIndex, LinePoint[] points) {
         Line line = getLine(lineIndex);
-        for(LinePoint point : points){
+        for (LinePoint point : points) {
             line.removePoint(point);
         }
         lines.set(lineIndex, line);
         shouldUpdate = true;
         postInvalidate();
     }
-    public void removePointFromLine(int lineIndex, float x, float y){
+    public void removePointFromLine(int lineIndex, float x, float y) {
         LinePoint p = null;
         Line line = getLine(lineIndex);
         p = line.getPoint(x, y);
         removePointFromLine(lineIndex, p);
     }
-    public void removePointFromLine(int lineIndex, LinePoint point){
+    public void removePointFromLine(int lineIndex, LinePoint point) {
         Line line = getLine(lineIndex);
         line.removePoint(point);
         lines.set(lineIndex, line);
         postInvalidate();
     }
 
-    public void resetYLimits(){
+    public void resetYLimits() {
         float range = getMaxY() - getMinY();
         setRangeY(getMinY()-range*getRangeYRatio(), getMaxY()+range*getRangeYRatio());
     }
-    public void resetXLimits(){
+    public void resetXLimits() {
         float range = getMaxX() - getMinX();
         setRangeX(getMinX()-range*getRangeXRatio(), getMaxX()+range*getRangeXRatio());
     }
         shouldUpdate = true;
         postInvalidate();
     }
-    public int getLineToFill(){
+    public int getLineToFill() {
         return lineToFill;
     }
     public void setLines(ArrayList<Line> lines) {
     public Line getLine(int index) {
         return lines.get(index);
     }
-    public int getSize(){
+    public int getSize() {
         return lines.size();
     }
 
         minY = min;
         maxY = max;
     }
-    private void setRangeY(double min, double max){
+    private void setRangeY(double min, double max) {
         minY = (float)min;
         maxY = (float)max;
     }
         maxX = max;
         isMaxXUserSet = true;
     }
-    private void setRangeX(double min, double max){
+    private void setRangeX(double min, double max) {
         minX = (float)min;
         maxX = (float)max;
     }
-    public float getMaxY(){
+    public float getMaxY() {
         float max = lines.get(0).getPoint(0).getY();
-        for (Line line : lines){
-            for (LinePoint point : line.getPoints()){
+        for (Line line : lines) {
+            for (LinePoint point : line.getPoints()) {
                 max = point.getY() > max ? point.getY() : max;
             }
         }
         return maxY;
     }
 
-    public float getMinY(){
+    public float getMinY() {
         float min = lines.get(0).getPoint(0).getY();
-        for (Line line : lines){
-            for (LinePoint point : line.getPoints()){
+        for (Line line : lines) {
+            for (LinePoint point : line.getPoints()) {
                 min = point.getY() < min ? point.getY() : min;
             }
         }
         minY = min;
         return minY;
     }
-    public float getMinLimY(){
+    public float getMinLimY() {
         return minY;
     }
-    public float getMaxLimY(){
+    public float getMaxLimY() {
         return maxY;
     }
-    public float getMinLimX(){
+    public float getMinLimX() {
         return minX;
     }
-    public float getMaxLimX(){
+    public float getMaxLimX() {
         if (isMaxXUserSet) {
             return maxX;
-        }
-        else {
+        } else {
             return getMaxX();
         }
     }
-    public float getMaxX(){
+    public float getMaxX() {
         float max = lines.size() > 0 ? lines.get(0).getPoint(0).getX() : 0;
-        for (Line line : lines){
-            for (LinePoint point : line.getPoints()){
+        for (Line line : lines) {
+            for (LinePoint point : line.getPoints()) {
                 max = point.getX() > max ? point.getX() : max;
             }
         }
         return maxX;
 
     }
-    public float getMinX(){
+    public float getMinX() {
         float min = lines.size() > 0 ? lines.get(0).getPoint(0).getX() : 0;
-        for (Line line : lines){
-            for (LinePoint point : line.getPoints()){
+        for (Line line : lines) {
+            for (LinePoint point : line.getPoints()) {
                 min = point.getX() < min ? point.getX() : min;
             }
         }
 
 
             int lineCount = 0;
-            for (Line line : lines){
+            for (Line line : lines) {
                 int count = 0;
                 float lastXPixels = 0, newYPixels = 0;
                 float lastYPixels = 0, newXPixels = 0;
 
-                if (lineCount == lineToFill){
+                if (lineCount == lineToFill) {
                     paint.setColor(mFillColor);
                     paint.setStrokeWidth(mStrokeWidth);
-                    for (int i = 10; i-getWidth() < getHeight(); i = i+mStrokeSpacing){
+                    for (int i = 10; i-getWidth() < getHeight(); i = i+mStrokeSpacing) {
                         canvas.drawLine(i, getHeight()-bottomPadding, 0, getHeight()-bottomPadding-i, paint);
                     }
 
                     paint.reset();
 
                     paint.setXfermode(new PorterDuffXfermode(android.graphics.PorterDuff.Mode.CLEAR));
-                    for (LinePoint p : line.getPoints()){
+                    for (LinePoint p : line.getPoints()) {
                         float yPercent = (p.getY()-minY)/(maxY - minY);
                         float xPercent = (p.getX()-minX)/(maxX - minX);
-                        if (count == 0){
+                        if (count == 0) {
                             lastXPixels = sidePadding + (xPercent*usableWidth);
                             lastYPixels = getHeight() - bottomPadding - (usableHeight*yPercent);
                             path.moveTo(lastXPixels, lastYPixels);
             canvas.drawLine(sidePadding, getHeight() - bottomPadding, getWidth()-sidePadding, getHeight()-bottomPadding, paint);
             paint.setAlpha(255);
 
-            for (Line line : lines){
+            for (Line line : lines) {
                 int count = 0;
                 float lastXPixels = 0, newYPixels = 0;
                 float lastYPixels = 0, newXPixels = 0;
                 paint.setColor(line.getColor());
                 paint.setStrokeWidth(getStrokeWidth(line));
 
-                for (LinePoint p : line.getPoints()){
+                for (LinePoint p : line.getPoints()) {
                     float yPercent = (p.getY()-minY)/(maxY - minY);
                     float xPercent = (p.getX()-minX)/(maxX - minX);
-                    if (count == 0){
+                    if (count == 0) {
                         lastXPixels = sidePadding + (xPercent*usableWidth);
                         lastYPixels = getHeight() - bottomPadding - (usableHeight*yPercent);
                     } else {
 
             int pointCount = 0;
 
-            for (Line line : lines){
+            for (Line line : lines) {
 
                 paint.setColor(line.getColor());
                 paint.setStrokeWidth(getStrokeWidth(line));
                 paint.setStrokeCap(Paint.Cap.ROUND);
 
-                if (line.isShowingPoints()){
-                    for (LinePoint p : line.getPoints()){
+                if (line.isShowingPoints()) {
+                    for (LinePoint p : line.getPoints()) {
                         float yPercent = (p.getY()-minY)/(maxY - minY);
                         float xPercent = (p.getX()-minX)/(maxX - minX);
                         float xPixels = sidePadding + (xPercent*usableWidth);
                         int outerRadius;
                         if (line.isUsingDips()) {
                             outerRadius = getPixelForDip(line.getStrokeWidth() + 4);
-                        }
-                        else {
+                        } else {
                             outerRadius = line.getStrokeWidth() + 4;
                         }
                         int innerRadius = outerRadius / 2;
                         p.setPath(path2);
                         p.setRegion(new Region((int)(xPixels-30), (int)(yPixels-30), (int)(xPixels+30), (int)(yPixels+30)));
 
-                        if (indexSelected == pointCount && listener != null){
+                        if (indexSelected == pointCount && listener != null) {
                             paint.setColor(p.getSelectedColor());
                             canvas.drawPath(p.getPath(), paint);
                             paint.setAlpha(255);
         int strokeWidth;
         if (line.isUsingDips()) {
             strokeWidth = getPixelForDip(line.getStrokeWidth());
-        }
-        else {
+        } else {
             strokeWidth = line.getStrokeWidth();
         }
         return strokeWidth;
         int pointCount = 0;
 
         Region r = new Region();
-        for (Line line : lines){
+        for (Line line : lines) {
             pointCount = 0;
-            for (LinePoint p : line.getPoints()){
+            for (LinePoint p : line.getPoints()) {
 
-                if (p.getPath() != null && p.getRegion() != null){
+                if (p.getPath() != null && p.getRegion() != null) {
                     r.setPath(p.getPath(), p.getRegion());
-                    if (r.contains((int)point.x,(int) point.y) && event.getAction() == MotionEvent.ACTION_DOWN){
+                    if (r.contains((int)point.x,(int) point.y) && event.getAction() == MotionEvent.ACTION_DOWN) {
                         indexSelected = count;
-                    } else if (event.getAction() == MotionEvent.ACTION_UP){
-                        if (r.contains((int)point.x,(int) point.y) && listener != null){
+                    } else if (event.getAction() == MotionEvent.ACTION_UP) {
+                        if (r.contains((int)point.x,(int) point.y) && listener != null) {
                             listener.onClick(lineCount, pointCount);
                         }
                         indexSelected = -1;
 
         }
 
-        if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_UP){
+        if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_UP) {
             shouldUpdate = true;
             postInvalidate();
         }

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

     private int mColor = 0xFF000000;
     private int mSelectedColor = 0x8033B5E5;
 
-    public LinePoint(){
+    public LinePoint() {
     }
 
-    public LinePoint(double x, double y){
+    public LinePoint(double x, double y) {
         this.mX = (float)x;
         this.mY = (float)y;
     }
-    public LinePoint(float x, float y){
+    public LinePoint(float x, float y) {
         this.mX = x;
         this.mY = y;
     }
         this.mY = y;
     }
 
-    public void setX(double x){
+    public void setX(double x) {
         this.mX = (float) x;
     }
 
-    public void setY(double y){
+    public void setY(double y) {
         this.mY = (float) y;
     }
     public Region getRegion() {
     }
 
     @Override
-    public String toString(){
+    public String toString() {
         return "x= " + mX + ", y= " + mY;
     }
 

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

 
         midX = getWidth()/2;
         midY = getHeight()/2;
-        if (midX < midY){
+        if (midX < midY) {
             radius = midX;
         } else {
             radius = midY;
         radius -= mPadding;
         innerRadius = radius * mInnerCircleRatio / 255;
 
-        for (PieSlice slice : mSlices){
+        for (PieSlice slice : mSlices) {
             totalValue += slice.getValue();
         }
 
         int count = 0;
-        for (PieSlice slice : mSlices){
+        for (PieSlice slice : mSlices) {
             Path p = new Path();
-            if (mSelectedIndex == count && mListener != null){
+            if (mSelectedIndex == count && mListener != null) {
                 mPaint.setColor(slice.getSelectedColor());
-            }
-            else {
+            } else {
                 mPaint.setColor(slice.getColor());
             }
             currentSweep = (slice.getValue()/totalValue)*(360);
             point.y = (int) event.getY();
 
             int count = 0;
-            for (PieSlice slice : mSlices){
+            for (PieSlice slice : mSlices) {
                 Region r = new Region();
                 r.setPath(slice.getPath(), slice.getRegion());
-                if (r.contains((int)point.x,(int) point.y) && event.getAction() == MotionEvent.ACTION_DOWN){
+                if (r.contains((int)point.x,(int) point.y) && event.getAction() == MotionEvent.ACTION_DOWN) {
                     mSelectedIndex = count;
-                } else if (event.getAction() == MotionEvent.ACTION_UP){
-                    if (r.contains((int)point.x,(int) point.y) && mListener != null){
-                        if (mSelectedIndex > -1){
+                } else if (event.getAction() == MotionEvent.ACTION_UP) {
+                    if (r.contains((int)point.x,(int) point.y) && mListener != null) {
+                        if (mSelectedIndex > -1) {
                             mListener.onClick(mSelectedIndex);
                         }
                         mSelectedIndex = -1;
                     }
 
-                }
-                else if(event.getAction() == MotionEvent.ACTION_CANCEL)
+                } else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
                     mSelectedIndex = -1;
+                }
                 count++;
             }
 
             if (event.getAction() == MotionEvent.ACTION_DOWN ||
                     event.getAction() == MotionEvent.ACTION_UP ||
-                    event.getAction() == MotionEvent.ACTION_CANCEL){
+                    event.getAction() == MotionEvent.ACTION_CANCEL) {
                 postInvalidate();
             }
         }
         this.mListener = listener;
     }
 
-    public void removeSlices(){
-        for (int i = mSlices.size()-1; i >= 0; i--){
+    public void removeSlices() {
+        for (int i = mSlices.size()-1; i >= 0; i--) {
             mSlices.remove(i);
         }
         postInvalidate();