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.provider.system; 020 021import java.awt.Component; 022import java.util.ArrayList; 023import java.util.Collection; 024import java.util.Collections; 025import java.util.List; 026import jpen.owner.awt.ComponentPenOwner; 027import jpen.PenDevice; 028import jpen.PenManager; 029import jpen.PenProvider; 030import jpen.provider.AbstractPenProvider; 031 032public final class SystemProvider 033 extends AbstractPenProvider { 034 035 public static class Constructor 036 extends AbstractPenProvider.AbstractConstructor { 037 public static final String NAME="System"; 038 //@Override 039 public String getName() { 040 return NAME; 041 } 042 //@Override 043 public boolean constructable(PenManager penManager) { 044 return penManager.penOwner instanceof ComponentPenOwner; 045 } 046 @Override 047 protected PenProvider constructProvider() throws Throwable { 048 ComponentPenOwner componentPenOwner=(ComponentPenOwner)getPenManager().penOwner; 049 return new SystemProvider(this, componentPenOwner); 050 } 051 } 052 053 final ComponentPenOwner componentPenOwner; 054 private final MouseDevice mouseDevice=new MouseDevice(this); 055 private final KeyboardDevice keyboardDevice=new KeyboardDevice(this); 056 057 private SystemProvider(Constructor constructor, ComponentPenOwner componentPenOwner) { 058 super(constructor); 059 this.componentPenOwner=componentPenOwner; 060 devices.add(mouseDevice); 061 devices.add(keyboardDevice); 062 } 063 064 //@Override 065 public void penManagerPaused(boolean paused) { 066 mouseDevice.setPaused(paused); 067 keyboardDevice.setPaused(paused); 068 } 069}