コード例 #1
0
 @NonNull
 private Axis xAxis() {
   Axis xAxis = new Axis();
   xAxis.setAutoGenerated(false);
   List<AxisValue> xAxisValues = new ArrayList<AxisValue>();
   GregorianCalendar now = new GregorianCalendar();
   GregorianCalendar today =
       new GregorianCalendar(
           now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH));
   final java.text.DateFormat timeFormat = hourFormat();
   timeFormat.setTimeZone(TimeZone.getDefault());
   double start_hour_block = today.getTime().getTime();
   double timeNow = new Date().getTime();
   for (int l = 0; l <= 24; l++) {
     if ((start_hour_block + (60000 * 60 * (l))) < timeNow) {
       if ((start_hour_block + (60000 * 60 * (l + 1))) >= timeNow) {
         endHour = start_hour_block + (60000 * 60 * (l));
         l = 25;
       }
     }
   }
   for (int l = 0; l <= 24; l++) {
     double timestamp = (endHour - (60000 * 60 * l));
     xAxisValues.add(
         new AxisValue((long) (timestamp / FUZZER), (timeFormat.format(timestamp)).toCharArray()));
   }
   xAxis.setValues(xAxisValues);
   xAxis.setHasLines(true);
   xAxis.setLineColor(Color.parseColor("#555555"));
   xAxis.setTextSize(axisTextSize);
   return xAxis;
 }
コード例 #2
0
  public Axis yAxis() {
    Axis yAxis = new Axis();
    yAxis.setAutoGenerated(false);
    List<AxisValue> axisValues = new ArrayList<AxisValue>();

    //        for(int j = 1; j <= 12; j += 1) {
    //            if (doMgdl) {
    //                axisValues.add(new AxisValue(j * 50));
    //            } else {
    //                axisValues.add(new AxisValue(j*2));
    //            }
    //        }
    axisValues.add(new AxisValue(240));
    axisValues.add(new AxisValue((int) this.lowMark));
    axisValues.add(new AxisValue((int) this.highMark));
    yAxis.setValues(axisValues);
    yAxis.setHasLines(true);
    yAxis.setLineColor(Color.parseColor("#555555"));
    yAxis.setMaxLabelChars(5);
    yAxis.setInside(true);
    yAxis.setTextSize(axisTextSize);
    yAxis.setTextColor(Color.parseColor("#8D8D8D"));
    yAxis.setHasTiltedLabels(true);

    return yAxis;
  }
コード例 #3
0
  private void updateChart(int total) {
    int numSubcolumns = 60;
    int numColumns = 1000;
    List<float[]> flist = new ArrayList<>();
    //        if (!Constants.Queue_DrawRealtimewaterfall.isEmpty()) {
    //            flist = Constants.Queue_DrawRealtimewaterfall.poll();
    if (!Constants.Queue_DrawRealtimeSpectrum.isEmpty()) {
      flist = Constants.Queue_DrawRealtimeSpectrum.poll();
      int realsize = Constants.Queue_DrawRealtimeSpectrum.size();
      if (realsize >= 5) Constants.Queue_DrawRealtimeSpectrum.clear();
      List<Column> columns = new ArrayList<Column>();
      List<SubcolumnValue> values;
      if (flist.size() != total) {
        // 没收到整段就返回
        return;
      }
      float[] ff1 = selectData(flist);
      if (Xvalues.size() > 0) {
        int size = Xvalues.size();
        for (int i = 0; i < size; i++) {
          values = new ArrayList<SubcolumnValue>();
          values = Xvalues.get(i);
          for (int j = numSubcolumns - 1; j > 0; j--) {
            values.set(j, values.get(j - 1));
          }
          // int color=ChartUtils.pickColor();
          int index = (int) ((ff1[i] + 150) / 8);
          int color = 0;
          if (index >= 20) {
            color = colors[19];
          } else if (index < 0) {
            color = colors[0];
          } else {
            color = colors[(int) ((ff1[i] + 150) / 8)];
          }
          values.set(0, new SubcolumnValue(1, color));

          Column column = new Column(values);
          columns.add(column);
        }
      }
      data = new ColumnChartData(columns);
      data.setStacked(true);
      data.setFillRatio(1);
      Axis axisX = new Axis(Lvalues);
      Axis axisY = Axis.generateAxisFromRange(0, 60, 2);
      axisY.setLineColor(Color.GREEN);
      axisX.setHasLines(false);
      axisX.setHasSeparationLine(false);
      axisY.setHasSeparationLine(false);
      axisY.setHasLines(false);

      axisX.setName("Axis X");
      axisY.setName("Axis Y");
      data.setAxisXBottom(axisX);
      data.setAxisYLeft(axisY);
      chart.setColumnChartData(data);
    }
  }
コード例 #4
0
 public Axis previewXAxis() {
   List<AxisValue> previewXaxisValues = new ArrayList<AxisValue>();
   final java.text.DateFormat timeFormat = hourFormat();
   timeFormat.setTimeZone(TimeZone.getDefault());
   for (int l = 0; l <= 24; l += hoursPreviewStep) {
     double timestamp = (endHour - (60000 * 60 * l));
     previewXaxisValues.add(
         new AxisValue((long) (timestamp / FUZZER), (timeFormat.format(timestamp)).toCharArray()));
   }
   Axis previewXaxis = new Axis();
   previewXaxis.setValues(previewXaxisValues);
   previewXaxis.setHasLines(true);
   previewXaxis.setTextSize(previewAxisTextSize);
   previewXaxis.setLineColor(Color.parseColor("#555555"));
   previewXaxis.setTextSize(axisTextSize);
   return previewXaxis;
 }
コード例 #5
0
  /** Generates columns with stacked subcolumns. */
  private void generateStackedData(int start, int end) {
    int numSubcolumns = 60;
    int numColumns = 1000;
    List<Column> columns = new ArrayList<Column>();
    List<SubcolumnValue> values;
    Lvalues = new ArrayList<>();
    Xvalues = new ArrayList<List<SubcolumnValue>>();
    for (int i = 0; i < numColumns; ++i) {
      values = new ArrayList<SubcolumnValue>();
      if (i == 0) {
        Lvalues.add(new AxisValue(i).setLabel(String.valueOf(start)));
      } else if (i == numColumns - 30) {
        Lvalues.add(new AxisValue(i).setLabel(String.valueOf(end)));
      }
      for (int j = 1; j <= numSubcolumns; ++j) {
        values.add(new SubcolumnValue(1, Color.WHITE));
      }

      Column column = new Column(values);
      column.setHasLabelsOnlyForSelected(hasLabelForSelected);
      columns.add(column);

      Xvalues.add(values);
    }
    data = new ColumnChartData(columns);

    data.setStacked(true);
    data.setFillRatio(1);

    Axis axisX = new Axis(Lvalues);
    axisX.setHasSeparationLine(false);
    axisX.setHasLines(false);
    Axis axisY = Axis.generateAxisFromRange(0, 60, 1);
    axisY.setHasSeparationLine(false);
    axisY.setHasLines(false);
    axisY.setLineColor(Color.GREEN);

    axisX.setName("Axis X");
    axisY.setName("Axis Y");
    data.setAxisXBottom(axisX);
    data.setAxisYLeft(axisY);
    chart.setColumnChartData(data);
  }