-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timeline: fix low zoom limit for huge simultion tmes - prevent crashe… #583
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,7 +124,9 @@ public class TimeLine extends VisPlugin implements HasQuickHelp { | |
private static final long[] ZOOM_LEVELS = { | ||
1, 2, 5, 10, | ||
20, 50, 100, 200, 500, 1000, | ||
2000, 5000, 10000, 20000, 50000, 100000 }; | ||
2000, 5000, 10000, 20000, 50000, 100000, | ||
100000*2, 100000*5, 100000*10 | ||
}; | ||
|
||
private boolean needZoomOut = false; | ||
|
||
|
@@ -589,11 +591,21 @@ private static double zoomLevelToDivisor(int zoomLevel) { | |
return ZOOM_LEVELS[zoomLevel]; | ||
} | ||
|
||
private void zoomFinish (final double zoomDivisor, | ||
private void zoomFinish (double zoomDivisor, | ||
final long focusTime, | ||
final double focusCenter) { | ||
currentPixelDivisor = zoomDivisor; | ||
final double focusCenter) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep the opening brace where it was (this is how almost all code in Cooja is formatted). |
||
{ | ||
String note = ""; | ||
|
||
long now = simulation.getSimulationTime(); | ||
if (now/zoomDivisor > Integer.MAX_VALUE) { | ||
// limit zoom to fits sim-time in timeline | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the same indentation size as the rest of the file, in this file the code uses 2 spaces. |
||
int min_level = zoomGetLevel( now/Integer.MAX_VALUE ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other variables use |
||
zoomDivisor = zoomLevelToDivisor( min_level ); | ||
note = " (LIM)"; | ||
} | ||
|
||
currentPixelDivisor = zoomDivisor; | ||
if (ZOOM_LEVELS[0] >= zoomDivisor) { | ||
currentPixelDivisor = ZOOM_LEVELS[0]; | ||
note = " (MIN)"; | ||
|
@@ -604,6 +616,8 @@ private void zoomFinish (final double zoomDivisor, | |
if (zoomDivisor != currentPixelDivisor) { | ||
logger.info("Zoom level: adjusted out-of-range " + zoomDivisor + " us/pixel"); | ||
} | ||
|
||
if (note != "") | ||
logger.info("Zoom level: " + currentPixelDivisor + " microseconds/pixel " + note); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought I removed the noise in commit 83c13a9, just remove this line instead of making it conditional. |
||
|
||
forceRepaintAndFocus(focusTime, focusCenter); | ||
|
@@ -2550,9 +2564,14 @@ public void actionPerformed(ActionEvent e) { | |
/* Update timeline size */ | ||
int newWidth; | ||
if (now/currentPixelDivisor > Integer.MAX_VALUE) { | ||
/* Need zoom out */ | ||
newWidth = 1; | ||
needZoomOut = true; | ||
// if zoom not fits in timeline, try zoomout to apropriate level | ||
int level = zoomGetLevel( now/Integer.MAX_VALUE ); | ||
zoomFinishLevel(level, getCenterPointTime(), 0.5); | ||
} | ||
if (now/currentPixelDivisor > Integer.MAX_VALUE) { | ||
/* Need zoom out */ | ||
newWidth = 1; | ||
needZoomOut = true; | ||
} else { | ||
newWidth = (int) (now/currentPixelDivisor); | ||
needZoomOut = false; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the crash related to zoom levels not containing enough values, or is this change for usability?