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 ); } } }
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; }
/** * 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 ); }
/** * <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; }
/** */ 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()); }
@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(); }
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; }
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 ); }
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 ); } } }
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 ); }
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 ); }
/** * 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 ); }
/** * 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."); } }
/** * 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); } }
/** * 自定义拖拽区域 */ protected MouseInputListener installWindowListeners(JRootPane root) { MouseInputListener listener = super.installWindowListeners(root); if(listener instanceof WindowMouseHandler) { ((WindowMouseHandler) listener).setDragArea(new LuckRectangle(root)); } return listener; }
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: */ }
public LeftMouseDragAdapter( MouseInputListener drags, long hysteresis ) { super(); mDelegate = drags; this .hysteresis = hysteresis; }
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); } }
protected MouseInputListener createMouseInputListener() { if (mouseHandler == null) { mouseHandler = new MouseInputHandler(); } return mouseHandler; }
public void testCreateMouseInputListener() { MouseInputListener l1 = ui.createMouseInputListener(); MouseInputListener l2 = ui.createMouseInputListener(); assertTrue("not null", l1 != null); if (isHarmony()) { assertSame("the same instance", l1, l2); } }
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())); }
public void testUninstallListeners() { MouseInputListener listener = ui.createMouseInputListener(); ui.uninstallListeners(); assertFalse("uninstalled mouseListener", belongs(listener, icon.getMouseListeners())); assertFalse("uninstalled mouseMotionListener", belongs(listener, icon .getMouseMotionListeners())); }
/** * 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); } }); }
protected MouseInputListener createMouseInputListener(JComponent c) { if (JTattooUtilities.getJavaVersion() >= 1.5) { return new MyMouseInputHandler(); } else { return super.createMouseInputListener(c); } }
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)); }
@Override protected MouseInputListener createMouseInputListener () { return new ListMouseInputHandler (); }
@Override protected MouseInputListener createDockingListener() { return new RapidLookDockingListener(this.toolBar); }
@Override protected MouseInputListener createMouseInputListener() { return new MouseInputHandler((EditableTableHeader) header); }