Java Code Examples for com.github.mikephil.charting.utils.FSize

The following examples show how to use com.github.mikephil.charting.utils.FSize. These examples are extracted from open source projects. 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
@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);
}
 
Example 2
Source Project: StockChart-MPAndroidChart   Source File: XAxisRenderer.java    License: MIT License 6 votes vote down vote up
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);
    }
 
Example 3
Source Project: Ticket-Analysis   Source File: XAxisRendererHorizontalBarChart.java    License: MIT License 6 votes vote down vote up
@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);
}
 
Example 4
Source Project: Ticket-Analysis   Source File: XAxisRenderer.java    License: MIT License 6 votes vote down vote up
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);
    }
 
Example 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);
}
 
Example 6
Source Project: android-kline   Source File: XAxisRenderer.java    License: Apache License 2.0 6 votes vote down vote up
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);
    }
 
Example 7
Source Project: Stayfit   Source File: XAxisRendererHorizontalBarChart.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 8
Source Project: NetKnight   Source File: XAxisRendererHorizontalBarChart.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 9
Source Project: Stayfit   Source File: XAxisRenderer.java    License: Apache License 2.0 5 votes vote down vote up
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);
    }
 
Example 10
Source Project: NetKnight   Source File: XAxisRenderer.java    License: Apache License 2.0 5 votes vote down vote up
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);
    }
 
Example 11
Source Project: fingen   Source File: ChartUtils.java    License: Apache License 2.0 4 votes vote down vote up
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);
}
 
Example 12
Source Project: StockChart-MPAndroidChart   Source File: MarkerImage.java    License: MIT License 4 votes vote down vote up
public FSize getSize() {
    return mSize;
}
 
Example 13
Source Project: StockChart-MPAndroidChart   Source File: Legend.java    License: MIT License 4 votes vote down vote up
public List<FSize> getCalculatedLabelSizes() {
    return mCalculatedLabelSizes;
}
 
Example 14
Source Project: StockChart-MPAndroidChart   Source File: Legend.java    License: MIT License 4 votes vote down vote up
public List<FSize> getCalculatedLineSizes() {
    return mCalculatedLineSizes;
}
 
Example 15
Source Project: Ticket-Analysis   Source File: MarkerImage.java    License: MIT License 4 votes vote down vote up
public FSize getSize() {
    return mSize;
}
 
Example 16
Source Project: Ticket-Analysis   Source File: Legend.java    License: MIT License 4 votes vote down vote up
public List<FSize> getCalculatedLabelSizes() {
    return mCalculatedLabelSizes;
}
 
Example 17
Source Project: Ticket-Analysis   Source File: Legend.java    License: MIT License 4 votes vote down vote up
public List<FSize> getCalculatedLineSizes() {
    return mCalculatedLineSizes;
}
 
Example 18
Source Project: android-kline   Source File: MarkerImage.java    License: Apache License 2.0 4 votes vote down vote up
public FSize getSize() {
    return mSize;
}
 
Example 19
Source Project: android-kline   Source File: Legend.java    License: Apache License 2.0 4 votes vote down vote up
public List<FSize> getCalculatedLabelSizes() {
    return mCalculatedLabelSizes;
}
 
Example 20
Source Project: android-kline   Source File: Legend.java    License: Apache License 2.0 4 votes vote down vote up
public List<FSize> getCalculatedLineSizes() {
    return mCalculatedLineSizes;
}
 
Example 21
Source Project: iMoney   Source File: Legend.java    License: Apache License 2.0 4 votes vote down vote up
public FSize[] getCalculatedLabelSizes() {
    return mCalculatedLabelSizes;
}
 
Example 22
Source Project: iMoney   Source File: Legend.java    License: Apache License 2.0 4 votes vote down vote up
public FSize[] getCalculatedLineSizes() {
    return mCalculatedLineSizes;
}
 
Example 23
Source Project: Stayfit   Source File: Legend.java    License: Apache License 2.0 4 votes vote down vote up
public FSize[] getCalculatedLabelSizes() {
    return mCalculatedLabelSizes;
}
 
Example 24
Source Project: Stayfit   Source File: Legend.java    License: Apache License 2.0 4 votes vote down vote up
public FSize[] getCalculatedLineSizes() {
    return mCalculatedLineSizes;
}
 
Example 25
Source Project: NetKnight   Source File: Legend.java    License: Apache License 2.0 4 votes vote down vote up
public FSize[] getCalculatedLabelSizes() {
    return mCalculatedLabelSizes;
}
 
Example 26
Source Project: NetKnight   Source File: Legend.java    License: Apache License 2.0 4 votes vote down vote up
public FSize[] getCalculatedLineSizes() {
    return mCalculatedLineSizes;
}