/** * Paints a line at the current location of the divider. * * @param g the Graphics used to paint */ public void paint(Graphics g) { if (station.isResizingEnabled() && !station.isDisabled()) { if (current != null && pressed) { station.getPaint().drawDivider(g, bounds); } } }
@Override public void mouseExited(MouseEvent e) { if (station.isResizingEnabled()) { if (!pressed) { current = null; setCursor(null); } } }
@Override public void mousePressed(MouseEvent e) { if (station.isResizingEnabled()) { if (!pressed) { pressed = true; mouseMoved(e); if (current != null) { divider = current.getDividerAt(e.getX() + deltaX, e.getY() + deltaY); 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(); } } } }
public void mouseMoved(MouseEvent e) { if (station.isResizingEnabled()) { current = station.getRoot().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.getDivider(), bounds); deltaX = bounds.width / 2 + bounds.x - e.getX(); deltaY = bounds.height / 2 + bounds.y - e.getY(); } } }
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; } } }