This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
import matplotlib.pyplot as plt | |
def interpolateCatmulRomeSegment(P0, P1, P2, P3, nPoints=10): | |
""" | |
P0, P1, P2, and P3 should be (x,y) point pairs that define the Catmull-Rom spline. | |
nPoints is the number of points to include in this curve segment. | |
""" | |
# Convert the points to numpy so that we can do array multiplication | |
P0, P1, P2, P3 = map(numpy.array, [P0, P1, P2, P3]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.lecho.mobilization; | |
import android.content.Context; | |
import android.content.res.TypedArray; | |
import android.graphics.Canvas; | |
import android.graphics.Rect; | |
import android.graphics.drawable.Drawable; | |
import android.os.Build; | |
import android.support.v7.widget.LinearLayoutManager; | |
import android.support.v7.widget.RecyclerView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |
View rootView = inflater.inflate(R.layout.fragment_line_column_dependency, container, false); | |
// *** TOP LINE CHART *** | |
chartTop = (LineChartView) rootView.findViewById(R.id.chart_top); | |
// Generate and set data for line chart | |
generateInitialLineData(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lecho.lib.hellocharts.renderer; | |
import lecho.lib.hellocharts.util.CasteljauComputator; | |
import android.graphics.Canvas; | |
import android.graphics.Paint; | |
import android.graphics.PointF; | |
/** | |
* PathCompat uses Canvas.drawLines instead Canvas.drawPath. Supports normal lines and cubic Bezier's lines. | |
* Warning!: doesn't support breaks in line so line has to be continuous and doesn't support area chart. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lecho.lib.hellocharts.util; | |
import android.graphics.PointF; | |
/** | |
* Iterative implementation of de Casteljau's algorithm for cubic Bezier's curves. | |
* | |
*/ | |
public class CasteljauComputator { | |
private static final int DEFAULT_CURVE_DEGREE = 3;// By default cubic. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lecho.lib.hellocharts.util; | |
import android.graphics.RectF; | |
/** | |
* Cohen-Sutherland algorithm implementation based on wikipedia article. | |
* | |
* {@link http://en.wikipedia.org/wiki/Cohen-Sutherland_algorithm} | |
* | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Automatically calculates Y axis values. | |
private Axis calculateYAxis(int numberOfSteps) { | |
if (numberOfSteps < 2) { | |
throw new | |
IllegalArgumentException("Number or steps have to be grater or equal 2"); | |
} | |
List<Float> values = new ArrayList<Float>(); | |
final float range = mData.getMaxYValue() - mData.getMinYValue(); | |
final float tickRange = range / (numberOfSteps - 1); | |
final float x = (float) Math.ceil(Math.log10(tickRange) - 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TimePickerDialogFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener { | |
private static final String DIALOG_HOUR = "my.package:INITIAL_HOUR"; | |
private static final String DIALOG_MINUTE = "my.package:INITIAL_MINUTE"; | |
//My custom listener | |
private OnTimePickedListener mListener; | |
private int mDialogRequestCode; | |
//Use dialogRequestCode to discriminate dialogs in OnTimePickedListener#onTimePicked method. I think you could also use dialog tag string instead of integer variable. | |
public static TimePickerDialogFragment newInstance(int hour, int minute, int dialogRequestCode, OnTimePickedListener listener) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath 'com.android.tools.build:gradle:0.7.0' | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2012 The Android Open Source Project | |
* | |
* 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 |
NewerOlder