Skip to content

Commit 636768a

Browse files
authored
Merge pull request halfhp#68 from halfhp/nick3
1.5.3 Changes
2 parents 55fce04 + 5c4950b commit 636768a

12 files changed

Lines changed: 93 additions & 16 deletions

File tree

.circleci/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ jobs:
7979
path: androidplot-core/build/reports/tests/
8080
destination: test_results
8181

82+
- store_artifacts:
83+
path: androidplot-core/build/docs/javadoc
84+
destination: javadoc
85+
8286
- store_test_results:
8387
path: androidplot-core/build/test-results/
8488

androidplot-core/src/main/java/com/androidplot/xy/CatmullRomInterpolator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import java.util.List;
2121

2222
/**
23-
* A primitive implementation of Catmull-Rom interpolation, based on the information found at:
23+
* An implementation of Catmull-Rom interpolation, based on the information found at:
2424
* http://stackoverflow.com/questions/9489736/catmull-rom-curve-with-no-cusps-and-no-self-intersections/19283471#19283471
2525
*/
2626
public class CatmullRomInterpolator implements Interpolator<CatmullRomInterpolator.Params> {
@@ -196,7 +196,7 @@ public List<XYCoords> interpolate(XYSeries series, Params params) {
196196
* @return the list of coordinates that define the CatmullRom curve
197197
* between the points defined by index+1 and index+2.
198198
*/
199-
public List<XYCoords> interpolate(XYSeries series, int index, Params params) {
199+
protected List<XYCoords> interpolate(XYSeries series, int index, Params params) {
200200
List<XYCoords> result = new ArrayList<>();
201201
double[] x = new double[4];
202202
double[] y = new double[4];
@@ -251,7 +251,7 @@ public List<XYCoords> interpolate(XYSeries series, int index, Params params) {
251251
* position between p1 and p2 to interpolate the value.
252252
* @return
253253
*/
254-
public static double interpolate(double[] p, double[] time, double t) {
254+
protected static double interpolate(double[] p, double[] time, double t) {
255255
double L01 = p[0] * (time[1] - t) / (time[1] - time[0]) + p[1] * (t - time[0]) / (time[1] - time[0]);
256256
double L12 = p[1] * (time[2] - t) / (time[2] - time[1]) + p[2] * (t - time[1]) / (time[2] - time[1]);
257257
double L23 = p[2] * (time[3] - t) / (time[3] - time[2]) + p[3] * (t - time[2]) / (time[3] - time[2]);

androidplot-core/src/main/res/values/attrs.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ _This documentation is auto generated from [attrs.xml](../androidplot-core/src/m
2222
Attributes are broken down by element followed by either their type or list of accepted values.
2323
Supported Elements:
2424
25-
* [Plot](#Plot)
26-
* [XYPlot](#XYPlot)
27-
* [PieChart](#PieChart)
25+
* [Plot](#plot)
26+
* [XYPlot](#xyplot)
27+
* [PieChart](#piechart)
2828
-->
2929
<!--NODOC to generate from command line use: `./gradlew generateAttrsMarkdown` -->
3030
<resources>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.androidplot.xy;
2+
3+
import org.junit.Test;
4+
5+
import java.util.List;
6+
7+
import static junit.framework.Assert.assertEquals;
8+
import static org.mockito.Mockito.mock;
9+
10+
public class CatmullRomInterpolatorTest {
11+
12+
@Test(expected = IllegalArgumentException.class)
13+
public void interpolate_invalidPointsPerSegment_throwsIllegalArgumentException() {
14+
final XYSeries series = mock(XYSeries.class);
15+
final CatmullRomInterpolator.Params params =
16+
new CatmullRomInterpolator.Params(1, CatmullRomInterpolator.Type.Centripetal);
17+
18+
new CatmullRomInterpolator().interpolate(series, params);
19+
}
20+
21+
@Test(expected = IllegalArgumentException.class)
22+
public void interpolate_twoElementSeries_throwsIllegalArgumentException() {
23+
final XYSeries series = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "test", 1, 2);
24+
final CatmullRomInterpolator.Params params =
25+
new CatmullRomInterpolator.Params(2, CatmullRomInterpolator.Type.Centripetal);
26+
27+
new CatmullRomInterpolator().interpolate(series, params);
28+
}
29+
30+
@Test
31+
public void interpolate_threeElementSeriesAndThreePointsPerSegment_producesFivePoints() {
32+
final XYSeries series = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "test", 1, 2, 3);
33+
final CatmullRomInterpolator.Params params =
34+
new CatmullRomInterpolator.Params(3, CatmullRomInterpolator.Type.Centripetal);
35+
final List<XYCoords> interpolated = new CatmullRomInterpolator().interpolate(series, params);
36+
37+
assertEquals(5, interpolated.size());
38+
39+
// control points should exactly match input:
40+
assertEquals(1, interpolated.get(0).y);
41+
assertEquals(2, interpolated.get(2).y);
42+
assertEquals(3, interpolated.get(4).y);
43+
}
44+
45+
@Test
46+
public void interpolate_threeElementSeriesAndFourPointsPerSegment_producesSavenPoints() {
47+
final XYSeries series = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "test", 1, 2, 3);
48+
final CatmullRomInterpolator.Params params =
49+
new CatmullRomInterpolator.Params(4, CatmullRomInterpolator.Type.Centripetal);
50+
final List<XYCoords> interpolated = new CatmullRomInterpolator().interpolate(series, params);
51+
52+
assertEquals(7, interpolated.size());
53+
54+
// control points should exactly match input:
55+
assertEquals(1, interpolated.get(0).y);
56+
assertEquals(2, interpolated.get(3).y);
57+
assertEquals(3, interpolated.get(6).y);
58+
}
59+
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ ext {
2626
theCompileSdkVersion = 26
2727
theTargetSdkVersion = 26
2828
theMinSdkVersion = 5
29-
theVersionName = '1.5.2'
29+
theVersionName = '1.5.3'
3030
theVersionCode = 0
3131
}
3232

demoapp/src/main/java/com/androidplot/demos/widget/DemoAppWidgetProvider.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import android.widget.RemoteViews;
2626
import com.androidplot.demos.R;
2727
import com.androidplot.ui.*;
28+
import com.androidplot.util.PixelUtils;
29+
import com.androidplot.xy.XYGraphWidget;
2830
import com.androidplot.xy.XYSeries;
2931
import com.androidplot.xy.LineAndPointFormatter;
3032
import com.androidplot.xy.SimpleXYSeries;
@@ -43,10 +45,6 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a
4345

4446
plot.getGraph().setMargins(0, 0, 0 , 0);
4547
plot.getGraph().setPadding(0, 0, 0, 0);
46-
// plot.getGraphWidget().getDomainLineLabelPaint().setTextSize(PixelUtils.spToPix(10));
47-
// plot.getGraphWidget().getRangeLineLabelPaint().setTextSize(PixelUtils.spToPix(10));
48-
// plot.getGraphWidget().getDomainOriginLineLabelPaint().setTextSize(PixelUtils.spToPix(10));
49-
// plot.getGraphWidget().getRangeOriginLineLabelPaint().setTextSize(PixelUtils.spToPix(10));
5048

5149
plot.getGraph().position(0, HorizontalPositioning.ABSOLUTE_FROM_LEFT, 0,
5250
VerticalPositioning.ABSOLUTE_FROM_TOP, Anchor.LEFT_TOP);
@@ -55,6 +53,15 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a
5553

5654
plot.getLayoutManager().moveToTop(plot.getTitle());
5755

56+
plot.getGraph().setLineLabelEdges(XYGraphWidget.Edge.LEFT, XYGraphWidget.Edge.BOTTOM);
57+
plot.getGraph().getLineLabelInsets().setLeft(PixelUtils.dpToPix(16));
58+
plot.getGraph().getLineLabelInsets().setBottom(PixelUtils.dpToPix(4));
59+
plot.getGraph().getLineLabelStyle(XYGraphWidget.Edge.LEFT).getPaint().setColor(Color.RED);
60+
plot.getGraph().getGridInsets().setTop(PixelUtils.dpToPix(12));
61+
plot.getGraph().getGridInsets().setRight(PixelUtils.dpToPix(12));
62+
plot.getGraph().getGridInsets().setLeft(PixelUtils.dpToPix(36));
63+
plot.getGraph().getGridInsets().setBottom(PixelUtils.dpToPix(16));
64+
5865
plot.measure(w, h);
5966
plot.layout(0, 0, w, h);
6067

docs/custom_renderer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class RoundedBarFormatter extends BarFormatter {
1616
{
1717
// for now we'll hardcode some formatting values.
1818
// a real implementation would probably provide a constructor instead
19-
getLinePaint().setColor(Color.WHITE);
19+
getBorderPaint().setColor(Color.WHITE);
2020
getFillPaint().setColor(Color.RED);
2121
}
2222

File renamed without changes.

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Source code examples of the various plot types.
4242
# XML Attributes
4343
A complete list of XML attributes is [available here](attrs.md).
4444
# Javadoc
45-
The latest Javadocs are [available here](https://circleci.com/api/v1/project/halfhp/androidplot/latest/artifacts/0/$CIRCLE_ARTIFACTS/javadoc/index.html).
45+
The latest Javadocs are [available here](https://javadoc.io/doc/com.androidplot/androidplot-core).
4646

4747
# Release Notes
4848
Full release notes are [available here](release_notes.md)

docs/plot_composition.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ plot.getGraph().setSize(new Size(
247247
Every widget has a margin, padding and an optional border that can be drawn around it. These params behave
248248
very similarly to those defined in the [CSS Box Model](http://www.w3schools.com/css/css_boxmodel.asp).
249249

250-
## Markup Mode.
250+
## Markup Mode
251251
If you're having trouble visualizing the effects of tweaking margins and padding, you can enable
252252
markup mode which will highlight these spaces on each widget, as well as draw a green line around it's
253253
absolute border.
@@ -281,7 +281,7 @@ text style, etc. to apply while drawing.
281281
## Renderers
282282
The Renderer is what renders Series data onto a Plot. Users can provide their own custom rendering behavior
283283
by writing their own Renderer implementation along with a custom Formatter telling Androidplot about the
284-
Renderer via the `Formatter.getRendererClass()` method.
284+
Renderer via the `Formatter.getRendererClass()` method. See [Custom Renderer](custom_rnderer.md) documentation.
285285

286286
# XML Styling
287287
Androidplot supports an increasing number of XML attributes. The two best resources for learning about

0 commit comments

Comments
 (0)