Java源码示例:com.github.mikephil.charting.utils.FSize

示例1
@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);
}
 
示例2
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);
    }
 
示例3
@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);
}
 
示例4
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);
    }
 
示例5
@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);
}
 
示例6
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);
    }
 
示例7
@Override
public void computeAxis(float xValAverageLength, List<String> xValues) {
    
    mAxisLabelPaint.setTypeface(mXAxis.getTypeface());
    mAxisLabelPaint.setTextSize(mXAxis.getTextSize());
    mXAxis.setValues(xValues);

    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);
}
 
示例8
@Override
public void computeAxis(float xValAverageLength, List<String> xValues) {
    
    mAxisLabelPaint.setTypeface(mXAxis.getTypeface());
    mAxisLabelPaint.setTextSize(mXAxis.getTextSize());
    mXAxis.setValues(xValues);

    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);
}
 
示例9
public void computeAxis(float xValMaximumLength, List<String> xValues) {

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

        StringBuilder widthText = new StringBuilder();

        int xValChars = Math.round(xValMaximumLength);

        for (int i = 0; i < xValChars; i++) {
            widthText.append('h');
        }

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

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

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

        StringBuilder space = new StringBuilder();
        int xValSpaceChars = mXAxis.getSpaceBetweenLabels();

        for (int i = 0; i < xValSpaceChars; i++) {
            space.append('h');
        }

        final FSize spaceSize = Utils.calcTextSize(mAxisLabelPaint, space.toString());

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

        mXAxis.setValues(xValues);
    }
 
示例10
public void computeAxis(float xValMaximumLength, List<String> xValues) {

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

        StringBuilder widthText = new StringBuilder();

        int xValChars = Math.round(xValMaximumLength);

        for (int i = 0; i < xValChars; i++) {
            widthText.append('h');
        }

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

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

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

        StringBuilder space = new StringBuilder();
        int xValSpaceChars = mXAxis.getSpaceBetweenLabels();

        for (int i = 0; i < xValSpaceChars; i++) {
            space.append('h');
        }

        final FSize spaceSize = Utils.calcTextSize(mAxisLabelPaint, space.toString());

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

        mXAxis.setValues(xValues);
    }
 
示例11
public static void drawXAxisValue(Canvas c, String text, float x, float y,
                                  Paint paint,
                                  PointF anchor, float angleDegrees,
                                  int color) {

    float drawOffsetX = 0.f;
    float drawOffsetY = 0.f;

    final float lineHeight = paint.getFontMetrics(mFontMetricsBuffer);
    paint.getTextBounds(text, 0, text.length(), mDrawTextRectBuffer);

    // Android sometimes has pre-padding
    drawOffsetX -= mDrawTextRectBuffer.left;

    // Android does not snap the bounds to line boundaries,
    //  and draws from bottom to top.
    // And we want to normalize it.
    drawOffsetY += -mFontMetricsBuffer.ascent;

    // To have a consistent point of reference, we always draw left-aligned
    Paint.Align originalTextAlign = paint.getTextAlign();
    paint.setTextAlign(Paint.Align.LEFT);

    Paint.Style oldStyle = paint.getStyle();
    paint.setStyle(Paint.Style.STROKE);
    float oldStroleWidth = paint.getStrokeWidth();
    paint.setStrokeWidth(ScreenUtils.dpToPx(3f, FGApplication.getContext()));
    int oldColor = paint.getColor();
    paint.setColor(color);

    if (angleDegrees != 0.f) {

        // Move the text drawing rect in a way that it always rotates around its center
        drawOffsetX -= mDrawTextRectBuffer.width() * 0.5f;
        drawOffsetY -= lineHeight * 0.5f;

        float translateX = x;
        float translateY = y;

        // Move the "outer" rect relative to the anchor, assuming its centered
        if (anchor.x != 0.5f || anchor.y != 0.5f) {
            final FSize rotatedSize = getSizeOfRotatedRectangleByDegrees(
                    mDrawTextRectBuffer.width(),
                    lineHeight,
                    angleDegrees);

            translateX -= rotatedSize.width * (anchor.x - 0.5f);
            translateY -= rotatedSize.height * (anchor.y - 0.5f);
        }

        c.save();
        c.translate(translateX, translateY);
        c.rotate(angleDegrees);

        c.drawText(text, drawOffsetX, drawOffsetY, paint);

        c.restore();
    } else {
        if (anchor.x != 0.f || anchor.y != 0.f) {

            drawOffsetX -= mDrawTextRectBuffer.width() * anchor.x;
            drawOffsetY -= lineHeight * anchor.y;
        }

        drawOffsetX += x;
        drawOffsetY += y;

        c.drawText(text, drawOffsetX, drawOffsetY, paint);
    }

    paint.setTextAlign(originalTextAlign);

    paint.setStyle(oldStyle);
    paint.setStrokeWidth(oldStroleWidth);
    paint.setColor(oldColor);
}
 
示例12
public FSize getSize() {
    return mSize;
}
 
示例13
public List<FSize> getCalculatedLabelSizes() {
    return mCalculatedLabelSizes;
}
 
示例14
public List<FSize> getCalculatedLineSizes() {
    return mCalculatedLineSizes;
}
 
示例15
public FSize getSize() {
    return mSize;
}
 
示例16
public List<FSize> getCalculatedLabelSizes() {
    return mCalculatedLabelSizes;
}
 
示例17
public List<FSize> getCalculatedLineSizes() {
    return mCalculatedLineSizes;
}
 
示例18
public FSize getSize() {
    return mSize;
}
 
示例19
public List<FSize> getCalculatedLabelSizes() {
    return mCalculatedLabelSizes;
}
 
示例20
public List<FSize> getCalculatedLineSizes() {
    return mCalculatedLineSizes;
}
 
示例21
public FSize[] getCalculatedLabelSizes() {
    return mCalculatedLabelSizes;
}
 
示例22
public FSize[] getCalculatedLineSizes() {
    return mCalculatedLineSizes;
}
 
示例23
public FSize[] getCalculatedLabelSizes() {
    return mCalculatedLabelSizes;
}
 
示例24
public FSize[] getCalculatedLineSizes() {
    return mCalculatedLineSizes;
}
 
示例25
public FSize[] getCalculatedLabelSizes() {
    return mCalculatedLabelSizes;
}
 
示例26
public FSize[] getCalculatedLineSizes() {
    return mCalculatedLineSizes;
}