Class Metric

java.lang.Object
com.castlabs.sdk.debug.metric.Metric
Direct Known Subclasses:
BandwidthMetric, BufferAheadMetric, BufferBehindMetric, ChunkDownloadTimeMetric, PlayingQualityMetric, RateLimitMetric, SelectedQualityMetric

public abstract class Metric extends Object
Abstract class that provides the required underlying infrastructure to interact with the PlayerMetricChart and provide the necessary data to it.

You can create additional Metrics by extending this class. In addition to the abstract methods, you have access to the following:

  • addTimedDataPoint(float): Main data input. Use this method to add a data point to this metric.
  • dataSet: You can use this protected property to modify the underlying dataSet, right after calling the super constructor
  • Configuration overridable methods, replicateLastValue(), keepLastDroppedValue() and extendToRightEdge().
Since:
4.2.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Represents an object that can plot a metric.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Metric(int color, com.github.mikephil.charting.components.YAxis.AxisDependency axisDependency)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    attach(Metric.Plotter plotter, PlayerController playerController)
    Attach this Metric to the given plotter and PlayerController.
    void
    Unbind this Metric from the previously set PlayerController and Plotter.
    com.github.mikephil.charting.data.LineDataSet
    Updates and returns the Data set ready to be drawn.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Metric

      public Metric(int color, com.github.mikephil.charting.components.YAxis.AxisDependency axisDependency)
      Parameters:
      color - color that this Metric should be drawn in
      axisDependency - to which vertical axis bind the data from this Metric
  • Method Details

    • getDataSet

      public com.github.mikephil.charting.data.LineDataSet getDataSet()
      Updates and returns the Data set ready to be drawn. Some other operations may happen here depending on the configuration of this Metric.
      Returns:
      the LineDataSet ready to be drawn onto the graph.
    • attach

      public void attach(@NonNull Metric.Plotter plotter, PlayerController playerController)
      Attach this Metric to the given plotter and PlayerController.
      Parameters:
      plotter - plotter that will handle drawing of this Metric
      playerController - PlayerController from where to extract the metric data
    • detach

      public void detach()
      Unbind this Metric from the previously set PlayerController and Plotter.