List of usage examples for java.awt.event InputEvent BUTTON1_MASK
int BUTTON1_MASK
To view the source code for java.awt.event InputEvent BUTTON1_MASK.
Click Source Link
From source file:org.kineticsystem.commons.data.view.actions.MoveBackMouseAction.java
/** * This method is called when the user press a mouse button on the button * connected to this action./*ww w .java 2s.co m*/ * @param event The mouse event. */ public void mousePressed(MouseEvent event) { if ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0) { mover = new Accelerator() { public void execute() { if (navigator.isMoveBackEnabled()) { try { EventQueue.invokeAndWait(new Runnable() { public void run() { navigator.moveBack(); } }); } catch (Exception ex) { logger.info(ex); } } else { interrupt(); } } }; mover.setPriority(Thread.NORM_PRIORITY); mover.start(); } }
From source file:org.kineticsystem.commons.data.view.actions.MoveForwardMouseAction.java
/** * This method is called when the user press a mouse button on the button * connected to this action./*from ww w . jav a 2s .c om*/ * @param event The mouse event. */ public void mousePressed(MouseEvent event) { if ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0) { mover = new Accelerator() { public void execute() { if (navigator.isMoveForwardEnabled()) { try { EventQueue.invokeAndWait(new Runnable() { public void run() { navigator.moveNext(); } }); } catch (Exception ex) { logger.info(ex); } } else { interrupt(); } } }; mover.setPriority(Thread.NORM_PRIORITY); mover.start(); } }
From source file:com.artistech.tuio.mouse.MouseDriver.java
/** * Add Cursor Event.// w ww .j ava 2s . c o m * * @param tcur */ @Override public void addTuioCursor(TuioCursor tcur) { logger.trace(MessageFormat.format("add tuio cursor id: {0}", tcur.getCursorID())); int width = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth(); int height = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight(); boolean found = false; for (MutableTriple<Long, Integer, Integer> trip : curs) { if (trip.getLeft() == tcur.getSessionID()) { found = true; break; } } if (!found) { curs.add(new MutableTriple<>(tcur.getSessionID(), tcur.getScreenX(width), tcur.getScreenY(height))); } if (curs.size() == 1) { logger.debug(MessageFormat.format("add mouse move: ({0}, {1})", new Object[] { tcur.getScreenX(width), tcur.getScreenY(height) })); robot.mouseMove(tcur.getScreenX(width), tcur.getScreenY(height)); } else { logger.debug(MessageFormat.format("add mouse press: {0}", tcur.getCursorID())); if (curs.size() == 2) { robot.mousePress(InputEvent.BUTTON1_MASK); } else { robot.mousePress(InputEvent.BUTTON3_MASK); robot.mouseRelease(InputEvent.BUTTON3_MASK); } } }
From source file:EventTestPane.java
/** * Return a string representation of the modifiers for a MouseEvent. Note * that the methods called here are inherited from InputEvent. *///from ww w . j a v a 2 s . co m protected String mousemods(MouseEvent e) { int mods = e.getModifiers(); String s = ""; if (e.isShiftDown()) s += "Shift "; if (e.isControlDown()) s += "Ctrl "; if ((mods & InputEvent.BUTTON1_MASK) != 0) s += "Button 1 "; if ((mods & InputEvent.BUTTON2_MASK) != 0) s += "Button 2 "; if ((mods & InputEvent.BUTTON3_MASK) != 0) s += "Button 3 "; return s; }
From source file:ru.jcorp.smartstreets.gui.map.MapEditor.java
public MapEditor() { super(true);//from w w w. ja v a 2s. com setBorder(new LineBorder(Color.BLACK)); setLayout(new BorderLayout()); loadImages(); graphModel = new DirectedSparseGraph<GraphNode, GraphLink>(); graphLayout = new StaticLayout<GraphNode, GraphLink>(graphModel); graphView = new VisualizationViewer<GraphNode, GraphLink>(graphLayout); NodesFactory nodesFactory = new NodesFactory(this); LinesFactory linesFactory = new LinesFactory(); final RenderContext<GraphNode, GraphLink> renderContext = graphView.getRenderContext(); graphMouse = new EditingModalGraphMouse<GraphNode, GraphLink>(renderContext, nodesFactory, linesFactory) { @Override protected void loadPlugins() { pickingPlugin = new PickingGraphMousePlugin<GraphNode, GraphLink>(); animatedPickingPlugin = new AnimatedPickingGraphMousePlugin<GraphNode, GraphLink>(); translatingPlugin = new TranslatingGraphMousePlugin(InputEvent.BUTTON1_MASK); scalingPlugin = new ScalingGraphMousePlugin(new CrossoverScalingControl(), 0, in, out); rotatingPlugin = new RotatingGraphMousePlugin(); shearingPlugin = new ShearingGraphMousePlugin(); labelEditingPlugin = new LabelEditingGraphMousePlugin<GraphNode, GraphLink>(); annotatingPlugin = new AnnotatingGraphMousePlugin<GraphNode, GraphLink>(rc); popupEditingPlugin = new GraphPopupMousePlugin(MapEditor.this, vertexFactory, edgeFactory); editingPlugin = new GraphEditMousePlugin(MapEditor.this, vertexFactory, edgeFactory); add(scalingPlugin); setMode(Mode.EDITING); } }; graphMouse.setMode(ModalGraphMouse.Mode.EDITING); graphView.setGraphMouse(graphMouse); renderContext.setVertexLabelTransformer(new NodesLabeler()); renderContext.setEdgeLabelTransformer(new LinesLabeler()); renderContext.setVertexIconTransformer(new Transformer<GraphNode, Icon>() { @Override public Icon transform(GraphNode graphNode) { SmartMapNode node = graphNode.getMapNode(); if (sourceNode == node) return sourceMarker; if (destNode == node) return destMarker; TrafficLight trafficLight = graphNode.getMapNode().getTrafficLight(); Policeman policeman = graphNode.getMapNode().getPoliceman(); boolean hasLighter = trafficLight != null && trafficLight.getGreenDuration() != null && trafficLight.getGreenDuration() > 0 && trafficLight.getRedDuration() != null && trafficLight.getGreenDuration() > 0; boolean hasPoliceman = policeman != null; if (hasPoliceman && hasLighter) return lightPolicemanMarker; if (hasPoliceman) return policeMarker; if (hasLighter) return lightMarker; return null; } }); renderContext.setEdgeShapeTransformer(new AbstractEdgeShapeTransformer<GraphNode, GraphLink>() { private GeneralPath instance = new GeneralPath(); @Override public Shape transform(Context<Graph<GraphNode, GraphLink>, GraphLink> graphGraphLinkContext) { instance.reset(); instance.moveTo(0.0f, 5.0f); instance.lineTo(1.0f, 5.0f); return instance; } }); graphView.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR); final Transformer<GraphLink, Paint> defaultEdgePainter = graphView.getRenderContext() .getEdgeDrawPaintTransformer(); Transformer<GraphLink, Paint> linkDrawer = new Transformer<GraphLink, Paint>() { private final Color PATH_COLOR = new Color(0x0C9E0C); @Override public Paint transform(GraphLink graphLink) { if (path != null) { SmartMapLine line = graphLink.getMapLine(); SmartMapNode startNode = line.getStartNode(); SmartMapNode endNode = line.getEndNode(); int startNodeIndex = path.indexOf(startNode); int endNodeIndex = path.indexOf(endNode); if (startNodeIndex >= 0 && endNodeIndex >= 0 && Math.abs(endNodeIndex - startNodeIndex) == 1) { if (graphLink.isCoDirectional() && (startNodeIndex > endNodeIndex)) return PATH_COLOR; if (!graphLink.isCoDirectional() && (startNodeIndex < endNodeIndex)) return PATH_COLOR; } } RoadSign sign = graphLink.getRoadSign(); if (sign != null && sign.getRuleType() == RuleType.JOURNEY_IS_FORBIDDEN) { return Color.WHITE; } return defaultEdgePainter.transform(graphLink); } }; graphView.getRenderContext().setEdgeDrawPaintTransformer(linkDrawer); graphView.getRenderContext().setArrowDrawPaintTransformer(linkDrawer); graphView.getRenderContext().setArrowFillPaintTransformer(linkDrawer); graphView.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { graphView.repaint(); } }); GraphZoomScrollPane scrollPane = new GraphZoomScrollPane(graphView); this.add(scrollPane, BorderLayout.CENTER); valueLabel = new Label(); this.add(valueLabel, BorderLayout.SOUTH); }
From source file:com.varaneckas.hawkscope.hotkey.X11HotkeyListener.java
/** * Displays Hawkscope menu at mouse location. Based on dirty hacks and * blind experiments. Basically, it creates a window beneath the cursor * and executes a real mouse click with help of {@link Robot}. This way * invoking the menu works.//from w ww . j ava2 s . com * * A bug that prevents the normal activity: * https://bugs.eclipse.org/bugs/show_bug.cgi?id=11570 */ protected void displayHawkscopeMenu() { try { MenuFactory.getMainMenu().getSwtMenuObject().getDisplay().syncExec(new Runnable() { public void run() { if (MenuFactory.getMainMenu().getSwtMenuObject().isVisible()) { MenuFactory.getMainMenu().forceHide(); } try { final StateEvent se = new StateEvent(); final Point loc = Display.getDefault().getCursorLocation(); se.setX(loc.x); se.setY(loc.y); hawkscopeLaunchShell.setLocation(loc.x - 30, loc.y - 30); hawkscopeLaunchShell.setSize(60, 60); hawkscopeLaunchShell.setVisible(true); //for a weird reason, if the second shell is not //displayed, the whole hack does not work. supportShell.setLocation(loc.x - 30, loc.y - 30); supportShell.setSize(60, 60); supportShell.setVisible(true); //need all the sleeps //if duration is lowered, hack starts to randomly //fail to work. Thread.sleep(50L); Thread.yield(); if (robo != null) { robo.mousePress(InputEvent.BUTTON1_MASK); Thread.sleep(50L); } MenuFactory.getMainMenu().getState().act(se); Thread.sleep(50L); if (robo != null) { robo.mouseRelease(InputEvent.BUTTON1_MASK); } supportShell.setVisible(false); hawkscopeLaunchShell.setVisible(false); } catch (final Exception e) { throw new RuntimeException("Failed invoking hawkscope " + "menu with shortcut", e); } } }); } catch (final Exception e) { throw new RuntimeException("Failed invoking hawkscope with " + "shortcut key", e); } }
From source file:org.kineticsystem.commons.data.view.actions.MoveBackMouseAction.java
/** * This method is called when the user release a mouse button. * @param event The mouse event.//from www . java2 s . c o m */ public void mouseReleased(MouseEvent event) { if ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0) { mover.interrupt(); mover = null; } }
From source file:com.artistech.tuio.mouse.MouseDriver.java
/** * Remove Cursor Event.//ww w.j a v a2 s .c om * * @param tcur */ @Override public void removeTuioCursor(TuioCursor tcur) { logger.trace(MessageFormat.format("remove tuio cursor id: {0}", tcur.getCursorID())); if (!curs.isEmpty() && curs.get(0).getLeft() == tcur.getSessionID()) { robot.mouseRelease(InputEvent.BUTTON1_MASK); } else if (curs.size() == 2) { logger.debug(MessageFormat.format("remove mouse release: {0}", tcur.getCursorID())); robot.mouseRelease(InputEvent.BUTTON1_MASK); } MutableTriple t = null; for (MutableTriple<Long, Integer, Integer> trip : curs) { if (trip.getLeft() == tcur.getSessionID()) { t = trip; break; } } if (t != null) { curs.remove(t); } if (!curs.isEmpty()) { robot.mouseMove(curs.get(0).getMiddle(), curs.get(0).getRight()); } }
From source file:org.yccheok.jstock.gui.AutoCompleteJComboBox.java
private ActionListener getActionListener() { return new ActionListener() { @Override/* ww w . ja va 2 s . co m*/ public void actionPerformed(ActionEvent e) { /* Handle mouse clicked. */ if ((e.getModifiers() & java.awt.event.InputEvent.BUTTON1_MASK) == java.awt.event.InputEvent.BUTTON1_MASK) { final Object object = AutoCompleteJComboBox.this.getEditor().getItem(); /* Let us be extra paranoid. */ if (object instanceof DispType) { DispType lastEnteredDisp = (DispType) object; AutoCompleteJComboBox.this.dispSubject.notify(AutoCompleteJComboBox.this, lastEnteredDisp); } else if (object instanceof StockInfo) { // From our offline database. StockInfo lastEnteredStockInfo = (StockInfo) object; AutoCompleteJComboBox.this.stockInfoSubject.notify(AutoCompleteJComboBox.this, lastEnteredStockInfo); } else { assert (false); } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { // We schedule the below actions in GUI event queue, // so that DocumentListener will not be triggered. // But I am not sure why. AutoCompleteJComboBox.this.getEditor().setItem(null); AutoCompleteJComboBox.this.hidePopup(); AutoCompleteJComboBox.this.removeAllItems(); } }); } } }; }
From source file:edu.umn.ecology.populus.plot.BasicPlotCanvas.java
private void jbInit() throws Exception { /*/* www. j a va 2s .co m*/ if( info != null ) { mainCaption = new HTMLLabel( info.getMainCaption() ); xCaption = new HTMLLabel( info.getXCaptions()[0] ); yCaption = new HTMLLabel( info.getYCaptions()[0] ); yCaption.setDirection( HTMLLabel.DOWN_TO_UP ); } else { mainCaption = new HTMLLabel( "Main Caption" ); xCaption = new HTMLLabel( "X Caption" ); yCaption = new HTMLLabel( "Y Caption" ); } */ //* if (info != null) { mainCaption = new HTMLMultiLabel(info.getMainCaption()); xCaption = new HTMLMultiLabel(info.getXCaptions()); yCaption = new HTMLMultiLabel(info.getYCaptions()); yCaption.setDirection(HTMLLabel.DOWN_TO_UP); } else { mainCaption = new HTMLMultiLabel("Main Caption"); xCaption = new HTMLMultiLabel("X Caption"); yCaption = new HTMLMultiLabel("Y Caption"); yCaption.setDirection(HTMLLabel.DOWN_TO_UP); } setLayout(borderLayout1); if (PopPreferencesStorage.isUseJFreeClass()) { NumberAxis yAxis = new NumberAxis(null); NumberAxis xAxis = new NumberAxis(null); xAxis.setAutoRangeIncludesZero(false); AbstractXYItemRenderer renderer = null; if (info.isBarChart) { renderer = new XYBarRenderer(); } else { renderer = new XYLineAndShapeRenderer(true, false); } XYPlot plot = new XYPlot(null, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart jfchart = new JFreeChart(null, null, plot, false); jfchartpanel = new ChartPanel(jfchart); plot.setBackgroundPaint(ColorScheme.bG); info.styleJFree(jfchart); add(jfchartpanel, MacroLayout.CENTER); } else { chart = new JCChart(JCChart.PLOT); info.styleJC(chart); chart.setBackground(ColorScheme.bG); chart.setAllowUserChanges(true); chart.setTrigger(0, new EventTrigger(InputEvent.SHIFT_MASK, EventTrigger.CUSTOMIZE)); chart.setTrigger(1, new EventTrigger(InputEvent.BUTTON1_MASK, EventTrigger.ZOOM)); chart.setResetKey('r'); chart.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent e) { if ((e.getModifiers() & InputEvent.META_MASK) != 0) { info.setAxis(chart); chart.reset(); } } }); chart.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); chart.setWarningDialog(false); add(chart, MacroLayout.CENTER); } setBGColor(); add(mainCaption, MacroLayout.NORTH); add(xCaption, MacroLayout.SOUTH); add(yCaption, MacroLayout.WEST); }