Clover Coverage Report - SaveApp Coverage Report
Coverage timestamp: mar dic 23 2014 15:53:11 EST
../../../../img/srcFileCovDistChart0.png 77% of files have more coverage
62   165   6   62
10   113   0,1   1
1     6  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  PlotActivity       Line # 25 62 6 0% 0.0
 
No Tests
 
1    package com.loopback.androidapps.saveapp;
2   
3    import android.app.Activity;
4    import android.database.Cursor;
5    import android.graphics.Color;
6    import android.graphics.Paint;
7    import android.os.Bundle;
8    import android.util.Log;
9    import android.widget.TextView;
10    import android.widget.Toast;
11   
12    import com.androidplot.xy.SimpleXYSeries;
13    import com.androidplot.series.XYSeries;
14    import com.androidplot.ui.layout.AnchorPosition;
15    import com.androidplot.ui.layout.DynamicTableModel;
16    import com.androidplot.ui.layout.SizeLayoutType;
17    import com.androidplot.ui.layout.SizeMetrics;
18    import com.androidplot.ui.layout.XLayoutStyle;
19    import com.androidplot.ui.layout.YLayoutStyle;
20    import com.androidplot.xy.*;
21   
22    import java.text.DecimalFormat;
23    import java.util.ArrayList;
24   
 
25    public class PlotActivity extends Activity {
26   
27    private XYPlot mySimpleXYPlot;
28    private DBManager dbManager;
29    private TextView txtAccount;
30    public SaveApp saveApp;
31   
 
32  0 toggle @Override
33    public void onCreate(Bundle savedInstanceState) {
34  0 super.onCreate(savedInstanceState);
35  0 setContentView(R.layout.plot1);
36   
37  0 Log.i("PLOT", "Loading...");
38  0 saveApp = ((SaveApp) getApplicationContext());
39  0 dbManager = saveApp.getDbManager();
40   
41  0 txtAccount = (TextView) findViewById(R.id.txtAccount);
42  0 txtAccount.setText(getString(R.string.strAccount) + ": "
43    + saveApp.getAccountDesc());
44   
45    // Initialize our XYPlot reference:
46  0 mySimpleXYPlot = (XYPlot) findViewById(R.id.mySimpleXYPlot);
47   
48  0 Cursor cursor = dbManager.selectPlotList();
49  0 DBReader dbReader = new DBReader();
50  0 dbReader.plotList(cursor);
51   
52  0 if (dbReader.dateList == null)
53  0 Toast.makeText(this,
54    "You don�t have enough data to plot. Please add some. ",
55    Toast.LENGTH_SHORT).show();
56    else {
57    // DATA----------------------------------------------
58    // Inflate acumulated List
59  0 ArrayList<Integer> acumulatedList = new ArrayList<Integer>();
60  0 acumulatedList.add(dbReader.chargeList.get(0));
61  0 for (int i = 1; i < dbReader.chargeList.size(); i++) {
62  0 acumulatedList.add(dbReader.chargeList.get(i)
63    + acumulatedList.get(i - 1));
64    }
65   
66    // 0 to Null
67  0 for (int i = 0; i < dbReader.chargeList.size(); i++) {
68  0 if (dbReader.chargeList.get(i) == 0)
69  0 dbReader.chargeList.set(i, null);
70    }
71    // Turn the above arrays into XYSeries:
72    // ----------------------------------------------
73    // XYSeries series1 = new SimpleXYSeries(dbReader.dateList, // SimpleXYSeries
74    // dbReader.chargeList, "Movement"); // Set the display title
75    // of the
76    // series
77  0 XYSeries series2 = new SimpleXYSeries(dbReader.dateList, // SimpleXYSeries
78    acumulatedList, "Bag"); // Set the display title of the
79    // series
80   
81    // FOR THE BARS ----------------------------------------------
82    /*
83    * XYSeries series2 = new
84    * SimpleXYSeries(Arrays.asList(series2Numbers),
85    * SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Series2");
86    */
87   
88    //FORMATTING LINE----------------------------------------------
89  0 LineAndPointFormatter series1Format = new LineAndPointFormatter(
90    Color.rgb(100, 25, 20), Color.rgb(4, 100, 88), Color.rgb(
91    66, 100, 3));
92  0 series1Format.setFillPaint(null);
93  0 series1Format.setVertexPaint(null);
94  0 series1Format.getLinePaint().setShadowLayer(0, 0, 0, 0);
95   
96    // Add series1 to the xyplot:
97  0 mySimpleXYPlot.addSeries(series2, series1Format);
98    // MOVEMENTS SERIE
99    //mySimpleXYPlot.addSeries(series1, series1Format);
100   
101   
102    // MARKER----------------------------------------------
103  0 XYRegionFormatter regionFormatter = new XYRegionFormatter(Color.RED);
104  0 series1Format.addRegion(new RectRegion(Double.NEGATIVE_INFINITY,
105    Double.POSITIVE_INFINITY, 0, 3, "Zero"), regionFormatter);
106   
107  0 mySimpleXYPlot.addMarker(new YValueMarker(0, "0"));
108   
109    // LEGEND----------------------------------------------
110  0 mySimpleXYPlot.getLegendWidget().setTableModel(
111    new DynamicTableModel(2, 2));
112  0 mySimpleXYPlot.getLegendWidget().setSize(
113    new SizeMetrics(25, SizeLayoutType.ABSOLUTE, 125,
114    SizeLayoutType.ABSOLUTE));
115   
116  0 Paint bgPaint = new Paint();
117  0 bgPaint.setColor(Color.BLACK);
118  0 bgPaint.setStyle(Paint.Style.FILL);
119  0 bgPaint.setAlpha(140);
120  0 mySimpleXYPlot.getLegendWidget().setBackgroundPaint(bgPaint);
121   
122  0 mySimpleXYPlot.getLegendWidget().setPadding(10, 10, 10, 10);
123  0 mySimpleXYPlot.position(mySimpleXYPlot.getLegendWidget(), 20,
124    XLayoutStyle.ABSOLUTE_FROM_RIGHT, 35,
125    YLayoutStyle.ABSOLUTE_FROM_BOTTOM,
126    AnchorPosition.RIGHT_BOTTOM);
127  0 mySimpleXYPlot.getGraphWidget().setRangeLabelMargin(-1);
128  0 mySimpleXYPlot.getGraphWidget().setRangeLabelWidth(25);
129  0 mySimpleXYPlot.getGraphWidget().setDomainLabelWidth(10);
130  0 mySimpleXYPlot.getGraphWidget().setDomainLabelMargin(-6);
131  0 mySimpleXYPlot.getGraphWidget().setBackgroundPaint(null);
132  0 mySimpleXYPlot.setBorderPaint(null);
133  0 mySimpleXYPlot.getGraphWidget().getGridBackgroundPaint()
134    .setColor(Color.WHITE);
135  0 mySimpleXYPlot.getGraphWidget().setMarginTop(10);
136  0 mySimpleXYPlot.getGraphWidget().setMarginRight(10);
137   
138    // GENERAL ----------------------------------------------
139    // RANGE
140  0 mySimpleXYPlot.setRangeLabel(saveApp.getCurrencySymbol());
141  0 mySimpleXYPlot.setRangeStepValue(25);
142  0 mySimpleXYPlot.setRangeStep(XYStepMode.INCREMENT_BY_VAL, 10);
143  0 mySimpleXYPlot.setRangeValueFormat(new DecimalFormat("#"));
144    // RANGE BOUNDARIES
145  0 mySimpleXYPlot.setRangeBoundaries(
146  0 (saveApp.getCurrentBudget() > 0 ? -20 : saveApp
147    .getCurrentBudget()),
148    saveApp.getBudget() + saveApp.getBudget() / 20,
149    BoundaryMode.FIXED);
150  0 mySimpleXYPlot.setTicksPerRangeLabel(5);
151    // DOMAIN
152  0 mySimpleXYPlot.setDomainLabel("Day");
153  0 mySimpleXYPlot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 1);
154  0 mySimpleXYPlot.setDomainValueFormat(new DecimalFormat("#"));
155  0 mySimpleXYPlot.getDomainLabelWidget().setVisible(true);
156    // GENERAL
157  0 mySimpleXYPlot.setTitle(saveApp.getAccountDesc());
158  0 mySimpleXYPlot.setPlotPadding(20, 20, 20, 20);
159  0 mySimpleXYPlot.getRangeLabelWidget().setVisible(true);
160  0 mySimpleXYPlot.getTitleWidget().pack();
161  0 mySimpleXYPlot.disableAllMarkup();
162   
163    }
164    }
165    }