Java Code Examples for java.awt.event.ActionEvent#SHIFT_MASK

The following examples show how to use java.awt.event.ActionEvent#SHIFT_MASK . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotationEditor.java    From gate-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent evt) {
  long maxOffset = owner.getDocument().getContent().size().longValue();
  int increment = 1;
  if((evt.getModifiers() & ActionEvent.SHIFT_MASK) != 0) {
    // CTRL pressed -> use tokens for advancing
    increment = SHIFT_INCREMENT;
    if((evt.getModifiers() & ActionEvent.CTRL_MASK) != 0) {
      increment = CTRL_SHIFT_INCREMENT;
    }
  }
  long newValue = ann.getEndNode().getOffset().longValue() + increment;
  if(newValue > maxOffset) newValue = maxOffset;
  try {
    moveAnnotation(set, ann, ann.getStartNode().getOffset(), new Long(
        newValue));
  } catch(InvalidOffsetException ioe) {
    throw new GateRuntimeException(ioe);
  }
}
 
Example 2
Source File: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
@Override public void actionPerformed(ActionEvent e) {
  if (table.isEditing()) {
    table.getCellEditor().stopCellEditing();
  }
  int[] pos = table.getSelectedRows();
  if (pos.length == 0) {
    return;
  }
  RowDataModel model = (RowDataModel) table.getModel();
  boolean isShiftDown = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0;
  if (isShiftDown) { // Jump to the end
    model.moveRow(pos[0], pos[pos.length - 1], model.getRowCount() - pos.length);
    table.setRowSelectionInterval(model.getRowCount() - pos.length, model.getRowCount() - 1);
  } else {
    if (pos[pos.length - 1] == model.getRowCount() - 1) {
      return;
    }
    model.moveRow(pos[0], pos[pos.length - 1], pos[0] + 1);
    table.setRowSelectionInterval(pos[0] + 1, pos[pos.length - 1] + 1);
  }
  Rectangle r = table.getCellRect(model.getRowCount() - 1, 0, true);
  table.scrollRectToVisible(r);
}
 
Example 3
Source File: ScreenCaptureAction.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void saveScreenShot( final int modifiers ) {
  final Component component = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
  final GraphicsConfiguration graphicsConfiguration = component.getGraphicsConfiguration();
  final GraphicsDevice graphicsDevice = graphicsConfiguration.getDevice();
  try {
    final Robot robot = new Robot( graphicsDevice );
    final BufferedImage image;
    if ( ( modifiers & ActionEvent.SHIFT_MASK ) == ActionEvent.SHIFT_MASK ) {
      image = robot.createScreenCapture( graphicsConfiguration.getBounds() );
    } else {
      image = robot.createScreenCapture( component.getBounds() );
    }

    final String homeDirectory =
      ReportDesignerBoot.getInstance().getGlobalConfig().getConfigProperty( "user.home", "." );
    final File homeDir = new File( homeDirectory );
    final File f = generateName( homeDir );
    if ( f == null ) {
      return;
    }
    final FileOutputStream fout = new FileOutputStream( f );
    try {
      final PngEncoder encoder = new PngEncoder();
      encoder.setCompressionLevel( 6 );
      encoder.setEncodeAlpha( false );
      encoder.setImage( image );
      final byte[] bytes = encoder.pngEncode();
      fout.write( bytes );
    } finally {
      fout.close();
    }
  } catch ( IOException ioe ) {
    UncaughtExceptionsModel.getInstance().addException( ioe );
  } catch ( AWTException e1 ) {
    // ignore
    UncaughtExceptionsModel.getInstance().addException( e1 );
  }
}
 
Example 4
Source File: DefaultCaret.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adjusts the caret location based on the MouseEvent.
 */
private void adjustCaret(MouseEvent e) {
    if ((e.getModifiers() & ActionEvent.SHIFT_MASK) != 0 &&
        getDot() != -1) {
        moveCaret(e);
    } else if (!e.isPopupTrigger()) {
        positionCaret(e);
    }
}
 
Example 5
Source File: MoveAction.java    From openAGV with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
  AffineTransform tx = new AffineTransform();

  // TODO: Make these factors configurable?
  if ((e.getModifiers() & ActionEvent.CTRL_MASK) > 0) {
    tx.translate(dx * 10, dy * 10);
  }
  else if ((e.getModifiers() & ActionEvent.SHIFT_MASK) > 0) {
    tx.translate(dx, dy);
  }
  else {
    tx.translate(dx * 5, dy * 5);
  }

  Set<Figure> transformedFigures = new HashSet<>();

  for (Figure f : getView().getSelectedFigures()) {
    if (f.isTransformable()) {
      transformedFigures.add(f);
      f.willChange();
      f.transform(tx);
      f.changed();
    }
  }

  fireUndoableEditHappened(new TransformEdit(transformedFigures, tx));
}
 
Example 6
Source File: BriefAppDescriptionBuilder.java    From raccoon4 with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
	if (e.getSource() == button) {
		if ((e.getModifiers() & ActionEvent.SHIFT_MASK) == ActionEvent.SHIFT_MASK) {
			globals.get(TransferManager.class).schedule(globals,
					new AppDownloadWorker(globals, doc), TransferManager.WAN);
			return;
		}
		if ((e.getModifiers() & ActionEvent.ALT_MASK) == ActionEvent.ALT_MASK) {
			System.err.println(doc.toString());
			return;
		}
		globals.get(PlayManager.class).fireAppView(doc, true);
	}
}
 
Example 7
Source File: DefaultCaret.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adjusts the caret location based on the MouseEvent.
 */
private void adjustCaret(MouseEvent e) {
    if ((e.getModifiers() & ActionEvent.SHIFT_MASK) != 0 &&
        getDot() != -1) {
        moveCaret(e);
    } else if (!e.isPopupTrigger()) {
        positionCaret(e);
    }
}
 
Example 8
Source File: DefaultCaret.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adjusts the caret location based on the MouseEvent.
 */
private void adjustCaret(MouseEvent e) {
    if ((e.getModifiers() & ActionEvent.SHIFT_MASK) != 0 &&
        getDot() != -1) {
        moveCaret(e);
    } else if (!e.isPopupTrigger()) {
        positionCaret(e);
    }
}
 
Example 9
Source File: DefaultCaret.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adjusts the caret location based on the MouseEvent.
 */
private void adjustCaret(MouseEvent e) {
    if ((e.getModifiers() & ActionEvent.SHIFT_MASK) != 0 &&
        getDot() != -1) {
        moveCaret(e);
    } else if (!e.isPopupTrigger()) {
        positionCaret(e);
    }
}
 
Example 10
Source File: DefaultCaret.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adjusts the caret location based on the MouseEvent.
 */
private void adjustCaret(MouseEvent e) {
    if ((e.getModifiers() & ActionEvent.SHIFT_MASK) != 0 &&
        getDot() != -1) {
        moveCaret(e);
    } else if (!e.isPopupTrigger()) {
        positionCaret(e);
    }
}
 
Example 11
Source File: DefaultCaret.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adjusts the caret location based on the MouseEvent.
 */
private void adjustCaret(MouseEvent e) {
    if ((e.getModifiers() & ActionEvent.SHIFT_MASK) != 0 &&
        getDot() != -1) {
        moveCaret(e);
    } else if (!e.isPopupTrigger()) {
        positionCaret(e);
    }
}
 
Example 12
Source File: DefaultCaret.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adjusts the caret location based on the MouseEvent.
 */
private void adjustCaret(MouseEvent e) {
    if ((e.getModifiers() & ActionEvent.SHIFT_MASK) != 0 &&
        getDot() != -1) {
        moveCaret(e);
    } else if (!e.isPopupTrigger()) {
        positionCaret(e);
    }
}
 
Example 13
Source File: GridBagCustomizer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void hMinusInsetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hMinusInsetButtonActionPerformed
    int changeBy = STANDARD_SIZE_CHANGE;
    if (( evt.getModifiers() & ActionEvent.CTRL_MASK ) != 0) changeBy = ACCELERATED_SIZE_CHANGE;
    boolean shift = ( evt.getModifiers() & ActionEvent.SHIFT_MASK ) != 0;
    update(-1, -1, null, null, new InsetsChange(0, -changeBy, 0, -changeBy, shift), null, null, null);
}
 
Example 14
Source File: GridBagCustomizer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void xGridMinusButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_xGridMinusButtonActionPerformed
    int changeBy = STANDARD_SIZE_CHANGE;
    if (( evt.getModifiers() & ActionEvent.CTRL_MASK ) != 0) changeBy = ACCELERATED_SIZE_CHANGE;
    boolean shift = ( evt.getModifiers() & ActionEvent.SHIFT_MASK ) != 0;
    update(-1, -1, null, null, null, new GridPositionChange(-changeBy, NO_INDIRECT_CHANGE, 0, NO_INDIRECT_CHANGE, shift), null, null);
}
 
Example 15
Source File: GridBagCustomizer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void yGridMinusButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_yGridMinusButtonActionPerformed
    int changeBy = STANDARD_SIZE_CHANGE;
    if (( evt.getModifiers() & ActionEvent.CTRL_MASK ) != 0) changeBy = ACCELERATED_SIZE_CHANGE;
    boolean shift = ( evt.getModifiers() & ActionEvent.SHIFT_MASK ) != 0;
    update(-1, -1, null, null, null, new GridPositionChange(0, NO_INDIRECT_CHANGE, -changeBy, NO_INDIRECT_CHANGE, shift), null, null);
}
 
Example 16
Source File: GridBagCustomizer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void vMinusBottomInsetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vMinusBottomInsetButtonActionPerformed
    int changeBy = STANDARD_SIZE_CHANGE;
    if (( evt.getModifiers() & ActionEvent.CTRL_MASK ) != 0) changeBy = ACCELERATED_SIZE_CHANGE;
    boolean shift = ( evt.getModifiers() & ActionEvent.SHIFT_MASK ) != 0;
    update(-1, -1, null, null, new InsetsChange(0, 0, -changeBy, 0, shift), null, null, null);
}
 
Example 17
Source File: GridBagCustomizer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void vMinusWeightButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vMinusWeightButtonActionPerformed
    double changeBy = STANDARD_WEIGHT_CHANGE;
    if (( evt.getModifiers() & ActionEvent.CTRL_MASK ) != 0) changeBy = ACCELERATED_WEIGHT_CHANGE;
    boolean shift = ( evt.getModifiers() & ActionEvent.SHIFT_MASK ) != 0;
    update(-1, -1, null, null, null, null, null, new WeightChange(0.0d, NO_INDIRECT_CHANGE, -changeBy, NO_INDIRECT_CHANGE, shift));
}
 
Example 18
Source File: GridBagCustomizer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void hGridMinusButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hGridMinusButtonActionPerformed
    int changeBy = STANDARD_SIZE_CHANGE;
    if (( evt.getModifiers() & ActionEvent.CTRL_MASK ) != 0) changeBy = ACCELERATED_SIZE_CHANGE;
    boolean shift = ( evt.getModifiers() & ActionEvent.SHIFT_MASK ) != 0;
    update(-1, -1, null, null, null, null, new GridSizeChange(-changeBy, NO_INDIRECT_CHANGE, 0, NO_INDIRECT_CHANGE, shift), null);
}
 
Example 19
Source File: GridBagCustomizer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void vGridMinusButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vGridMinusButtonActionPerformed
    int changeBy = STANDARD_SIZE_CHANGE;
    if (( evt.getModifiers() & ActionEvent.CTRL_MASK ) != 0) changeBy = ACCELERATED_SIZE_CHANGE;
    boolean shift = ( evt.getModifiers() & ActionEvent.SHIFT_MASK ) != 0;
    update(-1, -1, null, null, null, null, new GridSizeChange(0, NO_INDIRECT_CHANGE, -changeBy, NO_INDIRECT_CHANGE, shift), null);
}
 
Example 20
Source File: GridBagCustomizer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void hMinusLeftInsetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hMinusLeftInsetButtonActionPerformed
    int changeBy = STANDARD_SIZE_CHANGE;
    if (( evt.getModifiers() & ActionEvent.CTRL_MASK ) != 0) changeBy = ACCELERATED_SIZE_CHANGE;
    boolean shift = ( evt.getModifiers() & ActionEvent.SHIFT_MASK ) != 0;
    update(-1, -1, null, null, new InsetsChange(0, -changeBy, 0, 0, shift), null, null, null);
}