的
This commit is contained in:
@@ -0,0 +1 @@
|
||||
/build
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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 {
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.1.4'
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
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'
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
# 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 *;
|
||||
#}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.androidplot.demo.wearable" >
|
||||
|
||||
<uses-feature android:name="android.hardware.type.watch" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@android:style/Theme.DeviceDefault" >
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name" >
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:ap="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="${relativePackage}.${activityClass}">
|
||||
|
||||
<com.androidplot.xy.XYPlot
|
||||
android:id="@+id/plot"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
ap:label="Wearable"
|
||||
ap:rangeLabel="range"
|
||||
ap:domainLabel="domain"
|
||||
ap:domainStepMode="subdivide"
|
||||
ap:domainStep="2"
|
||||
ap:rangeStepMode="subdivide"
|
||||
ap:rangeStep="3"
|
||||
ap:rangeLabelTextSize="13sp"
|
||||
ap:domainLabelTextSize="13sp"
|
||||
ap:domainLabelLayoutStyleX="relative_from_center"
|
||||
ap:domainLabelLayoutStyleY="absolute_from_bottom"
|
||||
ap:domainLabelPositionX="0dp"
|
||||
ap:domainLabelPositionY="0dp"
|
||||
ap:domainLabelAnchorPosition="bottom_middle"
|
||||
ap:borderColor="#000000"
|
||||
ap:backgroundColor="#000000"
|
||||
ap:graphBackgroundColor="#000000"
|
||||
ap:gridBackgroundColor="#000000"
|
||||
ap:gridPaddingLeft="20dp"
|
||||
ap:gridPaddingRight="20dp"
|
||||
ap:gridPaddingTop="20dp"
|
||||
ap:gridPaddingBottom="20dp"
|
||||
ap:labelTextSize="20sp"
|
||||
ap:graphMarginTop="5dp"
|
||||
ap:graphMarginBottom="10dp"
|
||||
ap:graphMarginLeft="0dp"
|
||||
ap:graphMarginRight="10dp"
|
||||
ap:graphDomainLineColor="#FFFFFF"
|
||||
ap:graphDomainLineThickness="1dp"
|
||||
ap:graphRangeLineColor="#FFFFFF"
|
||||
ap:graphRangeLineThickness="1dp"
|
||||
ap:rangeTickLabelTextSize="10sp"
|
||||
ap:rangeOriginTickLabelTextSize="10sp"
|
||||
ap:domainOriginTickLabelTextSize="10sp"
|
||||
ap:domainTickLabelTextSize="10sp"
|
||||
ap:legendTextSize="15sp"
|
||||
ap:legendIconHeight="10dp"
|
||||
ap:legendIconWidth="10dp"
|
||||
ap:legendHeight="20dp"
|
||||
ap:legendWidth="0.5"
|
||||
ap:legendLayoutStyleX="relative_from_center"
|
||||
ap:legendLayoutStyleY="absolute_from_bottom"
|
||||
ap:legendPositionX="0dp"
|
||||
ap:legendPositionY="15dp"
|
||||
ap:legendAnchorPosition="bottom_middle"/>
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<config
|
||||
linePaint.strokeWidth="5dp"
|
||||
linePaint.color="#00AA00"
|
||||
vertexPaint.color="#007700"
|
||||
vertexPaint.strokeWidth="20dp"
|
||||
fillPaint.color="#00000000"
|
||||
pointLabelFormatter.textPaint.color="#FFFFFF"/>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<config
|
||||
linePaint.strokeWidth="5dp"
|
||||
linePaint.color="#0000AA"
|
||||
vertexPaint.strokeWidth="20dp"
|
||||
vertexPaint.color="#000099"
|
||||
fillPaint.color="#00000000"
|
||||
pointLabelFormatter.textPaint.color="#FFFFFF"/>
|
||||
Reference in New Issue
Block a user