/** * Uses getCell, getMarkedState and intersects to return the state for * the given event. */ protected mxCellState getState(MouseEvent e) { Object cell = getCell(e); mxGraphView view = graphComponent.getGraph().getView(); mxCellState state = getStateToMark(view.getState(cell)); return (state != null && intersects(state, e)) ? state : null; }
/** * Paints the outline of the markedState with the currentColor. */ public void paint(Graphics g) { if (markedState != null && currentColor != null) { ((Graphics2D) g).setStroke(DEFAULT_STROKE); g.setColor(currentColor); if (markedState.getAbsolutePointCount() > 0) { Point last = markedState.getAbsolutePoint(0).getPoint(); for (int i = 1; i < markedState.getAbsolutePointCount(); i++) { Point current = markedState.getAbsolutePoint(i).getPoint(); g.drawLine(last.x - getX(), last.y - getY(), current.x - getX(), current.y - getY()); last = current; } } else { g.drawRect(1, 1, getWidth() - 3, getHeight() - 3); } } }
/** * Processes the given event and marks the state returned by getStateAt * with the color returned by getMarkerColor. If the markerColor is not * null, then the state is stored in markedState. If isValidState returns * true, then the state is stored in validState regardless of the marker * color. The state is returned regardless of the marker color and * valid state. */ public mxCellState process(MouseEvent e) { mxCellState state = null; if (isEnabled()) { state = getState(e); boolean valid = (state != null) ? isValidState(state) : false; Color color = getMarkerColor(e, state, valid); highlight(state, color, valid); } return state; }
/** * Hides the marker and fires a mxEvent.MARK event. */ public void unmark() { if (getParent() != null) { setVisible(false); getParent().remove(this); eventSource.fireEvent(new mxEventObject(mxEvent.MARK)); } }
final mxCellState markedState = marker.getMarkedState(); Object target = ( markedState != null ) ? markedState.getCell() : null; final mxCellState targetState = marker.getValidState(); final Object target = ( targetState != null ) ? targetState.getCell() : null;
/** * Marks the markedState and fires a mxEvent.MARK event. */ public void mark() { if (markedState != null) { Rectangle bounds = markedState.getRectangle(); bounds.grow(3, 3); bounds.width += 1; bounds.height += 1; setBounds(bounds); if (getParent() == null) { setVisible(true); if (KEEP_ON_TOP) { graphComponent.getGraphControl().add(this, 0); } else { graphComponent.getGraphControl().add(this); } } repaint(); eventSource.fireEvent(new mxEventObject(mxEvent.MARK, "state", markedState)); } }
/** * */ public void mousePressed(MouseEvent e) { if (!graphComponent.isForceMarqueeEvent(e) && !graphComponent.isPanningEvent(e) && !e.isPopupTrigger() && graphComponent.isEnabled() && isEnabled() && !e.isConsumed() && ((isHighlighting() && marker.hasValidState()) || (!isHighlighting() && bounds != null && bounds.contains(e.getPoint())))) { start(e, marker.getValidState()); e.consume(); } }
mxCellState state = marker.process(e); connectPreview.update(e, marker.getValidState(), e.getX(), e.getY()); setBounds(null);
protected Object getCell(MouseEvent e) { Object cell = super.getCell(e); if (isConnecting()) { if (source != null) { error = validateConnection(source.getCell(), cell); if (error != null && error.length() == 0) { cell = null; // Enables create target inside groups if (createTarget) { error = null; } } } } else if (!isValidSource(cell)) { cell = null; } return cell; }
protected Color getMarkerColor(MouseEvent e, mxCellState state, boolean isValid) { return (isHighlighting() || isConnecting()) ? super .getMarkerColor(e, state, isValid) : null; }
/** * Processes the given event and marks the state returned by getStateAt * with the color returned by getMarkerColor. If the markerColor is not * null, then the state is stored in markedState. If isValidState returns * true, then the state is stored in validState regardless of the marker * color. The state is returned regardless of the marker color and * valid state. */ public mxCellState process(MouseEvent e) { mxCellState state = null; if (isEnabled()) { state = getState(e); boolean valid = (state != null) ? isValidState(state) : false; Color color = getMarkerColor(e, state, valid); highlight(state, color, valid); } return state; }
final mxCellState markedState = marker.getMarkedState(); Object target = ( markedState != null ) ? markedState.getCell() : null; final mxCellState targetState = marker.getValidState(); final Object target = ( targetState != null ) ? targetState.getCell() : null;
/** * Marks the markedState and fires a mxEvent.MARK event. */ public void mark() { if (markedState != null) { Rectangle bounds = markedState.getRectangle(); bounds.grow(3, 3); bounds.width += 1; bounds.height += 1; setBounds(bounds); if (getParent() == null) { setVisible(true); if (KEEP_ON_TOP) { graphComponent.getGraphControl().add(this, 0); } else { graphComponent.getGraphControl().add(this); } } repaint(); eventSource.fireEvent(new mxEventObject(mxEvent.MARK, "state", markedState)); } }
/** * */ public void mousePressed(MouseEvent e) { if (!graphComponent.isForceMarqueeEvent(e) && !graphComponent.isPanningEvent(e) && !e.isPopupTrigger() && graphComponent.isEnabled() && isEnabled() && !e.isConsumed() && ((isHighlighting() && marker.hasValidState()) || (!isHighlighting() && bounds != null && bounds.contains(e.getPoint())))) { start(e, marker.getValidState()); e.consume(); } }
mxCellState state = marker.process(e); connectPreview.update(e, marker.getValidState(), e.getX(), e.getY()); setBounds(null);
protected Object getCell(MouseEvent e) { Object cell = super.getCell(e); if (isConnecting()) { if (source != null) { error = validateConnection(source.getCell(), cell); if (error != null && error.length() == 0) { cell = null; // Enables create target inside groups if (createTarget) { error = null; } } } } else if (!isValidSource(cell)) { cell = null; } return cell; }
/** * Hides the marker and fires a mxEvent.MARK event. */ public void unmark() { if (getParent() != null) { setVisible(false); getParent().remove(this); eventSource.fireEvent(new mxEventObject(mxEvent.MARK)); } }
protected Color getMarkerColor(MouseEvent e, mxCellState state, boolean isValid) { return (isHighlighting() || isConnecting()) ? super .getMarkerColor(e, state, isValid) : null; }
mxCellState markedState = marker.getMarkedState(); Object target = (markedState != null) ? markedState.getCell() : null; mxCellState targetState = marker.getValidState(); Object target = (targetState != null) ? targetState.getCell() : null;