public void mouseMoved( MouseEvent e ){ if( station.isResizingEnabled() && !station.isDisabled() ) { current = getDividerNode( e.getX(), e.getY() ); if( current == null ) setCursor( null ); else if( current.getOrientation() == Orientation.HORIZONTAL ) setCursor( Cursor.getPredefinedCursor( Cursor.W_RESIZE_CURSOR ) ); else setCursor( Cursor.getPredefinedCursor( Cursor.N_RESIZE_CURSOR ) ); if( current != null ) { bounds = current.getDividerBounds( current.getActualDivider(), bounds ); deltaX = bounds.width / 2 + bounds.x - e.getX(); deltaY = bounds.height / 2 + bounds.y - e.getY(); // mouse is over divider withinBounds = true; } else { // mouse is not over divider anymore withinBounds = false; } } }
/** * AWT event listener. * Used to reset the mouse cursor when divider was changed and mouse exited event had not occurred normally. * @param event */ public void eventDispatched(AWTEvent event) { if (event.getID() == MouseEvent.MOUSE_MOVED || event.getID() == MouseEvent.MOUSE_RELEASED) { MouseEvent mev = (MouseEvent)event; if( mev.getSource() != Handler.this.container && withinBounds ){ if( mev.getSource() instanceof GlassedPane.GlassPane ){ // on glass pane -> check with traditional method // Question by Beni: does this ever happen? checkMousePositionAsync(); } else{ // mouse is over another component which is not the registered container and the mouse cursor had not been reseted yet -> reset mouse cursor Point p = SwingUtilities.convertPoint(mev.getComponent(), mev.getPoint(), station); if (station.getBounds().contains(p)) { // only if mouse is within our station setCursor(null); withinBounds = false; } } } } }
public void uninstall( SplitDockStation station ){ Handler handler = handlers.remove( station ); if( handler != null ){ handler.destroy(); } }
@Override protected Divideable getDividerNode( int x, int y ){ Divideable node = super.getDividerNode( x, y ); if( node == null ){ int gap = getDividerSize(); if( side == Side.RIGHT && x <= gap ){ return new ColumnDividier( WizardSplitDockStation.this ); } else if( side == Side.LEFT && x >= getWidth() - gap - 1 ){ return new ColumnDividier( WizardSplitDockStation.this ); } else if( side == Side.TOP && y >= getHeight() - gap - 1 ){ return new ColumnDividier( WizardSplitDockStation.this ); } else if( side == Side.BOTTOM && y <= gap ){ return new ColumnDividier( WizardSplitDockStation.this ); } Leaf leaf = resizeableLeafAt( x, y ); if( leaf != null ){ return new CellDivider( WizardSplitDockStation.this, leaf ); } } return node; } }
/** * AWT event listener. * Used to reset the mouse cursor when divider was changed and mouse exited event had not occurred normally. * @param event */ public void eventDispatched(AWTEvent event) { if (event.getID() == MouseEvent.MOUSE_MOVED || event.getID() == MouseEvent.MOUSE_RELEASED) { MouseEvent mev = (MouseEvent)event; if( mev.getSource() != Handler.this.container && withinBounds ){ if( mev.getSource() instanceof GlassedPane.GlassPane ){ // on glass pane -> check with traditional method // Question by Beni: does this ever happen? checkMousePositionAsync(); } else{ // mouse is over another component which is not the registered container and the mouse cursor had not been reseted yet -> reset mouse cursor Point p = SwingUtilities.convertPoint(mev.getComponent(), mev.getPoint(), station); if (station.getBounds().contains(p)) { // only if mouse is within our station setCursor(null); withinBounds = false; } } } } }
public void run(){ if( container != null ){ PointerInfo p = MouseInfo.getPointerInfo(); Point e = p.getLocation(); SwingUtilities.convertPointFromScreen(e, container); current = getDividerNode( e.x, e.y ); if( current == null ) { mouseExited( null ); } else { // check bounds with one pixel delta -> divider needs to be greater than 2 pixels, because divider bounds will be shrinked by 1 pixel at each side if( bounds.width > 2 && bounds.height > 2 ){ if( e.x <= bounds.x || e.x >= bounds.x+bounds.width-1 || e.y <= bounds.y || e.y >= bounds.y+bounds.height-1 ){ // mouse is likely to be not on divider anymore mouseExited( null ); } } } } } });
public void mouseMoved( MouseEvent e ){ if( station.isResizingEnabled() && !station.isDisabled() ) { current = getDividerNode( e.getX(), e.getY() ); if( current == null ) setCursor( null ); else if( current.getOrientation() == Orientation.HORIZONTAL ) setCursor( Cursor.getPredefinedCursor( Cursor.W_RESIZE_CURSOR ) ); else setCursor( Cursor.getPredefinedCursor( Cursor.N_RESIZE_CURSOR ) ); if( current != null ) { bounds = current.getDividerBounds( current.getActualDivider(), bounds ); deltaX = bounds.width / 2 + bounds.x - e.getX(); deltaY = bounds.height / 2 + bounds.y - e.getY(); // mouse is over divider withinBounds = true; } else { // mouse is not over divider anymore withinBounds = false; } } }
public void run(){ if( container != null ){ PointerInfo p = MouseInfo.getPointerInfo(); Point e = p.getLocation(); SwingUtilities.convertPointFromScreen(e, container); current = getDividerNode( e.x, e.y ); if( current == null ) { mouseExited( null ); } else { // check bounds with one pixel delta -> divider needs to be greater than 2 pixels, because divider bounds will be shrinked by 1 pixel at each side if( bounds.width > 2 && bounds.height > 2 ){ if( e.x <= bounds.x || e.x >= bounds.x+bounds.width-1 || e.y <= bounds.y || e.y >= bounds.y+bounds.height-1 ){ // mouse is likely to be not on divider anymore mouseExited( null ); } } } } } });
@Override public void mouseReleased( MouseEvent e ){ if( pressed ) { pressed = false; if( current != null ) { setDivider( current, divider ); repaint( bounds.x, bounds.y, bounds.width, bounds.height ); station.updateBounds(); } setCursor( null ); mouseMoved( e ); if( controller != null && !controller.isRestrictedEnvironment() && awtListenerEnabled ) { // new solution eventDispatched(e); } else { // old solution with a little tweaking checkMousePositionAsync(); } } }
@Override public void mouseReleased( MouseEvent e ){ if( pressed ) { pressed = false; if( current != null ) { setDivider( current, divider ); repaint( bounds.x, bounds.y, bounds.width, bounds.height ); station.updateBounds(); } setCursor( null ); mouseMoved( e ); if( controller != null && !controller.isRestrictedEnvironment() && awtListenerEnabled ) { // new solution eventDispatched(e); } else { // old solution with a little tweaking checkMousePositionAsync(); } } }
@Override public void mousePressed( MouseEvent e ){ if( station.isResizingEnabled() && !station.isDisabled() ) { if( !pressed ) { pressed = true; mouseMoved( e ); if( current != null ) { divider = current.getDividerAt( e.getX() + deltaX, e.getY() + deltaY ); divider = current.validateDivider( divider ); repaint( bounds.x, bounds.y, bounds.width, bounds.height ); bounds = current.getDividerBounds( divider, bounds ); repaint( bounds.x, bounds.y, bounds.width, bounds.height ); } } } }
public void mouseDragged( MouseEvent e ){ if( station.isResizingEnabled() && !station.isDisabled() ) { if( pressed && current != null ) { divider = current.getDividerAt( e.getX() + deltaX, e.getY() + deltaY ); divider = current.validateDivider( divider ); repaint( bounds.x, bounds.y, bounds.width, bounds.height ); bounds = current.getDividerBounds( divider, bounds ); repaint( bounds.x, bounds.y, bounds.width, bounds.height ); if( station.isContinousDisplay() && current != null ) { setDivider( current, divider ); station.updateBounds(); } } } }
@Override public void mousePressed( MouseEvent e ){ if( station.isResizingEnabled() && !station.isDisabled() ) { if( !pressed ) { pressed = true; mouseMoved( e ); if( current != null ) { divider = current.getDividerAt( e.getX() + deltaX, e.getY() + deltaY ); divider = current.validateDivider( divider ); repaint( bounds.x, bounds.y, bounds.width, bounds.height ); bounds = current.getDividerBounds( divider, bounds ); repaint( bounds.x, bounds.y, bounds.width, bounds.height ); } } } }
public void mouseDragged( MouseEvent e ){ if( station.isResizingEnabled() && !station.isDisabled() ) { if( pressed && current != null ) { divider = current.getDividerAt( e.getX() + deltaX, e.getY() + deltaY ); divider = current.validateDivider( divider ); repaint( bounds.x, bounds.y, bounds.width, bounds.height ); bounds = current.getDividerBounds( divider, bounds ); repaint( bounds.x, bounds.y, bounds.width, bounds.height ); if( station.isContinousDisplay() && current != null ) { setDivider( current, divider ); station.updateBounds(); } } } }
/** * Creates a new {@link Handler} for <code>station</code>. * @param station the station which is to be monitored * @return the new handler, not <code>null</code> */ protected Handler createHandlerFor( SplitDockStation station ){ return new Handler( station ); }
/** * Creates a new {@link Handler} for <code>station</code>. * @param station the station which is to be monitored * @return the new handler, not <code>null</code> */ protected Handler createHandlerFor( SplitDockStation station ){ return new Handler( station ); }
public void uninstall( SplitDockStation station ){ Handler handler = handlers.remove( station ); if( handler != null ){ handler.destroy(); } }
public void install( SplitDockStation station, Component container ){ Handler handler = createHandlerFor( station ); handler.install( container ); handlers.put( station, handler ); }
public void install( SplitDockStation station, Component container ){ Handler handler = createHandlerFor( station ); handler.install( container ); handlers.put( station, handler ); }
public void paint( SplitDockStation station, Graphics g ){ Handler handler = handlers.get( station ); if( handler != null ){ handler.paint( g ); } }