Java Code Examples for com.github.mikephil.charting.utils.Utils#getSDKInt()

The following examples show how to use com.github.mikephil.charting.utils.Utils#getSDKInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LineRadarRenderer.java    From StockChart-MPAndroidChart with MIT License 6 votes vote down vote up
/**
 * Draws the provided path in filled mode with the provided drawable.
 *
 * @param c
 * @param filledPath
 * @param drawable
 */
protected void drawFilledPath(Canvas c, Path filledPath, Drawable drawable) {

    if (clipPathSupported()) {

        int save = c.save();
        c.clipPath(filledPath);

        drawable.setBounds((int) mViewPortHandler.contentLeft(),
                (int) mViewPortHandler.contentTop(),
                (int) mViewPortHandler.contentRight(),
                (int) mViewPortHandler.contentBottom());
        drawable.draw(c);

        c.restoreToCount(save);
    } else {
        throw new RuntimeException("Fill-drawables not (yet) supported below API level 18, " +
                "this code was run on API level " + Utils.getSDKInt() + ".");
    }
}
 
Example 2
Source File: LineRadarRenderer.java    From Ticket-Analysis with MIT License 6 votes vote down vote up
/**
 * Draws the provided path in filled mode with the provided drawable.
 *
 * @param c
 * @param filledPath
 * @param drawable
 */
protected void drawFilledPath(Canvas c, Path filledPath, Drawable drawable) {

    if (clipPathSupported()) {

        int save = c.save();
        c.clipPath(filledPath);

        drawable.setBounds((int) mViewPortHandler.contentLeft(),
                (int) mViewPortHandler.contentTop(),
                (int) mViewPortHandler.contentRight(),
                (int) mViewPortHandler.contentBottom());
        drawable.draw(c);

        c.restoreToCount(save);
    } else {
        throw new RuntimeException("Fill-drawables not (yet) supported below API level 18, " +
                "this code was run on API level " + Utils.getSDKInt() + ".");
    }
}
 
Example 3
Source File: LineRadarRenderer.java    From android-kline with Apache License 2.0 6 votes vote down vote up
/**
 * Draws the provided path in filled mode with the provided drawable.
 *
 * @param c
 * @param filledPath
 * @param drawable
 */
protected void drawFilledPath(Canvas c, Path filledPath, Drawable drawable) {

    if (clipPathSupported()) {

        int save = c.save();
        c.clipPath(filledPath);

        drawable.setBounds((int) mViewPortHandler.contentLeft(),
                (int) mViewPortHandler.contentTop(),
                (int) mViewPortHandler.contentRight(),
                (int) mViewPortHandler.contentBottom());
        drawable.draw(c);

        c.restoreToCount(save);
    } else {
        throw new RuntimeException("Fill-drawables not (yet) supported below API level 18, " +
                "this code was run on API level " + Utils.getSDKInt() + ".");
    }
}
 
Example 4
Source File: LineRadarRenderer.java    From NetKnight with Apache License 2.0 6 votes vote down vote up
/**
 * Draws the provided path in filled mode with the provided drawable.
 *
 * @param c
 * @param filledPath
 * @param drawable
 */
protected void drawFilledPath(Canvas c, Path filledPath, Drawable drawable) {

    if (clipPathSupported()) {

        c.save();
        c.clipPath(filledPath);

        drawable.setBounds((int) mViewPortHandler.contentLeft(),
                (int) mViewPortHandler.contentTop(),
                (int) mViewPortHandler.contentRight(),
                (int) mViewPortHandler.contentBottom());
        drawable.draw(c);

        c.restore();
    } else {
        throw new RuntimeException("Fill-drawables not (yet) supported below API level 18, " +
                "this code was run on API level " + Utils.getSDKInt() + ".");
    }
}
 
Example 5
Source File: DateGraph.java    From fastnfitness with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void draw(ArrayList<Entry> entries) {
    mChart.clear();
    if (entries.isEmpty()) {
        return;
    }

    Collections.sort(entries, new EntryXComparator());

    //Log.d("DEBUG", arrayToString(entries));

    LineDataSet set1 = new LineDataSet(entries, mChartName);
    set1.setLineWidth(3f);
    set1.setCircleRadius(4f);
    set1.setDrawFilled(true);
    if (Utils.getSDKInt() >= 18) {
        // fill drawable only supported on api level 18 and above
        Drawable drawable = ContextCompat.getDrawable(mContext, R.drawable.fade_blue);
        set1.setFillDrawable(drawable);
    } else {
        set1.setFillColor(ColorTemplate.getHoloBlue());
    }
    set1.setFillAlpha(100);
    set1.setColor(mContext.getResources().getColor(R.color.toolbar_background));
    set1.setCircleColor(mContext.getResources().getColor(R.color.toolbar_background));

    // Create a data object with the datasets
    LineData data = new LineData(set1);

    data.setValueFormatter(new IValueFormatter() {
        private DecimalFormat mFormat = new DecimalFormat("#.##");

        @Override
        public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
            return mFormat.format(value);
        }
    });

    // Set data
    mChart.setData(data);

    mChart.invalidate();
    //mChart.animateY(500, Easing.EasingOption.EaseInBack);    //refresh graph

}
 
Example 6
Source File: MiniDateGraph.java    From fastnfitness with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void draw(ArrayList<Entry> entries) {
    mChart.clear();
    if (entries.isEmpty()) {
        return;
    }

    Collections.sort(entries, new EntryXComparator());

    //Log.d("DEBUG", arrayToString(entries));

    LineDataSet set1 = new LineDataSet(entries, mChartName);
    set1.setLineWidth(3f);
    set1.setCircleRadius(0f);
    set1.setDrawFilled(true);
    if (Utils.getSDKInt() >= 18) {
        // fill drawable only supported on api level 18 and above
        Drawable drawable = ContextCompat.getDrawable(mContext, R.drawable.fade_blue);
        set1.setFillDrawable(drawable);
    } else {
        set1.setFillColor(ColorTemplate.getHoloBlue());
    }
    set1.setFillAlpha(100);
    set1.setColor(mContext.getResources().getColor(R.color.toolbar_background));
    set1.setCircleColor(mContext.getResources().getColor(R.color.toolbar_background));

    // Create a data object with the datasets
    LineData data = new LineData(set1);
    data.setDrawValues(false);

    /*data.setValueFormatter(new IValueFormatter() {
        private DecimalFormat mFormat = new DecimalFormat("#.##");

        @Override
        public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
            return mFormat.format(value);
        }
    });*/

    // Set data
    mChart.setData(data);

    mChart.invalidate();
    //mChart.animateY(500, Easing.EasingOption.EaseInBack);    //refresh graph

}
 
Example 7
Source File: CurrencyActivity.java    From Travel-Mate with MIT License 4 votes vote down vote up
void setGraphData(JSONArray currencyRateTrends) {
    ArrayList<Entry> values = new ArrayList<>();

    for (int i = 0; i < currencyRateTrends.length(); i++) {
        try {
            values.add(new Entry(i, (float) currencyRateTrends.getDouble(i)));
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    LineDataSet lineDataSet = new LineDataSet(values, GRAPH_LABEL_NAME);
    lineDataSet.setDrawIcons(false);
    lineDataSet.setColor(Color.RED);
    lineDataSet.setCircleColor(Color.BLUE);
    lineDataSet.setCircleRadius(1f);
    lineDataSet.setLineWidth(1f);
    lineDataSet.setCircleRadius(3f);
    lineDataSet.setDrawCircleHole(true);
    lineDataSet.setValueTextSize(10f);
    lineDataSet.setValueTextColor(Color.BLACK);
    lineDataSet.setDrawFilled(true);
    lineDataSet.setFormSize(10.f);
    if (Utils.getSDKInt() >= 18) {
        // fill drawable only supported on api level 18 and above
        Drawable drawable = ContextCompat.getDrawable(this, R.drawable.fade_green);
        lineDataSet.setFillDrawable(drawable);
    } else {
        lineDataSet.setFillColor(Color.BLACK);
    }

    ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
    dataSets.add(lineDataSet);

    // create a data object with the datasets
    LineData data = new LineData(dataSets);

    // set data
    graph.setData(data);

}
 
Example 8
Source File: LineRadarRenderer.java    From StockChart-MPAndroidChart with MIT License 2 votes vote down vote up
/**
 * Clip path with hardware acceleration only working properly on API level 18 and above.
 *
 * @return
 */
private boolean clipPathSupported() {
    return Utils.getSDKInt() >= 18;
}
 
Example 9
Source File: LineRadarRenderer.java    From Ticket-Analysis with MIT License 2 votes vote down vote up
/**
 * Clip path with hardware acceleration only working properly on API level 18 and above.
 *
 * @return
 */
private boolean clipPathSupported() {
    return Utils.getSDKInt() >= 18;
}
 
Example 10
Source File: LineRadarRenderer.java    From android-kline with Apache License 2.0 2 votes vote down vote up
/**
 * Clip path with hardware acceleration only working properly on API level 18 and above.
 *
 * @return
 */
private boolean clipPathSupported() {
    return Utils.getSDKInt() >= 18;
}
 
Example 11
Source File: LineRadarRenderer.java    From NetKnight with Apache License 2.0 2 votes vote down vote up
/**
 * Clip path with hardware acceleration only working properly on API level 18 and above.
 *
 * @return
 */
private boolean clipPathSupported() {
    return Utils.getSDKInt() >= 18;
}