Java Code Examples for java.awt.event.MouseEvent.consume()

The following are Jave code examples for showing how to use consume() of the java.awt.event.MouseEvent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: TrabalhoFinalEDA2   File: mxPanningHandler.java   View Source Code Vote up 6 votes
/**
 * 
 */
public void mouseReleased(MouseEvent e)
{
	if (!e.isConsumed() && start != null)
	{
		int dx = Math.abs(start.x - e.getX());
		int dy = Math.abs(start.y - e.getY());

		if (graphComponent.isSignificant(dx, dy))
		{
			e.consume();
		}
	}

	start = null;
}
 
Example 2
Project: Panako   File: StreamLayer.java   View Source Code Vote up 6 votes
@Override
public void mouseMoved(MouseEvent e) {
	if(graphics!=null){
		float spacer = LayerUtilities.pixelsToUnits(graphics, 20, false);
		float heightOfABlock = LayerUtilities.pixelsToUnits(graphics, 30, false);		
		int verticalOffsetOffset = -1 * (Math.round((index + 1) * spacer + index * heightOfABlock));
		int startHeight = verticalOffsetOffset ;
		int stopHeight = verticalOffsetOffset + Math.round(heightOfABlock); 

		Point2D pointInUnits = LayerUtilities.pixelsToUnits(graphics, e.getX(), e.getY());
		int startTime = Math.round(guessedStartTimeOfStream);
		int stopTime = Math.round(guessedStartTimeOfStream+streamDuration);
		
		if(pointInUnits.getX() >= startTime && pointInUnits.getX() <= stopTime && pointInUnits.getY() >= startHeight &&  pointInUnits.getY() <= stopHeight){
			((JComponent)(e.getSource())).setCursor(new Cursor(Cursor.HAND_CURSOR));
			e.consume();
		}
	}
}
 
Example 3
Project: incubator-netbeans   File: AbstractQuickSearchComboBar.java   View Source Code Vote up 6 votes
private void mouseClickedOnItem(MouseEvent e) {
    if (SwingUtilities.isRightMouseButton(e)) {
        e.consume();
        if (isSelected()) {
            Iterator<Category> iterator = evalCats.iterator();
            while (iterator.hasNext()) {
                Category c = iterator.next();
                if (!CommandEvaluator.RECENT.equals(c.getName())) {
                    iterator.remove();
                }
            }
            evalCats.add(category);
        } else {
            evalCats.addAll(
                    ProviderModel.getInstance().getCategories());
            evalCats.remove(category);
        }
        updateCheckBoxes(CategoryCheckBoxMenuItem.this, evalCats);
        updateCats(evalCats);
    }
}
 
Example 4
Project: jmt   File: ConnectState.java   View Source Code Vote up 6 votes
@Override
public void handleDrag(MouseEvent e) {
	if (firstPort != null) {
		if (!e.isConsumed()) {
			Graphics2D g = mediator.getGraphGraphics();
			Color bg = mediator.getGraphBackground();
			Color fg = Color.BLACK;
			g.setColor(fg);
			g.setXORMode(bg);
			overlay(g);

			current = mediator.snap(e.getPoint());
			port = getInPortViewAt(e.getX(), e.getY());
			if (port != null) {
				current = mediator.toScreen(port.getLocation(null));
			}

			g.setColor(bg);
			g.setXORMode(fg);
			overlay(g);
			e.consume();
		}
	}
}
 
Example 5
Project: Tarski   File: mxGraphHandler.java   View Source Code Vote up 6 votes
/**
 * 
 */
public void mousePressed(MouseEvent e) {
  if (graphComponent.isEnabled() && isEnabled() && !e.isConsumed()
      && !graphComponent.isForceMarqueeEvent(e)) {
    cell = graphComponent.getCellAt(e.getX(), e.getY(), false);
    initialCell = cell;

    if (cell != null) {
      if (isSelectEnabled() && !graphComponent.getGraph().isCellSelected(cell)) {
        graphComponent.selectCellForEvent(cell, e);
        cell = null;
      }

      // Starts move if the cell under the mouse is movable and/or any
      // cells of the selection are movable
      if (isMoveEnabled() && !e.isPopupTrigger()) {
        start(e);
        e.consume();
      }
    } else if (e.isPopupTrigger()) {
      graphComponent.getGraph().clearSelection();
    }
  }
}
 
Example 6
Project: TrabalhoFinalEDA2   File: mxGraphHandler.java   View Source Code Vote up 6 votes
/**
 * 
 */
public void mouseMoved(MouseEvent e)
{
	if (graphComponent.isEnabled() && isEnabled() && !e.isConsumed())
	{
		Cursor cursor = getCursor(e);

		if (cursor != null)
		{
			graphComponent.getGraphControl().setCursor(cursor);
			e.consume();
		}
		else
		{
			graphComponent.getGraphControl().setCursor(DEFAULT_CURSOR);
		}
	}
}
 
Example 7
Project: TrabalhoFinalEDA2   File: mxVertexHandler.java   View Source Code Vote up 6 votes
/**
 * 
 */
public void mouseReleased(MouseEvent e)
{
	if (!e.isConsumed() && first != null)
	{
		if (preview != null && preview.isVisible())
		{
			if (isLabel(index))
			{
				moveLabel(e);
			}
			else
			{
				resizeCell(e);
			}
		}

		e.consume();
	}

	super.mouseReleased(e);
}
 
Example 8
Project: incubator-netbeans   File: BasicTabDisplayerUI.java   View Source Code Vote up 5 votes
private void performCommand (String command, int idx, MouseEvent evt) {
    evt.consume();
    if (TabDisplayer.COMMAND_SELECT == command) {
        if (idx != displayer.getSelectionModel().getSelectedIndex()) {
            boolean go = shouldPerformAction (command, idx, evt);
            if (go) {
                selectionModel.setSelectedIndex (idx);
            }
        }
    } else {
        boolean should = shouldPerformAction (command, idx, evt) && displayer.isShowCloseButton();
        if (should) {
            if (TabDisplayer.COMMAND_CLOSE == command) {
                displayer.getModel().removeTab(idx);
            } else if (TabDisplayer.COMMAND_CLOSE_ALL == command) {
                displayer.getModel().removeTabs (0, displayer.getModel().size());
            } else if (TabDisplayer.COMMAND_CLOSE_ALL_BUT_THIS == command) {
                int start;
                int end;
                if (idx != displayer.getModel().size()-1) {
                    start = idx+1;
                    end = displayer.getModel().size();
                    displayer.getModel().removeTabs(start, end);
                }
                if (idx != 0) {
                    start = 0;
                    end = idx;
                    displayer.getModel().removeTabs(start, end);
                }
            }
        }
    }
}
 
Example 9
Project: Tarski   File: mxRubberband.java   View Source Code Vote up 5 votes
/**
 * 
 */
public void mousePressed(MouseEvent e) {
  if (!e.isConsumed() && isEnabled() && isRubberbandTrigger(e) && !e.isPopupTrigger()) {
    start(e.getPoint());
    e.consume();
  }
}
 
Example 10
Project: Tarski   File: BasicGraphEditor.java   View Source Code Vote up 5 votes
/**
 * 
 */
protected void showGraphPopupMenu(MouseEvent e)
{
	Point pt = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(),
			graphComponent);
	EditorPopupMenu menu = new EditorPopupMenu(BasicGraphEditor.this);
	menu.show(graphComponent, pt.x, pt.y);

	e.consume();
}
 
Example 11
Project: incubator-netbeans   File: TaskListTable.java   View Source Code Vote up 5 votes
private void maybePopup( MouseEvent e ) {
    if( e.isPopupTrigger() ) {
        e.consume();
        int row = rowAtPoint( e.getPoint() );
        if( row >= 0 )
            getSelectionModel().setSelectionInterval( row, row );
        JPopupMenu popup = Util.createPopup( this );
        popup.show( this, e.getX(), e.getY() );
    }
}
 
Example 12
Project: TrabalhoFinalEDA2   File: mxConnectionHandler.java   View Source Code Vote up 5 votes
/**
 * 
 */
public void mouseDragged(MouseEvent e)
{
	if (!e.isConsumed() && graphComponent.isEnabled() && isEnabled())
	{
		// Activates the handler
		if (!active && first != null)
		{
			double dx = Math.abs(first.getX() - e.getX());
			double dy = Math.abs(first.getY() - e.getY());
			int tol = graphComponent.getTolerance();
			
			if (dx > tol || dy > tol)
			{
				active = true;
			}
		}
		
		if (e.getButton() == 0 || (isActive() && connectPreview.isActive()))
		{
			mxCellState state = marker.process(e);

			if (connectPreview.isActive())
			{
				connectPreview.update(e, marker.getValidState(), e.getX(),
						e.getY());
				setBounds(null);
				e.consume();
			}
			else
			{
				source = state;
			}
		}
	}
}
 
Example 13
Project: jdk8u-jdk   File: NervousText.java   View Source Code Vote up 5 votes
@Override
public synchronized void mousePressed(MouseEvent e) {
    e.consume();
    threadSuspended = !threadSuspended;
    if (!threadSuspended) {
        notify();
    }
}
 
Example 14
Project: incubator-netbeans   File: ButtonPopupSwitcher.java   View Source Code Vote up 5 votes
@Override
public void mouseMoved(MouseEvent e) {
    e.consume();
    changeSelection(e);
    pTable.onMouseEvent(e);
    isDragging = false;
}
 
Example 15
Project: smile_1.5.0_java7   File: PlotCanvas.java   View Source Code Vote up 5 votes
@Override
public void mouseReleased(MouseEvent e) {
    if (e.isPopupTrigger()) {
        popup.show(e.getComponent(), e.getX(), e.getY());
        e.consume();
    } else {
        if (mouseDraggingX != -1 && mouseDraggingY != -1) {
            mouseDraggingX = -1;
            mouseDraggingY = -1;

            if (base.dimension == 2) {
                if (Math.abs(e.getX() - mouseClickX) > 20 && Math.abs(e.getY() - mouseClickY) > 20) {
                    double[] sc1 = ((Projection2D) (graphics.projection)).inverseProjection(mouseClickX, mouseClickY);
                    double[] sc2 = ((Projection2D) (graphics.projection)).inverseProjection(e.getX(), e.getY());

                    if (Math.min(sc1[0], sc2[0]) < base.upperBound[0]
                            && Math.max(sc1[0], sc2[0]) > base.lowerBound[0]
                            && Math.min(sc1[1], sc2[1]) < base.upperBound[1]
                            && Math.max(sc1[1], sc2[1]) > base.lowerBound[1]) {

                        base.lowerBound[0] = Math.max(base.lowerBound[0], Math.min(sc1[0], sc2[0]));
                        base.upperBound[0] = Math.min(base.upperBound[0], Math.max(sc1[0], sc2[0]));
                        base.lowerBound[1] = Math.max(base.lowerBound[1], Math.min(sc1[1], sc2[1]));
                        base.upperBound[1] = Math.min(base.upperBound[1], Math.max(sc1[1], sc2[1]));

                        for (int i = 0; i < base.dimension; i++) {
                            base.setPrecisionUnit(i);
                        }
                        base.initBaseCoord();
                        graphics.projection.reset();
                        baseGrid.setBase(base);
                    }
                }
            }

            repaint();
            e.consume();
        }
    }
}
 
Example 16
Project: AgentWorkbench   File: GraphEnvironmentMousePlugin.java   View Source Code Vote up 5 votes
/**
 * This is the MouseDragged super action of the super class (because of several exceptions).
 * @param me the MouseEvent
 */
private void mouseDraggedSuperAction(MouseEvent me) {

	if(locked == false) {
           VisualizationViewer<GraphNode,GraphEdge> vv = this.basicGraphGUI.getVisualizationViewer();
           if(vertex != null) {
               Point p = me.getPoint();
               Point2D graphPoint = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(p);
               Point2D graphDown = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(down);
               Layout<GraphNode,GraphEdge> layout = vv.getGraphLayout();
               double dx = graphPoint.getX()-graphDown.getX();
               double dy = graphPoint.getY()-graphDown.getY();
               PickedState<GraphNode> ps = vv.getPickedVertexState();
               
               for(GraphNode v : ps.getPicked()) {
                   Point2D vp = layout.transform(v);
                   vp.setLocation(vp.getX()+dx, vp.getY()+dy);
                   layout.setLocation(v, vp);
               }
               down = p;
               me.consume();
               vv.repaint();
               
           } else {
               Point2D out = me.getPoint();
               if(me.getModifiers() == this.addToSelectionModifiers || me.getModifiers() == modifiers) {
                   if (down!=null) {
                   	rect.setFrameFromDiagonal(down,out);
                   	vv.repaint();
                   }
               }
           }
       }
}
 
Example 17
Project: incubator-netbeans   File: AbstractListUI.java   View Source Code Vote up 4 votes
private boolean redispatchComponent(MouseEvent e) {
    Point p = e.getPoint();
    int index = list.locationToIndex(p);
    if (index < 0 || index >= list.getModel().getSize()) {
        return false;
    }

    ListCellRenderer renderer = list.getCellRenderer();
    if (null == renderer) {
        return false;
    }
    Component renComponent = renderer.getListCellRendererComponent(list, list.getModel().getElementAt(index), index, false, false);
    if (null == renComponent) {
        return false;
    }
    Rectangle rect = list.getCellBounds(index, index);
    if (null == rect) {
        return false;
    }
    renComponent.setBounds(0, 0, rect.width, rect.height);
    renComponent.doLayout();
    Point p3 = rect.getLocation();

    Point p2 = new Point(p.x - p3.x, p.y - p3.y);
    Component dispatchComponent =
            SwingUtilities.getDeepestComponentAt(renComponent,
            p2.x, p2.y);
    if ( e.isPopupTrigger() &&
         dispatchComponent instanceof LinkButton && 
         !((LinkButton)dispatchComponent).isHandlingPopupEvents() ) 
    {
        return false;
    } 
    if (dispatchComponent instanceof AbstractButton) {
        if (!((AbstractButton) dispatchComponent).isEnabled()) {
            return false;
        }
        Point p4 = SwingUtilities.convertPoint(renComponent, p2, dispatchComponent);
        MouseEvent newEvent = new MouseEvent(dispatchComponent,
                e.getID(),
                e.getWhen(),
                e.getModifiers(),
                p4.x, p4.y,
                e.getClickCount(),
                e.isPopupTrigger(),
                MouseEvent.NOBUTTON);
        dispatchComponent.dispatchEvent(newEvent);
        list.repaint(rect);
        e.consume();
        return true;
    }
    return false;
}
 
Example 18
Project: incubator-netbeans   File: MethodChooser.java   View Source Code Vote up 4 votes
@Override
public void mouseExited(MouseEvent e) {
    e.consume();
}
 
Example 19
Project: incubator-netbeans   File: MethodChooser.java   View Source Code Vote up 4 votes
@Override
public void mousePressed(MouseEvent e) {
    e.consume();
}
 
Example 20
Project: TrabalhoFinalEDA2   File: mxRotationHandler.java   View Source Code Vote up 4 votes
/**
 * 
 */
public void mouseMoved(MouseEvent e)
{
	if (graphComponent.isEnabled() && isEnabled())
	{
		if (handle.getParent() != null && e.getSource() == handle /* mouse hits handle */)
		{
			graphComponent.getGraphControl().setCursor(
					new Cursor(Cursor.HAND_CURSOR));
			e.consume();
		}
		else if (currentState == null
				|| !currentState.getRectangle().contains(e.getPoint()))
		{
			mxCellState eventState = graphComponent
					.getGraph()
					.getView()
					.getState(
							graphComponent.getCellAt(e.getX(), e.getY(),
									false));

			mxCellState state = null;

			if (eventState != null && isStateHandled(eventState))
			{
				state = eventState;
			}

			if (currentState != state)
			{
				currentState = state;

				if (currentState == null && handle.getParent() != null)
				{
					handle.setVisible(false);
					handle.getParent().remove(handle);
				}
				else if (currentState != null)
				{
					if (handle.getParent() == null)
					{
						// Adds component for rendering the handles (preview is separate)
						graphComponent.getGraphControl().add(handle, 0);
						handle.setVisible(true);
					}

					handle.setLocation(
							(int) (currentState.getX()
									+ currentState.getWidth()
									- handle.getWidth() - 4),
							(int) (currentState.getY()
									+ currentState.getHeight()
									- handle.getWidth() - 4));
				}
			}
		}
	}
}