Skip to content

Commit

Permalink
Trying to fix issue #310
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Fisch authored and Robert Fisch committed Apr 18, 2016
1 parent 960739c commit b191867
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 35 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/lu/fisch/canze/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
2016.04.18 [Bob] Trying to fix issue #310
2016.04.18 [Bob] The plotter on the Battery screen has been fixed

---< Version 1.12 / 2016.04.11 >---
Expand Down
74 changes: 39 additions & 35 deletions app/src/main/java/lu/fisch/canze/widgets/Timeplot.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,49 +285,53 @@ public void draw(Graphics g) {
if (i < values.size() - 1) {
if(getOptions().getOption(sid)!=null &&
getOptions().getOption(sid).contains("full")) {
Polygon p = new Polygon();
p.addPoint(getX() + getWidth() - barWidth + (int) lastX-spaceAlt,
getY() + (int) lastY);
p.addPoint(getX() + getWidth() - barWidth + (int) mx-spaceAlt,
getY() + (int) my);
p.addPoint(getX() + getWidth() - barWidth + (int) mx-spaceAlt,
(int) (getY() + zy));
p.addPoint(getX() + getWidth() - barWidth + (int) lastX-spaceAlt,
(int) (getY() + zy));
g.fillPolygon(p);
}
else if(getOptions().getOption(sid)!=null &&
getOptions().getOption(sid).contains("gradient")) {

if(i<values.size() && values.get(i+1)!=null) {
if((lastY!=Double.NaN) && (lastX!=Double.NaN)) {
Polygon p = new Polygon();
p.addPoint(getX() + getWidth() - barWidth + (int) lastX-spaceAlt,
p.addPoint(getX() + getWidth() - barWidth + (int) lastX - spaceAlt,
getY() + (int) lastY);
p.addPoint(getX() + getWidth() - barWidth + (int) mx-spaceAlt,
p.addPoint(getX() + getWidth() - barWidth + (int) mx - spaceAlt,
getY() + (int) my);
p.addPoint(getX() + getWidth() - barWidth + (int) mx-spaceAlt,
p.addPoint(getX() + getWidth() - barWidth + (int) mx - spaceAlt,
(int) (getY() + zy));
p.addPoint(getX() + getWidth() - barWidth + (int) lastX-spaceAlt,
p.addPoint(getX() + getWidth() - barWidth + (int) lastX - spaceAlt,
(int) (getY() + zy));
g.fillPolygon(p);
}
}
else if(getOptions().getOption(sid)!=null &&
getOptions().getOption(sid).contains("gradient")) {

/*if ((values.get(i + 1).value > 0 && tp.value > 0) || (values.get(i + 1).value < 0 && tp.value < 0)) {
if (tp.value > 0)
g.fillPolygon(p, 0, (int) zy, 0, 0, colorRanges.getColors(sid, tp.value > 0), colorRanges.getSpacings(sid, 0, max, tp.value > 0));
if(i<values.size() && values.get(i+1)!=null) {
if((lastY!=Double.NaN) && (lastX!=Double.NaN)) {
Polygon p = new Polygon();
p.addPoint(getX() + getWidth() - barWidth + (int) lastX - spaceAlt,
getY() + (int) lastY);
p.addPoint(getX() + getWidth() - barWidth + (int) mx - spaceAlt,
getY() + (int) my);
p.addPoint(getX() + getWidth() - barWidth + (int) mx - spaceAlt,
(int) (getY() + zy));
p.addPoint(getX() + getWidth() - barWidth + (int) lastX - spaceAlt,
(int) (getY() + zy));

/*if ((values.get(i + 1).value > 0 && tp.value > 0) || (values.get(i + 1).value < 0 && tp.value < 0)) {
if (tp.value > 0)
g.fillPolygon(p, 0, (int) zy, 0, 0, colorRanges.getColors(sid, tp.value > 0), colorRanges.getSpacings(sid, 0, max, tp.value > 0));
else
g.fillPolygon(p, 0, graphHeight, 0, (int) zy, colorRanges.getColors(sid, tp.value > 0), colorRanges.getSpacings(sid, min, 0, tp.value > 0));
}
else
g.fillPolygon(p, 0, graphHeight, 0, (int) zy, colorRanges.getColors(sid, tp.value > 0), colorRanges.getSpacings(sid, min, 0, tp.value > 0));
{
g.fillPolygon(p, 0, graphHeight, 0, 0, colorRanges.getColors(sid), colorRanges.getSpacings(sid, min, max));
}*/
int[] colors = colorRanges.getColors(sid);
float[] spacings = colorRanges.getSpacings(sid, min, max);
if (colors.length == spacings.length)
g.setGradient(0, graphHeight, 0, 0, colors, spacings);
g.fillPolygon(p);
g.clearGradient();

//else MainActivity.debug("size not equal: "+colors.length+"=="+spacings.length);
}
else
{
g.fillPolygon(p, 0, graphHeight, 0, 0, colorRanges.getColors(sid), colorRanges.getSpacings(sid, min, max));
}*/
int[] colors = colorRanges.getColors(sid);
float[] spacings = colorRanges.getSpacings(sid, min, max);
if(colors.length==spacings.length)
g.setGradient(0, graphHeight, 0, 0, colors, spacings);
g.fillPolygon(p);
g.clearGradient();

//else MainActivity.debug("size not equal: "+colors.length+"=="+spacings.length);
}
}
else
Expand Down

0 comments on commit b191867

Please sign in to comment.