From a26e5377d5782a244a20a1456e28e341bafb73e0 Mon Sep 17 00:00:00 2001 From: Nick Fellows Date: Wed, 28 Feb 2018 21:03:33 -0600 Subject: [PATCH 01/41] 1.5.4 Changes (#74) * #69 Fixes resize etc. for Y_VALS_ONLY format for SimpleXYSeries. * #73 Fixes issue with XYGraphWidget not laying out on size change. Also adds Widget.onResize to efficiently detect when new layout dimensions may need recalculation. * Adds license and issue template for Github display --- .github/ISSUE_TEMPLATE.md | 14 ++ LICENSE.md | 13 ++ README.md | 2 +- .../com/androidplot/ui/LayoutManager.java | 2 +- .../com/androidplot/ui/widget/Widget.java | 132 +++++++++++------- .../com/androidplot/xy/SimpleXYSeries.java | 13 +- .../com/androidplot/xy/XYGraphWidget.java | 16 +-- .../com/androidplot/ui/widget/WidgetTest.java | 112 +++++++++++++++ .../androidplot/xy/SimpleXYSeriesTest.java | 30 +++- .../com/androidplot/xy/XYGraphWidgetTest.java | 8 +- build.gradle | 2 +- .../res/layout/simple_xy_plot_example.xml | 17 ++- docs/quickstart.md | 2 +- docs/release_notes.md | 7 +- 14 files changed, 283 insertions(+), 87 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 LICENSE.md create mode 100644 androidplot-core/src/test/java/com/androidplot/ui/widget/WidgetTest.java diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..1e022fdb --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,14 @@ +Thanks for taking the time to help make Androidplot better! Please note +that issues should be submitted on Github for bugs only. + +How-to questions may be posted under the [Androidplot tag on Stack Overflow](https://stackoverflow.com/questions/tagged/androidplot) +and feature requests etc. may be posted to the [Google Group Forum](https://groups.google.com/forum/#!forum/androidplot). + +When possible, please include the following in your bug report: + +* Description of the problem +* Steps to reproduce the issue +* Version(s) of Androidplot being used +* A stacktrace if the issue is causing a crash + + diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 00000000..3fbf0a78 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,13 @@ + Copyright 2018 Androidplot.com + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/README.md b/README.md index 0e4e127d..7d7020d2 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Technical questions should be posted using the [androidplot tag](http://stackove # License Androidplot has been made available under the Apache 2.0 license: - Copyright 2016 Androidplot.com + Copyright 2018 Androidplot.com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/androidplot-core/src/main/java/com/androidplot/ui/LayoutManager.java b/androidplot-core/src/main/java/com/androidplot/ui/LayoutManager.java index 9e66e80c..e4c5cce5 100644 --- a/androidplot-core/src/main/java/com/androidplot/ui/LayoutManager.java +++ b/androidplot-core/src/main/java/com/androidplot/ui/LayoutManager.java @@ -96,7 +96,7 @@ public void draw(Canvas canvas) throws PlotRenderException { PositionMetrics metrics = widget.getPositionMetrics(); float elementWidth = widget.getWidthPix(displayDims.paddedRect.width()); float elementHeight = widget.getHeightPix(displayDims.paddedRect.height()); - PointF coords = widget.getElementCoordinates(elementHeight, + PointF coords = Widget.calculateCoordinates(elementHeight, elementWidth, displayDims.paddedRect, metrics); DisplayDimensions dims = widget.getWidgetDimensions(); diff --git a/androidplot-core/src/main/java/com/androidplot/ui/widget/Widget.java b/androidplot-core/src/main/java/com/androidplot/ui/widget/Widget.java index 6009ce36..d66b85a8 100644 --- a/androidplot-core/src/main/java/com/androidplot/ui/widget/Widget.java +++ b/androidplot-core/src/main/java/com/androidplot/ui/widget/Widget.java @@ -17,6 +17,9 @@ package com.androidplot.ui.widget; import android.graphics.*; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + import com.androidplot.exception.PlotRenderException; import com.androidplot.ui.*; import com.androidplot.util.DisplayDimensions; @@ -42,6 +45,7 @@ public abstract class Widget implements BoxModelable, Resizable { private LayoutManager layoutManager; private Rotation rotation = Rotation.NONE; + private RectF lastWidgetRect = null; public enum Rotation { NINETY_DEGREES, @@ -77,6 +81,7 @@ public void setAnchor(Anchor anchor) { /** * Same as {@link #position(float, HorizontalPositioning, float, VerticalPositioning, Anchor)} * but with the anchor parameter defaulted to the upper left corner. + * * @param x * @param horizontalPositioning * @param y @@ -87,11 +92,11 @@ public void position(float x, HorizontalPositioning horizontalPositioning, float } /** - * @param x X-Coordinate of the top left corner of element. When using RELATIVE, must be a value between 0 and 1. + * @param x X-Coordinate of the top left corner of element. When using RELATIVE, must be a value between 0 and 1. * @param horizontalPositioning LayoutType to use when orienting this element's X-Coordinate. - * @param y Y_VALS_ONLY-Coordinate of the top-left corner of element. When using RELATIVE, must be a value between 0 and 1. - * @param verticalPositioning LayoutType to use when orienting this element's Y_VALS_ONLY-Coordinate. - * @param anchor The point of reference used by this positioning call. + * @param y Y_VALS_ONLY-Coordinate of the top-left corner of element. When using RELATIVE, must be a value between 0 and 1. + * @param verticalPositioning LayoutType to use when orienting this element's Y_VALS_ONLY-Coordinate. + * @param anchor The point of reference used by this positioning call. */ public void position(float x, HorizontalPositioning horizontalPositioning, float y, VerticalPositioning verticalPositioning, Anchor anchor) { @@ -271,7 +276,7 @@ public float getMarginRight() { * into this Widget's size or position is altered. */ public synchronized void refreshLayout() { - if(positionMetrics == null) { + if (positionMetrics == null) { // make sure positionMetrics have been set. this method can be // automatically called during xml configuration of certain params // before the widget is fully configured. @@ -279,7 +284,7 @@ public synchronized void refreshLayout() { } float elementWidth = getWidthPix(plotDimensions.paddedRect.width()); float elementHeight = getHeightPix(plotDimensions.paddedRect.height()); - PointF coords = getElementCoordinates(elementHeight, + PointF coords = calculateCoordinates(elementHeight, elementWidth, plotDimensions.paddedRect, positionMetrics); RectF widgetRect = new RectF(coords.x, coords.y, @@ -296,56 +301,76 @@ public synchronized void layout(final DisplayDimensions plotDimensions) { refreshLayout(); } - public PointF getElementCoordinates(float height, float width, RectF viewRect, PositionMetrics metrics) { - float x = metrics.getXPositionMetric().getPixelValue(viewRect.width()) + viewRect.left; - float y = metrics.getYPositionMetric().getPixelValue(viewRect.height()) + viewRect.top; - PointF point = new PointF(x, y); - return PixelUtils.sub(point, getAnchorOffset(width, height, metrics.getAnchor())); - } + + public static PointF calculateCoordinates(float height, float width, RectF viewRect, PositionMetrics metrics) { + float x = metrics.getXPositionMetric().getPixelValue(viewRect.width()) + viewRect.left; + float y = metrics.getYPositionMetric().getPixelValue(viewRect.height()) + viewRect.top; + PointF point = new PointF(x, y); + return PixelUtils.sub(point, getAnchorOffset(width, height, metrics.getAnchor())); + } public static PointF getAnchorOffset(float width, float height, Anchor anchor) { - PointF point = new PointF(); - switch (anchor) { - case LEFT_TOP: - break; - case LEFT_MIDDLE: - point.set(0, height / 2); - break; - case LEFT_BOTTOM: - point.set(0, height); - break; - case RIGHT_TOP: - point.set(width, 0); - break; - case RIGHT_BOTTOM: - point.set(width, height); - break; - case RIGHT_MIDDLE: - point.set(width, height / 2); - break; - case TOP_MIDDLE: - point.set(width / 2, 0); - break; - case BOTTOM_MIDDLE: - point.set(width / 2, height); - break; - case CENTER: - point.set(width / 2, height / 2); - break; - default: - throw new IllegalArgumentException("Unsupported anchor location: " + anchor); - } - return point; + PointF point = new PointF(); + switch (anchor) { + case LEFT_TOP: + break; + case LEFT_MIDDLE: + point.set(0, height / 2); + break; + case LEFT_BOTTOM: + point.set(0, height); + break; + case RIGHT_TOP: + point.set(width, 0); + break; + case RIGHT_BOTTOM: + point.set(width, height); + break; + case RIGHT_MIDDLE: + point.set(width, height / 2); + break; + case TOP_MIDDLE: + point.set(width / 2, 0); + break; + case BOTTOM_MIDDLE: + point.set(width / 2, height); + break; + case CENTER: + point.set(width / 2, height / 2); + break; + default: + throw new IllegalArgumentException("Unsupported anchor location: " + anchor); } + return point; + } public static PointF getAnchorCoordinates(RectF widgetRect, Anchor anchor) { - return PixelUtils.add(new PointF(widgetRect.left, widgetRect.top), - getAnchorOffset(widgetRect.width(), widgetRect.height(), anchor)); - } + return PixelUtils.add(new PointF(widgetRect.left, widgetRect.top), + getAnchorOffset(widgetRect.width(), widgetRect.height(), anchor)); + } + + public static PointF getAnchorCoordinates(float x, float y, float width, float height, Anchor anchor) { + return getAnchorCoordinates(new RectF(x, y, x + width, y + height), anchor); + } - public static PointF getAnchorCoordinates(float x, float y, float width, float height, Anchor anchor) { - return getAnchorCoordinates(new RectF(x, y, x+width, y+height), anchor); + private void checkSize(@NonNull RectF widgetRect) { + if (lastWidgetRect == null || !lastWidgetRect.equals(widgetRect)) { + onResize(lastWidgetRect, widgetRect); } + lastWidgetRect = widgetRect; + } + + /** + * Called whenever the height or width of the Widget's reserved space has changed, + * immediately before {@link #doOnDraw(Canvas, RectF)}. + * May be used to efficiently carry out expensive operations only when necessary. + * + * @param oldRect + * @param newRect + */ + protected void onResize(@Nullable RectF oldRect, @NonNull RectF newRect) { + // do nothing by default + } public void draw(Canvas canvas) throws PlotRenderException { if (isVisible()) { @@ -353,12 +378,13 @@ public void draw(Canvas canvas) throws PlotRenderException { drawBackground(canvas, widgetDimensions.canvasRect); } canvas.save(); - final RectF paddedRect = applyRotation(canvas, widgetDimensions.paddedRect); - doOnDraw(canvas, paddedRect); + final RectF widgetRect = applyRotation(canvas, widgetDimensions.paddedRect); + checkSize(widgetRect); + doOnDraw(canvas, widgetRect); canvas.restore(); if (borderPaint != null) { - drawBorder(canvas, paddedRect); + drawBorder(canvas, widgetRect); } } } @@ -395,7 +421,7 @@ protected RectF applyRotation(Canvas canvas, RectF rect) { throw new UnsupportedOperationException("Not yet implemented."); } - if(rotation != Rotation.NONE) { + if (rotation != Rotation.NONE) { canvas.rotate(rotationDegs, cx, cy); } return rect; diff --git a/androidplot-core/src/main/java/com/androidplot/xy/SimpleXYSeries.java b/androidplot-core/src/main/java/com/androidplot/xy/SimpleXYSeries.java index 4d3ebaac..b9178123 100644 --- a/androidplot-core/src/main/java/com/androidplot/xy/SimpleXYSeries.java +++ b/androidplot-core/src/main/java/com/androidplot/xy/SimpleXYSeries.java @@ -33,9 +33,6 @@ * A convenience class used to create instances of XYPlot generated from Lists of Numbers. */ public class SimpleXYSeries implements EditableXYSeries, OrderedXYSeries, PlotListener { - - private static final String TAG = SimpleXYSeries.class.getName(); - private volatile LinkedList xVals = new LinkedList<>(); private volatile LinkedList yVals = new LinkedList<>(); private volatile String title = null; @@ -144,7 +141,7 @@ public void setModel(List model, ArrayFormat format) { lock.writeLock().lock(); try { // empty the current values: - xVals = null; + xVals.clear(); yVals.clear(); // make sure the new model has data: @@ -156,15 +153,16 @@ public void setModel(List model, ArrayFormat format) { // array containing only y-vals. assume x = index: case Y_VALS_ONLY: - for(Number n : model) { - yVals.add(n); + yVals.addAll(model); + for(int i = 0; i < yVals.size(); i++) { + xVals.add(i); } break; // xy interleaved array: case XY_VALS_INTERLEAVED: if (xVals == null) { - xVals = new LinkedList(); + xVals = new LinkedList<>(); } if (model.size() % 2 != 0) { throw new IndexOutOfBoundsException("Cannot auto-generate series from odd-sized xy List."); @@ -217,7 +215,6 @@ public void resize(int size) { try { lock.writeLock().lock(); if (xVals.size() < size) { - for (int i = xVals.size(); i < size; i++) { xVals.add(null); yVals.add(null); diff --git a/androidplot-core/src/main/java/com/androidplot/xy/XYGraphWidget.java b/androidplot-core/src/main/java/com/androidplot/xy/XYGraphWidget.java index d1ce96ec..2ecd4fcb 100644 --- a/androidplot-core/src/main/java/com/androidplot/xy/XYGraphWidget.java +++ b/androidplot-core/src/main/java/com/androidplot/xy/XYGraphWidget.java @@ -22,6 +22,8 @@ import android.graphics.Paint; import android.graphics.PointF; import android.graphics.RectF; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.androidplot.R; import com.androidplot.Region; @@ -492,18 +494,16 @@ protected float seriesToScreenY(Number y) { transform(y.doubleValue(), gridRect.bottom, gridRect.top, true); } + @Override + protected void onResize(@Nullable RectF oldRect, @NonNull RectF newRect) { + gridRect = RectFUtils.applyInsets(newRect, gridInsets); + labelRect = RectFUtils.applyInsets(newRect, lineLabelInsets); + } + @Override protected void doOnDraw(Canvas canvas, RectF widgetRect) throws PlotRenderException { - if(gridRect == null) { - gridRect = RectFUtils.applyInsets(widgetRect, gridInsets); - } - - if(labelRect == null) { - labelRect = RectFUtils.applyInsets(widgetRect, lineLabelInsets); - } - // don't draw if we have no space to draw into if (gridRect.height() > ZERO && gridRect.width() > ZERO) { final RectRegion bounds = plot.getBounds(); diff --git a/androidplot-core/src/test/java/com/androidplot/ui/widget/WidgetTest.java b/androidplot-core/src/test/java/com/androidplot/ui/widget/WidgetTest.java new file mode 100644 index 00000000..db81d57c --- /dev/null +++ b/androidplot-core/src/test/java/com/androidplot/ui/widget/WidgetTest.java @@ -0,0 +1,112 @@ +package com.androidplot.ui.widget; + +import android.graphics.Canvas; +import android.graphics.RectF; +import android.support.annotation.NonNull; + +import com.androidplot.exception.PlotRenderException; +import com.androidplot.test.AndroidplotTest; +import com.androidplot.ui.Anchor; +import com.androidplot.ui.HorizontalPositioning; +import com.androidplot.ui.LayoutManager; +import com.androidplot.ui.PositionMetrics; +import com.androidplot.ui.Size; +import com.androidplot.ui.SizeMetric; +import com.androidplot.ui.SizeMode; +import com.androidplot.ui.VerticalPositioning; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.InOrder; +import org.mockito.Mock; +import org.mockito.Mockito; + +import static junit.framework.Assert.assertEquals; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class WidgetTest extends AndroidplotTest { + + @Mock + LayoutManager layoutManager; + + @Mock + Size size; + + @Mock + Canvas canvas; + + Widget widget; + + PositionMetrics positionMetrics; + + @Before + public void before() { + + positionMetrics = new PositionMetrics( + 0, HorizontalPositioning.ABSOLUTE_FROM_LEFT, + 0, VerticalPositioning.ABSOLUTE_FROM_TOP, Anchor.LEFT_TOP); + when(size.getHeight()).thenReturn(new SizeMetric(100, SizeMode.ABSOLUTE)); + when(size.getWidth()).thenReturn(new SizeMetric(100, SizeMode.ABSOLUTE)); + widget = spy(new TestWidget(layoutManager, size)); + widget.setPositionMetrics(positionMetrics); + widget.refreshLayout(); + } + + @Test + public void setGetAnchor_setsAndGetsAnchor() { + widget.setAnchor(Anchor.LEFT_TOP); + assertEquals(Anchor.LEFT_TOP, widget.getAnchor()); + + widget.setAnchor(Anchor.RIGHT_BOTTOM); + assertEquals(Anchor.RIGHT_BOTTOM, widget.getAnchor()); + } + + @Test + public void position_withoutAnchor_updatesPositionWithExistingAnchor() { + final Anchor existingAnchor = widget.getAnchor(); + widget.position(1, HorizontalPositioning.ABSOLUTE_FROM_RIGHT, + 1, VerticalPositioning.ABSOLUTE_FROM_BOTTOM); + + assertEquals(existingAnchor, widget.getAnchor()); + assertEquals(1F, widget.getPositionMetrics().getYPositionMetric().getValue()); + assertEquals(1F, widget.getPositionMetrics().getXPositionMetric().getValue()); + } + + @Test + public void position_withAnchor_updatesPositionWithNewAnchor() { + final Anchor newAnchor = Anchor.CENTER; + widget.position(1, HorizontalPositioning.ABSOLUTE_FROM_RIGHT, + 1, VerticalPositioning.ABSOLUTE_FROM_BOTTOM, newAnchor); + + assertEquals(newAnchor, widget.getAnchor()); + assertEquals(1F, widget.getPositionMetrics().getYPositionMetric().getValue()); + assertEquals(1F, widget.getPositionMetrics().getXPositionMetric().getValue()); + } + + @Test + public void draw_sizeChanged_invokesOnResizeBeforeDoOnDraw() throws Exception { + InOrder inOrder = Mockito.inOrder(widget); + + widget.draw(canvas); + + inOrder.verify(widget).onResize(any(RectF.class), any(RectF.class)); + inOrder.verify(widget).doOnDraw(eq(canvas), any(RectF.class)); + verify(widget).onResize(any(RectF.class), any(RectF.class)); + } + + static class TestWidget extends Widget { + + public TestWidget(@NonNull LayoutManager layoutManager, @NonNull Size size) { + super(layoutManager, size); + } + + @Override + protected void doOnDraw(Canvas canvas, RectF widgetRect) throws PlotRenderException { + // nothing to do + } + } +} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/SimpleXYSeriesTest.java b/androidplot-core/src/test/java/com/androidplot/xy/SimpleXYSeriesTest.java index 50fd0f8a..dc21ab7c 100644 --- a/androidplot-core/src/test/java/com/androidplot/xy/SimpleXYSeriesTest.java +++ b/androidplot-core/src/test/java/com/androidplot/xy/SimpleXYSeriesTest.java @@ -26,7 +26,7 @@ public class SimpleXYSeriesTest { @Test - public void testYValsOnlyConstructor() throws Exception { + public void constructor_yValsOnly() throws Exception { Number[] yVals = {5, 6, 7, 8, 9}; SimpleXYSeries series = new SimpleXYSeries(Arrays.asList(yVals), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "test"); @@ -44,7 +44,7 @@ public void testYValsOnlyConstructor() throws Exception { } @Test - public void testXYInterleavedConstructor() throws Exception { + public void constructor_xyInterleaved() throws Exception { Number[] yVals = {55, 5, 66, 6, 77, 7, 88, 8, 99, 9}; SimpleXYSeries series = new SimpleXYSeries(Arrays.asList(yVals), SimpleXYSeries.ArrayFormat.XY_VALS_INTERLEAVED, "test"); @@ -62,7 +62,7 @@ public void testXYInterleavedConstructor() throws Exception { } @Test - public void testTwoListConstructor() throws Exception { + public void constructor_xAndYLists() throws Exception { Number[] yVals = {5, 6, 7, 8, 9}; Number[] xVals = {1, 2, 3, 4, 5}; SimpleXYSeries series = new SimpleXYSeries(Arrays.asList(xVals), Arrays.asList(yVals), "test"); @@ -81,7 +81,7 @@ public void testTwoListConstructor() throws Exception { } @Test - public void testPushPopStuff() throws Exception { + public void addRemove_modifiesSeries() throws Exception { Number[] yVals = {5, 6, 7, 8, 9}; Number[] xVals = {1, 2, 3, 4, 5}; SimpleXYSeries series = new SimpleXYSeries(Arrays.asList(xVals), Arrays.asList(yVals), "test"); @@ -108,7 +108,7 @@ public void testPushPopStuff() throws Exception { } @Test - public void testSet() throws Exception { + public void set_setsExpectedValue() throws Exception { Number[] yVals = {5, 6, 7, 8, 9}; Number[] xVals = {1, 2, 3, 4, 5}; SimpleXYSeries series = new SimpleXYSeries(Arrays.asList(xVals), Arrays.asList(yVals), "test"); @@ -129,7 +129,7 @@ public void testSet() throws Exception { } @Test - public void testResize() throws Exception { + public void resize_emptySeries_resizesSeries() { SimpleXYSeries series = new SimpleXYSeries("series"); series.resize(10); assertEquals(10, series.size()); @@ -148,7 +148,15 @@ public void testResize() throws Exception { } @Test - public void setXY_setsXAndY() { + public void resize_yValsOnly_resizesSeries() { + SimpleXYSeries series = new SimpleXYSeries( + SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "", 1, 2, 3); + series.resize(10); + assertEquals(10, series.size()); + } + + @Test + public void setXY_modifiesSeries() { SimpleXYSeries series = new SimpleXYSeries("series"); series.resize(5); series.setXY(100, 200, 0); @@ -158,6 +166,14 @@ public void setXY_setsXAndY() { } + @Test + public void setX_yValsOnly_changesValue() { + SimpleXYSeries series = new SimpleXYSeries( + SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "", 1, 2, 3); + series.setX(9, 0); + assertEquals(9, series.getX(0)); + } + @Test(expected = NoSuchElementException.class) public void removeFirst_throwsNoSuchElementException_ifEmpty() { new SimpleXYSeries("series").removeFirst(); diff --git a/androidplot-core/src/test/java/com/androidplot/xy/XYGraphWidgetTest.java b/androidplot-core/src/test/java/com/androidplot/xy/XYGraphWidgetTest.java index 0bfe4d9d..9f92afa8 100644 --- a/androidplot-core/src/test/java/com/androidplot/xy/XYGraphWidgetTest.java +++ b/androidplot-core/src/test/java/com/androidplot/xy/XYGraphWidgetTest.java @@ -103,7 +103,9 @@ public void testDoOnDraw_drawGridOnTopFalse() throws Exception { doNothing().when(graphWidget).drawGrid(canvas); doNothing().when(graphWidget).drawData(canvas); - graphWidget.doOnDraw(canvas, new RectF(0, 0, 100, 100)); + final RectF canvasRect = new RectF(0, 0, 100, 100); + graphWidget.onResize(null, canvasRect); + graphWidget.doOnDraw(canvas, canvasRect); InOrder io = inOrder(graphWidget); io.verify(graphWidget).drawGrid(canvas); @@ -117,7 +119,9 @@ public void testDoOnDraw_drawGridOnTopTrue() throws Exception { doNothing().when(graphWidget).drawGrid(canvas); doNothing().when(graphWidget).drawData(canvas); - graphWidget.doOnDraw(canvas, new RectF(0, 0, 100, 100)); + final RectF canvasRect = new RectF(0, 0, 100, 100); + graphWidget.onResize(null, canvasRect); + graphWidget.doOnDraw(canvas, canvasRect); InOrder io = inOrder(graphWidget); io.verify(graphWidget).drawData(canvas); diff --git a/build.gradle b/build.gradle index b1e30c15..c45af2f9 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ ext { theCompileSdkVersion = 26 theTargetSdkVersion = 26 theMinSdkVersion = 5 - theVersionName = '1.5.3' + theVersionName = '1.5.4' theVersionCode = 0 } diff --git a/demoapp/src/main/res/layout/simple_xy_plot_example.xml b/demoapp/src/main/res/layout/simple_xy_plot_example.xml index fecf1241..48aeb5cb 100644 --- a/demoapp/src/main/res/layout/simple_xy_plot_example.xml +++ b/demoapp/src/main/res/layout/simple_xy_plot_example.xml @@ -18,16 +18,25 @@ + android:layout_width="match_parent" + android:orientation="vertical"> + ap:lineLabelRotationBottom="-45" + android:layout_weight="1"/> + +