├── .github ├── ISSUE_TEMPLATE.md └── workflows │ └── build.yml ├── .gitignore ├── .idea └── copyright │ └── profiles_settings.xml ├── LICENSE.md ├── README.md ├── _config.yml ├── androidplot-core ├── build.gradle └── src │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── androidplot │ │ │ ├── LineLabelFormatter.java │ │ │ ├── Plot.java │ │ │ ├── PlotListener.java │ │ │ ├── Region.java │ │ │ ├── Series.java │ │ │ ├── SeriesRegistry.java │ │ │ ├── SimpleLineLabelFormatter.java │ │ │ ├── pie │ │ │ ├── PieChart.java │ │ │ ├── PieLegendItem.java │ │ │ ├── PieLegendWidget.java │ │ │ ├── PieRenderer.java │ │ │ ├── PieWidget.java │ │ │ ├── Segment.java │ │ │ ├── SegmentBundle.java │ │ │ ├── SegmentFormatter.java │ │ │ └── SegmentRegistry.java │ │ │ ├── ui │ │ │ ├── Anchor.java │ │ │ ├── BoxModel.java │ │ │ ├── BoxModelable.java │ │ │ ├── DynamicTableModel.java │ │ │ ├── FixedTableModel.java │ │ │ ├── Formatter.java │ │ │ ├── HorizontalPosition.java │ │ │ ├── HorizontalPositioning.java │ │ │ ├── Insets.java │ │ │ ├── LayoutManager.java │ │ │ ├── LayoutMetric.java │ │ │ ├── PositionMetric.java │ │ │ ├── PositionMetrics.java │ │ │ ├── RenderBundle.java │ │ │ ├── RenderStack.java │ │ │ ├── Resizable.java │ │ │ ├── SeriesBundle.java │ │ │ ├── SeriesRenderer.java │ │ │ ├── Size.java │ │ │ ├── SizeMetric.java │ │ │ ├── SizeMode.java │ │ │ ├── TableModel.java │ │ │ ├── TableOrder.java │ │ │ ├── TableSizingMethod.java │ │ │ ├── TextOrientation.java │ │ │ ├── VerticalPosition.java │ │ │ ├── VerticalPositioning.java │ │ │ └── widget │ │ │ │ ├── LegendItem.java │ │ │ │ ├── LegendWidget.java │ │ │ │ ├── TextLabelWidget.java │ │ │ │ └── Widget.java │ │ │ ├── util │ │ │ ├── APTrace.java │ │ │ ├── AttrUtils.java │ │ │ ├── DisplayDimensions.java │ │ │ ├── FastNumber.java │ │ │ ├── FontUtils.java │ │ │ ├── LayerHash.java │ │ │ ├── LayerListOrganizer.java │ │ │ ├── Layerable.java │ │ │ ├── LinkedLayerList.java │ │ │ ├── Mapping.java │ │ │ ├── PixelUtils.java │ │ │ ├── PlotStatistics.java │ │ │ ├── RectFUtils.java │ │ │ ├── Redrawer.java │ │ │ └── SeriesUtils.java │ │ │ └── xy │ │ │ ├── AdvancedLineAndPointRenderer.java │ │ │ ├── Axis.java │ │ │ ├── BarFormatter.java │ │ │ ├── BarRenderer.java │ │ │ ├── BoundaryMode.java │ │ │ ├── BubbleFormatter.java │ │ │ ├── BubbleRenderer.java │ │ │ ├── BubbleSeries.java │ │ │ ├── CandlestickFormatter.java │ │ │ ├── CandlestickMaker.java │ │ │ ├── CandlestickRenderer.java │ │ │ ├── CandlestickSeries.java │ │ │ ├── CatmullRomInterpolator.java │ │ │ ├── EditableXYSeries.java │ │ │ ├── Estimator.java │ │ │ ├── FastLineAndPointRenderer.java │ │ │ ├── FastXYSeries.java │ │ │ ├── FillDirection.java │ │ │ ├── FixedSizeEditableXYSeries.java │ │ │ ├── GroupRenderer.java │ │ │ ├── InterpolationParams.java │ │ │ ├── Interpolator.java │ │ │ ├── LTTBSampler.java │ │ │ ├── LineAndPointFormatter.java │ │ │ ├── LineAndPointRenderer.java │ │ │ ├── NormedXYSeries.java │ │ │ ├── OrderedXYSeries.java │ │ │ ├── PanZoom.java │ │ │ ├── PointLabelFormatter.java │ │ │ ├── PointLabeler.java │ │ │ ├── RectRegion.java │ │ │ ├── SampledXYSeries.java │ │ │ ├── Sampler.java │ │ │ ├── ScalingXYSeries.java │ │ │ ├── SimpleXYSeries.java │ │ │ ├── Step.java │ │ │ ├── StepFormatter.java │ │ │ ├── StepMode.java │ │ │ ├── StepModel.java │ │ │ ├── StepModelFit.java │ │ │ ├── StepRenderer.java │ │ │ ├── ValueMarker.java │ │ │ ├── XValueMarker.java │ │ │ ├── XYConstraints.java │ │ │ ├── XYCoords.java │ │ │ ├── XYFramingModel.java │ │ │ ├── XYGraphWidget.java │ │ │ ├── XYLegendItem.java │ │ │ ├── XYLegendWidget.java │ │ │ ├── XYPlot.java │ │ │ ├── XYRegionFormatter.java │ │ │ ├── XYSeries.java │ │ │ ├── XYSeriesBundle.java │ │ │ ├── XYSeriesFormatter.java │ │ │ ├── XYSeriesRegistry.java │ │ │ ├── XYSeriesRenderer.java │ │ │ ├── XYStepCalculator.java │ │ │ ├── YValueMarker.java │ │ │ ├── ZoomEstimator.java │ │ │ └── package-info.java │ └── res │ │ └── values │ │ ├── attrs.xml │ │ ├── color.xml │ │ └── style.xml │ └── test │ └── java │ └── com │ └── androidplot │ ├── PlotTest.java │ ├── RegionTest.java │ ├── SeriesRegistryTest.java │ ├── pie │ └── PieRendererTest.java │ ├── test │ ├── AndroidplotTest.java │ ├── MyTestRunner.java │ └── TestUtils.java │ ├── ui │ ├── DynamicTableModelTest.java │ ├── FixedTableModelTest.java │ ├── RenderStackTest.java │ └── widget │ │ ├── TextLabelWidgetTest.java │ │ └── WidgetTest.java │ ├── util │ ├── FastNumberTest.java │ ├── InstrumentedXYPlot.java │ ├── LayerHashTest.java │ ├── LinkedLayerListOrganizerTest.java │ ├── PixelUtilsTest.java │ ├── PlotStatisticsTest.java │ └── SeriesUtilsTest.java │ └── xy │ ├── AdvanceLineAndPointRendererTest.java │ ├── BarRendererTest.java │ ├── BubbleRendererTest.java │ ├── CandlestickRendererTest.java │ ├── CandlestickSeriesTest.java │ ├── CatmullRomInterpolatorTest.java │ ├── FastLineAndPointRendererTest.java │ ├── LTTBSamplerTest.java │ ├── LineAndPointRendererTest.java │ ├── NormedXYSeriesTest.java │ ├── PanZoomTest.java │ ├── RectRegionTest.java │ ├── SampledXYSeriesTest.java │ ├── ScalingXYSeriesTest.java │ ├── SimpleXYSeriesTest.java │ ├── StepCalculatorTest.java │ ├── StepModelFitTest.java │ ├── XYGraphWidgetTest.java │ ├── XYLegendWidgetTest.java │ ├── XYPlotTest.java │ ├── XYSeriesRendererTest.java │ └── ZoomEstimatorTest.java ├── build.gradle ├── demoapp-wearable ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── androidplot │ │ └── demo │ │ └── wearable │ │ └── MainActivity.java │ └── res │ ├── layout │ └── activity_main.xml │ └── xml │ ├── line_point_formatter_with_labels.xml │ └── line_point_formatter_with_labels_2.xml ├── demoapp ├── build.gradle ├── proguard-project.txt ├── project.properties └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── androidplot │ │ └── demos │ │ ├── AnimatedXYPlotActivity.java │ │ ├── BarPlotExampleActivity.java │ │ ├── BubbleChartActivity.java │ │ ├── CandlestickChartActivity.java │ │ ├── DemoApplication.java │ │ ├── DualScaleActivity.java │ │ ├── DynamicXYPlotActivity.java │ │ ├── ECGExample.java │ │ ├── FXPlotExampleActivity.java │ │ ├── ListViewActivity.java │ │ ├── MainActivity.kt │ │ ├── OrientationSensorExampleActivity.java │ │ ├── RecyclerViewActivity.kt │ │ ├── ScatterPlotActivity.java │ │ ├── SimplePieChartActivity.java │ │ ├── SimpleXYPlotActivity.java │ │ ├── StepChartExampleActivity.java │ │ ├── TimeSeriesActivity.java │ │ ├── TouchZoomExampleActivity.java │ │ ├── Util.java │ │ ├── XYPlotWithBgImgActivity.java │ │ ├── XYRegionExampleActivity.java │ │ └── widget │ │ └── DemoAppWidgetProvider.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ ├── drawable-xxxhdpi │ └── ic_launcher.png │ ├── drawable │ ├── graph_background.png │ └── ic_launcher.png │ ├── layout │ ├── bar_plot_example.xml │ ├── bubble_chart_example.xml │ ├── candlestick_example.xml │ ├── demo_app_widget.xml │ ├── dual_scale_example.xml │ ├── dynamic_xyplot_example.xml │ ├── ecg_example.xml │ ├── fx_plot_example.xml │ ├── listview_example.xml │ ├── listview_example_item.xml │ ├── main.xml │ ├── orientation_sensor_example.xml │ ├── pie_chart.xml │ ├── recyclerview_example.xml │ ├── recyclerview_example_item.xml │ ├── scatter_plot_example.xml │ ├── simple_xy_plot_example.xml │ ├── spinner_item.xml │ ├── step_chart_example.xml │ ├── time_series_example.xml │ ├── touch_zoom_example.xml │ ├── xy_plot_with_bq_img_example.xml │ └── xyregion_example.xml │ ├── values-hdpi │ └── dimens.xml │ ├── values │ ├── dimens.xml │ └── strings.xml │ └── xml │ ├── bubble_formatter1.xml │ ├── bubble_formatter2.xml │ ├── bubble_formatter3.xml │ ├── candlestick_formatter.xml │ ├── demo_app_widget_provider_info.xml │ ├── line_point_formatter.xml │ ├── line_point_formatter_with_labels.xml │ ├── line_point_formatter_with_labels_2.xml │ ├── pie_segment_formatter1.xml │ ├── pie_segment_formatter2.xml │ ├── pie_segment_formatter3.xml │ ├── pie_segment_formatter4.xml │ ├── point_formatter.xml │ └── point_formatter_2.xml ├── docs ├── advanced_xy_plot.md ├── attrs.md ├── barchart.md ├── bubblechart.md ├── candlestick.md ├── contributing.md ├── custom_renderer.md ├── dynamicdata.md ├── grouprenderer.md ├── images │ ├── aplogo.png │ ├── aplogo_small.png │ ├── bargroup_overlaid.png │ ├── bargroup_side_by_side.png │ ├── bargroup_spacing.png │ ├── bargroup_stacked.png │ ├── bubble_chart.png │ ├── markup_mode.jpg │ ├── pie_donut_size.png │ ├── pie_extent.png │ ├── pie_inner_inset.png │ ├── pie_offset.png │ ├── pie_orientation.png │ ├── pie_outer_inset.png │ ├── pie_radial_inset.png │ ├── plot_anatomy.png │ ├── positioning │ │ ├── bottom-right-absolute-with-offset.png │ │ ├── bottom-right-absolute.png │ │ ├── center-absolute.png │ │ └── top-left-absolute.png │ ├── preview.png │ ├── screens │ │ ├── about_screens.md │ │ ├── bar_horiz.png │ │ ├── bar_vert.png │ │ ├── bubble_horiz.png │ │ ├── bubble_vert.png │ │ ├── candlestick_horiz.png │ │ ├── candlestick_vert.png │ │ ├── fx_horiz.png │ │ ├── fx_vert.png │ │ ├── pie_horiz.png │ │ ├── pie_vert.png │ │ ├── rounded_bar_renderer.png │ │ ├── scatter_horiz.png │ │ ├── scatter_vert.png │ │ ├── step_horiz.png │ │ └── step_vert.png │ ├── simple_xy_plot.png │ └── sizing │ │ ├── abs100x-abs100y.png │ │ ├── abs100x-abs150y.png │ │ ├── abs100x-rel1y.png │ │ ├── fil50x-fil50y.png │ │ └── rel075x-abs100y.png ├── index.md ├── legend.md ├── piechart.md ├── plot_composition.md ├── quickstart.md ├── release_notes.md ├── versioning.md └── xyplot.md ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── misc ├── download_google_publisher_json.sh └── inject_circle_build_number.sh └── settings.gradle /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thanks for taking the time to help make Androidplot better! Please note 2 | that issues should be submitted on Github for bugs only. 3 | 4 | How-to questions may be posted under the [Androidplot tag on Stack Overflow](https://stackoverflow.com/questions/tagged/androidplot) 5 | and feature requests etc. may be posted to the [Google Group Forum](https://groups.google.com/forum/#!forum/androidplot). 6 | 7 | When possible, please include the following in your bug report: 8 | 9 | * Description of the problem 10 | * Steps to reproduce the issue 11 | * Version(s) of Androidplot being used 12 | * A stacktrace if the issue is causing a crash 13 | 14 | 15 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build androidplot 2 | on: [push] 3 | jobs: 4 | build-and-test: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - name: Checkout Code 8 | uses: actions/checkout@v3 9 | 10 | - name: Set Up JDK 17 11 | uses: actions/setup-java@v2 12 | with: 13 | distribution: 'adopt' 14 | java-version: '17' 15 | 16 | - name: Build and Test 17 | run: ./gradlew testDebugUnitTest jacocoTestDebugUnitTestReport 18 | 19 | - name: Build Release 20 | env: 21 | ENCODED: ${{ secrets.DEMOAPP_KEYSTORE }} 22 | KEYSTORE: keystore.jks 23 | KEY_ALIAS: Key0 24 | KEYSTORE_PASSWORD: ${{ secrets.DEMOAPP_KEYSTORE_PASSWORD }} 25 | KEY_PASSWORD: ${{ secrets.DEMOAPP_KEY_PASSWORD }} 26 | run: | 27 | echo $ENCODED | base64 -di > "${GITHUB_WORKSPACE}/demoapp/keystore.jks" 28 | ./gradlew assembleRelease 29 | 30 | # TODO: get javadoc working again at some point 31 | # - name: Javadoc 32 | # run: ./gradlew javadoc 33 | 34 | - name: Code Coverage 35 | run: bash <(curl -s https://codecov.io/bash) 36 | 37 | - uses: actions/upload-artifact@v3 38 | with: 39 | name: Core Library 40 | path: androidplot-core/build/outputs/aar/*.aar 41 | retention-days: 30 42 | 43 | - uses: actions/upload-artifact@v3 44 | if: github.ref_name == 'master' 45 | with: 46 | name: Demoapp APK 47 | path: demoapp/build/outputs/apk/release/*.apk 48 | retention-days: 30 49 | 50 | - name: Stage for Maven Central 51 | if: github.ref_name == 'master' 52 | env: 53 | OSSRH_ACTOR: ${{ secrets.OSSRH_ACTOR }} 54 | OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} 55 | SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} 56 | SIGNING_PASSWORD: ${{ secrets.GPG_SIGNING_PASSWORD }} 57 | run: ./gradlew publish -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.ipr 2 | *.iml 3 | .gradle 4 | local.properties 5 | 6 | build 7 | 8 | .metadata 9 | AndroidPlot-Core/target 10 | AndroidPlot-Core/.settings 11 | DemoApp/.settings 12 | DemoApp/bin 13 | DemoApp/gen 14 | DemoApp/target 15 | .idea 16 | **/R.java 17 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-minimal -------------------------------------------------------------------------------- /androidplot-core/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 19 | 20 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/LineLabelFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot; 18 | 19 | import android.graphics.Paint; 20 | 21 | public interface LineLabelFormatter { 22 | 23 | 24 | /** 25 | * 26 | * @param value The value being rendered by this formatter. 27 | * @return Paint instance that should be used to render the specified value. 28 | */ 29 | Paint getPaint(Number value); 30 | } 31 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/PlotListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot; 18 | 19 | import android.graphics.Canvas; 20 | 21 | /** 22 | * Defines methods used for monitoring events generated by a Plot. 23 | */ 24 | public interface PlotListener { 25 | 26 | /** 27 | * Fired immediately before the Plot "source" is drawn onto canvas. 28 | * Commonly used by implementing Series instances to activate a read 29 | * lock on it's self in preparation for the Plot's imminent reading 30 | * of that series. 31 | * @param source 32 | * @param canvas 33 | */ 34 | void onBeforeDraw(Plot source, Canvas canvas); 35 | 36 | /** 37 | * Fired immediately after the Plot "source" is drawn onto canvas. 38 | * Just as onBeforeDraw(...) is commonly used by Series implementations 39 | * to activate a read lock, this method is commonly used to release that 40 | * same lock. 41 | * @param source 42 | * @param canvas 43 | */ 44 | void onAfterDraw(Plot source, Canvas canvas); 45 | } 46 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/Series.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot; 18 | 19 | /** 20 | * Base interface for all Series implementations 21 | */ 22 | public interface Series { 23 | 24 | /** 25 | * 26 | * @return The title of this Series. 27 | */ 28 | String getTitle(); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/SimpleLineLabelFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot; 18 | 19 | import android.graphics.Color; 20 | import android.graphics.Paint; 21 | import com.androidplot.util.PixelUtils; 22 | 23 | /** 24 | * A basic implementation of a {@link LineLabelFormatter}. 25 | */ 26 | public class SimpleLineLabelFormatter implements LineLabelFormatter { 27 | 28 | private static final int DEFAULT_TEXT_SIZE_SP = 12; 29 | private static final int DEFAULT_STROKE_SIZE_DP = 2; 30 | private Paint paint; 31 | 32 | public SimpleLineLabelFormatter() { 33 | this(new Paint()); 34 | getPaint().setColor(Color.WHITE); 35 | getPaint().setTextSize(PixelUtils.spToPix(DEFAULT_TEXT_SIZE_SP)); 36 | getPaint().setStrokeWidth(PixelUtils.dpToPix(DEFAULT_STROKE_SIZE_DP)); 37 | } 38 | 39 | public SimpleLineLabelFormatter(int color) { 40 | this(); 41 | getPaint().setColor(color); 42 | } 43 | 44 | public SimpleLineLabelFormatter(Paint paint) { 45 | this.paint = paint; 46 | } 47 | 48 | public Paint getPaint() { 49 | return paint; 50 | } 51 | 52 | public void setPaint(Paint paint) { 53 | this.paint = paint; 54 | } 55 | 56 | @Override 57 | public Paint getPaint(Number value) { 58 | return getPaint(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/pie/PieLegendItem.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.pie; 2 | 3 | 4 | import androidx.annotation.NonNull; 5 | 6 | import com.androidplot.ui.widget.LegendItem; 7 | 8 | /** 9 | * An item in a {@link PieLegendWidget} corresponding to a {@link Segment} in a {@link PieChart}. 10 | */ 11 | public class PieLegendItem implements LegendItem { 12 | 13 | public SegmentFormatter formatter; 14 | 15 | public Segment segment; 16 | 17 | public PieLegendItem(@NonNull Segment segment, @NonNull SegmentFormatter formatter) { 18 | this.segment = segment; 19 | this.formatter = formatter; 20 | } 21 | 22 | @Override 23 | public String getTitle() { 24 | return segment.getTitle(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/pie/PieLegendWidget.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.pie; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.RectF; 5 | import androidx.annotation.NonNull; 6 | 7 | import com.androidplot.ui.LayoutManager; 8 | import com.androidplot.ui.SeriesBundle; 9 | import com.androidplot.ui.Size; 10 | import com.androidplot.ui.TableModel; 11 | import com.androidplot.ui.widget.LegendWidget; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | public class PieLegendWidget extends LegendWidget { 17 | 18 | private PieChart pieChart; 19 | 20 | public PieLegendWidget(LayoutManager layoutManager, PieChart pieChart, 21 | Size widgetSize, 22 | TableModel tableModel, 23 | Size iconSize) { 24 | super(tableModel, layoutManager, widgetSize, iconSize); 25 | this.pieChart = pieChart; 26 | } 27 | 28 | @Override 29 | protected void drawIcon(@NonNull Canvas canvas, @NonNull RectF iconRect, @NonNull PieLegendItem item) { 30 | canvas.drawRect(iconRect, item.formatter.getFillPaint()); 31 | } 32 | 33 | @Override 34 | protected List getLegendItems() { 35 | final List legendItems = new ArrayList<>(); 36 | for(SeriesBundle item : pieChart.getRegistry().getLegendEnabledItems()) { 37 | legendItems.add(new PieLegendItem(item.getSeries(), item.getFormatter())); 38 | } 39 | return legendItems; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/pie/PieWidget.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.pie; 18 | 19 | import android.graphics.*; 20 | import com.androidplot.ui.LayoutManager; 21 | import com.androidplot.ui.Size; 22 | import com.androidplot.ui.widget.Widget; 23 | import com.androidplot.ui.RenderStack; 24 | 25 | /** 26 | * Visualizes data as a pie chart. 27 | */ 28 | public class PieWidget extends Widget { 29 | 30 | private PieChart pieChart; 31 | private RenderStack renderStack; 32 | 33 | public PieWidget(LayoutManager layoutManager, PieChart pieChart, Size metrics) { 34 | super(layoutManager, metrics); 35 | this.pieChart = pieChart; 36 | renderStack = new RenderStack(pieChart); 37 | } 38 | 39 | @Override 40 | protected void doOnDraw(Canvas canvas, RectF widgetRect) { 41 | renderStack.sync(); 42 | for(RenderStack.StackElement thisElement : renderStack.getElements()) { 43 | if(thisElement.isEnabled()) { 44 | pieChart.getRenderer(thisElement.get().getFormatter().getRendererClass()). 45 | render(canvas, widgetRect, thisElement.get(), renderStack); 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/pie/Segment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.pie; 18 | 19 | import com.androidplot.Series; 20 | 21 | /** 22 | * An implementation of Series representing a segment in a pie chart. 23 | */ 24 | public class Segment implements Series { 25 | 26 | private String title; 27 | 28 | private Number value; 29 | 30 | public Segment(String title, Number value) { 31 | this.title = title; 32 | this.setValue(value); 33 | } 34 | 35 | @Override 36 | public String getTitle() { 37 | return title; 38 | } 39 | 40 | public void setTitle(String title) { 41 | this.title = title; 42 | } 43 | 44 | public Number getValue() { 45 | return value; 46 | } 47 | 48 | public void setValue(Number value) { 49 | this.value = value; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/pie/SegmentBundle.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.pie; 2 | 3 | import com.androidplot.ui.*; 4 | 5 | /** 6 | * Manages the association between a given {@link Segment} and the {@link SegmentFormatter} that 7 | * will be used to render it. 8 | */ 9 | public class SegmentBundle extends SeriesBundle { 10 | 11 | public SegmentBundle(Segment series, SegmentFormatter formatter) { 12 | super(series, formatter); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/pie/SegmentRegistry.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.pie; 2 | 3 | import com.androidplot.*; 4 | 5 | /** 6 | * SeriesRegistry implementation to be used in a {@link PieChart}. 7 | */ 8 | public class SegmentRegistry extends SeriesRegistry { 9 | 10 | @Override 11 | protected SegmentBundle newSeriesBundle(Segment series, SegmentFormatter formatter) { 12 | return new SegmentBundle(series, formatter); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/ui/Anchor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.ui; 18 | 19 | /** 20 | * Enumeration of possible anchor positions that a {@link com.androidplot.ui.widget.Widget} can use. There are a total 21 | * 8 possible anchor positions representing each corner of the Widget and the point exactly between each corner. 22 | */ 23 | public enum Anchor { 24 | TOP_MIDDLE, 25 | LEFT_TOP, // default 26 | LEFT_MIDDLE, 27 | LEFT_BOTTOM, 28 | RIGHT_TOP, 29 | RIGHT_MIDDLE, 30 | RIGHT_BOTTOM, 31 | BOTTOM_MIDDLE, 32 | CENTER 33 | } 34 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/ui/BoxModelable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.ui; 18 | 19 | import android.graphics.RectF; 20 | 21 | /** 22 | * Defines the properties of a BoxModel as used 23 | * by Androidplot. Essentially, the BoxModel composes three nested (but not necessarily concentric) rectangles: 24 | * * The bounding box, which is the outer-most box. 25 | * * The marginated box, which is calculated by applying the margin insets to the bounding box. 26 | * * The padded box, which is calculated by applying the padding insets to the marginated box. 27 | */ 28 | public interface BoxModelable { 29 | /** 30 | * Returns a RectF instance describing the inner edge of the margin layer. 31 | * @param boundsRect 32 | * @return 33 | */ 34 | RectF getMarginatedRect(RectF boundsRect); 35 | 36 | /** 37 | * Returns a RectF instance describing the inner edge of the padding layer. 38 | * @param marginRect 39 | * @return 40 | */ 41 | RectF getPaddedRect(RectF marginRect); 42 | 43 | 44 | void setMargins(float left, float top, float right, float bottom); 45 | 46 | void setPadding(float left, float top, float right, float bottom); 47 | 48 | float getMarginLeft(); 49 | 50 | void setMarginLeft(float marginLeft); 51 | 52 | float getMarginTop(); 53 | 54 | void setMarginTop(float marginTop); 55 | 56 | float getMarginRight(); 57 | 58 | void setMarginRight(float marginRight); 59 | 60 | float getMarginBottom(); 61 | 62 | void setMarginBottom(float marginBottm); 63 | 64 | float getPaddingLeft(); 65 | 66 | void setPaddingLeft(float paddingLeft); 67 | 68 | float getPaddingTop(); 69 | 70 | void setPaddingTop(float paddingTop); 71 | 72 | float getPaddingRight(); 73 | 74 | void setPaddingRight(float paddingRight); 75 | 76 | float getPaddingBottom(); 77 | 78 | void setPaddingBottom(float paddingBottom); 79 | } 80 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/ui/HorizontalPositioning.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.ui; 18 | 19 | public enum HorizontalPositioning { 20 | ABSOLUTE_FROM_LEFT, 21 | ABSOLUTE_FROM_RIGHT, 22 | ABSOLUTE_FROM_CENTER, 23 | RELATIVE_TO_LEFT, 24 | RELATIVE_TO_RIGHT, 25 | RELATIVE_TO_CENTER 26 | 27 | } 28 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/ui/Insets.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.ui; 18 | 19 | /** 20 | * A set of insets for a rect space. 21 | */ 22 | public class Insets { 23 | 24 | private float top; 25 | private float bottom; 26 | private float left; 27 | private float right; 28 | 29 | public Insets() {} 30 | 31 | public Insets(float top, float bottom, float left, float right) { 32 | this.top = top; 33 | this.bottom = bottom; 34 | this.left = left; 35 | this.right = right; 36 | } 37 | 38 | public float getTop() { 39 | return top; 40 | } 41 | 42 | public void setTop(float top) { 43 | this.top = top; 44 | } 45 | 46 | public float getBottom() { 47 | return bottom; 48 | } 49 | 50 | public void setBottom(float bottom) { 51 | this.bottom = bottom; 52 | } 53 | 54 | public float getLeft() { 55 | return left; 56 | } 57 | 58 | public void setLeft(float left) { 59 | this.left = left; 60 | } 61 | 62 | public float getRight() { 63 | return right; 64 | } 65 | 66 | public void setRight(float right) { 67 | this.right = right; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/ui/LayoutMetric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.ui; 18 | 19 | 20 | 21 | abstract class LayoutMetric { 22 | 23 | private LayoutType layoutType; 24 | 25 | //private LayoutType layoutType; 26 | private float value; 27 | //private float lastRow; 28 | 29 | public LayoutMetric(float value, LayoutType layoutType) { 30 | validatePair(value, layoutType); 31 | set(value, layoutType); 32 | //setLayoutType(layoutType); 33 | //setValue(value); 34 | //setLayoutType(layoutType); 35 | } 36 | 37 | /** 38 | * Verifies that the values passed in are valid for the layout algorithm being used. 39 | * @param value 40 | * @param layoutType 41 | */ 42 | protected abstract void validatePair(float value, LayoutType layoutType); 43 | 44 | public void set(float value, LayoutType layoutType) { 45 | validatePair(value, layoutType); 46 | this.value = value; 47 | this.layoutType = layoutType; 48 | } 49 | 50 | public float getValue() { 51 | return value; 52 | } 53 | 54 | public void setValue(float value) { 55 | validatePair(value, layoutType); 56 | this.value = value; 57 | } 58 | 59 | public abstract float getPixelValue(float size); 60 | 61 | public LayoutType getLayoutType() { 62 | return layoutType; 63 | } 64 | 65 | public void setLayoutType(LayoutType layoutType) { 66 | validatePair(value, layoutType); 67 | this.layoutType = layoutType; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/ui/PositionMetrics.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.ui; 18 | 19 | import androidx.annotation.NonNull; 20 | 21 | public class PositionMetrics implements Comparable { 22 | 23 | private HorizontalPosition horizontalPosition; 24 | private VerticalPosition verticalPosition; 25 | private Anchor anchor; 26 | private float layerDepth; 27 | 28 | public PositionMetrics(float x, HorizontalPositioning horizontalPositioning, float y, VerticalPositioning verticalPositioning, Anchor anchor) { 29 | setXPositionMetric(new HorizontalPosition(x, horizontalPositioning)); 30 | setYPositionMetric(new VerticalPosition(y, verticalPositioning)); 31 | setAnchor(anchor); 32 | 33 | } 34 | 35 | public VerticalPosition getYPositionMetric() { 36 | return verticalPosition; 37 | } 38 | 39 | public void setYPositionMetric(VerticalPosition verticalPosition) { 40 | this.verticalPosition = verticalPosition; 41 | } 42 | 43 | public Anchor getAnchor() { 44 | return anchor; 45 | } 46 | 47 | public void setAnchor(Anchor anchor) { 48 | this.anchor = anchor; 49 | } 50 | 51 | @Override 52 | public int compareTo(@NonNull PositionMetrics o) { 53 | if(this.layerDepth < o.layerDepth) { 54 | return -1; 55 | } else if(this.layerDepth == o.layerDepth) { 56 | return 0; 57 | } else { 58 | return 1; 59 | } 60 | } 61 | 62 | public HorizontalPosition getXPositionMetric() { 63 | return horizontalPosition; 64 | } 65 | 66 | public void setXPositionMetric(HorizontalPosition horizontalPosition) { 67 | this.horizontalPosition = horizontalPosition; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/ui/RenderBundle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.ui; 18 | 19 | import com.androidplot.Series; 20 | import com.androidplot.xy.XYSeriesFormatter; 21 | 22 | public abstract class RenderBundle { 23 | //private XYDataset series; 24 | private Series series; 25 | private SeriesFormatterType formatter; 26 | 27 | public RenderBundle(SeriesType series, SeriesFormatterType formatter) { 28 | this.formatter = formatter; 29 | this.series = series; 30 | } 31 | 32 | public Series getSeries() { 33 | return series; 34 | } 35 | 36 | public void setSeries(Series series) { 37 | this.series = series; 38 | } 39 | 40 | public SeriesFormatterType getFormatter() { 41 | return formatter; 42 | } 43 | 44 | public void setFormatter(SeriesFormatterType formatter) { 45 | this.formatter = formatter; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/ui/Resizable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.ui; 18 | 19 | import com.androidplot.util.DisplayDimensions; 20 | 21 | /** 22 | * Used by classes that depend on dimensional values to lay themselves out and draw. 23 | * Consideration should be given to synchronizing with any draw routines that also 24 | * exist within the class. 25 | */ 26 | public interface Resizable { 27 | 28 | /** 29 | * Called when a change to the class' dimensions is made. This method is responsible 30 | * for cascading calls to update for any logical children of this class, for example 31 | * the Plot class is responsible for updating the LayoutManager. Note that while dims 32 | * is marked final in this interface, the compiler will not enforce it. Implementors of 33 | * this method should take care not to make changes to dims as this will affect parent 34 | * Resizables in likely undesired ways. 35 | * @param dims 36 | */ 37 | void layout(final DisplayDimensions dims); 38 | } 39 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/ui/SeriesBundle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.ui; 18 | 19 | import com.androidplot.Series; 20 | 21 | /** 22 | * Defines a relationship between a Series instance and other elements needed to unique render that instance 23 | * such as a Formatter etc. 24 | */ 25 | public class SeriesBundle { 26 | 27 | private final SeriesType series; 28 | private final FormatterType formatter; 29 | 30 | public SeriesBundle(SeriesType series, FormatterType formatter) { 31 | this.series = series; 32 | this.formatter = formatter; 33 | } 34 | 35 | public SeriesType getSeries() { 36 | return series; 37 | } 38 | 39 | public FormatterType getFormatter() { 40 | return formatter; 41 | } 42 | 43 | public boolean rendersWith(SeriesRenderer renderer) { 44 | return getFormatter().getRendererClass() == renderer.getClass(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/ui/SizeMetric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.ui; 18 | 19 | /** 20 | * Encapsulates a sizing algorithm and an associated value. 21 | * 22 | * The available algorithms list are stored in the {@link SizeMode} enumeration. 23 | * 24 | */ 25 | public class SizeMetric extends LayoutMetric { 26 | 27 | public SizeMetric(float value, SizeMode layoutType) { 28 | super(value, layoutType); 29 | } 30 | 31 | protected void validatePair(float value, SizeMode layoutType) { 32 | switch(layoutType) { 33 | case RELATIVE: 34 | if(value < 0 || value > 1) { 35 | throw new IllegalArgumentException("SizeMetric Relative and Hybrid layout values must be within the range of 0 to 1."); 36 | } 37 | case ABSOLUTE: 38 | case FILL: 39 | default: 40 | break; 41 | } 42 | } 43 | 44 | @Override 45 | public float getPixelValue(float size) { 46 | switch(getLayoutType()) { 47 | case ABSOLUTE: 48 | return getValue(); 49 | case RELATIVE: 50 | return getValue() * size; 51 | case FILL: 52 | return size - getValue(); 53 | default: 54 | throw new IllegalArgumentException("Unsupported LayoutType: " + this.getLayoutType()); 55 | } 56 | } 57 | 58 | @Override 59 | public void setLayoutType(SizeMode layoutType) { 60 | super.setLayoutType(layoutType); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/ui/SizeMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.ui; 18 | 19 | /** 20 | * Algorithms available for calculating an arbitrary dimension of a widget. 21 | * Each algorithm also takes a single value called "val" in this doc. 22 | * ABSOLUTE - Val is treated as absolute. If val is 5 then the size of the widget along the associated axis is 5 pixels. 23 | * 24 | * RELATIVE - Val represents the percentage of the display that the widget should fill along the associated axis. For example, 25 | * if the total size of the owning plot is 120 pixels and val is set to 50 then the size of the widget along the associated axis 26 | * is 60; 50% of 120 = 60. 27 | * 28 | * FILL - Widget completely fills along the associated axis, minus the input size value 29 | */ 30 | public enum SizeMode { 31 | ABSOLUTE, 32 | RELATIVE, 33 | FILL 34 | } -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/ui/TableModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.ui; 18 | 19 | import android.graphics.RectF; 20 | 21 | import java.util.Iterator; 22 | 23 | public abstract class TableModel { 24 | private TableOrder order; 25 | 26 | protected TableModel(TableOrder order) { 27 | setOrder(order); 28 | } 29 | 30 | public abstract Iterator getIterator(RectF tableRect, int totalElements); 31 | 32 | //public abstract RectF getCellRect(RectF tableRect, int numElements); 33 | 34 | public TableOrder getOrder() { 35 | return order; 36 | } 37 | 38 | public void setOrder(TableOrder order) { 39 | this.order = order; 40 | } 41 | 42 | public enum Axis { 43 | ROW, 44 | COLUMN 45 | } 46 | 47 | public enum CellSizingMethod { 48 | FIXED, 49 | FILL 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/ui/TableOrder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.ui; 18 | 19 | public enum TableOrder { 20 | ROW_MAJOR, // standard c-style 21 | COLUMN_MAJOR 22 | } 23 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/ui/TableSizingMethod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.ui; 18 | 19 | /** 20 | * The sizing methods available to a table. 21 | * AUTO: The table is divided evenly int tableSize/numElements sections. 22 | * FIXED: Each element in the table has a predefined number of pixels 23 | * regardless of what the table's dimensions actually are. 24 | */ 25 | public enum TableSizingMethod { 26 | AUTO, 27 | FIXED 28 | } 29 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/ui/TextOrientation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.ui; 18 | 19 | public enum TextOrientation { 20 | HORIZONTAL, 21 | VERTICAL_ASCENDING, 22 | VERTICAL_DESCENDING 23 | } 24 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/ui/VerticalPosition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.ui; 18 | 19 | public class VerticalPosition extends PositionMetric { 20 | 21 | public VerticalPosition(float value, VerticalPositioning layoutStyle) { 22 | super(value, layoutStyle); 23 | } 24 | 25 | /** 26 | * Throws IllegalArgumentException if there is a problem. 27 | * @param value 28 | */ 29 | protected void validatePair(float value, VerticalPositioning layoutStyle) { 30 | switch(layoutStyle) { 31 | case ABSOLUTE_FROM_TOP: 32 | case ABSOLUTE_FROM_BOTTOM: 33 | case ABSOLUTE_FROM_CENTER: 34 | validateValue(value, PositionMetric.LayoutMode.ABSOLUTE); 35 | break; 36 | case RELATIVE_TO_TOP: 37 | case RELATIVE_TO_BOTTOM: 38 | case RELATIVE_TO_CENTER: 39 | validateValue(value, PositionMetric.LayoutMode.RELATIVE); 40 | } 41 | } 42 | 43 | @Override 44 | public float getPixelValue(float size) { 45 | switch(getLayoutType()) { 46 | case ABSOLUTE_FROM_TOP: 47 | return this.getAbsolutePosition(size, PositionMetric.Origin.FROM_BEGINING); 48 | case ABSOLUTE_FROM_BOTTOM: 49 | return this.getAbsolutePosition(size, PositionMetric.Origin.FROM_END); 50 | case ABSOLUTE_FROM_CENTER: 51 | return this.getAbsolutePosition(size, PositionMetric.Origin.FROM_CENTER); 52 | case RELATIVE_TO_TOP: 53 | return this.getRelativePosition(size, PositionMetric.Origin.FROM_BEGINING); 54 | case RELATIVE_TO_BOTTOM: 55 | return this.getRelativePosition(size, PositionMetric.Origin.FROM_END); 56 | case RELATIVE_TO_CENTER: 57 | return this.getRelativePosition(size, PositionMetric.Origin.FROM_CENTER); 58 | default: 59 | throw new IllegalArgumentException("Unsupported LayoutType: " + this.getLayoutType()); 60 | } 61 | } 62 | 63 | @Override 64 | public void setLayoutType(VerticalPositioning layoutType) { 65 | super.setLayoutType(layoutType); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/ui/VerticalPositioning.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.ui; 18 | 19 | public enum VerticalPositioning { 20 | ABSOLUTE_FROM_TOP, 21 | ABSOLUTE_FROM_BOTTOM, 22 | ABSOLUTE_FROM_CENTER, 23 | RELATIVE_TO_TOP, 24 | RELATIVE_TO_BOTTOM, 25 | RELATIVE_TO_CENTER 26 | } 27 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/ui/widget/LegendItem.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.ui.widget; 2 | 3 | /** 4 | * An item to be displayed by {@link LegendWidget}. 5 | */ 6 | public interface LegendItem { 7 | 8 | /** 9 | * 10 | * @return The user facing label for this item. 11 | */ 12 | String getTitle(); 13 | } 14 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/util/APTrace.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.util; 2 | 3 | import android.os.*; 4 | 5 | /** 6 | * Wraps {@link Trace} to provide API-safe methods as well as an easy target for runtime removal 7 | * via obfuscation. 8 | */ 9 | public abstract class APTrace { 10 | 11 | public static void begin(final String sectionName) { 12 | if(Build.VERSION.SDK_INT >= 18) { 13 | Trace.beginSection(sectionName); 14 | } else { 15 | // TODO: alternate impl? 16 | } 17 | } 18 | 19 | public static void end() { 20 | if(Build.VERSION.SDK_INT >= 18) { 21 | Trace.endSection(); 22 | } else { 23 | // TODO: alternate impl? 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/util/DisplayDimensions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.util; 18 | 19 | import android.graphics.RectF; 20 | 21 | /** 22 | * Convenience class for managing {@link com.androidplot.ui.BoxModel} data 23 | */ 24 | public class DisplayDimensions { 25 | 26 | private static final int ONE = 1; 27 | 28 | public final RectF canvasRect; 29 | public final RectF marginatedRect; 30 | public final RectF paddedRect; 31 | 32 | // init to 1 to avoid potential divide by zero errors (yet to be observed in practice) 33 | private static final RectF initRect; 34 | 35 | static { 36 | initRect = new RectF(ONE, ONE, ONE, ONE); 37 | } 38 | 39 | public DisplayDimensions() { 40 | this(initRect, initRect, initRect); 41 | } 42 | public DisplayDimensions(RectF canvasRect, RectF marginatedRect, RectF paddedRect) { 43 | this.canvasRect = canvasRect; 44 | this.marginatedRect = marginatedRect; 45 | this.paddedRect = paddedRect; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/util/Layerable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.util; 18 | 19 | import java.util.List; 20 | 21 | /** 22 | * Encapsulates the concept of "layerable" objects; Each object is stored above or below each other object and may 23 | * be moved up and down in the queue relative to other elements in the hash or absolutely to the front or back of the queue. 24 | * 25 | * Note that the method names correspond to the order of items drawn directly on top of one another using an iterator; 26 | * the first element drawn (lowest layer) is effectively the "bottom" element. 27 | * @param 28 | */ 29 | public interface Layerable { 30 | 31 | /** 32 | * Move above all other elements 33 | * @param element 34 | * @return 35 | */ 36 | boolean moveToTop(ElementType element); 37 | 38 | 39 | /** 40 | * Move above the specified element 41 | * @param objectToMove 42 | * @param reference 43 | * @return 44 | */ 45 | boolean moveAbove(ElementType objectToMove, ElementType reference); 46 | 47 | 48 | /** 49 | * Move beneath the specified element 50 | * 51 | * @param objectToMove 52 | * @param reference 53 | * @return 54 | */ 55 | boolean moveBeneath(ElementType objectToMove, ElementType reference); 56 | 57 | /** 58 | * Move beneath all other elements 59 | * @param key 60 | * @return 61 | */ 62 | boolean moveToBottom(ElementType key); 63 | 64 | 65 | /** 66 | * Move up by one element 67 | * @param key 68 | * @return 69 | */ 70 | boolean moveUp(ElementType key); 71 | 72 | /** 73 | * Move down by one element 74 | * @param key 75 | * @return 76 | */ 77 | boolean moveDown(ElementType key); 78 | 79 | List elements(); 80 | } -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/util/LinkedLayerList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.util; 18 | 19 | import java.util.LinkedList; 20 | import java.util.List; 21 | 22 | /** 23 | * A implementation of {@link Layerable} backed by a {@link LinkedList}. 24 | * @param 25 | */ 26 | public class LinkedLayerList extends LinkedList implements Layerable { 27 | 28 | private LayerListOrganizer organizer = new LayerListOrganizer<>(this); 29 | 30 | @Override 31 | public boolean moveToTop(Type element) { 32 | return organizer.moveToTop(element); 33 | } 34 | 35 | @Override 36 | public boolean moveAbove(Type objectToMove, Type reference) { 37 | return organizer.moveAbove(objectToMove, reference); 38 | } 39 | 40 | @Override 41 | public boolean moveBeneath(Type objectToMove, Type reference) { 42 | return organizer.moveBeneath(objectToMove, reference); 43 | } 44 | 45 | @Override 46 | public boolean moveToBottom(Type key) { 47 | return organizer.moveToBottom(key); 48 | } 49 | 50 | @Override 51 | public boolean moveUp(Type key) { 52 | return organizer.moveUp(key); 53 | } 54 | 55 | @Override 56 | public boolean moveDown(Type key) { 57 | return organizer.moveDown(key); 58 | } 59 | 60 | @Override 61 | public List elements() { 62 | return organizer.elements(); 63 | } 64 | 65 | public void addToBottom(Type element) { 66 | organizer.addToBottom(element); 67 | } 68 | 69 | public void addToTop(Type element) { 70 | organizer.addToTop(element); 71 | } 72 | 73 | 74 | 75 | } 76 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/util/Mapping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.util; 18 | 19 | /** 20 | * Essentially just a version of the Map interface used to associate 21 | * a key of a given type with a value of a given type, does impose a 1:1 22 | * relationship between keys and values and defines no method for insertion or deletion. 23 | */ 24 | public interface Mapping { 25 | 26 | /** 27 | * @param value 28 | * @return The Key associated with the specified value. 29 | */ 30 | Key get(Value value); 31 | } 32 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/Axis.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | public enum Axis { 20 | DOMAIN, 21 | RANGE 22 | } 23 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/BoundaryMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | public enum BoundaryMode { 20 | FIXED, 21 | AUTO, 22 | GROW, 23 | SHRINK 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/BubbleSeries.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.xy; 2 | 3 | import java.util.*; 4 | 5 | /** 6 | * Created by halfhp on 9/17/16. 7 | */ 8 | public class BubbleSeries implements XYSeries { 9 | 10 | private List xVals; 11 | private List yVals; 12 | private List zVals; 13 | private String title; 14 | 15 | /** 16 | * 17 | * @param interleavedValues Interleaved values ordered as x, y, z; total size must be a multiple of 3. 18 | */ 19 | public BubbleSeries(Number... interleavedValues) { 20 | if(interleavedValues == null || interleavedValues.length % 3 > 0) { 21 | throw new RuntimeException("BubbleSeries interleave array length must be a non-zero multiple of 3."); 22 | } 23 | 24 | xVals = new ArrayList<>(); 25 | yVals = new ArrayList<>(); 26 | zVals = new ArrayList<>(); 27 | for(int i = 0; i < interleavedValues.length; i+=3) { 28 | xVals.add(interleavedValues[i]); 29 | yVals.add(interleavedValues[i+1]); 30 | zVals.add(interleavedValues[i+2]); 31 | } 32 | } 33 | 34 | public BubbleSeries(List yVals, List zVals, String title) { 35 | this.yVals = yVals; 36 | this.zVals = zVals; 37 | this.title = title; 38 | // populate x with iVals: 39 | this.xVals = new ArrayList<>(zVals.size()); 40 | for(int i = 0; i < zVals.size(); i++) { 41 | this.xVals.add(i); 42 | } 43 | } 44 | 45 | public BubbleSeries(List xVals, List yVals, List zVals, String title) { 46 | this.xVals = xVals; 47 | this.yVals = yVals; 48 | this.zVals = zVals; 49 | this.title = title; 50 | } 51 | 52 | @Override 53 | public String getTitle() { 54 | return title; 55 | } 56 | 57 | @Override 58 | public int size() { 59 | return xVals.size(); 60 | } 61 | 62 | @Override 63 | public Number getX(int index) { 64 | return xVals.get(index); 65 | } 66 | 67 | @Override 68 | public Number getY(int index) { 69 | return yVals.get(index); 70 | } 71 | 72 | public Number getZ(int index) { 73 | return zVals.get(index); 74 | } 75 | 76 | public List getZVals() { 77 | return zVals; 78 | } 79 | 80 | 81 | } 82 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/EditableXYSeries.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | /** 20 | * An {@link XYSeries} that exposes methods to set values and resize 21 | */ 22 | public interface EditableXYSeries extends XYSeries { 23 | 24 | void setX(Number x, int index); 25 | void setY(Number y, int index); 26 | 27 | /** 28 | * Resize to accommodate the specified number of x/y pairs. If elements must be droped, those 29 | * at the highest iVal should be removed first. 30 | * @param size 31 | */ 32 | void resize(int size); 33 | } 34 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/Estimator.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.xy; 2 | 3 | /** 4 | * Base for all estimation management schemes. 5 | */ 6 | public abstract class Estimator { 7 | 8 | public abstract void run(XYPlot plot, XYSeriesBundle sf); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/FastXYSeries.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.xy; 2 | 3 | /** 4 | * An implementation of {@link XYSeries} that defines additional methods to speed up rendering by 5 | * giving a hint to the renderer about the min/max values contained in the series. 6 | * 7 | * Note that these hints can only be leveraged if the containing XYPlot's constraints completely 8 | * contain the FastXYSeries min/max values. If this condition is not met then XYPlot falls back 9 | * to manually determining the min/max values of the series that exist within the defined constraints. 10 | */ 11 | public interface FastXYSeries extends XYSeries { 12 | 13 | /** 14 | * TIP: You can use {@link RectRegion#union(Number, Number)} during 15 | * to keep a running tally of min/max values when iterating. 16 | * @return A {@link RectRegion} representing the min/max values that currently exist this series. 17 | */ 18 | RectRegion minMax(); 19 | } 20 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/FillDirection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | /** 20 | * Defines which edge is used to close a fill path for drawing lines. 21 | * 22 | * TOP - Use the top edge of the plot. 23 | * BOTTOM - Use the bottom edge of the plot. 24 | * LEFT - (Not implemented) Use the left edge of the plot. 25 | * RIGHT - (Not implemented) Use the right edge of the plot. 26 | * DOMAIN_ORIGIN - (Not implemented) Use the domain origin line. 27 | * RANGE_ORIGIN - Use the range origin line. 28 | */ 29 | public enum FillDirection { 30 | TOP, 31 | BOTTOM, 32 | LEFT, 33 | RIGHT, 34 | DOMAIN_ORIGIN, 35 | RANGE_ORIGIN 36 | } 37 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/FixedSizeEditableXYSeries.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.xy; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.annotation.Nullable; 5 | 6 | import com.androidplot.util.FastNumber; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * An efficient implementation of {@link EditableXYSeries} intended for use cases where 13 | * the total number of points visible is known ahead of time and is fairly static. 14 | * 15 | * {@link #resize(int)} may be used to resize the series when necessary, however it is a slow 16 | * operation and should be avoided as much as possible. 17 | * 18 | */ 19 | public class FixedSizeEditableXYSeries implements EditableXYSeries { 20 | 21 | @NonNull 22 | private List xVals = new ArrayList<>(); 23 | 24 | @NonNull 25 | private List yVals = new ArrayList<>(); 26 | private String title; 27 | 28 | public FixedSizeEditableXYSeries(String title, int size) { 29 | setTitle(title); 30 | resize(size); 31 | } 32 | 33 | @Override 34 | public void setX(@Nullable Number x, int index) { 35 | xVals.set(index, FastNumber.orNull(x)); 36 | } 37 | 38 | @Override 39 | public void setY(@Nullable Number y, int index) { 40 | yVals.set(index, FastNumber.orNull(y)); 41 | } 42 | 43 | /** 44 | * May be used to dynamically resize the series. This is a relatively slow operation, especially 45 | * as size increases so care should be taken to avoid unnecessary usage. 46 | * @param size 47 | */ 48 | @Override 49 | public void resize(int size) { 50 | resize(xVals, size); 51 | resize(yVals, size); 52 | } 53 | 54 | protected void resize(@NonNull List list, int size) { 55 | if (size > list.size()) { 56 | while (list.size() < size) { 57 | list.add(null); 58 | } 59 | } else if (size < list.size()) { 60 | while (list.size() > size) { 61 | list.remove(list.size() - 1); 62 | } 63 | } 64 | } 65 | 66 | @Override 67 | public String getTitle() { 68 | return this.title; 69 | } 70 | 71 | public void setTitle(String title) { 72 | this.title = title; 73 | } 74 | 75 | @Override 76 | public int size() { 77 | return xVals.size(); 78 | } 79 | 80 | @Override 81 | public Number getX(int index) { 82 | return xVals.get(index); 83 | } 84 | 85 | @Override 86 | public Number getY(int index) { 87 | return yVals.get(index); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/InterpolationParams.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | /** 20 | * Created by nick_f on 9/25/14. 21 | */ 22 | public interface InterpolationParams { 23 | 24 | Class getInterpolatorClass(); 25 | } 26 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/Interpolator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | import java.util.List; 20 | 21 | /** 22 | * Created by nick_f on 9/25/14. 23 | */ 24 | public interface Interpolator { 25 | 26 | 27 | List interpolate(XYSeries series, ParamsType params); 28 | } 29 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/OrderedXYSeries.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.xy; 2 | 3 | /** 4 | * An implementation of {@link XYSeries} that gives hints to it's renderer about the order 5 | * of the data being rendered. 6 | */ 7 | public interface OrderedXYSeries extends XYSeries { 8 | 9 | enum XOrder { 10 | /** 11 | * XVals are in strict ascending order such that: 12 | * x(i) < x(i+1) == true 13 | */ 14 | ASCENDING, 15 | 16 | /** 17 | * XVals are in strict descending order such that: 18 | * x(i) > x(i+1) == true 19 | */ 20 | DESCENDING, 21 | 22 | /** 23 | * XVals appear in no particular order. 24 | */ 25 | NONE 26 | } 27 | 28 | /** 29 | * The order of XVals as they appear in this series. 30 | * @return 31 | */ 32 | XOrder getXOrder(); 33 | } 34 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/PointLabeler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | public interface PointLabeler { 20 | 21 | String getLabel(SeriesType series, int index); 22 | } 23 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/Sampler.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.xy; 2 | 3 | /** 4 | * An algorithm used to to resample a larger set of data into a smaller set. 5 | */ 6 | public interface Sampler { 7 | 8 | /** 9 | * 10 | * @param input The original unsampled series 11 | * @param output The destination series to contain sampled result. 12 | * This series size should be set to the desired sampled size. 13 | * @return min/max values encountered while processing input. 14 | */ 15 | RectRegion run(XYSeries input, EditableXYSeries output); 16 | } 17 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/ScalingXYSeries.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.xy; 2 | 3 | /** 4 | * Wraps an existing {@link XYSeries} allowing easy scaling of that series' xy values. 5 | */ 6 | public class ScalingXYSeries implements XYSeries { 7 | 8 | private double scale; 9 | private XYSeries series; 10 | private Mode mode; 11 | 12 | public enum Mode { 13 | X_ONLY, 14 | Y_ONLY, 15 | X_AND_Y 16 | } 17 | 18 | /** 19 | * 20 | * @param series The {@link XYSeries} to be scaled 21 | * @param scale The initial scale to be applied 22 | * @param mode Determines which axis (or both) to which scaling will be applied. 23 | */ 24 | public ScalingXYSeries(XYSeries series, double scale, Mode mode) { 25 | this.series = series; 26 | this.scale = scale; 27 | this.mode = mode; 28 | } 29 | 30 | @Override 31 | public String getTitle() { 32 | return series.getTitle(); 33 | } 34 | 35 | @Override 36 | public int size() { 37 | return series.size(); 38 | } 39 | 40 | @Override 41 | public Number getX(int index) { 42 | Number x = series.getX(index); 43 | if(mode == Mode.X_ONLY || mode == Mode.X_AND_Y) { 44 | return x == null ? null : x.doubleValue() * scale; 45 | } else { 46 | return x; 47 | } 48 | } 49 | 50 | @Override 51 | public Number getY(int index) { 52 | Number y = series.getY(index); 53 | if(mode == Mode.Y_ONLY || mode == Mode.X_AND_Y) { 54 | return y == null ? null : y.doubleValue() * scale; 55 | } else { 56 | return y; 57 | } 58 | } 59 | 60 | public double getScale() { 61 | return scale; 62 | } 63 | 64 | public void setScale(double scale) { 65 | this.scale = scale; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/Step.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | /** 20 | * An immutable object generated by XYStepCalculator representing 21 | * a stepping model to be used by an XYPlot. 22 | */ 23 | public class Step { 24 | 25 | private final double stepCount; 26 | private final double stepPix; 27 | private final double stepVal; 28 | 29 | //public XYStep() {} 30 | 31 | public Step(double stepCount, double stepPix, double stepVal) { 32 | this.stepCount = stepCount; 33 | this.stepPix = stepPix; 34 | this.stepVal = stepVal; 35 | } 36 | 37 | public double getStepCount() { 38 | return stepCount; 39 | } 40 | 41 | /*public void setStepCount(double stepCount) { 42 | this.stepCount = stepCount; 43 | }*/ 44 | 45 | public double getStepPix() { 46 | return stepPix; 47 | } 48 | 49 | /*public void setStepPix(float stepPix) { 50 | this.stepPix = stepPix; 51 | }*/ 52 | 53 | public double getStepVal() { 54 | return stepVal; 55 | } 56 | 57 | /*public void setStepVal(double stepVal) { 58 | this.stepVal = stepVal; 59 | }*/ 60 | } 61 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/StepFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | import com.androidplot.ui.SeriesRenderer; 20 | 21 | public class StepFormatter extends LineAndPointFormatter { 22 | 23 | /** 24 | * Should only be used in conjunction with calls to configure()... 25 | */ 26 | public StepFormatter() {} 27 | 28 | public StepFormatter(Integer lineColor, Integer fillColor) { 29 | initLinePaint(lineColor); 30 | initFillPaint(fillColor); 31 | } 32 | 33 | @Override 34 | public Class getRendererClass() { 35 | return StepRenderer.class; 36 | } 37 | 38 | @Override 39 | public SeriesRenderer doGetRendererInstance(XYPlot plot) { 40 | return new StepRenderer(plot); 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/StepMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | /** 20 | * INCREMENTAL_VALUE - (default) draw a tick every n values. 21 | * INCREMENTAL_PIXEL - draw a tick every n pixels. 22 | * SUBDIVIDE - draw n number of evenly spaced lines. 23 | * INCREMENT_BY_FIT choose increment from a list of possible values 24 | */ 25 | public enum StepMode { 26 | SUBDIVIDE, // default 27 | INCREMENT_BY_VAL, 28 | INCREMENT_BY_PIXELS, 29 | INCREMENT_BY_FIT 30 | } 31 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/StepModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | /** 20 | * Encapsulates a set of stepping parameters for a single axis. 21 | */ 22 | public class StepModel { 23 | 24 | public StepModel(StepMode mode, double value) { 25 | setMode(mode); 26 | setValue(value); 27 | } 28 | 29 | private StepMode mode; 30 | private double value; 31 | 32 | public StepMode getMode() { 33 | return mode; 34 | } 35 | 36 | public void setMode(StepMode mode) { 37 | this.mode = mode; 38 | } 39 | 40 | public double getValue() { 41 | return value; 42 | } 43 | 44 | public void setValue(double value) { 45 | this.value = value; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/StepModelFit.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.xy; 2 | 3 | import com.androidplot.Region; 4 | 5 | import java.util.Arrays; 6 | 7 | /** 8 | * Subclass of StepModel that chooses from predefined step values. Depending on the currently 9 | * displayed range (by value) choose increment so that the number of lines 10 | * is closest to StepModel.value 11 | */ 12 | public class StepModelFit extends StepModel { 13 | 14 | private double[] steps; // list of steps to choose from 15 | private Region scale; // axis region on display 16 | 17 | public StepModelFit(Region axisRegion, double[] increments, double numLines) { 18 | super(StepMode.INCREMENT_BY_FIT, numLines); 19 | 20 | setSteps(increments); 21 | setScale(axisRegion); 22 | } 23 | 24 | public double[] getSteps() { 25 | return steps; 26 | } 27 | 28 | public void setSteps(double[] steps) { 29 | 30 | // sanity checks: no null, 0 or negative 31 | if (steps == null || steps.length == 0) 32 | return; 33 | 34 | for (double step : steps) { 35 | if (step <= 0.0d) 36 | return; 37 | } 38 | 39 | this.steps = steps; 40 | } 41 | 42 | public Region getScale() { 43 | return scale; 44 | } 45 | 46 | public void setScale(Region scale) { 47 | this.scale = scale; 48 | } 49 | 50 | // does not return StepModel.value instead calculates best fit 51 | @Override 52 | public double getValue() { 53 | 54 | // no possible increments where supplied 55 | // or no region defined 56 | if (steps == null || scale == null || !scale.isDefined()) 57 | return super.getValue(); 58 | 59 | double curStep = steps[0]; 60 | double oldDistance = Math.abs((scale.length().doubleValue() / curStep)-super.getValue() ); 61 | 62 | // determine which step size comes closest to the desired number of steps 63 | // since steps[] is a small array brute force search is ok 64 | for (double step : steps) { 65 | 66 | double newDistance = Math.abs((scale.length().doubleValue() / step)-super.getValue() ); 67 | 68 | // closer than previous stepping? 69 | if (newDistance < oldDistance){ 70 | curStep = step; 71 | oldDistance = newDistance; 72 | } 73 | } 74 | return curStep; 75 | } 76 | 77 | @Override 78 | public String toString() { 79 | return "StepModelFit{" + 80 | "steps=" + Arrays.toString(steps) + 81 | ", scale=" + scale + 82 | ", current stepping=" + getValue() + 83 | '}'; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/StepRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | import android.graphics.Path; 20 | import android.graphics.PointF; 21 | 22 | /** 23 | * Renders a point as a line with the vertices marked. Requires 2 or more points to 24 | * be rendered. 25 | */ 26 | public class StepRenderer extends LineAndPointRenderer { 27 | 28 | public StepRenderer(XYPlot plot) { 29 | super(plot); 30 | } 31 | 32 | @Override 33 | protected void appendToPath(Path path, PointF thisPoint, PointF lastPoint) { 34 | path.lineTo(thisPoint.x, lastPoint.y); 35 | path.lineTo(thisPoint.x, thisPoint.y); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/XYCoords.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | /** 20 | * A pair of x/y coordinates 21 | */ 22 | public class XYCoords { 23 | public Number x; 24 | public Number y; 25 | 26 | public XYCoords() {} 27 | 28 | public XYCoords(Number x, Number y) { 29 | this.x = x; 30 | this.y = y; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/XYFramingModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | public enum XYFramingModel { 20 | ORIGIN, 21 | EDGE, 22 | } 23 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/XYLegendItem.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.xy; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.androidplot.ui.widget.LegendItem; 6 | 7 | public class XYLegendItem implements LegendItem { 8 | 9 | public enum Type { 10 | SERIES, 11 | REGION 12 | } 13 | 14 | public final Type type; 15 | public final Object item; 16 | private final String text; 17 | 18 | public XYLegendItem(@NonNull Type cellType, @NonNull Object item, @NonNull String text) { 19 | this.type = cellType; 20 | this.item = item; 21 | this.text = text; 22 | } 23 | 24 | @Override 25 | public String getTitle() { 26 | return this.text; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/XYRegionFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | import android.content.Context; 20 | import android.graphics.Paint; 21 | 22 | import com.halfhp.fig.*; 23 | 24 | /** 25 | * Base class of all XYRegionFormatters. 26 | */ 27 | public class XYRegionFormatter { 28 | 29 | private Paint paint = new Paint(); 30 | 31 | { 32 | paint.setStyle(Paint.Style.FILL); 33 | paint.setAntiAlias(true); 34 | } 35 | 36 | /** 37 | * Provided as a convenience to users; allows instantiation and xml configuration 38 | * to take place in a single line 39 | * 40 | * @param ctx 41 | * @param xmlCfgId Id of the xml config file within /res/xml 42 | */ 43 | public XYRegionFormatter(Context ctx, int xmlCfgId) { 44 | // prevent configuration of classes derived from this one: 45 | if (getClass().equals(XYRegionFormatter.class)) { 46 | try { 47 | Fig.configure(ctx, this, xmlCfgId); 48 | } catch (FigException e) { 49 | throw new RuntimeException(e); 50 | } 51 | } 52 | } 53 | 54 | public XYRegionFormatter(int color) { 55 | paint.setColor(color); 56 | } 57 | 58 | public int getColor() { 59 | return paint.getColor(); 60 | } 61 | 62 | public void setColor(int color) { 63 | paint.setColor(color); 64 | } 65 | 66 | /** 67 | * Advanced users can use this method to access the Paint instance to add transparency etc. 68 | * @return 69 | */ 70 | public Paint getPaint() { 71 | return paint; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/XYSeries.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | import com.androidplot.Series; 20 | 21 | /** 22 | * Represents a two dimensional series of data represented as xy values. 23 | */ 24 | public interface XYSeries extends Series { 25 | 26 | /** 27 | * @return Number of elements in this Series. 28 | */ 29 | int size(); 30 | 31 | /** 32 | * Returns the x-value for an index within a series. 33 | * 34 | * @param index the index index (in the range 0 to 35 | * size()-1). 36 | * 37 | * @return The x-value. 38 | */ 39 | Number getX(int index); 40 | 41 | /** 42 | * Returns the y-value for an index within a series. 43 | * 44 | * @param index the index index (in the range 0 to 45 | * size()-1). 46 | * 47 | * @return The y-value. 48 | */ 49 | Number getY(int index); 50 | } 51 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/XYSeriesBundle.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.xy; 2 | 3 | import com.androidplot.ui.*; 4 | 5 | /** 6 | * Created by halfhp on 10/6/16. 7 | */ 8 | public class XYSeriesBundle extends SeriesBundle { 9 | 10 | public XYSeriesBundle(XYSeries series, XYSeriesFormatter formatter) { 11 | super(series, formatter); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/XYSeriesRegistry.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.xy; 2 | 3 | import com.androidplot.*; 4 | 5 | /** 6 | * Maintains the "registry" of mappings of XYSeries instances and their associated formatters. 7 | */ 8 | public class XYSeriesRegistry extends SeriesRegistry { 9 | 10 | private Estimator estimator; 11 | 12 | public void estimate(XYPlot plot) { 13 | if(estimator != null) { 14 | for (XYSeriesBundle sf : getSeriesAndFormatterList()) { 15 | getEstimator().run(plot, sf); 16 | } 17 | } 18 | } 19 | 20 | @Override 21 | protected XYSeriesBundle newSeriesBundle(XYSeries series, XYSeriesFormatter formatter) { 22 | return new XYSeriesBundle(series, formatter); 23 | } 24 | 25 | /** 26 | * 27 | * @return The currently active Estimator, or null if none is set. 28 | */ 29 | public Estimator getEstimator() { 30 | return estimator; 31 | } 32 | 33 | public void setEstimator(Estimator estimator) { 34 | this.estimator = estimator; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/XYSeriesRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | import com.androidplot.ui.SeriesBundle; 20 | import com.androidplot.ui.SeriesRenderer; 21 | import com.androidplot.util.Layerable; 22 | 23 | import java.util.Hashtable; 24 | 25 | /** 26 | * Base class for all Renderers that render XYSeries data. 27 | * @param 28 | */ 29 | public abstract class XYSeriesRenderer 30 | extends SeriesRenderer { 31 | 32 | public XYSeriesRenderer(XYPlot plot) { 33 | super(plot); 34 | } 35 | 36 | /** 37 | * TODO: get rid of this method! 38 | * @return Map of all unique XYRegionFormatters to region labels. 39 | */ 40 | public Hashtable getUniqueRegionFormatters() { 41 | 42 | Hashtable found = new Hashtable<>(); 43 | for(SeriesBundle sfPair : getSeriesAndFormatterList()) { 44 | Layerable regionIndexer = sfPair.getFormatter().getRegions(); 45 | for (RectRegion region : regionIndexer.elements()) { 46 | XYRegionFormatter f = sfPair.getFormatter().getRegionFormatter(region); 47 | found.put(f, region.getLabel()); 48 | } 49 | } 50 | return found; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/ZoomEstimator.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.xy; 2 | 3 | /** 4 | * Estimates optimal zoom level to be applied to a {@link SampledXYSeries} based on the current 5 | * visible bounds of the owning {@link XYPlot}. 6 | */ 7 | public class ZoomEstimator extends Estimator { 8 | 9 | @Override 10 | public void run(XYPlot plot, XYSeriesBundle sf) { 11 | if(sf.getSeries() instanceof SampledXYSeries) { 12 | SampledXYSeries oxy = (SampledXYSeries) sf.getSeries(); 13 | final double factor = calculateZoom(oxy, plot.getBounds()); 14 | oxy.setZoomFactor(factor); 15 | } 16 | } 17 | 18 | protected double calculateZoom(SampledXYSeries series, RectRegion visibleBounds) { 19 | RectRegion seriesBounds = series.getBounds(); 20 | final double ratio = seriesBounds.getxRegion().ratio(visibleBounds.getxRegion()).doubleValue(); 21 | final double maxFactor = series.getMaxZoomFactor(); 22 | final double factor = Math.abs(Math.round(maxFactor / ratio)); 23 | return factor > 0 ? factor : 1; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /androidplot-core/src/main/java/com/androidplot/xy/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes involved in the creation and presentation of {@link com.androidplot.xy.XYPlot}. 3 | */ 4 | package com.androidplot.xy; -------------------------------------------------------------------------------- /androidplot-core/src/main/res/values/color.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | #00000000 22 | #000 23 | #111 24 | #FFF 25 | #EEE 26 | #888 27 | -------------------------------------------------------------------------------- /androidplot-core/src/test/java/com/androidplot/test/AndroidplotTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.test; 18 | 19 | import android.content.Context; 20 | 21 | import com.androidplot.util.*; 22 | 23 | import org.junit.*; 24 | import org.junit.runner.RunWith; 25 | import org.mockito.junit.*; 26 | import org.robolectric.RobolectricTestRunner; 27 | import org.robolectric.RuntimeEnvironment; 28 | import org.robolectric.annotation.*; 29 | 30 | /** 31 | * Base class for all Androidplot tests that make use of Android platform classes. 32 | */ 33 | @RunWith(MyTestRunner.class) 34 | @Config(manifest=Config.NONE) 35 | public abstract class AndroidplotTest { 36 | 37 | /** 38 | * Enable mockito without requiring usage of {@link org.mockito.runners.MockitoJUnitRunner}. 39 | * See: http://site.mockito.org/mockito/docs/current/org/mockito/junit/MockitoRule.html 40 | */ 41 | @Rule 42 | public MockitoRule rule = MockitoJUnit.rule(); 43 | 44 | { 45 | PixelUtils.init(getContext()); 46 | } 47 | 48 | /** 49 | * Convience method - to access the application context. 50 | * @return 51 | */ 52 | protected Context getContext() { 53 | return RuntimeEnvironment.application; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /androidplot-core/src/test/java/com/androidplot/test/MyTestRunner.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.test; 2 | 3 | import org.junit.runners.model.*; 4 | import org.robolectric.*; 5 | 6 | public class MyTestRunner extends RobolectricTestRunner { 7 | 8 | /** 9 | * Constructs a new instance of the test runner. 10 | * 11 | * @throws InitializationError if the test class is malformed 12 | */ 13 | public MyTestRunner(Class testClass) throws InitializationError 14 | { 15 | super(testClass); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /androidplot-core/src/test/java/com/androidplot/test/TestUtils.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.test; 2 | 3 | import android.annotation.*; 4 | import android.view.*; 5 | 6 | import com.androidplot.xy.*; 7 | 8 | import org.robolectric.shadows.*; 9 | 10 | import static org.robolectric.Shadows.shadowOf; 11 | 12 | /** 13 | * Utilities to help with unit testing 14 | */ 15 | public abstract class TestUtils { 16 | 17 | public static XYSeries generateXYSeries(String title, int size) { 18 | return generateXYSeries(title, size, 0, 1); 19 | } 20 | 21 | /** 22 | * Generate a series of random numbers within a min/max range 23 | * @param title 24 | * @param size 25 | * @param min 26 | * @param max 27 | * @return 28 | */ 29 | public static XYSeries generateXYSeries(String title, int size, double min, double max) { 30 | SimpleXYSeries series = new SimpleXYSeries(title); 31 | for(int i = 0; i < size; i++) { 32 | series.addLast(i, Math.random() * max - min); 33 | } 34 | return series; 35 | } 36 | 37 | public static XYSeries generateXYSeriesWithNulls(String title, int size) { 38 | SimpleXYSeries series = new SimpleXYSeries(title); 39 | for(int i = 0; i < size; i++) { 40 | if(Math.random() > 0.5) { 41 | series.addLast(i, null); 42 | } else { 43 | series.addLast(i, Math.random()); 44 | } 45 | } 46 | return series; 47 | } 48 | 49 | /** 50 | * Generate a two finger {@link MotionEvent}. 51 | * @param finger1x 52 | * @param finger1y 53 | * @param finger2x 54 | * @param finger2y 55 | * @return 56 | */ 57 | @SuppressLint("NewApi") 58 | public static MotionEvent newPointerDownEvent(int finger1x, int finger1y, int finger2x, int finger2y) { 59 | MotionEvent me = MotionEvent.obtain(0, 0, MotionEvent.ACTION_POINTER_DOWN, finger1x, finger1y, 0); 60 | ShadowMotionEvent sme = shadowOf(me); 61 | //sme.setAction(MotionEvent.ACTION_POINTER_DOWN); 62 | sme.setPointerIds(0, 1); 63 | //sme.setLocation(finger1x, finger1y); 64 | sme.setPointer2(finger2x, finger2y); 65 | return me; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /androidplot-core/src/test/java/com/androidplot/ui/RenderStackTest.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.ui; 2 | 3 | import com.androidplot.Plot; 4 | import com.androidplot.SeriesRegistry; 5 | import com.androidplot.test.AndroidplotTest; 6 | import com.androidplot.xy.LineAndPointFormatter; 7 | import com.androidplot.xy.LineAndPointRenderer; 8 | import com.androidplot.xy.XYSeries; 9 | import com.google.common.collect.Lists; 10 | 11 | import org.junit.Before; 12 | import org.junit.Test; 13 | import org.mockito.Mock; 14 | 15 | import static junit.framework.Assert.assertEquals; 16 | import static junit.framework.Assert.assertFalse; 17 | import static junit.framework.Assert.assertTrue; 18 | import static org.mockito.Mockito.mock; 19 | import static org.mockito.Mockito.when; 20 | 21 | public class RenderStackTest extends AndroidplotTest { 22 | 23 | @Mock Plot plot; 24 | @Mock SeriesRegistry seriesRegistry; 25 | 26 | @Before 27 | public void before() { 28 | when(plot.getRegistry()).thenReturn(seriesRegistry); 29 | } 30 | 31 | @Test 32 | public void disable_disablesElements_ofSpecifiedRendererOnly() { 33 | final SeriesBundle s1 = new SeriesBundle(mock(XYSeries.class), 34 | new LineAndPointFormatter()); 35 | final SeriesBundle s2 = new SeriesBundle(mock(XYSeries.class), 36 | new LineAndPointFormatter()); 37 | when(seriesRegistry.getSeriesAndFormatterList()).thenReturn(Lists.newArrayList(s1, s2)); 38 | RenderStack renderStack = new RenderStack<>(plot); 39 | 40 | renderStack.sync(); 41 | assertEquals(2, renderStack.getElements().size()); 42 | for(RenderStack.StackElement element : renderStack.getElements()) { 43 | assertTrue(element.isEnabled()); 44 | } 45 | 46 | renderStack.disable(LineAndPointRenderer.class); 47 | assertEquals(2, renderStack.getElements().size()); 48 | for(RenderStack.StackElement element : renderStack.getElements()) { 49 | assertFalse(element.isEnabled()); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /androidplot-core/src/test/java/com/androidplot/util/InstrumentedXYPlot.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.util; 2 | 3 | import android.content.*; 4 | import android.graphics.*; 5 | 6 | import com.androidplot.xy.*; 7 | 8 | /** 9 | * Created by halfhp on 10/21/16. 10 | */ 11 | public class InstrumentedXYPlot extends XYPlot { 12 | 13 | // may be set by consumers if necessary 14 | public Canvas canvas = new Canvas(); 15 | 16 | public InstrumentedXYPlot(Context context) { 17 | super(context, "a test plot"); 18 | } 19 | 20 | @Override 21 | public void redraw() { 22 | super.onDraw(canvas); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /androidplot-core/src/test/java/com/androidplot/util/LinkedLayerListOrganizerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.util; 18 | 19 | import org.junit.After; 20 | import org.junit.Before; 21 | import org.junit.Test; 22 | 23 | import java.util.LinkedList; 24 | 25 | import static junit.framework.Assert.assertEquals; 26 | 27 | public class LinkedLayerListOrganizerTest { 28 | @Before 29 | public void setUp() throws Exception { 30 | 31 | } 32 | 33 | @After 34 | public void tearDown() throws Exception { 35 | 36 | } 37 | 38 | @Test 39 | public void testMoveToTop() throws Exception { 40 | 41 | } 42 | 43 | @Test 44 | public void testMoveAbove() throws Exception { 45 | 46 | } 47 | 48 | @Test 49 | public void testMoveBeneath() throws Exception { 50 | 51 | } 52 | 53 | @Test 54 | public void testMoveToBottom() throws Exception { 55 | Object obj1 = new Object(); 56 | Object obj2 = new Object(); 57 | Object obj3 = new Object(); 58 | LinkedList list = new LinkedList(); 59 | 60 | list.add(obj1); 61 | list.add(obj2); 62 | list.add(obj3); 63 | 64 | assertEquals(obj1, list.getFirst()); 65 | assertEquals(obj3, list.getLast()); 66 | 67 | LayerListOrganizer organizer = new LayerListOrganizer(list); 68 | 69 | organizer.moveToBottom(obj3); 70 | 71 | assertEquals(obj2, list.getLast()); 72 | assertEquals(obj3, list.getFirst()); 73 | 74 | } 75 | 76 | @Test 77 | public void testMoveUp() throws Exception { 78 | 79 | } 80 | 81 | @Test 82 | public void testMoveDown() throws Exception { 83 | 84 | } 85 | 86 | @Test 87 | public void testAddFirst() throws Exception { 88 | 89 | } 90 | 91 | @Test 92 | public void testAddLast() throws Exception { 93 | 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /androidplot-core/src/test/java/com/androidplot/util/PixelUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.util; 18 | 19 | import org.junit.Test; 20 | import java.util.regex.Pattern; 21 | import static junit.framework.Assert.assertTrue; 22 | 23 | public class PixelUtilsTest { 24 | 25 | @org.junit.After 26 | public void tearDown() throws Exception { 27 | 28 | } 29 | 30 | @Test 31 | public void testDimensionPattern() { 32 | Pattern DIMENSION_PATTERN = Pattern.compile(PixelUtils.DIMENSION_REGEX); 33 | assertTrue("Dimension failed dimension pattern match", DIMENSION_PATTERN.matcher("20dp").matches()); 34 | assertTrue("Negative dimension failed dimension pattern match", DIMENSION_PATTERN.matcher("-20dp").matches()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /androidplot-core/src/test/java/com/androidplot/util/PlotStatisticsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.util; 18 | 19 | import android.graphics.Canvas; 20 | import android.graphics.Paint; 21 | 22 | import com.androidplot.Plot; 23 | import com.androidplot.test.AndroidplotTest; 24 | 25 | import org.junit.Before; 26 | import org.junit.Test; 27 | import org.mockito.InjectMocks; 28 | import org.mockito.Mock; 29 | 30 | import static org.mockito.ArgumentMatchers.any; 31 | import static org.mockito.ArgumentMatchers.anyFloat; 32 | import static org.mockito.ArgumentMatchers.anyString; 33 | import static org.mockito.Mockito.never; 34 | import static org.mockito.Mockito.verify; 35 | import static org.mockito.Mockito.when; 36 | 37 | public class PlotStatisticsTest extends AndroidplotTest { 38 | 39 | @Mock 40 | Canvas canvas; 41 | 42 | @Mock 43 | Paint paint; 44 | 45 | @Mock 46 | Plot plot; 47 | 48 | @InjectMocks 49 | PlotStatistics ps = new PlotStatistics(1, true); 50 | 51 | @Before 52 | public void before() { 53 | when(plot.getDisplayDimensions()).thenReturn(new DisplayDimensions()); 54 | } 55 | 56 | @Test 57 | public void annotatePlot_annotates_ifEnabled() { 58 | ps.onAfterDraw(plot, canvas); 59 | verify(canvas).drawText(anyString(), anyFloat(), anyFloat(), any(Paint.class)); 60 | } 61 | 62 | @Test 63 | public void annotatePlot_doesNotAnnotate_ifDisabled() { 64 | ps.setEnabled(false); 65 | ps.onAfterDraw(plot, canvas); 66 | verify(canvas, never()).drawText(anyString(), anyFloat(), anyFloat(), any(Paint.class)); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /androidplot-core/src/test/java/com/androidplot/xy/AdvanceLineAndPointRendererTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | import android.graphics.*; 20 | 21 | import com.androidplot.test.*; 22 | import com.androidplot.ui.*; 23 | 24 | import org.junit.*; 25 | import org.mockito.*; 26 | 27 | import static org.mockito.Mockito.*; 28 | 29 | /** 30 | * Tests {@link AdvancedLineAndPointRenderer} and some of 31 | * {@link com.androidplot.xy.AdvancedLineAndPointRenderer.Formatter}. 32 | */ 33 | public class AdvanceLineAndPointRendererTest extends AndroidplotTest { 34 | 35 | XYPlot xyPlot; 36 | 37 | Canvas canvas; 38 | 39 | RectF plotArea = new RectF(0, 0, 100, 100); 40 | 41 | @Mock 42 | RenderStack renderStack; 43 | 44 | @Before 45 | public void setUp() throws Exception { 46 | canvas = new Canvas(); 47 | xyPlot = spy(new XYPlot(getContext(), "My Plot")); 48 | } 49 | 50 | @Test 51 | public void testOnRender() throws Exception { 52 | AdvancedLineAndPointRenderer.Formatter formatter = spy(new AdvancedLineAndPointRenderer.Formatter()); 53 | AdvancedLineAndPointRenderer renderer = formatter.getRendererInstance(xyPlot); 54 | 55 | doReturn(renderer.getClass()).when(formatter).getRendererClass(); 56 | doReturn(renderer).when(formatter).getRendererInstance(any(XYPlot.class)); 57 | 58 | XYSeries s = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Series1", 1, 2, 3, 4); 59 | 60 | xyPlot.addSeries(s, formatter); 61 | 62 | renderer.onRender(canvas, plotArea, s, formatter, renderStack); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /androidplot-core/src/test/java/com/androidplot/xy/CandlestickRendererTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | import android.graphics.*; 20 | 21 | import com.androidplot.test.*; 22 | import com.androidplot.ui.*; 23 | 24 | import org.junit.*; 25 | import org.mockito.*; 26 | 27 | import static org.mockito.Mockito.*; 28 | 29 | public class CandlestickRendererTest extends AndroidplotTest { 30 | 31 | XYPlot xyPlot; 32 | 33 | Canvas canvas; 34 | 35 | RectF plotArea = new RectF(0, 0, 100, 100); 36 | 37 | @Mock 38 | RenderStack renderStack; 39 | 40 | @Before 41 | public void setUp() throws Exception { 42 | canvas = new Canvas(); 43 | xyPlot = spy(new XYPlot(getContext(), "My Plot")); 44 | } 45 | 46 | @Test 47 | public void testOnRender() throws Exception { 48 | CandlestickFormatter formatter = spy(new CandlestickFormatter()); 49 | CandlestickRenderer renderer = spy((CandlestickRenderer) formatter.doGetRendererInstance(xyPlot)); 50 | doReturn(renderer.getClass()).when(formatter).getRendererClass(); 51 | doReturn(renderer).when(formatter).doGetRendererInstance(any(XYPlot.class)); 52 | 53 | XYSeries openVals = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "open", 1, 2, 3, 4); 54 | XYSeries closeVals = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "open", 1, 2, 3, 4); 55 | XYSeries highVals = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "open", 1, 2, 3, 4); 56 | XYSeries lowVals = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "open", 1, 2, 3, 4); 57 | CandlestickMaker.make(xyPlot, formatter, openVals, closeVals, highVals, lowVals); 58 | 59 | renderer.onRender(canvas, plotArea, openVals, formatter, renderStack); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /androidplot-core/src/test/java/com/androidplot/xy/CandlestickSeriesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | import org.junit.Test; 20 | 21 | import java.util.Arrays; 22 | 23 | import static junit.framework.Assert.assertEquals; 24 | 25 | public class CandlestickSeriesTest { 26 | 27 | @Test 28 | public void testConstructors() throws Exception { 29 | CandlestickSeries candlestickSeries = new CandlestickSeries( 30 | new CandlestickSeries.Item(1, 10, 2, 9), 31 | new CandlestickSeries.Item(4, 18, 6, 5), 32 | new CandlestickSeries.Item(3, 11, 5, 10), 33 | new CandlestickSeries.Item(2, 17, 2, 15), 34 | new CandlestickSeries.Item(6, 11, 11, 7), 35 | new CandlestickSeries.Item(8, 16, 10, 15)); 36 | 37 | XYSeries lowSeries = candlestickSeries.getLowSeries(); 38 | assertEquals(1d, lowSeries.getY(0)); 39 | assertEquals(4d, lowSeries.getY(1)); 40 | assertEquals(3d, lowSeries.getY(2)); 41 | 42 | XYSeries highSeries = candlestickSeries.getHighSeries(); 43 | assertEquals(10d, highSeries.getY(0)); 44 | assertEquals(18d, highSeries.getY(1)); 45 | assertEquals(11d, highSeries.getY(2)); 46 | 47 | XYSeries openSeries = candlestickSeries.getOpenSeries(); 48 | assertEquals(2d, openSeries.getY(0)); 49 | assertEquals(6d, openSeries.getY(1)); 50 | assertEquals(5d, openSeries.getY(2)); 51 | 52 | XYSeries closeSeries = candlestickSeries.getCloseSeries(); 53 | assertEquals(9d, closeSeries.getY(0)); 54 | assertEquals(5d, closeSeries.getY(1)); 55 | assertEquals(10d, closeSeries.getY(2)); 56 | 57 | CandlestickMaker.check(candlestickSeries); 58 | 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /androidplot-core/src/test/java/com/androidplot/xy/CatmullRomInterpolatorTest.java: -------------------------------------------------------------------------------- 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 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 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 | } 60 | -------------------------------------------------------------------------------- /androidplot-core/src/test/java/com/androidplot/xy/LTTBSamplerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | import android.graphics.*; 20 | 21 | import com.androidplot.test.*; 22 | import com.androidplot.ui.*; 23 | 24 | import org.junit.*; 25 | import org.mockito.*; 26 | 27 | import java.util.*; 28 | 29 | import static junit.framework.Assert.assertEquals; 30 | import static org.mockito.Mockito.*; 31 | 32 | public class LTTBSamplerTest extends AndroidplotTest { 33 | 34 | @Test 35 | public void testSomething() throws Exception { 36 | 37 | } 38 | 39 | // @Test 40 | // public void testDownsample() throws Exception { 41 | // 42 | // Number[][] rawNumbers = new Number[][] { {1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}, {11, 12}, {13, 14}, {15, 16}, {17, 18}, {19, 20} }; 43 | // XYSeries rawSeries = new SimpleXYSeries( 44 | // Arrays.asList(1, 3, 5, 7, 9, 11, 13, 15, 17, 19), 45 | // Arrays.asList(2, 4, 6, 8, 10, 12, 14, 16, 18, 20), "raw"); 46 | // compareSeriesToRaw(rawNumbers, rawSeries); 47 | // 48 | // LTTBDownsampler downsampler = new LTTBDownsampler(); 49 | // SimpleXYSeries sampled = new SimpleXYSeries( 50 | // Arrays.asList(new Number[]{0, 0, 0, 0, 0}), 51 | // Arrays.asList(new Number[]{0, 0, 0, 0, 0}), "sampled"); 52 | // downsampler.downsample(rawSeries, sampled); 53 | // 54 | // Number[][] downsampled = LTTBDownsampler.downsample(rawNumbers, 5); 55 | // compareSeriesToRaw(downsampled, sampled); 56 | // } 57 | // 58 | // protected void compareSeriesToRaw(Number[][] raw, XYSeries series) { 59 | // assertEquals(raw.length, series.size()); 60 | // int i = 0; 61 | // for(Number[] xy : raw) { 62 | // assertEquals(xy[0], series.getX(i)); 63 | // assertEquals(xy[1], series.getY(i)); 64 | // i++; 65 | // } 66 | // } 67 | } 68 | -------------------------------------------------------------------------------- /androidplot-core/src/test/java/com/androidplot/xy/ScalingXYSeriesTest.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.xy; 2 | 3 | import com.androidplot.test.AndroidplotTest; 4 | 5 | import org.junit.Test; 6 | 7 | import static junit.framework.Assert.assertEquals; 8 | 9 | /** 10 | * Tests {@link ScalingXYSeries}. 11 | */ 12 | public class ScalingXYSeriesTest extends AndroidplotTest { 13 | 14 | @Test 15 | public void testScale_yOnly() { 16 | SimpleXYSeries s1 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 0, 5, 10); 17 | ScalingXYSeries scaled1 = new ScalingXYSeries(s1, 0.5, ScalingXYSeries.Mode.Y_ONLY); 18 | 19 | assertEquals(0d, scaled1.getX(0).doubleValue()); 20 | assertEquals(0d, scaled1.getY(0).doubleValue()); 21 | 22 | assertEquals(1d, scaled1.getX(1).doubleValue()); 23 | assertEquals(2.5d, scaled1.getY(1).doubleValue()); 24 | 25 | assertEquals(2d, scaled1.getX(2).doubleValue()); 26 | assertEquals(5d, scaled1.getY(2).doubleValue()); 27 | } 28 | 29 | @Test 30 | public void testScale_xOnly() { 31 | SimpleXYSeries s1 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 0, 5, 10); 32 | ScalingXYSeries scaled1 = new ScalingXYSeries(s1, 0.5, ScalingXYSeries.Mode.X_ONLY); 33 | 34 | assertEquals(0d, scaled1.getX(0).doubleValue()); 35 | assertEquals(0d, scaled1.getY(0).doubleValue()); 36 | 37 | assertEquals(0.5d, scaled1.getX(1).doubleValue()); 38 | assertEquals(5d, scaled1.getY(1).doubleValue()); 39 | 40 | assertEquals(1d, scaled1.getX(2).doubleValue()); 41 | assertEquals(10d, scaled1.getY(2).doubleValue()); 42 | } 43 | 44 | @Test 45 | public void testScale_xAndY() { 46 | SimpleXYSeries s1 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 0, 5, 10); 47 | ScalingXYSeries scaled1 = new ScalingXYSeries(s1, 0.5, ScalingXYSeries.Mode.X_AND_Y); 48 | 49 | assertEquals(0d, scaled1.getX(0).doubleValue()); 50 | assertEquals(0d, scaled1.getY(0).doubleValue()); 51 | 52 | assertEquals(0.5d, scaled1.getX(1).doubleValue()); 53 | assertEquals(2.5d, scaled1.getY(1).doubleValue()); 54 | 55 | assertEquals(1d, scaled1.getX(2).doubleValue()); 56 | assertEquals(5d, scaled1.getY(2).doubleValue()); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /androidplot-core/src/test/java/com/androidplot/xy/StepCalculatorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | import com.androidplot.*; 20 | 21 | import org.junit.After; 22 | import org.junit.Before; 23 | import org.junit.Test; 24 | 25 | import static junit.framework.Assert.assertEquals; 26 | 27 | public class StepCalculatorTest { 28 | @Before 29 | public void setUp() throws Exception { 30 | 31 | } 32 | 33 | @After 34 | public void tearDown() throws Exception { 35 | 36 | } 37 | 38 | @Test 39 | public void testGetStep() throws Exception { 40 | 41 | } 42 | 43 | @Test 44 | public void testSubdivide() throws Exception { 45 | int numSegments = 10; 46 | 47 | Region pixBounds = new Region(0, 100); 48 | Region realBounds = new Region(0, 100); 49 | Step step = XYStepCalculator.getStep(StepMode.SUBDIVIDE,numSegments, realBounds, pixBounds); 50 | 51 | assertEquals(pixBounds.length().doubleValue()/(numSegments-1), step.getStepPix()); 52 | 53 | // make sure large values dont break anything: 54 | realBounds.setMin(1000000000); 55 | realBounds.setMax(2000000000); 56 | step = XYStepCalculator.getStep(StepMode.SUBDIVIDE, 57 | numSegments, realBounds, pixBounds); 58 | 59 | assertEquals(pixBounds.length().doubleValue()/(numSegments-1), step.getStepPix()); 60 | } 61 | 62 | @Test 63 | public void testIncrementByVal() throws Exception { 64 | Region pixBounds = new Region(50, 150); 65 | Region realBounds = new Region(100, 200); 66 | Step step = XYStepCalculator.getStep(StepMode.INCREMENT_BY_VAL, 1, realBounds, pixBounds); 67 | assertEquals(1.0, step.getStepPix()); 68 | } 69 | 70 | @Test 71 | public void testIncrementByPixels() throws Exception { 72 | Region pixBounds = new Region(50, 150); 73 | Region realBounds = new Region(100, 200); 74 | Step step = XYStepCalculator.getStep(StepMode.INCREMENT_BY_PIXELS, 1, realBounds, pixBounds); 75 | assertEquals(1.0, step.getStepPix()); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /androidplot-core/src/test/java/com/androidplot/xy/StepModelFitTest.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.xy; 2 | 3 | import com.androidplot.Region; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | 9 | import static org.junit.Assert.*; 10 | 11 | public class StepModelFitTest { 12 | 13 | Region regionSmall = new Region(0,11); 14 | Region regionBig = new Region(-111,420); 15 | Region regionZero = new Region(0, 0); 16 | Region regionUndef = new Region(0, null); 17 | 18 | double[] stpSmall = {1,2,5}, stpBig = {1,10,100}, nonsense = {0}; 19 | 20 | @Before 21 | public void setUp() throws Exception { 22 | 23 | } 24 | 25 | @After 26 | public void tearDown() throws Exception { 27 | 28 | } 29 | 30 | @Test 31 | public void getValue() throws Exception { 32 | 33 | StepModelFit model = new StepModelFit(regionSmall,stpSmall,3); 34 | 35 | assertEquals(5.0, model.getValue(), 0.0); 36 | model.setValue(5.0); 37 | assertEquals(2.0, model.getValue(), 0.0); 38 | model.setValue(7.0); 39 | assertEquals(2.0, model.getValue(), 0.0); 40 | 41 | model.setSteps(stpBig); 42 | assertEquals(1.0, model.getValue(), 0.0); 43 | 44 | model.setScale(regionBig); 45 | assertEquals(100.0, model.getValue(), 0.0); 46 | model.setValue(1000.0); 47 | assertEquals(1.0, model.getValue(), 0.0); 48 | 49 | // bad parameters 50 | model.setSteps(nonsense); 51 | assertArrayEquals(stpBig,model.getSteps(), 0.0); 52 | 53 | model.setScale(regionZero); 54 | assertEquals(stpBig[0], model.getValue(), 0.0); 55 | 56 | model.setScale(regionUndef); 57 | model.setValue(1.1); 58 | assertEquals(1.1, model.getValue(), 0.0); 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /androidplot-core/src/test/java/com/androidplot/xy/XYSeriesRendererTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.xy; 18 | 19 | import android.graphics.RectF; 20 | 21 | import com.androidplot.*; 22 | import com.androidplot.test.AndroidplotTest; 23 | import org.junit.After; 24 | import org.junit.Before; 25 | import org.junit.Test; 26 | import org.robolectric.RuntimeEnvironment; 27 | 28 | import static junit.framework.Assert.assertEquals; 29 | 30 | public class XYSeriesRendererTest extends AndroidplotTest { 31 | 32 | @Before 33 | public void setUp() throws Exception { 34 | 35 | } 36 | 37 | @After 38 | public void tearDown() throws Exception { 39 | 40 | } 41 | 42 | @Test 43 | public void testDataToGridCorrelation() throws Exception { 44 | RectF gridRect = new RectF(5, 5, 105, 105); 45 | XYPlot plot = new XYPlot(RuntimeEnvironment.application, "Test"); 46 | plot.setDomainStepMode(StepMode.SUBDIVIDE); 47 | plot.setDomainStepValue(10); 48 | plot.setDomainBoundaries(0, 100, BoundaryMode.FIXED); 49 | plot.setRangeBoundaries(0, 100, BoundaryMode.FIXED); 50 | plot.calculateMinMaxVals(); 51 | Step domainStep = XYStepCalculator.getStep(plot, Axis.DOMAIN, gridRect); 52 | 53 | Region xBounds = new Region(0, 9); 54 | 55 | int x = 0; 56 | double val = xBounds.transform(x, gridRect.left, gridRect.right, false); 57 | assertEquals(val, (domainStep.getStepPix()*x) + gridRect.left); 58 | 59 | x = 1; 60 | val = xBounds.transform(x, gridRect.left, gridRect.right, false); 61 | assertEquals(val, (domainStep.getStepPix()*x) + gridRect.left); 62 | 63 | x = 9; 64 | val = xBounds.transform(x, gridRect.left, gridRect.right, false); 65 | assertEquals(val, (domainStep.getStepPix()*x) + gridRect.left); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /androidplot-core/src/test/java/com/androidplot/xy/ZoomEstimatorTest.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.xy; 2 | 3 | import com.androidplot.test.*; 4 | 5 | import org.junit.*; 6 | import org.mockito.*; 7 | 8 | import static junit.framework.Assert.*; 9 | import static org.mockito.Mockito.*; 10 | 11 | /** 12 | * Created by halfhp on 10/8/16. 13 | */ 14 | public class ZoomEstimatorTest extends AndroidplotTest { 15 | 16 | @Mock 17 | XYPlot xyPlot; 18 | 19 | 20 | @Test 21 | public void testCheck() throws Exception { 22 | ZoomEstimator estimator = spy(new ZoomEstimator()); 23 | 24 | SampledXYSeries series = 25 | spy(new SampledXYSeries(TestUtils 26 | .generateXYSeries("test series", 1000), 2, 100)); 27 | series.resample(); 28 | assertEquals(8d, series.getMaxZoomFactor()); 29 | 30 | XYSeriesBundle bundle = new XYSeriesBundle(series, null); 31 | 32 | when(xyPlot.getBounds()) 33 | .thenReturn(new RectRegion(0, 1000, 0, 1000)) 34 | .thenReturn(new RectRegion(0, 500, 0, 500)) 35 | .thenReturn(new RectRegion(0, 1, 0, 1)); 36 | 37 | estimator.run(xyPlot, bundle); 38 | estimator.run(xyPlot, bundle); 39 | estimator.run(xyPlot, bundle); 40 | 41 | verify(series).setZoomFactor(8); 42 | verify(series).setZoomFactor(4); 43 | verify(series).setZoomFactor(1); 44 | } 45 | 46 | @Test 47 | public void testCalculateZoom() { 48 | ZoomEstimator estimator = spy(new ZoomEstimator()); 49 | 50 | SampledXYSeries series = 51 | spy(new SampledXYSeries(TestUtils 52 | .generateXYSeries("test series", 1000), 2, 100)); 53 | series.resample(); 54 | 55 | when(xyPlot.getBounds()) 56 | .thenReturn(new RectRegion(0, 1000, 0, 1000)); 57 | 58 | // fully zoomed out so max zoom factor should be applied: 59 | assertEquals(series.getMaxZoomFactor(), estimator.calculateZoom(series, new RectRegion(0, 1000, 0, 1000))); 60 | 61 | // fully zoomed in so min zoom factor should be applied: 62 | assertEquals(1d, estimator.calculateZoom(series, new RectRegion(0, 1, 0, 1))); 63 | 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | ext { 18 | theCompileSdkVersion = 34 19 | theTargetSdkVersion = 34 20 | theMinSdkVersion = 5 21 | theVersionName = '1.5.11' 22 | theVersionCode = 227 23 | gitUrl = 'https://github.com/halfhp/androidplot.git' 24 | } 25 | 26 | buildscript { 27 | repositories { 28 | mavenCentral() 29 | maven { url "https://plugins.gradle.org/m2/" } 30 | maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots' } 31 | google() 32 | } 33 | 34 | dependencies { 35 | classpath 'com.android.tools.build:gradle:8.5.2' 36 | classpath 'com.mxalbert.gradle:jacoco-android:0.2.0' 37 | } 38 | } 39 | 40 | allprojects { 41 | repositories { 42 | mavenCentral() 43 | google() 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /demoapp-wearable/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /demoapp-wearable/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | buildscript { 18 | repositories { 19 | google() 20 | } 21 | dependencies { 22 | classpath 'com.android.tools.build:gradle:3.1.4' 23 | } 24 | } 25 | 26 | apply plugin: 'com.android.application' 27 | 28 | android { 29 | compileSdkVersion theCompileSdkVersion 30 | buildToolsVersion theBuildToolsVersion 31 | 32 | defaultConfig { 33 | applicationId "com.androidplot.demo.wearable" 34 | minSdkVersion 20 35 | targetSdkVersion theTargetSdkVersion 36 | versionCode theVersionCode 37 | versionName theVersionName 38 | } 39 | 40 | compileOptions { 41 | sourceCompatibility JavaVersion.VERSION_17 42 | targetCompatibility JavaVersion.VERSION_17 43 | } 44 | 45 | buildTypes { 46 | release { 47 | minifyEnabled false 48 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 49 | } 50 | } 51 | } 52 | 53 | dependencies { 54 | compile project(':androidplot-core') 55 | compile 'com.google.android.support:wearable:2.3.0' 56 | compile 'com.google.android.gms:play-services-wearable:8.3.0' 57 | } 58 | -------------------------------------------------------------------------------- /demoapp-wearable/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/android_sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /demoapp-wearable/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 20 | 21 | 22 | 23 | 28 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /demoapp-wearable/src/main/res/xml/line_point_formatter_with_labels.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /demoapp-wearable/src/main/res/xml/line_point_formatter_with_labels_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /demoapp/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | 22 | # remove all debug and verbose level logging statements: 23 | -assumenosideeffects class android.util.Log { 24 | public static *** d(...); 25 | public static *** v(...); 26 | } 27 | -------------------------------------------------------------------------------- /demoapp/project.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2012 AndroidPlot.com. All rights reserved. 3 | # 4 | # Redistribution and use of source without modification and derived binaries with or without modification, 5 | # are permitted provided that the following conditions are met: 6 | # 7 | # 1. Redistributions of source code must retain the above copyright notice, this list of 8 | # conditions and the following disclaimer. 9 | # 10 | # 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 | # of conditions and the following disclaimer in the documentation and/or other materials 12 | # provided with the distribution. 13 | # 14 | # THIS SOFTWARE IS PROVIDED BY ANDROIDPLOT.COM ``AS IS'' AND ANY EXPRESS OR IMPLIED 15 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANDROIDPLOT.COM OR 17 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 20 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 22 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | # 24 | # The views and conclusions contained in the software and documentation are those of the 25 | # authors and should not be interpreted as representing official policies, either expressed 26 | # or implied, of AndroidPlot.com. 27 | # 28 | 29 | # This file is automatically generated by Android Tools. 30 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 31 | # 32 | # This file must be checked in Version Control Systems. 33 | # 34 | # To customize properties used by the Ant build system edit 35 | # "ant.properties", and override values to adapt the script to your 36 | # project structure. 37 | # 38 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 39 | #proguard.config=${sdk.dir}\tools\proguard\proguard-android.txt:proguard-project.txt 40 | # using config with optimization enabled so that things like log statement removal will work: 41 | proguard.config=${sdk.dir}/tools/proguard/proguard-android-optimize.txt:proguard-project.txt 42 | -------------------------------------------------------------------------------- /demoapp/src/main/java/com/androidplot/demos/BubbleChartActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.androidplot.demos; 18 | 19 | import android.app.*; 20 | import android.graphics.*; 21 | import android.os.*; 22 | 23 | import com.androidplot.xy.*; 24 | 25 | import java.util.*; 26 | 27 | /** 28 | * An example of a bubble chart. 29 | */ 30 | public class BubbleChartActivity extends Activity { 31 | 32 | private XYPlot plot; 33 | 34 | @Override 35 | public void onCreate(Bundle savedInstanceState) 36 | { 37 | super.onCreate(savedInstanceState); 38 | setContentView(R.layout.bubble_chart_example); 39 | 40 | // initialize our XYPlot reference: 41 | plot = (XYPlot) findViewById(R.id.plot); 42 | 43 | // turn the above arrays into XYSeries': 44 | // (Y_VALS_ONLY means use the element index as the x value) 45 | BubbleSeries series1 = new BubbleSeries( 46 | Arrays.asList(new Number[]{3, 5, 2, 3, 6}), 47 | Arrays.asList(new Number[]{1, 5, 2, 2, 3}), "s1"); 48 | 49 | BubbleSeries series2 = new BubbleSeries( 50 | Arrays.asList(new Number[]{2, 7, 3, 1, 3}), 51 | Arrays.asList(new Number[]{2, 1, 2, 6, 7}), "s2"); 52 | 53 | BubbleSeries series3 = new BubbleSeries( 54 | Arrays.asList(new Number[]{7, 2, 5, 6, 5}), 55 | Arrays.asList(new Number[]{3, 2, 4, 6, 7}), "s3"); 56 | 57 | plot.setDomainBoundaries(-1, 5, BoundaryMode.FIXED); 58 | plot.setRangeBoundaries(0, 8, BoundaryMode.FIXED); 59 | 60 | BubbleFormatter bf1 = new BubbleFormatter(this, R.xml.bubble_formatter1); 61 | bf1.setPointLabelFormatter(new PointLabelFormatter(Color.BLACK)); 62 | bf1.getPointLabelFormatter().getTextPaint().setTextAlign(Paint.Align.CENTER); 63 | bf1.getPointLabelFormatter().getTextPaint().setFakeBoldText(true); 64 | 65 | // add series to the xyplot: 66 | plot.addSeries(series1, bf1); 67 | plot.addSeries(series2, new BubbleFormatter(this, R.xml.bubble_formatter2)); 68 | plot.addSeries(series3, new BubbleFormatter(this, R.xml.bubble_formatter3)); 69 | PanZoom.attach(plot); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /demoapp/src/main/java/com/androidplot/demos/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.demos; 2 | 3 | import android.app.*; 4 | 5 | public class DemoApplication extends Application { 6 | 7 | @Override public void onCreate() { 8 | super.onCreate(); 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /demoapp/src/main/java/com/androidplot/demos/Util.java: -------------------------------------------------------------------------------- 1 | package com.androidplot.demos; 2 | 3 | import android.app.*; 4 | import android.content.*; 5 | 6 | /** 7 | * Created by halfhp on 10/29/16. 8 | */ 9 | public class Util { 10 | 11 | 12 | 13 | public ProgressDialog showLoadingDialog(Context context) { 14 | return ProgressDialog.show(context, "Loading", "Please wait...", true); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /demoapp/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/demoapp/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /demoapp/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/demoapp/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demoapp/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/demoapp/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demoapp/src/main/res/drawable-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/demoapp/src/main/res/drawable-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demoapp/src/main/res/drawable/graph_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/demoapp/src/main/res/drawable/graph_background.png -------------------------------------------------------------------------------- /demoapp/src/main/res/drawable/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/demoapp/src/main/res/drawable/ic_launcher.png -------------------------------------------------------------------------------- /demoapp/src/main/res/layout/bubble_chart_example.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | 23 | 33 | -------------------------------------------------------------------------------- /demoapp/src/main/res/layout/candlestick_example.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 23 | 24 | 39 | -------------------------------------------------------------------------------- /demoapp/src/main/res/layout/demo_app_widget.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | 19 | 23 | 24 | 29 | -------------------------------------------------------------------------------- /demoapp/src/main/res/layout/dual_scale_example.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | 23 | 35 | -------------------------------------------------------------------------------- /demoapp/src/main/res/layout/dynamic_xyplot_example.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 21 | 22 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /demoapp/src/main/res/layout/ecg_example.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | 23 | 32 | -------------------------------------------------------------------------------- /demoapp/src/main/res/layout/fx_plot_example.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | 23 | 42 | -------------------------------------------------------------------------------- /demoapp/src/main/res/layout/listview_example.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 23 | 26 | -------------------------------------------------------------------------------- /demoapp/src/main/res/layout/listview_example_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | 19 | 23 | 24 | 30 | 31 | -------------------------------------------------------------------------------- /demoapp/src/main/res/layout/pie_chart.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | 23 | 30 | 35 | 36 | 42 | 50 | 56 | 57 | -------------------------------------------------------------------------------- /demoapp/src/main/res/layout/recyclerview_example.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 24 | 25 | 30 | 31 | -------------------------------------------------------------------------------- /demoapp/src/main/res/layout/recyclerview_example_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | 19 | -------------------------------------------------------------------------------- /demoapp/src/main/res/layout/scatter_plot_example.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | 23 | 31 | -------------------------------------------------------------------------------- /demoapp/src/main/res/layout/simple_xy_plot_example.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 23 | 24 | 35 | 36 | -------------------------------------------------------------------------------- /demoapp/src/main/res/layout/spinner_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /demoapp/src/main/res/layout/step_chart_example.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 23 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /demoapp/src/main/res/layout/time_series_example.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | 19 | 24 | 25 | 43 | -------------------------------------------------------------------------------- /demoapp/src/main/res/layout/xy_plot_with_bq_img_example.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 25 | 26 | 34 | 35 | 46 | 47 | -------------------------------------------------------------------------------- /demoapp/src/main/res/values-hdpi/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 30dp 3 | 20dp 4 | -------------------------------------------------------------------------------- /demoapp/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16dp 5 | 16dp 6 | 7 | 10sp 8 | 20sp 9 | 13sp 10 | 13sp 11 | 15sp 12 | 15sp 13 | 20sp 14 | 15 | 72dp 16 | 294dp 17 | -------------------------------------------------------------------------------- /demoapp/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | Androidplot Demos 20 | A Simple XY Plot 21 | Time Series 22 | UFO Sightings 23 | 24 | -------------------------------------------------------------------------------- /demoapp/src/main/res/xml/bubble_formatter1.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /demoapp/src/main/res/xml/bubble_formatter2.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /demoapp/src/main/res/xml/bubble_formatter3.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /demoapp/src/main/res/xml/candlestick_formatter.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /demoapp/src/main/res/xml/demo_app_widget_provider_info.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | 19 | 25 | -------------------------------------------------------------------------------- /demoapp/src/main/res/xml/line_point_formatter.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /demoapp/src/main/res/xml/line_point_formatter_with_labels.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /demoapp/src/main/res/xml/line_point_formatter_with_labels_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /demoapp/src/main/res/xml/pie_segment_formatter1.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /demoapp/src/main/res/xml/pie_segment_formatter2.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /demoapp/src/main/res/xml/pie_segment_formatter3.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /demoapp/src/main/res/xml/pie_segment_formatter4.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /demoapp/src/main/res/xml/point_formatter.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /demoapp/src/main/res/xml/point_formatter_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /docs/bubblechart.md: -------------------------------------------------------------------------------- 1 | # Bubble Charts 2 | A `BubbleChart` is a two dimensional representation of three dimensional data 3 | on an `XYPlot`, where the xy values are drawn as a circle with a radius representing the zVal. 4 | 5 | ![image](images/screens/bubble_horiz.png) 6 | 7 | # Basic Usage 8 | The first step in creating a `BubbleChart` is to define the data to be plotted. We'll start 9 | by creating an instance of `BubbleSeries`: 10 | 11 | Using the implicit iVal for x: 12 | 13 | ```java 14 | BubbleSeries series1 = new BubbleSeries( 15 | Arrays.asList(new Number[]{3, 5, 2, 3, 6}), // xCoordinate 16 | Arrays.asList(new Number[]{1, 5, 2, 2, 3}), "s1"); // yCoordinate 17 | ``` 18 | 19 | Or it's equivalent four argument counterpart: 20 | 21 | ```java 22 | BubbleSeries bubbleSeries = new BubbleSeries( 23 | Arrays.asList(new Number[]{0, 1, 2, 3, 4}), // xCoordinate 24 | Arrays.asList(new Number[]{3, 5, 2, 3, 6}), // yCoordinate 25 | Arrays.asList(new Number[]{1, 5, 2, 2, 3}), // zVal (corresponds to radius) 26 | "s1"); 27 | ``` 28 | 29 | Next, create a `Formatter` defining the fill and outline colors of the bubbles: 30 | 31 | 32 | ```java 33 | // draw bubbles with a green fill and white outline: 34 | BubbleFormatter formatter = new BubbleFormatter(Color.GREEN, Color.WHITE) 35 | ``` 36 | 37 | Finally, add the `BubbleSeries` to our plot as you would any other `XYSeries` instance: 38 | 39 | ```java 40 | plot.addSeries(bubbleSeries, formatter); 41 | ``` 42 | 43 | # BubbleScaleMode 44 | By default, `BubbleRenderer` scales each rendered bubble radius using the square root of it's corresponding 45 | zVal, preventing apparent size differences in each bubble radius from being visually misleading. See: https://en.wikipedia.org/wiki/Bubble_chart#Choosing_bubble_sizes_correctly 46 | 47 | If you'd prefer to use a linear scale: 48 | 49 | ```java 50 | plot.getRenderer(BubbleRenderer.class).setBubbleScaleMode(BubbleRenderer.BubbleScaleMode.LINEAR); 51 | ``` 52 | # Example 53 | Check out the [bubble chart example source](../demoapp/src/main/java/com/androidplot/demos/BubbleChartActivity.java) for a full source example of a bubble chart. 54 | -------------------------------------------------------------------------------- /docs/grouprenderer.md: -------------------------------------------------------------------------------- 1 | # GroupRenderer 2 | `GroupRenderer` is a special implementation of `XYSeriesRenderer` that combines multiple instances 3 | of `XYSeries` into a single virtual series of s higher dimension. Examples of `GroupRenderer` are: 4 | 5 | * BarRenderer 6 | * CandlestickRenderer 7 | 8 | Let's take a quick look at `CandlestickRenderer`. A candlestick chart is basically a two two dimensional 9 | representation of a complex value; for every value of x a single candlestick is drawn, but there are 10 | four values (dimensions) that make up each candlestick: 11 | 12 | * open 13 | * close 14 | * high 15 | * low 16 | 17 | When a series is added to the plot with a formatter associated with a renderer that extends `GroupRenderer`, 18 | all series added with formatters of the same type are automatically "grouped" together during rendering. -------------------------------------------------------------------------------- /docs/images/aplogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/aplogo.png -------------------------------------------------------------------------------- /docs/images/aplogo_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/aplogo_small.png -------------------------------------------------------------------------------- /docs/images/bargroup_overlaid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/bargroup_overlaid.png -------------------------------------------------------------------------------- /docs/images/bargroup_side_by_side.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/bargroup_side_by_side.png -------------------------------------------------------------------------------- /docs/images/bargroup_spacing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/bargroup_spacing.png -------------------------------------------------------------------------------- /docs/images/bargroup_stacked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/bargroup_stacked.png -------------------------------------------------------------------------------- /docs/images/bubble_chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/bubble_chart.png -------------------------------------------------------------------------------- /docs/images/markup_mode.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/markup_mode.jpg -------------------------------------------------------------------------------- /docs/images/pie_donut_size.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/pie_donut_size.png -------------------------------------------------------------------------------- /docs/images/pie_extent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/pie_extent.png -------------------------------------------------------------------------------- /docs/images/pie_inner_inset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/pie_inner_inset.png -------------------------------------------------------------------------------- /docs/images/pie_offset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/pie_offset.png -------------------------------------------------------------------------------- /docs/images/pie_orientation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/pie_orientation.png -------------------------------------------------------------------------------- /docs/images/pie_outer_inset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/pie_outer_inset.png -------------------------------------------------------------------------------- /docs/images/pie_radial_inset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/pie_radial_inset.png -------------------------------------------------------------------------------- /docs/images/plot_anatomy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/plot_anatomy.png -------------------------------------------------------------------------------- /docs/images/positioning/bottom-right-absolute-with-offset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/positioning/bottom-right-absolute-with-offset.png -------------------------------------------------------------------------------- /docs/images/positioning/bottom-right-absolute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/positioning/bottom-right-absolute.png -------------------------------------------------------------------------------- /docs/images/positioning/center-absolute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/positioning/center-absolute.png -------------------------------------------------------------------------------- /docs/images/positioning/top-left-absolute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/positioning/top-left-absolute.png -------------------------------------------------------------------------------- /docs/images/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/preview.png -------------------------------------------------------------------------------- /docs/images/screens/about_screens.md: -------------------------------------------------------------------------------- 1 | # About Androidplot Screenshots 2 | Screenshots should be added to this directory for each new plot type. These screens should 3 | conform to the following guidelines: 4 | 5 | * Screenshots framed in Nexus5x, no glare, no shadows 6 | * Horizontal screen dimensions: 950w * 484h 7 | * Vertical screen dimensions 484w * 950h -------------------------------------------------------------------------------- /docs/images/screens/bar_horiz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/screens/bar_horiz.png -------------------------------------------------------------------------------- /docs/images/screens/bar_vert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/screens/bar_vert.png -------------------------------------------------------------------------------- /docs/images/screens/bubble_horiz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/screens/bubble_horiz.png -------------------------------------------------------------------------------- /docs/images/screens/bubble_vert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/screens/bubble_vert.png -------------------------------------------------------------------------------- /docs/images/screens/candlestick_horiz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/screens/candlestick_horiz.png -------------------------------------------------------------------------------- /docs/images/screens/candlestick_vert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/screens/candlestick_vert.png -------------------------------------------------------------------------------- /docs/images/screens/fx_horiz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/screens/fx_horiz.png -------------------------------------------------------------------------------- /docs/images/screens/fx_vert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/screens/fx_vert.png -------------------------------------------------------------------------------- /docs/images/screens/pie_horiz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/screens/pie_horiz.png -------------------------------------------------------------------------------- /docs/images/screens/pie_vert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/screens/pie_vert.png -------------------------------------------------------------------------------- /docs/images/screens/rounded_bar_renderer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/screens/rounded_bar_renderer.png -------------------------------------------------------------------------------- /docs/images/screens/scatter_horiz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/screens/scatter_horiz.png -------------------------------------------------------------------------------- /docs/images/screens/scatter_vert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/screens/scatter_vert.png -------------------------------------------------------------------------------- /docs/images/screens/step_horiz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/screens/step_horiz.png -------------------------------------------------------------------------------- /docs/images/screens/step_vert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/screens/step_vert.png -------------------------------------------------------------------------------- /docs/images/simple_xy_plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/simple_xy_plot.png -------------------------------------------------------------------------------- /docs/images/sizing/abs100x-abs100y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/sizing/abs100x-abs100y.png -------------------------------------------------------------------------------- /docs/images/sizing/abs100x-abs150y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/sizing/abs100x-abs150y.png -------------------------------------------------------------------------------- /docs/images/sizing/abs100x-rel1y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/sizing/abs100x-rel1y.png -------------------------------------------------------------------------------- /docs/images/sizing/fil50x-fil50y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/sizing/fil50x-fil50y.png -------------------------------------------------------------------------------- /docs/images/sizing/rel075x-abs100y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/docs/images/sizing/rel075x-abs100y.png -------------------------------------------------------------------------------- /docs/versioning.md: -------------------------------------------------------------------------------- 1 | # Versioning 2 | Androidplot's versioning scheme is Major.Minor.Rev. For example, in the version 1.3.2 the Major is 1 3 | the Minor is 3 and the Rev is 2. 4 | 5 | Revisional releases (releases where only the Rev value has increased from the previous release, ie 1.3.1 -> 1.3.2) 6 | may include new features and bug fixes but will be fully backwards compatible with releases of the same minor version. 7 | **Updating to the latest revisional release should require no code changes in your app.** 8 | 9 | Minor Releases (releases where the Minor value has increased but the Major value has not) may contain 10 | new features, bug fixes, removed methods deprecated in the previous minor release 11 | and other moderate refactoring. **Updating to a new minor release may require code changes in your app.** 12 | 13 | Major releases (releases where the Major value has increased) are typically complete rewrites of core 14 | elements of the library. Unless otherwise specified in the release notes, **updating to a new major release 15 | will require significant code changes to your app.** -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | android.useAndroidX=true 2 | android.enableJetifier=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halfhp/androidplot/2a15eed4decc4f4b9a604f302068d6de4b055e01/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jul 19 09:24:31 CDT 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip 7 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /misc/download_google_publisher_json.sh: -------------------------------------------------------------------------------- 1 | # use curl to download the publisher acct json file from $PUBLISHER_ACCT_JSON_FILE_URI, if set, 2 | # to the path/filename set in $PUBLISHER_ACCT_JSON_FILE. 3 | if [[ $PUBLISHER_ACCT_JSON_FILE && ${PUBLISHER_ACCT_JSON_FILE} && $PUBLISHER_ACCT_JSON_FILE_URI && ${PUBLISHER_ACCT_JSON_FILE_URI} ]] 4 | then 5 | echo "Keystore detected - downloading..." 6 | curl -L -o ${PUBLISHER_ACCT_JSON_FILE} ${PUBLISHER_ACCT_JSON_FILE_URI} 7 | else 8 | echo "Keystore uri not set. .APK artifact will not be signed." 9 | fi -------------------------------------------------------------------------------- /misc/inject_circle_build_number.sh: -------------------------------------------------------------------------------- 1 | # uses the vcs build number as the android version code and adds it to the display version string. 2 | #MAJOR_MINOR=`cat version.txt` 3 | VERSION_CODE=$CIRCLE_BUILD_NUM 4 | VERSION_NAME="$MAJOR_MINOR.$VERSION_CODE" 5 | 6 | echo "Building with Version Name: $VERSION_NAME" 7 | 8 | # update build.gradle with new version code: 9 | perl -pi -w -e "s/theVersionCode = \d/theVersionCode = $VERSION_CODE/g;" build.gradle 10 | 11 | # update build.gradle with new version name: 12 | #perl -pi -w -e 's/_dev_build_/'$VERSION_NAME'/g;' build.gradle 13 | 14 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 AndroidPlot.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | rootProject.name = 'androidplot' 18 | include 'androidplot-core' 19 | include 'demoapp' 20 | // TODO: enable this once the gradle deps are sorted 21 | //include 'demoapp-wearable' 22 | --------------------------------------------------------------------------------