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


Java Utils.convertDpToPixel方法代码示例

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


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

示例1: 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

示例2: drawDataSet

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
protected void drawDataSet(Canvas c, IScatterDataSet dataSet) {

        Transformer trans = mChart.getTransformer(dataSet.getAxisDependency());

        float phaseX = Math.max(0.f, Math.min(1.f, mAnimator.getPhaseX()));
        float phaseY = mAnimator.getPhaseY();

        final float shapeSize = Utils.convertDpToPixel(dataSet.getScatterShapeSize());

        ScatterBuffer buffer = mScatterBuffers[mChart.getScatterData().getIndexOfDataSet(
                dataSet)];
        buffer.setPhases(phaseX, phaseY);
        buffer.feed(dataSet);

        trans.pointValuesToPixel(buffer.buffer);

        String shape = dataSet.getScatterShape();
        ShapeRenderer renderer = mChart.getShapeRenderer(shape);

        if (renderer != null) {
            renderer.renderShape(c, dataSet, mViewPortHandler, buffer, mRenderPaint, shapeSize);
        } else {
            throw new RuntimeException("No ShapeRenderer found for provided identifier. Please make sure to add a ShapeRenderer" +
                    " capable of rendering the provided shape.");
        }
    }
 
开发者ID:pencil-box,项目名称:NetKnight,代码行数:27,代码来源:ScatterChartRenderer.java

示例3: setSliceSpace

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
/**
 * Sets the space that is left out between the piechart-slices in dp.
 * Default: 0 --> no space, maximum 20f
 *
 * @param spaceDp
 */
public void setSliceSpace(float spaceDp) {

    if (spaceDp > 20)
        spaceDp = 20f;
    if (spaceDp < 0)
        spaceDp = 0f;

    mSliceSpace = Utils.convertDpToPixel(spaceDp);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:PieDataSet.java

示例4: drawHighlightCircle

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
public void drawHighlightCircle(Canvas c,
                                MPPointF point,
                                float innerRadius,
                                float outerRadius,
                                int fillColor,
                                int strokeColor,
                                float strokeWidth) {
    c.save();

    outerRadius = Utils.convertDpToPixel(outerRadius);
    innerRadius = Utils.convertDpToPixel(innerRadius);

    if (fillColor != ColorTemplate.COLOR_NONE) {
        Path p = mDrawHighlightCirclePathBuffer;
        p.reset();
        p.addCircle(point.x, point.y, outerRadius, Path.Direction.CW);
        if (innerRadius > 0.f) {
            p.addCircle(point.x, point.y, innerRadius, Path.Direction.CCW);
        }
        mHighlightCirclePaint.setColor(fillColor);
        mHighlightCirclePaint.setStyle(Paint.Style.FILL);
        c.drawPath(p, mHighlightCirclePaint);
    }

    if (strokeColor != ColorTemplate.COLOR_NONE) {
        mHighlightCirclePaint.setColor(strokeColor);
        mHighlightCirclePaint.setStyle(Paint.Style.STROKE);
        mHighlightCirclePaint.setStrokeWidth(Utils.convertDpToPixel(strokeWidth));
        c.drawCircle(point.x, point.y, outerRadius, mHighlightCirclePaint);
    }

    c.restore();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:34,代码来源:RadarChartRenderer.java

示例5: onMeasure

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    int size = (int) Utils.convertDpToPixel(50f);
    setMeasuredDimension(
            Math.max(getSuggestedMinimumWidth(),
                    resolveSize(size,
                            widthMeasureSpec)),
            Math.max(getSuggestedMinimumHeight(),
                    resolveSize(size,
                            heightMeasureSpec)));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:Chart.java

示例6: BarLineChartTouchListener

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
/**
 * Constructor with initialization parameters.
 *
 * @param chart               instance of the chart
 * @param touchMatrix         the touch-matrix of the chart
 * @param dragTriggerDistance the minimum movement distance that will be interpreted as a "drag" gesture in dp (3dp equals
 *                            to about 9 pixels on a 5.5" FHD screen)
 */
public BarLineChartTouchListener(BarLineChartBase<? extends BarLineScatterCandleBubbleData<? extends
        IBarLineScatterCandleBubbleDataSet<? extends Entry>>> chart, Matrix touchMatrix, float dragTriggerDistance) {
    super(chart);
    this.mMatrix = touchMatrix;

    this.mDragTriggerDist = Utils.convertDpToPixel(dragTriggerDistance);

    this.mMinScalePointerDistance = Utils.convertDpToPixel(3.5f);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:BarLineChartTouchListener.java

示例7: AxisBase

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
/**
 * default constructor
 */
public AxisBase() {
    this.mTextSize = Utils.convertDpToPixel(10f);
    this.mXOffset = Utils.convertDpToPixel(5f);
    this.mYOffset = Utils.convertDpToPixel(5f);
    this.mLimitLines = new ArrayList<LimitLine>();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:AxisBase.java

示例8: init

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
@Override
protected void init() {
    super.init();

    mYAxis = new YAxis(AxisDependency.LEFT);
    mXAxis = new XAxis();
    mXAxis.setSpaceBetweenLabels(0);

    mWebLineWidth = Utils.convertDpToPixel(1.5f);
    mInnerWebLineWidth = Utils.convertDpToPixel(0.75f);

    mRenderer = new RadarChartRenderer(this, mAnimator, mViewPortHandler);
    mYAxisRenderer = new YAxisRendererRadarChart(mViewPortHandler, mYAxis, this);
    mXAxisRenderer = new XAxisRendererRadarChart(mViewPortHandler, mXAxis, this);
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:16,代码来源:RadarChart.java

示例9: setLineWidth

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
/**
 * set the line width of the chart (min = 0.2f, max = 10f); default 1f NOTE:
 * thinner line == better performance, thicker line == worse performance
 *
 * @param width
 */
public void setLineWidth(float width) {

    if (width < 0.2f)
        width = 0.2f;
    if (width > 10.0f)
        width = 10.0f;
    mLineWidth = Utils.convertDpToPixel(width);
}
 
开发者ID:xsingHu,项目名称:xs-android-architecture,代码行数:15,代码来源:LineRadarDataSet.java

示例10: Legend

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
/**
 * default constructor
 */
public Legend() {

    mFormSize = Utils.convertDpToPixel(8f);
    mXEntrySpace = Utils.convertDpToPixel(6f);
    mYEntrySpace = Utils.convertDpToPixel(0f);
    mFormToTextSpace = Utils.convertDpToPixel(5f);
    mTextSize = Utils.convertDpToPixel(10f);
    mStackSpace = Utils.convertDpToPixel(3f);
    this.mXOffset = Utils.convertDpToPixel(5f);
    this.mYOffset = Utils.convertDpToPixel(3f); // 2
}
 
开发者ID:letolab,项目名称:LETO-Toggl_Android,代码行数:15,代码来源:Legend.java

示例11: 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 shapeSize = dataSet.getScatterShapeSize();
    final float shapeHalf = shapeSize / 2f;
    final float shapeHoleSizeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius());
    final float shapeHoleSize = shapeHoleSizeHalf * 2.f;
    final float shapeStrokeSize = (shapeSize - shapeHoleSize) / 2.f;

    final int shapeHoleColor = dataSet.getScatterShapeHoleColor();

    renderPaint.setStyle(Paint.Style.FILL);

    // create a triangle path
    Path tri = mTrianglePathBuffer;
    tri.reset();

    tri.moveTo(posX, posY - shapeHalf);
    tri.lineTo(posX + shapeHalf, posY + shapeHalf);
    tri.lineTo(posX - shapeHalf, posY + shapeHalf);

    if (shapeSize > 0.0) {
        tri.lineTo(posX, posY - shapeHalf);

        tri.moveTo(posX - shapeHalf + shapeStrokeSize,
                posY + shapeHalf - shapeStrokeSize);
        tri.lineTo(posX + shapeHalf - shapeStrokeSize,
                posY + shapeHalf - shapeStrokeSize);
        tri.lineTo(posX,
                posY - shapeHalf + shapeStrokeSize);
        tri.lineTo(posX - shapeHalf + shapeStrokeSize,
                posY + shapeHalf - shapeStrokeSize);
    }

    tri.close();

    c.drawPath(tri, renderPaint);
    tri.reset();

    if (shapeSize > 0.0 &&
            shapeHoleColor != ColorTemplate.COLOR_NONE) {

        renderPaint.setColor(shapeHoleColor);

        tri.moveTo(posX,
                posY - shapeHalf + shapeStrokeSize);
        tri.lineTo(posX + shapeHalf - shapeStrokeSize,
                posY + shapeHalf - shapeStrokeSize);
        tri.lineTo(posX - shapeHalf + shapeStrokeSize,
                posY + shapeHalf - shapeStrokeSize);
        tri.close();

        c.drawPath(tri, renderPaint);
        tri.reset();
    }

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

示例12: getRequiredBaseOffset

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
@Override
protected float getRequiredBaseOffset() {
    return mXAxis.isEnabled() && mXAxis.isDrawLabelsEnabled() ?
            mXAxis.mLabelRotatedWidth :
            Utils.convertDpToPixel(10f);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:RadarChart.java

示例13: calculateOffsets

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
@Override
public void calculateOffsets() {

    float offsetLeft = 0f, offsetRight = 0f, offsetTop = 0f, offsetBottom = 0f;

    calculateLegendOffsets(mOffsetsBuffer);

    offsetLeft += mOffsetsBuffer.left;
    offsetTop += mOffsetsBuffer.top;
    offsetRight += mOffsetsBuffer.right;
    offsetBottom += mOffsetsBuffer.bottom;

    // offsets for y-labels
    if (mAxisLeft.needsOffset()) {
        offsetTop += mAxisLeft.getRequiredHeightSpace(mAxisRendererLeft.getPaintAxisLabels());
    }

    if (mAxisRight.needsOffset()) {
        offsetBottom += mAxisRight.getRequiredHeightSpace(mAxisRendererRight.getPaintAxisLabels());
    }

    float xlabelwidth = mXAxis.mLabelRotatedWidth;

    if (mXAxis.isEnabled()) {

        // offsets for x-labels
        if (mXAxis.getPosition() == XAxisPosition.BOTTOM) {

            offsetLeft += xlabelwidth;

        } else if (mXAxis.getPosition() == XAxisPosition.TOP) {

            offsetRight += xlabelwidth;

        } else if (mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {

            offsetLeft += xlabelwidth;
            offsetRight += xlabelwidth;
        }
    }

    offsetTop += getExtraTopOffset();
    offsetRight += getExtraRightOffset();
    offsetBottom += getExtraBottomOffset();
    offsetLeft += getExtraLeftOffset();

    float minOffset = Utils.convertDpToPixel(mMinOffset);

    mViewPortHandler.restrainViewPort(
            Math.max(minOffset, offsetLeft),
            Math.max(minOffset, offsetTop),
            Math.max(minOffset, offsetRight),
            Math.max(minOffset, offsetBottom));

    if (mLogEnabled) {
        Log.i(LOG_TAG, "offsetLeft: " + offsetLeft + ", offsetTop: " + offsetTop + ", offsetRight: " +
                offsetRight + ", offsetBottom: "
                + offsetBottom);
        Log.i(LOG_TAG, "Content: " + mViewPortHandler.getContentRect().toString());
    }

    prepareOffsetMatrix();
    prepareValuePxMatrix();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:65,代码来源:HorizontalBarChart.java

示例14: drawForm

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
/**
 * Draws the Legend-form at the given position with the color at the given
 * index.
 *
 * @param c      canvas to draw with
 * @param x      position
 * @param y      position
 * @param entry  the entry to render
 * @param legend the legend context
 */
protected void drawForm(
        Canvas c,
        float x, float y,
        LegendEntry entry,
        Legend legend) {

    if (entry.formColor == ColorTemplate.COLOR_SKIP ||
            entry.formColor == ColorTemplate.COLOR_NONE ||
            entry.formColor == 0)
        return;

    int restoreCount = c.save();

    Legend.LegendForm form = entry.form;
    if (form == Legend.LegendForm.DEFAULT)
        form = legend.getForm();

    mLegendFormPaint.setColor(entry.formColor);

    final float formSize = Utils.convertDpToPixel(
            Float.isNaN(entry.formSize)
                    ? legend.getFormSize()
                    : entry.formSize);
    final float half = formSize / 2f;

    switch (form) {
        case NONE:
            // Do nothing
            break;

        case EMPTY:
            // Do not draw, but keep space for the form
            break;

        case DEFAULT:
        case CIRCLE:
            mLegendFormPaint.setStyle(Paint.Style.FILL);
            c.drawCircle(x + half, y, half, mLegendFormPaint);
            break;

        case SQUARE:
            mLegendFormPaint.setStyle(Paint.Style.FILL);
            c.drawRect(x, y - half, x + formSize, y + half, mLegendFormPaint);
            break;

        case LINE:
        {
            final float formLineWidth = Utils.convertDpToPixel(
                    Float.isNaN(entry.formLineWidth)
                            ? legend.getFormLineWidth()
                            : entry.formLineWidth);
            final DashPathEffect formLineDashEffect = entry.formLineDashEffect == null
                    ? legend.getFormLineDashEffect()
                    : entry.formLineDashEffect;
            mLegendFormPaint.setStyle(Paint.Style.STROKE);
            mLegendFormPaint.setStrokeWidth(formLineWidth);
            mLegendFormPaint.setPathEffect(formLineDashEffect);

            mLineFormPath.reset();
            mLineFormPath.moveTo(x, y);
            mLineFormPath.lineTo(x + formSize, y);
            c.drawPath(mLineFormPath, mLegendFormPaint);
        }
            break;
    }

    c.restoreToCount(restoreCount);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:79,代码来源:LegendRenderer.java

示例15: setExtraLeftOffset

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
/**
 * Set an extra offset to be appended to the viewport's left
 */
public void setExtraLeftOffset(float offset) {
    mExtraLeftOffset = Utils.convertDpToPixel(offset);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:Chart.java


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