فهرست منبع

Graphs initial commit

Berislav 9 سال پیش
کامیت
52b32805db
36فایلهای تغییر یافته به همراه1440 افزوده شده و 0 حذف شده
  1. 9 0
      .gitignore
  2. 22 0
      .idea/compiler.xml
  3. 3 0
      .idea/copyright/profiles_settings.xml
  4. 18 0
      .idea/gradle.xml
  5. 46 0
      .idea/misc.xml
  6. 9 0
      .idea/modules.xml
  7. 12 0
      .idea/runConfigurations.xml
  8. 1 0
      app/.gitignore
  9. 28 0
      app/build.gradle
  10. 25 0
      app/proguard-rules.pro
  11. 26 0
      app/src/androidTest/java/hr/tacitus/graphs/ExampleInstrumentedTest.java
  12. 15 0
      app/src/main/AndroidManifest.xml
  13. 16 0
      app/src/main/java/hr/tacitus/graphs/BarGraphAdapter.java
  14. 864 0
      app/src/main/java/hr/tacitus/graphs/BarGraphView.java
  15. BIN
      app/src/main/res/mipmap-hdpi/ic_launcher.png
  16. BIN
      app/src/main/res/mipmap-hdpi/ic_launcher_round.png
  17. BIN
      app/src/main/res/mipmap-mdpi/ic_launcher.png
  18. BIN
      app/src/main/res/mipmap-mdpi/ic_launcher_round.png
  19. BIN
      app/src/main/res/mipmap-xhdpi/ic_launcher.png
  20. BIN
      app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
  21. BIN
      app/src/main/res/mipmap-xxhdpi/ic_launcher.png
  22. BIN
      app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
  23. BIN
      app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
  24. BIN
      app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
  25. 12 0
      app/src/main/res/values/attrs.xml
  26. 6 0
      app/src/main/res/values/colors.xml
  27. 3 0
      app/src/main/res/values/strings.xml
  28. 11 0
      app/src/main/res/values/styles.xml
  29. 17 0
      app/src/test/java/hr/tacitus/graphs/ExampleUnitTest.java
  30. 23 0
      build.gradle
  31. 17 0
      gradle.properties
  32. BIN
      gradle/wrapper/gradle-wrapper.jar
  33. 6 0
      gradle/wrapper/gradle-wrapper.properties
  34. 160 0
      gradlew
  35. 90 0
      gradlew.bat
  36. 1 0
      settings.gradle

+ 9 - 0
.gitignore

@@ -0,0 +1,9 @@
+*.iml
+.gradle
+/local.properties
+/.idea/workspace.xml
+/.idea/libraries
+.DS_Store
+/build
+/captures
+.externalNativeBuild

+ 22 - 0
.idea/compiler.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <resourceExtensions />
+    <wildcardResourcePatterns>
+      <entry name="!?*.java" />
+      <entry name="!?*.form" />
+      <entry name="!?*.class" />
+      <entry name="!?*.groovy" />
+      <entry name="!?*.scala" />
+      <entry name="!?*.flex" />
+      <entry name="!?*.kt" />
+      <entry name="!?*.clj" />
+      <entry name="!?*.aj" />
+    </wildcardResourcePatterns>
+    <annotationProcessing>
+      <profile default="true" name="Default" enabled="false">
+        <processorPath useClasspath="true" />
+      </profile>
+    </annotationProcessing>
+  </component>
+</project>

+ 3 - 0
.idea/copyright/profiles_settings.xml

@@ -0,0 +1,3 @@
+<component name="CopyrightManager">
+  <settings default="" />
+</component>

+ 18 - 0
.idea/gradle.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="GradleSettings">
+    <option name="linkedExternalProjectsSettings">
+      <GradleProjectSettings>
+        <option name="distributionType" value="DEFAULT_WRAPPED" />
+        <option name="externalProjectPath" value="$PROJECT_DIR$" />
+        <option name="modules">
+          <set>
+            <option value="$PROJECT_DIR$" />
+            <option value="$PROJECT_DIR$/app" />
+          </set>
+        </option>
+        <option name="resolveModulePerSourceSet" value="false" />
+      </GradleProjectSettings>
+    </option>
+  </component>
+</project>

+ 46 - 0
.idea/misc.xml

@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="EntryPointsManager">
+    <entry_points version="2.0" />
+  </component>
+  <component name="NullableNotNullManager">
+    <option name="myDefaultNullable" value="android.support.annotation.Nullable" />
+    <option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
+    <option name="myNullables">
+      <value>
+        <list size="4">
+          <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
+          <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
+          <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
+          <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
+        </list>
+      </value>
+    </option>
+    <option name="myNotNulls">
+      <value>
+        <list size="4">
+          <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
+          <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
+          <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
+          <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
+        </list>
+      </value>
+    </option>
+  </component>
+  <component name="ProjectLevelVcsManager" settingsEditedManually="false">
+    <OptionsSetting value="true" id="Add" />
+    <OptionsSetting value="true" id="Remove" />
+    <OptionsSetting value="true" id="Checkout" />
+    <OptionsSetting value="true" id="Update" />
+    <OptionsSetting value="true" id="Status" />
+    <OptionsSetting value="true" id="Edit" />
+    <ConfirmationsSetting value="0" id="Add" />
+    <ConfirmationsSetting value="0" id="Remove" />
+  </component>
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/build/classes" />
+  </component>
+  <component name="ProjectType">
+    <option name="id" value="Android" />
+  </component>
+</project>

+ 9 - 0
.idea/modules.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/Graphs.iml" filepath="$PROJECT_DIR$/Graphs.iml" />
+      <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
+    </modules>
+  </component>
+</project>

+ 12 - 0
.idea/runConfigurations.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="RunConfigurationProducerService">
+    <option name="ignoredProducers">
+      <set>
+        <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
+        <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
+        <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
+      </set>
+    </option>
+  </component>
+</project>

+ 1 - 0
app/.gitignore

@@ -0,0 +1 @@
+/build

+ 28 - 0
app/build.gradle

@@ -0,0 +1,28 @@
+apply plugin: 'com.android.library'
+
+android {
+    compileSdkVersion 26
+    buildToolsVersion "25.0.3"
+    defaultConfig {
+        minSdkVersion 19
+        targetSdkVersion 26
+        versionCode 1
+        versionName "1.0"
+        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+    }
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+        }
+    }
+}
+
+dependencies {
+    compile fileTree(dir: 'libs', include: ['*.jar'])
+    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
+        exclude group: 'com.android.support', module: 'support-annotations'
+    })
+    compile 'com.android.support:appcompat-v7:26.+'
+    testCompile 'junit:junit:4.12'
+}

+ 25 - 0
app/proguard-rules.pro

@@ -0,0 +1,25 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in C:\Users\Bero\AppData\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 *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile

+ 26 - 0
app/src/androidTest/java/hr/tacitus/graphs/ExampleInstrumentedTest.java

@@ -0,0 +1,26 @@
+package hr.tacitus.graphs;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumentation test, which will execute on an Android device.
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+    @Test
+    public void useAppContext() throws Exception {
+        // Context of the app under test.
+        Context appContext = InstrumentationRegistry.getTargetContext();
+
+        assertEquals("hr.tacitus.graphs", appContext.getPackageName());
+    }
+}

+ 15 - 0
app/src/main/AndroidManifest.xml

@@ -0,0 +1,15 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+
+    package="hr.tacitus.graphs">
+
+    <application
+        android:allowBackup="true"
+        android:icon="@mipmap/ic_launcher"
+        android:label="@string/app_name"
+        android:roundIcon="@mipmap/ic_launcher_round"
+        android:supportsRtl="true"
+        android:theme="@style/AppTheme">
+
+    </application>
+
+</manifest>

+ 16 - 0
app/src/main/java/hr/tacitus/graphs/BarGraphAdapter.java

@@ -0,0 +1,16 @@
+package hr.tacitus.graphs;
+
+/**
+ * Created by Bero on 1.7.2017..
+ */
+
+public interface BarGraphAdapter {
+
+    int getCount();
+
+    String getHorizontalValueDescription(int position);
+    String getValueDescription(int position);
+    String getVerticalMarkingText(double markingValue);
+
+    double getValue(int position);
+}

+ 864 - 0
app/src/main/java/hr/tacitus/graphs/BarGraphView.java

@@ -0,0 +1,864 @@
+package hr.tacitus.graphs;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.util.AttributeSet;
+import android.util.DisplayMetrics;
+import android.view.Display;
+import android.view.GestureDetector;
+import android.view.GestureDetector.OnGestureListener;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.WindowManager;
+
+import hr.tacitus.graphs.R;
+
+public class BarGraphView extends View {
+    // Spacing between axis and values, and values and description.
+    private final static float DEFAULT_AXIS_LINE_SPACING_DP = 2.0f;
+    private final static float DEFAULT_MARKINGS_LENGTH_DP = 6.0f;
+    private final static float DEFAULT_AXIS_DESCRIPTION_FONT_SIZE_SP = 16.f;
+    private final static float AVERAGE_LINE_STROKE_WIDTH = 1.f;
+    private final static float VALUE_TEXT_OFFSET = 5f;
+
+    VerticalAxisRect verticalAxisRect = new VerticalAxisRect();
+    HorizontalAxisRect horizontalAxisRect = new HorizontalAxisRect();
+    BarConfig barConfig = new BarConfig();
+
+    private double maxGraphValue;
+    // Scroll value, default is leftmost.
+    private float offsetX = 0;
+    private boolean drawAverageLine = false;
+
+    private Paint averageLinePaint = null;
+    private Paint canvasPaint = null;
+    private Paint axisPaint = null;
+
+    private DisplayMetrics dm = null;
+
+    private BarGraphAdapter adapter;
+
+    // Paramaters
+    float barFontSizePx;
+    // Font size for each value
+    float axisValuesFontSizePx;
+    // Text padding on bars
+    float barPaddingPx;
+    float ordinateMinMarkingsDistance;
+
+    public BarGraphView(Context context) {
+        super(context);
+        init(context, null);
+    }
+
+    public BarGraphView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        init(context, attrs);
+    }
+
+    public BarGraphView(Context context, AttributeSet attrs, int defStyle) {
+        super(context, attrs, defStyle);
+        init(context, attrs);
+    }
+
+    private void setDefaultParamValues() {
+        barFontSizePx = getDimensionFromSp(15.f);
+        barPaddingPx = getDimensionFromDp(6.f);
+        axisValuesFontSizePx = getDimensionFromSp(14.f);
+        ordinateMinMarkingsDistance = getDimensionFromDp(40.f);
+    }
+
+    private void setupDisplayMetrics() {
+        dm = new DisplayMetrics();
+        WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
+        Display d = wm.getDefaultDisplay();
+        d.getMetrics(dm);
+    }
+
+    private void readAttributes(AttributeSet attrs) {
+        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.BarGraph);
+        if (a != null) {
+            try {
+                String xAxisText = a.getString(R.styleable.BarGraph_xAxisText);
+                if (xAxisText != null) {
+                    setDescriptionX(xAxisText);
+                }
+
+                String yAxisText = a.getString(R.styleable.BarGraph_yAxisText);
+                if (yAxisText != null) {
+                    setDescriptionY(yAxisText);
+                }
+
+                barFontSizePx = a.getDimension(R.styleable.BarGraph_barTextSize, barFontSizePx);
+                barPaddingPx = a.getDimension(R.styleable.BarGraph_barPadding, barPaddingPx);
+                axisValuesFontSizePx = a.getDimension(R.styleable.BarGraph_axisValuesTextSize, axisValuesFontSizePx);
+
+                drawAverageLine = a.getBoolean(R.styleable.BarGraph_showAverageLine, drawAverageLine);
+
+                horizontalAxisRect.setShowValues(a.getBoolean(R.styleable.BarGraph_showHorizontalValues, false));
+                verticalAxisRect.setShowValues(a.getBoolean(R.styleable.BarGraph_showVerticalValues, true));
+
+            } finally {
+                a.recycle();
+            }
+        }
+    }
+
+    private void cacheValues() {
+        // Initialize paints used in onDraw
+        averageLinePaint = new Paint();
+        averageLinePaint.setColor(Color.RED);
+        averageLinePaint.setStrokeWidth(getDimensionFromDp(AVERAGE_LINE_STROKE_WIDTH));
+
+        canvasPaint = new Paint();
+        canvasPaint.setStyle(Paint.Style.FILL);
+        canvasPaint.setColor(Color.WHITE);
+        canvasPaint.setAntiAlias(true);
+
+        axisPaint = new Paint();
+        axisPaint.setStyle(Paint.Style.FILL);
+        axisPaint.setColor(Color.BLACK);
+        axisPaint.setAntiAlias(true);
+    }
+
+    private void init(Context context, AttributeSet attrs) {
+        setupDisplayMetrics();
+        setDefaultParamValues();
+        if (attrs != null) {
+            readAttributes(attrs);
+        }
+
+        cacheValues();
+
+        verticalAxisValues.setMinDistanceBetweenMarkings(ordinateMinMarkingsDistance);
+    }
+
+    private void drawHorizontalAxis(Canvas canvas) {
+        canvas.drawLine(verticalAxisRect.getWidth() + getPaddingLeft(), horizontalAxisRect.getAxisBottom(),
+                getWidth() - getPaddingRight(), horizontalAxisRect.getAxisBottom(), axisPaint);
+        drawHorizontalMeasures(canvas);
+    }
+
+    private void drawVerticalAxis(Canvas canvas) {
+        canvas.drawLine(verticalAxisRect.getWidth() + getPaddingLeft(), getPaddingTop(),
+                verticalAxisRect.getWidth() + getPaddingLeft(), horizontalAxisRect.getAxisBottom(), axisPaint);
+        drawVerticalMeasures(canvas);
+    }
+
+    private void drawAverageLine(Canvas canvas) {
+        int width = getWidth();
+
+        double barHeight = getBarHeight(verticalAxisValues.getAverageValue());
+        float y1 = (float) (getPaddingTop() + getGraphHeight() - barHeight);
+        float y2 = y1;
+        canvas.drawLine(verticalAxisRect.getWidth() + getPaddingLeft(), y1, width - getPaddingRight(), y2, averageLinePaint);
+    }
+
+    @Override
+    protected void onDraw(Canvas canvas) {
+        super.onDraw(canvas);
+
+        if (adapter == null)
+            return;
+
+        canvas.drawPaint(canvasPaint);
+
+        drawHorizontalAxis(canvas);
+        drawVerticalAxis(canvas);
+        drawValues(canvas);
+        if (drawAverageLine) {
+            drawAverageLine(canvas);
+        }
+    }
+
+    private void drawHorizontalMeasures(Canvas canvas) {
+        float xStart = verticalAxisRect.getWidth() + getPaddingLeft();
+        float barWidth = barConfig.getBarWidth();
+
+        float y1 = horizontalAxisRect.getAxisBottom();
+        float y2 = y1 + horizontalAxisRect.getAxisMarkingsLength();
+
+        for (int i = 0; i < adapter.getCount(); ++i) {
+            float x1 = xStart - offsetX + barConfig.getWhiteSpace() - getDimensionFromDp(1.0f);
+            float x2 = x1;
+
+            if (x1 <= getWidth() - getPaddingRight()) {
+                if (x1 >= verticalAxisRect.getWidth() + getPaddingLeft()) {
+                    canvas.drawLine(x1, y1, x2, y2, horizontalAxisRect.getPaintLine());
+                    if (horizontalAxisRect.isShowValues()) {
+                        String horizontalDescription = adapter.getHorizontalValueDescription(i);
+                        if (horizontalDescription != null) {
+                            float textWidth = horizontalAxisRect.getPaintLine().measureText(horizontalDescription);
+                            canvas.drawText(horizontalDescription, x1 - (textWidth / 2), horizontalAxisRect.getMarkingValuesY(), horizontalAxisRect.getPaintLine());
+                        }
+                    }
+                }
+            }
+
+            xStart += barWidth + barConfig.getWhiteSpace();
+        }
+        if (horizontalAxisRect.getDescription() != null) {
+            float textWidth = horizontalAxisRect.getPaintDescription().measureText(horizontalAxisRect.getDescription());
+            float x = BarGraphView.this.getWidth() / 2 - textWidth / 2;
+            float y = horizontalAxisRect.getDescriptionY();
+            canvas.drawText(horizontalAxisRect.getDescription(), x, y, horizontalAxisRect.getPaintDescription());
+        }
+    }
+
+    private void drawVerticalMeasures(Canvas canvas) {
+        if (adapter == null || adapter.getCount() == 0)
+            return;
+
+        initVerticalAxisValues();
+
+        float yStart = horizontalAxisRect.getAxisBottom();
+        float x1 = verticalAxisRect.getWidth() + getPaddingLeft();
+        float x2 = x1 - verticalAxisRect.getAxisMarkingsLength();
+        for (int i = 0; i <= verticalAxisValues.getMarkingsCount(); ++i) {
+            float y1 = yStart;
+            float y2 = y1;
+
+            canvas.drawLine(x1, y1, x2, y2, verticalAxisRect.getPaintLine());
+
+            if (verticalAxisRect.isShowValues()) {
+                // draw bounding rect before rotating text
+                Rect rect = new Rect();
+                canvas.save();
+
+                String markingText = adapter.getVerticalMarkingText(i * verticalAxisValues.getYieldBetweenMarkings());
+                float textWidth = verticalAxisRect.getPaintLine().measureText(markingText);
+
+                canvas.rotate(-90.f, rect.exactCenterX(), yStart + rect.exactCenterY());
+                canvas.drawText(markingText, -(textWidth / 2), yStart + verticalAxisRect.getValuesX() + getPaddingLeft(), verticalAxisRect.getPaintLine());
+                canvas.restore();
+            }
+
+            yStart -= verticalAxisValues.getDistanceBetweenMarkingsPx();
+        }
+
+        if (verticalAxisRect.getDescription() != null) {
+            float textWidth = verticalAxisRect.getPaintDescription().measureText(verticalAxisRect.getDescription());
+            float x = -textWidth / 2;
+            float y = BarGraphView.this.getHeight() / 2 + verticalAxisRect.getDescriptionX();
+
+            canvas.save();
+            Rect rect = new Rect();
+            canvas.rotate(-90f, rect.exactCenterX(), BarGraphView.this.getHeight() / 2 + rect.exactCenterY());
+            canvas.drawText(verticalAxisRect.getDescription(), x, y + getPaddingLeft(), verticalAxisRect.getPaintDescription());
+            canvas.restore();
+        }
+    }
+
+    private void drawValue(Canvas canvas, String valueDescription, float x1, float y1, float x2, float y2) {
+        canvas.drawRect(x1, y1, x2, y2, barConfig.getPaintRect());
+
+        // Value descriptor
+        if (valueDescription != null) {
+            float barWidth = x2 - x1;
+            if (barConfig.getPadding() + barConfig.getMaxTextHeight() <= barWidth) {
+                canvas.save();
+                Rect rect = new Rect();
+
+                canvas.rotate(-90.f, x1 + rect.exactCenterX(), y2 + rect.exactCenterY());
+                float x = x1 + getDimensionFromDp(VALUE_TEXT_OFFSET);
+                float y = y2 + barWidth - barConfig.getPadding();
+                canvas.drawText(valueDescription, x, y, barConfig.getPaintText());
+
+                canvas.restore();
+            }
+        }
+    }
+
+    private void drawValues(Canvas canvas) {
+        float graphHeight = getGraphHeight();
+        float left = verticalAxisRect.getWidth();
+        float barWidth = barConfig.getBarWidth();
+        // float viewWidth = getMeasuredWidth();
+
+        for (int i = 0; i < adapter.getCount(); ++i) {
+            int barHeight = getBarHeight(adapter.getValue(i));
+
+            float x1 = left - offsetX + barConfig.getWhiteSpace() + getPaddingLeft();
+            float x2 = x1 + barConfig.getWhiteSpace() + barConfig.getBarWidth() - barConfig.getWhiteSpace();
+
+            left += barWidth + barConfig.getWhiteSpace();
+            // Check if it is too left, and goes into y axis
+            if (x1 + barWidth < verticalAxisRect.getWidth() + getPaddingLeft()) {
+                continue;
+            }
+
+            // Check if too right
+            if (x1 > getWidth() - getPaddingRight()) {
+                break;
+            }
+
+            // Prevent overlap with Y-axis
+            if (x1 < verticalAxisRect.getWidth() + getPaddingLeft()) {
+                x1 = verticalAxisRect.getWidth() + getPaddingLeft();
+            }
+
+            if (x2 > getWidth() - getPaddingRight()) {
+                x2 = getWidth() - getPaddingRight();
+            }
+
+            if (x2 >= verticalAxisRect.getWidth()) {
+                float y1 = getPaddingTop() + graphHeight - barHeight;
+                float y2 = horizontalAxisRect.getAxisBottom();
+
+                drawValue(canvas, adapter.getValueDescription(i), x1, y1, x2, y2);
+            }
+        }
+    }
+
+    private float getDimensionFromDp(float dp) {
+        return dm.density * dp;
+    }
+
+    private float getDimensionFromSp(float sp) {
+        return dm.scaledDensity * sp;
+    }
+
+    private int getBarHeight(double d) {
+        int res = (int) (d / verticalAxisValues.getTopMarkingHeight() * getGraphHeight());
+        return res;
+    }
+
+    private int getGraphHeight() {
+        int height = getHeight();
+        // Consider margins
+        return (int) (height - getPaddingTop() - horizontalAxisRect.getHeight() - getPaddingBottom());
+    }
+
+    private float getTotalWidth() {
+        if (adapter == null || adapter.getCount() == 0)
+            return 0;
+        return adapter.getCount() * barConfig.getBarWidth() + (adapter.getCount() - 1) * barConfig.getWhiteSpace();
+    }
+
+    /**
+     * Calculates available width where bars can be stored.
+     *
+     * @return
+     */
+    private float getAvailableDataWidth() {
+        return (getWidth() - verticalAxisRect.getWidth() - getPaddingLeft() - getPaddingRight());
+    }
+
+    GestureDetector gd = new GestureDetector(this.getContext(), new OnGestureListener() {
+        @Override
+        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
+            scrollBy((int) distanceX, (int) distanceY);
+            return true;
+        }
+
+        @Override
+        public boolean onDown(MotionEvent e) {
+            return true;
+        }
+
+        @Override
+        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
+            return false;
+        }
+
+        @Override
+        public void onLongPress(MotionEvent e) {
+
+        }
+
+        @Override
+        public void onShowPress(MotionEvent e) {
+
+        }
+
+        @Override
+        public boolean onSingleTapUp(MotionEvent e) {
+            return false;
+        }
+    });
+    private double maxDataValue;
+
+    @Override
+    public boolean onTouchEvent(MotionEvent event) {
+        return gd.onTouchEvent(event);
+    }
+
+    @Override
+    public void scrollBy(int dx, int dy) {
+        float candidateOffsetX = offsetX;
+        candidateOffsetX += dx;
+
+        // Maybe too far left?
+        if (candidateOffsetX < 0)
+            candidateOffsetX = 0;
+
+        float totalDataWidth = getTotalWidth();
+        float visibleDataWidth =  getAvailableDataWidth();
+
+        float maxOffset = totalDataWidth - visibleDataWidth + getDimensionFromDp(1.0f);
+        if (maxOffset < 0)
+            maxOffset = 0;
+
+        // To far right?
+        if (candidateOffsetX > maxOffset) {
+            candidateOffsetX = maxOffset;
+        }
+
+        if (candidateOffsetX != offsetX) {
+            offsetX = candidateOffsetX;
+            invalidate();
+        }
+    }
+
+    private void adapterChanged() {
+        verticalAxisRect.init();
+        horizontalAxisRect.init();
+        barConfig.init();
+
+        // max vrijednost unutar Data arraya, max vrijednost podataka koje imamo
+        maxDataValue = getDataMaxValue();
+        // max vrijednost grafa, ovisi o max vrijednosti data arraya, ali nije
+        // ista (nekad imamo lufta)
+        maxGraphValue = getGraphMaxValue(maxDataValue);
+
+        verticalAxisValues.setHeight(-1);
+        verticalAxisValues.setAverageValue(getAverageDataValue());
+
+        invalidate();
+    }
+
+    public void setAdapter(BarGraphAdapter adapter) {
+        this.adapter = adapter;
+
+        adapterChanged();
+    }
+
+    public void notifyDatasetChanged() {
+        adapterChanged();
+    }
+
+    /**
+     *
+     * Value returned by this function is >= maxDataValue.
+     * Basically, calculates number of digits in max value and rounds to the next value in that
+     * order of magnitude.
+     *
+     * Example:
+     * maxDataValue     maxGraphValue
+     * 23.21            30.0
+     * 542.32           600.0
+     *
+     * @param maxDataValue
+     * @return
+     */
+    private double getGraphMaxValue(double maxDataValue) {
+        // odmah računamo sve potrebno, da se ne zamaramo s tim na onDraw
+        // vrijednost za graf
+        // zanima me kolko dekadskih znamenki ima najveća vrijednost
+        int numberOfDigits = (int) Math.floor(Math.log10(maxDataValue)) + 1;
+        // osnova je 10^(broj_znakova - 1)
+        int order = (int) Math.pow(10, numberOfDigits - 1);
+        // pocetak je na n*order tako da je n*order najmanji veći za neki cijeli
+        // broj n
+        // ovaj broj nam je u biti logički maksimum
+        return ((int) (Math.ceil(maxDataValue / order))) * order;
+    }
+
+    private double getAverageDataValue() {
+        double res = getDataValuesSum();
+        return res / adapter.getCount();
+    }
+
+    private double getDataValuesSum() {
+        if (adapter == null || adapter.getCount() == 0)
+            return Double.NEGATIVE_INFINITY;
+
+        double res = 0.0;
+        for (int i = 0; i < adapter.getCount(); ++i)
+            res += adapter.getValue(i);
+        return res;
+    }
+
+    private class VerticalAxisValues {
+        private int height;
+        private float minDistanceBetweenMarkings;
+        private float distanceBetweenMarkingsPx;
+        private double yieldBetweenMarkings;
+        private int markingsCount;
+        private double topMarkingHeight;
+        private double averageValue;
+
+        public VerticalAxisValues() {
+
+        }
+
+        private void normalize(double maxDataValue) {
+            int markingsCount = (int) Math.ceil(maxDataValue / getYieldBetweenMarkings());
+            double maxMarkingHeight = markingsCount * getYieldBetweenMarkings();
+            setTopMarkingHeight(maxMarkingHeight);
+            setMarkingsCount(markingsCount);
+        }
+
+        public void update(int height, double maxGraphValue) {
+            this.height = height;
+
+            int maxNumberOfMarkings = calculateMaximumNumberOfVerticalMarkings(minDistanceBetweenMarkings);
+            yieldBetweenMarkings = maxGraphValue / maxNumberOfMarkings;
+
+            normalize(maxDataValue);
+            distanceBetweenMarkingsPx = calculateLogicalYWidth(verticalAxisValues.getMarkingsCount());
+        }
+
+        private float calculateLogicalYWidth(int count) {
+            float normYResolution = (float) getGraphHeight() / count;
+            return normYResolution;
+        }
+
+        public int getHeight() {
+            return height;
+        }
+
+        public void setHeight(int height) {
+            this.height = height;
+        }
+
+        public float getDistanceBetweenMarkingsPx() {
+            return distanceBetweenMarkingsPx;
+        }
+
+        public void setDistanceBetweenMarkingsPx(float distanceBetweenMarkingsPx) {
+            this.distanceBetweenMarkingsPx = distanceBetweenMarkingsPx;
+        }
+
+        public float getMinDistanceBetweenMarkings() {
+            return minDistanceBetweenMarkings;
+        }
+
+        public void setMinDistanceBetweenMarkings(float minDistanceBetweenMarkings) {
+            this.minDistanceBetweenMarkings = minDistanceBetweenMarkings;
+        }
+
+        public double getYieldBetweenMarkings() {
+            return yieldBetweenMarkings;
+        }
+
+        public void setYieldBetweenMarkings(double yYield) {
+            this.yieldBetweenMarkings = yYield;
+        }
+
+        public int getMarkingsCount() {
+            return markingsCount;
+        }
+
+        public void setMarkingsCount(int markingsCount) {
+            this.markingsCount = markingsCount;
+        }
+
+        public double getTopMarkingHeight() {
+            return topMarkingHeight;
+        }
+
+        public void setTopMarkingHeight(double topMarkingHeight) {
+            this.topMarkingHeight = topMarkingHeight;
+        }
+
+        public double getAverageValue() {
+            return averageValue;
+        }
+
+        public void setAverageValue(double averageValue) {
+            this.averageValue = averageValue;
+        }
+
+    }
+
+    private VerticalAxisValues verticalAxisValues = new VerticalAxisValues();
+
+    private void initVerticalAxisValues() {
+        if (verticalAxisValues.getHeight() != getHeight()) {
+            verticalAxisValues.update(getHeight(), maxGraphValue);
+        }
+    }
+
+    private int calculateMaximumNumberOfVerticalMarkings(float distance) {
+        // na koliko dijelova možemo raspodijeliti
+        int discreteY = (int) (getGraphHeight() / distance);
+        // trazimo najmanju nizu potenciju od 2 koja bi odgovorala discreteY
+        int log2 = (int) Math.floor(Math.log(discreteY) / Math.log(2.));
+        int normDiscreteY = (int) Math.pow(2, log2);
+        return normDiscreteY;
+    }
+
+    private double getDataMaxValue() {
+        double res = Double.NEGATIVE_INFINITY;
+        if (adapter != null) {
+            for (int i = 0; i < adapter.getCount(); ++i) {
+                if (adapter.getValue(i) > res) {
+                    res = adapter.getValue(i);
+                }
+            }
+        }
+
+        return res;
+    }
+
+    public boolean isDrawAverageLine() {
+        return drawAverageLine;
+    }
+
+    public void setDrawAverageLine(boolean drawAvgLine) {
+        this.drawAverageLine = drawAvgLine;
+    }
+
+    public void setDrawXValues(boolean draw) {
+        horizontalAxisRect.setShowValues(draw);
+    }
+
+    public void setDrawYValues(boolean draw) {
+        verticalAxisRect.setShowValues(draw);
+    }
+
+    public void setDescriptionY(String desc) {
+        verticalAxisRect.setDescription(desc);
+    }
+
+    public void setDescriptionX(String desc) {
+        horizontalAxisRect.setDescription(desc);
+    }
+
+    private class BarConfig {
+        private float padding;
+        private float whiteSpace;
+        private Paint paintRect = null;
+        private Paint paintText = null;
+        private float barWidth;
+
+        public void init() {
+            float fontSize = barFontSizePx;
+            paintRect = new Paint();
+            paintRect.setColor(Color.parseColor("#81E5F0"));
+            paintRect.setAntiAlias(true);
+
+            paintText = new Paint();
+            paintText.setColor(Color.parseColor("#000000"));
+            paintText.setAntiAlias(true);
+            paintText.setTextSize(fontSize);
+
+            padding = barPaddingPx;
+            whiteSpace = getDimensionFromDp(1.0f);
+
+            barWidth = 2 * padding + getMaxTextHeight();
+        }
+
+        public float getPadding() {
+            return padding;
+        }
+
+        public int getMaxTextHeight() {
+            Rect bounds = new Rect();
+            paintText.getTextBounds("M", 0, 1, bounds);
+            return bounds.height();
+        }
+
+        public Paint getPaintRect() {
+            return paintRect;
+        }
+
+        public void setPaintRect(Paint paintRect) {
+            this.paintRect = paintRect;
+        }
+
+        public Paint getPaintText() {
+            return paintText;
+        }
+
+        public void setPaintText(Paint paintText) {
+            this.paintText = paintText;
+        }
+
+        public float getBarWidth() {
+            return barWidth;
+        }
+
+        public void setBarWidth(float barWidth) {
+            this.barWidth = barWidth;
+        }
+
+        public float getWhiteSpace() {
+            return whiteSpace;
+        }
+
+        public void setWhiteSpace(float whiteSpace) {
+            this.whiteSpace = whiteSpace;
+        }
+    }
+
+    private abstract class AxisRect {
+        float lineSpacing;
+        float fontSize;
+        float axisMarkingsLength;
+
+        Paint paintLine = null;
+        Paint paintDescription = null;
+
+        boolean showValues = true;
+        String description = null;
+
+        public void init() {
+            fontSize = axisValuesFontSizePx;
+            axisMarkingsLength = getDimensionFromDp(DEFAULT_MARKINGS_LENGTH_DP);
+
+            paintLine = new Paint();
+            paintLine.setAntiAlias(true);
+            paintLine.setColor(Color.BLACK);
+            paintLine.setTextSize(fontSize);
+
+            paintDescription = new Paint();
+            paintDescription.setAntiAlias(true);
+            paintDescription.setColor(Color.BLACK);
+            paintDescription.setTextSize(getDimensionFromSp(DEFAULT_AXIS_DESCRIPTION_FONT_SIZE_SP));
+
+            lineSpacing = getDimensionFromDp(DEFAULT_AXIS_LINE_SPACING_DP);
+        }
+
+        public Paint getPaintLine() {
+            return paintLine;
+        }
+
+        public float getFontSize() {
+            return fontSize;
+        }
+
+        public void setFontSize(float fontSize) {
+            this.fontSize = fontSize;
+        }
+
+        public float getLineSpacing() {
+            return lineSpacing;
+        }
+
+        public void setLineSpacing(float lineSpacing) {
+            this.lineSpacing = lineSpacing;
+        }
+
+        public boolean isShowValues() {
+            return showValues;
+        }
+
+        public void setShowValues(boolean showValues) {
+            this.showValues = showValues;
+        }
+
+        public float getAxisMarkingsLength() {
+            return axisMarkingsLength;
+        }
+
+        public int getTextHeight(Paint paint, String s) {
+            Rect bounds = new Rect();
+            paint.getTextBounds(s, 0, s.length(), bounds);
+            return bounds.height();
+        }
+
+        public int getTextHeight() {
+            Rect bounds = new Rect();
+            paintLine.getTextBounds("0", 0, 1, bounds);
+            return bounds.height();
+        }
+
+        public String getDescription() {
+            return description;
+        }
+
+        public void setDescription(String description) {
+            this.description = description;
+        }
+
+        public Paint getPaintDescription() {
+            return paintDescription;
+        }
+
+        public void setPaintDescription(Paint paintDescription) {
+            this.paintDescription = paintDescription;
+        }
+    }
+
+    private class VerticalAxisRect extends AxisRect {
+        @Override
+        public void init() {
+            super.init();
+        }
+
+        public float getWidth() {
+            float res = getAxisLeft();
+            res += paintLine.getStrokeWidth();
+            return res;
+        }
+
+        public float getAxisLeft() {
+            float res = 0;
+            if (showValues) {
+                res += getTextHeight();
+                res += lineSpacing;
+            }
+            if (description != null) {
+                res += getTextHeight(paintDescription, description);
+                res += lineSpacing * 2;
+            }
+            res += axisMarkingsLength;
+            return res;
+        }
+
+        public float getValuesX() {
+            float res = getTextHeight();
+            if (description != null) res += lineSpacing * 2 + getTextHeight(paintDescription, description);
+            return res;
+        }
+
+        public float getDescriptionX() {
+            return getTextHeight(paintDescription, description);
+        }
+    }
+
+    private class HorizontalAxisRect extends AxisRect {
+        @Override
+        public void init() {
+            super.init();
+        }
+
+        public float getHeight() {
+            float res = 0;
+            if (showValues) {
+                res += getTextHeight();
+                res += lineSpacing;
+            }
+            if (description != null) {
+                res += getTextHeight(paintDescription, description);
+                res += lineSpacing * 2;
+            }
+            res += axisMarkingsLength;
+            return res;
+        }
+
+        public float getMarkingValuesY() {
+            float res = BarGraphView.this.getHeight() - BarGraphView.this.getPaddingBottom();
+            if (description != null)
+                res -= lineSpacing * 2 + getTextHeight(paintDescription, description);
+            return res;
+        }
+
+        public float getDescriptionY() {
+            return BarGraphView.this.getHeight() - BarGraphView.this.getPaddingBottom();
+        }
+
+        public float getAxisBottom() {
+            float viewHeight = BarGraphView.this.getHeight();
+            float axisHeight = getHeight();
+            return viewHeight - axisHeight - getPaddingBottom();
+        }
+
+    }
+}

BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.png


BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.png


BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.png


BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png


BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png


+ 12 - 0
app/src/main/res/values/attrs.xml

@@ -0,0 +1,12 @@
+<resources>
+    <declare-styleable name="BarGraph">
+        <attr name="xAxisText" format="string" />
+        <attr name="yAxisText" format="string" />
+        <attr name="barTextSize" format="dimension" />
+        <attr name="barPadding" format="dimension" />
+        <attr name="axisValuesTextSize" format="dimension" />
+        <attr name="showAverageLine" format="boolean" />
+        <attr name="showVerticalValues" format="boolean" />
+        <attr name="showHorizontalValues" format="boolean" />
+    </declare-styleable>
+</resources>

+ 6 - 0
app/src/main/res/values/colors.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <color name="colorPrimary">#3F51B5</color>
+    <color name="colorPrimaryDark">#303F9F</color>
+    <color name="colorAccent">#FF4081</color>
+</resources>

+ 3 - 0
app/src/main/res/values/strings.xml

@@ -0,0 +1,3 @@
+<resources>
+    <string name="app_name">Graphs</string>
+</resources>

+ 11 - 0
app/src/main/res/values/styles.xml

@@ -0,0 +1,11 @@
+<resources>
+
+    <!-- Base application theme. -->
+    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
+        <!-- Customize your theme here. -->
+        <item name="colorPrimary">@color/colorPrimary</item>
+        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+        <item name="colorAccent">@color/colorAccent</item>
+    </style>
+
+</resources>

+ 17 - 0
app/src/test/java/hr/tacitus/graphs/ExampleUnitTest.java

@@ -0,0 +1,17 @@
+package hr.tacitus.graphs;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+public class ExampleUnitTest {
+    @Test
+    public void addition_isCorrect() throws Exception {
+        assertEquals(4, 2 + 2);
+    }
+}

+ 23 - 0
build.gradle

@@ -0,0 +1,23 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+    repositories {
+        jcenter()
+    }
+    dependencies {
+        classpath 'com.android.tools.build:gradle:2.3.3'
+
+        // NOTE: Do not place your application dependencies here; they belong
+        // in the individual module build.gradle files
+    }
+}
+
+allprojects {
+    repositories {
+        jcenter()
+    }
+}
+
+task clean(type: Delete) {
+    delete rootProject.buildDir
+}

+ 17 - 0
gradle.properties

@@ -0,0 +1,17 @@
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx1536m
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true

BIN
gradle/wrapper/gradle-wrapper.jar


+ 6 - 0
gradle/wrapper/gradle-wrapper.properties

@@ -0,0 +1,6 @@
+#Sat Jul 01 13:36:56 CEST 2017
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

+ 160 - 0
gradlew

@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+    JAVACMD=`cygpath --unix "$JAVACMD"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+    JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

+ 90 - 0
gradlew.bat

@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega

+ 1 - 0
settings.gradle

@@ -0,0 +1 @@
+include ':app'