Skip to content

Commit 2adb538

Browse files
committed
Change scale values to show most recent rather than average
1 parent 2ba36af commit 2adb538

File tree

3 files changed

+33
-35
lines changed

3 files changed

+33
-35
lines changed

uis/src/com/biglybt/ui/swt/components/graphics/MultiPlotGraphic.java

+16-26
Original file line numberDiff line numberDiff line change
@@ -940,29 +940,36 @@ public void handleEvent(Event e) {
940940

941941
if ( show_label ){
942942

943-
int average_val = computeAverage( chartIdx, currentPosition - 6 );
943+
int position = currentPosition-1;
944+
945+
if ( position < 0 ){
944946

945-
int average_mod = average_val;
947+
position += maxEntries;
948+
}
949+
950+
int last_val = all_values[chartIdx][ position ];
946951

947-
if ( average_mod > max ){
952+
int last_mod = last_val;
948953

949-
average_mod = max;
954+
if ( last_mod > max ){
955+
956+
last_mod = max;
950957
}
951958

952-
int height = bounds.height - scale.getScaledValue( average_mod) - 2;
959+
int height = bounds.height - scale.getScaledValue( last_mod) - 2;
953960

954961
gcImage.setAlpha( 255 );
955962

956963
gcImage.setForeground( source.getLineColor());
957964

958-
gcImage.drawText(formater.format( average_val ), bounds.width - 65, height - 12, SWT.DRAW_TRANSPARENT);
965+
gcImage.drawText(formater.format( last_mod ), bounds.width - 65, height - 12, SWT.DRAW_TRANSPARENT);
959966

960967
Color bg = gcImage.getBackground();
961968

962969
if (( style & ValueSource.STYLE_DOWN ) != 0 ){
963970

964971
int x = bounds.width - 72;
965-
int y = height - 12;
972+
int y = height-3;
966973

967974
gcImage.setBackground( source.getLineColor());
968975

@@ -973,7 +980,7 @@ public void handleEvent(Event e) {
973980
}else if (( style & ValueSource.STYLE_UP ) != 0 ){
974981

975982
int x = bounds.width - 72;
976-
int y = height - 12;
983+
int y = height - 3;
977984

978985
gcImage.setBackground( source.getLineColor());
979986

@@ -984,7 +991,7 @@ public void handleEvent(Event e) {
984991
}else if (( style & ValueSource.STYLE_BLOB ) != 0 ){
985992

986993
int x = bounds.width - 72;
987-
int y = height - 12;
994+
int y = height - 3;
988995

989996
gcImage.setBackground( source.getLineColor());
990997

@@ -1012,23 +1019,6 @@ public void handleEvent(Event e) {
10121019
}
10131020
}
10141021

1015-
private int
1016-
computeAverage(
1017-
int line_index,
1018-
int position )
1019-
{
1020-
long sum = 0;
1021-
for(int i = -5 ; i < 6 ; i++) {
1022-
int pos = position + i;
1023-
pos %= maxEntries;
1024-
if (pos < 0)
1025-
pos += maxEntries;
1026-
sum += all_values[line_index][pos];
1027-
}
1028-
return(int)(sum / 11);
1029-
1030-
}
1031-
10321022
@Override
10331023
public void
10341024
parameterChanged(

uis/src/com/biglybt/ui/swt/components/graphics/PingGraphic.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ protected void drawChart(boolean sizeChanged) {
290290

291291
scale.setMax(max);
292292

293+
int lastAverage = -1;
293294
for(int x = 0 ; x < bounds.width - 71 ; x++) {
294295
int position = currentPosition - x -1;
295296
if(position < 0)
@@ -302,8 +303,8 @@ protected void drawChart(boolean sizeChanged) {
302303
int oldTargetValue = oldTargetValues[z];
303304

304305
if ( x > 1 ){
305-
int h1 = bounds.height - scale.getScaledValue(targetValue) - 2;
306-
int h2 = bounds.height - scale.getScaledValue(oldTargetValue) - 2;
306+
int h1 = bounds.height - scale.getScaledValue(targetValue) - 2;
307+
int h2 = bounds.height - scale.getScaledValue(oldTargetValue) - 2;
307308
gcImage.setForeground( externalAverage?colors[z]: (z <= 2 ? colors[z+1] : colors[3]));
308309
gcImage.drawLine(xDraw,h1,xDraw+1, h2);
309310
}
@@ -318,14 +319,17 @@ protected void drawChart(boolean sizeChanged) {
318319
gcImage.setForeground(colors[COLOR_AVERAGE]);
319320
gcImage.setLineWidth(2);
320321
gcImage.drawLine(xDraw,h1,xDraw+1, h2);
322+
if ( lastAverage == -1 ){
323+
lastAverage = oldAverage;
324+
}
321325
}
322326
oldAverage = average;
323327
}
324328

325-
if(nbValues > 0) {
326-
int height = bounds.height - scale.getScaledValue(computeAverage(currentPosition-6)) - 2;
329+
if(lastAverage >= 0) {
330+
int height = bounds.height - scale.getScaledValue(lastAverage) - 2;
327331
gcImage.setForeground(colors[COLOR_AVERAGE]);
328-
gcImage.drawText(formater.format(computeAverage(currentPosition-6)),bounds.width - 65,height - 12,true);
332+
gcImage.drawText(formater.format(lastAverage),bounds.width - 65,height - 12,true);
329333
}
330334

331335
gcImage.dispose();

uis/src/com/biglybt/ui/swt/components/graphics/SpeedGraphic.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ protected void drawChart(boolean sizeChanged) {
383383

384384
int last_xpos = -1;
385385

386+
int lastAverage = -1;
387+
386388
for (int x = 0; x < bounds.width - 71; x++){
387389

388390
int position = currentPosition - x - 1;
@@ -492,15 +494,17 @@ protected void drawChart(boolean sizeChanged) {
492494
int h2 = bounds.height - scale.getScaledValue(oldAverage) - 2;
493495
gcImage.setForeground(colors[COLOR_AVERAGE]);
494496
gcImage.drawLine(xDraw, h1, xDraw + 1, h2);
497+
if ( lastAverage == -1 ){
498+
lastAverage = oldAverage;
499+
}
495500
}
496501
oldAverage = average;
497502
}
498503

499-
if (nbValues > 0)
500-
{
501-
int height = bounds.height - scale.getScaledValue(computeAverage(currentPosition - 6)) - 2;
504+
if (lastAverage >= 0){
505+
int height = bounds.height - scale.getScaledValue(lastAverage) - 2;
502506
gcImage.setForeground(colors[COLOR_AVERAGE]);
503-
gcImage.drawText(formater.format(computeAverage(currentPosition - 6)), bounds.width - 65, height - 12, true);
507+
gcImage.drawText(formater.format(lastAverage), bounds.width - 65, height - 12, true);
504508
}
505509

506510
} catch (Exception e)

0 commit comments

Comments
 (0)