我使用GraphView库构建图形(.txt文件中有许多用于ECG模型构建的数字)。我有下一个问题。我需要在图形中突出显示该区域。例如,如果Y> 500,则我们突出显示该区域,但不小于500。这是我的代码。我会很高兴为您提供任何帮助。
P.S。对不起,这个巨大的代码
try {
DataInputStream text = new DataInputStream(getAssets().open(String.format("Ekg1.txt")));
Scanner scan = new Scanner(text);
String line;
int all = 0;
while (scan.hasNextLine()) {
int[] arr = new int[12];
all++;
line = scan.nextLine();
if (!(line.length() == 0 || (line.charAt(0) == ';'))) { // если строка пустая или первое значение ;
line = scan.nextLine().replaceAll(",", "").replaceAll(";", "");
for (int i = 0; i < 12; i++) {
arr[i] = Integer.parseInt(line.split(" ")[i].trim());
}
list.add(arr);
count++; //определяем сколько символов в list[i]
}
if (count >= 1000) { // сдесь ставим значение до которого надо кастрировать файл
break;
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
int[] col1 = new int[count];
int[] col2 = new int[count];
int[] col3 = new int[count];
int[] col4 = new int[count];
int[] col5 = new int[count];
int[] col6 = new int[count];
int[] col7 = new int[count];
int[] col8 = new int[count];
int[] col9 = new int[count];
int[] col10 = new int[count];
int[] col11 = new int[count];
int[] col12 = new int[count];
for (int i = 0; i < list.size(); i++) {
col1[i] = list.get(i)[0];
col2[i] = list.get(i)[1];
col3[i] = list.get(i)[2];
col4[i] = list.get(i)[3];
col5[i] = list.get(i)[4];
col6[i] = list.get(i)[5];
col7[i] = list.get(i)[6];
col8[i] = list.get(i)[7];
col9[i] = list.get(i)[8];
col10[i] = list.get(i)[9];
col11[i] = list.get(i)[10];
col12[i] = list.get(i)[11];
}
double x;
int y;
x = 0;
GraphView graph = (GraphView) findViewById(R.id.graph);
series = new LineGraphSeries<DataPoint>();
for (int i = 0; i < count; i++) {
x = x + 0.001;
y = col1[i];
series.appendData(new DataPoint(x, y), true, 40000);
}
for (int i = 0; i < count; i++) {
x = x + 0.001;
y = col2[i];
series.appendData(new DataPoint(x, y), true, 40000);
}
for (int i = 0; i < count; i++) {
x = x + 0.001;
y = col3[i];
series.appendData(new DataPoint(x, y), true, 40000);
}
for (int i = 0; i < count; i++) {
x = x + 0.001;
y = col4[i];
series.appendData(new DataPoint(x, y), true, 40000);
}
for (int i = 0; i < count; i++) {
x = x + 0.001;
y = col4[i];
series.appendData(new DataPoint(x, y), true, 40000);
}
for (int i = 0; i < count; i++) {
x = x + 0.001;
y = col5[i];
series.appendData(new DataPoint(x, y), true, 40000);
}
for (int i = 0; i < count; i++) {
x = x + 0.001;
y = col6[i];
series.appendData(new DataPoint(x, y), true, 40000);
}
for (int i = 0; i < count; i++) {
x = x + 0.001;
y = col7[i];
series.appendData(new DataPoint(x, y), true, 40000);
}
for (int i = 0; i < count; i++) {
x = x + 0.001;
y = col8[i];
series.appendData(new DataPoint(x, y), true, 40000);
}
for (int i = 0; i < count; i++) {
x = x + 0.001;
y = col9[i];
series.appendData(new DataPoint(x, y), true, 40000);
}
for (int i = 0; i < count; i++) {
x = x + 0.001;
y = col10[i];
series.appendData(new DataPoint(x, y), true, 40000);
}
for (int i = 0; i < count; i++) {
x = x + 0.001;
y = col11[i];
series.appendData(new DataPoint(x, y), true, 40000);
}
for (int i = 0; i < count; i++) {
x = x + 0.001;
y = col12[i];
series.appendData(new DataPoint(x, y), true, 40000);
}
graph.addSeries(series);