当前位置: 首页>>代码示例>>Java>>正文


Java Utils类代码示例

本文整理汇总了Java中com.github.mikephil.charting.utils.Utils的典型用法代码示例。如果您正苦于以下问题:Java Utils类的具体用法?Java Utils怎么用?Java Utils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Utils类属于com.github.mikephil.charting.utils包,在下文中一共展示了Utils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupDefaultFormatter

import com.github.mikephil.charting.utils.Utils; //导入依赖的package包/类
/**
 * Calculates the required number of digits for the values that might be
 * drawn in the chart (if enabled), and creates the default-value-formatter
 */
protected void setupDefaultFormatter(float min, float max) {

    float reference = 0f;

    if (mData == null || mData.getEntryCount() < 2) {

        reference = Math.max(Math.abs(min), Math.abs(max));
    } else {
        reference = Math.abs(max - min);
    }

    int digits = Utils.getDecimals(reference);

    // setup the formatter with a new number of digits
    mDefaultValueFormatter.setup(digits);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:Chart.java

示例2: equalTo

import com.github.mikephil.charting.utils.Utils; //导入依赖的package包/类
/**
 * Compares value, xIndex and data of the entries. Returns true if entries
 * are equal in those points, false if not. Does not check by hash-code like
 * it's done by the "equals" method.
 * 
 * @param e
 * @return
 */
public boolean equalTo(Entry e) {

    if (e == null)
        return false;

    if (e.getData() != this.getData())
        return false;

    if (Math.abs(e.x - this.x) > Utils.FLOAT_EPSILON)
        return false;

    if (Math.abs(e.getY() - this.getY()) > Utils.FLOAT_EPSILON)
        return false;

    return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:Entry.java

示例3: renderShape

import com.github.mikephil.charting.utils.Utils; //导入依赖的package包/类
@Override
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
                        float posX, float posY, Paint renderPaint) {

    final float shapeHalf = dataSet.getScatterShapeSize() / 2f;

    renderPaint.setStyle(Paint.Style.STROKE);
    renderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));

    c.drawLine(
            posX - shapeHalf,
            posY - shapeHalf,
            posX + shapeHalf,
            posY + shapeHalf,
            renderPaint);
    c.drawLine(
            posX + shapeHalf,
            posY - shapeHalf,
            posX - shapeHalf,
            posY + shapeHalf,
            renderPaint);

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:XShapeRenderer.java

示例4: renderShape

import com.github.mikephil.charting.utils.Utils; //导入依赖的package包/类
@Override
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
                        float posX, float posY, Paint renderPaint) {

    final float shapeHalf = dataSet.getScatterShapeSize() / 2f;

    renderPaint.setStyle(Paint.Style.STROKE);
    renderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));

    c.drawLine(
            posX - shapeHalf,
            posY,
            posX + shapeHalf,
            posY,
            renderPaint);
    c.drawLine(
            posX,
            posY - shapeHalf,
            posX,
            posY + shapeHalf,
            renderPaint);

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:CrossShapeRenderer.java

示例5: renderShape

import com.github.mikephil.charting.utils.Utils; //导入依赖的package包/类
@Override
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
                        float posX, float posY, Paint renderPaint) {

    final float shapeHalf = dataSet.getScatterShapeSize() / 2f;

    renderPaint.setStyle(Paint.Style.STROKE);
    renderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));

    c.drawLine(
            posX,
            posY - (2 * shapeHalf),
            posX + (2 * shapeHalf),
            posY,
            renderPaint);

    c.drawLine(
            posX,
            posY - (2 * shapeHalf),
            posX - (2 * shapeHalf),
            posY,
            renderPaint);

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:ChevronUpShapeRenderer.java

示例6: renderShape

import com.github.mikephil.charting.utils.Utils; //导入依赖的package包/类
@Override
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
                 float posX, float posY, Paint renderPaint) {

    final float shapeHalf = dataSet.getScatterShapeSize() / 2f;

    renderPaint.setStyle(Paint.Style.STROKE);
    renderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));

    c.drawLine(
            posX,
            posY + (2 * shapeHalf),
            posX + (2 * shapeHalf),
            posY,
            renderPaint);

    c.drawLine(
            posX,
            posY + (2 * shapeHalf),
            posX - (2 * shapeHalf),
            posY,
            renderPaint);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:ChevronDownShapeRenderer.java

示例7: DataRenderer

import com.github.mikephil.charting.utils.Utils; //导入依赖的package包/类
public DataRenderer(ChartAnimator animator, ViewPortHandler viewPortHandler) {
    super(viewPortHandler);
    this.mAnimator = animator;

    mRenderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mRenderPaint.setStyle(Style.FILL);

    mDrawPaint = new Paint(Paint.DITHER_FLAG);

    mValuePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mValuePaint.setColor(Color.rgb(63, 63, 63));
    mValuePaint.setTextAlign(Align.CENTER);
    mValuePaint.setTextSize(Utils.convertDpToPixel(9f));

    mHighlightPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mHighlightPaint.setStyle(Paint.Style.STROKE);
    mHighlightPaint.setStrokeWidth(2f);
    mHighlightPaint.setColor(Color.rgb(255, 187, 115));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:DataRenderer.java

示例8: computeSize

import com.github.mikephil.charting.utils.Utils; //导入依赖的package包/类
@Override
protected void computeSize() {
    
    mAxisLabelPaint.setTypeface(mXAxis.getTypeface());
    mAxisLabelPaint.setTextSize(mXAxis.getTextSize());

    String longest = mXAxis.getLongestLabel();

    final FSize labelSize = Utils.calcTextSize(mAxisLabelPaint, longest);

    final float labelWidth = (int)(labelSize.width + mXAxis.getXOffset() * 3.5f);
    final float labelHeight = labelSize.height;

    final FSize labelRotatedSize = Utils.getSizeOfRotatedRectangleByDegrees(
            labelSize.width,
            labelHeight,
            mXAxis.getLabelRotationAngle());

    mXAxis.mLabelWidth = Math.round(labelWidth);
    mXAxis.mLabelHeight = Math.round(labelHeight);
    mXAxis.mLabelRotatedWidth = (int)(labelRotatedSize.width + mXAxis.getXOffset() * 3.5f);
    mXAxis.mLabelRotatedHeight = Math.round(labelRotatedSize.height);

    FSize.recycleInstance(labelRotatedSize);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:XAxisRendererHorizontalBarChart.java

示例9: computeSize

import com.github.mikephil.charting.utils.Utils; //导入依赖的package包/类
protected void computeSize() {

        String longest = mXAxis.getLongestLabel();

        mAxisLabelPaint.setTypeface(mXAxis.getTypeface());
        mAxisLabelPaint.setTextSize(mXAxis.getTextSize());

        final FSize labelSize = Utils.calcTextSize(mAxisLabelPaint, longest);

        final float labelWidth = labelSize.width;
        final float labelHeight = Utils.calcTextHeight(mAxisLabelPaint, "Q");

        final FSize labelRotatedSize = Utils.getSizeOfRotatedRectangleByDegrees(
                labelWidth,
                labelHeight,
                mXAxis.getLabelRotationAngle());


        mXAxis.mLabelWidth = Math.round(labelWidth);
        mXAxis.mLabelHeight = Math.round(labelHeight);
        mXAxis.mLabelRotatedWidth = Math.round(labelRotatedSize.width);
        mXAxis.mLabelRotatedHeight = Math.round(labelRotatedSize.height);

        FSize.recycleInstance(labelRotatedSize);
        FSize.recycleInstance(labelSize);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:XAxisRenderer.java

示例10: drawFilledPath

import com.github.mikephil.charting.utils.Utils; //导入依赖的package包/类
/**
 * 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() + ".");
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:LineRadarRenderer.java

示例11: YAxisRenderer

import com.github.mikephil.charting.utils.Utils; //导入依赖的package包/类
public YAxisRenderer(ViewPortHandler viewPortHandler, YAxis yAxis, Transformer trans) {
    super(viewPortHandler, trans, yAxis);

    this.mYAxis = yAxis;

    if(mViewPortHandler != null) {

        mAxisLabelPaint.setColor(Color.BLACK);
        mAxisLabelPaint.setTextSize(Utils.convertDpToPixel(10f));

        mZeroLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mZeroLinePaint.setColor(Color.GRAY);
        mZeroLinePaint.setStrokeWidth(1f);
        mZeroLinePaint.setStyle(Paint.Style.STROKE);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:YAxisRenderer.java

示例12: getMaximumEntryWidth

import com.github.mikephil.charting.utils.Utils; //导入依赖的package包/类
/**
 * returns the maximum length in pixels across all legend labels + formsize
 * + formtotextspace
 *
 * @param p the paint object used for rendering the text
 * @return
 */
public float getMaximumEntryWidth(Paint p) {

    float max = 0f;
    float maxFormSize = 0f;
    float formToTextSpace = Utils.convertDpToPixel(mFormToTextSpace);

    for (LegendEntry entry : mEntries) {
        final float formSize = Utils.convertDpToPixel(
                Float.isNaN(entry.formSize)
                ? mFormSize : entry.formSize);
        if (formSize > maxFormSize)
            maxFormSize = formSize;

        String label = entry.label;
        if (label == null) continue;

        float length = (float) Utils.calcTextWidth(p, label);

        if (length > max)
            max = length;
    }

    return max + maxFormSize + formToTextSpace;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:Legend.java

示例13: getMaximumEntryHeight

import com.github.mikephil.charting.utils.Utils; //导入依赖的package包/类
/**
 * returns the maximum height in pixels across all legend labels
 *
 * @param p the paint object used for rendering the text
 * @return
 */
public float getMaximumEntryHeight(Paint p) {

    float max = 0f;

    for (LegendEntry entry : mEntries) {
        String label = entry.label;
        if (label == null) continue;

        float length = (float) Utils.calcTextHeight(p, label);

        if (length > max)
            max = length;
    }

    return max;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:Legend.java

示例14: refreshContent

import com.github.mikephil.charting.utils.Utils; //导入依赖的package包/类
@Override
public void refreshContent(Entry e, Highlight highlight) {

    if (e instanceof BarEntry) {

        BarEntry be = (BarEntry) e;

        if(be.getYVals() != null) {

            // draw the stack value
            tvContent.setText("" + Utils.formatNumber(be.getYVals()[highlight.getStackIndex()], 0, true));
        } else {
            tvContent.setText("" + Utils.formatNumber(be.getY(), 0, true));
        }
    } else {

        tvContent.setText("" + Utils.formatNumber(e.getY(), 0, true));
    }

    super.refreshContent(e, highlight);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:StackedBarsMarkerView.java

示例15: testCase

import com.github.mikephil.charting.utils.Utils; //导入依赖的package包/类
ArrayList<ChartItem> testCase() {
    Utils.init(getApplicationContext());
    JSONObject jsonObject = null;
    ArrayList<ChartItem> chartItems = null;
    //dataList 변수에 vel_raw, vel_max, dis_raw, dis_max 정보가 담기게 된다.
    //저장한 값을 그래프에 넣어준다.
    try {
        jsonObject = Test.generateJson();
        dataList = parseJsonFromDataSet(jsonObject);
        float[] velRaw = dataList.getVelRaw();
        float velMax = dataList.getVelMax();
        float[] disRaw = dataList.getDisRaw();
        float disMax = dataList.getDisMax();

        chartItems = new ArrayList<>();
        chartItems.add(new LineChartItem(generateDataLine(velRaw, "vel_raw"), getApplicationContext(),velMax));
        chartItems.add(new LineChartItem(generateDataLine(disRaw, "dis_raw"), getApplicationContext(),disMax));

    } catch (Exception e) {
        e.printStackTrace();
    }
    return chartItems;
}
 
开发者ID:Ksj7,项目名称:Rabbitqueue,代码行数:24,代码来源:MainActivity.java


注:本文中的com.github.mikephil.charting.utils.Utils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。