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

The following are Jave code examples for showing how to use isShiftDown() 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: parabuild-ci   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 2
Project: parabuild-ci   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 3
Project: dev-courses   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  = h.columnAtPoint(e.getPoint());
            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 4
Project: QN-ACTR-Release   File: RowHeader.java   View Source Code Vote up 6 votes
@Override
public void mousePressed(MouseEvent e) {
	stopEditing(table);
	row0 = rowAtPoint(e.getPoint());
	int row0b = row0;
	if (row0 >= 0) {
		if (e.isShiftDown()) {
			row0b = table.getSelectionModel().getAnchorSelectionIndex();
		}
		table.setRowSelectionInterval(row0b, row0);
		table.setColumnSelectionInterval(0, table.getColumnCount() - 1);
		//selectionModel.setAnchorSelectionIndex(0);
		//columnModel.getSelectionModel().setAnchorSelectionIndex(col0);
		table.requestFocus();
	}
}
 
Example 5
Project: rapidminer   File: ExtendedJTableSorterModel.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 = getSortingColumnIndex(h, e.getPoint());
	if (viewColumn != -1) {
		int column = columnModel.getColumn(viewColumn).getModelIndex();
		if (column != -1) {
			int status = getSortingStatus(column);
			if (!SwingTools.isControlOrMetaDown(e)) {
				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);
		}
		e.consume();
	}
}
 
Example 6
Project: Equella   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 7
Project: geomapapp   File: GMATable.java   View Source Code Vote up 6 votes
void select( MouseEvent e) {
	if( !map.isSelectable() ) return;
	double zoom = map.getZoom();
	double radius = 3./Math.pow(zoom, .75);
	double r2 = radius*radius;
	double wrap = map.getWrap();
	Point2D p = map.getScaledPoint(e.getPoint());
	if( !e.isShiftDown() ) table.clearSelection();
	int xyIndex = headings.size()+1;
	for( int k=0 ; k<currentRowsIndices.size() ; k++) {
		Vector row = getCurrentRow(k);
		float[] xy = (float[])row.get(xyIndex);
		double offset = 0.;
		while( xy[0]+offset<p.getX()-radius ) offset+=wrap;
		while( xy[0]+offset>p.getX()+radius ) offset-=wrap;
		if( xy[0]+offset<p.getX()-radius )continue;
		double r = p.distanceSq( offset+xy[0], (double)xy[1]);
		if( r < r2) {
			table.getSelectionModel().addSelectionInterval(k,k);
			table.ensureIndexIsVisible(k);
		}
	}
}
 
Example 8
Project: geomapapp   File: UnknownDataSet.java   View Source Code Vote up 6 votes
public void mousePressed(MouseEvent e) {
	
	if (station){
		//This will detect if the mouse clicks on a datapoint 
		//and will set the selectedRow value.  Used for dragging.
		selectedRow = -1;
		selectPoint(e);
	}		
	
	if (e.isControlDown()) return;
	if (e.isConsumed()||!map.isSelectable()) return;

	if (db.panTB.isSelected()) return;
	if (e.isShiftDown()) {
		p1=e.getPoint();
		p2=new Point(p1.x+1,p1.y+1);
		drawSelectionBox();
	}
	else {
		poly = new Polygon();
		poly.addPoint(e.getPoint().x, e.getPoint().y);
	}
}
 
Example 9
Project: jaer   File: EvolutionaryThrottleController.java   View Source Code Vote up 5 votes
@Override
public void mouseDragged(MouseEvent e) {
    if (currentProfile == null) {
        return;
    }
    int idx = -1;
    if ((idx = getIndex(e)) == -1) {
        return;
    }
    if (idx != lastEditIdx) {
        if (e.isAltDown() && e.isShiftDown()) {
            // brake point
            currentProfile.editClearBrake(idx);
            currentProfile.log();
            editState = EditState.None;
            glCanvas.repaint();
        } else if (e.isAltDown() && !e.isShiftDown()) {
            // brake point
            currentProfile.editSetBrake(idx);
            currentProfile.log();
            editState = EditState.None;
            glCanvas.repaint();
        } else if (isShift(e)) {
            currentProfile.editIncreaseThrottle(idx);
            currentProfile.log();
            editState = EditState.Increae;
            glCanvas.repaint();
        } else if (isControl(e)) {
            currentProfile.editDecreaseThrottle(idx);
            currentProfile.log();
            editState = EditState.Decrease;
            glCanvas.repaint();
        } else {
            editState = EditState.None;
        }
    }
    lastEditIdx = idx;
}
 
Example 10
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 11
Project: QN-ACTR-Release   File: ClickableTableHeader.java   View Source Code Vote up 5 votes
public void mouseDragged(MouseEvent e) {
	if (e.isShiftDown()) {
		return; //ignore drag when shift is pressed
	}
	int col1 = columnAtPoint(e.getPoint());
	if (col0 >= 0 && col1 >= 0) {
		table.setColumnSelectionInterval(col0, col1);
		table.setRowSelectionInterval(0, table.getRowCount() - 1);
	}
}
 
Example 12
Project: VASSAL-src   File: PieceMover.java   View Source Code Vote up 5 votes
protected boolean canHandleEvent(MouseEvent e) {
  return !e.isShiftDown() &&
         !e.isControlDown() &&
         !e.isMetaDown() &&
          e.getClickCount() < 2 &&
         !e.isConsumed();
}
 
Example 13
Project: DicomViewer   File: PanelController.java   View Source Code Vote up 5 votes
@Override
public void mouseDragged(MouseEvent e) {
    if (e.isShiftDown()) return;
    
    if (bAllowDrag) {
        if (!bDragging) { // Cas particulier de la surcharge du mouse pressed par la classe fille
            mousePressed(e);
        } else {
            dragAnim.updateVelocity(dragMem, e.getPoint(), dragWhen, e.getWhen());
            map.onDragged(e.getX() - dragMem.getX(), e.getY() - dragMem.getY());
            dragMem = e.getPoint();
            dragWhen = e.getWhen();
        }
    }
}
 
Example 14
Project: DicomViewer   File: PanelController.java   View Source Code Vote up 5 votes
@Override
public void mouseReleased(MouseEvent e) {
    if (e.isShiftDown()) return;
    
    if (bDragging) {
        dragAnim.start(e.getWhen());
    }
}
 
Example 15
Project: YtQueue   File: YtQueueFrame.java   View Source Code Vote up 5 votes
@Override
public void mouseClicked(MouseEvent e) {
    if (e.isControlDown() || e.isShiftDown() && e.getButton() != MouseEvent.BUTTON3) {
        VideoViewer viewer = VideoViewer.INSTANCE;
        if (viewer.PLAYER.isPlaying()) {
            Dimension dim = viewer.PLAYER.getVideoDimension();
            if (e.getButton() == MouseEvent.BUTTON1) {
                updateVisibility(false);
            } else {
                updateVisibility(true);
            }
            YtQueueFrame frame = YtQueueFrame.INSTANCE;
            int x = frame.getX(), y = frame.getY(), w = frame.getWidth(), h = frame.getHeight();
            double simillar = dim.width / (double) w;
            if (e.isShiftDown()) {
                simillar = 1;
            }
            dim.width = (int) (dim.width / simillar);
            dim.height = (int) (dim.height / simillar) +
                         (e.getButton() != MouseEvent.BUTTON2 ? 0 : SearchPanel.INSTANCE.getHeight() +
                                                                    VideoViewer.INSTANCE.MANAGER.getHeight());
            frame.setBounds(x + w - dim.width, y + h - dim.height, dim.width, dim.height);
        }
    }
    if (e.getClickCount() == 2) {
        if (e.getButton() == MouseEvent.BUTTON1) {
            updateVisibility(!SearchPanel.INSTANCE.isVisible());
        } else if (e.getButton() == MouseEvent.BUTTON2) {
            close();
        }
    }
}
 
Example 16
Project: jaer   File: HumanVsComputerThrottleController.java   View Source Code Vote up 5 votes
@Override
public void mouseDragged(MouseEvent e) {
    if (currentProfile == null) {
        return;
    }
    int idx = -1;
    if ((idx = getIndex(e)) == -1) {
        return;
    }
    if (idx != lastEditIdx) {
        if (e.isAltDown() && e.isShiftDown()) {
            // brake point
            currentProfile.editClearBrake(idx);
            currentProfile.log();
            editState = EditState.None;
            glCanvas.repaint();
        } else if (e.isAltDown() && !e.isShiftDown()) {
            // brake point
            currentProfile.editSetBrake(idx);
            currentProfile.log();
            editState = EditState.None;
            glCanvas.repaint();
        } else if (isShift(e)) {
            currentProfile.editIncreaseThrottle(idx);
            currentProfile.log();
            editState = EditState.Increae;
            glCanvas.repaint();
        } else if (isControl(e)) {
            currentProfile.editDecreaseThrottle(idx);
            currentProfile.log();
            editState = EditState.Decrease;
            glCanvas.repaint();
        } else {
            editState = EditState.None;
        }
    }
    lastEditIdx = idx;
}
 
Example 17
Project: DicomViewer   File: PanelController.java   View Source Code Vote up 5 votes
@Override
public void mousePressed(MouseEvent e) {
    if (e.isShiftDown()) return;
            
    e.getComponent().requestFocus();
    if (e.getButton() == MouseEvent.BUTTON1) {
        dragAnim.stop();
        bDragging = true;
        dragMem = e.getPoint();
        dragWhen = e.getWhen();
    }
}
 
Example 18
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 19
Project: incubator-netbeans   File: BaseCaret.java   View Source Code Vote up 4 votes
@Override
public void mousePressed(MouseEvent evt) {
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("mousePressed: " + logMouseEvent(evt) + ", state=" + mouseState + '\n'); // NOI18N
    }

    JTextComponent c = component;
    if (c != null && isLeftMouseButtonExt(evt)) {
        // Expand fold if offset is in collapsed fold
        int offset = mouse2Offset(evt);
        switch (evt.getClickCount()) {
            case 1: // Single press
                if (c.isEnabled() && !c.hasFocus()) {
                    c.requestFocus();
                }
                c.setDragEnabled(true);
                if (evt.isShiftDown()) { // Select till offset
                    moveDot(offset);
                    adjustRectangularSelectionMouseX(evt.getX(), evt.getY()); // also fires state change
                    mouseState = MouseState.CHAR_SELECTION;
                } else { // Regular press
                    // check whether selection drag is possible
                    if (isDragPossible(evt) && mapDragOperationFromModifiers(evt) != TransferHandler.NONE) {
                        mouseState = MouseState.DRAG_SELECTION_POSSIBLE;
                    } else { // Drag not possible
                        mouseState = MouseState.CHAR_SELECTION;
                        setDot(offset);
                    }
                }
                break;

            case 2: // double-click => word selection
                mouseState = MouseState.WORD_SELECTION;
                // Disable drag which would otherwise occur when mouse would be over text
                c.setDragEnabled(false);
                // Check possible fold expansion
                try {
                    // hack, to get knowledge of possible expansion. Editor depends on Folding, so it's not really possible
                    // to have Folding depend on BaseCaret (= a cycle). If BaseCaret moves to editor.lib2, this contract
                    // can be formalized as an interface.
                    Callable<Boolean> cc = (Callable<Boolean>)c.getClientProperty("org.netbeans.api.fold.expander");
                    if (cc == null || !cc.equals(this)) {
                        if (selectWordAction == null) {
                            selectWordAction = ((BaseKit) c.getUI().getEditorKit(
                                    c)).getActionByName(BaseKit.selectWordAction);
                        }
                        if (selectWordAction != null) {
                            selectWordAction.actionPerformed(null);
                        }
                        // Select word action selects forward i.e. dot > mark
                        minSelectionStartOffset = getMark();
                        minSelectionEndOffset = getDot();
                    }
                } catch (Exception ex) {
                    Exceptions.printStackTrace(ex);
                }
                break;
                
            case 3: // triple-click => line selection
                mouseState = MouseState.LINE_SELECTION;
                // Disable drag which would otherwise occur when mouse would be over text
                c.setDragEnabled(false);
                if (selectLineAction == null) {
                    selectLineAction = ((BaseKit) c.getUI().getEditorKit(
                            c)).getActionByName(BaseKit.selectLineAction);
                }
                if (selectLineAction != null) {
                    selectLineAction.actionPerformed(null);
                    // Select word action selects forward i.e. dot > mark
                    minSelectionStartOffset = getMark();
                    minSelectionEndOffset = getDot();
                }
                break;

            default: // multi-click
        }
    }
}
 
Example 20
Project: Tarski   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;
}