diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index f333b5c29ff0307731087389af2f60adfd8e4801..0000000000000000000000000000000000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,103 +0,0 @@ -# Java Gradle CircleCI 2.0 configuration file -# -# Check https://circleci.com/docs/2.0/language-java/ for more details -# -version: 2 - -general: - branches: - only: - #- circleci -jobs: - build: - docker: - # specify the version you desire here - #- image: circleci/openjdk:8-jdk - - # CircleCI maintains a library of pre-built images - # documented at https://circleci.com/docs/2.0/circleci-images/ - - image: circleci/android:api-28-alpha - - working_directory: ~/repo - - environment: - # Customize the JVM maximum heap limit - JVM_OPTS: -Xmx3200m - TERM: dumb -# KEYSTORE: ${CIRCLE_WORKING_DIRECTORY}/sigining.keystore -# PUBLISHER_ACCT_JSON_FILE: ${CIRCLE_WORKING_DIRECTORY}/publisher_profile.json - - steps: - - checkout - - - run: echo 'export KEYSTORE=${HOME}/repo/sigining.keystore' >> $BASH_ENV - - run: echo 'export PUBLISHER_ACCT_JSON_FILE=${HOME}/repo/publisher_profile.json' >> $BASH_ENV - - # Download and cache dependencies - - restore_cache: - keys: - - v1-dependencies-{{ checksum "build.gradle" }} - # fallback to using the latest cache if no exact match is found - - v1-dependencies- - - # Get private keys etc - - run: ./misc/download_keystore.sh - - run: ./misc/inject_circle_build_number.sh - - - run: ./gradlew dependencies - - - save_cache: - paths: - - ~/.m2 - key: v1-dependencies-{{ checksum "build.gradle" }} - - # run tests & code coc! - - run: ./gradlew testDebugUnitTest jacocoTestDebugUnitTestReport - - # build release - - run: ./gradlew assembleRelease - - # javadoc - - run: ./gradlew javadoc - - # trigger codecod.io - - run: bash <(curl -s https://codecov.io/bash) - - - store_artifacts: - path: androidplot-core/build/outputs/aar/ - destination: aar - - - store_artifacts: - path: demoapp/build/outputs/apk/ - destination: apk - - - store_artifacts: - path: androidplot-core/build/reports/jacoco/debug/ - destination: coverage_report - - - store_artifacts: - path: androidplot-core/build/reports/tests/ - destination: test_results - - - store_artifacts: - path: androidplot-core/build/docs/javadoc - destination: javadoc - - - store_test_results: - path: androidplot-core/build/test-results/ - - - deploy: - name: "Deploy to Bintray" - command: | - if [ "${CIRCLE_BRANCH}" == "master" ]; - then ./gradlew bintrayUpload; - fi - - - deploy: - name: "Deploy to Google Play" - command: | - if [ "${CIRCLE_BRANCH}" == "master" ]; - then - ./misc/download_google_publisher_json.sh; - ./gradlew publishApkRelease - fi \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 1e022fdbd2f0d2309e62bbbd8003e2d3068015c8..0000000000000000000000000000000000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,14 +0,0 @@ -Thanks for taking the time to help make Androidplot better! Please note -that issues should be submitted on Github for bugs only. - -How-to questions may be posted under the [Androidplot tag on Stack Overflow](https://stackoverflow.com/questions/tagged/androidplot) -and feature requests etc. may be posted to the [Google Group Forum](https://groups.google.com/forum/#!forum/androidplot). - -When possible, please include the following in your bug report: - -* Description of the problem -* Steps to reproduce the issue -* Version(s) of Androidplot being used -* A stacktrace if the issue is causing a crash - - diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 694f2995a8c1a53d9caa8270a7d57d3ec85bc1c0..0000000000000000000000000000000000000000 --- a/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -*.ipr -*.iml -.gradle -local.properties - -build - -.metadata -AndroidPlot-Core/target -AndroidPlot-Core/.settings -DemoApp/.settings -DemoApp/bin -DemoApp/gen -DemoApp/target -.idea -**/R.java diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index 8f7b02e75d9b7c5782c8f3ecbfb4526cf4a5bc81..0000000000000000000000000000000000000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index f49a4e16e68b128803cc2dcea614603632b04eac..0000000000000000000000000000000000000000 --- a/LICENSE.md +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 7d7020d2a42e36d2e94d10ca547d80f74b13a5f0..0000000000000000000000000000000000000000 --- a/README.md +++ /dev/null @@ -1,58 +0,0 @@ -# ![image](docs/images/aplogo_small.png) Androidplot [![CircleCI](https://circleci.com/gh/halfhp/androidplot.svg?style=shield)](https://circleci.com/gh/halfhp/androidplot) [![codecov](https://codecov.io/gh/halfhp/androidplot/branch/master/graph/badge.svg)](https://codecov.io/gh/halfhp/androidplot) [![Twitter URL](https://img.shields.io/twitter/url/https/twitter.com/androidplot.svg?style=social&label=Follow%20Us)](https://twitter.com/androidplot) - -A library for creating dynamic and static charts in Android apps. It’s designed from the ground up for Android, -compatible with all versions of Android from 1.6 onward and is **used by over -[1,000 apps](http://www.appbrain.com/stats/libraries/details/androidplot/androidplot) on Google Play**. - -[![Codix](http://codix.io/gh/badge/halfhp/androidplot)](http://codix.io/gh/repo/halfhp/androidplot) - -If you enjoy the lib, please [rate us on codix.io](http://codix.io/gh/repo/halfhp/androidplot)! - - - -**Features:** - -* Line Charts -* Scatter Charts -* Bar Charts -* Pie Charts -* Step Charts -* Candlestick Charts -* Bubble Charts -* Dynamic plots -* Pan & Zoom - -# Usage - -* **[Quickstart](docs/quickstart.md)** :star: -* [Full Documentation](docs/index.md) - -# Links - -* [Website](http://androidplot.com) -* [Github Repo](https://github.com/halfhp/androidplot) -* [Bitbucket Repo](https://bitbucket.org/androidplot/androidplot) -* [Demo App (Google Play Store)](https://play.google.com/store/apps/details?id=com.androidplot.demos&hl=en) -* [Demo App Soure Code](https://bitbucket.org/androidplot/androidplot/src/1538c5dfa56aed0d2cfdcbc7cdc6173e605543cd/demoapp/?at=master) -* [Bugs](https://github.com/halfhp/androidplot/issues) :ant: -* [Contributing Source Code](docs/contributing.md) - -# Help -Technical questions should be posted using the [androidplot tag](http://stackoverflow.com/questions/tagged/androidplot) on Stack Overflow. For everything else use the [Google Groups forum](https://groups.google.com/d/forum/androidplot). - -# License -Androidplot has been made available under the Apache 2.0 license: - - Copyright 2018 Androidplot.com - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/_config.yml b/_config.yml deleted file mode 100644 index 2f7efbeab578c8042531ea7908ee8ffd7589fe46..0000000000000000000000000000000000000000 --- a/_config.yml +++ /dev/null @@ -1 +0,0 @@ -theme: jekyll-theme-minimal \ No newline at end of file diff --git a/androidplot-core/build.gradle b/androidplot-core/build.gradle deleted file mode 100644 index e513a542d9a095d8be26fc7f3c5f306badce1800..0000000000000000000000000000000000000000 --- a/androidplot-core/build.gradle +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' -apply plugin: 'com.jfrog.bintray' -apply plugin: 'jacoco-android' - -class AttrMarkdown extends DefaultTask { - - def inFile - def outFile - - @TaskAction - def generate() { - def input = project.file(inFile) - - def output = project.file(outFile) - if(output.exists()) { - output.delete() - } - output.parentFile.mkdirs() - - input.text.findAll(//) { match, g1 -> g1 - if(!g1.startsWith("NODOC")) { - output.append(g1) - output.append "\n\n" - } - } - } -} - -/** - * Generates xml attrs markdown docs. To run: - * at the command line from the project root dir type: - * ./gradlew generateAttrsMarkdown - * - * The generated doc will appear in / replace androidplot/docs/attrs.md - */ -task generateAttrsMarkdown(type: AttrMarkdown) { - inFile = { "src/main/res/values/attrs.xml"} - outFile = { "../docs/attrs.md" } -} - -android { - compileSdkVersion theCompileSdkVersion - - defaultConfig { - versionCode theVersionCode - versionName theVersionName - minSdkVersion theMinSdkVersion - targetSdkVersion theTargetSdkVersion - testApplicationId "com.androidplot.test" - } - - testOptions { - unitTests.all { - jacoco { - includeNoLocationClasses = true - } - } - } - - /** - * TODO: enable and address lint issues. - */ - lintOptions { - abortOnError false - } -} - -group = 'com.androidplot' -version = theVersionName - -def siteUrl = 'http://androidplot.com' -def gitUrl = 'https://github.com/halfhp/androidplot.git' - -dependencies { - - implementation 'com.halfhp.fig:figlib:1.0.7' - implementation 'com.android.support:support-annotations:28.0.0' - testImplementation "org.mockito:mockito-core:3.0.0" - testImplementation group: 'junit', name: 'junit', version: '4.12' - testImplementation "org.robolectric:robolectric:4.2.1" - - // temp fix for: - // https://github.com/robolectric/robolectric/issues/1932 - testImplementation 'org.khronos:opengl-api:gl1.1-android-2.1_r1' -} - -task javadoc(type: Javadoc) { - source = android.sourceSets.main.java.srcDirs - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) - failOnError false - options { - links "http://docs.oracle.com/javase/7/docs/api/" - linksOffline "http://d.android.com/reference","${android.sdkDirectory}/docs/reference" - } - exclude '**/BuildConfig.java' - exclude '**/R.java' -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -task sourcesJar(type: Jar) { - classifier = 'sources' - from android.sourceSets.main.java.srcDirs -} - -install { - repositories.mavenInstaller { - pom { - project { - packaging 'aar' - name 'Androidplot Core Library' - description = "Androidplot is a library for creating dynamic and static charts within your Android application." - url siteUrl - licenses { - license { - name 'The Apache Software License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - developers { - developer { - id 'halfhp' - name 'Nick Fellows' - email 'halfhp@gmail.com' - } - } - scm { - connection gitUrl - developerConnection gitUrl - url siteUrl - - } - } - } - } -} - -bintray { - - // these environment vars must be set when deploying to bintray. - // note: BINTRAY_PASSWORD is actually the api key, but naming it 'password' - // tells the CI environment to obfuscate the value in public logs. - user = System.getenv('BINTRAY_USER') - key = System.getenv('BINTRAY_PASSWORD') - - - configurations = ['archives'] - pkg { - version { - name = theVersionName - } - repo = "androidplot" - name = "com.androidplot:androidplot-core" - issueTrackerUrl = "https://github.com/halfhp/androidplot/issues" - websiteUrl = siteUrl - vcsUrl = gitUrl - licenses = ["Apache-2.0"] - } -} - -javadoc { - options.overview = "src/main/java/overview.html" -} - -artifacts { - archives javadocJar - archives sourcesJar -} diff --git a/androidplot-core/src/main/AndroidManifest.xml b/androidplot-core/src/main/AndroidManifest.xml deleted file mode 100644 index e83183d1a346b98488629db91b00a3919869efdc..0000000000000000000000000000000000000000 --- a/androidplot-core/src/main/AndroidManifest.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - \ No newline at end of file diff --git a/androidplot-core/src/main/java/com/androidplot/util/APTrace.java b/androidplot-core/src/main/java/com/androidplot/util/APTrace.java deleted file mode 100644 index 88e6317a4bb8f0b2b116b1061b14519662f9a36b..0000000000000000000000000000000000000000 --- a/androidplot-core/src/main/java/com/androidplot/util/APTrace.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.androidplot.util; - -import android.os.*; - -/** - * Wraps {@link Trace} to provide API-safe methods as well as an easy target for runtime removal - * via obfuscation. - */ -public abstract class APTrace { - - public static void begin(final String sectionName) { - if(Build.VERSION.SDK_INT >= 18) { - Trace.beginSection(sectionName); - } else { - // TODO: alternate impl? - } - } - - public static void end() { - if(Build.VERSION.SDK_INT >= 18) { - Trace.endSection(); - } else { - // TODO: alternate impl? - } - } -} diff --git a/androidplot-core/src/main/java/com/androidplot/util/AttrUtils.java b/androidplot-core/src/main/java/com/androidplot/util/AttrUtils.java deleted file mode 100644 index 853ae25ae8d16cfd27258c6f4b6920a754a7342a..0000000000000000000000000000000000000000 --- a/androidplot-core/src/main/java/com/androidplot/util/AttrUtils.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.util; - -import android.content.res.TypedArray; -import android.graphics.Paint; -import android.util.*; - -import com.androidplot.ui.*; -import com.androidplot.ui.Size; -import com.androidplot.ui.widget.Widget; -import com.androidplot.xy.StepMode; -import com.androidplot.xy.StepModel; - -/** - * Methods for applying styleable attributes. - * - */ -public class AttrUtils { - - private static final String TAG = AttrUtils.class.getName(); - - public static void configureInsets(TypedArray attrs, Insets insets, - int topAttr, int bottomAttr, int leftAttr, int rightAttr) { - insets.setTop(attrs.getDimension(topAttr, insets.getTop())); - insets.setBottom(attrs.getDimension(bottomAttr, insets.getBottom())); - insets.setLeft(attrs.getDimension(leftAttr, insets.getLeft())); - insets.setRight(attrs.getDimension(rightAttr, insets.getRight())); - } - - /** - * Configure a {@link Paint} instance used for drawing text from xml attrs. - * @param attrs - * @param paint - * @param colorAttr - * @param textSizeAttr - */ - public static void configureTextPaint(TypedArray attrs, Paint paint, - int colorAttr, int textSizeAttr) { - configureTextPaint(attrs, paint, colorAttr, textSizeAttr, null); - } - - /** - * Configure a {@link Paint} instance used for drawing text from xml attrs. - * @param attrs - * @param paint - * @param colorAttr - * @param textSizeAttr - * @param alignAttr - */ - public static void configureTextPaint(TypedArray attrs, Paint paint, int colorAttr, - int textSizeAttr, Integer alignAttr) { - if(attrs != null) { - setColor(attrs, paint, colorAttr); - setTextSize(attrs, paint, textSizeAttr); - - if(alignAttr != null && attrs.hasValue(alignAttr)) { - configureTextAlign(attrs, paint, alignAttr); - } - } - } - - /** - * Configure {@link Paint} text alignment from xml attrs. - * @param attrs - * @param paint - * @param alignAttr - */ - public static void configureTextAlign(TypedArray attrs, Paint paint, int alignAttr) { - if (attrs != null) { - //if(attrs.hasValue(alignAttr)) { - final Paint.Align alignment = Paint.Align.values() - [attrs.getInt(alignAttr, paint.getTextAlign().ordinal())]; - paint.setTextAlign(alignment); - //} - } - } - - /** - * Configure a {@link Paint} instance used for drawing lines from xml attrs. - * @param attrs - * @param paint - * @param colorAttr - * @param strokeWidthAttr - */ - public static void configureLinePaint(TypedArray attrs, Paint paint, int colorAttr, int strokeWidthAttr) { - if(attrs != null) { - setColor(attrs, paint, colorAttr); - paint.setStrokeWidth(attrs.getDimension(strokeWidthAttr, paint.getStrokeWidth())); - } - } - - public static void setColor(TypedArray attrs, Paint paint, int attrId) { - if(paint == null) { - Log.w(TAG, "Attempt to configure null Paint property for attrId: " + attrId); - } else { - paint.setColor(attrs.getColor(attrId, paint.getColor())); - } - } - - public static void setTextSize(TypedArray attrs, Paint paint, int attrId) { - paint.setTextSize(attrs.getDimension(attrId, paint.getTextSize())); - } - - /** - * Configure a {@link BoxModelable} instance from xml attrs. - * @param attrs - * @param model - * @param marginTop - * @param marginBottom - * @param marginLeft - * @param marginRight - * @param paddingTop - * @param paddingBottom - * @param paddingLeft - * @param paddingRight - */ - public static void configureBoxModelable(TypedArray attrs, BoxModelable model, int marginTop, int marginBottom, - int marginLeft, int marginRight, int paddingTop, int paddingBottom, - int paddingLeft, int paddingRight) { - if(attrs != null) { - model.setMargins(attrs.getDimension(marginLeft, model.getMarginLeft()), - attrs.getDimension(marginTop, model.getMarginTop()), - attrs.getDimension(marginRight, model.getMarginRight()), - attrs.getDimension(marginBottom, model.getMarginBottom())); - - model.setPadding(attrs.getDimension(paddingLeft, model.getPaddingLeft()), - attrs.getDimension(paddingTop, model.getPaddingTop()), - attrs.getDimension(paddingRight, model.getPaddingRight()), - attrs.getDimension(paddingBottom, model.getPaddingBottom())); - } - } - - /** - * Configure a {@link Size} instance from xml attrs. - * @param attrs - * @param model - * @param heightSizeLayoutTypeAttr - * @param heightAttr - * @param widthSizeLayoutTypeAttr - * @param widthAttr - */ - public static void configureSize(TypedArray attrs, Size model, int heightSizeLayoutTypeAttr, int heightAttr, - int widthSizeLayoutTypeAttr, int widthAttr) { - if(attrs != null) { - configureSizeMetric(attrs, model.getHeight(), heightSizeLayoutTypeAttr, heightAttr); - configureSizeMetric(attrs, model.getWidth(), widthSizeLayoutTypeAttr, widthAttr); - } - } - - private static void configureSizeMetric(TypedArray attrs, SizeMetric model, int typeAttr, int valueAttr) { - - final float value = getIntFloatDimenValue(attrs, valueAttr, model.getValue()).floatValue(); - final SizeMode sizeMode = - getSizeLayoutType(attrs, typeAttr, model.getLayoutType()); - - model.set(value, sizeMode); - } - - private static SizeMode getSizeLayoutType(TypedArray attrs, int attr, SizeMode defaultValue) { - return SizeMode.values()[attrs.getInt(attr, defaultValue.ordinal())]; - } - - public static void configureWidget(TypedArray attrs, Widget widget, int heightSizeLayoutTypeAttr, int heightAttr, - int widthSizeLayoutTypeAttr, int widthAttr, int xLayoutStyleAttr, - int xLayoutValueAttr, int yLayoutStyleAttr, int yLayoutValueAttr, - int anchorPositionAttr, int visibilityAttr) { - if(attrs != null) { - configureSize(attrs, widget.getSize(), heightSizeLayoutTypeAttr, - heightAttr, widthSizeLayoutTypeAttr, widthAttr); - configurePositionMetrics(attrs, widget.getPositionMetrics(), xLayoutStyleAttr, xLayoutValueAttr, - yLayoutStyleAttr, yLayoutValueAttr, anchorPositionAttr); - widget.setVisible(attrs.getBoolean(visibilityAttr, widget.isVisible())); - } - } - - public static void configureWidgetRotation(TypedArray attrs, Widget widget, int rotationAttr) { - if(attrs != null) { - widget.setRotation(getWidgetRotation(attrs, rotationAttr, Widget.Rotation.NONE)); - } - } - - /** - * Configure a {@link Widget} from xml attrs. - * @param attrs - * @param metrics - * @param xLayoutStyleAttr - * @param xLayoutValueAttr - * @param yLayoutStyleAttr - * @param yLayoutValueAttr - * @param anchorPositionAttr - */ - public static void configurePositionMetrics(TypedArray attrs, PositionMetrics metrics, int xLayoutStyleAttr, - int xLayoutValueAttr, int yLayoutStyleAttr, int yLayoutValueAttr, - int anchorPositionAttr) { - if(attrs != null && metrics != null) { - metrics.getXPositionMetric().set( - getIntFloatDimenValue(attrs, xLayoutValueAttr, metrics.getXPositionMetric().getValue()).floatValue(), - getXLayoutStyle(attrs, xLayoutStyleAttr, metrics.getXPositionMetric().getLayoutType())); - - metrics.getYPositionMetric().set( - getIntFloatDimenValue(attrs, yLayoutValueAttr, metrics.getYPositionMetric().getValue()).floatValue(), - getYLayoutStyle(attrs, yLayoutStyleAttr, metrics.getYPositionMetric().getLayoutType())); - metrics.setAnchor(getAnchorPosition(attrs, anchorPositionAttr, metrics.getAnchor())); - } - } - - /** - * Convenience method to retrieve values from xml that can be entered as a int, float or dimen. - * @param attrs - * @param valueAttr - * @param defaultValue - * @return - */ - private static Number getIntFloatDimenValue(TypedArray attrs, int valueAttr, Number defaultValue) { - Number result = defaultValue; - if(attrs != null && attrs.hasValue(valueAttr)) { - final int valueType = attrs.peekValue(valueAttr).type; - if (valueType == TypedValue.TYPE_DIMENSION) { - result = attrs.getDimension(valueAttr, defaultValue.floatValue()); - } else if(valueType == TypedValue.TYPE_INT_DEC) { - result = attrs.getInt(valueAttr, defaultValue.intValue()); - } else if (valueType == TypedValue.TYPE_FLOAT) { - result = attrs.getFloat(valueAttr, defaultValue.floatValue()); - } else { - throw new IllegalArgumentException("Invalid value type - must be int, float or dimension."); - } - } - return result; - } - - private static HorizontalPositioning getXLayoutStyle(TypedArray attrs, int attr, HorizontalPositioning defaultValue) { - return HorizontalPositioning.values()[attrs.getInt(attr, defaultValue.ordinal())]; - } - - private static VerticalPositioning getYLayoutStyle(TypedArray attrs, int attr, VerticalPositioning defaultValue) { - return VerticalPositioning.values()[attrs.getInt(attr, defaultValue.ordinal())]; - } - - private static Widget.Rotation getWidgetRotation(TypedArray attrs, int attr, Widget.Rotation defaultValue) { - return Widget.Rotation.values()[attrs.getInt(attr, defaultValue.ordinal())]; - } - - private static Anchor getAnchorPosition(TypedArray attrs, int attr, Anchor defaultValue) { - return Anchor.values()[attrs.getInt(attr, defaultValue.ordinal())]; - } - - public static void configureStep(TypedArray attrs, StepModel model, int stepModeAttr, int stepValueAttr) { - if(attrs != null) { - model.setMode(StepMode.values()[attrs.getInt(stepModeAttr, model.getMode().ordinal())]); - model.setValue(getIntFloatDimenValue(attrs, stepValueAttr, model.getValue()).doubleValue()); - } - } -} diff --git a/androidplot-core/src/main/res/values/attrs.xml b/androidplot-core/src/main/res/values/attrs.xml deleted file mode 100644 index 535ccf18da5a42782b328b63dd6ce9d146660502..0000000000000000000000000000000000000000 --- a/androidplot-core/src/main/res/values/attrs.xml +++ /dev/null @@ -1,1134 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/androidplot-core/src/main/res/values/color.xml b/androidplot-core/src/main/res/values/color.xml deleted file mode 100644 index 659c1ac8d7f6cbb25bff2ad29435138b6fea3969..0000000000000000000000000000000000000000 --- a/androidplot-core/src/main/res/values/color.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - #00000000 - #000 - #111 - #FFF - #EEE - #888 - \ No newline at end of file diff --git a/androidplot-core/src/main/res/values/style.xml b/androidplot-core/src/main/res/values/style.xml deleted file mode 100644 index 5c861e553131402be74fea60b1e0c5919498d2c5..0000000000000000000000000000000000000000 --- a/androidplot-core/src/main/res/values/style.xml +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/androidplot-core/src/test/java/com/androidplot/PlotTest.java b/androidplot-core/src/test/java/com/androidplot/PlotTest.java deleted file mode 100644 index 5a750afd6010fe64f49877160bb3e9b8f49c2524..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/PlotTest.java +++ /dev/null @@ -1,464 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot; - -import android.content.res.TypedArray; -import android.graphics.*; -import android.util.*; - -import com.androidplot.test.*; -import com.androidplot.ui.*; -import com.halfhp.fig.*; -import org.junit.Test; -import org.mockito.Mock; -import org.robolectric.RuntimeEnvironment; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNotSame; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -public class PlotTest extends AndroidplotTest { - - @Mock - SeriesRegistry mockSeriesRegistry; - - @Test - public void testInit_withoutAttrs() { - Plot plot = mock(Plot.class); - plot.init(RuntimeEnvironment.application, null, 0); - - verify(plot, times(1)).onPreInit(); - verify(plot, times(1)).onAfterConfig(); - } - - @Test - public void testInit_withAttrs() { - Plot plot = new MockPlot("MockPlot"); - AttributeSet attrs = mock(AttributeSet.class); - plot.init(RuntimeEnvironment.application, attrs, 0); - // TODO: verifications - } - - @Test - public void testAddSeries() { - Plot plot = new MockPlot("MockPlot"); - - MockSeries m1 = new MockSeries(); - Class cl = MockRenderer1.class; - - plot.addSeries(m1, new MockFormatter1()); - assertEquals(1, plot.getRegistry().size()); - - // a new copy of m1 is added: - plot.addSeries(m1, new MockFormatter1()); - - assertEquals(1, plot.getRenderers().size()); - assertEquals(2, plot.getRenderer(cl).getSeriesList().size()); - - MockSeries m2 = new MockSeries(); - - plot.addSeries(m2, new MockFormatter1()); - - // still should only be one renderer type: - assertEquals(1, plot.getRendererList().size()); - - // we added a new instance of cl to the renderer so there should be 3 in the subregistry: - assertEquals(3, plot.getRenderer(cl).getSeriesList().size()); - - - // lets add another renderer: - plot.addSeries(m1, new MockFormatter2()); - - assertEquals(2, plot.getRendererList().size()); - } - - @Test - public void testRemoveSeries() { - - Plot plot = new MockPlot("MockPlot"); - - MockSeries m1 = new MockSeries(); - MockSeries m2 = new MockSeries(); - MockSeries m3 = new MockSeries(); - - plot.addSeries(m1, new MockFormatter1()); - plot.addSeries(m2, new MockFormatter1()); - plot.addSeries(m3, new MockFormatter1()); - - plot.addSeries(m1, new MockFormatter2()); - plot.addSeries(m2, new MockFormatter2()); - plot.addSeries(m3, new MockFormatter2()); - - - // a quick sanity run: - assertEquals(2, plot.getRendererList().size()); - assertEquals(3, plot.getRenderer(MockRenderer1.class).getSeriesList().size()); - assertEquals(3, plot.getRenderer(MockRenderer2.class).getSeriesList().size()); - - plot.removeSeries(m1, MockRenderer1.class); - assertEquals(2, plot.getRenderer(MockRenderer1.class).getSeriesList().size()); - - plot.removeSeries(m2, MockRenderer1.class); - assertEquals(1, plot.getRenderer(MockRenderer1.class).getSeriesList().size()); - - plot.removeSeries(m2, MockRenderer1.class); - assertEquals(1, plot.getRenderer(MockRenderer1.class).getSeriesList().size()); - - plot.removeSeries(m3, MockRenderer1.class); - - // add em all back - plot.addSeries(m1, new MockFormatter1()); - plot.addSeries(m2, new MockFormatter1()); - plot.addSeries(m3, new MockFormatter1()); - - plot.addSeries(m1, new MockFormatter1()); - plot.addSeries(m2, new MockFormatter1()); - plot.addSeries(m3, new MockFormatter1()); - - - // a quick sanity run: - assertEquals(2, plot.getRendererList().size()); - assertEquals(6, plot.getRenderer(MockRenderer1.class).getSeriesList().size()); - assertEquals(3, plot.getRenderer(MockRenderer2.class).getSeriesList().size()); - - // now lets try removing a series from all renderers: - plot.removeSeries(m1); - assertEquals(4, plot.getRenderer(MockRenderer1.class).getSeriesList().size()); - assertEquals(2, plot.getRenderer(MockRenderer2.class).getSeriesList().size()); - - // and now lets remove the remaining series: - plot.removeSeries(m2); - plot.removeSeries(m3); - } - - - @Test - public void testGetFormatter() { - Plot plot = new MockPlot("MockPlot"); - - MockSeries m1 = new MockSeries(); - MockSeries m2 = new MockSeries(); - MockSeries m3 = new MockSeries(); - - MockFormatter1 f1 = new MockFormatter1(); - MockFormatter1 f2 = new MockFormatter1(); - MockFormatter2 f3 = new MockFormatter2(); - - plot.addSeries(m1, f1); - plot.addSeries(m2, f2); - plot.addSeries(m3, new MockFormatter1()); - - plot.addSeries(m1, new MockFormatter1()); - plot.addSeries(m2, f3); - plot.addSeries(m3, new MockFormatter1()); - - assertEquals(plot.getRenderer(MockRenderer1.class).getFormatter(m1), f1); - assertEquals(plot.getRenderer(MockRenderer1.class).getFormatter(m2), f2); - assertEquals(plot.getRenderer(MockRenderer2.class).getFormatter(m2), f3); - - assertNotSame(plot.getRenderer(MockRenderer2.class).getFormatter(m2), f1); - - } - - @Test - public void testGetRendererList() { - - Plot plot = new MockPlot("MockPlot"); - - MockSeries m1 = new MockSeries(); - MockSeries m2 = new MockSeries(); - MockSeries m3 = new MockSeries(); - - plot.addSeries(m1, new MockFormatter1()); - plot.addSeries(m2, new MockFormatter1()); - plot.addSeries(m3, new MockFormatter1()); - - plot.addSeries(m1, new MockFormatter2()); - plot.addSeries(m2, new MockFormatter2()); - plot.addSeries(m3, new MockFormatter2()); - - List rList = plot.getRendererList(); - assertEquals(2, rList.size()); - } - - @Test - public void testAddListener() { - Plot plot = new MockPlot("MockPlot"); - ArrayList listeners = plot.getListeners(); - - assertEquals(0, listeners.size()); - - MockPlotListener pl1 = new MockPlotListener(); - MockPlotListener pl2 = new MockPlotListener(); - - plot.addListener(pl1); - - assertEquals(1, listeners.size()); - - // should return false on a double entry attempt - assertFalse(plot.addListener(pl1)); - - // make sure the listener wasnt added anyway: - assertEquals(1, listeners.size()); - - plot.addListener(pl2); - - assertEquals(2, listeners.size()); - - } - - @Test - public void testRemoveListener() { - Plot plot = new MockPlot("MockPlot"); - ArrayList listeners = plot.getListeners(); - - assertEquals(0, listeners.size()); - - MockPlotListener pl1 = new MockPlotListener(); - MockPlotListener pl2 = new MockPlotListener(); - MockPlotListener pl3 = new MockPlotListener(); - - plot.addListener(pl1); - plot.addListener(pl2); - - assertEquals(2, listeners.size()); - - assertFalse(plot.removeListener(pl3)); - - assertTrue(plot.removeListener(pl1)); - - assertEquals(1, listeners.size()); - - assertFalse(plot.removeListener(pl1)); - - assertEquals(1, listeners.size()); - - assertTrue(plot.removeListener(pl2)); - - assertEquals(0, listeners.size()); - - } - - @Test - public void testConfigure() throws Exception { - Plot plot = new MockPlot("MockPlot"); - - HashMap params = new HashMap(); - String param1 = "this is a test."; - String param2 = "use_background_thread"; - String param3 = "#FF0000"; - params.put("title.text", param1); - params.put("renderMode", param2); - params.put("backgroundPaint.color", param3); - - Fig.configure(RuntimeEnvironment.application, plot, params); - - assertEquals(param1, plot.getTitle().getText()); - assertEquals(Plot.RenderMode.USE_BACKGROUND_THREAD, plot.getRenderMode()); - assertEquals(Color.parseColor(param3), plot.getBackgroundPaint().getColor()); - } - - @Test - public void setTitle_setsTitle() { - Plot plot = new MockPlot("foo"); - plot.setTitle("bar"); - assertEquals("bar", plot.getTitle().getText()); - } - - @Test - public void clear_unregistersAllPlotListeners() { - Plot plot = new MockPlot("MockPlot"); - plot.addSeries(new MockSeries(), new MockFormatter1()); - plot.addSeries(new MockSeries(), new MockFormatter1()); - plot.addSeries(new MockSeries(), new MockFormatter1()); - assertEquals(3, plot.getListeners().size()); - - plot.clear(); - assertEquals(0, plot.getListeners().size()); - } - - @Test - public void clear_clearsRegistry() { - Plot plot = new MockPlot("MockPlot"); - plot.setRegistry(mockSeriesRegistry); - - plot.clear(); - verify(mockSeriesRegistry).clear(); - } - - @Test - public void setPlotMargins_updatesMargins() { - Plot plot = new MockPlot("MockPlot"); - plot.setPlotMargins(11, 22, 33, 44); - - assertEquals(11f, plot.getPlotMarginLeft()); - assertEquals(22f, plot.getPlotMarginTop()); - assertEquals(33f, plot.getPlotMarginRight()); - assertEquals(44f, plot.getPlotMarginBottom()); - } - - @Test - public void setPlotPadding_updatesPadding() { - Plot plot = new MockPlot("MockPlot"); - plot.setPlotPadding(11, 22, 33, 44); - - assertEquals(11f, plot.getPlotPaddingLeft()); - assertEquals(22f, plot.getPlotPaddingTop()); - assertEquals(33f, plot.getPlotPaddingRight()); - assertEquals(44f, plot.getPlotPaddingBottom()); - } - - static class MockPlotListener implements PlotListener { - - public void onBeforeDraw(Plot source, Canvas canvas) { - } - - public void onAfterDraw(Plot source, Canvas canvas) { - } - } - - static class MockSeries implements Series, PlotListener { - - public String getTitle() { - return null; - } - - @Override - public void onBeforeDraw(Plot source, Canvas canvas) { - - } - - @Override - public void onAfterDraw(Plot source, Canvas canvas) { - - } - } - - static class MockSeries2 implements Series { - - public String getTitle() { - return null; - } - } - - static class MockSeries3 implements Series { - - public String getTitle() { - return null; - } - } - - static class MockRenderer1 extends SeriesRenderer { - - public MockRenderer1(Plot plot) { - super(plot); - } - - @Override - public void onRender(Canvas canvas, RectF plotArea, Series series, Formatter formatter, RenderStack stack) { - - } - - @Override - public void doDrawLegendIcon(Canvas canvas, RectF rect, Formatter formatter) { - - } - } - - static class MockRenderer2 extends SeriesRenderer { - - public MockRenderer2(Plot plot) { - super(plot); - } - - @Override - public void onRender(Canvas canvas, RectF plotArea, Series series, Formatter formatter, RenderStack stack) { - - } - - @Override - public void doDrawLegendIcon(Canvas canvas, RectF rect, Formatter formatter) { - - } - } - - static class MockFormatter1 extends Formatter { - - @Override - public Class getRendererClass() { - return MockRenderer1.class; - } - - @Override - public SeriesRenderer doGetRendererInstance(MockPlot plot) { - return new MockRenderer1(plot); - } - } - - static class MockFormatter2 extends Formatter { - - @Override - public Class getRendererClass() { - return MockRenderer2.class; - } - - @Override - public SeriesRenderer doGetRendererInstance(MockPlot plot) { - return new MockRenderer2(plot); - } - } - - public static class MockSeriesBundle extends SeriesBundle { - - public MockSeriesBundle(MockSeries series, Formatter formatter) { - super(series, formatter); - } - } - - public static class MockPlot extends Plot> { - public MockPlot(String title) { - super(RuntimeEnvironment.application, title); - } - - @Override - protected SeriesRegistry getRegistryInstance() { - return new SeriesRegistry() { - @Override - protected MockSeriesBundle newSeriesBundle( - MockSeries series, Formatter formatter) { - return new MockSeriesBundle(series, formatter); - } - }; - } - - @Override - protected void onPreInit() { - - } - - @Override - protected void processAttrs(TypedArray attrs) { - - } - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/RegionTest.java b/androidplot-core/src/test/java/com/androidplot/RegionTest.java deleted file mode 100644 index c38ded3c459eccd9efca336868f5a9dd0ddeff4d..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/RegionTest.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import static junit.framework.Assert.assertNotSame; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class RegionTest { - - @Before - public void setUp() throws Exception { - - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testConstructor() throws Exception { - Region lr = new Region(0d, 0d); - assertEquals(0d, lr.getMin().doubleValue(), 0); - assertEquals(0d, lr.getMax().doubleValue(), 0); - - lr = new Region(1.5d, -2d); - assertEquals(-2f, lr.getMin().floatValue(), 0); - assertEquals(1.5f, lr.getMax().floatValue(), 0); - - lr = new Region(10d, 20d); - assertEquals(10l, lr.getMin().longValue(), 0); - assertEquals(20l, lr.getMax().longValue(), 0); - } - - - @Test - public void testContains() throws Exception { - - } - - @Test - public void testIntersects() throws Exception { - Region line1 = new Region(1, 10); - Region line2 = new Region(11, 20); - assertFalse(line1.intersects(line2)); - - line1.setMax(15); - assertTrue(line1.intersects(line2)); - - //l1end = 30; - line1.setMax(30); - assertTrue(line1.intersects(line2)); - - //l1start = 21; - line1.setMin(21); - assertFalse(line1.intersects(line2)); - } - - @Test - public void testLength() throws Exception { - Region lr = new Region(0, 10); - assertEquals(10d, lr.length().doubleValue(), 0); - - lr = new Region(-5, 5); - assertEquals(10d, lr.length().doubleValue(), 0); - } - - @Test - public void testCenter() throws Exception { - Region r1 = new Region(1, 2); - assertEquals(1.5, r1.center()); - - Region r2 = new Region(-10, 10); - assertEquals(0.0, r2.center()); - - Region r3 = new Region(-2, -1); - assertEquals(-1.5, r3.center()); - } - - @Test - public void testTransform() throws Exception { - Region r1 = new Region(1, 2); - Region r2 = new Region(0, 10); - - assertEquals(5.0, r1.transform(1.5, r2)); - assertEquals(0.0, r1.transform(1, r2)); - assertEquals(10.0, r1.transform(2, r2)); - - Region r3 = new Region(-10, 10); - assertEquals(-10.0, r1.transform(1, r3)); - } - - @Test - public void testTransformWithFlip() throws Exception { - Region r1 = new Region(1, 2); - Region r2 = new Region(0, 10); - - assertEquals(5.0, r1.transform(1.5, r2, true)); - assertEquals(10.0, r1.transform(1, r2, true)); - assertEquals(0.0, r1.transform(2, r2, true)); - - Region r3 = new Region(-10, 10); - assertEquals(10.0, r1.transform(1, r3, true)); - } - - @Test - public void testRatio() throws Exception { - Region r1 = new Region(1, 2); - Region r2 = new Region(0, 100); - assertEquals(0.01, r1.ratio(r2)); - assertEquals(100.0, r2.ratio(r1)); - - r1 = new Region(0f, 21402646f); - r2 = new Region(0, 999); - - //assertTrue(r2.ratio(r1).doubleValue() > 0); - } - - @Test - public void testRegionRegionUnion() throws Exception { - Region r1 = new Region(1, 2); - Region r2 = new Region(0, 100); - - r1.union(r2); - assertEquals(0, r1.getMin().doubleValue(), 0); - assertEquals(100, r1.getMax().doubleValue(), 0); - } - - @Test - public void testRegionPointUnion() throws Exception { - Region r1 = new Region(1, 2); - - r1.union(0); - assertEquals(0, r1.getMin().doubleValue(), 0); - assertEquals(2, r1.getMax().doubleValue(), 0); - - r1.union(100); - assertEquals(0, r1.getMin().doubleValue(), 0); - assertEquals(100, r1.getMax().doubleValue(), 0); - } - -} diff --git a/androidplot-core/src/test/java/com/androidplot/SeriesRegistryTest.java b/androidplot-core/src/test/java/com/androidplot/SeriesRegistryTest.java deleted file mode 100644 index 7352193ffe249da362e8a082ddaeca9973f39067..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/SeriesRegistryTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot; - -import com.androidplot.test.AndroidplotTest; -import com.androidplot.ui.Formatter; -import com.androidplot.xy.BarFormatter; -import com.androidplot.xy.LineAndPointFormatter; -import com.androidplot.xy.SimpleXYSeries; -import com.androidplot.xy.XYSeriesRegistry; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -public class SeriesRegistryTest extends AndroidplotTest { - - SeriesRegistry seriesRegistry; - - @Before - public void setUp() throws Exception { - seriesRegistry = new XYSeriesRegistry(); - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testAdd() { - assertEquals(0, seriesRegistry.size()); - seriesRegistry.add(new SimpleXYSeries("s1"), new LineAndPointFormatter()); - assertEquals(1, seriesRegistry.size()); - } - - @Test - public void testAdd_failsOnNullArgument() throws Exception { - try { - seriesRegistry.add(null, null); - fail("IllegalArgumentException expected."); - } catch(IllegalArgumentException e) { - // expected - } - - try { - seriesRegistry.add(new SimpleXYSeries("s1"), null); - fail("IllegalArgumentException expected."); - } catch(IllegalArgumentException e) { - // expected - } - - try { - seriesRegistry.add(null, new LineAndPointFormatter()); - fail("IllegalArgumentException expected."); - } catch(IllegalArgumentException e) { - // expected - } - } - - @Test - public void testGet() { - Series s1 = new SimpleXYSeries("s1"); - Formatter f1 = new LineAndPointFormatter(); - Series s2 = new SimpleXYSeries("s2"); - Formatter f2 = new LineAndPointFormatter(); - Formatter f3 = new LineAndPointFormatter(); - seriesRegistry.add(s1, f1); - seriesRegistry.add(s1, f3); - seriesRegistry.add(s2, f2); - - - assertEquals(2, seriesRegistry.get(s1).size()); - assertEquals(1, seriesRegistry.get(s2).size()); - } - - @Test - public void testRemove() { - Series series = new SimpleXYSeries("s1"); - seriesRegistry.add(series, new LineAndPointFormatter()); - assertEquals(1, seriesRegistry.size()); - - seriesRegistry.remove(new SimpleXYSeries("s2")); - assertEquals(1, seriesRegistry.size()); - - seriesRegistry.remove(series); - assertEquals(0, seriesRegistry.size()); - } - - @Test - public void testClear() { - seriesRegistry.add(new SimpleXYSeries("s1"), new LineAndPointFormatter()); - seriesRegistry.add(new SimpleXYSeries("s2"), new LineAndPointFormatter()); - assertEquals(2, seriesRegistry.size()); - - seriesRegistry.clear(); - assertEquals(0, seriesRegistry.size()); - - } - - @Test - public void testContains() { - Series s1 = new SimpleXYSeries("s1"); - Series s2 = new SimpleXYSeries("s1"); - Series s3 = new SimpleXYSeries("s1"); - - seriesRegistry.add(s1, new LineAndPointFormatter()); - seriesRegistry.add(s2, new LineAndPointFormatter()); - - assertTrue(seriesRegistry.contains(s1, LineAndPointFormatter.class)); - assertFalse(seriesRegistry.contains(s1, BarFormatter.class)); - assertTrue(seriesRegistry.contains(s2, LineAndPointFormatter.class)); - assertFalse(seriesRegistry.contains(s3, LineAndPointFormatter.class)); - - } - -} diff --git a/androidplot-core/src/test/java/com/androidplot/pie/PieRendererTest.java b/androidplot-core/src/test/java/com/androidplot/pie/PieRendererTest.java deleted file mode 100644 index e504582a6459939a394037137164e96b2fa1eefe..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/pie/PieRendererTest.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.pie; - -import android.content.res.*; -import android.graphics.*; -import android.view.*; - -import com.androidplot.*; -import com.androidplot.test.*; -import com.androidplot.ui.*; - -import org.junit.*; -import org.mockito.*; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; -import static org.mockito.Mockito.*; - -public class PieRendererTest extends AndroidplotTest { - - RectF plotArea = new RectF(0, 0, 100, 100); - - @Mock - LayoutManager layoutManager; - - PieChart pieChart; - - @Mock - TypedArray typedArray; - - @Mock - SeriesRegistry seriesRegistry; - - @Mock - RenderStack renderStack; - - Canvas canvas; - - @Before - public void setUp() throws Exception { - pieChart = spy(new PieChart(getContext(), "My Pie")); - canvas = spy(new Canvas()); - } - - @Test - public void testDrawSegment_withoutTextPaintDoesntDrawLabel() throws Exception { - PieRenderer pieRenderer = spy(new PieRenderer(pieChart)); - Segment segment = spy(new Segment("My Segment", 100)); - - SegmentFormatter formatterWithoutTextPaint = new SegmentFormatter(Color.GREEN); - formatterWithoutTextPaint.setLabelPaint(null); - - pieRenderer.drawSegment( - new Canvas(), - plotArea, - segment, - formatterWithoutTextPaint, - 100, 100, 100); - - SegmentFormatter formatterWithTextPaint = new SegmentFormatter(Color.GREEN); - - pieRenderer.drawSegment( - canvas, - plotArea, - segment, - formatterWithTextPaint, - 100, 100, 100); - - verify(pieRenderer, times(0)) - .drawSegmentLabel( - any(Canvas.class), - any(PointF.class), - any(Segment.class), - eq(formatterWithoutTextPaint)); - - verify(pieRenderer, times(1)) - .drawSegmentLabel( - eq(canvas), - any(PointF.class), - eq(segment), - eq(formatterWithTextPaint)); - } - - @Test - public void testOnRender() throws Exception { - Segment segment = spy(new Segment("My Segment", 100)); - SegmentFormatter formatter = spy( - new SegmentFormatter(Color.GREEN, Color.GREEN, Color.GREEN, Color.GREEN)); - PieRenderer pr = formatter.getRendererInstance(pieChart); - PieRenderer renderer = spy(pr); - doReturn(renderer.getClass()).when(formatter).getRendererClass(); - doReturn(renderer).when(formatter).getRendererInstance(any(PieChart.class)); - pieChart.addSegment(segment, formatter); - renderer.onRender(canvas, plotArea, segment, formatter, renderStack); - } - - @Test - public void getContainingSegment_returnsCorrectSegment() throws Exception { - Segment segment1 = spy(new Segment("s1", 25)); - Segment segment2 = spy(new Segment("s2", 25)); - Segment segment3 = spy(new Segment("s3", 25)); - Segment segment4 = spy(new Segment("s4", 25)); - SegmentFormatter formatter = spy( - new SegmentFormatter(Color.GREEN, Color.GREEN, Color.GREEN, Color.GREEN)); - PieRenderer renderer = formatter.getRendererInstance(pieChart); - - pieChart.addSegment(segment1, formatter); - pieChart.addSegment(segment2, formatter); - pieChart.addSegment(segment3, formatter); - pieChart.addSegment(segment4, formatter); - - // southeast - assertEquals(segment1, renderer.getContainingSegment(new PointF(100, 100))); - - // southwest - assertEquals(segment2, renderer.getContainingSegment(new PointF(0, 100))); - - // northwest - assertEquals(segment3, renderer.getContainingSegment(new PointF(0, 0))); - - // northeast - assertEquals(segment4, renderer.getContainingSegment(new PointF(100, 0))); - - renderer.setStartDegs(90); - // southeast - assertEquals(segment2, renderer.getContainingSegment(new PointF(100, 100))); - - // southwest - assertEquals(segment3, renderer.getContainingSegment(new PointF(0, 100))); - - // northwest - assertEquals(segment4, renderer.getContainingSegment(new PointF(0, 0))); - - // northeast - assertEquals(segment1, renderer.getContainingSegment(new PointF(100, 0))); - } - - @Test - public void getContainingSegment_handlesSegmentsLargerThanHalfPie() throws Exception { - Segment segment1 = spy(new Segment("s1", 25)); - Segment segment2 = spy(new Segment("s2", 24)); - Segment segment3 = spy(new Segment("s3", 51)); - SegmentFormatter formatter = spy( - new SegmentFormatter(Color.GREEN, Color.GREEN, Color.GREEN, Color.GREEN)); - PieRenderer renderer = formatter.getRendererInstance(pieChart); - - pieChart.addSegment(segment1, formatter); - pieChart.addSegment(segment2, formatter); - pieChart.addSegment(segment3, formatter); - - // southeast - assertEquals(segment1, renderer.getContainingSegment(new PointF(100, 100))); - - // southwest - assertEquals(segment2, renderer.getContainingSegment(new PointF(0, 100))); - - // northwest - assertEquals(segment3, renderer.getContainingSegment(new PointF(0, 0))); - - // northeast - assertEquals(segment3, renderer.getContainingSegment(new PointF(100, 0))); - - renderer.setStartDegs(90); - // southeast - assertEquals(segment2, renderer.getContainingSegment(new PointF(100, 100))); - - // southwest - assertEquals(segment3, renderer.getContainingSegment(new PointF(0, 100))); - - // northwest - assertEquals(segment3, renderer.getContainingSegment(new PointF(0, 0))); - - // northeast - assertEquals(segment1, renderer.getContainingSegment(new PointF(100, 0))); - } - - @Test - public void testDegsToScreenDegs() throws Exception { - assertEquals(0f, PieRenderer.degsToScreenDegs(0)); - assertEquals(359f, PieRenderer.degsToScreenDegs(1)); - assertEquals(271f, PieRenderer.degsToScreenDegs(89)); - assertEquals(270f, PieRenderer.degsToScreenDegs(90)); - assertEquals(269f, PieRenderer.degsToScreenDegs(91)); - assertEquals(181f, PieRenderer.degsToScreenDegs(179)); - assertEquals(180f, PieRenderer.degsToScreenDegs(180)); - assertEquals(179f, PieRenderer.degsToScreenDegs(181)); - assertEquals(91f, PieRenderer.degsToScreenDegs(269)); - assertEquals(90f, PieRenderer.degsToScreenDegs(270)); - assertEquals(89f, PieRenderer.degsToScreenDegs(271)); - assertEquals(1f, PieRenderer.degsToScreenDegs(359)); - assertEquals(0f, PieRenderer.degsToScreenDegs(360)); - - } - - @Test - public void testSetDonutSize() throws Exception { - - Segment segment1 = spy(new Segment("s1", 25)); - Segment segment2 = spy(new Segment("s2", 25)); - Segment segment3 = spy(new Segment("s3", 25)); - Segment segment4 = spy(new Segment("s4", 25)); - - SegmentFormatter formatter = spy( - new SegmentFormatter(Color.GREEN, Color.GREEN, Color.GREEN, Color.GREEN)); - PieRenderer renderer = formatter.getRendererInstance(pieChart); - - pieChart.addSegment(segment1, formatter); - pieChart.addSegment(segment2, formatter); - pieChart.addSegment(segment3, formatter); - pieChart.addSegment(segment4, formatter); - - renderer.setDonutSize(0.25f, PieRenderer.DonutMode.PERCENT); - - renderer.onRender(canvas, plotArea, segment1, formatter, renderStack); - - // TODO: verify radials are drown at the correct offsets from center - //verify(canvas).drawLine(anyFloat(), anyFloat(), anyFloat(), anyFloat(), any(Paint.class)); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/test/AndroidplotTest.java b/androidplot-core/src/test/java/com/androidplot/test/AndroidplotTest.java deleted file mode 100644 index 4648ccd23093fb9265001ae429adff4374d13e19..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/test/AndroidplotTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.test; - -import android.content.Context; - -import com.androidplot.util.*; - -import org.junit.*; -import org.junit.runner.RunWith; -import org.mockito.junit.*; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.*; - -/** - * Base class for all Androidplot tests that make use of Android platform classes. - */ -@RunWith(MyTestRunner.class) -@Config(manifest=Config.NONE) -public abstract class AndroidplotTest { - - /** - * Enable mockito without requiring usage of {@link org.mockito.runners.MockitoJUnitRunner}. - * See: http://site.mockito.org/mockito/docs/current/org/mockito/junit/MockitoRule.html - */ - @Rule - public MockitoRule rule = MockitoJUnit.rule(); - - { - PixelUtils.init(getContext()); - } - - /** - * Convience method - to access the application context. - * @return - */ - protected Context getContext() { - return RuntimeEnvironment.application; - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/test/MyTestRunner.java b/androidplot-core/src/test/java/com/androidplot/test/MyTestRunner.java deleted file mode 100644 index f268087a22688621fdd46bfe6db09f148137689b..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/test/MyTestRunner.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.androidplot.test; - -import org.junit.runners.model.*; -import org.robolectric.*; - -public class MyTestRunner extends RobolectricTestRunner { - - /** - * Constructs a new instance of the test runner. - * - * @throws InitializationError if the test class is malformed - */ - public MyTestRunner(Class testClass) throws InitializationError - { - super(testClass); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/test/TestUtils.java b/androidplot-core/src/test/java/com/androidplot/test/TestUtils.java deleted file mode 100644 index 1f8f14575099ea5c60245e44253a5734423f7474..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/test/TestUtils.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.androidplot.test; - -import android.annotation.*; -import android.view.*; - -import com.androidplot.xy.*; - -import org.robolectric.shadows.*; - -import static org.robolectric.Shadows.shadowOf; - -/** - * Utilities to help with unit testing - */ -public abstract class TestUtils { - - public static XYSeries generateXYSeries(String title, int size) { - return generateXYSeries(title, size, 0, 1); - } - - /** - * Generate a series of random numbers within a min/max range - * @param title - * @param size - * @param min - * @param max - * @return - */ - public static XYSeries generateXYSeries(String title, int size, double min, double max) { - SimpleXYSeries series = new SimpleXYSeries(title); - for(int i = 0; i < size; i++) { - series.addLast(i, Math.random() * max - min); - } - return series; - } - - public static XYSeries generateXYSeriesWithNulls(String title, int size) { - SimpleXYSeries series = new SimpleXYSeries(title); - for(int i = 0; i < size; i++) { - if(Math.random() > 0.5) { - series.addLast(i, null); - } else { - series.addLast(i, Math.random()); - } - } - return series; - } - - /** - * Generate a two finger {@link MotionEvent}. - * @param finger1x - * @param finger1y - * @param finger2x - * @param finger2y - * @return - */ - @SuppressLint("NewApi") - public static MotionEvent newPointerDownEvent(int finger1x, int finger1y, int finger2x, int finger2y) { - MotionEvent me = MotionEvent.obtain(0, 0, MotionEvent.ACTION_POINTER_DOWN, finger1x, finger1y, 0); - ShadowMotionEvent sme = shadowOf(me); - //sme.setAction(MotionEvent.ACTION_POINTER_DOWN); - sme.setPointerIds(0, 1); - //sme.setLocation(finger1x, finger1y); - sme.setPointer2(finger2x, finger2y); - return me; - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/ui/DynamicTableModelTest.java b/androidplot-core/src/test/java/com/androidplot/ui/DynamicTableModelTest.java deleted file mode 100644 index 18e12af4445da6c542ef4b09e11f306671a29c59..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/ui/DynamicTableModelTest.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.ui; - -import android.graphics.RectF; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; - -import java.util.Iterator; - -import static junit.framework.Assert.assertEquals; - -@RunWith(RobolectricTestRunner.class) -public class DynamicTableModelTest { - - @Test - public void testConstructor() throws Exception { - TableModel model = new DynamicTableModel(5, 5, TableOrder.COLUMN_MAJOR); - // TODO - } - - @Test - public void testGetCellRect() throws Exception { - - // square table, both rows and columns defined: - DynamicTableModel model = new DynamicTableModel(5, 5); - RectF tableRect = new RectF(0, 0, 1000, 2000); - RectF cellRect = model.getCellRect(tableRect, 10); - assertEquals(200f, cellRect.width()); - - // only rows defined: - model = new DynamicTableModel(5, 0); - cellRect = model.getCellRect(tableRect, 10); - assertEquals(200f, cellRect.width()); - - // only columns defined: - model = new DynamicTableModel(0, 5); - cellRect = model.getCellRect(tableRect, 10); - assertEquals(400f, cellRect.height()); - } - - @Test public void testIterator() throws Exception { - TableModel model = new DynamicTableModel(2, 2); - - RectF tableRect = new RectF(0, 0, 1000, 2000); - - // should stop at 4 iterations since the table can only hold that many: - Iterator it = model.getIterator(tableRect, 10); - int iterations = 0; - while(it.hasNext()) { - it.next(); - iterations++; - } - assertEquals(4, iterations); - - // now set a dynamic number of columns. iterations should equal however - // many elements we throw at it: - model = new DynamicTableModel(2, 0); - it = model.getIterator(tableRect, 10); - iterations = 0; - while(it.hasNext()) { - it.next(); - iterations++; - } - assertEquals(10, iterations); - - - } - - @Test - public void testRowMajorIteration() throws Exception { - - // square table, both rows and columns defined: - TableModel model = new DynamicTableModel(2, 2); - RectF tableRect = new RectF(0, 0, 1000, 2000); - int createdCells = 4; - Iterator it = model.getIterator(tableRect, createdCells); - - - // 2x2: - // cell 0 (top-left - RectF cellRect = it.next(); - assertEquals(500f, cellRect.width()); - assertEquals(1000f, cellRect.height()); - assertEquals(0f, cellRect.left); - assertEquals(0f, cellRect.top); - assertEquals(500f, cellRect.right); - assertEquals(1000f, cellRect.bottom); - - // cell 1 (top-right) - cellRect = it.next(); - assertEquals(500f, cellRect.width()); - assertEquals(1000f, cellRect.height()); - assertEquals(500f, cellRect.left); - assertEquals(0f, cellRect.top); - assertEquals(1000f, cellRect.right); - assertEquals(1000f, cellRect.bottom); - - // cell 2 (bottom-left) - cellRect = it.next(); - assertEquals(500f, cellRect.width()); - assertEquals(1000f, cellRect.height()); - assertEquals(0f, cellRect.left); - assertEquals(1000f, cellRect.top); - assertEquals(500f, cellRect.right); - assertEquals(2000f, cellRect.bottom); - - // cell 3 (bottom-right) - cellRect = it.next(); - assertEquals(500f, cellRect.width()); - assertEquals(1000f, cellRect.height()); - assertEquals(500f, cellRect.left); - assertEquals(1000f, cellRect.top); - assertEquals(1000f, cellRect.right); - assertEquals(2000f, cellRect.bottom); - - // 2xN: - /*model = new DynamicTableModel(2, 0); - tableRect = new RectF(0, 0, 1000, 2000); - createdCells = 4; - it = model.getIterator(tableRect, createdCells);*/ - - - - } - - - @Test - public void testColumnMajorIteration() throws Exception { - - // square table, both rows and columns defined: - TableModel model = new DynamicTableModel(2, 2, TableOrder.COLUMN_MAJOR); - RectF tableRect = new RectF(0, 0, 1000, 2000); - int createdCells = 4; - Iterator it = model.getIterator(tableRect, createdCells); - - - // 2x2 fixed: - // cell 0 (top-left - RectF cellRect = it.next(); - assertEquals(500f, cellRect.width()); - assertEquals(1000f, cellRect.height()); - assertEquals(0f, cellRect.left); - assertEquals(0f, cellRect.top); - assertEquals(500f, cellRect.right); - assertEquals(1000f, cellRect.bottom); - - // cell 1 (bottom-left) - cellRect = it.next(); - assertEquals(500f, cellRect.width()); - assertEquals(1000f, cellRect.height()); - assertEquals(0f, cellRect.left); - assertEquals(1000f, cellRect.top); - assertEquals(500f, cellRect.right); - assertEquals(2000f, cellRect.bottom); - - // cell 2 (bottom-left) - cellRect = it.next(); - assertEquals(500f, cellRect.width()); - assertEquals(1000f, cellRect.height()); - assertEquals(500f, cellRect.left); - assertEquals(0f, cellRect.top); - assertEquals(1000f, cellRect.right); - assertEquals(1000f, cellRect.bottom); - - // cell 3 (bottom-right) - cellRect = it.next(); - assertEquals(500f, cellRect.width()); - assertEquals(1000f, cellRect.height()); - assertEquals(500f, cellRect.left); - assertEquals(1000f, cellRect.top); - assertEquals(1000f, cellRect.right); - assertEquals(2000f, cellRect.bottom); - } - - @Test - public void testSingleRowIteration() throws Exception { - // square table, both rows and columns defined: - TableModel model = new DynamicTableModel(0, 1); - RectF tableRect = new RectF(0, 0, 1000, 1000); - int createdCells = 4; - Iterator it = model.getIterator(tableRect, createdCells); - - - - // 2x2 fixed: - // cell 0 (top-left - RectF cellRect = it.next(); - assertEquals(250f, cellRect.width()); - assertEquals(1000f, cellRect.height()); - assertEquals(0f, cellRect.left); - assertEquals(0f, cellRect.top); - assertEquals(250f, cellRect.right); - assertEquals(1000f, cellRect.bottom); - - // cell 1 - cellRect = it.next(); - assertEquals(250f, cellRect.width()); - assertEquals(1000f, cellRect.height()); - assertEquals(250f, cellRect.left); - assertEquals(0f, cellRect.top); - assertEquals(500f, cellRect.right); - assertEquals(1000f, cellRect.bottom); - - // cell 2 - cellRect = it.next(); - assertEquals(250f, cellRect.width()); - assertEquals(1000f, cellRect.height()); - assertEquals(500f, cellRect.left); - assertEquals(0f, cellRect.top); - assertEquals(750f, cellRect.right); - assertEquals(1000f, cellRect.bottom); - - // cell 3 - cellRect = it.next(); - assertEquals(250f, cellRect.width()); - assertEquals(1000f, cellRect.height()); - assertEquals(750f, cellRect.left); - assertEquals(0f, cellRect.top); - assertEquals(1000f, cellRect.right); - assertEquals(1000f, cellRect.bottom); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/ui/FixedTableModelTest.java b/androidplot-core/src/test/java/com/androidplot/ui/FixedTableModelTest.java deleted file mode 100644 index bd9488bcee429e35dde794df9a9ef6a4cd1f6043..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/ui/FixedTableModelTest.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.ui; - -import android.graphics.RectF; -import com.androidplot.test.AndroidplotTest; -import org.junit.Test; -import java.util.Iterator; -import static junit.framework.Assert.*; - -public class FixedTableModelTest extends AndroidplotTest { - - @Test - public void testConstructor() throws Exception { - FixedTableModel model = new FixedTableModel(100, 100, null); - // TODO - } - - @Test - public void testIterator() throws Exception { - FixedTableModel model = new FixedTableModel(100, 100, TableOrder.COLUMN_MAJOR); - - RectF tableRect = new RectF(0, 0, 1000, 2000); - - Iterator it = model.getIterator(tableRect, 5); - - assertTrue(it.hasNext()); - RectF cellRect = it.next(); - - assertTrue(it.hasNext()); - cellRect = it.next(); - - assertTrue(it.hasNext()); - cellRect = it.next(); - - assertTrue(it.hasNext()); - cellRect = it.next(); - - assertTrue(it.hasNext()); - cellRect = it.next(); - - assertFalse(it.hasNext()); - try { - cellRect = it.next(); - fail("Expected IndexOutOfBoundsException"); - } catch(IndexOutOfBoundsException ex) { - // this was expected - } - } - - @Test - public void testColumnMajor() throws Exception { - FixedTableModel model = new FixedTableModel(300, 500, TableOrder.COLUMN_MAJOR); - - RectF tableRect = new RectF(0, 0, 1000, 2000); - - // test the numElement limit: - Iterator it = model.getIterator(tableRect, 5); - assertTrue(it.hasNext()); - RectF cellRect = it.next(); - assertEquals(0f, cellRect.left); - assertEquals(0f, cellRect.top); - assertEquals(300f, cellRect.right); - assertEquals(500f, cellRect.bottom); - - assertTrue(it.hasNext()); - cellRect = it.next(); - assertEquals(300f, cellRect.left); - assertEquals(0f, cellRect.top); - assertEquals(600f, cellRect.right); - assertEquals(500f, cellRect.bottom); - - assertTrue(it.hasNext()); - cellRect = it.next(); - assertEquals(600f, cellRect.left); - assertEquals(0f, cellRect.top); - assertEquals(900f, cellRect.right); - assertEquals(500f, cellRect.bottom); - - assertTrue(it.hasNext()); - cellRect = it.next(); - assertEquals(0f, cellRect.left); - assertEquals(500f, cellRect.top); - assertEquals(300f, cellRect.right); - assertEquals(1000f, cellRect.bottom); - - assertTrue(it.hasNext()); - cellRect = it.next(); - assertEquals(300f, cellRect.left); - assertEquals(500f, cellRect.top); - assertEquals(600f, cellRect.right); - assertEquals(1000f, cellRect.bottom); - - assertFalse(it.hasNext()); - - // test border limit: - it = model.getIterator(tableRect, 25); - assertTrue(it.hasNext()); - cellRect = it.next(); - assertEquals(0f, cellRect.left); - assertEquals(0f, cellRect.top); - assertEquals(300f, cellRect.right); - assertEquals(500f, cellRect.bottom); - - assertTrue(it.hasNext()); - cellRect = it.next(); - assertEquals(300f, cellRect.left); - assertEquals(0f, cellRect.top); - assertEquals(600f, cellRect.right); - assertEquals(500f, cellRect.bottom); - - assertTrue(it.hasNext()); - cellRect = it.next(); - assertEquals(600f, cellRect.left); - assertEquals(0f, cellRect.top); - assertEquals(900f, cellRect.right); - assertEquals(500f, cellRect.bottom); - - assertTrue(it.hasNext()); - cellRect = it.next(); - assertEquals(0f, cellRect.left); - assertEquals(500f, cellRect.top); - assertEquals(300f, cellRect.right); - assertEquals(1000f, cellRect.bottom); - - assertTrue(it.hasNext()); - cellRect = it.next(); - assertEquals(300f, cellRect.left); - assertEquals(500f, cellRect.top); - assertEquals(600f, cellRect.right); - assertEquals(1000f, cellRect.bottom); - - assertTrue(it.hasNext()); - cellRect = it.next(); - assertEquals(600f, cellRect.left); - assertEquals(500f, cellRect.top); - assertEquals(900f, cellRect.right); - assertEquals(1000f, cellRect.bottom); - - assertTrue(it.hasNext()); - cellRect = it.next(); - assertEquals(0f, cellRect.left); - assertEquals(1000f, cellRect.top); - assertEquals(300f, cellRect.right); - assertEquals(1500f, cellRect.bottom); - - assertTrue(it.hasNext()); - cellRect = it.next(); - assertEquals(300f, cellRect.left); - assertEquals(1000f, cellRect.top); - assertEquals(600f, cellRect.right); - assertEquals(1500f, cellRect.bottom); - - assertTrue(it.hasNext()); - cellRect = it.next(); - assertEquals(600f, cellRect.left); - assertEquals(1000f, cellRect.top); - assertEquals(900f, cellRect.right); - assertEquals(1500f, cellRect.bottom); - - assertTrue(it.hasNext()); - cellRect = it.next(); - assertEquals(0f, cellRect.left); - assertEquals(1500f, cellRect.top); - assertEquals(300f, cellRect.right); - assertEquals(2000f, cellRect.bottom); - - assertTrue(it.hasNext()); - cellRect = it.next(); - assertEquals(300f, cellRect.left); - assertEquals(1500f, cellRect.top); - assertEquals(600f, cellRect.right); - assertEquals(2000f, cellRect.bottom); - - assertTrue(it.hasNext()); - cellRect = it.next(); - assertEquals(600f, cellRect.left); - assertEquals(1500f, cellRect.top); - assertEquals(900f, cellRect.right); - assertEquals(2000f, cellRect.bottom); - - //we've reached the limit - assertFalse(it.hasNext()); - } - - @Test - public void testRowMajor() throws Exception { - FixedTableModel model = new FixedTableModel(300, 500, TableOrder.ROW_MAJOR); - - RectF tableRect = new RectF(0, 0, 1000, 2000); - - // test the numElement limit: - Iterator it = model.getIterator(tableRect, 5); - assertTrue(it.hasNext()); - RectF cellRect = it.next(); - assertEquals(0f, cellRect.left); - assertEquals(0f, cellRect.top); - assertEquals(300f, cellRect.right); - assertEquals(500f, cellRect.bottom); - - assertTrue(it.hasNext()); - cellRect = it.next(); - assertEquals(0f, cellRect.left); - assertEquals(500f, cellRect.top); - assertEquals(300f, cellRect.right); - assertEquals(1000f, cellRect.bottom); - - assertTrue(it.hasNext()); - cellRect = it.next(); - assertEquals(0f, cellRect.left); - assertEquals(1000f, cellRect.top); - assertEquals(300f, cellRect.right); - assertEquals(1500f, cellRect.bottom); - - assertTrue(it.hasNext()); - cellRect = it.next(); - assertEquals(0f, cellRect.left); - assertEquals(1500f, cellRect.top); - assertEquals(300f, cellRect.right); - assertEquals(2000f, cellRect.bottom); - - // next column over - assertTrue(it.hasNext()); - cellRect = it.next(); - assertEquals(300f, cellRect.left); - assertEquals(0f, cellRect.top); - assertEquals(600f, cellRect.right); - assertEquals(500f, cellRect.bottom); - } -} \ No newline at end of file diff --git a/androidplot-core/src/test/java/com/androidplot/ui/RenderStackTest.java b/androidplot-core/src/test/java/com/androidplot/ui/RenderStackTest.java deleted file mode 100644 index 59bab3805c8d77a3f5a146dc972557c95f13d993..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/ui/RenderStackTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.androidplot.ui; - -import com.androidplot.Plot; -import com.androidplot.SeriesRegistry; -import com.androidplot.test.AndroidplotTest; -import com.androidplot.xy.LineAndPointFormatter; -import com.androidplot.xy.LineAndPointRenderer; -import com.androidplot.xy.XYSeries; -import com.google.common.collect.Lists; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class RenderStackTest extends AndroidplotTest { - - @Mock Plot plot; - @Mock SeriesRegistry seriesRegistry; - - @Before - public void before() { - when(plot.getRegistry()).thenReturn(seriesRegistry); - } - - @Test - public void disable_disablesElements_ofSpecifiedRendererOnly() { - final SeriesBundle s1 = new SeriesBundle(mock(XYSeries.class), - new LineAndPointFormatter()); - final SeriesBundle s2 = new SeriesBundle(mock(XYSeries.class), - new LineAndPointFormatter()); - when(seriesRegistry.getSeriesAndFormatterList()).thenReturn(Lists.newArrayList(s1, s2)); - RenderStack renderStack = new RenderStack<>(plot); - - renderStack.sync(); - assertEquals(2, renderStack.getElements().size()); - for(RenderStack.StackElement element : renderStack.getElements()) { - assertTrue(element.isEnabled()); - } - - renderStack.disable(LineAndPointRenderer.class); - assertEquals(2, renderStack.getElements().size()); - for(RenderStack.StackElement element : renderStack.getElements()) { - assertFalse(element.isEnabled()); - } - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/ui/widget/TextLabelWidgetTest.java b/androidplot-core/src/test/java/com/androidplot/ui/widget/TextLabelWidgetTest.java deleted file mode 100644 index 6ed81b7bbece31fe46473b14076e53282df2b0d1..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/ui/widget/TextLabelWidgetTest.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.androidplot.ui.widget; - -import android.graphics.Canvas; -import android.graphics.Paint; -import android.graphics.RectF; - -import com.androidplot.test.AndroidplotTest; -import com.androidplot.ui.LayoutManager; -import com.androidplot.ui.Size; -import com.androidplot.ui.TextOrientation; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InOrder; -import org.mockito.Mock; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyFloat; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -public class TextLabelWidgetTest extends AndroidplotTest { - - @Mock - LayoutManager layoutManager; - - @Mock - Size size; - - @Mock - Canvas canvas; - - @Mock - RectF rectF; - - private TextLabelWidget textLabelWidget; - - @Before - public void before() { - textLabelWidget = spy(new TextLabelWidget(layoutManager, size)); - } - - @Test - public void onMetricsChanged_invokesPack_ifAutopackEnabled() { - textLabelWidget.setAutoPackEnabled(true); - textLabelWidget.onMetricsChanged(size, size); - verify(textLabelWidget, times(2)).pack(); - } - - @Test - public void onMetricsChanged_doesNotInvokePack_ifAutopackDisabled() { - textLabelWidget.setAutoPackEnabled(false); - textLabelWidget.onMetricsChanged(size, size); - verify(textLabelWidget, never()).pack(); - } - - @Test - public void doOnDraw_rotatesThenDraws_ifVerticalAscending() { - textLabelWidget.setText("this is a test"); - textLabelWidget.setOrientation(TextOrientation.VERTICAL_ASCENDING); - textLabelWidget.doOnDraw(canvas, rectF); - - InOrder inOrder = inOrder(canvas); - inOrder.verify(canvas).rotate(-90); - inOrder.verify(canvas).drawText(eq(textLabelWidget.getText()), anyFloat(), anyFloat(), any(Paint.class)); - } - - @Test - public void doOnDraw_rotatesThenDraws_ifVerticalDescending() { - textLabelWidget.setText("this is a test"); - textLabelWidget.setOrientation(TextOrientation.VERTICAL_DESCENDING); - textLabelWidget.doOnDraw(canvas, rectF); - - InOrder inOrder = inOrder(canvas); - inOrder.verify(canvas).rotate(90); - inOrder.verify(canvas).drawText(eq(textLabelWidget.getText()), anyFloat(), anyFloat(), any(Paint.class)); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/ui/widget/WidgetTest.java b/androidplot-core/src/test/java/com/androidplot/ui/widget/WidgetTest.java deleted file mode 100644 index 408edc33158c4eb71a4be7ea5d2ec29e3c014df3..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/ui/widget/WidgetTest.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.androidplot.ui.widget; - -import android.graphics.Canvas; -import android.graphics.RectF; -import android.support.annotation.NonNull; - -import com.androidplot.test.AndroidplotTest; -import com.androidplot.ui.Anchor; -import com.androidplot.ui.HorizontalPositioning; -import com.androidplot.ui.LayoutManager; -import com.androidplot.ui.PositionMetrics; -import com.androidplot.ui.Size; -import com.androidplot.ui.SizeMetric; -import com.androidplot.ui.SizeMode; -import com.androidplot.ui.VerticalPositioning; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InOrder; -import org.mockito.Mock; -import org.mockito.Mockito; - -import static junit.framework.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.isNull; -import static org.mockito.ArgumentMatchers.nullable; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class WidgetTest extends AndroidplotTest { - - @Mock - LayoutManager layoutManager; - - @Mock - Size size; - - @Mock - Canvas canvas; - - Widget widget; - - PositionMetrics positionMetrics; - - @Before - public void before() { - - positionMetrics = new PositionMetrics( - 0, HorizontalPositioning.ABSOLUTE_FROM_LEFT, - 0, VerticalPositioning.ABSOLUTE_FROM_TOP, Anchor.LEFT_TOP); - when(size.getHeight()).thenReturn(new SizeMetric(100, SizeMode.ABSOLUTE)); - when(size.getWidth()).thenReturn(new SizeMetric(100, SizeMode.ABSOLUTE)); - widget = spy(new TestWidget(layoutManager, size)); - widget.setPositionMetrics(positionMetrics); - widget.refreshLayout(); - } - - @Test - public void setGetAnchor_setsAndGetsAnchor() { - widget.setAnchor(Anchor.LEFT_TOP); - assertEquals(Anchor.LEFT_TOP, widget.getAnchor()); - - widget.setAnchor(Anchor.RIGHT_BOTTOM); - assertEquals(Anchor.RIGHT_BOTTOM, widget.getAnchor()); - } - - @Test - public void position_withoutAnchor_updatesPositionWithExistingAnchor() { - final Anchor existingAnchor = widget.getAnchor(); - widget.position(1, HorizontalPositioning.ABSOLUTE_FROM_RIGHT, - 1, VerticalPositioning.ABSOLUTE_FROM_BOTTOM); - - assertEquals(existingAnchor, widget.getAnchor()); - assertEquals(1F, widget.getPositionMetrics().getYPositionMetric().getValue()); - assertEquals(1F, widget.getPositionMetrics().getXPositionMetric().getValue()); - } - - @Test - public void position_withAnchor_updatesPositionWithNewAnchor() { - final Anchor newAnchor = Anchor.CENTER; - widget.position(1, HorizontalPositioning.ABSOLUTE_FROM_RIGHT, - 1, VerticalPositioning.ABSOLUTE_FROM_BOTTOM, newAnchor); - - assertEquals(newAnchor, widget.getAnchor()); - assertEquals(1F, widget.getPositionMetrics().getYPositionMetric().getValue()); - assertEquals(1F, widget.getPositionMetrics().getXPositionMetric().getValue()); - } - - @Test - public void draw_sizeChanged_invokesOnResizeBeforeDoOnDraw() { - InOrder inOrder = Mockito.inOrder(widget); - - widget.draw(canvas); - - inOrder.verify(widget).onResize(isNull(RectF.class), any(RectF.class)); - inOrder.verify(widget).doOnDraw(eq(canvas), any(RectF.class)); - verify(widget).onResize(isNull(RectF.class), any(RectF.class)); - } - - static class TestWidget extends Widget { - - public TestWidget(@NonNull LayoutManager layoutManager, @NonNull Size size) { - super(layoutManager, size); - } - - @Override - protected void doOnDraw(Canvas canvas, RectF widgetRect) { - // nothing to do - } - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/util/FastNumberTest.java b/androidplot-core/src/test/java/com/androidplot/util/FastNumberTest.java deleted file mode 100644 index 8bca2a38c9fac15e150977d5ea025fb96feb96a3..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/util/FastNumberTest.java +++ /dev/null @@ -1,136 +0,0 @@ -package com.androidplot.util; - -import android.annotation.SuppressLint; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -@SuppressWarnings({"UnnecessaryBoxing", "ObjectEqualsNull", "EqualsBetweenInconvertibleTypes", "EqualsWithItself", "NumberEquality"}) -@SuppressLint("UseValueOf") -public class FastNumberTest { - - private static final Number[] NUMBERS = new Number[]{ - new Integer(0), - new Integer(1), - new Integer(-1), - new Integer(Integer.MAX_VALUE), - new Integer(Integer.MIN_VALUE), - - new Long(0), - new Long(1), - new Long(-1), - new Long(Long.MAX_VALUE), - new Long(Long.MIN_VALUE), - - new Double(0), - new Double(1), - new Double(-1), - new Double(87654321.12345d), - new Double(0.0002f), - new Double(Double.MAX_VALUE), - new Double(Double.MIN_VALUE), - - new Float(0), - new Float(1.0f), - new Float(-1.0f), - new Float(8765.4321f), - new Float(1098.576f), - new Float(Float.MIN_VALUE), - new Float(Float.MAX_VALUE), - }; - - private static final Number[] NUMBERS_CLONE = new Number[]{ - new Integer(0), - new Integer(1), - new Integer(-1), - new Integer(Integer.MAX_VALUE), - new Integer(Integer.MIN_VALUE), - - new Long(0), - new Long(1), - new Long(-1), - new Long(Long.MAX_VALUE), - new Long(Long.MIN_VALUE), - - new Double(0), - new Double(1), - new Double(-1), - new Double(87654321.12345d), - new Double(0.0002f), - new Double(Double.MAX_VALUE), - new Double(Double.MIN_VALUE), - - new Float(0), - new Float(1.0f), - new Float(-1.0f), - new Float(8765.4321f), - new Float(1098.576f), - new Float(Float.MIN_VALUE), - new Float(Float.MAX_VALUE), - }; - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void orNull_returnsNull_ifNullNumber() { - //noinspection ConstantConditions - assertNull(FastNumber.orNull(null)); - } - - @Test - public void equals_returnsTrue_ifFromSameNumberInstance() { - for (Number number : NUMBERS) { - assertTrue("Equality test failed on " + number, FastNumber.orNull(number).equals(FastNumber.orNull(number))); - } - } - - @Test - public void equals_returnsTrue_ifFromSameNumber() { - assertEquals("misconfigured test values", NUMBERS.length, NUMBERS_CLONE.length); - for (int i = 0; i < NUMBERS.length; i++) { - assertEquals("misconfigured test values", NUMBERS[i], NUMBERS_CLONE[i]); - assertTrue(FastNumber.orNull(NUMBERS[i]).equals(FastNumber.orNull(NUMBERS_CLONE[i]))); - } - } - - @Test - public void equals_returnsFalse_ifNumberIsDifferent() { - for (int i = 0; i < NUMBERS.length; i++) { - for (int j = 0; j < NUMBERS.length; j++) { - if (j == i) { - continue; - } - assertNotEquals("duplicate test values at index " + i + " and " + j, NUMBERS[i], NUMBERS[j]); - assertFalse(FastNumber.orNull(NUMBERS[i]).equals(FastNumber.orNull(NUMBERS[j]))); - } - } - } - - @Test - public void hashCode_isEqual_ifInstanceIsEqual() { - for (Number number : NUMBERS) { - for (Number number2 : NUMBERS) { - FastNumber fastNumber1 = FastNumber.orNull(number); - FastNumber fastNumber2 = FastNumber.orNull(number2); - if (fastNumber1.equals(fastNumber2)) { - assertEquals(fastNumber1.hashCode(), fastNumber2.hashCode()); - } - } - } - } - -} \ No newline at end of file diff --git a/androidplot-core/src/test/java/com/androidplot/util/InstrumentedXYPlot.java b/androidplot-core/src/test/java/com/androidplot/util/InstrumentedXYPlot.java deleted file mode 100644 index ab1a71b49334c7609b3803668350f1d862b1b244..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/util/InstrumentedXYPlot.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.androidplot.util; - -import android.content.*; -import android.graphics.*; - -import com.androidplot.xy.*; - -/** - * Created by halfhp on 10/21/16. - */ -public class InstrumentedXYPlot extends XYPlot { - - // may be set by consumers if necessary - public Canvas canvas = new Canvas(); - - public InstrumentedXYPlot(Context context) { - super(context, "a test plot"); - } - - @Override - public void redraw() { - super.onDraw(canvas); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/util/LayerHashTest.java b/androidplot-core/src/test/java/com/androidplot/util/LayerHashTest.java deleted file mode 100644 index 3dbd69704f913ff87697c195a7ff744003c5fce5..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/util/LayerHashTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.util; - -import org.junit.*; - -import static junit.framework.Assert.assertEquals; - -public class LayerHashTest { - - Object obj1 = new Object(); - Object obj2 = new Object(); - Object obj3 = new Object(); - - LayerHash layerHash; - - @Before - public void setUp() throws Exception { - layerHash = new LayerHash<>(); - layerHash.addToBottom(obj1, obj1); - layerHash.addToBottom(obj2, obj2); - layerHash.addToBottom(obj3, obj3); - - assertEquals(obj1, layerHash.getTop()); - assertEquals(obj3, layerHash.getBottom()); - } - - // "top" == last element in the list: - @Test - public void moveUp() { - layerHash.moveUp(obj3); - assertEquals(obj1, layerHash.getTop()); - assertEquals(obj3, layerHash.getBeneath(obj1)); - assertEquals(obj2, layerHash.getBeneath(obj3)); - - layerHash.moveUp(obj3); - assertEquals(obj3, layerHash.getTop()); - assertEquals(obj1, layerHash.getBeneath(obj3)); - assertEquals(obj2, layerHash.getBeneath(obj1)); - - layerHash.moveUp(obj3); - assertEquals(obj3, layerHash.getTop()); - assertEquals(obj1, layerHash.getBeneath(obj3)); - assertEquals(obj2, layerHash.getBeneath(obj1)); - } - - // "bottom" == first element in the list: - @Test - public void moveDown() { - layerHash.moveDown(obj1); - assertEquals(obj3, layerHash.getKeysAsList().get(0)); - assertEquals(obj1, layerHash.getKeysAsList().get(1)); - assertEquals(obj2, layerHash.getKeysAsList().get(2)); - - layerHash.moveDown(obj1); - assertEquals(obj1, layerHash.getKeysAsList().get(0)); - assertEquals(obj3, layerHash.getKeysAsList().get(1)); - assertEquals(obj2, layerHash.getKeysAsList().get(2)); - - layerHash.moveDown(obj1); - assertEquals(obj1, layerHash.getKeysAsList().get(0)); - assertEquals(obj3, layerHash.getKeysAsList().get(1)); - assertEquals(obj2, layerHash.getKeysAsList().get(2)); - } - - @Test - public void moveAbove() { - layerHash.moveAbove(obj2, obj1); - assertEquals(obj3, layerHash.getKeysAsList().get(0)); - assertEquals(obj1, layerHash.getKeysAsList().get(1)); - assertEquals(obj2, layerHash.getKeysAsList().get(2)); - } - - @Test - public void moveBeneath() { - layerHash.moveBeneath(obj1, obj2); - assertEquals(obj3, layerHash.getKeysAsList().get(0)); - assertEquals(obj1, layerHash.getKeysAsList().get(1)); - assertEquals(obj2, layerHash.getKeysAsList().get(2)); - } - - @Test - public void addToTop() { - Object obj = new Object(); - layerHash.addToTop(obj, obj); - assertEquals(obj, layerHash.getTop()); - assertEquals(obj3, layerHash.getKeysAsList().get(0)); - assertEquals(obj2, layerHash.getKeysAsList().get(1)); - assertEquals(obj1, layerHash.getKeysAsList().get(2)); - assertEquals(obj, layerHash.getKeysAsList().get(3)); - } - - @Test - public void moveToTop() { - layerHash.moveToTop(obj3); - assertEquals(obj3, layerHash.getTop()); - assertEquals(obj1, layerHash.getBeneath(obj3)); - assertEquals(obj2, layerHash.getBeneath(obj1)); - } - - @Test - public void moveToBottom() { - layerHash.moveToBottom(obj1); - assertEquals(obj1, layerHash.getBottom()); - assertEquals(obj3, layerHash.getAbove(obj1)); - assertEquals(obj2, layerHash.getAbove(obj3)); - } - - @Test - public void remove() { - layerHash.remove(obj2); - assertEquals(2, layerHash.size()); - assertEquals(obj1, layerHash.getAbove(obj3)); - } - -} diff --git a/androidplot-core/src/test/java/com/androidplot/util/LinkedLayerListOrganizerTest.java b/androidplot-core/src/test/java/com/androidplot/util/LinkedLayerListOrganizerTest.java deleted file mode 100644 index a554d9d6ea0431e8aac71f56f0509488f31b4de2..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/util/LinkedLayerListOrganizerTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.util; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.util.LinkedList; - -import static junit.framework.Assert.assertEquals; - -public class LinkedLayerListOrganizerTest { - @Before - public void setUp() throws Exception { - - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testMoveToTop() throws Exception { - - } - - @Test - public void testMoveAbove() throws Exception { - - } - - @Test - public void testMoveBeneath() throws Exception { - - } - - @Test - public void testMoveToBottom() throws Exception { - Object obj1 = new Object(); - Object obj2 = new Object(); - Object obj3 = new Object(); - LinkedList list = new LinkedList(); - - list.add(obj1); - list.add(obj2); - list.add(obj3); - - assertEquals(obj1, list.getFirst()); - assertEquals(obj3, list.getLast()); - - LayerListOrganizer organizer = new LayerListOrganizer(list); - - organizer.moveToBottom(obj3); - - assertEquals(obj2, list.getLast()); - assertEquals(obj3, list.getFirst()); - - } - - @Test - public void testMoveUp() throws Exception { - - } - - @Test - public void testMoveDown() throws Exception { - - } - - @Test - public void testAddFirst() throws Exception { - - } - - @Test - public void testAddLast() throws Exception { - - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/util/PixelUtilsTest.java b/androidplot-core/src/test/java/com/androidplot/util/PixelUtilsTest.java deleted file mode 100644 index 49ef070ef62cbe0c877b9ed25c7b731d3708bf82..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/util/PixelUtilsTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.util; - -import org.junit.Test; -import java.util.regex.Pattern; -import static junit.framework.Assert.assertTrue; - -public class PixelUtilsTest { - - @org.junit.After - public void tearDown() throws Exception { - - } - - @Test - public void testDimensionPattern() { - Pattern DIMENSION_PATTERN = Pattern.compile(PixelUtils.DIMENSION_REGEX); - assertTrue("Dimension failed dimension pattern match", DIMENSION_PATTERN.matcher("20dp").matches()); - assertTrue("Negative dimension failed dimension pattern match", DIMENSION_PATTERN.matcher("-20dp").matches()); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/util/PlotStatisticsTest.java b/androidplot-core/src/test/java/com/androidplot/util/PlotStatisticsTest.java deleted file mode 100644 index b063235a29648c2dcadbe3a0ad8c4e8d22cdc9cf..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/util/PlotStatisticsTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.util; - -import android.graphics.Canvas; -import android.graphics.Paint; - -import com.androidplot.Plot; -import com.androidplot.test.AndroidplotTest; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyFloat; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class PlotStatisticsTest extends AndroidplotTest { - - @Mock - Canvas canvas; - - @Mock - Paint paint; - - @Mock - Plot plot; - - @InjectMocks - PlotStatistics ps = new PlotStatistics(1, true); - - @Before - public void before() { - when(plot.getDisplayDimensions()).thenReturn(new DisplayDimensions()); - } - - @Test - public void annotatePlot_annotates_ifEnabled() { - ps.onAfterDraw(plot, canvas); - verify(canvas).drawText(anyString(), anyFloat(), anyFloat(), any(Paint.class)); - } - - @Test - public void annotatePlot_doesNotAnnotate_ifDisabled() { - ps.setEnabled(false); - ps.onAfterDraw(plot, canvas); - verify(canvas, never()).drawText(anyString(), anyFloat(), anyFloat(), any(Paint.class)); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/util/SeriesUtilsTest.java b/androidplot-core/src/test/java/com/androidplot/util/SeriesUtilsTest.java deleted file mode 100644 index df9014cd4c2e9a23bf398f0e10597a82b5e781d1..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/util/SeriesUtilsTest.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Copyright 2016 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.util; - -import com.androidplot.*; -import com.androidplot.xy.*; - -import org.junit.Test; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNull; -import static junit.framework.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class SeriesUtilsTest { - - // 8 element lists: - final List LINEAR = Arrays.asList(new Number[]{ 1, 2, 3, 4 ,5 , 6, 7, 8}); - final List LINEAR_INVERSE = Arrays.asList(new Number[]{ 8, 7, 6, 5, 4, 3, 2, 1}); - final List ZIG_ZAG = Arrays.asList(new Number[]{1, 10, 1, 10, 1, 10, 1, 10}); - final List NULLS = Arrays.asList(new Number[]{null, 2, null, 4, null, 0, -1, null}); - - // single element lists: - final List SINGLE_VALUE = Arrays.asList(new Number[]{3}); - final List SINGLE_VALUE_NULL = Arrays.asList(new Number[]{null}); - - // empty list: - final List EMPTY = new ArrayList<>(); - - @org.junit.After - public void tearDown() throws Exception { - - } - - @Test - public void minMax_onSimpleXYSeries_calculatesExpectedRegion() { - SimpleXYSeries series = new SimpleXYSeries(LINEAR, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, null); - RectRegion minMax = SeriesUtils.minMax(series); - assertEquals(0, minMax.getMinX().doubleValue(), 0); - assertEquals(7, minMax.getMaxX().doubleValue(), 0); - assertEquals(1, minMax.getMinY().doubleValue(), 0); - assertEquals(8, minMax.getMaxY().doubleValue(), 0); - - series = new SimpleXYSeries(LINEAR_INVERSE, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, null); - minMax = SeriesUtils.minMax(series); - assertEquals(0, minMax.getMinX().doubleValue(), 0); - assertEquals(7, minMax.getMaxX().doubleValue(), 0); - assertEquals(1, minMax.getMinY().doubleValue(), 0); - assertEquals(8, minMax.getMaxY().doubleValue(), 0); - - series = new SimpleXYSeries(ZIG_ZAG, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, null); - minMax = SeriesUtils.minMax(series); - assertEquals(0, minMax.getMinX().doubleValue(), 0); - assertEquals(7, minMax.getMaxX().doubleValue(), 0); - assertEquals(1, minMax.getMinY().doubleValue(), 0); - assertEquals(10, minMax.getMaxY().doubleValue(), 0); - - series = new SimpleXYSeries(NULLS, NULLS, null); - minMax = SeriesUtils.minMax(series); - assertEquals(-1, minMax.getMinX().doubleValue(), 0); - assertEquals(4, minMax.getMaxX().doubleValue(), 0); - assertEquals(-1, minMax.getMinY().doubleValue(), 0); - assertEquals(4, minMax.getMaxY().doubleValue(), 0); - - series = new SimpleXYSeries(SINGLE_VALUE, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, null); - minMax = SeriesUtils.minMax(series); - assertEquals(0, minMax.getMinX().doubleValue(), 0); - assertEquals(0, minMax.getMaxX().doubleValue(), 0); - assertEquals(3, minMax.getMinY().doubleValue(), 0); - assertEquals(3, minMax.getMaxY().doubleValue(), 0); - - series = new SimpleXYSeries(SINGLE_VALUE_NULL, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, null); - minMax = SeriesUtils.minMax(series); - assertEquals(0, minMax.getMinX().doubleValue(), 0); - assertEquals(0, minMax.getMaxX().doubleValue(), 0); - assertEquals(null, minMax.getMinY()); - assertEquals(null, minMax.getMaxY()); - - series = new SimpleXYSeries(EMPTY, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, null); - minMax = SeriesUtils.minMax(series); - assertEquals(null, minMax.getMinX()); - assertEquals(null, minMax.getMaxX()); - assertEquals(null, minMax.getMinY()); - assertEquals(null, minMax.getMaxY()); - } - - @Test - public void minMax_onFastXYSeries_usesSeriesMinMax() { - FastXYSeries series = mock(FastXYSeries.class); - SeriesUtils.minMax(series); - verify(series).minMax(); - } - - @Test - public void minMax_calculatesExpectedRegion_onFastXYSeriesWithLayoutConstraints() { - FastXYSeries series = new FastXYSeries() { - - // create a couple arrays of y-values to plot: - final ArrayList times = new ArrayList<>(); - final ArrayList values = new ArrayList<>(); - - { - for (int i = 0; i < 10; i++) { - times.add(i); - values.add(i); - } - } - - @Override - public int size() { - return times.size(); - } - - @Override - public Number getX(int index) { - return times.get(index); - } - - @Override - public Number getY(int index) { - return values.get(index); - } - - @Override - public String getTitle() { - return "Isaac's crazy thing"; - } - - @Override - public RectRegion minMax() { - return new RectRegion(0, 10, 0, 10); - } - }; - - final XYConstraints constraints = new XYConstraints(); - constraints.setDomainLowerBoundaryMode(BoundaryMode.FIXED); - constraints.setDomainUpperBoundaryMode(BoundaryMode.FIXED); - constraints.setMinX(5); - constraints.setMaxX(9); - - final RectRegion result = SeriesUtils.minMax(constraints, series); - assertEquals(5d, result.getMinX().doubleValue()); - assertEquals(9d, result.getMaxX().doubleValue()); - assertEquals(5d, result.getMinY().doubleValue()); - assertEquals(9d, result.getMaxY().doubleValue()); - } - - @Test - public void minMax_onSeriesList_producesAggregateResult() { - Region minMax = SeriesUtils.minMax(LINEAR); - assertEquals(1, minMax.getMin().doubleValue(), 0); - assertEquals(8, minMax.getMax().doubleValue(), 0); - - minMax = SeriesUtils.minMax(LINEAR_INVERSE); - assertEquals(1, minMax.getMin().doubleValue(), 0); - assertEquals(8, minMax.getMax().doubleValue(), 0); - - minMax = SeriesUtils.minMax(ZIG_ZAG); - assertEquals(1, minMax.getMin().doubleValue(), 0); - assertEquals(10, minMax.getMax().doubleValue(), 0); - - minMax = SeriesUtils.minMax(NULLS); - assertEquals(-1, minMax.getMin().doubleValue(), 0); - assertEquals(4, minMax.getMax().doubleValue(), 0); - - minMax = SeriesUtils.minMax(SINGLE_VALUE); - assertEquals(3, minMax.getMin().doubleValue(), 0); - assertEquals(3, minMax.getMax().doubleValue(), 0); - - minMax = SeriesUtils.minMax(SINGLE_VALUE_NULL); - assertEquals(null, minMax.getMin()); - assertEquals(null, minMax.getMax()); - - minMax = SeriesUtils.minMax(EMPTY); - assertEquals(null, minMax.getMin()); - assertEquals(null, minMax.getMax()); - } - - @Test - public void getNullRegion_producesExpectedResult() { - XYSeries s1 = new SimpleXYSeries( - SimpleXYSeries.ArrayFormat.XY_VALS_INTERLEAVED, "s1", - 0, 0, // 0 - 1, 1, // 1 - 2, 2, // 2 - null, null, // 3 - null, null, // 4 - 5, 5, // 5 - 6, 6); // 6 - - try { - Region r1 = SeriesUtils.getNullRegion(s1, 0); - fail("IllegalArgumentException expected."); - } catch(IllegalArgumentException e) { - // expected - } - - try { - Region r2 = SeriesUtils.getNullRegion(s1, s1.size() - 1); - fail("IllegalArgumentException expected."); - } catch(IllegalArgumentException e) { - // expected - } - - Region r3 = SeriesUtils.getNullRegion(s1, 3); - assertEquals(2, r3.getMin().intValue()); - assertEquals(5, r3.getMax().intValue()); - - Region r4 = SeriesUtils.getNullRegion(s1, 4); - assertEquals(2, r4.getMin().intValue()); - assertEquals(5, r4.getMax().intValue()); - } - - @Test - public void iBoundsMin_findsMin() { - XYSeries s1 = new SimpleXYSeries( - Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), - Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), - "s1"); - - assertEquals(0, SeriesUtils.iBoundsMin(s1, 0, 1)); - assertEquals(6, SeriesUtils.iBoundsMin(s1, 6, 1)); - assertEquals(12, SeriesUtils.iBoundsMin(s1, 12, 1)); - - // now test with null vals: - XYSeries s2 = new SimpleXYSeries( - Arrays.asList(null, 1, 2, null, null, 5, 6, 7, 8, null, 10, 11, null), - Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), - "s2"); - - assertEquals(0, SeriesUtils.iBoundsMin(s2, 0, 1)); - assertEquals(2, SeriesUtils.iBoundsMin(s2, 3, 1)); - assertEquals(11, SeriesUtils.iBoundsMin(s2, 12, 1)); - - // test with a higher step value: - assertEquals(0, SeriesUtils.iBoundsMin(s2, 0, 5)); - assertEquals(2, SeriesUtils.iBoundsMin(s2, 3, 5)); - assertEquals(11, SeriesUtils.iBoundsMin(s2, 12, 5)); - } - - @Test - public void iBoundsMax_findsMax() { - XYSeries s1 = new SimpleXYSeries( - Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), - Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), - "s1"); - - assertEquals(12, SeriesUtils.iBoundsMax(s1, 12, 1)); - assertEquals(6, SeriesUtils.iBoundsMax(s1, 6, 1)); - assertEquals(12, SeriesUtils.iBoundsMax(s1, 12, 1)); - - // now test with null vals: - XYSeries s2 = new SimpleXYSeries( - Arrays.asList(null, 1, 2, null, null, 5, 6, 7, 8, null, 10, 11, null), - Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), - "s2"); - - assertEquals(1, SeriesUtils.iBoundsMax(s2, 0, 1)); - assertEquals(5, SeriesUtils.iBoundsMax(s2, 3, 1)); - assertEquals(12, SeriesUtils.iBoundsMax(s2, 12, 1)); - - // test with a higher step value: - assertEquals(1, SeriesUtils.iBoundsMax(s2, 0, 5)); - assertEquals(5, SeriesUtils.iBoundsMax(s2, 3, 5)); - assertEquals(12, SeriesUtils.iBoundsMax(s2, 12, 5)); - } - - @Test - public void iBounds_findsMinMax() { - FastXYSeries series = mock(FastXYSeries.class); - when(series.size()).thenReturn(3); - when(series.getX(0)).thenReturn(0); - when(series.getX(1)).thenReturn(1); - when(series.getX(2)).thenReturn(2); - - Region result = SeriesUtils.iBounds(series, new RectRegion(0, 1, 0, 1)); - assertEquals(0, result.getMin().intValue()); - assertEquals(1, result.getMax().intValue()); - - // test with nulls: - when(series.size()).thenReturn(6); - when(series.getX(0)).thenReturn(0); - when(series.getX(1)).thenReturn(0.5); - when(series.getX(2)).thenReturn(null); - when(series.getX(3)).thenReturn(null); - when(series.getX(4)).thenReturn(1); - when(series.getX(5)).thenReturn(3); - - result = SeriesUtils.iBounds(series, new RectRegion(0, 1, 0, 1)); - assertEquals(0, result.getMin().intValue()); - assertEquals(4, result.getMax().intValue()); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/AdvanceLineAndPointRendererTest.java b/androidplot-core/src/test/java/com/androidplot/xy/AdvanceLineAndPointRendererTest.java deleted file mode 100644 index 647882c5e24528a3abb216ea2be01d61a79619b4..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/AdvanceLineAndPointRendererTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.xy; - -import android.graphics.*; - -import com.androidplot.test.*; -import com.androidplot.ui.*; - -import org.junit.*; -import org.mockito.*; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.*; - -/** - * Tests {@link AdvancedLineAndPointRenderer} and some of - * {@link com.androidplot.xy.AdvancedLineAndPointRenderer.Formatter}. - */ -public class AdvanceLineAndPointRendererTest extends AndroidplotTest { - - XYPlot xyPlot; - - Canvas canvas; - - RectF plotArea = new RectF(0, 0, 100, 100); - - @Mock - RenderStack renderStack; - - @Before - public void setUp() throws Exception { - canvas = new Canvas(); - xyPlot = spy(new XYPlot(getContext(), "My Plot")); - } - - @Test - public void testOnRender() throws Exception { - AdvancedLineAndPointRenderer.Formatter formatter = spy(new AdvancedLineAndPointRenderer.Formatter()); - AdvancedLineAndPointRenderer renderer = formatter.getRendererInstance(xyPlot); - - doReturn(renderer.getClass()).when(formatter).getRendererClass(); - doReturn(renderer).when(formatter).getRendererInstance(any(XYPlot.class)); - - XYSeries s = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Series1", 1, 2, 3, 4); - - xyPlot.addSeries(s, formatter); - - renderer.onRender(canvas, plotArea, s, formatter, renderStack); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/BarRendererTest.java b/androidplot-core/src/test/java/com/androidplot/xy/BarRendererTest.java deleted file mode 100644 index e4624d0806afcafec7f03362238fb3b9a4ceb815..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/BarRendererTest.java +++ /dev/null @@ -1,317 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.xy; - -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.RectF; - -import com.androidplot.test.AndroidplotTest; -import com.androidplot.ui.RenderStack; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.Mock; - -import java.util.List; - -import static junit.framework.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyFloat; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -public class BarRendererTest extends AndroidplotTest { - - XYPlot xyPlot; - - Canvas canvas; - - RectF plotArea = new RectF(0, 0, 100, 100); - - BarFormatter barFormatter; - - @Mock - RenderStack renderStack; - - @Captor - ArgumentCaptor barCaptor; - - @Captor - ArgumentCaptor rectCaptor; - - @Before - public void setUp() { - canvas = spy(new Canvas()); - xyPlot = spy(new XYPlot(getContext(), "My Plot")); - barFormatter = spy(new BarFormatter(Color.RED, Color.RED)); - } - - @Test - public void onRender_handlesNullValues() { - XYSeries s1 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", null, 5, null); - XYSeries s2 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s2", null, 5, null); - - BarRenderer renderer = setupRendererForTesting(s1, s2); - - xyPlot.setRangeBoundaries(0, 10, BoundaryMode.FIXED); - xyPlot.calculateMinMaxVals(); - renderer.onRender(canvas, plotArea, s1, barFormatter, renderStack); - - verify(renderer, times(6)) - .drawBar(eq(canvas), barCaptor.capture(), rectCaptor.capture()); - } - - @Test - public void onRender_stacked() { - XYSeries s1 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 2, 5, 7); - XYSeries s2 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s2", 8, 5, 3); - - BarRenderer renderer = setupRendererForTesting(s1, s2); - - renderer.setBarOrientation(BarRenderer.BarOrientation.STACKED); - - xyPlot.setRangeBoundaries(0, 10, BoundaryMode.FIXED); - xyPlot.calculateMinMaxVals(); - renderer.onRender(canvas, plotArea, s1, barFormatter, renderStack); - - // make sure the expected number of bars draws were attempted: - verify(renderer, times(s1.size() + s2.size())). - drawBar(eq(canvas), any(BarRenderer.Bar.class), any(RectF.class)); - - // s1[0] - verifyBarHeight(80, 100, barFormatter, 1); - - // s2[0] - verifyBarHeight(0, 80, barFormatter, 1); - - // s1[1] - verifyBarHeight(50, 100, barFormatter, 1); - - // s2[1] - verifyBarHeight(0, 50, barFormatter, 1); - - // s1[2] - verifyBarHeight(30, 100, barFormatter, 1); - - // s2[2] - verifyBarHeight(0, 30, barFormatter, 1); - } - - @Test - public void onRender_sideBySide() { - XYSeries s1 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 0, 5, 10); - XYSeries s2 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s2", 1, 7.5, 10); - - BarRenderer renderer = setupRendererForTesting(s1, s2); - renderer.setBarOrientation(BarRenderer.BarOrientation.SIDE_BY_SIDE); - - xyPlot.calculateMinMaxVals(); - renderer.onRender(canvas, plotArea, s1, barFormatter, renderStack); - - // make sure the expected number of bars draws were attempted: - verify(renderer, times(s1.size() + s2.size())). - drawBar(eq(canvas), any(BarRenderer.Bar.class), any(RectF.class)); - - // s1[0] has zero height so should not be drawn: - verifyBarHeight(100, 100, barFormatter, 0); - - // s1[1]: - verifyBarHeight(50, 100, barFormatter, 1); - - // s1[2] & s2[2]: - verifyBarHeight(0, 100, barFormatter, 2); - - // s2[0]: - verifyBarHeight(90, 100, barFormatter, 1); - - // s2[1]: - verifyBarHeight(25, 100, barFormatter, 1); - } - - @Test - public void onRender_inOrder_drawsFirstAddedSeriesFirst() { - XYSeries s1 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 1, 5, 6); - XYSeries s2 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s2", 2, 4, 7); - - BarRenderer renderer = setupRendererForTesting(s1, s2); - renderer.setBarOrientation(BarRenderer.BarOrientation.IN_ORDER); - - xyPlot.setUserRangeOrigin(0); - xyPlot.calculateMinMaxVals(); - renderer.onRender(canvas, plotArea, s1, barFormatter, renderStack); - - verify(renderer, times(6)) - .drawBar(eq(canvas), barCaptor.capture(), rectCaptor.capture()); - - // list of all bars drawn, in the exact order they were drawn. - List bars = barCaptor.getAllValues(); - - assertEquals(bars.get(0).getY(), s1.getY(0)); - assertEquals(bars.get(1).getY(), s2.getY(0)); - - assertEquals(bars.get(2).getY(), s1.getY(1)); - assertEquals(bars.get(3).getY(), s2.getY(1)); - - assertEquals(bars.get(4).getY(), s1.getY(2)); - assertEquals(bars.get(5).getY(), s2.getY(2)); - } - - @Test - public void onRender_overlaid_drawsBarsWithExpectedHeight() { - XYSeries s1 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 0, 5, 10); - XYSeries s2 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s2", 1, 7.5, 10); - - BarRenderer renderer = setupRendererForTesting(s1, s2); - renderer.setBarOrientation(BarRenderer.BarOrientation.OVERLAID); - - xyPlot.calculateMinMaxVals(); - renderer.onRender(canvas, plotArea, s1, barFormatter, renderStack); - - // make sure the expected number of bars draws were attempted: - verify(renderer, times(s1.size() + s2.size())). - drawBar(eq(canvas), any(BarRenderer.Bar.class), any(RectF.class)); - - // s1[0] has zero height so should not be drawn: - verifyBarHeight(100, 100, barFormatter, 0); - - // s1[1]: - verifyBarHeight(50, 100, barFormatter, 1); - - // s1[2] & s2[2]: - verifyBarHeight(0, 100, barFormatter, 2); - - // s2[0]: - verifyBarHeight(90, 100, barFormatter, 1); - - // s2[1]: - verifyBarHeight(25, 100, barFormatter, 1); - } - - /** - * Verify that positive values are drawn in order of highest yVal, while negative values are - * drawn in order of lowest yVal. - */ - @Test - public void onRender_overlaid_drawsSmallestBarsLast() { - XYSeries s1 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", -1, -2, 1, 2); - XYSeries s2 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s2", -2, -1, 2, 1); - - BarRenderer renderer = setupRendererForTesting(s1, s2); - renderer.setBarOrientation(BarRenderer.BarOrientation.OVERLAID); - - xyPlot.setUserRangeOrigin(0); - xyPlot.calculateMinMaxVals(); - renderer.onRender(canvas, plotArea, s1, barFormatter, renderStack); - - verify(renderer, times(8)) - .drawBar(eq(canvas), barCaptor.capture(), rectCaptor.capture()); - - // list of all bars drawn, in the exact order they were drawn. - List bars = barCaptor.getAllValues(); - - assertEquals(s2.getY(0), bars.get(0).getY()); - assertEquals(s1.getY(0), bars.get(1).getY()); - - assertEquals(s1.getY(1), bars.get(2).getY()); - assertEquals(s2.getY(1), bars.get(3).getY()); - } - - @Test - public void onRender_fixedBarWidth_rendersAllBarsWithSameWidth() { - XYSeries s1 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 0, 5, 10); - XYSeries s2 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s2", 1, 7.5, 10); - - BarRenderer renderer = setupRendererForTesting(s1, s2); - final float barWidth = 10; - renderer.setBarGroupWidth(BarRenderer.BarGroupWidthMode.FIXED_WIDTH, barWidth); - - xyPlot.calculateMinMaxVals(); - renderer.onRender(canvas, plotArea, s1, barFormatter, renderStack); - - verify(renderer, times(6)) - .drawBar(eq(canvas), barCaptor.capture(), rectCaptor.capture()); - - List barRects = rectCaptor.getAllValues(); - - for(RectF rect : barRects) { - assertEquals(barWidth, rect.width()); - } - } - - @Test - public void onRender_fixedGapWidth_rendersFixedGapBetweenAllBars() { - XYSeries s1 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 0, 5, 10); - XYSeries s2 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s2", 1, 7.5, 10); - - BarRenderer renderer = setupRendererForTesting(s1, s2); - - final float gap = 5; - renderer.setBarGroupWidth(BarRenderer.BarGroupWidthMode.FIXED_GAP, gap); - - xyPlot.calculateMinMaxVals(); - renderer.onRender(canvas, plotArea, s1, barFormatter, renderStack); - - verify(renderer, times(6)) - .drawBar(eq(canvas), barCaptor.capture(), rectCaptor.capture()); - - List barRects = rectCaptor.getAllValues(); - - // verify that the spacing between each bar group is exactly what was set: - assertEquals(gap, barRects.get(2).left - barRects.get(0).right); - assertEquals(gap, barRects.get(3).left - barRects.get(1).right); - - assertEquals(gap, barRects.get(4).left - barRects.get(2).right); - assertEquals(gap, barRects.get(5).left - barRects.get(3).right); - } - - private void verifyBarHeight(float top, float bottom, BarFormatter formatter, int times) { - final Paint borderPaint = formatter.getBorderPaint(); - verify(canvas, times(times)).drawRect( - anyFloat(), - eq(top), - anyFloat(), - eq(bottom), - eq(borderPaint)); - - final Paint fillPaint = formatter.getFillPaint(); - verify(canvas, times(times)).drawRect( - anyFloat(), - eq(top), - anyFloat(), - eq(bottom), - eq(fillPaint)); - } - - protected BarRenderer setupRendererForTesting(XYSeries... series) { - BarRenderer renderer = spy((BarRenderer)barFormatter.getRendererInstance(xyPlot)); - renderer.setBarOrientation(BarRenderer.BarOrientation.OVERLAID); - - for(XYSeries s : series) { - xyPlot.addSeries(s, barFormatter); - } - - doReturn(renderer.getClass()).when(barFormatter).getRendererClass(); - return renderer; - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/BubbleRendererTest.java b/androidplot-core/src/test/java/com/androidplot/xy/BubbleRendererTest.java deleted file mode 100644 index cd0ff2b1f7ef10769f3b6f891039dc3abf0fdf55..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/BubbleRendererTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.xy; - -import android.graphics.*; - -import com.androidplot.test.*; -import com.androidplot.ui.*; - -import org.junit.*; -import org.mockito.*; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.*; - -/** - * Tests {@link BubbleRenderer} and some of {@link BubbleFormatter}. - */ -public class BubbleRendererTest extends AndroidplotTest { - - XYPlot xyPlot; - - Canvas canvas; - - RectF plotArea = new RectF(0, 0, 100, 100); - - @Mock - RenderStack renderStack; - - @Before - public void setUp() throws Exception { - canvas = spy(new Canvas()); - xyPlot = spy(new XYPlot(getContext(), "My Plot")); - } - - @Test - public void testOnRender() throws Exception { - BubbleFormatter formatter = spy(new BubbleFormatter()); - BubbleRenderer br = formatter.getRendererInstance(xyPlot); - BubbleRenderer renderer = spy(br); - - doReturn(renderer.getClass()).when(formatter).getRendererClass(); - doReturn(renderer).when(formatter).getRendererInstance(any(XYPlot.class)); - - BubbleSeries bs = new BubbleSeries(1, 2, 3, 4, 5, 6, 7, 8, 9); - - xyPlot.addSeries(bs, formatter); - - renderer.onRender(canvas, plotArea, bs, formatter, renderStack); - } - - @Test - public void testOnRender_withPointLabeler() throws Exception { - BubbleFormatter formatter = spy(new BubbleFormatter()); - PointLabelFormatter plf = new PointLabelFormatter(Color.MAGENTA); - formatter.setPointLabelFormatter(plf); - BubbleRenderer br = formatter.getRendererInstance(xyPlot); - BubbleRenderer renderer = spy(br); - - doReturn(renderer.getClass()).when(formatter).getRendererClass(); - doReturn(renderer).when(formatter).getRendererInstance(any(XYPlot.class)); - - BubbleSeries bs = new BubbleSeries(2, 2, 22); - - xyPlot.addSeries(bs, formatter); - - renderer.onRender(canvas, plotArea, bs, formatter, renderStack); - - // verify the z-val is the one labeled: - verify(canvas).drawText(eq("22"), anyFloat(), anyFloat(), eq(plf.getTextPaint())); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/CandlestickRendererTest.java b/androidplot-core/src/test/java/com/androidplot/xy/CandlestickRendererTest.java deleted file mode 100644 index a7fba7753c4e3013b2e28f842079ac46181bd523..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/CandlestickRendererTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.xy; - -import android.graphics.*; - -import com.androidplot.test.*; -import com.androidplot.ui.*; - -import org.junit.*; -import org.mockito.*; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.*; - -public class CandlestickRendererTest extends AndroidplotTest { - - XYPlot xyPlot; - - Canvas canvas; - - RectF plotArea = new RectF(0, 0, 100, 100); - - @Mock - RenderStack renderStack; - - @Before - public void setUp() throws Exception { - canvas = new Canvas(); - xyPlot = spy(new XYPlot(getContext(), "My Plot")); - } - - @Test - public void testOnRender() throws Exception { - CandlestickFormatter formatter = spy(new CandlestickFormatter()); - CandlestickRenderer renderer = spy((CandlestickRenderer) formatter.doGetRendererInstance(xyPlot)); - doReturn(renderer.getClass()).when(formatter).getRendererClass(); - doReturn(renderer).when(formatter).doGetRendererInstance(any(XYPlot.class)); - - XYSeries openVals = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "open", 1, 2, 3, 4); - XYSeries closeVals = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "open", 1, 2, 3, 4); - XYSeries highVals = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "open", 1, 2, 3, 4); - XYSeries lowVals = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "open", 1, 2, 3, 4); - CandlestickMaker.make(xyPlot, formatter, openVals, closeVals, highVals, lowVals); - - renderer.onRender(canvas, plotArea, openVals, formatter, renderStack); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/CandlestickSeriesTest.java b/androidplot-core/src/test/java/com/androidplot/xy/CandlestickSeriesTest.java deleted file mode 100644 index 919d3b585d100b9302f198ab9d8477642743d09b..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/CandlestickSeriesTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2016 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.xy; - -import org.junit.Test; - -import java.util.Arrays; - -import static junit.framework.Assert.assertEquals; - -public class CandlestickSeriesTest { - - @Test - public void testConstructors() throws Exception { - CandlestickSeries candlestickSeries = new CandlestickSeries( - new CandlestickSeries.Item(1, 10, 2, 9), - new CandlestickSeries.Item(4, 18, 6, 5), - new CandlestickSeries.Item(3, 11, 5, 10), - new CandlestickSeries.Item(2, 17, 2, 15), - new CandlestickSeries.Item(6, 11, 11, 7), - new CandlestickSeries.Item(8, 16, 10, 15)); - - XYSeries lowSeries = candlestickSeries.getLowSeries(); - assertEquals(1d, lowSeries.getY(0)); - assertEquals(4d, lowSeries.getY(1)); - assertEquals(3d, lowSeries.getY(2)); - - XYSeries highSeries = candlestickSeries.getHighSeries(); - assertEquals(10d, highSeries.getY(0)); - assertEquals(18d, highSeries.getY(1)); - assertEquals(11d, highSeries.getY(2)); - - XYSeries openSeries = candlestickSeries.getOpenSeries(); - assertEquals(2d, openSeries.getY(0)); - assertEquals(6d, openSeries.getY(1)); - assertEquals(5d, openSeries.getY(2)); - - XYSeries closeSeries = candlestickSeries.getCloseSeries(); - assertEquals(9d, closeSeries.getY(0)); - assertEquals(5d, closeSeries.getY(1)); - assertEquals(10d, closeSeries.getY(2)); - - CandlestickMaker.check(candlestickSeries); - - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/CatmullRomInterpolatorTest.java b/androidplot-core/src/test/java/com/androidplot/xy/CatmullRomInterpolatorTest.java deleted file mode 100644 index 1d672dafb6811940264171a984082e5a557814aa..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/CatmullRomInterpolatorTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.androidplot.xy; - -import org.junit.Test; - -import java.util.List; - -import static junit.framework.Assert.assertEquals; -import static org.mockito.Mockito.mock; - -public class CatmullRomInterpolatorTest { - - @Test(expected = IllegalArgumentException.class) - public void interpolate_invalidPointsPerSegment_throwsIllegalArgumentException() { - final XYSeries series = mock(XYSeries.class); - final CatmullRomInterpolator.Params params = - new CatmullRomInterpolator.Params(1, CatmullRomInterpolator.Type.Centripetal); - - new CatmullRomInterpolator().interpolate(series, params); - } - - @Test(expected = IllegalArgumentException.class) - public void interpolate_twoElementSeries_throwsIllegalArgumentException() { - final XYSeries series = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "test", 1, 2); - final CatmullRomInterpolator.Params params = - new CatmullRomInterpolator.Params(2, CatmullRomInterpolator.Type.Centripetal); - - new CatmullRomInterpolator().interpolate(series, params); - } - - @Test - public void interpolate_threeElementSeriesAndThreePointsPerSegment_producesFivePoints() { - final XYSeries series = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "test", 1, 2, 3); - final CatmullRomInterpolator.Params params = - new CatmullRomInterpolator.Params(3, CatmullRomInterpolator.Type.Centripetal); - final List interpolated = new CatmullRomInterpolator().interpolate(series, params); - - assertEquals(5, interpolated.size()); - - // control points should exactly match input: - assertEquals(1, interpolated.get(0).y); - assertEquals(2, interpolated.get(2).y); - assertEquals(3, interpolated.get(4).y); - } - - @Test - public void interpolate_threeElementSeriesAndFourPointsPerSegment_producesSavenPoints() { - final XYSeries series = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "test", 1, 2, 3); - final CatmullRomInterpolator.Params params = - new CatmullRomInterpolator.Params(4, CatmullRomInterpolator.Type.Centripetal); - final List interpolated = new CatmullRomInterpolator().interpolate(series, params); - - assertEquals(7, interpolated.size()); - - // control points should exactly match input: - assertEquals(1, interpolated.get(0).y); - assertEquals(2, interpolated.get(3).y); - assertEquals(3, interpolated.get(6).y); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/FastLineAndPointRendererTest.java b/androidplot-core/src/test/java/com/androidplot/xy/FastLineAndPointRendererTest.java deleted file mode 100644 index de81e70c79c75346c8e9e1eca4c0e12bb7425ed0..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/FastLineAndPointRendererTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.xy; - -import android.graphics.*; - -import com.androidplot.test.*; - -import org.junit.*; -import org.junit.runner.*; -import org.mockito.*; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -public class FastLineAndPointRendererTest extends AndroidplotTest { - - @Before - public void setUp() throws Exception { - - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testOnRender() throws Exception { - RectF gridRect = new RectF(5, 5, 105, 105); - XYPlot plot = new XYPlot(getContext(), "Test"); - - FastLineAndPointRenderer.Formatter formatter = - new FastLineAndPointRenderer.Formatter(Color.RED, Color.RED, null); - - - // create a series composed of 3 "segments"; series portions separated by null values: - XYSeries series = new SimpleXYSeries( - SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "some data", 1, 2, null, 3, 4, 5, 6, 7, null, null, 8); - - FastLineAndPointRenderer renderer = Mockito.spy(new FastLineAndPointRenderer(plot)); - Canvas canvas = mock(Canvas.class); - - renderer.onRender(canvas, gridRect, series, formatter, null); - - // first segment - verify(renderer, times(1)).drawSegment( - eq(canvas), - any(float[].class), - eq(0), - eq(4), - eq(formatter)); - - verify(canvas, times(1)).drawPoints( - any(float[].class), - eq(0), - eq(4), - eq(formatter.getVertexPaint())); - - // second segment - verify(renderer, times(1)).drawSegment( - eq(canvas), - any(float[].class), - eq(6), - eq(10), - eq(formatter)); - - verify(canvas, times(1)).drawPoints( - any(float[].class), - eq(6), - eq(10), - eq(formatter.getVertexPaint())); - - // third segment - verify(renderer, times(1)).drawSegment( - eq(canvas), - any(float[].class), - eq(20), - eq(2), - eq(formatter)); - - verify(canvas, times(1)).drawPoints( - any(float[].class), - eq(20), - eq(2), - eq(formatter.getVertexPaint())); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/LTTBSamplerTest.java b/androidplot-core/src/test/java/com/androidplot/xy/LTTBSamplerTest.java deleted file mode 100644 index 3269082dad6061284c086947f4691ddee5ba4606..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/LTTBSamplerTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.xy; - -import android.graphics.*; - -import com.androidplot.test.*; -import com.androidplot.ui.*; - -import org.junit.*; -import org.mockito.*; - -import java.util.*; - -import static junit.framework.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.*; - -public class LTTBSamplerTest extends AndroidplotTest { - - @Test - public void testSomething() throws Exception { - - } - -// @Test -// public void testDownsample() throws Exception { -// -// Number[][] rawNumbers = new Number[][] { {1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}, {11, 12}, {13, 14}, {15, 16}, {17, 18}, {19, 20} }; -// XYSeries rawSeries = new SimpleXYSeries( -// Arrays.asList(1, 3, 5, 7, 9, 11, 13, 15, 17, 19), -// Arrays.asList(2, 4, 6, 8, 10, 12, 14, 16, 18, 20), "raw"); -// compareSeriesToRaw(rawNumbers, rawSeries); -// -// LTTBDownsampler downsampler = new LTTBDownsampler(); -// SimpleXYSeries sampled = new SimpleXYSeries( -// Arrays.asList(new Number[]{0, 0, 0, 0, 0}), -// Arrays.asList(new Number[]{0, 0, 0, 0, 0}), "sampled"); -// downsampler.downsample(rawSeries, sampled); -// -// Number[][] downsampled = LTTBDownsampler.downsample(rawNumbers, 5); -// compareSeriesToRaw(downsampled, sampled); -// } -// -// protected void compareSeriesToRaw(Number[][] raw, XYSeries series) { -// assertEquals(raw.length, series.size()); -// int i = 0; -// for(Number[] xy : raw) { -// assertEquals(xy[0], series.getX(i)); -// assertEquals(xy[1], series.getY(i)); -// i++; -// } -// } -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/LineAndPointRendererTest.java b/androidplot-core/src/test/java/com/androidplot/xy/LineAndPointRendererTest.java deleted file mode 100644 index 9cb03cd1002c8ac3b350551568aaf5d1ff41d1b6..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/LineAndPointRendererTest.java +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.xy; - -import android.graphics.*; - -import com.androidplot.test.*; - -import org.junit.*; -import org.mockito.*; - -import java.util.*; - -import static junit.framework.Assert.assertEquals; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.*; - -public class LineAndPointRendererTest extends AndroidplotTest { - - private XYPlot xyPlot; - - @Mock - Canvas canvas; - - RectF plotArea = new RectF(0, 0, 100, 100); - - @Before - public void setUp() throws Exception { - xyPlot = spy(new XYPlot(getContext(), "XYPlot")); - } - - @Test - public void testDrawSeries_withInterpolation() throws Exception { - LineAndPointRenderer renderer = spy(new LineAndPointRenderer(xyPlot)); - LineAndPointFormatter formatter = new LineAndPointFormatter(); - formatter.setInterpolationParams( - new CatmullRomInterpolator.Params(10, CatmullRomInterpolator.Type.Centripetal)); - XYSeries series = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Series1", 1, 2, 3); - renderer.drawSeries(canvas, plotArea, series, formatter); - } - - /** - * Sanity run to make sure that at the end of the day, points are being drawn at the expected - * screen-coords. - * @throws Exception - */ - @Test - public void testDrawSeries() throws Exception { - - // 100x100 plot space: - plotArea = new RectF(0, 0, 99, 99); - FastLineAndPointRenderer.Formatter formatter = - new FastLineAndPointRenderer.Formatter(Color.RED, Color.RED, null); - - // create a series composed of 3 "segments"; series portions separated by null values: - XYSeries series = new SimpleXYSeries( - SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "some data", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - - LineAndPointRenderer renderer = Mockito.spy(new LineAndPointRenderer(xyPlot)); - - xyPlot.addSeries(series, formatter); - - xyPlot.calculateMinMaxVals(); - renderer.drawSeries(canvas, plotArea, series, formatter); - - PointF[] expectedPoints = new PointF[] { - new PointF(0, 99), - new PointF(11, 88), - new PointF(22, 77), - new PointF(33, 66), - new PointF(44, 55), - new PointF(55, 44), - new PointF(66, 33), - new PointF(77, 22), - new PointF(88, 11), - new PointF(99, 0) - }; - ArgumentCaptor capturedPoints= ArgumentCaptor.forClass(List.class); - - verify(renderer, times(1)).renderPoints( - eq(canvas), - eq(plotArea), - eq(series), - eq(0), - eq(expectedPoints.length), - capturedPoints.capture(), - eq(formatter)); - - List pList = capturedPoints.getValue(); - - // {0, 1} - assertEquals(expectedPoints[0].x, pList.get(0).x); - assertEquals(expectedPoints[0].y, pList.get(0).y); - - // {1, 2} - assertEquals(expectedPoints[1].x, pList.get(1).x); - assertEquals(expectedPoints[1].y, pList.get(1).y); - - // {2, 3} - assertEquals(expectedPoints[2].x, pList.get(2).x); - assertEquals(expectedPoints[2].y, pList.get(2).y); - - // {3, 4} - assertEquals(expectedPoints[3].x, pList.get(3).x); - assertEquals(expectedPoints[3].y, pList.get(3).y); - - // {4, 5} - assertEquals(expectedPoints[4].x, pList.get(4).x); - assertEquals(expectedPoints[4].y, pList.get(4).y); - - // {5, 6} - assertEquals(expectedPoints[5].x, pList.get(5).x); - assertEquals(expectedPoints[5].y, pList.get(5).y); - - // {6, 7} - assertEquals(expectedPoints[6].x, pList.get(6).x); - assertEquals(expectedPoints[6].y, pList.get(6).y); - - // {7, 8} - assertEquals(expectedPoints[7].x, pList.get(7).x); - assertEquals(expectedPoints[7].y, pList.get(7).y); - - // {8, 9} - assertEquals(expectedPoints[8].x, pList.get(8).x); - assertEquals(expectedPoints[8].y, pList.get(8).y); - - // {9, 10} - assertEquals(expectedPoints[9].x, pList.get(9).x); - assertEquals(expectedPoints[9].y, pList.get(9).y); - } - - @Test - public void testDrawSeries_supportsOrderedXYSeries() throws Exception { - // 100x100 plot space: - //RectF plotArea = new RectF(0, 0, 99, 99); - FastLineAndPointRenderer.Formatter formatter = - new FastLineAndPointRenderer.Formatter(Color.RED, Color.RED, null); - - // create a series composed of 3 "segments"; series portions separated by null values: - SimpleXYSeries series = new SimpleXYSeries( - SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "some data", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - - LineAndPointRenderer renderer = Mockito.spy(new LineAndPointRenderer(xyPlot)); - - xyPlot.addSeries(series, formatter); - - xyPlot.calculateMinMaxVals(); - renderer.drawSeries(canvas, plotArea, series, formatter); - - verify(renderer, times(1)).renderPoints( - eq(canvas), - eq(plotArea), - eq(series), - eq(0), - eq(series.size()), - any(List.class), - eq(formatter)); - - xyPlot.setDomainBoundaries(5, 6, BoundaryMode.FIXED); - series.setXOrder(OrderedXYSeries.XOrder.ASCENDING); - xyPlot.calculateMinMaxVals(); - renderer.drawSeries(canvas, plotArea, series, formatter); - - verify(renderer, times(1)).renderPoints( - eq(canvas), - eq(plotArea), - eq(series), - eq(4), - eq(8), - any(List.class), - eq(formatter)); - - } - - @Test - public void testCullPointsCache() throws Exception { - LineAndPointFormatter formatter = - new LineAndPointFormatter(0, 0, 0, null); - - // create a series composed of 3 "segments"; series portions separated by null values: - SimpleXYSeries series = new SimpleXYSeries( - SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "some data", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - - xyPlot.addSeries(series, formatter); - LineAndPointRenderer renderer = xyPlot.getRenderer(LineAndPointRenderer.class); - - assertEquals(0, renderer.pointsCaches.size()); - - // should generate a new pointCache: - renderer.getPointsCache(series); - assertEquals(1, renderer.pointsCaches.size()); - - // culling should not delete it since it is - // registered in the series registry: - renderer.getPointsCache(series); - assertEquals(1, renderer.pointsCaches.size()); - renderer.cullPointsCache(); - assertEquals(1, renderer.pointsCaches.size()); - - // unregister the series. this time, culling should remove the series - // from the points cache: - xyPlot.removeSeries(series); - renderer.cullPointsCache(); - assertEquals(0, renderer.pointsCaches.size()); - } - - @Test - public void renderPath_rendersRegions() { - LineAndPointFormatter formatter = - new LineAndPointFormatter(0, 0, 0, null); - - XYRegionFormatter r1 = new XYRegionFormatter(Color.RED); - formatter.addRegion(new RectRegion(0, 2, 0, 2, "region1"), r1); - - XYRegionFormatter r2 = new XYRegionFormatter(Color.GREEN); - formatter.addRegion(new RectRegion(0, 2, 0, 2, "region2"), r2); - - SimpleXYSeries series = new SimpleXYSeries( - SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "some data", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - - xyPlot.addSeries(series, formatter); - LineAndPointRenderer renderer = xyPlot.getRenderer(LineAndPointRenderer.class); - - //xyPlot.draw(canvas); - renderer.renderPath(canvas, plotArea, new Path(), mock(PointF.class), mock(PointF.class), formatter); - verify(canvas).drawRect(any(RectF.class), eq(r1.getPaint())); - verify(canvas).drawRect(any(RectF.class), eq(r2.getPaint())); - } - - @Test - public void drawSeries_withPointLabelFormatter_drawsPointLabels() { - LineAndPointFormatter formatter = - new LineAndPointFormatter(0, 0, 0, null); - formatter.setPointLabelFormatter(new PointLabelFormatter(Color.RED)); - SimpleXYSeries series = new SimpleXYSeries( - SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "some data", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - xyPlot.addSeries(series, formatter); - LineAndPointRenderer renderer = xyPlot.getRenderer(LineAndPointRenderer.class); - renderer.drawSeries(canvas, plotArea, series, formatter); - - verify(canvas, times(series.size())).drawText( - anyString(), - anyFloat(), - anyFloat(), - eq(formatter.getPointLabelFormatter().getTextPaint())); - - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/NormedXYSeriesTest.java b/androidplot-core/src/test/java/com/androidplot/xy/NormedXYSeriesTest.java deleted file mode 100644 index 8e8b341de5504afc83947b3f860f97fb5f8b8cc2..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/NormedXYSeriesTest.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.androidplot.xy; - -import com.androidplot.test.AndroidplotTest; -import com.androidplot.test.TestUtils; - -import org.junit.Ignore; -import org.junit.Test; - -import static junit.framework.Assert.assertEquals; -import static org.mockito.Mockito.spy; - -/** - * Tests {@link NormedXYSeries}. - */ -public class NormedXYSeriesTest extends AndroidplotTest { - - // account for precision issues inherent in floating point math: - private static final double DELTA = 0.0000001; - - @Test - public void testConstructor_withNoOffset() { - XYSeries rawData = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 0, 2, 4, 6, 8, 10); - NormedXYSeries normedData = new NormedXYSeries(rawData, - new NormedXYSeries.Norm(null), - new NormedXYSeries.Norm(null)); - - assertEquals(0d, normedData.getY(0).doubleValue(), DELTA); - assertEquals(0.2d, normedData.getY(1).doubleValue(), DELTA); - assertEquals(0.4d, normedData.getY(2).doubleValue(), DELTA); - assertEquals(0.6d, normedData.getY(3).doubleValue(), DELTA); - assertEquals(0.8d, normedData.getY(4).doubleValue(), DELTA); - assertEquals(1.0d, normedData.getY(5).doubleValue(), DELTA); - } - - @Test - public void testConstructor_withNullYVals() { - XYSeries rawData = new SimpleXYSeries( - SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, - "s1", - 0, null, 4, null, 8, 10); - NormedXYSeries normedData = new NormedXYSeries(rawData, - new NormedXYSeries.Norm(null), - new NormedXYSeries.Norm(null)); - - assertEquals(0d, normedData.getY(0).doubleValue(), DELTA); - assertEquals(0.4d, normedData.getY(2).doubleValue(), DELTA); - assertEquals(0.8d, normedData.getY(4).doubleValue(), DELTA); - assertEquals(1.0d, normedData.getY(5).doubleValue(), DELTA); - } - - @Test - public void testConstructor_withPositiveOffsetAndOffsetCompression() { - XYSeries rawData = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 0, 2, 4, 6, 8, 10); - NormedXYSeries normedData = new NormedXYSeries(rawData, - new NormedXYSeries.Norm(null, 0.5, true), - new NormedXYSeries.Norm(null, 0.5, true)); - - assertEquals(0.5d, normedData.getY(0).doubleValue(), DELTA); - assertEquals(0.6d, normedData.getY(1).doubleValue(), DELTA); - assertEquals(1.0d, normedData.getY(5).doubleValue(), DELTA); - } - - @Test - public void testConstructor_withNegativeOffsetAndOffsetCompression() { - XYSeries rawData = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 0, 2, 4, 6, 8, 10); - NormedXYSeries normedData = new NormedXYSeries(rawData, - new NormedXYSeries.Norm(null, -0.5, true), - new NormedXYSeries.Norm(null, -0.5, true)); - - assertEquals(0d, normedData.getY(0).doubleValue(), DELTA); - assertEquals(0.1d, normedData.getY(1).doubleValue(), DELTA); - assertEquals(0.2d, normedData.getY(2).doubleValue(), DELTA); - assertEquals(0.5d, normedData.getY(5).doubleValue(), DELTA); - } - - @Test - public void testConstructor_withOffsetAndNoOffsetCompression() { - XYSeries rawData = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 0, 2, 4, 6, 8, 10); - NormedXYSeries normedData = new NormedXYSeries(rawData, - new NormedXYSeries.Norm(null, 0.5, false), - new NormedXYSeries.Norm(null, 0.5, false)); - - assertEquals(0.5d, normedData.getY(0).doubleValue(), DELTA); - assertEquals(0.7d, normedData.getY(1).doubleValue(), DELTA); - assertEquals(1.5d, normedData.getY(5).doubleValue(), DELTA); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/PanZoomTest.java b/androidplot-core/src/test/java/com/androidplot/xy/PanZoomTest.java deleted file mode 100644 index 50d3c16c0aa5eb69021d93763dae492dbe4880f9..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/PanZoomTest.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.xy; - -import android.content.res.*; -import android.graphics.*; -import android.view.*; - -import com.androidplot.Region; -import com.androidplot.test.*; -import com.androidplot.ui.*; -import com.androidplot.util.*; - -import org.junit.*; -import org.mockito.*; - -import static junit.framework.Assert.assertEquals; -import static org.mockito.Mockito.*; - -public class PanZoomTest extends AndroidplotTest { - - @Mock - LayoutManager layoutManager; - - @Mock - XYPlot xyPlot; - - @Mock - TypedArray typedArray; - - @Mock - XYSeriesRegistry seriesRegistry; - - RectRegion bounds = new RectRegion(0, 100, 0, 100); - - @Before - public void setUp() throws Exception { - when(xyPlot.getRegistry()).thenReturn(seriesRegistry); - when(xyPlot.getBounds()).thenReturn(bounds); - when(xyPlot.getInnerLimits()).thenReturn(new RectRegion()); - when(xyPlot.getOuterLimits()).thenReturn(new RectRegion()); - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testOnTouch_notifiesOnTouchListener() throws Exception { - PanZoom panZoom = new PanZoom(xyPlot, PanZoom.Pan.BOTH, PanZoom.Zoom.SCALE); - - View.OnTouchListener listener = mock(View.OnTouchListener.class); - panZoom.setDelegate(listener); - - MotionEvent motionEvent = mock(MotionEvent.class); - panZoom.onTouch(xyPlot, motionEvent); - - verify(listener, times(1)).onTouch(xyPlot, motionEvent); - } - - @Test - public void testOnTouch_oneFingerMovePansButDoesNotZoom() throws Exception { - PanZoom panZoom = spy(new PanZoom(xyPlot, PanZoom.Pan.BOTH, PanZoom.Zoom.SCALE)); - - View.OnTouchListener listener = mock(View.OnTouchListener.class); - panZoom.setDelegate(listener); - - MotionEvent moveEvent = mock(MotionEvent.class); - - doNothing().when(panZoom).calculatePan( - any(PointF.class), any(Region.class), anyBoolean()); - - when(moveEvent.getAction()) - .thenReturn(MotionEvent.ACTION_DOWN) - .thenReturn(MotionEvent.ACTION_MOVE) - .thenReturn(MotionEvent.ACTION_UP); - - panZoom.onTouch(xyPlot, moveEvent); // fires ACTION_DOWN - panZoom.onTouch(xyPlot, moveEvent); // fires ACTION_MOVE - panZoom.onTouch(xyPlot, moveEvent); // fires ACTION_UP - - verify(panZoom).pan(moveEvent); - verify(panZoom, never()).zoom(moveEvent); - verify(panZoom).reset(); - } - - @Test - public void testOnTouch_twoFingersZoom() throws Exception { - PanZoom panZoom = spy(new PanZoom(xyPlot, PanZoom.Pan.BOTH, PanZoom.Zoom.SCALE)); - MotionEvent moveEvent = mock(MotionEvent.class); - - // simulate a zoom gesture sequence: - when(moveEvent.getAction()) - .thenReturn(MotionEvent.ACTION_DOWN) - .thenReturn(MotionEvent.ACTION_POINTER_DOWN) - .thenReturn(MotionEvent.ACTION_MOVE) - .thenReturn(MotionEvent.ACTION_UP); - - when(panZoom.fingerDistance(moveEvent)) - .thenReturn(new RectF(0, 0, 10, 10)) - .thenReturn(new RectF(0, 0, 11, 11)) - .thenReturn(new RectF(0, 0, 12, 12)) - .thenReturn(new RectF(0, 0, 13, 13)); - - panZoom.onTouch(xyPlot, moveEvent); // ACTION_DOWN - panZoom.onTouch(xyPlot, moveEvent); // ACTION_POINTER_DOWN - panZoom.onTouch(xyPlot, moveEvent); // ACTION_MOVE - panZoom.onTouch(xyPlot, moveEvent); // ACTION_UP - - verify(xyPlot).redraw(); - verify(panZoom, never()).pan(any(MotionEvent.class)); - verify(panZoom).zoom(moveEvent); - verify(panZoom).reset(); - } - - @Test - public void testZoom() { - xyPlot = spy(new InstrumentedXYPlot(getContext())); - xyPlot.setDomainBoundaries(0, 100, BoundaryMode.FIXED); - xyPlot.setRangeBoundaries(0, 100, BoundaryMode.FIXED); - xyPlot.redraw(); - - PanZoom panZoom = spy(new PanZoom(xyPlot, PanZoom.Pan.BOTH, PanZoom.Zoom.SCALE)); - - // cap our pan/zoom boundaries: - xyPlot.getOuterLimits().set(0, 100, 0, 100); - - panZoom.setFingersRect(new RectF(0, 0, 20, 20)); - - InOrder inOrder = inOrder(xyPlot); - inOrder.verify(xyPlot).setDomainBoundaries(0, 100, BoundaryMode.FIXED); - - // should result in a 2x zoom on domain centerpoint: - panZoom.zoom(TestUtils.newPointerDownEvent(0, 0, 40, 40)); - inOrder.verify(xyPlot).setDomainBoundaries(25f, 75f, BoundaryMode.FIXED); - inOrder.verify(xyPlot).setRangeBoundaries(25f, 75f, BoundaryMode.FIXED); - inOrder.verify(xyPlot).redraw(); - - // should result in another 2x zoom on domain centerpoint: - panZoom.zoom(TestUtils.newPointerDownEvent(0, 0, 80, 80)); - inOrder.verify(xyPlot).setDomainBoundaries(37.5f, 62.5f, BoundaryMode.FIXED); - inOrder.verify(xyPlot).setRangeBoundaries(37.5f, 62.5f, BoundaryMode.FIXED); - inOrder.verify(xyPlot).redraw(); - - // should zoom out and take us back to the original bounds: - panZoom.zoom(TestUtils.newPointerDownEvent(0, 0, 20, 20)); - inOrder.verify(xyPlot).setDomainBoundaries(0f, 100f, BoundaryMode.FIXED); - inOrder.verify(xyPlot).setRangeBoundaries(0f, 100f, BoundaryMode.FIXED); - inOrder.verify(xyPlot).redraw(); - - // zooming out past capped bounds should not result in any change: - panZoom.zoom(TestUtils.newPointerDownEvent(0, 0, 1, 1)); - inOrder.verify(xyPlot).setDomainBoundaries(0f, 100f, BoundaryMode.FIXED); - inOrder.verify(xyPlot).setRangeBoundaries(0f, 100f, BoundaryMode.FIXED); - // TODO: if nothing changed, then why bother redrawing?? - inOrder.verify(xyPlot).redraw(); - - // redraw should not be called again - inOrder.verify(xyPlot, never()).redraw(); - - // make sure no panning took place during these zoom ops: - verify(panZoom, never()).pan(any(MotionEvent.class)); - - } - - @Test - public void testLimitZoom() { - double[] inc_domain = new double[]{10,50,100}; - double[] inc_range = new double[]{20,50}; - - xyPlot = spy(new InstrumentedXYPlot(getContext())); - xyPlot.setDomainBoundaries(0, 20, BoundaryMode.FIXED); - xyPlot.setRangeBoundaries(0, 30, BoundaryMode.FIXED); - xyPlot.setDomainStepModel(new StepModelFit(xyPlot.getBounds().getxRegion(), inc_domain, 5)); - xyPlot.setRangeStepModel(new StepModelFit(xyPlot.getBounds().getyRegion(), inc_range, 5)); - xyPlot.redraw(); - - PanZoom panZoom = spy(new PanZoom(xyPlot, PanZoom.Pan.BOTH, PanZoom.Zoom.SCALE, PanZoom.ZoomLimit.MIN_TICKS)); - - // cap our pan/zoom boundaries: - xyPlot.getOuterLimits().set(0, 20, 0, 30); - - panZoom.setFingersRect(new RectF(0, 0, 20, 20)); - - InOrder inOrder = inOrder(xyPlot); - inOrder.verify(xyPlot).setDomainBoundaries(0, 20, BoundaryMode.FIXED); - - // should NOT result in a 2x zoom on domain centerpoint, but in a zoom to - // the minimum spacing 10 and 20 respectively - panZoom.zoom(TestUtils.newPointerDownEvent(0, 0, 40, 40)); - inOrder.verify(xyPlot).setDomainBoundaries(5f, 15f, BoundaryMode.FIXED); - inOrder.verify(xyPlot).setRangeBoundaries(5f, 25f, BoundaryMode.FIXED); - inOrder.verify(xyPlot).redraw(); - - // to zoom in beyond min limits - panZoom.setZoomLimit(PanZoom.ZoomLimit.OUTER); - - // should result in another 2x zoom on domain centerpoint: - panZoom.zoom(TestUtils.newPointerDownEvent(0, 0, 80, 80)); - inOrder.verify(xyPlot).setDomainBoundaries(7.5f, 12.5f, BoundaryMode.FIXED); - inOrder.verify(xyPlot).setRangeBoundaries(10f, 20f, BoundaryMode.FIXED); - inOrder.verify(xyPlot).redraw(); - - // back to limited zoom - panZoom.setZoomLimit(PanZoom.ZoomLimit.MIN_TICKS); - - // try to zoom in further, should snap back to min limit: - panZoom.zoom(TestUtils.newPointerDownEvent(0, 0, 90, 90)); - inOrder.verify(xyPlot).setDomainBoundaries(5f, 15f, BoundaryMode.FIXED); - inOrder.verify(xyPlot).setRangeBoundaries(5f, 25f, BoundaryMode.FIXED); - inOrder.verify(xyPlot).redraw(); - - // redraw should not be called again - inOrder.verify(xyPlot, never()).redraw(); - - // make sure no panning took place during these zoom ops: - verify(panZoom, never()).pan(any(MotionEvent.class)); - - } - - @Test - public void testFingerDistance() { - PanZoom panZoom = spy(new PanZoom(xyPlot, PanZoom.Pan.BOTH, PanZoom.Zoom.SCALE)); - RectF distance = panZoom.fingerDistance(TestUtils.newPointerDownEvent(0, 0, 10, 10)); - assertEquals(0f, distance.left); - assertEquals(0f, distance.top); - assertEquals(10f, distance.right); - assertEquals(10f, distance.bottom); - - // no matter what order the coords are supplied, make sure the same rect is calculated: - distance = panZoom.fingerDistance(10, 10, 0, 0); - assertEquals(0f, distance.left); - assertEquals(0f, distance.top); - assertEquals(10f, distance.right); - assertEquals(10f, distance.bottom); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/RectRegionTest.java b/androidplot-core/src/test/java/com/androidplot/xy/RectRegionTest.java deleted file mode 100644 index c6e11ae74198a0ea41de38ad5c91dcc797bb343a..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/RectRegionTest.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.xy; - -import android.graphics.*; - -import com.androidplot.test.AndroidplotTest; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import static junit.framework.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class RectRegionTest extends AndroidplotTest{ - - @Before - public void setUp() throws Exception { - - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testContainsPoint() throws Exception { - - } - - @Test - public void testContainsValue() throws Exception { - - } - - @Test - public void testContainsDomainValue() throws Exception { - - } - - @Test - public void testContainsRangeValue() throws Exception { - - } - - - - @Test - public void testIsWithin() throws Exception { - - RectRegion region1 = new RectRegion(0, 100, 0, 100, ""); - - RectRegion region2 = new RectRegion(5, 10, 5, 10, ""); - - assertTrue(region1.intersects(region2)); - assertTrue(region2.intersects(region1)); - - RectRegion region3 = new RectRegion(101, 200, 101, 200, ""); - assertFalse(region1.intersects(region3)); - assertFalse(region3.intersects(region1)); - - RectRegion region4 = new RectRegion(99, 109, 99, 109, ""); - assertTrue(region1.intersects(region4)); - assertTrue(region4.intersects(region1)); - - // negative numbers: - RectRegion region5 = new RectRegion(-100, 1, -100, 1, ""); - assertTrue(region1.intersects(region5)); - assertTrue(region5.intersects(region1)); - } - - @Test - public void testTransform() throws Exception { - RectRegion r1 = new RectRegion(1, 2, 0, 10); - RectRegion r2 = new RectRegion(2, 4, 10, 20); - - final XYCoords trans1 = r1.transform(new XYCoords(1.5, 5), r2); - assertEquals(3.0, trans1.x); - assertEquals(15.0, trans1.y); - - // try a screen transform: - RectF screen = new RectF(0, 0, 100, 100); - PointF result = r1.transform(2, 10, screen, false, true); - assertEquals(100f, result.x); - assertEquals(0f, result.y); - - // now transform back to real: - RectRegion screenRegion = new RectRegion(screen); - XYCoords result2 = screenRegion.transform(result.x, result.y, r1, false, true); - assertEquals(2d, result2.x); - assertEquals(10d, result2.y); - } - - @Test - public void testIntersects() throws Exception { - RectRegion r1 = new RectRegion(0, 10, 0, 10); - RectRegion r2 = new RectRegion(5, 15, 5, 15); - RectRegion r3 = new RectRegion(11, 21, 11, 21); - - assertTrue(r1.intersects(r2)); - assertTrue(r2.intersects(r1)); - assertFalse(r1.intersects(r3)); - assertFalse(r3.intersects(r1)); - assertTrue(r2.intersects(r3)); - assertTrue(r3.intersects(r2)); - } - - @Test - public void testClip_sameDimensions() throws Exception { - RectRegion r1 = new RectRegion(0, 10, 0, 10); - RectRegion r2 = new RectRegion(0, 10, 0, 10); - - r1.intersect(r2); - assertEquals(0, r1.getMinX().doubleValue(), 0); - assertEquals(10, r1.getMaxX().doubleValue(), 0); - assertEquals(0, r1.getMinY().doubleValue(), 0); - assertEquals(10, r1.getMaxY().doubleValue(), 0); - } - - @Test - public void testClip_intersectingDimensions() throws Exception { - RectRegion r1 = new RectRegion(0, 10, 0, 10); - RectRegion r2 = new RectRegion(5, 15, 5, 15); - - r1.intersect(r2); - assertEquals(5, r1.getMinX().doubleValue(), 0); - assertEquals(10, r1.getMaxX().doubleValue(), 0); - assertEquals(5, r1.getMinY().doubleValue(), 0); - assertEquals(10, r1.getMaxY().doubleValue(), 0); - - r1 = new RectRegion(0, 10, 0, 10); - r2 = new RectRegion(-5, 5, -5, 5); - r1.intersect(r2); - - assertEquals(0, r1.getMinX().doubleValue(), 0); - assertEquals(5, r1.getMaxX().doubleValue(), 0); - assertEquals(0, r1.getMinY().doubleValue(), 0); - assertEquals(5, r1.getMaxY().doubleValue(), 0); - } - - @Test - public void testClip_nonIntersectingDimensions() throws Exception { - RectRegion r1 = new RectRegion(0, 10, 0, 10); - RectRegion r2 = new RectRegion(100, 200, 100, 200); - r1.intersect(r2); - - assertEquals(null, r1.getMinX()); - assertEquals(null, r1.getMaxX()); - assertEquals(null, r1.getMinY()); - assertEquals(null, r1.getMaxY()); - - r1 = new RectRegion(0, 10, 0, 10); - r2 = new RectRegion(-200, -100, -200, -100); - r1.intersect(r2); - - assertEquals(null, r1.getMinX()); - assertEquals(null, r1.getMaxX()); - assertEquals(null, r1.getMinY()); - assertEquals(null, r1.getMaxY()); - } - - @Test - public void testUnion() throws Exception { - RectRegion r1 = new RectRegion(0, 10, 0, 10); - RectRegion r2 = new RectRegion(100, 200, 100, 200); - - r1.union(r2); - - assertEquals(0, r1.getMinX().doubleValue(), 0); - assertEquals(200, r1.getMaxX().doubleValue(), 0); - assertEquals(0, r1.getMinY().doubleValue(), 0); - assertEquals(200, r1.getMaxY().doubleValue(), 0); - - r1 = new RectRegion(0, 10, 0, 10); - r2.union(r1); - - assertEquals(0, r2.getMinX().doubleValue(), 0); - assertEquals(200, r2.getMaxX().doubleValue(), 0); - assertEquals(0, r2.getMinY().doubleValue(), 0); - assertEquals(200, r2.getMaxY().doubleValue(), 0); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/SampledXYSeriesTest.java b/androidplot-core/src/test/java/com/androidplot/xy/SampledXYSeriesTest.java deleted file mode 100644 index 95cea342323b0797245d2dcdcbbc49f1b6910250..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/SampledXYSeriesTest.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.androidplot.xy; - -import com.androidplot.test.*; - -import org.junit.*; - -import static junit.framework.Assert.assertEquals; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; - -/** - * Tests {@link SampledXYSeries} - */ -public class SampledXYSeriesTest extends AndroidplotTest { - - @Test - public void testInit() throws Exception { - - XYSeries rawData = TestUtils.generateXYSeries("my series", 2000); - SampledXYSeries s1 = spy(new SampledXYSeries(rawData, 2, 100)); - - // expect 5 setZoomFactor levels (besides 1x): 2x, 4x, 8x, 16x, 32x - assertEquals(4, s1.getZoomLevels().size()); - assertEquals(1000, s1.getZoomLevels().get(0).size()); // 2x - assertEquals(500, s1.getZoomLevels().get(1).size()); // 4x - assertEquals(250, s1.getZoomLevels().get(2).size()); // 8x - assertEquals(125, s1.getZoomLevels().get(3).size()); // 16x - - SampledXYSeries s2 = spy(new SampledXYSeries(rawData, 4, 100)); - - // expect 2 setZoomFactor levels (besides 1x): 4x & 16x: - assertEquals(2, s2.getZoomLevels().size()); - assertEquals(500, s2.getZoomLevels().get(0).size()); // 4x - assertEquals(125, s2.getZoomLevels().get(1).size()); // 16x - } - - @Test - public void testGetZoomIndex() throws Exception { - assertEquals(0, SampledXYSeries.getZoomIndex(2, 2)); - assertEquals(1, SampledXYSeries.getZoomIndex(3, 2)); - assertEquals(1, SampledXYSeries.getZoomIndex(4, 2)); - assertEquals(2, SampledXYSeries.getZoomIndex(8, 2)); - assertEquals(2, SampledXYSeries.getZoomIndex(9, 2)); - assertEquals(2, SampledXYSeries.getZoomIndex(10, 2)); - assertEquals(3, SampledXYSeries.getZoomIndex(15, 2)); - assertEquals(3, SampledXYSeries.getZoomIndex(16, 2)); - assertEquals(3, SampledXYSeries.getZoomIndex(17, 2)); - assertEquals(4, SampledXYSeries.getZoomIndex(31, 2)); - assertEquals(4, SampledXYSeries.getZoomIndex(32, 2)); - - assertEquals(0, SampledXYSeries.getZoomIndex(1, 4)); - assertEquals(0, SampledXYSeries.getZoomIndex(4, 4)); - assertEquals(1, SampledXYSeries.getZoomIndex(15, 4)); - assertEquals(1, SampledXYSeries.getZoomIndex(16, 4)); - assertEquals(1, SampledXYSeries.getZoomIndex(17, 4)); - assertEquals(2, SampledXYSeries.getZoomIndex(63, 4)); - assertEquals(2, SampledXYSeries.getZoomIndex(64, 4)); - assertEquals(2, SampledXYSeries.getZoomIndex(65, 4)); - } - - @Test - public void testSetZoomFactor() throws Exception { - XYSeries rawData = TestUtils.generateXYSeries("my series", 2000); - SampledXYSeries sampledXYSeries = spy(new SampledXYSeries(rawData, 2, 100)); - sampledXYSeries.setZoomFactor(2); - assertEquals(1000, sampledXYSeries.size()); - sampledXYSeries.setZoomFactor(4); - assertEquals(500, sampledXYSeries.size()); - sampledXYSeries.setZoomFactor(8); - assertEquals(250, sampledXYSeries.size()); - sampledXYSeries.setZoomFactor(16); - assertEquals(125, sampledXYSeries.size()); - } - - @Test - public void testResample() { - XYSeries rawData = TestUtils.generateXYSeries("my series", 10000); - SampledXYSeries sampledXYSeries = new SampledXYSeries(rawData, 2, 200); - assertEquals(5, sampledXYSeries.getZoomLevels().size()); - } - - /** - * Ignored until null support is added to {@link LTTBSampler}. - */ - @Ignore - @Test - public void testResample_supportsNullVals() { - XYSeries rawData = TestUtils.generateXYSeriesWithNulls("my series", 10000); - SampledXYSeries sampledXYSeries = new SampledXYSeries(rawData, 2, 200); - assertEquals(5, sampledXYSeries.getZoomLevels().size()); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/ScalingXYSeriesTest.java b/androidplot-core/src/test/java/com/androidplot/xy/ScalingXYSeriesTest.java deleted file mode 100644 index 9075642826d6847183b13e5624b82e5e6fb1397c..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/ScalingXYSeriesTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.androidplot.xy; - -import com.androidplot.test.AndroidplotTest; - -import org.junit.Test; - -import static junit.framework.Assert.assertEquals; - -/** - * Tests {@link ScalingXYSeries}. - */ -public class ScalingXYSeriesTest extends AndroidplotTest { - - @Test - public void testScale_yOnly() { - SimpleXYSeries s1 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 0, 5, 10); - ScalingXYSeries scaled1 = new ScalingXYSeries(s1, 0.5, ScalingXYSeries.Mode.Y_ONLY); - - assertEquals(0d, scaled1.getX(0).doubleValue()); - assertEquals(0d, scaled1.getY(0).doubleValue()); - - assertEquals(1d, scaled1.getX(1).doubleValue()); - assertEquals(2.5d, scaled1.getY(1).doubleValue()); - - assertEquals(2d, scaled1.getX(2).doubleValue()); - assertEquals(5d, scaled1.getY(2).doubleValue()); - } - - @Test - public void testScale_xOnly() { - SimpleXYSeries s1 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 0, 5, 10); - ScalingXYSeries scaled1 = new ScalingXYSeries(s1, 0.5, ScalingXYSeries.Mode.X_ONLY); - - assertEquals(0d, scaled1.getX(0).doubleValue()); - assertEquals(0d, scaled1.getY(0).doubleValue()); - - assertEquals(0.5d, scaled1.getX(1).doubleValue()); - assertEquals(5d, scaled1.getY(1).doubleValue()); - - assertEquals(1d, scaled1.getX(2).doubleValue()); - assertEquals(10d, scaled1.getY(2).doubleValue()); - } - - @Test - public void testScale_xAndY() { - SimpleXYSeries s1 = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 0, 5, 10); - ScalingXYSeries scaled1 = new ScalingXYSeries(s1, 0.5, ScalingXYSeries.Mode.X_AND_Y); - - assertEquals(0d, scaled1.getX(0).doubleValue()); - assertEquals(0d, scaled1.getY(0).doubleValue()); - - assertEquals(0.5d, scaled1.getX(1).doubleValue()); - assertEquals(2.5d, scaled1.getY(1).doubleValue()); - - assertEquals(1d, scaled1.getX(2).doubleValue()); - assertEquals(5d, scaled1.getY(2).doubleValue()); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/SimpleXYSeriesTest.java b/androidplot-core/src/test/java/com/androidplot/xy/SimpleXYSeriesTest.java deleted file mode 100644 index dc21ab7c89397e7c7dd8b9e6a8f662dac6eb5657..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/SimpleXYSeriesTest.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.xy; - -import org.junit.Test; - -import java.util.Arrays; -import java.util.NoSuchElementException; - -import static junit.framework.Assert.assertEquals; - -public class SimpleXYSeriesTest { - - @Test - public void constructor_yValsOnly() throws Exception { - Number[] yVals = {5, 6, 7, 8, 9}; - SimpleXYSeries series = new SimpleXYSeries(Arrays.asList(yVals), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "test"); - - assertEquals(yVals[0], series.getY(0)); - assertEquals(yVals[1], series.getY(1)); - assertEquals(yVals[2], series.getY(2)); - assertEquals(yVals[3], series.getY(3)); - assertEquals(yVals[4], series.getY(4)); - - assertEquals(0, series.getX(0)); - assertEquals(1, series.getX(1)); - assertEquals(2, series.getX(2)); - assertEquals(3, series.getX(3)); - assertEquals(4, series.getX(4)); - } - - @Test - public void constructor_xyInterleaved() throws Exception { - Number[] yVals = {55, 5, 66, 6, 77, 7, 88, 8, 99, 9}; - SimpleXYSeries series = new SimpleXYSeries(Arrays.asList(yVals), SimpleXYSeries.ArrayFormat.XY_VALS_INTERLEAVED, "test"); - - assertEquals(5, series.getY(0)); - assertEquals(6, series.getY(1)); - assertEquals(7, series.getY(2)); - assertEquals(8, series.getY(3)); - assertEquals(9, series.getY(4)); - - assertEquals(55, series.getX(0)); - assertEquals(66, series.getX(1)); - assertEquals(77, series.getX(2)); - assertEquals(88, series.getX(3)); - assertEquals(99, series.getX(4)); - } - - @Test - public void constructor_xAndYLists() throws Exception { - Number[] yVals = {5, 6, 7, 8, 9}; - Number[] xVals = {1, 2, 3, 4, 5}; - SimpleXYSeries series = new SimpleXYSeries(Arrays.asList(xVals), Arrays.asList(yVals), "test"); - - assertEquals(5, series.getY(0)); - assertEquals(6, series.getY(1)); - assertEquals(7, series.getY(2)); - assertEquals(8, series.getY(3)); - assertEquals(9, series.getY(4)); - - assertEquals(1, series.getX(0)); - assertEquals(2, series.getX(1)); - assertEquals(3, series.getX(2)); - assertEquals(4, series.getX(3)); - assertEquals(5, series.getX(4)); - } - - @Test - public void addRemove_modifiesSeries() throws Exception { - Number[] yVals = {5, 6, 7, 8, 9}; - Number[] xVals = {1, 2, 3, 4, 5}; - SimpleXYSeries series = new SimpleXYSeries(Arrays.asList(xVals), Arrays.asList(yVals), "test"); - - // chop off the tail: - series.removeLast(); - assertEquals(8, series.getY(series.size()-1)); - assertEquals(4, series.getX(series.size()-1)); - - // chop off the head: - series.removeFirst(); - assertEquals(6, series.getY(0)); - assertEquals(2, series.getX(0)); - - // add to the tail: - series.addLast(22, 33); - assertEquals(33, series.getY(series.size()-1)); - assertEquals(22, series.getX(series.size()-1)); - - // add to the head: - series.addFirst(55, 66); - assertEquals(66, series.getY(0)); - assertEquals(55, series.getX(0)); - } - - @Test - public void set_setsExpectedValue() throws Exception { - Number[] yVals = {5, 6, 7, 8, 9}; - Number[] xVals = {1, 2, 3, 4, 5}; - SimpleXYSeries series = new SimpleXYSeries(Arrays.asList(xVals), Arrays.asList(yVals), "test"); - - int size = series.size(); - - series.setX(22, 2); - assertEquals(22, series.getX(2)); - - // make sure size has not changed: - assertEquals(size, series.size()); - - series.setY(23, 2); - assertEquals(23, series.getY(2)); - - // make sure size has not changed: - assertEquals(size, series.size()); - } - - @Test - public void resize_emptySeries_resizesSeries() { - SimpleXYSeries series = new SimpleXYSeries("series"); - series.resize(10); - assertEquals(10, series.size()); - - series.resize(20); - assertEquals(20, series.size()); - - series.resize(1); - assertEquals(1, series.size()); - - series.resize(0); - assertEquals(0, series.size()); - - series.resize(0); - assertEquals(0, series.size()); - } - - @Test - public void resize_yValsOnly_resizesSeries() { - SimpleXYSeries series = new SimpleXYSeries( - SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "", 1, 2, 3); - series.resize(10); - assertEquals(10, series.size()); - } - - @Test - public void setXY_modifiesSeries() { - SimpleXYSeries series = new SimpleXYSeries("series"); - series.resize(5); - series.setXY(100, 200, 0); - - assertEquals(100, series.getX(0)); - assertEquals(200, series.getY(0)); - - } - - @Test - public void setX_yValsOnly_changesValue() { - SimpleXYSeries series = new SimpleXYSeries( - SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "", 1, 2, 3); - series.setX(9, 0); - assertEquals(9, series.getX(0)); - } - - @Test(expected = NoSuchElementException.class) - public void removeFirst_throwsNoSuchElementException_ifEmpty() { - new SimpleXYSeries("series").removeFirst(); - } - - @Test(expected = NoSuchElementException.class) - public void removeLast_throwsNoSuchElementException_ifEmpty() { - new SimpleXYSeries("series").removeLast(); - } - - @Test - public void setTitle_changesTitle() { - SimpleXYSeries series = new SimpleXYSeries("series"); - - final String newTitle = "newTitle"; - series.setTitle(newTitle); - assertEquals(newTitle, series.getTitle()); - } - - @Test - public void clear_removesEverything() { - SimpleXYSeries series = new SimpleXYSeries( - Arrays.asList(1, 2, 3, 4, 5), - SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "series"); - - series.clear(); - assertEquals(0, series.size()); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/StepCalculatorTest.java b/androidplot-core/src/test/java/com/androidplot/xy/StepCalculatorTest.java deleted file mode 100644 index 91cc0f9c6b3b9eecc8bc59b42dc940de5ab9674f..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/StepCalculatorTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.xy; - -import com.androidplot.*; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import static junit.framework.Assert.assertEquals; - -public class StepCalculatorTest { - @Before - public void setUp() throws Exception { - - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testGetStep() throws Exception { - - } - - @Test - public void testSubdivide() throws Exception { - int numSegments = 10; - - Region pixBounds = new Region(0, 100); - Region realBounds = new Region(0, 100); - Step step = XYStepCalculator.getStep(StepMode.SUBDIVIDE,numSegments, realBounds, pixBounds); - - assertEquals(pixBounds.length().doubleValue()/(numSegments-1), step.getStepPix()); - - // make sure large values dont break anything: - realBounds.setMin(1000000000); - realBounds.setMax(2000000000); - step = XYStepCalculator.getStep(StepMode.SUBDIVIDE, - numSegments, realBounds, pixBounds); - - assertEquals(pixBounds.length().doubleValue()/(numSegments-1), step.getStepPix()); - } - - @Test - public void testIncrementByVal() throws Exception { - Region pixBounds = new Region(50, 150); - Region realBounds = new Region(100, 200); - Step step = XYStepCalculator.getStep(StepMode.INCREMENT_BY_VAL, 1, realBounds, pixBounds); - assertEquals(1.0, step.getStepPix()); - } - - @Test - public void testIncrementByPixels() throws Exception { - Region pixBounds = new Region(50, 150); - Region realBounds = new Region(100, 200); - Step step = XYStepCalculator.getStep(StepMode.INCREMENT_BY_PIXELS, 1, realBounds, pixBounds); - assertEquals(1.0, step.getStepPix()); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/StepModelFitTest.java b/androidplot-core/src/test/java/com/androidplot/xy/StepModelFitTest.java deleted file mode 100644 index 5f34fd52e43d6692c562786cfe4a3f9b083277c0..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/StepModelFitTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.androidplot.xy; - -import com.androidplot.Region; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class StepModelFitTest { - - Region regionSmall = new Region(0,11); - Region regionBig = new Region(-111,420); - Region regionZero = new Region(0, 0); - Region regionUndef = new Region(0, null); - - double[] stpSmall = {1,2,5}, stpBig = {1,10,100}, nonsense = {0}; - - @Before - public void setUp() throws Exception { - - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void getValue() throws Exception { - - StepModelFit model = new StepModelFit(regionSmall,stpSmall,3); - - assertEquals(5.0, model.getValue(), 0.0); - model.setValue(5.0); - assertEquals(2.0, model.getValue(), 0.0); - model.setValue(7.0); - assertEquals(2.0, model.getValue(), 0.0); - - model.setSteps(stpBig); - assertEquals(1.0, model.getValue(), 0.0); - - model.setScale(regionBig); - assertEquals(100.0, model.getValue(), 0.0); - model.setValue(1000.0); - assertEquals(1.0, model.getValue(), 0.0); - - // bad parameters - model.setSteps(nonsense); - assertArrayEquals(stpBig,model.getSteps(), 0.0); - - model.setScale(regionZero); - assertEquals(stpBig[0], model.getValue(), 0.0); - - model.setScale(regionUndef); - model.setValue(1.1); - assertEquals(1.1, model.getValue(), 0.0); - } - -} \ No newline at end of file diff --git a/androidplot-core/src/test/java/com/androidplot/xy/XYGraphWidgetTest.java b/androidplot-core/src/test/java/com/androidplot/xy/XYGraphWidgetTest.java deleted file mode 100644 index 03897972c7781fcdb70af7a77d2f2a559040c8fb..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/XYGraphWidgetTest.java +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.xy; - -import android.content.res.*; -import android.graphics.*; - -import com.androidplot.test.*; -import com.androidplot.ui.*; -import com.androidplot.util.DisplayDimensions; - -import org.junit.*; -import org.mockito.*; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertTrue; -import static junit.framework.Assert.fail; -import static org.mockito.ArgumentMatchers.anyDouble; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.anyFloat; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class XYGraphWidgetTest extends AndroidplotTest { - - @Mock - LayoutManager layoutManager; - - XYPlot xyPlot; - - @Mock - TypedArray typedArray; - - @Mock - XYSeriesRegistry seriesRegistry; - - RectRegion bounds = new RectRegion(0, 100, 0, 100); - - @Mock - Canvas canvas; - - // this is a spy - Size size; - - // this is a spy - XYGraphWidget graphWidget; - - - @Before - public void setUp() { - size = spy(new Size(100, SizeMode.ABSOLUTE, 100, SizeMode.ABSOLUTE)); - xyPlot = spy(new XYPlot(getContext(), "XYPlot")); - when(xyPlot.getRegistry()).thenReturn(seriesRegistry); - when(xyPlot.getBounds()).thenReturn(bounds); - when(xyPlot.getDomainOrigin()).thenReturn(0); - when(xyPlot.getRangeOrigin()).thenReturn(0); - - xyPlot.setDomainStep(StepMode.INCREMENT_BY_VAL, 1); - xyPlot.setRangeStep(StepMode.INCREMENT_BY_VAL, 1); - - graphWidget = spy(new XYGraphWidget(layoutManager, xyPlot, size)); - graphWidget.setGridRect(new RectF(0, 0, 10, 100)); - graphWidget.setLabelRect(new RectF(0, 0, 100, 100)); - } - - @Test - public void processAttrs_withDefaults_disablesGridClipping() { - XYGraphWidget graphWidget = spy(new XYGraphWidget(layoutManager, xyPlot, size)); - - graphWidget.processAttrs(typedArray); - verify(graphWidget, times(1)).setGridClippingEnabled(false); - } - - @Test - public void doOnDraw_drawGridOnTopFalse_drawsGridAfterData() throws Exception { - XYGraphWidget graphWidget = spy(new XYGraphWidget(layoutManager, xyPlot, size)); - graphWidget.setDrawGridOnTop(false); - doNothing().when(graphWidget).drawGrid(canvas); - doNothing().when(graphWidget).drawData(canvas); - - final RectF canvasRect = new RectF(0, 0, 100, 100); - graphWidget.onResize(null, canvasRect); - graphWidget.doOnDraw(canvas, canvasRect); - - InOrder io = inOrder(graphWidget); - io.verify(graphWidget).drawGrid(canvas); - io.verify(graphWidget).drawData(canvas); - } - - @Test - public void doOnDraw_drawGridOnTopTrue_drawsGridBeforeData() throws Exception { - XYGraphWidget graphWidget = spy(new XYGraphWidget(layoutManager, xyPlot, size)); - graphWidget.setDrawGridOnTop(true); - doNothing().when(graphWidget).drawGrid(canvas); - doNothing().when(graphWidget).drawData(canvas); - - final RectF canvasRect = new RectF(0, 0, 100, 100); - graphWidget.onResize(null, canvasRect); - graphWidget.doOnDraw(canvas, canvasRect); - - InOrder io = inOrder(graphWidget); - io.verify(graphWidget).drawData(canvas); - io.verify(graphWidget).drawGrid(canvas); - } - - @Test - public void drawMarkers_drawsLineForEachMarker() { - xyPlot.addMarker(new XValueMarker(1, "x")); - xyPlot.addMarker(new YValueMarker(-1, "y")); - - graphWidget.drawMarkers(canvas); - - // TODO: verifications - verify(canvas, times(2)) - .drawLine(anyFloat(), anyFloat(), anyFloat(), anyFloat(), any(Paint.class)); - } - - @Test - public void drawGrid_nullOrigin_drawsGrid() { - when(xyPlot.getDomainOrigin()).thenReturn(null); - when(xyPlot.getRangeOrigin()).thenReturn(null); - runDrawGridTest(); - } - - @Test - public void drawGrid_zeroOrigin_drawsGrid() { - when(xyPlot.getDomainOrigin()).thenReturn(0); - when(xyPlot.getRangeOrigin()).thenReturn(0); - runDrawGridTest(); - } - - @Test - public void drawGrid_centeredOrigin_drawsGrid() { - - // set origin to midpoint so we exercise - // code to draw lines on both sides of the origin: - when(xyPlot.getDomainOrigin()).thenReturn(50); - when(xyPlot.getRangeOrigin()).thenReturn(50); - runDrawGridTest(); - } - - @Test - public void drawCursors_withCursorPaintAndPosition_drawsCursorLines() { - final Paint domainCursorPaint = new Paint(); - graphWidget.setDomainCursorPaint(domainCursorPaint); - - final Paint rangeCursorPaint = new Paint(); - graphWidget.setRangeCursorPaint(rangeCursorPaint); - graphWidget.setRangeCursorPosition(0f); - graphWidget.setDomainCursorPosition(0f); - graphWidget.drawCursors(canvas); - - // expect one line to be drawn for each cursor: - verify(canvas, times(1)).drawLine(anyFloat(), anyFloat(), anyFloat(), anyFloat(), eq(domainCursorPaint)); - verify(canvas, times(1)).drawLine(anyFloat(), anyFloat(), anyFloat(), anyFloat(), eq(rangeCursorPaint)); - } - - @Test - public void testDrawCursors_noCursorPaintOrPosition_drawsNoCursorLines() { - graphWidget.setDomainCursorPaint(null); - graphWidget.setRangeCursorPaint(null); - - graphWidget.drawCursors(canvas); - - // no lines should be drawn onto the canvas: - verify(canvas, times(0)).drawLine(anyFloat(), anyFloat(), anyFloat(), anyFloat(), any(Paint.class)); - } - - @Test - public void drawCursorLabel_drawsText() { - graphWidget.setDomainCursorPosition(0f); - graphWidget.setRangeCursorPosition(0f); - XYGraphWidget.CursorLabelFormatter clf = mock(XYGraphWidget.CursorLabelFormatter.class); - when(clf.getTextPaint()).thenReturn(new Paint()); - when(clf.getLabelText(any(Number.class), any(Number.class))).thenReturn("bla"); - when(graphWidget.getCursorLabelFormatter()).thenReturn(clf); - graphWidget.drawCursorLabel(canvas); - verify(canvas, times(1)).drawText(eq("bla"), anyFloat(), anyFloat(), any(Paint.class)); - } - - @Test - public void setLineLabelEdges_setsEdges() { - - graphWidget.setLineLabelEdges(XYGraphWidget.Edge.LEFT, XYGraphWidget.Edge.BOTTOM); - assertTrue(graphWidget.isLineLabelEnabled(XYGraphWidget.Edge.LEFT)); - assertTrue(graphWidget.isLineLabelEnabled(XYGraphWidget.Edge.BOTTOM)); - - graphWidget.setLineLabelEdges(XYGraphWidget.Edge.NONE); - assertFalse(graphWidget.isLineLabelEnabled(XYGraphWidget.Edge.TOP)); - assertFalse(graphWidget.isLineLabelEnabled(XYGraphWidget.Edge.BOTTOM)); - assertFalse(graphWidget.isLineLabelEnabled(XYGraphWidget.Edge.LEFT)); - assertFalse(graphWidget.isLineLabelEnabled(XYGraphWidget.Edge.RIGHT)); - } - - @Test - public void setLineLabelEdges_bitfield_setsEdges() { - - graphWidget.setLineLabelEdges( - XYGraphWidget.Edge.TOP.getValue() | XYGraphWidget.Edge.RIGHT.getValue()); - - assertTrue(graphWidget.isLineLabelEnabled(XYGraphWidget.Edge.TOP)); - assertTrue(graphWidget.isLineLabelEnabled(XYGraphWidget.Edge.RIGHT)); - assertFalse(graphWidget.isLineLabelEnabled(XYGraphWidget.Edge.BOTTOM)); - assertFalse(graphWidget.isLineLabelEnabled(XYGraphWidget.Edge.LEFT)); - } - - @Test - public void screenToSeries_returnsSeriesCoords() { - when(xyPlot.getBounds()).thenReturn(new RectRegion(-100, 100, -100, 100)); - - XYCoords coords = graphWidget.screenToSeries(new PointF(0, 0)); - assertEquals(-100, coords.x.intValue()); - assertEquals(100, coords.y.intValue()); - - coords = graphWidget.screenToSeries(new PointF(10, 100)); - assertEquals(100, coords.x.intValue()); - assertEquals(-100, coords.y.intValue()); - - coords = graphWidget.screenToSeries(new PointF(5, 50)); - assertEquals(0, coords.x.intValue()); - assertEquals(0, coords.y.intValue()); - } - - @Test - public void seriesToScreen_returnsScreenPoint() { - when(xyPlot.getBounds()).thenReturn(new RectRegion(-100, 100, -100, 100)); - - PointF point = graphWidget.seriesToScreen(new XYCoords(-100, 100)); - assertEquals(0f, point.x); - assertEquals(0f, point.y); - - point = graphWidget.seriesToScreen(new XYCoords(100, -100)); - assertEquals(10f, point.x); - assertEquals(100f, point.y); - - point = graphWidget.seriesToScreen(new XYCoords(0, 0)); - assertEquals(5f, point.x); - assertEquals(50f, point.y); - } - - @Test - public void screenToSeriesX_returnsSeriesValue() { - when(xyPlot.getBounds()).thenReturn(new RectRegion(-100, 100, -100, 100)); - - assertEquals(-100, graphWidget.screenToSeriesX(new PointF(0, 0)).intValue()); - assertEquals(100, graphWidget.screenToSeriesX(new PointF(10, 100)).intValue()); - assertEquals(0, graphWidget.screenToSeriesX(new PointF(5, 50)).intValue()); - } - - @Test - public void screenToSeriesY_returnsSeriesValue() { - when(xyPlot.getBounds()).thenReturn(new RectRegion(-100, 100, -100, 100)); - - assertEquals(100, graphWidget.screenToSeriesY(new PointF(0, 0)).intValue()); - assertEquals(-100, graphWidget.screenToSeriesY(new PointF(100, 100)).intValue()); - assertEquals(0, graphWidget.screenToSeriesY(new PointF(50, 50)).intValue()); - } - - @Test - public void seriesToScreenX_returnsScreenValue() { - when(xyPlot.getBounds()).thenReturn(new RectRegion(-100, 100, -100, 100)); - - assertEquals(0f, graphWidget.seriesToScreenX(-100)); - assertEquals(10f, graphWidget.seriesToScreenX(100)); - assertEquals(5f, graphWidget.seriesToScreenX(0)); - } - - @Test - public void seriesToScreenY_returnsScreenValue() { - when(xyPlot.getBounds()).thenReturn(new RectRegion(-100, 100, -100, 100)); - - assertEquals(100f, graphWidget.seriesToScreenY(100)); - assertEquals(0f, graphWidget.seriesToScreenY(-100)); - assertEquals(50f, graphWidget.seriesToScreenY(0)); - } - - @Test - public void setGridInsets_updatesGridRect() { - graphWidget.setGridInsets(new Insets(0, 0, 0, 0)); - final RectF oldRect = graphWidget.getGridRect(); - - graphWidget.setGridInsets(new Insets(2, 2, 2, 2)); - final RectF newRect = graphWidget.getGridRect(); - - assertEquals(oldRect.left + 2, newRect.left); - assertEquals(oldRect.top + 2, newRect.top); - assertEquals(oldRect.right - 2, newRect.right); - assertEquals(oldRect.bottom -2, newRect.bottom); - } - - private void runDrawGridTest() { - doNothing().when(graphWidget). - drawDomainLine(any(Canvas.class), anyFloat(), any(Number.class), any(Paint.class), anyBoolean()); - - doNothing().when(graphWidget). - drawRangeLine(any(Canvas.class), anyFloat(), any(Number.class), any(Paint.class), anyBoolean()); - - xyPlot.setRangeBoundaries(0, 100, BoundaryMode.FIXED); - xyPlot.setDomainBoundaries(0, 100, BoundaryMode.FIXED); - - graphWidget.drawGrid(canvas); - - // expecting a 100x100 grid to be drawn: - verify(graphWidget, times(100)) - .drawDomainLine(eq(canvas), anyFloat(), anyDouble(), any(Paint.class), eq(false)); - - verify(graphWidget, times(100)) - .drawRangeLine(eq(canvas), anyFloat(), anyDouble(), any(Paint.class), eq(false)); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/XYLegendWidgetTest.java b/androidplot-core/src/test/java/com/androidplot/xy/XYLegendWidgetTest.java deleted file mode 100644 index b50f723731a834529b43201c378de750f27ef7f7..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/XYLegendWidgetTest.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.xy; - -import android.graphics.*; -import com.androidplot.test.AndroidplotTest; -import com.androidplot.ui.DynamicTableModel; -import com.androidplot.ui.LayoutManager; -import com.androidplot.ui.Size; -import com.androidplot.ui.SizeMode; -import com.google.common.collect.Lists; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InOrder; -import org.mockito.Mock; -import org.mockito.Mockito; - -import java.util.List; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class XYLegendWidgetTest extends AndroidplotTest { - - @Mock LayoutManager layoutManager; - @Mock XYPlot xyPlot; - @Mock Canvas canvas; - @Mock XYRegionFormatter xyRegionFormatter; - LineAndPointRenderer lineAndPointRenderer; - - Size widgetSize = new Size(100, SizeMode.ABSOLUTE, 100, SizeMode.ABSOLUTE); - Size iconSize = new Size(10, SizeMode.ABSOLUTE, 10, SizeMode.ABSOLUTE); - XYSeriesRegistry seriesRegistry; - - XYLegendWidget legendWidget; - - @Before - public void before() { - seriesRegistry = new XYSeriesRegistry(); - legendWidget = spy(new XYLegendWidget(layoutManager, xyPlot, widgetSize, - new DynamicTableModel(4, 4), iconSize)); - - lineAndPointRenderer = new LineAndPointRenderer(xyPlot); - - when(xyPlot.getRegistry()).thenReturn(seriesRegistry); - when(xyPlot.getRendererList()).thenReturn(Lists.newArrayList(lineAndPointRenderer)); - when(xyPlot.getRenderer(any(Class.class))).thenReturn(lineAndPointRenderer); - } - - @Test - public void draw_drawsLegendIcons_forEnabledItemsOnly() throws Exception { - final XYSeries s1 = mock(XYSeries.class); - final XYSeriesFormatter f1 = new LineAndPointFormatter(); - f1.setLegendIconEnabled(true); - - final XYSeries s2 = mock(XYSeries.class); - final XYSeriesFormatter f2 = new LineAndPointFormatter(); - f2.setLegendIconEnabled(false); - - final RectRegion r1 = new RectRegion(0, 0, 10, 10, "r1"); - final RectRegion r2 = new RectRegion(0, 0, 20, 20, "r2"); - f1.addRegion(r1, new XYRegionFormatter(0)); - f2.addRegion(r2, new XYRegionFormatter(0)); - - seriesRegistry.add(s1, f1); - seriesRegistry.add(s2, f2); - legendWidget.draw(canvas); - - verify(legendWidget, times(2)) - .drawRegionLegendIcon(any(Canvas.class), any(RectF.class), any(XYRegionFormatter.class)); - verify(legendWidget, times(3)) - .drawIcon(any(Canvas.class), any(RectF.class), any(XYLegendItem.class)); - } - - @Test - public void draw_sortsItemsAlphabeticallyByTitle() throws Exception{ - final XYLegendItem i1 = new XYLegendItem(XYLegendItem.Type.SERIES, - new LineAndPointFormatter(), "zoo"); - final XYLegendItem i2 = new XYLegendItem(XYLegendItem.Type.SERIES, - new LineAndPointFormatter(), "apple"); - final XYLegendItem i3 = new XYLegendItem(XYLegendItem.Type.SERIES, - new LineAndPointFormatter(), "boo"); - - final List legendItems = Lists.newArrayList(i1, i2, i3); - doReturn(legendItems).when(legendWidget).getLegendItems(); - - legendWidget.draw(canvas); - - InOrder inOrder = Mockito.inOrder(legendWidget); - - inOrder.verify(legendWidget).drawIcon(any(Canvas.class), any(RectF.class), eq(i2)); - inOrder.verify(legendWidget).drawIcon(any(Canvas.class), any(RectF.class), eq(i3)); - inOrder.verify(legendWidget).drawIcon(any(Canvas.class), any(RectF.class), eq(i1)); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/XYPlotTest.java b/androidplot-core/src/test/java/com/androidplot/xy/XYPlotTest.java deleted file mode 100644 index 2e8c60948ceaa66eba72c07ccf4c668f09802263..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/XYPlotTest.java +++ /dev/null @@ -1,553 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.xy; - -import android.graphics.*; -import com.androidplot.Plot; -import com.androidplot.test.AndroidplotTest; -import com.halfhp.fig.*; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.robolectric.RuntimeEnvironment; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; - -import static junit.framework.Assert.assertEquals; -import static org.mockito.Mockito.mock; - -public class XYPlotTest extends AndroidplotTest { - - XYPlot plot; // testing - - List numList1; - List numList2; - SimpleXYSeries series0To100; - - @Before - public void setUp() throws Exception { - - plot = new XYPlot(getContext(), "test"); - numList1 = Arrays.asList(0, 1, 3, 5, 10, 15, 25, 50, 75, 100); // 10 elements - numList2 = Arrays.asList(-100, 0, 1, 3, 5, 10, 15, 25, 50, 75, 100, 200); // 12 elements - series0To100 = new SimpleXYSeries(numList1, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, ""); - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testOriginFixedMode() throws Exception { - plot.addSeries(series0To100, new LineAndPointFormatter()); - plot.centerOnDomainOrigin(5, 2, BoundaryMode.FIXED); - plot.calculateMinMaxVals(); - - - assertEquals(3.0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(7.0, plot.getBounds().getMaxX().doubleValue(), 0); - } - - @Test - public void testOriginAutoMode() throws Exception { - plot.addSeries(series0To100, new LineAndPointFormatter()); - plot.centerOnDomainOrigin(5); - plot.calculateMinMaxVals(); - - assertEquals(10.0, plot.getBounds().getMaxX().doubleValue(), 0); // symmetry is @ 10, not 9 - assertEquals(0.0, plot.getBounds().getMinX().doubleValue(), 0); - - plot.centerOnRangeOrigin(50); - plot.calculateMinMaxVals(); - - assertEquals(100.0, plot.getBounds().getMaxY().doubleValue(), 0); - assertEquals(0.0, plot.getBounds().getMinY().doubleValue(), 0); - - } - - @Test - public void testOriginGrowMode() throws Exception { - plot.addSeries(series0To100, new LineAndPointFormatter()); - plot.centerOnDomainOrigin(5, null, BoundaryMode.GROW); - plot.calculateMinMaxVals(); - - assertEquals(0.0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(10.0, plot.getBounds().getMaxX().doubleValue(), 0); - - // introduce a larger domain set. boundaries should change - series0To100.setModel(numList2, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY); - plot.calculateMinMaxVals(); - - assertEquals(-1.0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(11.0, plot.getBounds().getMaxX().doubleValue(), 0); - - // revert series model back to the previous set. boundaries should remain the same - series0To100.setModel(numList1, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY); - plot.calculateMinMaxVals(); - - assertEquals(-1.0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(11.0, plot.getBounds().getMaxX().doubleValue(), 0); - } - - @Test - public void testOriginShrinkMode() throws Exception { - plot.addSeries(series0To100, new LineAndPointFormatter()); - plot.centerOnDomainOrigin(5, null, BoundaryMode.SHRINK); - plot.calculateMinMaxVals(); - - assertEquals(0.0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(10.0, plot.getBounds().getMaxX().doubleValue(), 0); - - // update with more extreme values...nothing should change in shrink mode: - series0To100.setModel(numList2,SimpleXYSeries.ArrayFormat.Y_VALS_ONLY); - - assertEquals(0.0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(10.0, plot.getBounds().getMaxX().doubleValue(), 0); - - } - - @Test(expected = IllegalArgumentException.class) - public void centerOnRangeOrigin_throwsIllegalArgumentException_ifNullOrigin() { - plot.centerOnRangeOrigin(null); - } - - @Test(expected = IllegalArgumentException.class) - public void centerOnDomainOrigin_throwsIllegalArgumentException_ifNullOrigin() { - plot.centerOnDomainOrigin(null); - } - - // Ifor not sure about filling in test stubs just going to do my own stuff instead. - @Test - public void testsetDomainBoundaries() throws Exception { - plot.addSeries(series0To100, new LineAndPointFormatter()); - plot.calculateMinMaxVals(); - - // default to auto so run them - assertEquals(0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(9, plot.getBounds().getMaxX().doubleValue(), 0); - - plot.setDomainBoundaries(2, BoundaryMode.FIXED, 8, BoundaryMode.FIXED); - plot.calculateMinMaxVals(); - - // fixed - assertEquals(2, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(8, plot.getBounds().getMaxX().doubleValue(), 0); - - // back to auto - plot.setDomainBoundaries(2, BoundaryMode.AUTO, 8, BoundaryMode.AUTO); - plot.calculateMinMaxVals(); - - // run again - assertEquals(0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(9, plot.getBounds().getMaxX().doubleValue(), 0); - - // we are not testing MinY well with this dataset. - // try grow - plot.setDomainBoundaries(2, BoundaryMode.GROW, 8, BoundaryMode.GROW); - plot.calculateMinMaxVals(); - - // run inital - assertEquals(0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(9, plot.getBounds().getMaxX().doubleValue(), 0); - - // update with more extreme values... - series0To100.setModel(numList2,SimpleXYSeries.ArrayFormat.Y_VALS_ONLY); - plot.calculateMinMaxVals(); - - // after growing - assertEquals(0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(11, plot.getBounds().getMaxX().doubleValue(), 0); - - // back to previous - series0To100.setModel(numList1,SimpleXYSeries.ArrayFormat.Y_VALS_ONLY); - plot.calculateMinMaxVals(); - - // should not of changed. - assertEquals(0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(11, plot.getBounds().getMaxX().doubleValue(), 0); - - // back to big - series0To100.setModel(numList2,SimpleXYSeries.ArrayFormat.Y_VALS_ONLY); - - plot.setDomainBoundaries(2, BoundaryMode.SHRINK, 8, BoundaryMode.SHRINK); - plot.calculateMinMaxVals(); - - // run inital - assertEquals(0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(11, plot.getBounds().getMaxX().doubleValue(), 0); - - // now small - series0To100.setModel(numList1,SimpleXYSeries.ArrayFormat.Y_VALS_ONLY); - plot.calculateMinMaxVals(); - - // after shrinking - assertEquals(0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(9, plot.getBounds().getMaxX().doubleValue(), 0); - - // back to previous - series0To100.setModel(numList2,SimpleXYSeries.ArrayFormat.Y_VALS_ONLY); - plot.calculateMinMaxVals(); - - // should not of changed. - assertEquals(0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(9, plot.getBounds().getMaxX().doubleValue(), 0); - - // back to auto - plot.setDomainBoundaries(2, BoundaryMode.AUTO, 8, BoundaryMode.AUTO); - plot.calculateMinMaxVals(); - - // should of changed. - assertEquals(0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(11, plot.getBounds().getMaxX().doubleValue(), 0); - } - - @Test - public void setRangeBoundaries_calculatesCorrectMinMaxVals() throws Exception { - plot.addSeries(series0To100, new LineAndPointFormatter()); - plot.calculateMinMaxVals(); - - // default to auto so run them - assertEquals(0, plot.getBounds().getMinY().doubleValue(), 0); - assertEquals(100, plot.getBounds().getMaxY().doubleValue(), 0); - - plot.setRangeBoundaries(5, BoundaryMode.FIXED, 80, BoundaryMode.FIXED); - plot.calculateMinMaxVals(); - - // fixed - assertEquals(5, plot.getBounds().getMinY().doubleValue(), 0); - assertEquals(80, plot.getBounds().getMaxY().doubleValue(), 0); - - // back to auto - plot.setRangeBoundaries(2, BoundaryMode.AUTO, 8, BoundaryMode.AUTO); - plot.calculateMinMaxVals(); - - // run again - assertEquals(0, plot.getBounds().getMinY().doubleValue(), 0); - assertEquals(100, plot.getBounds().getMaxY().doubleValue(), 0); - - // try grow - plot.setRangeBoundaries(2, BoundaryMode.GROW, 8, BoundaryMode.GROW); - plot.calculateMinMaxVals(); - - // run inital - assertEquals(0, plot.getBounds().getMinY().doubleValue(), 0); - assertEquals(100, plot.getBounds().getMaxY().doubleValue(), 0); - - // update with more extreme values... - series0To100.setModel(numList2,SimpleXYSeries.ArrayFormat.Y_VALS_ONLY); - plot.calculateMinMaxVals(); - - // after growing - assertEquals(-100, plot.getBounds().getMinY().doubleValue(), 0); - assertEquals(200, plot.getBounds().getMaxY().doubleValue(), 0); - - // back to previous - series0To100.setModel(numList1,SimpleXYSeries.ArrayFormat.Y_VALS_ONLY); - plot.calculateMinMaxVals(); - - // should not of changed. - assertEquals(-100, plot.getBounds().getMinY().doubleValue(), 0); - assertEquals(200, plot.getBounds().getMaxY().doubleValue(), 0); - - // back to big - series0To100.setModel(numList2,SimpleXYSeries.ArrayFormat.Y_VALS_ONLY); - - plot.setRangeBoundaries(2, BoundaryMode.SHRINK, 8, BoundaryMode.SHRINK); - plot.calculateMinMaxVals(); - - // run inital - assertEquals(-100, plot.getBounds().getMinY().doubleValue(), 0); - assertEquals(200, plot.getBounds().getMaxY().doubleValue(), 0); - - // now small - series0To100.setModel(numList1,SimpleXYSeries.ArrayFormat.Y_VALS_ONLY); - plot.calculateMinMaxVals(); - - // after shrinking - assertEquals(0, plot.getBounds().getMinY().doubleValue(), 0); - assertEquals(100, plot.getBounds().getMaxY().doubleValue(), 0); - - // back to previous - series0To100.setModel(numList2,SimpleXYSeries.ArrayFormat.Y_VALS_ONLY); - plot.calculateMinMaxVals(); - - // should not of changed. - assertEquals(0, plot.getBounds().getMinY().doubleValue(), 0); - assertEquals(100, plot.getBounds().getMaxY().doubleValue(), 0); - - // back to auto - plot.setRangeBoundaries(2, BoundaryMode.AUTO, 8, BoundaryMode.AUTO); - plot.calculateMinMaxVals(); - - // should of changed. - assertEquals(-100, plot.getBounds().getMinY().doubleValue(), 0); - assertEquals(200, plot.getBounds().getMaxY().doubleValue(), 0); - } - - @Test - public void testSetDomainRightMinMax() throws Exception { - plot.addSeries(series0To100, new LineAndPointFormatter()); - plot.calculateMinMaxVals(); - - // default to auto so run them - assertEquals(0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(9, plot.getBounds().getMaxX().doubleValue(), 0); - - plot.getOuterLimits().setMaxX(10); - plot.calculateMinMaxVals(); - - // same values. - assertEquals(0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(9, plot.getBounds().getMaxX().doubleValue(), 0); - - series0To100.setModel(numList2,SimpleXYSeries.ArrayFormat.Y_VALS_ONLY); - plot.calculateMinMaxVals(); - - // on RightMax - assertEquals(0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(10, plot.getBounds().getMaxX().doubleValue(), 0); - - plot.getOuterLimits().setMaxX(null); - plot.calculateMinMaxVals(); - - // back to full - assertEquals(0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(11, plot.getBounds().getMaxX().doubleValue(), 0); - - // now the RightMin - plot.getInnerLimits().setMaxX(10); - plot.calculateMinMaxVals(); - - // still to full - assertEquals(0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(11, plot.getBounds().getMaxX().doubleValue(), 0); - - // small list - series0To100.setModel(numList1,SimpleXYSeries.ArrayFormat.Y_VALS_ONLY); - plot.calculateMinMaxVals(); - - // on RightMin - assertEquals(0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(10, plot.getBounds().getMaxX().doubleValue(), 0); - - // now off again - plot.getInnerLimits().setMaxX(null); - plot.calculateMinMaxVals(); - - // small values. - assertEquals(0, plot.getBounds().getMinX().doubleValue(), 0); - assertEquals(9, plot.getBounds().getMaxX().doubleValue(), 0); - } - - @Test - public void testSetRangeTopBottomMinMax() throws Exception { - plot.addSeries(series0To100, new LineAndPointFormatter()); - plot.calculateMinMaxVals(); - - // default to auto so run them - assertEquals(0, plot.getBounds().getMinY().doubleValue(), 0); - assertEquals(100, plot.getBounds().getMaxY().doubleValue(), 0); - - plot.getOuterLimits().setMaxY(110); - plot.getOuterLimits().setMinY(-50); - plot.calculateMinMaxVals(); - - // same values. - assertEquals(0, plot.getBounds().getMinY().doubleValue(), 0); - assertEquals(100, plot.getBounds().getMaxY().doubleValue(), 0); - - series0To100.setModel(numList2,SimpleXYSeries.ArrayFormat.Y_VALS_ONLY); - plot.calculateMinMaxVals(); - - // on Limits - assertEquals(-50, plot.getBounds().getMinY().doubleValue(), 0); - assertEquals(110, plot.getBounds().getMaxY().doubleValue(), 0); - - plot.getOuterLimits().setMaxY(null); - plot.getOuterLimits().setMinY(null); - plot.calculateMinMaxVals(); - - // back to full - assertEquals(-100, plot.getBounds().getMinY().doubleValue(), 0); - assertEquals(200, plot.getBounds().getMaxY().doubleValue(), 0); - - // now the Min - plot.getInnerLimits().setMaxY(150); - plot.getInnerLimits().setMinY(-60); - plot.calculateMinMaxVals(); - - // still to full - assertEquals(-100, plot.getBounds().getMinY().doubleValue(), 0); - assertEquals(200, plot.getBounds().getMaxY().doubleValue(), 0); - - // small list - series0To100.setModel(numList1,SimpleXYSeries.ArrayFormat.Y_VALS_ONLY); - plot.calculateMinMaxVals(); - - // on Limits - assertEquals(-60, plot.getBounds().getMinY().doubleValue(), 0); - assertEquals(150, plot.getBounds().getMaxY().doubleValue(), 0); - - // now off again - plot.getInnerLimits().setMaxY(null); - plot.getInnerLimits().setMinY(null); - plot.calculateMinMaxVals(); - - // small values. - assertEquals(0, plot.getBounds().getMinY().doubleValue(), 0); - assertEquals(100, plot.getBounds().getMaxY().doubleValue(), 0); - } - - @Test - public void setDomainUpperBoundary_overridesCalculatedBoundary() throws Exception { - plot.addSeries(series0To100, new LineAndPointFormatter()); - plot.setDomainUpperBoundary(350, BoundaryMode.FIXED); - plot.calculateMinMaxVals(); - assertEquals(350, plot.getBounds().getMaxX().intValue()); - } - - @Test - public void testSetDomainLowerBoundary() throws Exception { - plot.addSeries(series0To100, new LineAndPointFormatter()); - plot.setDomainLowerBoundary(-350, BoundaryMode.FIXED); - plot.calculateMinMaxVals(); - assertEquals(-350, plot.getBounds().getMinX().intValue()); - } - - @Test - public void testSetRangeUpperBoundary() throws Exception { - plot.addSeries(series0To100, new LineAndPointFormatter()); - plot.setRangeUpperBoundary(350, BoundaryMode.FIXED); - plot.calculateMinMaxVals(); - assertEquals(350, plot.getBounds().getMaxY().intValue()); - } - - @Test - public void testSetRangeLowerBoundary() throws Exception { - plot.addSeries(series0To100, new LineAndPointFormatter()); - plot.setRangeLowerBoundary(-350, BoundaryMode.FIXED); - plot.calculateMinMaxVals(); - assertEquals(-350, plot.getBounds().getMinY().intValue()); - } - - @Test - public void testSetDomainOrigin() throws Exception { - // TODO - } - - @Test - public void testSetRangeOrigin() throws Exception { - // TODO - } - - @Test - public void testConfigure() throws Exception { - HashMap params = new HashMap(); - String param1 = "this is a test."; - String param2 = Plot.RenderMode.USE_BACKGROUND_THREAD.toString(); - String param3 = "#FF0000"; - params.put("title.text", param1); - params.put("renderMode", param2); - params.put("backgroundPaint.color", param3); - - Fig.configure(RuntimeEnvironment.application, plot, params); - assertEquals(param1, plot.getTitle().getText()); - assertEquals(Plot.RenderMode.USE_BACKGROUND_THREAD, plot.getRenderMode()); - assertEquals(Color.parseColor(param3), plot.getBackgroundPaint().getColor()); - } - - @Test - public void removeMarker_withXMarker_removesExpectedXMarkerOnly() { - - XValueMarker xMarker1 = new XValueMarker(1, "x1"); - XValueMarker xMarker2 = new XValueMarker(2, "x2"); - XValueMarker xMarker3 = new XValueMarker(2, "x2"); - XValueMarker xMarker4 = new XValueMarker(2, "x2"); - XValueMarker xMarker5 = new XValueMarker(2, "x2"); - - plot.addMarker(xMarker1); - plot.addMarker(xMarker2); - plot.addMarker(xMarker3); - plot.addMarker(xMarker4); - plot.addMarker(xMarker5); - - assertEquals(5, plot.getXValueMarkers().size()); - - assertEquals(xMarker3, plot.removeMarker(xMarker3)); - assertEquals(4, plot.getXValueMarkers().size()); - } - - @Test - public void removeMarker_withYMarker_removesExpectedYMarkerOnly() { - - YValueMarker YMarker1 = new YValueMarker(1, "Y1"); - YValueMarker YMarker2 = new YValueMarker(2, "Y2"); - YValueMarker YMarker3 = new YValueMarker(2, "Y2"); - YValueMarker YMarker4 = new YValueMarker(2, "Y2"); - YValueMarker YMarker5 = new YValueMarker(2, "Y2"); - - plot.addMarker(YMarker1); - plot.addMarker(YMarker2); - plot.addMarker(YMarker3); - plot.addMarker(YMarker4); - plot.addMarker(YMarker5); - - assertEquals(5, plot.getYValueMarkers().size()); - - assertEquals(YMarker3, plot.removeMarker(YMarker3)); - assertEquals(4, plot.getYValueMarkers().size()); - } - - @Test - public void removeMarkers_removesAllXAndYMarkers() { - - XValueMarker xMarker1 = new XValueMarker(1, "x1"); - XValueMarker xMarker2 = new XValueMarker(2, "x2"); - XValueMarker xMarker3 = new XValueMarker(2, "x2"); - XValueMarker xMarker4 = new XValueMarker(2, "x2"); - XValueMarker xMarker5 = new XValueMarker(2, "x2"); - - plot.addMarker(xMarker1); - plot.addMarker(xMarker2); - plot.addMarker(xMarker3); - plot.addMarker(xMarker4); - plot.addMarker(xMarker5); - - YValueMarker YMarker1 = new YValueMarker(1, "Y1"); - YValueMarker YMarker2 = new YValueMarker(2, "Y2"); - YValueMarker YMarker3 = new YValueMarker(2, "Y2"); - YValueMarker YMarker4 = new YValueMarker(2, "Y2"); - YValueMarker YMarker5 = new YValueMarker(2, "Y2"); - - plot.addMarker(YMarker1); - plot.addMarker(YMarker2); - plot.addMarker(YMarker3); - plot.addMarker(YMarker4); - plot.addMarker(YMarker5); - - assertEquals(5, plot.getXValueMarkers().size()); - assertEquals(5, plot.getYValueMarkers().size()); - - plot.removeMarkers(); - assertEquals(0, plot.getXValueMarkers().size()); - assertEquals(0, plot.getYValueMarkers().size()); - } -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/XYSeriesRendererTest.java b/androidplot-core/src/test/java/com/androidplot/xy/XYSeriesRendererTest.java deleted file mode 100644 index 484dde3924096bba0e57153384a66bc751330a3f..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/XYSeriesRendererTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.xy; - -import android.graphics.RectF; - -import com.androidplot.*; -import com.androidplot.test.AndroidplotTest; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.robolectric.RuntimeEnvironment; - -import static junit.framework.Assert.assertEquals; - -public class XYSeriesRendererTest extends AndroidplotTest { - - @Before - public void setUp() throws Exception { - - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testDataToGridCorrelation() throws Exception { - RectF gridRect = new RectF(5, 5, 105, 105); - XYPlot plot = new XYPlot(RuntimeEnvironment.application, "Test"); - plot.setDomainStepMode(StepMode.SUBDIVIDE); - plot.setDomainStepValue(10); - plot.setDomainBoundaries(0, 100, BoundaryMode.FIXED); - plot.setRangeBoundaries(0, 100, BoundaryMode.FIXED); - plot.calculateMinMaxVals(); - Step domainStep = XYStepCalculator.getStep(plot, Axis.DOMAIN, gridRect); - - Region xBounds = new Region(0, 9); - - int x = 0; - double val = xBounds.transform(x, gridRect.left, gridRect.right, false); - assertEquals(val, (domainStep.getStepPix()*x) + gridRect.left); - - x = 1; - val = xBounds.transform(x, gridRect.left, gridRect.right, false); - assertEquals(val, (domainStep.getStepPix()*x) + gridRect.left); - - x = 9; - val = xBounds.transform(x, gridRect.left, gridRect.right, false); - assertEquals(val, (domainStep.getStepPix()*x) + gridRect.left); - } - -} diff --git a/androidplot-core/src/test/java/com/androidplot/xy/ZoomEstimatorTest.java b/androidplot-core/src/test/java/com/androidplot/xy/ZoomEstimatorTest.java deleted file mode 100644 index e33ff402f1e8c8ec058b6096726e123892abb0c0..0000000000000000000000000000000000000000 --- a/androidplot-core/src/test/java/com/androidplot/xy/ZoomEstimatorTest.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.androidplot.xy; - -import com.androidplot.test.*; - -import org.junit.*; -import org.mockito.*; - -import static junit.framework.Assert.*; -import static org.mockito.Mockito.*; - -/** - * Created by halfhp on 10/8/16. - */ -public class ZoomEstimatorTest extends AndroidplotTest { - - @Mock - XYPlot xyPlot; - - - @Test - public void testCheck() throws Exception { - ZoomEstimator estimator = spy(new ZoomEstimator()); - - SampledXYSeries series = - spy(new SampledXYSeries(TestUtils - .generateXYSeries("test series", 1000), 2, 100)); - series.resample(); - assertEquals(8d, series.getMaxZoomFactor()); - - XYSeriesBundle bundle = new XYSeriesBundle(series, null); - - when(xyPlot.getBounds()) - .thenReturn(new RectRegion(0, 1000, 0, 1000)) - .thenReturn(new RectRegion(0, 500, 0, 500)) - .thenReturn(new RectRegion(0, 1, 0, 1)); - - estimator.run(xyPlot, bundle); - estimator.run(xyPlot, bundle); - estimator.run(xyPlot, bundle); - - verify(series).setZoomFactor(8); - verify(series).setZoomFactor(4); - verify(series).setZoomFactor(1); - } - - @Test - public void testCalculateZoom() { - ZoomEstimator estimator = spy(new ZoomEstimator()); - - SampledXYSeries series = - spy(new SampledXYSeries(TestUtils - .generateXYSeries("test series", 1000), 2, 100)); - series.resample(); - - when(xyPlot.getBounds()) - .thenReturn(new RectRegion(0, 1000, 0, 1000)); - - // fully zoomed out so max zoom factor should be applied: - assertEquals(series.getMaxZoomFactor(), estimator.calculateZoom(series, new RectRegion(0, 1000, 0, 1000))); - - // fully zoomed in so min zoom factor should be applied: - assertEquals(1d, estimator.calculateZoom(series, new RectRegion(0, 1, 0, 1))); - - } -} diff --git a/build.gradle b/build.gradle index a00c8e72b8f78017283806734186e566cc8da311..2d3ec49da5c2d13a14d3798c498c6f56759b234a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,53 +1,40 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Top-level build file where you can add configuration options common to all sub-projects/modules. -apply plugin: 'java' +apply plugin: 'com.huawei.ohos.app' -allprojects { - repositories { - jcenter() - } -} +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#ZH-CN_TOPIC_0000001154985555__section1112183053510 +ohos { -ext { - theCompileSdkVersion = 28 - theTargetSdkVersion = 28 - theMinSdkVersion = 5 - theVersionName = '1.5.7' - theVersionCode = 1 + compileSdkVersion 5 + defaultConfig { + compatibleSdkVersion 5 + } } buildscript { repositories { - mavenCentral() + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } jcenter() - google() } - dependencies { - classpath 'com.android.tools.build:gradle:3.5.3' - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' - classpath 'com.dicedmelon.gradle:jacoco-android:0.1.4' + classpath 'com.huawei.ohos:hap:2.4.5.0' + classpath 'com.huawei.ohos:decctest:1.2.4.1' } } allprojects { repositories { - mavenCentral() - google() + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + jcenter() } } diff --git a/demoapp-wearable/.gitignore b/demoapp-wearable/.gitignore deleted file mode 100644 index 796b96d1c402326528b4ba3c12ee9d92d0e212e9..0000000000000000000000000000000000000000 --- a/demoapp-wearable/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/demoapp-wearable/build.gradle b/demoapp-wearable/build.gradle deleted file mode 100644 index 22e5186dfeab6fb1a9b0e2a478d0ae7dc0f884f2..0000000000000000000000000000000000000000 --- a/demoapp-wearable/build.gradle +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -buildscript { - repositories { - jcenter() - google() - } - dependencies { - classpath 'com.android.tools.build:gradle:3.1.1' - } -} -apply plugin: 'com.android.application' - -repositories { - jcenter() -} - -android { - compileSdkVersion theCompileSdkVersion - buildToolsVersion theBuildToolsVersion - - defaultConfig { - applicationId "com.androidplot.demo.wearable" - minSdkVersion 20 - targetSdkVersion theTargetSdkVersion - versionCode theVersionCode - versionName theVersionName - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_6 - targetCompatibility JavaVersion.VERSION_1_6 - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - compile project(':androidplot-core') - compile 'com.google.android.support:wearable:2.3.0' - compile 'com.google.android.gms:play-services-wearable:8.3.0' -} diff --git a/demoapp-wearable/proguard-rules.pro b/demoapp-wearable/proguard-rules.pro deleted file mode 100644 index 321058f67d2a31b63b2a363b1cb7c0e7c13543dd..0000000000000000000000000000000000000000 --- a/demoapp-wearable/proguard-rules.pro +++ /dev/null @@ -1,17 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in /usr/local/android_sdk/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/demoapp-wearable/src/main/AndroidManifest.xml b/demoapp-wearable/src/main/AndroidManifest.xml deleted file mode 100644 index 9ff883a6f5dad32de7a8ec16cc790c6e0e83db74..0000000000000000000000000000000000000000 --- a/demoapp-wearable/src/main/AndroidManifest.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/demoapp-wearable/src/main/java/com/androidplot/demo/wearable/MainActivity.java b/demoapp-wearable/src/main/java/com/androidplot/demo/wearable/MainActivity.java deleted file mode 100644 index ace6847f52209f5ebc1730ecb2e307b1737c0b69..0000000000000000000000000000000000000000 --- a/demoapp-wearable/src/main/java/com/androidplot/demo/wearable/MainActivity.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.demo.wearable; - -import android.app.Activity; -import android.graphics.DashPathEffect; -import android.os.Bundle; -import com.androidplot.util.PixelUtils; -import com.androidplot.xy.*; - -import java.util.Arrays; - -/** - * A simple XY Plot styled for wearables. - */ -public class MainActivity extends Activity { - - private XYPlot plot; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - // initialize our XYPlot reference: - plot = (XYPlot) findViewById(R.id.plot); - - // create a couple arrays of y-values to plot: - Number[] series1Numbers = {1, 4, 2, 8, 4, 16, 8, 32, 16, 64}; - Number[] series2Numbers = {5, 2, 10, 5, 20, 10, 40, 20, 80, 40}; - - // turn the above arrays into XYSeries': - // (Y_VALS_ONLY means use the element index as the x value) - XYSeries series1 = new SimpleXYSeries(Arrays.asList(series1Numbers), - SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Series1"); - - XYSeries series2 = new SimpleXYSeries(Arrays.asList(series2Numbers), - SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Series2"); - - // create formatters to use for drawing a series using LineAndPointRenderer - // and configure them from xml: - LineAndPointFormatter series1Format = new LineAndPointFormatter(); - series1Format.setPointLabelFormatter(new PointLabelFormatter()); - series1Format.configure(getApplicationContext(), - R.xml.line_point_formatter_with_labels); - - LineAndPointFormatter series2Format = new LineAndPointFormatter(); - series2Format.setPointLabelFormatter(new PointLabelFormatter()); - series2Format.configure(getApplicationContext(), - R.xml.line_point_formatter_with_labels_2); - - // add an "dash" effect to the series2 line: - series2Format.getLinePaint().setPathEffect( - new DashPathEffect(new float[] { - - // always use DP when specifying pixel sizes, to keep things consistent across devices: - PixelUtils.dpToPix(20), - PixelUtils.dpToPix(15)}, 0)); - - // just for fun, add some smoothing to the lines: - // see: http://androidplot.com/smooth-curves-and-androidplot/ - series1Format.setInterpolationParams( - new CatmullRomInterpolator.Params(10, CatmullRomInterpolator.Type.Centripetal)); - - series2Format.setInterpolationParams( - new CatmullRomInterpolator.Params(10, CatmullRomInterpolator.Type.Centripetal)); - - // add a new series' to the xyplot: - plot.addSeries(series1, series1Format); - plot.addSeries(series2, series2Format); - - // reduce the number of range labels - plot.setTicksPerRangeLabel(3); - - // rotate domain labels 45 degrees to make them more compact horizontally: - plot.getGraphWidget().setDomainLabelOrientation(-45); - } -} diff --git a/demoapp-wearable/src/main/res/layout/activity_main.xml b/demoapp-wearable/src/main/res/layout/activity_main.xml deleted file mode 100644 index 745bc40056c442d2dfba0747c77e8be070f5cfd8..0000000000000000000000000000000000000000 --- a/demoapp-wearable/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - diff --git a/demoapp-wearable/src/main/res/xml/line_point_formatter_with_labels.xml b/demoapp-wearable/src/main/res/xml/line_point_formatter_with_labels.xml deleted file mode 100644 index 2cf6008eacc6a087f9d46127fcde2a8eebda5f2c..0000000000000000000000000000000000000000 --- a/demoapp-wearable/src/main/res/xml/line_point_formatter_with_labels.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - \ No newline at end of file diff --git a/demoapp-wearable/src/main/res/xml/line_point_formatter_with_labels_2.xml b/demoapp-wearable/src/main/res/xml/line_point_formatter_with_labels_2.xml deleted file mode 100644 index a3851af1c833fdf0030a6998dde8e0b472a8cb61..0000000000000000000000000000000000000000 --- a/demoapp-wearable/src/main/res/xml/line_point_formatter_with_labels_2.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - \ No newline at end of file diff --git a/demoapp/build.gradle b/demoapp/build.gradle deleted file mode 100644 index 191280a56bdaab48b297f702a3b701f371b71f56..0000000000000000000000000000000000000000 --- a/demoapp/build.gradle +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -//apply plugin: 'com.android.application' -//apply plugin: 'com.github.triplet.play' - -buildscript { - - repositories { - mavenCentral() - } - dependencies { - classpath 'com.github.triplet.gradle:play-publisher:2.2.1' - } -} - -plugins { - id 'com.android.application' - id 'com.github.triplet.play' version '2.2.1' -} - -dependencies { - implementation project(':androidplot-core') - implementation 'com.crittercism:crittercism-android-agent:5.4.0' - - debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3' - releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3' - testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3' -} - -android { - compileSdkVersion theCompileSdkVersion - - defaultConfig { - versionCode theVersionCode - versionName theVersionName - minSdkVersion 14 - targetSdkVersion theTargetSdkVersion - applicationId "com.androidplot.demos" - } - - signingConfigs { - release { - storeFile file(System.getenv("KEYSTORE") ?: "keystore.jks") - storePassword System.getenv("KEYSTORE_PASSWORD") - keyAlias System.getenv("KEY_ALIAS") - keyPassword System.getenv("KEY_PASSWORD") - } - } - - buildTypes { - release { - zipAlignEnabled true - signingConfig signingConfigs.release - } - - debug { - debuggable true - } - } - - - /** - * TODO: uncomment this and address all the lint issues. - */ - lintOptions { - abortOnError false - } -} - -play { - // see: https://github.com/Triple-T/gradle-play-publisher - serviceAccountCredentials = file(System.getenv("PUBLISHER_ACCT_JSON_FILE") ?: "publisher.json") - track = 'beta' -} diff --git a/demoapp/proguard-project.txt b/demoapp/proguard-project.txt deleted file mode 100644 index 32bc957ba116934d143b0414ecd060c5f83f42b8..0000000000000000000000000000000000000000 --- a/demoapp/proguard-project.txt +++ /dev/null @@ -1,26 +0,0 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# remove all debug and verbose level logging statements: --assumenosideeffects class android.util.Log { - public static *** d(...); - public static *** v(...); -} diff --git a/demoapp/project.properties b/demoapp/project.properties deleted file mode 100644 index 29656f2da5fef6e58ad7887722022f8dbf492037..0000000000000000000000000000000000000000 --- a/demoapp/project.properties +++ /dev/null @@ -1,43 +0,0 @@ -# -# Copyright (c) 2012 AndroidPlot.com. All rights reserved. -# -# Redistribution and use of source without modification and derived binaries with or without modification, -# are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this list of -# conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, this list -# of conditions and the following disclaimer in the documentation and/or other materials -# provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY ANDROIDPLOT.COM ``AS IS'' AND ANY EXPRESS OR IMPLIED -# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANDROIDPLOT.COM OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# The views and conclusions contained in the software and documentation are those of the -# authors and should not be interpreted as representing official policies, either expressed -# or implied, of AndroidPlot.com. -# - -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}\tools\proguard\proguard-android.txt:proguard-project.txt -# using config with optimization enabled so that things like log statement removal will work: -proguard.config=${sdk.dir}/tools/proguard/proguard-android-optimize.txt:proguard-project.txt -# Project target. -target=android-16 diff --git a/demoapp/src/main/AndroidManifest.xml b/demoapp/src/main/AndroidManifest.xml deleted file mode 100644 index 89f1428fe590a6718b3a26641b9e3902293a26cb..0000000000000000000000000000000000000000 --- a/demoapp/src/main/AndroidManifest.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/demoapp/src/main/java/com/androidplot/demos/DemoApplication.java b/demoapp/src/main/java/com/androidplot/demos/DemoApplication.java deleted file mode 100644 index 9c931a7302a66f1e79f9c6a5af33825687f601f3..0000000000000000000000000000000000000000 --- a/demoapp/src/main/java/com/androidplot/demos/DemoApplication.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.androidplot.demos; - -import android.app.*; - -import com.squareup.leakcanary.*; - -public class DemoApplication extends Application { - - @Override public void onCreate() { - super.onCreate(); - initLeakCanary(); - } - - protected void initLeakCanary() { - if (LeakCanary.isInAnalyzerProcess(this)) { - return; - } - LeakCanary.install(this); - } -} - diff --git a/demoapp/src/main/java/com/androidplot/demos/MainActivity.java b/demoapp/src/main/java/com/androidplot/demos/MainActivity.java deleted file mode 100644 index 86dadb685fc6cf34b0f2bcbdf17e6169603b35e4..0000000000000000000000000000000000000000 --- a/demoapp/src/main/java/com/androidplot/demos/MainActivity.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.demos; - -import android.app.Activity; -import android.content.Intent; -import android.os.Bundle; -import android.util.Log; -import android.view.View; -import android.widget.Button; -import com.crittercism.app.Crittercism; - -public class MainActivity extends Activity { - - private static final String TAG = MainActivity.class.getName(); - - // DO *NOT* CHANGE THIS LINE! (CI-MATCH-POPULATE) - private static final String CRITTERCISM_APP_ID = null; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - if (CRITTERCISM_APP_ID != null) { - Log.d(TAG, "Crittercism initialized."); - Crittercism.initialize(getApplicationContext(), CRITTERCISM_APP_ID); - } - - setContentView(R.layout.main); - - Button startAnimatedXYPlotExButton = (Button) findViewById(R.id.animatedXYPlotExButton); - startAnimatedXYPlotExButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startActivity(new Intent(MainActivity.this, AnimatedXYPlotActivity.class)); - } - }); - - Button startScatterPlotExButton = (Button) findViewById(R.id.startScatterExButton); - startScatterPlotExButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startActivity(new Intent(MainActivity.this, ScatterPlotActivity.class)); - } - }); - - Button startSimplePieExButton = (Button) findViewById(R.id.startSimplePieExButton); - startSimplePieExButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startActivity(new Intent(MainActivity.this, SimplePieChartActivity.class)); - } - }); - - Button startDynamicXYExButton = (Button) findViewById(R.id.startDynamicXYExButton); - startDynamicXYExButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startActivity(new Intent(MainActivity.this, DynamicXYPlotActivity.class)); - } - }); - - Button startCandlestickExButton = (Button) findViewById(R.id.startCandlestickExButton); - startCandlestickExButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startActivity(new Intent(MainActivity.this, CandlestickChartActivity.class)); - } - }); - - Button startSimpleXYExButton = (Button) findViewById(R.id.startSimpleXYExButton); - startSimpleXYExButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startActivity(new Intent(MainActivity.this, SimpleXYPlotActivity.class)); - } - }); - - Button startBarPlotExButton = (Button) findViewById(R.id.startBarPlotExButton); - startBarPlotExButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startActivity(new Intent(MainActivity.this, BarPlotExampleActivity.class)); - } - }); - - Button startOrSensorExButton = (Button) findViewById(R.id.startOrSensorExButton); - startOrSensorExButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startActivity(new Intent(MainActivity.this, OrientationSensorExampleActivity.class)); - } - }); - - Button startDualScaleExButton = (Button) findViewById(R.id.startDualScaleExButton); - startDualScaleExButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startActivity(new Intent(MainActivity.this, DualScaleActivity.class)); - } - }); - - Button startTimeSeriesExButon = (Button) findViewById(R.id.startTimeSeriesExButton); - startTimeSeriesExButon.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startActivity(new Intent(MainActivity.this, TimeSeriesActivity.class)); - } - }); - - Button startStepChartExButton = (Button) findViewById(R.id.startStepChartExButton); - startStepChartExButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startActivity(new Intent(MainActivity.this, StepChartExampleActivity.class)); - } - }); - - Button startScrollZoomExButton = (Button) findViewById(R.id.startScrollZoomButton); - startScrollZoomExButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startActivity(new Intent(MainActivity.this, TouchZoomExampleActivity.class)); - } - }); - - Button startXyRegionExampleButton = (Button) findViewById(R.id.startXyRegionExampleButton); - startXyRegionExampleButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startActivity(new Intent(MainActivity.this, XYRegionExampleActivity.class)); - } - }); - - - Button listViewExButton = (Button) findViewById(R.id.startXyListViewExButton); - listViewExButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startActivity(new Intent(MainActivity.this, ListViewActivity.class)); - } - }); - - Button startXYPlotWithBgImgExampleButton = (Button) findViewById(R.id.startXYPlotWithBgImgExample); - startXYPlotWithBgImgExampleButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startActivity(new Intent(MainActivity.this, XYPlotWithBgImgActivity.class)); - } - }); - - // ECG - Button startECGExampleButton = (Button) findViewById(R.id.startECGExample); - startECGExampleButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startActivity(new Intent(MainActivity.this, ECGExample.class)); - } - }); - - // f(x) plot - Button fxPlotExampleButton = (Button) findViewById(R.id.fxPlotExample); - fxPlotExampleButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startActivity(new Intent(MainActivity.this, FXPlotExampleActivity.class)); - } - }); - - // bubble chart - Button bubbleChartButton = (Button) findViewById(R.id.bubbleChartExample); - bubbleChartButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startActivity(new Intent(MainActivity.this, BubbleChartActivity.class)); - } - }); - } -} diff --git a/demoapp/src/main/java/com/androidplot/demos/Util.java b/demoapp/src/main/java/com/androidplot/demos/Util.java deleted file mode 100644 index 617f3976a73d79b93aa52378a72f06848e8d5878..0000000000000000000000000000000000000000 --- a/demoapp/src/main/java/com/androidplot/demos/Util.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.androidplot.demos; - -import android.app.*; -import android.content.*; - -/** - * Created by halfhp on 10/29/16. - */ -public class Util { - - - - public ProgressDialog showLoadingDialog(Context context) { - return ProgressDialog.show(context, "Loading", "Please wait...", true); - } - -} diff --git a/demoapp/src/main/java/com/androidplot/demos/XYPlotWithBgImgActivity.java b/demoapp/src/main/java/com/androidplot/demos/XYPlotWithBgImgActivity.java deleted file mode 100644 index e1dd432d1faf6a6d8df834dfb594f8f428438a45..0000000000000000000000000000000000000000 --- a/demoapp/src/main/java/com/androidplot/demos/XYPlotWithBgImgActivity.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.demos; - -import android.app.Activity; -import android.graphics.*; -import android.os.Bundle; -import android.view.View; -import android.widget.ToggleButton; -import com.androidplot.util.PixelUtils; -import com.androidplot.xy.*; - -import java.text.DecimalFormat; -import java.util.Arrays; - -public class XYPlotWithBgImgActivity extends Activity { - private static final String TAG = XYPlotWithBgImgActivity.class.getName(); - - private int SERIES_LEN = 50; - private Shader WHITE_SHADER = new LinearGradient(1, 1, 1, 1, Color.WHITE, Color.WHITE, Shader.TileMode.REPEAT); - - private XYPlot plot; - private SimpleXYSeries series; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.xy_plot_with_bq_img_example); - - plot = (XYPlot) findViewById(R.id.graph_metrics); - - // Format Graph - plot.getGraph().getBackgroundPaint().setColor(Color.TRANSPARENT); - plot.getGraph().getGridBackgroundPaint().setShader(WHITE_SHADER); - plot.getGraph().getDomainGridLinePaint().setColor(Color.BLACK); - plot.getGraph().getDomainGridLinePaint().setPathEffect(new DashPathEffect(new float[]{3, 3}, 1)); - plot.getGraph().getRangeGridLinePaint().setColor(Color.BLACK); - plot.getGraph().getRangeGridLinePaint().setPathEffect(new DashPathEffect(new float[]{3, 3}, 1)); - plot.getGraph().getDomainOriginLinePaint().setColor(Color.BLACK); - plot.getGraph().getRangeOriginLinePaint().setColor(Color.BLACK); - - // Customize domain and range labels. - plot.setDomainLabel("x-vals"); - plot.setRangeLabel("y-vals"); - plot.getGraph().getLineLabelStyle(XYGraphWidget.Edge.LEFT). - setFormat(new DecimalFormat("0")); - - // Make the domain and range step correctly - plot.setRangeBoundaries(40, 160, BoundaryMode.FIXED); - plot.setRangeStep(StepMode.INCREMENT_BY_VAL, 20); - plot.setDomainStep(StepMode.INCREMENT_BY_VAL, 60); - plot.setLinesPerDomainLabel(2); - - series = getSeries(); - LineAndPointFormatter lpFormat = new LineAndPointFormatter( - Color.BLACK, - Color.GRAY, - null, // No fill - new PointLabelFormatter(Color.TRANSPARENT) // Don't show text at points - ); - lpFormat.getLinePaint().setStrokeWidth(PixelUtils.dpToPix(3)); - lpFormat.getVertexPaint().setStrokeWidth(PixelUtils.dpToPix(6)); - plot.addSeries(series, lpFormat); - plot.redraw(); - } - - private SimpleXYSeries getSeries() { - Integer[] xVals = new Integer[SERIES_LEN]; - Integer[] yVals = new Integer[SERIES_LEN]; - - xVals[0] = 0; - yVals[0] = 0; - - for (int i = 1; i < SERIES_LEN; i += 1){ - xVals[i] = xVals[i-1] + (int)(Math.random() * i); - yVals[i] = (int)(Math.random() * 140); - } - - return new SimpleXYSeries( - Arrays.asList(xVals), - Arrays.asList(yVals), - "Sample Series"); - } - - public void onGraphStyleToggle(View v) { - boolean styleOn = ((ToggleButton) v).isChecked(); - RectF rect = plot.getGraph().getGridRect(); - BitmapShader myShader = new BitmapShader( - Bitmap.createScaledBitmap( - BitmapFactory.decodeResource( - getResources(), - R.drawable.graph_background), - 1, - (int) rect.height(), - false), - Shader.TileMode.REPEAT, - Shader.TileMode.REPEAT); - Matrix m = new Matrix(); - m.setTranslate(rect.left, rect.top); - myShader.setLocalMatrix(m); - if (styleOn) - plot.getGraph().getGridBackgroundPaint().setShader( - myShader); - else - plot.getGraph().getGridBackgroundPaint().setShader(WHITE_SHADER); - - plot.redraw(); - - } -} diff --git a/demoapp/src/main/java/com/androidplot/demos/widget/DemoAppWidgetProvider.java b/demoapp/src/main/java/com/androidplot/demos/widget/DemoAppWidgetProvider.java deleted file mode 100644 index 592fbce3bec456f81d19d37dc66532ce0a0a74ef..0000000000000000000000000000000000000000 --- a/demoapp/src/main/java/com/androidplot/demos/widget/DemoAppWidgetProvider.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2015 AndroidPlot.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.androidplot.demos.widget; - -import android.appwidget.AppWidgetManager; -import android.appwidget.AppWidgetProvider; -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Color; -import android.widget.RemoteViews; -import com.androidplot.demos.R; -import com.androidplot.ui.*; -import com.androidplot.util.PixelUtils; -import com.androidplot.xy.XYGraphWidget; -import com.androidplot.xy.XYSeries; -import com.androidplot.xy.LineAndPointFormatter; -import com.androidplot.xy.SimpleXYSeries; -import com.androidplot.xy.XYPlot; - -import java.util.Arrays; - -public class DemoAppWidgetProvider extends AppWidgetProvider { - - @Override - public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { - for (int widgetId : appWidgetIds) { - XYPlot plot = new XYPlot(context, "Widget Example"); - final int h = (int) context.getResources().getDimension(R.dimen.sample_widget_height); - final int w = (int) context.getResources().getDimension(R.dimen.sample_widget_width); - - plot.getGraph().setMargins(0, 0, 0 , 0); - plot.getGraph().setPadding(0, 0, 0, 0); - - plot.getGraph().position(0, HorizontalPositioning.ABSOLUTE_FROM_LEFT, 0, - VerticalPositioning.ABSOLUTE_FROM_TOP, Anchor.LEFT_TOP); - - plot.getGraph().setSize(Size.FILL); - - plot.getLayoutManager().moveToTop(plot.getTitle()); - - plot.getGraph().setLineLabelEdges(XYGraphWidget.Edge.LEFT, XYGraphWidget.Edge.BOTTOM); - plot.getGraph().getLineLabelInsets().setLeft(PixelUtils.dpToPix(16)); - plot.getGraph().getLineLabelInsets().setBottom(PixelUtils.dpToPix(4)); - plot.getGraph().getLineLabelStyle(XYGraphWidget.Edge.LEFT).getPaint().setColor(Color.RED); - plot.getGraph().getGridInsets().setTop(PixelUtils.dpToPix(12)); - plot.getGraph().getGridInsets().setRight(PixelUtils.dpToPix(12)); - plot.getGraph().getGridInsets().setLeft(PixelUtils.dpToPix(36)); - plot.getGraph().getGridInsets().setBottom(PixelUtils.dpToPix(16)); - - plot.measure(w, h); - plot.layout(0, 0, w, h); - - Number[] series1Numbers = {1, 4, 2, 8, 4, 16, 8, 32, 16, 64}; - Number[] series2Numbers = {5, 2, 10, 5, 20, 10, 40, 20, 80, 40}; - - // Turn the above arrays into XYSeries': - XYSeries series1 = new SimpleXYSeries( - Arrays.asList(series1Numbers), // SimpleXYSeries takes a List so turn our array into a List - SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, // Y_VALS_ONLY means use the element index as the x value - "Series1"); // Set the display title of the series - - // same as above - XYSeries series2 = new SimpleXYSeries(Arrays.asList(series2Numbers), - SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Series2"); - - // Create a formatter to use for drawing a series using LineAndPointRenderer: - LineAndPointFormatter series1Format = new LineAndPointFormatter( - Color.rgb(0, 200, 0), // line color - Color.rgb(0, 100, 0), // point color - null, null); // fill color (none) - - // add a new series' to the xyplot: - plot.addSeries(series1, series1Format); - - // same as above: - plot.addSeries(series2, - new LineAndPointFormatter( - Color.rgb(0, 0, 200), Color.rgb(0, 0, 100), null, null)); - - - // reduce the number of range labels - plot.setLinesPerRangeLabel(3); - plot.setLinesPerDomainLabel(2); - - // hide the legend: - plot.getLegend().setVisible(false); - - RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.demo_app_widget); - - Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); - plot.draw(new Canvas(bitmap)); - rv.setImageViewBitmap(R.id.imgView, bitmap); - appWidgetManager.updateAppWidget(widgetId, rv); - } - } -} diff --git a/demoapp/src/main/res/drawable-hdpi/ic_launcher.png b/demoapp/src/main/res/drawable-hdpi/ic_launcher.png deleted file mode 100755 index 4036921570db566bea90db5a7fb9b9612ba1ee8f..0000000000000000000000000000000000000000 Binary files a/demoapp/src/main/res/drawable-hdpi/ic_launcher.png and /dev/null differ diff --git a/demoapp/src/main/res/drawable-xhdpi/ic_launcher.png b/demoapp/src/main/res/drawable-xhdpi/ic_launcher.png deleted file mode 100755 index b53ab1e853f264175804784efa4926dad3848e0c..0000000000000000000000000000000000000000 Binary files a/demoapp/src/main/res/drawable-xhdpi/ic_launcher.png and /dev/null differ diff --git a/demoapp/src/main/res/drawable-xxhdpi/ic_launcher.png b/demoapp/src/main/res/drawable-xxhdpi/ic_launcher.png deleted file mode 100755 index de40e4a9c718389085aa3134b3a13ce648bb12f4..0000000000000000000000000000000000000000 Binary files a/demoapp/src/main/res/drawable-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/demoapp/src/main/res/drawable-xxxhdpi/ic_launcher.png b/demoapp/src/main/res/drawable-xxxhdpi/ic_launcher.png deleted file mode 100755 index 92187631239b16d097592e3e09de7f50eac138b5..0000000000000000000000000000000000000000 Binary files a/demoapp/src/main/res/drawable-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/demoapp/src/main/res/drawable/ic_launcher.png b/demoapp/src/main/res/drawable/ic_launcher.png deleted file mode 100755 index 56d3977d087920945d3a53faa89591edcafa61b7..0000000000000000000000000000000000000000 Binary files a/demoapp/src/main/res/drawable/ic_launcher.png and /dev/null differ diff --git a/demoapp/src/main/res/layout/bar_plot_example.xml b/demoapp/src/main/res/layout/bar_plot_example.xml deleted file mode 100644 index 3182342dc121e485131df77b998604c39419b88e..0000000000000000000000000000000000000000 --- a/demoapp/src/main/res/layout/bar_plot_example.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/demoapp/src/main/res/layout/bubble_chart_example.xml b/demoapp/src/main/res/layout/bubble_chart_example.xml deleted file mode 100644 index e18289aa00a3cf328bc7e431b3ccffd073286aa3..0000000000000000000000000000000000000000 --- a/demoapp/src/main/res/layout/bubble_chart_example.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/demoapp/src/main/res/layout/candlestick_example.xml b/demoapp/src/main/res/layout/candlestick_example.xml deleted file mode 100644 index 831f003be0648dfc8a8cd5210b47fb1c35b06bda..0000000000000000000000000000000000000000 --- a/demoapp/src/main/res/layout/candlestick_example.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/demoapp/src/main/res/layout/dual_scale_example.xml b/demoapp/src/main/res/layout/dual_scale_example.xml deleted file mode 100644 index f442b4ff25d423800e1cff4790d76f3754f0adc7..0000000000000000000000000000000000000000 --- a/demoapp/src/main/res/layout/dual_scale_example.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/demoapp/src/main/res/layout/dynamic_xyplot_example.xml b/demoapp/src/main/res/layout/dynamic_xyplot_example.xml deleted file mode 100644 index 5b0c5644af246f12f7011bb9ebb4da1aab6d12e2..0000000000000000000000000000000000000000 --- a/demoapp/src/main/res/layout/dynamic_xyplot_example.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - diff --git a/demoapp/src/main/res/layout/ecg_example.xml b/demoapp/src/main/res/layout/ecg_example.xml deleted file mode 100644 index c2d2e197a30922425ee5254ab822f6607b3df726..0000000000000000000000000000000000000000 --- a/demoapp/src/main/res/layout/ecg_example.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/demoapp/src/main/res/layout/fx_plot_example.xml b/demoapp/src/main/res/layout/fx_plot_example.xml deleted file mode 100644 index 6b0a052c7f619a9540767e723f97b17da9a39dfe..0000000000000000000000000000000000000000 --- a/demoapp/src/main/res/layout/fx_plot_example.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/demoapp/src/main/res/layout/listview_example.xml b/demoapp/src/main/res/layout/listview_example.xml deleted file mode 100644 index 3eba0c5b717cd30ec00b7f2b89dfac439b77008c..0000000000000000000000000000000000000000 --- a/demoapp/src/main/res/layout/listview_example.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/demoapp/src/main/res/layout/listview_example_item.xml b/demoapp/src/main/res/layout/listview_example_item.xml deleted file mode 100644 index a0b257fd7ce961027b0363a228ca1804e12b3a14..0000000000000000000000000000000000000000 --- a/demoapp/src/main/res/layout/listview_example_item.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/demoapp/src/main/res/layout/main.xml b/demoapp/src/main/res/layout/main.xml deleted file mode 100644 index 590087def763e6507303041c68a049d9f7115246..0000000000000000000000000000000000000000 --- a/demoapp/src/main/res/layout/main.xml +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - - - - -