/*
If an end event happens of the right type, update the pointer, run endHandlers, and save the pointer as 'lastPointer'
185708
function gestureEnd(ev) {
    if (!pointer || !typesMatch(ev, pointer)) return;

    updatePointerState(ev, pointer);
    pointer.endTime = +Date.now();

    if (ev.type !== 'pointercancel') {
      runHandlers('end', ev);
    }

    lastPointer = pointer;
    pointer = null;
  }
167326
function (evt) {
        if (this.mouseDown && (!this.lastUp || !this.lastUp.equals(evt.xy))) {
            if(this.stoppedDown && this.freehandMode(evt)) {
                if (this.persist) {
                    this.destroyPersistedFeature();
                }
                this.removePoint();
                this.finalize();
            } else {
                if (this.passesTolerance(this.lastDown, evt.xy,
                                         this.pixelTolerance)) {
                    if (this.touch) {
                        this.modifyFeature(evt.xy);
                    }
                    if(this.lastUp == null && this.persist) {
                        this.destroyPersistedFeature();
                    }
                    this.addPoint(evt.xy);
                    this.lastUp = evt.xy;
                    if(this.line.geometry.components.length === this.maxVertices + 1) {
                        this.finishGeometry();
                    }
                }
            }
        }
        this.stoppedDown = this.stopDown;
        this.mouseDown = false;
        return !this.stopUp;
    }
973113
function processLastException() {
        var _lastExceptionStack = lastExceptionStack,
            _lastException = lastException;
        lastExceptionStack = null;
        lastException = null;
        notifyHandlers(_lastExceptionStack, false, _lastException);
    }
864048
def _handleEnd(self):
        
        self.cursorPos = len(self.inputBuffer)
        self._refreshInputPrompt(len(self.inputBuffer))
403344
public void setEnd(int x2, int y2) {
		end.x = x2;
		end.y = y2;
		needsRefresh = true;
	}
130024
function _dispatchReady(type) {
        var i,
            myHandlers = _callbacks[type];

        // mark this status complete
        _status[type] = true;

        for (i = 0; i < myHandlers.length; i++) {
            _callHandler(myHandlers[i]);
        }

        // clear all callbacks after being called
        _callbacks[type] = [];
    }
1168937
function msLostPointerCapture(inEvent) {
  const e = this.dispatcher.makeEvent('lostpointercapture', inEvent, inEvent);
  this.dispatcher.dispatchEvent(e);
}
559723
public void notifyEnd(String projectApiId, String projectVersion, String category, long duration) {
		try {
			if (isStarted()) {
				JSONObject endNotification = new JSONObject().
					put("project", new JSONObject().
						put("apiId", projectApiId).
						put("version", projectVersion)
					).
					put("category", category).
					put("duration", duration);
				
				socket.emit("run:end", endNotification);
			}
			else {
				LOGGER.log(Level.WARNING, "Probe Dock RT is not available to send the end notification");
			}
		}
		catch (Exception e) {
			LOGGER.log(Level.INFO, "Unable to send the end notification to the agent. Cause: " + e.getMessage());
			
			if (LOGGER.getLevel() == Level.FINEST) {
				LOGGER.log(Level.FINEST, "Exception:", e);
			}
		}
	}
878733
function msPointerUp(inEvent) {
  const e = this.prepareEvent_(inEvent);
  this.dispatcher.up(e, inEvent);
  this.cleanup(inEvent.pointerId);
}
352740
function() {
		var c = this._callback;
		var p = this._pointer;
		if (c) {
			this.then(null, null);
			c.apply(p, arguments);
		} else {
			this._now = true;
		}
	}
1047614
@Override protected void handleEvents(final String EVENT_TYPE) {
        super.handleEvents(EVENT_TYPE);
        if ("RECALC".equals(EVENT_TYPE)) {
            angleRange = Helper.clamp(90.0, 180.0, gauge.getAngleRange());
            startAngle = getStartAngle();
            minValue   = gauge.getMinValue();
            range      = gauge.getRange();
            sections   = gauge.getSections();
            angleStep  = angleRange / range;
            redraw();
            rotateNeedle(gauge.getCurrentValue());
        } else if ("FINISHED".equals(EVENT_TYPE)) {
            String text = String.format(locale, formatString, gauge.getValue());
            needleTooltip.setText(text);
            double value = gauge.getValue();
            if (gauge.isValueVisible()) {
                Bounds bounds       = barBackground.localToScreen(barBackground.getBoundsInLocal());
                double tooltipAngle = needleRotate.getAngle();
                double sinValue     = Math.sin(Math.toRadians(90 + angleRange * 0.5 - tooltipAngle));
                double cosValue     = Math.cos(Math.toRadians(90 + angleRange * 0.5 - tooltipAngle));
                double needleTipX   = bounds.getMinX() + bounds.getWidth() * 0.5 + bounds.getHeight() * sinValue;
                double needleTipY   = bounds.getMinY() + bounds.getHeight() * 0.8 + bounds.getHeight() * cosValue;
                if (value < (gauge.getMinValue() + (gauge.getRange() * 0.5))) {
                    needleTipX -= text.length() * 7;
                }
                needleTooltip.show(needle, needleTipX, needleTipY);
            }
            if (sections.isEmpty() || sectionsAlwaysVisible) return;
            for (Section section : sections) {
                if (section.contains(value)) {
                    barTooltip.setText(section.getText());
                    break;
                }
            }
        } else if ("VISIBILITY".equals(EVENT_TYPE)) {
            Helper.enableNode(titleText, !gauge.getTitle().isEmpty());
        }
    }
1026331
@Override
    public void endDefinitionList(Map<String, String> parameters)
    {
        saveEvent(EventType.END_DEFINITION_LIST, parameters);
    }
863988
function () {
                    if (this._notificationsSent && !this._externalBegin && !this._endNotificationsPosted) {
                        this._endNotificationsPosted = true;
                        var that = this;
                        Scheduler.schedule(function ItemsManager_async_endNotifications() {
                            that._endNotificationsPosted = false;
                            that._endNotifications();
                        }, Scheduler.Priority.high, null, "WinJS.UI._ItemsManager._postEndNotifications");
                    }
                }
1269813
function finisher(error, output, callback)
{
  // signal end of the stream
  // only for successfully finished streams
  if (!error)
  {
    this.push(null);
  }

  // back to original track
  callback(error, output);
}
790909
function(event) {
      // Usually, this method will be called while iterating over a list of
      // events sorted by start time, so this method won't usually change
      // this.start. However, this will sometimes be called for ProtoIRs created
      // by previous handlers, in which case event.start could possibly be
      // before this.start.
      this.start = Math.min(this.start, event.start);
      this.end = Math.max(this.end, event.end);
      this.associatedEvents.push(event);
    }
187467
function end (nextState) {
  if (__DEBUG__) {
    if (console.group) {
      displayBuffer.next = colorFormat('next history', colors.nextState, nextState)
    } else {
      displayBuffer.next = ['next history', nextState]
    }
    printBuffer()
  }
}
1364389
function PEhandler(ev) {
        var store = this.store;
        var removePointer = false;

        var eventTypeNormalized = ev.type.toLowerCase().replace('ms', '');
        var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
        var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;

        var isTouch = (pointerType == INPUT_TYPE_TOUCH);

        // get index of the event in the store
        var storeIndex = inArray(store, ev.pointerId, 'pointerId');

        // start and mouse must be down
        if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
            if (storeIndex < 0) {
                store.push(ev);
                storeIndex = store.length - 1;
            }
        } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
            removePointer = true;
        }

        // it not found, so the pointer hasn't been down (so it's probably a hover)
        if (storeIndex < 0) {
            return;
        }

        // update the event in the store
        store[storeIndex] = ev;

        this.callback(this.manager, eventType, {
            pointers: store,
            changedPointers: [ev],
            pointerType: pointerType,
            srcEvent: ev
        });

        if (removePointer) {
            // remove from the store
            store.splice(storeIndex, 1);
        }
    }