Java 类javax.swing.event.MouseInputListener 实例源码

项目:PhET    文件:MouseManager.java   
private void handleEntranceAndExit( MouseEvent e ) {
    MouseInputListener unit = getHandler( e );
    if ( unit == null ) {
        if ( activeUnit != null ) {
            activeUnit.mouseExited( e );
            activeUnit = null;
        }
    }
    else if ( unit != null ) {
        if ( activeUnit == unit ) {
            //same guy
        }
        else if ( activeUnit == null ) {
            //Fire a grabber entered, set the active unit.
            activeUnit = unit;
            activeUnit.mouseEntered( e );
        }
        else if ( activeUnit != unit ) {
            //Switch active units.
            activeUnit.mouseExited( e );
            activeUnit = unit;
            activeUnit.mouseEntered( e );
        }
    }
}
项目:PhET    文件:MouseManager.java   
private MouseInputListener getHandler( MouseEvent e ) {
//    private BoundedMouseListener getHandler( MouseEvent e ) {
//        DefaultInteractiveGraphic[] units = (DefaultInteractiveGraphic[])am.toArray( new DefaultInteractiveGraphic[0] );
        Iterator it = am.reverseIterator();
        while( it.hasNext() ) {
            Object o = it.next();
            if( o instanceof Boundary && o instanceof MouseInputListener ) {
                Boundary boundary = (Boundary)o;
                if( boundary.contains( e.getX(), e.getY() ) ) {
                    return (MouseInputListener)boundary;
                }
            }
//        BoundedMouseListener[] units = (BoundedMouseListener[])am.toArray( new BoundedMouseListener[0] );
//        for( int i = units.length - 1; i >= 0; i-- ) {
//            DefaultInteractiveGraphic unit = units[i];
//            BoundedMouseListener unit = units[i];
//            if( unit.contains( e.getX(), e.getY() ) ) {
//            if( unit.getAbstractShape().contains( e.getX(), e.getY() ) ) {
//                return unit;
//            }
        }
        return null;
    }
项目:PhET    文件:ApparatusPanel.java   
/**
 * Sets up mouse and key listeners
 */
protected void setMouseAndKeyListeners( MouseInputListener mouseHandler, KeyListener keyAdapter ) {
    // Clear the old handlers
    MouseListener[] mouseListeners = this.getMouseListeners();
    for ( int i = 0; i < mouseListeners.length; i++ ) {
        MouseListener mouseListener = mouseListeners[i];
        this.removeMouseListener( mouseListener );
    }
    MouseMotionListener[] mouseMostionListeners = this.getMouseMotionListeners();
    for ( int i = 0; i < mouseMostionListeners.length; i++ ) {
        MouseMotionListener mouseMostionListener = mouseMostionListeners[i];
        this.removeMouseMotionListener( mouseMostionListener );
    }
    KeyListener[] keyListeners = this.getKeyListeners();
    for ( int i = 0; i < keyListeners.length; i++ ) {
        KeyListener keyListener = keyListeners[i];
        this.removeKeyListener( keyListener );
    }

    // Add the new handlers
    this.addMouseListener( mouseHandler );
    this.addMouseMotionListener( getGraphic().getMouseHandler() );
    this.addKeyListener( keyAdapter );
}
项目:littleluck    文件:LuckRootPaneUI.java   
/**
 * <p>创建窗体鼠标监听器, 处理窗体的移动和拖拽事件</p>
 * 
 * <p>Create Window mouse listener, handle window move and drag event.</p>
 *
 * @param root <code>JRootPane</code>
 * @return <code>MouseInputListener</code> window move and drag event listener.
 */
protected MouseInputListener installWindowListeners(JRootPane root)
{
    Window window = SwingUtilities.getWindowAncestor(root);

    if (window != null)
    {
        if (mouseInputListener == null)
        {
            mouseInputListener = new WindowMouseHandler(root);
        }

        window.addMouseListener(mouseInputListener);

        window.addMouseMotionListener(mouseInputListener);
    }

    return mouseInputListener;
}
项目:modelingcommons    文件:GISDataView.java   
/** */
public GISDataView () {
    setOpaque(true);
    setPreferredSize(new Dimension(300, 300));
    setBackground(Color.WHITE);
    _shapes = new ArrayList<Shape>();
    _transform = new ProjectedSpaceToPixelSpaceTransform(new Point2D.Float(0.0f, 0.0f),
                                                         180.0 / 300.0,
                                                         new Point2D.Float(150f, 150f));
    _proj = null;
    MouseInputListener dragListener = new DragListener();
    addMouseListener(dragListener);
    addMouseMotionListener(dragListener);
    addMouseWheelListener(new ZoomListener());
    setSize(getPreferredSize());
}
项目:nextreports-designer    文件:JGridHeader.java   
@Override
public void updateUI() {

    // register(or not) listener for selection
    if  (allowSelection) {
        setUI(new BasicGridHeaderUI());
    } else  {
        setUI(new BasicGridHeaderUI() {
            @Override
            protected MouseInputListener createMouseInputListener() {
                return null;
            }
        });
    }

    // register listener for cell resize
    if (resize) {
        setUI(new BasicGridHeaderUI() {
            protected MouseInputListener createMouseInputListener() {
                return new HeaderResizeMouseInputListener();
            }
        });
    }

    repaintManager.resizeAndRepaint();
}
项目:PhET    文件:MouseManager.java   
private MouseInputListener getHandler( MouseEvent e ) {
    Iterator it = am.reverseIterator();
    while ( it.hasNext() ) {
        Object o = it.next();
        if ( o instanceof Boundary && o instanceof MouseInputListener ) {
            Boundary boundary = (Boundary) o;
            if ( boundary.contains( e.getX(), e.getY() ) ) {
                return (MouseInputListener) boundary;
            }
        }
    }
    return null;
}
项目:PhET    文件:MouseManager.java   
public void startDragging( MouseInputListener inputListener, MouseEvent event ) {
    if ( activeUnit != null ) {
        activeUnit.mouseReleased( event );//could be problems if expected event==RELEASE_EVENT
    }
    activeUnit = inputListener;
    activeUnit.mouseDragged( event );
}
项目:PhET    文件:MouseManager.java   
private void handleEntranceAndExit( MouseEvent e ) {
        MouseInputListener unit = getHandler( e );
//        BoundedMouseListener unit = getHandler( e );
        if( unit == null ) {
            if( activeUnit != null ) {
                activeUnit.mouseExited( e );
//                activeUnit.getMouseInputListener().mouseExited( e );
                activeUnit = null;
            }
        }
        else if( unit != null ) {
            if( activeUnit == unit ) {
                //same guy
            }
            else if( activeUnit == null ) {
                //Fire a mouse entered, set the active unit.
                activeUnit = unit;
                activeUnit.mouseEntered( e );
//                activeUnit.getMouseInputListener().mouseEntered( e );
            }
            else if( activeUnit != unit ) {
                //Switch active units.
                activeUnit.mouseExited( e );
//                activeUnit.getMouseInputListener().mouseExited( e );
                activeUnit = unit;
                activeUnit.mouseEntered( e );
//                activeUnit.getMouseInputListener().mouseEntered( e );
            }
        }
    }
项目:PhET    文件:CompositeInteractiveGraphicMouseDelegator.java   
public void startDragging( MouseEvent event, MouseInputListener activeUnit ) {
    if( this.activeUnit != null ) {
        this.activeUnit.mouseExited( event );
    }
    this.activeUnit = activeUnit;
    activeUnit.mouseEntered( event );
    activeUnit.mousePressed( event );
    activeUnit.mouseDragged( event );
}
项目:PhET    文件:CompositeInteractiveGraphicMouseDelegator.java   
public void handleEntranceAndExit( MouseEvent e ) {
        // Find the topmost graphic that can handle the event
        MouseInputListener unit = getLeaf( e.getPoint(), compositeInteractiveGraphic );
        if( unit == null ) {
            // If the mouse isn't over anything contained in the
            // CompositeGraphic...
            if( activeUnit != null ) {
                activeUnit.mouseExited( e );
                activeUnit = null;
            }
        }
        else {//unit was non-null.
            if( activeUnit == unit ) {
                //same guy
            }
            else if( activeUnit == null ) {
                //Fire a mouse entered, set the active unit.
                activeUnit = unit;
                activeUnit.mouseEntered( e );
            }
            else if( activeUnit != unit ) {
                //Switch active units.
                activeUnit.mouseExited( e );
                activeUnit = unit;
                activeUnit.mouseEntered( e );
            }
        }
//        System.out.println( "activeUnit = " + activeUnit );
    }
项目:PhET    文件:ColorControl.java   
/**
 * Constructor.
 *
 * @param labelString
 * @param color
 * @param chipSize
 */
public ColorControl( Frame parentFrame, String labelString, Color color, Dimension chipSize ) {
    super();

    this.parentFrame = parentFrame;
    this.labelString = labelString;
    this.chipSize = new Dimension( chipSize );
    listenerList = new EventListenerList();

    MouseInputListener mouseInputListener = new MouseInputAdapter() {
        public void mouseClicked( MouseEvent event ) {
            openColorChooser();
        }
    };

    JLabel label = new JLabel( labelString );
    label.addMouseListener( mouseInputListener );

    colorChip = new JLabel();
    colorChip.addMouseListener( mouseInputListener );

    add( label );
    add( Box.createHorizontalStrut( 5 ) );
    add( colorChip );

    setColor( color );
}
项目:VisualDCT    文件:MouseEventManager.java   
/**
 * Insert the method's description here.
 * Creation date: (18.12.2000 16:25:04)
 * @param subscriberID java.lang.String
 * @param listener javax.swing.event.MouseInputListener
 */
public void subscribe(String subscriberID, MouseInputListener listener) {
    JComponent comp = (JComponent)getSubscriber().get(subscriberID);
    if (comp!=null) {
        DoubleClickProxy proxy = new DoubleClickProxy(listener);
        comp.addMouseListener(proxy);
        comp.addMouseMotionListener(proxy);
    } else {
        //System.err.println("Warning: subscriber with id " + subscriberID + " doesn't exist.");
    }
}
项目:VisualDCT    文件:MouseEventManager.java   
/**
 * Insert the method's description here.
 * Creation date: (18.12.2000 16:25:04)
 * @param subscriberID java.lang.String
 * @param listener javax.swing.event.MouseInputListener
 */
public void unsubscribe(String subscriberID, MouseInputListener listener) {
    JComponent comp = (JComponent)getSubscriber().get(subscriberID);
    if (comp!=null) {
        comp.removeMouseListener(listener);
        comp.removeMouseMotionListener(listener);
    }
}
项目:littleluck    文件:FrameDemo.java   
/**
 * 自定义拖拽区域
 */
protected MouseInputListener installWindowListeners(JRootPane root)
{
    MouseInputListener listener = super.installWindowListeners(root);

    if(listener instanceof WindowMouseHandler)
    {
        ((WindowMouseHandler) listener).setDragArea(new LuckRectangle(root));
    }

    return listener;
}
项目:confluence.keygen    文件:DefaultInputBlocker.java   
BusyGlassPane()
/* 281:    */     {
/* 282:296 */       super(false);
/* 283:297 */       setVisible(false);
/* 284:298 */       setOpaque(false);
/* 285:299 */       setCursor(Cursor.getPredefinedCursor(3));
/* 286:300 */       MouseInputListener blockMouseEvents = new MouseInputAdapter() {};
/* 287:301 */       addMouseMotionListener(blockMouseEvents);
/* 288:302 */       addMouseListener(blockMouseEvents);
/* 289:    */     }
项目:vzome-desktop    文件:LeftMouseDragAdapter.java   
public LeftMouseDragAdapter( MouseInputListener drags, long hysteresis )
{
    super();

    mDelegate = drags;
    this .hysteresis = hysteresis;
}
项目:mapsracer    文件:MapManager.java   
public void initialize(NodeManager nodeManager, Map<String, Car> allCars) {
    this.nodeManager = nodeManager;

    mapViewer = new JXMapViewer();

    TileFactoryInfo info = new OSMTileFactoryInfo();
    DefaultTileFactory tileFactory = new DefaultTileFactory(info);
    tileFactory.setThreadPoolSize(8);

    mapViewer.setTileFactory(tileFactory);

    mapViewer.setAddressLocation(new GeoPosition(48.14650327493638,
            16.329095363616943));

    mapViewer.setZoom(3);

    CarPainter carPainter = new CarPainter();
    GraphPainter graphPainter = new GraphPainter();
    ClusterPainter clusterPainter = new ClusterPainter();

    CompoundPainter<JXMapViewer> painter = new CompoundPainter<JXMapViewer>();
    painter.addPainter(carPainter);
    if (MapsRacer.DEBUG) {
        painter.addPainter(graphPainter);
        painter.addPainter(clusterPainter);
    }

    carPainter.initialize(allCars);
    graphPainter.initialize(nodeManager.getStreets());
    clusterPainter.initialize(nodeManager.getClusters());

    mapViewer.setOverlayPainter(painter);

    if (MapsRacer.DEBUG) {
        MouseInputListener mouseListener = new PanMouseInputListener(
                mapViewer);
        mapViewer.addMouseListener(mouseListener);
        mapViewer.addMouseMotionListener(mouseListener);
    }
}
项目:cn1    文件:BasicDesktopIconUI.java   
protected MouseInputListener createMouseInputListener() {
    if (mouseHandler == null) {
        mouseHandler = new MouseInputHandler();
    }

    return mouseHandler;
}
项目:cn1    文件:BasicDesktopIconUITest.java   
public void testCreateMouseInputListener() {
    MouseInputListener l1 = ui.createMouseInputListener();
    MouseInputListener l2 = ui.createMouseInputListener();
    assertTrue("not null", l1 != null);
    if (isHarmony()) {
        assertSame("the same instance", l1, l2);
    }
}
项目:cn1    文件:BasicDesktopIconUITest.java   
public void testInstallListeners() {
    ui.uninstallListeners();
    ui.installListeners();
    MouseInputListener listener = ui.mouseInputListener;
    assertTrue("installed mouseListener", belongs(listener, icon.getMouseListeners()));
    assertTrue("installed mouseMotionListener", belongs(listener, icon
            .getMouseMotionListeners()));
}
项目:cn1    文件:BasicDesktopIconUITest.java   
public void testUninstallListeners() {
    MouseInputListener listener = ui.createMouseInputListener();
    ui.uninstallListeners();
    assertFalse("uninstalled mouseListener", belongs(listener, icon.getMouseListeners()));
    assertFalse("uninstalled mouseMotionListener", belongs(listener, icon
            .getMouseMotionListeners()));
}
项目:vzome-desktop    文件:LeftMouseDragAdapter.java   
public LeftMouseDragAdapter( MouseInputListener drags, long hysteresis )
{
    super();

    mDelegate = drags;
    this .hysteresis = hysteresis;
}
项目:freeVM    文件:BasicDesktopIconUI.java   
protected MouseInputListener createMouseInputListener() {
    if (mouseHandler == null) {
        mouseHandler = new MouseInputHandler();
    }

    return mouseHandler;
}
项目:freeVM    文件:BasicDesktopIconUITest.java   
public void testCreateMouseInputListener() {
    MouseInputListener l1 = ui.createMouseInputListener();
    MouseInputListener l2 = ui.createMouseInputListener();
    assertTrue("not null", l1 != null);
    if (isHarmony()) {
        assertSame("the same instance", l1, l2);
    }
}
项目:freeVM    文件:BasicDesktopIconUITest.java   
public void testInstallListeners() {
    ui.uninstallListeners();
    ui.installListeners();
    MouseInputListener listener = ui.mouseInputListener;
    assertTrue("installed mouseListener", belongs(listener, icon.getMouseListeners()));
    assertTrue("installed mouseMotionListener", belongs(listener, icon
            .getMouseMotionListeners()));
}
项目:freeVM    文件:BasicDesktopIconUITest.java   
public void testUninstallListeners() {
    MouseInputListener listener = ui.createMouseInputListener();
    ui.uninstallListeners();
    assertFalse("uninstalled mouseListener", belongs(listener, icon.getMouseListeners()));
    assertFalse("uninstalled mouseMotionListener", belongs(listener, icon
            .getMouseMotionListeners()));
}
项目:freeVM    文件:BasicDesktopIconUI.java   
protected MouseInputListener createMouseInputListener() {
    if (mouseHandler == null) {
        mouseHandler = new MouseInputHandler();
    }

    return mouseHandler;
}
项目:freeVM    文件:BasicDesktopIconUITest.java   
public void testCreateMouseInputListener() {
    MouseInputListener l1 = ui.createMouseInputListener();
    MouseInputListener l2 = ui.createMouseInputListener();
    assertTrue("not null", l1 != null);
    if (isHarmony()) {
        assertSame("the same instance", l1, l2);
    }
}
项目:freeVM    文件:BasicDesktopIconUITest.java   
public void testInstallListeners() {
    ui.uninstallListeners();
    ui.installListeners();
    MouseInputListener listener = ui.mouseInputListener;
    assertTrue("installed mouseListener", belongs(listener, icon.getMouseListeners()));
    assertTrue("installed mouseMotionListener", belongs(listener, icon
            .getMouseMotionListeners()));
}
项目:freeVM    文件:BasicDesktopIconUITest.java   
public void testUninstallListeners() {
    MouseInputListener listener = ui.createMouseInputListener();
    ui.uninstallListeners();
    assertFalse("uninstalled mouseListener", belongs(listener, icon.getMouseListeners()));
    assertFalse("uninstalled mouseMotionListener", belongs(listener, icon
            .getMouseMotionListeners()));
}
项目:swingx-ws    文件:JXMapViewer.java   
/**
 * Create a new JXMapViewer. By default it will use the EmptyTileFactory
 */
public JXMapViewer() {
    factory = new EmptyTileFactory();
    //setTileFactory(new GoogleTileFactory());
    MouseInputListener mia = new PanMouseInputListener();
    setRecenterOnClickEnabled(false);
    this.addMouseListener(mia);
    this.addMouseMotionListener(mia);
    this.addMouseWheelListener(new ZoomMouseWheelListener());
    this.addKeyListener(new PanKeyListener());

    // make a dummy loading image
    try {
        URL url = this.getClass().getResource("mapviewer/resources/loading.png");
        this.setLoadingImage(ImageIO.read(url));
    } catch (Throwable ex) {
        System.out.println("could not load 'loading.png'");
        BufferedImage img = new BufferedImage(16,16,BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2 = img.createGraphics();
        g2.setColor(Color.black);
        g2.fillRect(0,0,16,16);
        g2.dispose();
        this.setLoadingImage(img);
    }

    //setAddressLocation(new GeoPosition(37.392137,-121.950431)); // Sun campus

    setBackgroundPainter(new AbstractPainter<JXPanel>() {
        protected void doPaint(Graphics2D g, JXPanel component, int width, int height) {
            doPaintComponent(g);
        }
    });
}
项目:griffon-swingx-ws-plugin    文件:JXMapViewer.java   
/**
 * Create a new JXMapViewer. By default it will use the EmptyTileFactory
 */
public JXMapViewer() {
    factory = new EmptyTileFactory();
    //setTileFactory(new GoogleTileFactory());
    MouseInputListener mia = new PanMouseInputListener();
    setRecenterOnClickEnabled(false);
    this.addMouseListener(mia);
    this.addMouseMotionListener(mia);
    this.addMouseWheelListener(new ZoomMouseWheelListener());
    this.addKeyListener(new PanKeyListener());

    // make a dummy loading image
    try {
        URL url = this.getClass().getResource("mapviewer/resources/loading.png");
        this.setLoadingImage(ImageIO.read(url));
    } catch (Throwable ex) {
        System.out.println("could not load 'loading.png'");
        BufferedImage img = new BufferedImage(16,16,BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2 = img.createGraphics();
        g2.setColor(Color.black);
        g2.fillRect(0,0,16,16);
        g2.dispose();
        this.setLoadingImage(img);
    }

    //setAddressLocation(new GeoPosition(37.392137,-121.950431)); // Sun campus

    setBackgroundPainter(new AbstractPainter<JXPanel>() {
        protected void doPaint(Graphics2D g, JXPanel component, int width, int height) {
            doPaintComponent(g);
        }
    });
}
项目:Botnak    文件:BaseMenuUI.java   
protected MouseInputListener createMouseInputListener(JComponent c) {
    if (JTattooUtilities.getJavaVersion() >= 1.5) {
        return new MyMouseInputHandler();
    } else {
        return super.createMouseInputListener(c);
    }
}
项目:maps4cim    文件:MapViewerFactory.java   
protected void addActionListeners(JXMapViewer jxm) {
    MouseInputListener mia = new PanMouseInputListener(jxm);
    jxm.addMouseListener(mia);
    jxm.addMouseMotionListener(mia);

    jxm.addMouseListener(new CenterMapListener(jxm));

    jxm.addMouseWheelListener(new ZoomMouseWheelListenerCursor(jxm));

    jxm.addKeyListener(new PanKeyListener(jxm));
}
项目:android-packages-manager    文件:BaseMenuUI.java   
protected MouseInputListener createMouseInputListener(JComponent c) {
    if (JTattooUtilities.getJavaVersion() >= 1.5) {
        return new MyMouseInputHandler();
    } else {
        return super.createMouseInputListener(c);
    }
}
项目:spark-svn-mirror    文件:BaseMenuUI.java   
protected MouseInputListener createMouseInputListener(JComponent c) {
    if (JTattooUtilities.getJavaVersion() >= 1.5) {
        return new MyMouseInputHandler();
    } else {
        return super.createMouseInputListener(c);
    }
}
项目:incubator-netbeans    文件:CategoryList.java   
@Override
protected MouseInputListener createMouseInputListener () {
    return new ListMouseInputHandler ();
}
项目:rapidminer    文件:ToolBarUI.java   
@Override
protected MouseInputListener createDockingListener() {
    return new RapidLookDockingListener(this.toolBar);
}
项目:rapidminer    文件:EditableTableHeaderUI.java   
@Override
protected MouseInputListener createMouseInputListener() {
    return new MouseInputHandler((EditableTableHeader) header);
}