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


Java CustomLabelFormatter类代码示例

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


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

示例1: setProperties

import com.jjoe64.graphview.CustomLabelFormatter; //导入依赖的package包/类
private void setProperties() {
    GraphViewStyle gStyle =  getGraphViewStyle();
    gStyle.setHorizontalLabelsIndexDependentColor(new HorizontalLabelsColor());
    gStyle.setHorizontalLabelsColor(getResources().getColor(R.color.grey_darken_30));
    gStyle.setVerticalLabelsColor(getResources().getColor(R.color.grey_darken_10));
    gStyle.setTextSize(getResources().getDimensionPixelSize(R.dimen.text_sz_extra_small));
    gStyle.setGridXColor(Color.TRANSPARENT);
    gStyle.setGridYColor(getResources().getColor(R.color.grey_lighten_30));
    gStyle.setNumVerticalLabels(3);

    setCustomLabelFormatter(new CustomLabelFormatter() {
        private NumberFormat numberFormatter;
        @Override
        public String formatLabel(double value, boolean isValueX) {
            if (isValueX) {
                return null;
            }
            if (numberFormatter == null) {
                numberFormatter = NumberFormat.getNumberInstance();
                numberFormatter.setMaximumFractionDigits(0);
            }
            return numberFormatter.format(value);
        }
    });
}
 
开发者ID:ldsddn,项目名称:wordpress_app_android,代码行数:26,代码来源:StatsBarGraph.java

示例2: SensorAdapter

import com.jjoe64.graphview.CustomLabelFormatter; //导入依赖的package包/类
public SensorAdapter(final Context context, final View view) {
    mContext = context.getApplicationContext();
    mLoadingView = view;

    final Resources res = context.getResources();
    final int bgColor = ContextCompat.getColor(mContext, R.color.primary_graph);

    mGraph = new LineGraphView(context, "");
    mGraph.setDrawBackground(true);
    mGraph.setBackgroundColor(bgColor);
    mGraph.setCustomLabelFormatter(new CustomLabelFormatter() {
        @Override
        public String formatLabel(final double value, final boolean isValueX) {
            if (isValueX) {
                return DateUtils.formatDateTime(mContext,
                        (long) value, AppConstants.DATE_FORMAT_FLAGS_GRAPH);
            }
            return String.format(Locale.getDefault(), "%.1f", value);
        }
    });
    mGraph.getGraphViewStyle().setTextSize(res.getDimension(R.dimen.graph_text_size));
}
 
开发者ID:meisteg,项目名称:RaspberryPiTempAlarm,代码行数:23,代码来源:SensorAdapter.java

示例3: getLabelFormatter

import com.jjoe64.graphview.CustomLabelFormatter; //导入依赖的package包/类
public static CustomLabelFormatter getLabelFormatter(int days) {
    final String[] labels = getLabels(days);
    return new CustomLabelFormatter() {
        @Override
        public String formatLabel(double value, boolean isValueX) {
            if (isValueX && value < labels.length) {
                return labels[(int) value];
            } else if (!isValueX) {
                return COUNT_FORMAT.format(value);
            }
            return null; // let graphview generate Y-axis label for us
        }
    };
}
 
开发者ID:gotosleep,项目名称:ItchDroid,代码行数:15,代码来源:GraphHelper.java

示例4: drawGraph

import com.jjoe64.graphview.CustomLabelFormatter; //导入依赖的package包/类
private void drawGraph(final Journey journey) {
  final LineGraphView graph = new LineGraphView(getActivity(), "");

  List<GraphView.GraphViewData> data = new ArrayList<>();
  for (Elevation elevation : journey.elevation().profile())
    data.add(new GraphView.GraphViewData(elevation.distance(), elevation.elevation()));

  GraphViewSeries graphSeries = new GraphViewSeries(data.toArray(new GraphView.GraphViewData[]{}));

  graph.addSeries(graphSeries);
  graph.setDrawBackground(true);
  graph.getGraphViewStyle().setGridStyle(GraphViewStyle.GridStyle.HORIZONTAL);
  graph.getGraphViewStyle().setNumHorizontalLabels(5);
  graph.getGraphViewStyle().setNumVerticalLabels(4);

  final ElevationFormatter formatter = ElevationFormatter.formatter(CycleStreetsPreferences.units());
  graph.setCustomLabelFormatter(new CustomLabelFormatter() {
    @Override
    public String formatLabel(double value, boolean isValueX) {
      if (isValueX)
        return (value != 0) ? formatter.distance((int)value) : "";
      return formatter.height((int) value);
    }
  });

  graphHolder_.removeAllViews();
  graphHolder_.addView(graph);
}
 
开发者ID:MobileAppCodes,项目名称:CycleStreets-Android-app-,代码行数:29,代码来源:ElevationProfileFragment.java

示例5: createGraph

import com.jjoe64.graphview.CustomLabelFormatter; //导入依赖的package包/类
private GraphView createGraph(BenchmarkWrapper wrapper) {
    Resources res = getResources();
    int lineThicknessPx = (int) Math.ceil(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, res.getDisplayMetrics()));

    GraphView.GraphViewData[] data = new GraphView.GraphViewData[wrapper.getStatInfo().getBenchmarkData().size()];
    for (int j = 0; j < wrapper.getStatInfo().getBenchmarkData().size(); j++) {
        data[j] = new GraphView.GraphViewData(j, wrapper.getStatInfo().getBenchmarkData().get(j));
    }

    LineGraphView graphView = new LineGraphView(getActivity(), "");
    GraphViewSeries.GraphViewSeriesStyle seriesStyle = new GraphViewSeries.GraphViewSeriesStyle(res.getColor(R.color.graphBgGreen), lineThicknessPx);

    if (wrapper.getStatInfo().getAsAvg().getMin() <= IBlur.MS_THRESHOLD_FOR_SMOOTH) {
        graphView.addSeries(GraphUtil.getStraightLine(IBlur.MS_THRESHOLD_FOR_SMOOTH, wrapper.getStatInfo().getBenchmarkData().size() - 1, "16ms", new GraphViewSeries.GraphViewSeriesStyle(res.getColor(R.color.graphBgRed), lineThicknessPx)));
    }
    graphView.addSeries(GraphUtil.getStraightLine((int) wrapper.getStatInfo().getAsAvg().getAvg(), wrapper.getStatInfo().getBenchmarkData().size() - 1, "Avg", new GraphViewSeries.GraphViewSeriesStyle(res.getColor(R.color.graphBlue), lineThicknessPx)));
    graphView.addSeries(new GraphViewSeries("Blur", seriesStyle, data));
    graphView.setScrollable(true);
    graphView.setScalable(true);
    graphView.setManualYAxis(true);
    graphView.getGraphViewStyle().setGridColor(res.getColor(R.color.transparent));
    graphView.setCustomLabelFormatter(new CustomLabelFormatter() {
        @Override
        public String formatLabel(double value, boolean isValueX) {
            if (!isValueX) {
                return Math.round(value) + "ms";
            } else {
                return null;
            }
        }
    });
    graphView.setManualYAxisBounds(wrapper.getStatInfo().getAsAvg().getMax(), Math.max(0, wrapper.getStatInfo().getAsAvg().getMin() - 3l));
    graphView.setDrawBackground(false);
    graphView.setShowLegend(true);

    graphView.getGraphViewStyle().setHorizontalLabelsColor(res.getColor(R.color.transparent));
    graphView.getGraphViewStyle().setNumHorizontalLabels(0);
    graphView.getGraphViewStyle().setVerticalLabelsColor(res.getColor(R.color.optionsTextColorDark));
    graphView.getGraphViewStyle().setNumVerticalLabels(4);
    graphView.getGraphViewStyle().setVerticalLabelsAlign(Paint.Align.CENTER);
    graphView.getGraphViewStyle().setVerticalLabelsWidth((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, res.getDisplayMetrics()));
    graphView.getGraphViewStyle().setTextSize((int) Math.ceil(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, res.getDisplayMetrics())));

    return graphView;
}
 
开发者ID:patrickfav,项目名称:BlurTestAndroid,代码行数:46,代码来源:BenchmarkDetailsDialog.java


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