@@ -145,9 +145,12 @@ class DeviceUI {
145145 }
146146
147147 void update (GC gc , ViewPort vp , long time ) {
148- if (!user .getPosition ().isPresent ()) {
148+ final Optional <com .github .rinde .rinsim .geom .Point > maybe =
149+ user .getPosition ();
150+ if (!maybe .isPresent ()) {
149151 return ;
150152 }
153+ final com .github .rinde .rinsim .geom .Point userPos = maybe .get ();
151154 if (!color .isPresent ()
152155 && viewOptions .contains (ViewOptions .RELIABILITY_COLOR )) {
153156 final RGB rgb = ColorUtil .interpolate (unreliableColor , reliableColor ,
@@ -156,22 +159,22 @@ void update(GC gc, ViewPort vp, long time) {
156159 }
157160
158161 if (device .getMaxRange ().isPresent ()) {
159- helper .drawCircle (user . getPosition (). get () , device .getMaxRange ().get ());
162+ helper .drawCircle (userPos , device .getMaxRange ().get ());
160163 if (color .isPresent ()) {
161164 gc .setBackground (color .get ());
162165 } else {
163166 helper .setBackgroundSysCol (SWT .COLOR_DARK_BLUE );
164167 }
165168 gc .setAlpha (SEMI_TRANSPARENT );
166- helper .fillCircle (user . getPosition (). get () , device .getMaxRange ().get ());
169+ helper .fillCircle (userPos , device .getMaxRange ().get ());
167170 }
168171
169172 gc .setAlpha (OPAQUE );
170- helper .fillCircle (user . getPosition (). get () , DOT_RADIUS );
173+ helper .fillCircle (userPos , DOT_RADIUS );
171174
172175 if (viewOptions .contains (ViewOptions .TO_STRING )) {
173176 final Point p = gc .textExtent (user .toString ());
174- helper .drawString (user .toString (), user . getPosition (). get () , true ,
177+ helper .drawString (user .toString (), userPos , true ,
175178 -p .x / 2 , -p .y );
176179 }
177180 final StringBuilder sb = new StringBuilder ();
@@ -187,7 +190,7 @@ void update(GC gc, ViewPort vp, long time) {
187190 }
188191 if (sb .length () > 0 ) {
189192 final Point p = gc .textExtent (sb .toString ());
190- helper .drawString (sb .toString (), user . getPosition (). get () , true ,
193+ helper .drawString (sb .toString (), userPos , true ,
191194 -p .x / 2 , 0 );
192195 }
193196 }
0 commit comments