Java Code Examples for java.awt.Event#ALT_MASK

The following examples show how to use java.awt.Event#ALT_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: PreferencesUser.java    From SikuliX1 with MIT License 5 votes vote down vote up
private int defaultStopHotkeyModifiers() {
  int mod = Event.SHIFT_MASK + Event.META_MASK;
  if (!Settings.isMac()) {
    mod = Event.SHIFT_MASK + Event.ALT_MASK;
  }
  return mod;
}
 
Example 2
Source File: OSUtils.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public static Keys getMenuKey() {
    int keyMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    if (keyMask == Event.CTRL_MASK) {
        return Keys.CONTROL;
    }
    if (keyMask == Event.META_MASK) {
        return Keys.META;
    }
    if (keyMask == Event.ALT_MASK) {
        return Keys.ALT;
    }
    throw new WebDriverException("Unable to find the keymask... not control or meta?");
}
 
Example 3
Source File: Patch.java    From TrakEM2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void keyPressed(final KeyEvent ke) {
	final Object source = ke.getSource();
	if (! (source instanceof DisplayCanvas)) return;
	final DisplayCanvas dc = (DisplayCanvas)source;
	final Roi roi = dc.getFakeImagePlus().getRoi();

	final int mod = ke.getModifiers();

	switch (ke.getKeyCode()) {
		case KeyEvent.VK_C:
			// copy into ImageJ clipboard
			// Ignoring masks: outside is already black, and ImageJ cannot handle alpha masks.
			if (0 == (mod ^ (Event.SHIFT_MASK | Event.ALT_MASK))) {
				// Place the source image, untransformed, into clipboard:
				final ImagePlus imp = getImagePlus();
				if (null != imp) imp.copy(false);
			} else if (0 == mod || (0 == (mod ^ Event.SHIFT_MASK))) {
				CoordinateTransformList<CoordinateTransform> list = null;
				if (hasCoordinateTransform()) {
					list = new CoordinateTransformList<CoordinateTransform>();
					list.add(getCoordinateTransform());
				}
				if (0 == mod) { //SHIFT is not down
					final AffineModel2D am = new AffineModel2D();
					am.set(this.at);
					if (null == list) list = new CoordinateTransformList<CoordinateTransform>();
					list.add(am);
				}
				ImageProcessor ip;
				if (null != list) {
					final TransformMesh mesh = new TransformMesh(list, meshResolution, o_width, o_height);
					final TransformMeshMapping mapping = new TransformMeshMapping(mesh);
					ip = mapping.createMappedImageInterpolated(getImageProcessor());
				} else {
					ip = getImageProcessor();
				}
				new ImagePlus(this.title, ip).copy(false);
			}
			ke.consume();
			break;
		case KeyEvent.VK_F:
			// fill mask with current ROI using
			if (null != roi && M.isAreaROI(roi)) {
				Bureaucrat.createAndStart(new Worker.Task("Filling image mask") {
					@Override
					public void exec() {
						getLayerSet().addDataEditStep(Patch.this);
						if (0 == mod) {
							addAlphaMask(roi, ProjectToolbar.getForegroundColorValue());
						} else if (0 == (mod ^ Event.SHIFT_MASK)) {
							// shift is down: fill outside
							try {
								final Area localRoi = M.areaInInts(M.getArea(roi)).createTransformedArea(at.createInverse());
								final Area invLocalRoi = new Area(new Rectangle(0, 0, getOWidth()	, getOHeight()));
								invLocalRoi.subtract(localRoi);
								addAlphaMaskLocal(invLocalRoi, ProjectToolbar.getForegroundColorValue());
							} catch (final NoninvertibleTransformException e) {
								IJError.print(e);
								return;
							}
						}
						getLayerSet().addDataEditStep(Patch.this);
						try { updateMipMaps().get(); } catch (final Throwable t) { IJError.print(t); } // wait
						Display.repaint();
					}
				}, project);
			}
			// capturing:
			ke.consume();
			break;
		default:
			super.keyPressed(ke);
			break;
	}
}
 
Example 4
Source File: ProjectTree.java    From TrakEM2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void keyPressed(final KeyEvent ke) {
	super.keyPressed(ke);
	if (ke.isConsumed()) return;
	if (!ke.getSource().equals(ProjectTree.this) || !project.isInputEnabled()) {
		return;
	}
	// get the first selected node only
	TreePath path = getSelectionPath();
	if (null == path) return;
	DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
	if (null == node) return;
	final ProjectThing pt = (ProjectThing)node.getUserObject();
	if (null == pt) return;
	//
	final int flags = ke.getModifiers();
	switch (ke.getKeyCode()) {
		case KeyEvent.VK_PAGE_UP:
			move(node, -1);
			ke.consume(); // in any case
			break;
		case KeyEvent.VK_PAGE_DOWN:
			move(node, 1);
			ke.consume(); // in any case
			break;
		case KeyEvent.VK_F2:
			rename(pt);
			ke.consume();
			break;
		case KeyEvent.VK_H:
			if (0 == (flags ^ Event.ALT_MASK)) {
				pt.setVisible(true);
				ke.consume();
			} else if (0 == flags) {
				pt.setVisible(false);
				ke.consume();
			}
			break;
		case KeyEvent.VK_A:
			if (0 == flags || (0 == (flags ^ Event.SHIFT_MASK))) {
				selectInDisplay(pt, 0 == (flags ^ Event.SHIFT_MASK));
				ke.consume();
			}
			break;
		case KeyEvent.VK_3:
			if (0 == flags) {
				ini.trakem2.display.Display3D.showAndResetView(pt);
				ke.consume();
				break;
			}
			// else, flow:
		case KeyEvent.VK_1:
		case KeyEvent.VK_2:
		case KeyEvent.VK_4:
		case KeyEvent.VK_5:
		case KeyEvent.VK_6:
		case KeyEvent.VK_7:
		case KeyEvent.VK_8:
		case KeyEvent.VK_9:
			// run a plugin, if any
			if (pt.getObject() instanceof Displayable && null != Utils.launchTPlugIn(ke, "Project Tree", project, (Displayable)pt.getObject())) {
				ke.consume();
			}
			break;
	}
	ke.consume();
}