Skip to content

Commit b8d2c02

Browse files
GTO2013dschultzca
authored andcommitted
Use closest cell for highlight
1 parent 6c57ee1 commit b8d2c02

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/main/java/com/romraider/maps/Table1DView.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* RomRaider Open-Source Tuning, Logging and Reflashing
3-
* Copyright (C) 2006-2021 RomRaider.com
3+
* Copyright (C) 2006-2025 RomRaider.com
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -279,6 +279,7 @@ public void highlightLiveData(String liveVal) {
279279
}
280280

281281
int startIdx = data.length;
282+
double currentErrorToLiveValue = Double.POSITIVE_INFINITY;
282283
for (int i = 0; i < data.length; i++) {
283284
double currentValue = 0.0;
284285
if(table.isStaticDataTable() && null != data[i].getStaticText()) {
@@ -290,14 +291,14 @@ public void highlightLiveData(String liveVal) {
290291
} else {
291292
currentValue = data[i].getDataCell().getRealValue();
292293
}
293-
294-
if (liveValue == currentValue) {
295-
startIdx = i;
296-
break;
297-
} else if (liveValue < currentValue){
298-
startIdx = i-1;
299-
break;
300-
}
294+
295+
if(Math.abs(currentValue - liveValue) < currentErrorToLiveValue)
296+
{
297+
currentErrorToLiveValue = Math.abs(currentValue - liveValue);
298+
startIdx = i;
299+
300+
if(currentErrorToLiveValue <= 0.001) break;
301+
}
301302
}
302303

303304
setLiveDataIndex(startIdx);

0 commit comments

Comments
 (0)