001/* [{ 002Copyright 2007, 2008 Nicolas Carranza <nicarran at gmail.com> 003 004This file is part of jpen. 005 006jpen is free software: you can redistribute it and/or modify 007it under the terms of the GNU Lesser General Public License as published by 008the Free Software Foundation, either version 3 of the License, 009or (at your option) any later version. 010 011jpen is distributed in the hope that it will be useful, 012but WITHOUT ANY WARRANTY; without even the implied warranty of 013MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014GNU Lesser General Public License for more details. 015 016You should have received a copy of the GNU Lesser General Public License 017along with jpen. If not, see <http://www.gnu.org/licenses/>. 018}] */ 019package jpen.event; 020 021import jpen.*; 022 023public interface PenListener { 024 void penKindEvent(PKindEvent ev); 025 void penLevelEvent(PLevelEvent ev); 026 void penButtonEvent(PButtonEvent ev); 027 void penScrollEvent(PScrollEvent ev); 028 /** 029 Useful to detect if the listeners are taking too much time processing events ({@code availableMillis<0}) causing pen lagging (pen events being queued at a higher rate than they are being processed).<p> 030 The pen fires queued events at a given frequency (by default {@link jpen.Pen#DEFAULT_FREQUENCY}) in its own thread. Each cycle, after firing and processing the events, the pen calls jpen.event.PenListener.penTock(long availableMillis), where availableMillis is the time left of the period: {@code availableMillis=period-firingTime }, {@code period=1000/frequency}, and {@code firingTime} is the time spent in firing and processing events in the cycle.<p> 031 This method is called from the event dispatch thread if {@link Pen#getFirePenTockOnSwing()} is {@code true}. 032 033 @see Pen#setFirePenTockOnSwing(boolean) 034 */ 035 void penTock(long availableMillis); // TODO: Pen parameter?? 036}