001package com.github.sarxos.webcam;
002
003import java.awt.Point;
004import java.util.EventObject;
005
006
007/**
008 * Webcam detected motion event.
009 *
010 * @author Bartosz Firyn (SarXos)
011 */
012public class WebcamMotionEvent extends EventObject {
013
014        private static final long serialVersionUID = -7245768099221999443L;
015
016        private final double strength;
017        private final Point cog;
018
019        /**
020         * Create detected motion event.
021         *
022         * @param detector
023         * @param strength
024         * @param cog center of motion gravity
025         */
026        public WebcamMotionEvent(WebcamMotionDetector detector, double strength, Point cog) {
027
028                super(detector);
029
030                this.strength = strength;
031                this.cog = cog;
032        }
033
034        /**
035         * Get percentage fraction of image covered by motion. 0 is no motion on image, and 100 is full
036         * image covered by motion.
037         *
038         * @return Motion area
039         */
040        public double getArea() {
041                return strength;
042        }
043
044        public Point getCog() {
045                return cog;
046        }
047}