MCPcopy Create free account
hub / github.com/BaseXdb/basex / focus

Method focus

basex-core/src/main/java/org/basex/gui/view/map/MapView.java:245–267  ·  view source on GitHub ↗

Finds the rectangle at the cursor position. @return focused rectangle

()

Source from the content-addressed store, hash-verified

243 * @return focused rectangle
244 */
245 private boolean focus() {
246 if(gui.updating || mainRects == null) return false;
247
248 /*
249 * Loop through all rectangles. As the rectangles are sorted by PRE order
250 * and small rectangles are descendants of bigger ones, the focused
251 * rectangle can be found by simply parsing the array backwards.
252 */
253 int r = mainRects.size;
254 while(--r >= 0) {
255 final MapRect rect = mainRects.get(r);
256 if(rect.contains(mouseX, mouseY)) break;
257 }
258 // don't focus top rectangles
259 final MapRect fr = r >= 0 ? mainRects.get(r) : null;
260
261 // find focused rectangle
262 final boolean nf = focused != fr || fr != null && fr.thumb;
263 focused = fr;
264
265 if(nf) gui.notify.focus(focused != null ? focused.pre : -1, this);
266 return nf;
267 }
268
269 /**
270 * Initializes the calculation of the main map.

Callers 5

zoomMethod · 0.95
calcMethod · 0.95
mouseMovedMethod · 0.95
mousePressedMethod · 0.95
keyPressedMethod · 0.95

Calls 2

containsMethod · 0.95
getMethod · 0.65

Tested by

no test coverage detected