List of usage examples for java.awt.event MouseEvent BUTTON2
int BUTTON2
To view the source code for java.awt.event MouseEvent BUTTON2.
Click Source Link
From source file:org.ujmp.jung.JungVisualizationViewer.java
public final void mouseClicked(MouseEvent e) { switch (e.getButton()) { case MouseEvent.BUTTON1: break;/*from w ww. j a v a 2 s .c o m*/ case MouseEvent.BUTTON2: break; case MouseEvent.BUTTON3: JPopupMenu popup = null; popup = new JungGraphActions(this); popup.show(e.getComponent(), e.getX(), e.getY()); break; } }
From source file:org.jopenray.server.thinclient.DisplayReaderThread.java
private void processMouseEvent(int buttons, int mouseX, int mouseY) { buttons = buttons - 64;//from w ww . ja va2 s . c o m if (this.lastMouseState == Integer.MIN_VALUE) { this.lastMouseState = buttons; this.lastMouseX = mouseX; this.lastMouseY = mouseY; return; } // Mouse move if (lastMouseX != mouseX || lastMouseY != mouseY) { sendMouseMoved(mouseX, mouseY); } // Mouse pressed/released int change = buttons ^ this.lastMouseState; if ((change & 1) > 0) { if ((buttons & 1) > 0) { System.out.println("DisplayReaderThread.processMouseEvent() BUTTON1 pressed"); sendMousePressed(MouseEvent.BUTTON1, mouseX, mouseY); } else { System.out.println("DisplayReaderThread.processMouseEvent() BUTTON1 released"); sendMouseReleased(MouseEvent.BUTTON1, mouseX, mouseY); } } if ((change & 2) > 0) { if ((buttons & 2) > 0) { System.out.println("DisplayReaderThread.processMouseEvent() BUTTON2 pressed"); sendMousePressed(MouseEvent.BUTTON2, mouseX, mouseY); } else { sendMouseReleased(MouseEvent.BUTTON2, mouseX, mouseY); } } if ((change & 4) > 0) { if ((buttons & 4) > 0) { System.out.println("DisplayReaderThread.processMouseEvent() BUTTON3 pressed"); sendMousePressed(MouseEvent.BUTTON3, mouseX, mouseY); } else { sendMouseReleased(MouseEvent.BUTTON3, mouseX, mouseY); } } if ((change & 8) > 0) { if ((buttons & 8) > 0) { System.out.println("DisplayReaderThread.processMouseEvent() mouse wheel up"); sendMouseWheelUp(mouseX, mouseY); } else { // sendMouseReleased(MouseEvent.BUTTON3, mouseX, mouseY); } } if ((change & 16) > 0) { if ((buttons & 16) > 0) { System.out.println("DisplayReaderThread.processMouseEvent() mouse wheel down"); sendMouseWheelDown(mouseX, mouseY); } else { // sendMouseReleased(MouseEvent.BUTTON3, mouseX, mouseY); } } this.lastMouseState = buttons; this.lastMouseX = mouseX; this.lastMouseY = mouseY; }
From source file:org.squidy.nodes.MouseIO.java
/** * @param dataButton//w ww .j av a 2 s. c o m * @return */ public IData process(DataButton dataButton) { if (dataButton.getButtonType() == DataButton.BUTTON_1) { setMouseStatus(MouseEvent.BUTTON1, dataButton.getFlag()); } if (dataButton.getButtonType() == DataButton.BUTTON_2) { if (middleDoubleClick) { setMouseStatus(MouseEvent.BUTTON1, true); setMouseStatus(MouseEvent.BUTTON1, false); setMouseStatus(MouseEvent.BUTTON1, true); setMouseStatus(MouseEvent.BUTTON1, false); } else { setMouseStatus(MouseEvent.BUTTON2, dataButton.getFlag()); } } if (dataButton.getButtonType() == DataButton.BUTTON_3) { setMouseStatus(MouseEvent.BUTTON3, dataButton.getFlag()); // if (dataButton.getFlag()) { // setSingleMousePress(DataButton.BUTTON_3); // } } return dataButton; }
From source file:Filter3dTest.java
/** * Gets the mouse code for the button specified in this MouseEvent. *//*from ww w .ja va 2s. c om*/ public static int getMouseButtonCode(MouseEvent e) { switch (e.getButton()) { case MouseEvent.BUTTON1: return MOUSE_BUTTON_1; case MouseEvent.BUTTON2: return MOUSE_BUTTON_2; case MouseEvent.BUTTON3: return MOUSE_BUTTON_3; default: return -1; } }
From source file:org.squidy.nodes.MouseIO.java
protected void setSingleMousePress(int button) { if (button == MouseEvent.BUTTON1) { robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); } else if (button == MouseEvent.BUTTON2) { robot.mousePress(InputEvent.BUTTON2_MASK); robot.mouseRelease(InputEvent.BUTTON2_MASK); } else if (button == MouseEvent.BUTTON3) { robot.mousePress(InputEvent.BUTTON3_MASK); robot.mouseRelease(InputEvent.BUTTON3_MASK); }/* w w w .j a va 2 s. c om*/ }
From source file:org.squidy.nodes.MouseIO.java
protected void setMouseStatus(int button, boolean status) { if (button == MouseEvent.BUTTON1) { if (status) { robot.mousePress(InputEvent.BUTTON1_MASK); } else {/*from ww w . j av a2 s.c o m*/ robot.mouseRelease(InputEvent.BUTTON1_MASK); } } else if (button == MouseEvent.BUTTON2) { if (status) { robot.mousePress(InputEvent.BUTTON2_MASK); } else { robot.mouseRelease(InputEvent.BUTTON2_MASK); } } else if (button == MouseEvent.BUTTON3) { if (status) { robot.mousePress(InputEvent.BUTTON3_MASK); } else { robot.mouseRelease(InputEvent.BUTTON3_MASK); } } }
From source file:pl.edu.icm.visnow.geometries.viewer3d.Display3DPanel.java
/** * Creates new form Display3DPanel/*from w w w . ja va2s . com*/ */ public Display3DPanel() { initComponents(); effectiveHeight = getHeight(); effectiveWidth = getWidth(); logger.debug("creating Display3DPanel"); this.setMinimumSize(new Dimension(200, 200)); this.setPreferredSize(new Dimension(800, 600)); GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D(); template.setStereo(GraphicsConfigTemplate3D.PREFERRED); // Get the GraphicsConfiguration that best fits our needs. logger.debug("getting config"); GraphicsConfiguration gcfg = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getBestConfiguration(template); logger.debug("creating canvas"); canvas = new Canvas3D(gcfg) { @Override public void postRender() { vGraphics = super.getGraphics2D(); vGraphics.setFont(new Font("sans-serif", Font.PLAIN, 10)); vGraphics.setColor(Color.YELLOW); locToWin.update(); fireProjectionChanged(new ProjectionEvent(this, locToWin)); draw2D(vGraphics, locToWin, effectiveWidth, effectiveHeight); vGraphics.flush(false); } @Override public void postSwap() { if (postRenderSilent || waitForExternalTrigger) { return; } if (!(storingJPEG || storingPNG || storingFrames)) { fireFrameRendered(); } if (storingFrames) { if (storingJPEG) { writeImage(new File(controlsPanel.getMovieCreationPanel().getCurrentFrameFileName())); } else { writeYUV(controlsPanel.getMovieCreationPanel().getGenericFrameFileName()); } } } }; canvas.setStereoEnable(false); add("Center", canvas); pickObject = new PickObject(canvas, objScene, rootObject.getGeometryObj(), objRotate); canvas.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { if (evt.isShiftDown()) { // if (e.isShiftDown()) // System.out.println(""+e.getX() + " " + e.getY()); } if (evt.getButton() == MouseEvent.BUTTON1) { if (evt.getClickCount() > 1) { reset(); } else if (pickObject.consumeEmulated3DPick(evt.getX(), evt.getY())) { /* Nothing must be done - everything was done in consumeEmulated3DPick() */ } else { pickObject.consume2DSelectModule(evt.getX(), evt.getY()); } rootObject.firePickChanged(evt, locToWin); } if (evt.getButton() == MouseEvent.BUTTON3) { if (getControlsFrame() != null) { getControlsFrame().setBounds(evt.getXOnScreen() - 130, evt.getYOnScreen(), 240, 500); getControlsFrame().setVisible(true); } else if (getTransientControlsFrame() != null) { getTransientControlsFrame().setBounds(evt.getXOnScreen() - 130, evt.getYOnScreen(), 240, 500); getTransientControlsFrame().setVisible(true); } else if (application != null) { application.getFrames().getGuiPanel().selectModule(name); } } if (evt.getButton() == MouseEvent.BUTTON2) { reset(); } } @Override public void mouseEntered(java.awt.event.MouseEvent evt) { mouseOn = true; mouseObserverThread = new Thread(new MouseObserver()); mouseObserverThread.start(); } @Override public void mouseExited(java.awt.event.MouseEvent evt) { mouseObserverThread = null; mouseOn = false; } }); canvas.addMouseMotionListener(new java.awt.event.MouseMotionListener() { @Override public void mouseDragged(MouseEvent e) { // if (e.isShiftDown()) // System.out.println(""+e.getX() + " " + e.getY()); } @Override public void mouseMoved(MouseEvent e) { } }); canvas.addMouseWheelListener(new java.awt.event.MouseWheelListener() { @Override public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) { rescaleFromMouseWheel(evt); } }); canvas.addKeyListener(new java.awt.event.KeyAdapter() { @Override public void keyTyped(KeyEvent evt) { formKeyTyped(evt); } @Override public void keyPressed(KeyEvent evt) { formKeyPressed(evt); } @Override public void keyReleased(KeyEvent evt) { formKeyReleased(evt); } }); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(true); universe = new SimpleUniverse(canvas); view = canvas.getView(); view.setProjectionPolicy(View.PERSPECTIVE_PROJECTION); view.setTransparencySortingPolicy(View.TRANSPARENCY_SORT_GEOMETRY); objScene.addChild(rootObject.getGeometryObj()); rootObject.setRenderingWindow(this); rootObject.getGeometryObj().setUserData(null); bg.setCapability(Background.ALLOW_COLOR_WRITE); bg.setCapability(Background.ALLOW_COLOR_READ); bg.setCapability(Background.ALLOW_IMAGE_WRITE); bg.setCapability(Background.ALLOW_IMAGE_READ); bg.setCapability(Background.ALLOW_IMAGE_SCALE_MODE_READ); bg.setCapability(Background.ALLOW_IMAGE_SCALE_MODE_WRITE); bg.setImageScaleMode(Background.SCALE_FIT_ALL); bg.setApplicationBounds(bounds); myFog.setCapability(LinearFog.ALLOW_DISTANCE_WRITE); myFog.setCapability(LinearFog.ALLOW_COLOR_WRITE); myFog.setInfluencingBounds(bounds); myFog.setFrontDistance(1.); myFog.setBackDistance(4.); myFogGroup.addChild(myFog); mouseRotate.setTransformGroup(objRotate); mouseRotate.setSchedulingBounds(bounds); mouseRotate.setFactor(mouseRotateSensitivity); mouseTranslate.setTransformGroup(objRotate); mouseTranslate.setSchedulingBounds(bounds); mouseTranslate.setFactor(mouseTranslateSensitivity); mouseZoom.setTransformGroup(objRotate); mouseZoom.setSchedulingBounds(bounds); windowRootObject.addChild(mouseRotate); windowRootObject.addChild(mouseTranslate); windowRootObject.addChild(mouseZoom); objTranslate.addChild(objScene); objScale.addChild(objTranslate); objRotate.addChild(bg); objRotate.addChild(objScale); windowRootObject.addChild(objRotate); ambientLight = new EditableAmbientLight(new Color3f(.25f, .25f, .25f), bounds, "ambient light", true); windowRootObject.addChild(ambientLight.getLight()); directionalLights.add(new EditableDirectionalLight(new Color3f(0.4f, 0.4f, 0.4f), new Vector3f(.1f, .08f, -.5f), bounds, "light 1", true, true)); directionalLights.add(new EditableDirectionalLight(new Color3f(0.2f, 0.15f, 0.1f), new Vector3f(-1.f, -0.4f, -.5f), bounds, "light 2", true, false)); directionalLights.add(new EditableDirectionalLight(new Color3f(0.1f, 0.1f, 0.15f), new Vector3f(0.f, 0.6f, -1.f), bounds, "light 3", true, false)); directionalLights.add(new EditableDirectionalLight(new Color3f(0.1f, 0.1f, 0.15f), new Vector3f(0.f, -0.6f, -1.f), bounds, "light 3", false, false)); for (int i = 0; i < directionalLights.size(); i++) { TransformGroup lightTransform = new TransformGroup(); lightTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); lightTransform.setName("light" + i + "Transform"); directionalLightTransforms.add(lightTransform); OpenBranchGroup lightGroup = new OpenBranchGroup(); EditableDirectionalLight light = directionalLights.get(i); lightGroup.addChild(light.getLight()); lightGroup.addChild(light.getBackLight()); lightTransform.addChild(lightGroup); windowRootObject.addChild(lightTransform); } modelClip.setCapability(ModelClip.ALLOW_ENABLE_READ); modelClip.setCapability(ModelClip.ALLOW_ENABLE_WRITE); modelClip.setCapability(ModelClip.ALLOW_PLANE_READ); modelClip.setCapability(ModelClip.ALLOW_PLANE_WRITE); modelClip.setInfluencingBounds(bounds); objScene.addChild(modelClip); pointLights .add(new EditablePointLight(new Color3f(0.4f, 0.4f, 0.4f), bounds, null, null, "light 1", false)); pointLights .add(new EditablePointLight(new Color3f(0.4f, 0.4f, 0.4f), bounds, null, null, "light 1", false)); pointLights .add(new EditablePointLight(new Color3f(0.4f, 0.4f, 0.4f), bounds, null, null, "light 1", false)); for (int i = 0; i < pointLights.size(); i++) { TransformGroup lightTransform = new TransformGroup(); lightTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); lightTransform.setName("light" + i + "Transform"); pointLightTransforms.add(lightTransform); OpenBranchGroup lightGroup = new OpenBranchGroup(); EditablePointLight light = pointLights.get(i); lightGroup.addChild(light.getLight()); lightTransform.addChild(lightGroup); windowRootObject.addChild(lightTransform); } alternateTransformObj.addChild(alternateRootObj); alternateTransormBranch.addChild(alternateTransformObj); windowRootObject.addChild(alternateTransormBranch); universe.getViewingPlatform().setNominalViewingTransform(); universe.addBranchGraph(windowRootObject); view.getPhysicalBody().getLeftEyePosition(defaultLeftEye); view.getPhysicalBody().getRightEyePosition(defaultRightEye); controlsFrame = new Display3DControlsFrame(this); controlsPanel = controlsFrame.getControlPanel(); universe.getViewingPlatform().getViewPlatformTransform().getTransform(initialCameraTransform); objReper.addChild(reper.getGeometryObj()); positionedReper.addChild(objReper); positionedReper.setTransform( new Transform3D(new float[] { .15f, 0, 0, -.8f, 0, .15f, 0, .76f, 0, 0, .15f, 0, 0, 0, 0, 1 })); reperGroup.addChild(positionedReper); OpenBranchGroup reperLightGroup = new OpenBranchGroup(); reperLightGroup.addChild(new AmbientLight(new Color3f(.6f, .6f, .6f))); reperLightGroup.addChild(new EditableDirectionalLight(new Color3f(0.4f, 0.4f, 0.4f), new Vector3f(.1f, .08f, -1f), bounds, "light 1", true, true).getLight()); reperGroup.addChild(reperLightGroup); universe.addBranchGraph(reperGroup); locToWin = new LocalToWindow(rootObject.getGeometryObj(), canvas); /** * The line below binds reper with scene rotation when using any method that calls * objRotate.setTransform(), so: keyboard (explicitly calling), mouse (Java3D is calling * setTransform) and some custom ways (e.g. in haptic pointer) */ objRotate.addTransformListener(objReper); // mouseRotate.setupCallback(objReper); // it is not needed, because Java3D calls objRotate.setTranform which fires callback to the reper }
From source file:net.ytbolg.mcxa.MCLaucherXA.java
private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked if (jList1.getSelectedIndex() == -1) { return;//from w ww. j a va 2s . c o m } try { if (MakeCmd.isChanged( new ZipFile(GameInfo.GameDir + tpf + "versions" + tpf + jList1.getSelectedValue().toString() + tpf + jList1.getSelectedValue().toString() + ".jar"))) { jComboBox1.setSelectedItem( "-Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true"); } else { jComboBox1.setSelectedItem(""); } } catch (IOException ex) { Logger.getLogger(MCLaucherXA.class.getName()).log(Level.SEVERE, null, ex); } if (evt.getButton() == MouseEvent.BUTTON3 && jList1.getSelectedIndex() != -1) { jPopupMenu1.show(this, evt.getX() + 25, evt.getY() + 25); } if (evt.getButton() == MouseEvent.BUTTON2 && evt.getClickCount() == 2) { jButton1ActionPerformed(null); } try { BrushLabels(jList1.getSelectedIndex()); } catch (JSONException e) { } catch (Exception ex) { Logger.getLogger(MCLaucherXA.class.getName()).log(Level.SEVERE, null, ex); } // TODO add your handling code here: }
From source file:org.gtdfree.GTDFree.java
protected TrayIcon getTrayIcon() { if (trayIcon == null) { if (ApplicationHelper.isGTKLaF()) { trayIcon = new TrayIcon(ApplicationHelper.loadImage(ApplicationHelper.icon_name_large_tray_splash)); } else {// www . j a v a 2 s .c o m trayIcon = new TrayIcon(ApplicationHelper.loadImage(ApplicationHelper.icon_name_small_tray_splash)); } trayIcon.setImageAutoSize(true); trayIcon.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { trayIconPopup.setVisible(false); if (getJFrame().isVisible()) { getJFrame().setVisible(false); } else { pushVisible(); } } else { if (trayIconPopup.isVisible()) { trayIconPopup.setVisible(false); } else { Point p = new Point(e.getPoint()); /* * Disabled, because we are anyway doing things like rollover, * which are probably done by Frame. if (getJFrame().isShowing()) { SwingUtilities.convertPointFromScreen(p, getJFrame()); trayIconPopup.show(getJFrame(), p.x, p.y); } else { }*/ trayIconPopup.show(null, p.x, p.y); } } } }); trayIcon.setToolTip("GTD-Free - " + Messages.getString("GTDFree.Tray.desc")); //$NON-NLS-1$ //$NON-NLS-2$ /* * Necessary only when popup is showing with null window. Hides popup. */ MouseListener hideMe = new MouseAdapter() { @Override public void mouseExited(MouseEvent e) { if (e.getComponent() instanceof JMenuItem) { JMenuItem jm = (JMenuItem) e.getComponent(); jm.getModel().setRollover(false); jm.getModel().setArmed(false); jm.repaint(); } Point p = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), trayIconPopup); //System.out.println(p.x+" "+p.y+" "+trayIconPopup.getWidth()+" "+trayIconPopup.getHeight()); if (p.x < 0 || p.x >= trayIconPopup.getWidth() || p.y < 0 || p.y >= trayIconPopup.getHeight()) { trayIconPopup.setVisible(false); } } @Override public void mouseEntered(MouseEvent e) { if (e.getComponent() instanceof JMenuItem) { JMenuItem jm = (JMenuItem) e.getComponent(); jm.getModel().setRollover(true); jm.getModel().setArmed(true); jm.repaint(); } } }; trayIconPopup = new JPopupMenu(); trayIconPopup.addMouseListener(hideMe); JMenuItem mi = new JMenuItem(Messages.getString("GTDFree.Tray.Drop")); //$NON-NLS-1$ mi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_small_collecting)); mi.setToolTipText(Messages.getString("GTDFree.Tray.Drop.desc")); //$NON-NLS-1$ mi.addMouseListener(hideMe); /* * Workaround for tray, if JFrame is showing, then mouse click is not fired */ mi.addMouseListener(new MouseAdapter() { private boolean click = false; @Override public void mousePressed(MouseEvent e) { click = true; } @Override public void mouseReleased(MouseEvent e) { if (click) { click = false; doMouseClicked(e); } } @Override public void mouseExited(MouseEvent e) { click = false; } private void doMouseClicked(MouseEvent e) { trayIconPopup.setVisible(false); Clipboard c = null; if (e.getButton() == MouseEvent.BUTTON1) { c = Toolkit.getDefaultToolkit().getSystemClipboard(); } else if (e.getButton() == MouseEvent.BUTTON2) { c = Toolkit.getDefaultToolkit().getSystemSelection(); } else { return; } try { Object o = c.getData(DataFlavor.stringFlavor); if (o != null) { getEngine().getGTDModel().collectAction(o.toString()); } flashMessage(Messages.getString("GTDFree.Tray.Collect.ok"), e.getLocationOnScreen()); //$NON-NLS-1$ } catch (Exception e1) { Logger.getLogger(this.getClass()).debug("Internal error.", e1); //$NON-NLS-1$ flashMessage(Messages.getString("GTDFree.Tray.Collect.fail") + e1.getMessage(), //$NON-NLS-1$ e.getLocationOnScreen()); } } }); TransferHandler th = new TransferHandler() { private static final long serialVersionUID = 1L; @Override public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) { return DataFlavor.selectBestTextFlavor(transferFlavors) != null; } @Override public boolean importData(JComponent comp, Transferable t) { try { DataFlavor f = DataFlavor.selectBestTextFlavor(t.getTransferDataFlavors()); Object o = t.getTransferData(f); if (o != null) { getEngine().getGTDModel().collectAction(o.toString()); } return true; } catch (UnsupportedFlavorException e) { Logger.getLogger(this.getClass()).debug("Internal error.", e); //$NON-NLS-1$ } catch (IOException e) { Logger.getLogger(this.getClass()).debug("Internal error.", e); //$NON-NLS-1$ } return false; } }; mi.setTransferHandler(th); trayIconPopup.add(mi); mi = new JMenuItem(); mi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_delete)); mi.setText(Messages.getString("GTDFree.Tray.Hide")); //$NON-NLS-1$ mi.setToolTipText(Messages.getString("GTDFree.Tray.Hide.desc")); //$NON-NLS-1$ mi.addMouseListener(hideMe); mi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { trayIconPopup.setVisible(false); if (getJFrame().isVisible()) { getJFrame().setVisible(false); } } }); trayIconPopup.add(mi); mi = new JMenuItem(); mi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_small_splash)); mi.setText(Messages.getString("GTDFree.Tray.Show")); //$NON-NLS-1$ mi.setToolTipText(Messages.getString("GTDFree.Tray.Show.desc")); //$NON-NLS-1$ mi.addMouseListener(hideMe); mi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { trayIconPopup.setVisible(false); pushVisible(); } }); trayIconPopup.add(mi); mi = new JMenuItem(); mi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_exit)); mi.setText(Messages.getString("GTDFree.Tray.Exit")); //$NON-NLS-1$ mi.addMouseListener(hideMe); mi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { trayIconPopup.setVisible(false); close(false); } }); trayIconPopup.add(mi); } return trayIcon; }
From source file:corelyzer.ui.CorelyzerGLCanvas.java
public void mouseClicked(final MouseEvent e) { Point prePos = e.getPoint();// www. ja v a 2 s . c o m float sp[] = { 0.0f, 0.0f }; this.convertMousePointToSceneSpace(prePos, scenePos); switch (e.getButton()) { case MouseEvent.BUTTON1: if (e.getClickCount() > 1) { // doubleclick zoom in/out Point mousePos = e.getPoint(); float[] cp = { 0.0f, 0.0f }; float[] sc = { 0.0f, 0.0f }; canvasLock.lock(); convertMousePointToSceneSpace(mousePos, cp); sc[0] = SceneGraph.getSceneCenterX(); sc[1] = SceneGraph.getSceneCenterY(); // alt down for zoom out?! float base; if (e.isAltDown()) { // zoom out base = 1.05f; } else { // zoom out base = 0.95f; } float scale = (float) Math.pow(base, 3); SceneGraph.scaleScene(scale); float ncp[] = { 0.0f, 0.0f }; this.convertMousePointToSceneSpace(mousePos, ncp); ncp[0] = ncp[0] - cp[0]; ncp[1] = ncp[1] - cp[1]; SceneGraph.panScene(-ncp[0], -ncp[1]); canvasLock.unlock(); CorelyzerApp.getApp().updateGLWindows(); return; } // measuring mode if (canvasMode == CorelyzerApp.APP_MEASURE_MODE) { int nPoint = SceneGraph.addMeasurePoint(scenePos[0], scenePos[1]); this.convertScenePointToAbsolute(scenePos, sp); if (nPoint == 1) { CorelyzerApp.getApp().getToolFrame().addMeasure(sp, 1); } else if (nPoint == 2) { CorelyzerApp.getApp().getToolFrame().addMeasure(sp, 2); } PAN_MODE = 0; return; } if (selectedFreeDraw > -1) { CorelyzerApp.getApp().getPluginManager().broadcastEventToPlugin( SceneGraph.getFreeDrawPluginID(selectedFreeDraw), CorelyzerPluginEvent.FREE_DRAW_SELECTED, "" + selectedFreeDraw); return; } selectedMarker = SceneGraph.accessPickedMarker(); if (selectedMarker < 0) { if (canvasMode == CorelyzerApp.APP_MARKER_MODE) { SceneGraph.setCoreSectionMarkerFocus(false); CorelyzerApp.getApp().updateGLWindows(); } return; } else { if (canvasMode == CorelyzerApp.APP_NORMAL_MODE) { AnnotationUtils.openAnnotation(getCanvas(), selectedTrack, selectedTrackSection, selectedMarker); } else { // marker mode // TODO do something if want to allow user adjust the // selected // TODO block, like sync to ClastInfo hash... if (selectedMarker != SceneGraph.focusedMarker || selectedTrackSection != SceneGraph.focusedTrackSection || selectedTrack != SceneGraph.focusedTrack) { SceneGraph.setCoreSectionMarkerFocus(false); SceneGraph.focusedTrack = selectedTrack; SceneGraph.focusedTrackSection = selectedTrackSection; SceneGraph.focusedMarker = selectedMarker; SceneGraph.setCoreSectionMarkerFocus(true); } } } break; case MouseEvent.BUTTON2: /* * System.out.println("---- Middle button clicked at: " + * prePos.x + ", " + prePos.y); * System.out.println("Converted to Scene Space: " + scenePos[0] * + ", " + scenePos[1]); */ break; case MouseEvent.BUTTON3: /* * System.out.println("---- Right button clicked at: " + * prePos.x + ", " + prePos.y); * System.out.println("Converted to Scene Space: " + scenePos[0] * + ", " + scenePos[1]); */ this.handleRightMouseClick(e); break; default: if (e.isPopupTrigger()) { this.handleRightMouseClick(e); } } }