com.github.mikephil.charting.utils.Utils.calcTextSize()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(11.4k)|赞(0)|评价(0)|浏览(179)

本文整理了Java中com.github.mikephil.charting.utils.Utils.calcTextSize()方法的一些代码示例,展示了Utils.calcTextSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.calcTextSize()方法的具体详情如下:
包路径:com.github.mikephil.charting.utils.Utils
类名称:Utils
方法名:calcTextSize

Utils.calcTextSize介绍

[英]Returns a recyclable FSize instance. calculates the approximate size of a text, depending on a demo text avoid repeated calls (e.g. inside drawing methods)
[中]返回一个可回收的FSize实例。根据演示文本计算文本的大致大小,避免重复调用(例如内部绘图方法)

代码示例

代码示例来源:origin: PhilJay/MPAndroidChart

/**
 * Returns a recyclable FSize instance.
 * calculates the approximate size of a text, depending on a demo text
 * avoid repeated calls (e.g. inside drawing methods)
 *
 * @param paint
 * @param demoText
 * @return A Recyclable FSize instance
 */
public static FSize calcTextSize(Paint paint, String demoText) {
  FSize result = FSize.getInstance(0,0);
  calcTextSize(paint, demoText, result);
  return result;
}

代码示例来源:origin: PhilJay/MPAndroidChart

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);
}

代码示例来源:origin: PhilJay/MPAndroidChart

@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);
}

代码示例来源:origin: PhilJay/MPAndroidChart

mCalculatedLabelSizes.add(Utils.calcTextSize(labelpaint, label));
requiredWidth += drawingForm ? formToTextSpace + formSize : 0.f;
requiredWidth += mCalculatedLabelSizes.get(i).width;

代码示例来源:origin: xiaolongonly/Ticket-Analysis

/**
 * Returns a recyclable FSize instance.
 * calculates the approximate size of a text, depending on a demo text
 * avoid repeated calls (e.g. inside drawing methods)
 *
 * @param paint
 * @param demoText
 * @return A Recyclable FSize instance
 */
public static FSize calcTextSize(Paint paint, String demoText) {
  FSize result = FSize.getInstance(0,0);
  calcTextSize(paint, demoText, result);
  return result;
}

代码示例来源:origin: WenWangAndroid/ChartManager

/**
 * Returns a recyclable FSize instance.
 * calculates the approximate size of a text, depending on a demo text
 * avoid repeated calls (e.g. inside drawing methods)
 *
 * @param paint
 * @param demoText
 * @return A Recyclable FSize instance
 */
public static FSize calcTextSize(Paint paint, String demoText) {
  FSize result = FSize.getInstance(0,0);
  calcTextSize(paint, demoText, result);
  return result;
}

代码示例来源:origin: com.github.PhilJay/MPAndroidChart

/**
 * Returns a recyclable FSize instance.
 * calculates the approximate size of a text, depending on a demo text
 * avoid repeated calls (e.g. inside drawing methods)
 *
 * @param paint
 * @param demoText
 * @return A Recyclable FSize instance
 */
public static FSize calcTextSize(Paint paint, String demoText) {
  FSize result = FSize.getInstance(0,0);
  calcTextSize(paint, demoText, result);
  return result;
}

代码示例来源:origin: WallaceXiao/StockChart-MPAndroidChart

/**
 * Returns a recyclable FSize instance.
 * calculates the approximate size of a text, depending on a demo text
 * avoid repeated calls (e.g. inside drawing methods)
 *
 * @param paint
 * @param demoText
 * @return A Recyclable FSize instance
 */
public static FSize calcTextSize(Paint paint, String demoText) {
  FSize result = FSize.getInstance(0, 0);
  calcTextSize(paint, demoText, result);
  return result;
}

代码示例来源:origin: xiaolongonly/Ticket-Analysis

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);
}

代码示例来源:origin: WenWangAndroid/ChartManager

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);
}

代码示例来源:origin: WallaceXiao/StockChart-MPAndroidChart

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);
}

代码示例来源:origin: com.github.PhilJay/MPAndroidChart

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);
}

代码示例来源:origin: WenWangAndroid/ChartManager

@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);
}

代码示例来源:origin: WallaceXiao/StockChart-MPAndroidChart

@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);
}

代码示例来源:origin: xiaolongonly/Ticket-Analysis

@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);
}

代码示例来源:origin: com.github.PhilJay/MPAndroidChart

@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);
}

代码示例来源:origin: xiaolongonly/Ticket-Analysis

mCalculatedLabelSizes.add(Utils.calcTextSize(labelpaint, label));
requiredWidth += drawingForm ? formToTextSpace + formSize : 0.f;
requiredWidth += mCalculatedLabelSizes.get(i).width;

代码示例来源:origin: com.github.PhilJay/MPAndroidChart

mCalculatedLabelSizes.add(Utils.calcTextSize(labelpaint, label));
requiredWidth += drawingForm ? formToTextSpace + formSize : 0.f;
requiredWidth += mCalculatedLabelSizes.get(i).width;

代码示例来源:origin: WallaceXiao/StockChart-MPAndroidChart

mCalculatedLabelSizes.add(Utils.calcTextSize(labelpaint, label));
requiredWidth += drawingForm ? formToTextSpace + formSize : 0.f;
requiredWidth += mCalculatedLabelSizes.get(i).width;

代码示例来源:origin: WenWangAndroid/ChartManager

mCalculatedLabelSizes.add(Utils.calcTextSize(labelpaint, label));
requiredWidth += drawingForm ? formToTextSpace + formSize : 0.f;
requiredWidth += mCalculatedLabelSizes.get(i).width;

相关文章