/** Inform all registered MeasureToolListeners that the distance is not valid anymore. */ private void reportClearDistance() { Iterator iterator = this.listeners.iterator(); while (iterator.hasNext()) { MeasureToolListener listener = (MeasureToolListener) iterator.next(); listener.clearDistance(); } }
/** Inform all registered MeasureToolListeners of a new distance. */ private void reportDistance(boolean finalDistance) { if (dragStartPos == null || dragCurrentPos == null) return; final double dx = dragCurrentPos.x - dragStartPos.x; final double dy = dragCurrentPos.y - dragStartPos.y; final double d = Math.sqrt(dx * dx + dy * dy); final double angle = Math.atan2(dy, dx); Iterator iterator = this.listeners.iterator(); while (iterator.hasNext()) { MeasureToolListener listener = (MeasureToolListener) iterator.next(); if (finalDistance) listener.newDistance(d, angle, this.mapComponent); else listener.distanceChanged(d, angle, this.mapComponent); } }