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

The following are Jave code examples for showing how to use isControlDown() 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: sstore-soft   File: TableSorter.java   View Source Code Vote up 8 votes
public void mouseClicked(MouseEvent e) {

            JTableHeader     h           = (JTableHeader) e.getSource();
            TableColumnModel columnModel = h.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX());
            int column = columnModel.getColumn(viewColumn).getModelIndex();

            if (column != -1) {
                int status = getSortingStatus(column);

                if (!e.isControlDown()) {
                    cancelSorting();
                }

                // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
                // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed.
                status = status + (e.isShiftDown() ? -1
                                                   : 1);
                status = (status + 4) % 3 - 1;    // signed mod, returning {-1, 0, 1}

                setSortingStatus(column, status);
            }
        }
 
Example 2
Project: VISNode   File: JNodeContainer.java   View Source Code Vote up 6 votes
@Override
public void mouseReleased(MouseEvent e) {
    if (e.getSource() instanceof JNode) {
        // If there weren't multiple selection or component has draged
        if (!e.isControlDown() || !e.getLocationOnScreen().equals(pressedPosition)) {
            return;
        }
        JNode node = (JNode) e.getSource();
        // It is a new node
        if (!oldSelection.contains(node)) {
            return;
        }
        selection.remove(node);
        node.repaint();
    }
}
 
Example 3
Project: geomapapp   File: XYGraph.java   View Source Code Vote up 6 votes
void checkEdge(MouseEvent e) {
	if( e.isControlDown() )return;
	if( !(xy instanceof ScalableXYPoints) )return;
	int[] wesn = getWESN();
	int cursor = 0;
	int x = e.getX();
	int y = e.getY();
	if( tracksWidth || scPane==null) {
		if( (int)Math.abs(x-wesn[0])<2 ) cursor=10;
		else if( (int)Math.abs(x-wesn[1])<2 ) cursor=11;
	}
	if( (tracksHeight || scPane==null) && cursor==0 ) {
		if( (int)Math.abs(y-wesn[2])<2 ) cursor=8;
		else if( (int)Math.abs(y-wesn[3])<2 ) cursor=9;
	}
	setCursor(cursor);
}
 
Example 4
Project: ramus   File: GEFComponent.java   View Source Code Vote up 6 votes
@Override
public void mousePressed(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON1) {
        Bounds[] bounds = selection.getBounds();
        mousePressed(translateMouseEvent(e));
        if (e.isControlDown()) {
            Bounds[] bounds2 = selection.getBounds();
            if (!Arrays.equals(bounds, bounds2)) {
                Bounds[] bounds3 = Arrays.copyOf(bounds, bounds.length
                        + bounds2.length);
                for (int i = 0; i < bounds2.length; i++) {
                    bounds3[i + bounds.length] = bounds2[i];
                }
                selection.setBounds(bounds3);
                selectionChanged();
            }
        }
    }
}
 
Example 5
Project: incubator-netbeans   File: TableSorter.java   View Source Code Vote up 6 votes
public void mouseClicked(MouseEvent e) {
    JTableHeader h = (JTableHeader) e.getSource();
    TableColumnModel columnModel = h.getColumnModel();
    int viewColumn = columnModel.getColumnIndexAtX(e.getX());
    int column = columnModel.getColumn(viewColumn).getModelIndex();
    if (column != -1) {
        int status = getSortingStatus(column);
        if (!e.isControlDown()) {
            cancelSorting();
        }
        // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or 
        // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed. 
        status = status + (e.isShiftDown() ? -1 : 1);
        status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
        setSortingStatus(column, status);
    }
}
 
Example 6
Project: VASSAL-src   File: RegionGrid.java   View Source Code Vote up 6 votes
public void mousePressed(MouseEvent e) {
  final Point p = e.getPoint();
  lastClick = p;
  lastClickedRegion = grid.getRegion(p);

  if (!e.isShiftDown() && !e.isControlDown() &&
      (lastClickedRegion==null || !lastClickedRegion.isSelected())) {
    unSelectAll();
  }

  if (lastClickedRegion == null) {
    anchor = p;
    selectionRect = new Rectangle(anchor.x, anchor.y, 0, 0);
  }
  else {
    if (e.isControlDown()) {
      unselect(lastClickedRegion);
    }
    else {
      select(lastClickedRegion);
    }
  }
}
 
Example 7
Project: Tarski   File: mxGraphHandler.java   View Source Code Vote up 6 votes
/**
 * 
 * @param dx
 * @param dy
 * @param e
 */
protected void moveCells(Object[] cells, double dx, double dy, Object target, MouseEvent e) {
  mxGraph graph = graphComponent.getGraph();
  boolean clone = e.isControlDown() && isCloneEnabled();

  if (clone) {
    cells = graph.getCloneableCells(cells);
  }

  if (cells.length > 0) {
    // Removes cells from parent
    if (target == null && isRemoveCellsFromParent()
        && shouldRemoveCellFromParent(graph.getModel().getParent(initialCell), cells, e)) {
      target = graph.getDefaultParent();
    }

    Object[] tmp = graph.moveCells(cells, dx, dy, clone, target, e.getPoint());

    if (isSelectEnabled() && clone && tmp != null && tmp.length == cells.length) {
      graph.setSelectionCells(tmp);
    }
  }
}
 
Example 8
Project: OrthancAnonymization   File: TablePatientsMouseListener.java   View Source Code Vote up 6 votes
@Override
public void mousePressed(MouseEvent event) {
	this.modeleStudies.clear();
	this.modeleSeries.clear();
	if(!event.isControlDown()){
		// selects the row at which point the mouse is clicked
		Point point = event.getPoint();
		int currentRow = tableau.rowAtPoint(point);
		tableau.setRowSelectionInterval(currentRow, currentRow);
	}
	try {
		if(this.modele.getRowCount() != 0){
			String patientName = (String)this.tableau.getValueAt(this.tableau.getSelectedRow(), 0);
			String patientID = (String)this.tableau.getValueAt(this.tableau.getSelectedRow(), 1);
			String patientUID = (String)this.tableau.getValueAt(this.tableau.getSelectedRow(), 2);
			this.modeleStudies.addStudy(patientName, patientID, patientUID);
			this.tableauStudies.setRowSelectionInterval(0,0);
		}
	}catch (Exception e1) {
		e1.printStackTrace();
	}
	frame.pack();
}
 
Example 9
Project: Logisim   File: TableSorter.java   View Source Code Vote up 6 votes
@Override
public void mouseClicked(MouseEvent e) {
	JTableHeader h = (JTableHeader) e.getSource();
	TableColumnModel columnModel = h.getColumnModel();
	int viewColumn = columnModel.getColumnIndexAtX(e.getX());
	int column = columnModel.getColumn(viewColumn).getModelIndex();
	if (column != -1) {
		int status = getSortingStatus(column);
		if (!e.isControlDown()) {
			cancelSorting();
		}
		// Cycle the sorting states through {NOT_SORTED, ASCENDING,
		// DESCENDING} or
		// {NOT_SORTED, DESCENDING, ASCENDING} depending on whether
		// shift is pressed.
		status = status + (e.isShiftDown() ? -1 : 1);
		status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0,
										// 1}
		setSortingStatus(column, status);
	}
}
 
Example 10
Project: geomapapp   File: LineSegmentsObject.java   View Source Code Vote up 6 votes
public void mouseReleased( MouseEvent evt ) {
	if( editShape==null ) {
		currentPoint = -1;
		return;
	}
	drawEdit();
	editShape = null;
	if( evt.isControlDown() || evt.getWhen()-when<500L ) {
		currentPoint = -1;
		return;
	}
	Point2D.Double p = (Point2D.Double)map.getScaledPoint( evt.getPoint() );
	double[] xyz = (double[])points.get( currentPoint );
	xyz[0] = p.x - currentOffset;
	xyz[1] = p.y;
	xyz[2] = getZ(p);
	fireTableRowsUpdated(currentPoint, currentPoint);
	dig.makeProfile();
	map.repaint();
	
}
 
Example 11
Project: Tarski   File: mxGraphComponent.java   View Source Code Vote up 5 votes
/**
 * 
 * @param event
 * @return Returns true if the given event should toggle selected cells.
 */
public boolean isToggleEvent(MouseEvent event) {
  // NOTE: IsMetaDown always returns true for right-clicks on the Mac, so
  // toggle selection for left mouse buttons requires CMD key to be pressed,
  // but toggle for right mouse buttons requires CTRL to be pressed.
  return (event != null) ? ((mxUtils.IS_MAC)
      ? ((SwingUtilities.isLeftMouseButton(event) && event.isMetaDown())
          || (SwingUtilities.isRightMouseButton(event) && event.isControlDown()))
      : event.isControlDown()) : false;
}
 
Example 12
Project: incubator-netbeans   File: DropTargetLayer.java   View Source Code Vote up 5 votes
public static boolean isMultiselectPressed(MouseEvent evt) {
    if(evt.isShiftDown()) {
        return true;
    }
    if(!isAqua() && evt.isControlDown()) {
        return true;
    }
    return false;
}
 
Example 13
Project: jaer   File: HumanVsComputerThrottleController.java   View Source Code Vote up 5 votes
private boolean isControl(MouseEvent e) {
    if (!e.isShiftDown() && e.isControlDown() && !e.isAltDown()) {
        return true;
    } else {
        return false;
    }
}
 
Example 14
Project: geomapapp   File: PDB.java   View Source Code Vote up 5 votes
public void mouseClicked(MouseEvent e) {
	if(e.isControlDown())return;
	Point2D p = map.getScaledPoint( e.getPoint() );
	int index = getClickedIndex(p);
	if( index==-1 ) {
		if(e.isShiftDown()) return;
		table.clearSelection();
		current = -1;
	} else if(e.isShiftDown()) {
		if( index==current) {
			table.removeRowSelectionInterval(index, index);
			table.getRowHeader().setSelectedIndices(table.getSelectedRows());
			current = -1;
			return;
		}
		current = index;
		table.addRowSelectionInterval(index, index);
		table.getRowHeader().setSelectedIndices(table.getSelectedRows());
		table.ensureIndexIsVisible( index);
		table.getRowHeader().repaint();
	} else {
		current = index;
		table.setRowSelectionInterval(index, index);
		table.getRowHeader().setSelectedIndices(table.getSelectedRows());
		table.ensureIndexIsVisible( index);
		table.getRowHeader().repaint();
	}
	return;
}
 
Example 15
Project: onprom   File: AttributeTable.java   View Source Code Vote up 5 votes
@Override
public void mouseClicked(MouseEvent e) {
    if (e.getClickCount() == 2 || e.isPopupTrigger()) {
        if (e.isControlDown()) {
            if (getSelectedRow() > -1) {
                removeSelectedAttribute();
            }
        } else {
            addEmptyAttribute();
        }
    }
}
 
Example 16
Project: incubator-netbeans   File: TableSorter.java   View Source Code Vote up 4 votes
@Override
public void mouseClicked(MouseEvent e) {
    JTableHeader h = (JTableHeader) e.getSource();
    JTable table = h.getTable();
    int selectedRow = table.getSelectedRow();
    TableModel model = table.getModel();
    //remember selection to keep after sorting
    Object selectedAction=null;
    int objectColumn=-1;
    if(selectedRow>-1) {
        for(int i=0; i<table.getColumnCount(); i++) {
            //first find colum with appropriate object
            if(model.getValueAt(selectedRow, i) instanceof ActionHolder) {
                //remember this object
                selectedAction=model.getValueAt(selectedRow, i);
                objectColumn=i;
                //stop edition as we click somewhere ouside of editor
                TableCellEditor editor=table.getCellEditor();
                if(editor!=null) {
                    editor.stopCellEditing();
                }
                break;
            }
        }
    }
    TableColumnModel columnModel = h.getColumnModel();
    int viewColumn = columnModel.getColumnIndexAtX(e.getX());
    int column = columnModel.getColumn(viewColumn).getModelIndex();
    if (column != -1) {
        int status = getSortingStatus(column);
        if (!e.isControlDown()) {
            cancelSorting();
        }
        // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or 
        // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed. 
        status = status + (e.isShiftDown() ? -1 : 1);
        status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
        setSortingStatus(column, status);
        //reselect the same object
        if(selectedAction!=null)setSelectedRow(table, selectedAction, objectColumn);
    }
}
 
Example 17
Project: geomapapp   File: LineSegmentsObject.java   View Source Code Vote up 4 votes
public void mousePressed( MouseEvent evt ) {
	//finish drawing segment on double click
	if (evt.getClickCount() == 2 && !evt.isConsumed() && dig.startStopBtn.isSelected()) {
		evt.consume();
		dig.finish();
		return;
	}
	
       if (dig.startStopBtn.isSelected()){
		dig.startStopBtn.setForeground(Color.RED);
       	dig.startStopBtn.setText("Stop digitizing");
       } 
	if( evt.isControlDown() || !selected ) return;
	double zoom = map.getZoom();
	double r = 5/zoom;
	Point2D.Double p = (Point2D.Double)map.getScaledPoint( evt.getPoint() );
	double wrap = map.getWrap();
	for( int i=0 ; i<points.size() ; i++) {
		double[] xyz = (double[])points.get(i);
		if( p.y<xyz[1]-r || p.y>xyz[1]+r )continue;
		currentOffset = 0.;
		if( wrap>0. ) {
			while( p.x<xyz[0]-wrap/2. ) {
				currentOffset -= wrap;
				p.x+=wrap;
			}
			while( p.x>xyz[0]+wrap/2. ) {
				currentOffset += wrap;
				p.x-=wrap;
			}
		}
		if( p.x<xyz[0]-r || p.x>xyz[0]+r )continue;
		when = evt.getWhen();
		currentPoint = i;
		//highlight in table
		try {
			dig.table.setRowSelectionInterval(currentPoint, currentPoint);
	        dig.deletePtsBtn.setEnabled(true);	
			if (SwingUtilities.isRightMouseButton(evt)) {
				rightClickMenu.show(evt.getComponent(), evt.getX(), evt.getY());
			} else {
				mouseDragged( evt );
			}
			return;
			} 
		catch(Exception e) {
			System.out.println(e);
			continue;
		}
		
	}
	currentPoint = -1;
}
 
Example 18
Project: ramus   File: Handler.java   View Source Code Vote up 4 votes
@Override
public void mouseDragged(final MouseEvent me) {
    ourDraggingWindow = getDraggingWindow();
    if (ourDraggingWindow == null)
        return;

    // Only allow Button 1 to perform the drag...
    if ((me.getModifiers() & InputEvent.BUTTON1_MASK) != InputEvent.BUTTON1_MASK) {
        hideDraggingWindow();
        return;
    }

    final Container target = ourDockLayout.getTargetContainer();
    if (target == null)
        return;

    Point p = me.getPoint();
    p = SwingUtilities.convertPoint(ourToolBar, p, target);

    // Make sure the DockBoundary containing this point
    // and this toolbar wishes to allow the drag operation
    // to commence or continue...
    if (!isDraggable(p, ourToolBar)) {
        hideDraggingWindow();
        return;
    }

    // Determine if this point lies within a
    // DockBoundary's dockable range...
    int orient = ToolBarLayout.HORIZONTAL;
    boolean dockable = false;

    if (!me.isControlDown()) {
        final DockBoundary dock = getDockableBoundary(p);

        if (dock != null) {
            dockable = true;
            orient = dock.getOrientation();
        }
    }

    // Present the dragging window at this point on the screen...
    SwingUtilities.convertPointToScreen(p, target);
    ourDraggingWindow.presentWindow(p, dockable, orient);
    ourToolBarIsDragging = true;

}
 
Example 19
Project: TrabalhoFinalEDA2   File: mxGraphComponent.java   View Source Code Vote up 2 votes
/**
 * 
 * @param event
 * @return Returns true if the given event should toggle selected cells.
 */
public boolean isCloneEvent(MouseEvent event)
{
	return (event != null) ? event.isControlDown() : false;
}
 
Example 20
Project: TrabalhoFinalEDA2   File: mxGraphComponent.java   View Source Code Vote up 2 votes
/**
 * Note: This is not used during drag and drop operations due to limitations
 * of the underlying API. To enable this for move operations set dragEnabled
 * to false.
 * 
 * @param event
 * @return Returns true if the given event is a panning event.
 */
public boolean isPanningEvent(MouseEvent event)
{
	return (event != null) ? event.isShiftDown() && event.isControlDown()
			: false;
}