List of usage examples for java.awt.event MouseEvent getPoint
public Point getPoint()
From source file:VASSAL.launch.ModuleManagerWindow.java
protected void buildTree() { recentModuleConfig = new StringArrayConfigurer("RecentModules", null); Prefs.getGlobalPrefs().addOption(null, recentModuleConfig); final List<String> missingModules = new ArrayList<String>(); final List<ModuleInfo> moduleList = new ArrayList<ModuleInfo>(); for (String s : recentModuleConfig.getStringArray()) { final ModuleInfo module = new ModuleInfo(s); if (module.getFile().exists() && module.isValid()) { moduleList.add(module);//from w w w . j av a2s.c o m } else { missingModules.add(s); } } for (String s : missingModules) { logger.info(Resources.getString("ModuleManager.removing_module", s)); moduleList.remove(s); recentModuleConfig.removeValue(s); } Collections.sort(moduleList, new Comparator<ModuleInfo>() { public int compare(ModuleInfo f1, ModuleInfo f2) { return f1.compareTo(f2); } }); rootNode = new MyTreeNode(new RootInfo()); for (ModuleInfo moduleInfo : moduleList) { final MyTreeNode moduleNode = new MyTreeNode(moduleInfo); for (ExtensionInfo ext : moduleInfo.getExtensions()) { final MyTreeNode extensionNode = new MyTreeNode(ext); moduleNode.add(extensionNode); } final ArrayList<File> missingFolders = new ArrayList<File>(); for (File f : moduleInfo.getFolders()) { if (f.exists() && f.isDirectory()) { final GameFolderInfo folderInfo = new GameFolderInfo(f, moduleInfo); final MyTreeNode folderNode = new MyTreeNode(folderInfo); moduleNode.add(folderNode); final ArrayList<File> l = new ArrayList<File>(); final File[] files = f.listFiles(); if (files == null) continue; for (File f1 : files) { if (f1.isFile()) { l.add(f1); } } Collections.sort(l); for (File f2 : l) { final SaveFileInfo fileInfo = new SaveFileInfo(f2, folderInfo); if (fileInfo.isValid() && fileInfo.belongsToModule()) { final MyTreeNode fileNode = new MyTreeNode(fileInfo); folderNode.add(fileNode); } } } else { missingFolders.add(f); } } for (File mf : missingFolders) { logger.info(Resources.getString("ModuleManager.removing_folder", mf.getPath())); moduleInfo.removeFolder(mf); } rootNode.add(moduleNode); } updateModuleList(); treeModel = new MyTreeTableModel(rootNode); tree = new MyTree(treeModel); tree.setRootVisible(false); tree.setEditable(false); tree.setTreeCellRenderer(new MyTreeCellRenderer()); tree.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { final TreePath path = tree.getPathForLocation(e.getPoint().x, e.getPoint().y); // do nothing if not on a node, or if this node was expanded // or collapsed during the past doubleClickInterval milliseconds if (path == null || (lastExpansionPath == path && e.getWhen() - lastExpansionTime <= doubleClickInterval)) return; selectedNode = (MyTreeNode) path.getLastPathComponent(); final int row = tree.getRowForPath(path); if (row < 0) return; final AbstractInfo target = (AbstractInfo) selectedNode.getUserObject(); // launch module or load save, otherwise expand or collapse node if (target instanceof ModuleInfo) { final ModuleInfo modInfo = (ModuleInfo) target; if (modInfo.isModuleTooNew()) { ErrorDialog.show("Error.module_too_new", modInfo.getFile().getPath(), modInfo.getVassalVersion(), Info.getVersion()); return; } else { ((ModuleInfo) target).play(); } } else if (target instanceof SaveFileInfo) { ((SaveFileInfo) target).play(); } else if (tree.isExpanded(row)) { tree.collapseRow(row); } else { tree.expandRow(row); } } } @Override public void mouseReleased(MouseEvent e) { final TreePath path = tree.getPathForLocation(e.getPoint().x, e.getPoint().y); if (path == null) return; selectedNode = (MyTreeNode) path.getLastPathComponent(); if (e.isMetaDown()) { final int row = tree.getRowForPath(path); if (row >= 0) { tree.clearSelection(); tree.addRowSelectionInterval(row, row); final AbstractInfo target = (AbstractInfo) selectedNode.getUserObject(); target.buildPopup(row).show(tree, e.getX(), e.getY()); } } } }); // We capture the time and location of clicks which would cause // expansion in order to distinguish these from clicks which // might launch a module or game. tree.addTreeWillExpandListener(new TreeWillExpandListener() { public void treeWillCollapse(TreeExpansionEvent e) { lastExpansionTime = System.currentTimeMillis(); lastExpansionPath = e.getPath(); } public void treeWillExpand(TreeExpansionEvent e) { lastExpansionTime = System.currentTimeMillis(); lastExpansionPath = e.getPath(); } }); // This ensures that double-clicks always start the module but // doesn't prevent single-clicks on the handles from working. tree.setToggleClickCount(3); tree.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { final MyTreeNode node = (MyTreeNode) e.getPath().getLastPathComponent(); final AbstractInfo target = node.getNodeInfo(); if (target instanceof ModuleInfo) { setSelectedModule(target.getFile()); } else { if (node.getParent() != null) { setSelectedModule(node.getParentModuleFile()); } } } }); // FIXME: Width handling needs improvement. Also save in prefs tree.getColumnModel().getColumn(KEY_COLUMN).setMinWidth(250); tree.getColumnModel().getColumn(VERSION_COLUMN).setCellRenderer(new VersionCellRenderer()); tree.getColumnModel().getColumn(VERSION_COLUMN).setMinWidth(100); tree.getColumnModel().getColumn(VASSAL_COLUMN).setCellRenderer(new VersionCellRenderer()); tree.getColumnModel().getColumn(VASSAL_COLUMN).setMinWidth(100); tree.getColumnModel().getColumn(SPARE_COLUMN).setMinWidth(10); tree.getColumnModel().getColumn(SPARE_COLUMN).setPreferredWidth(600); // FIXME: How to set alignment of individual header components? tree.getTableHeader().setAlignmentX(JComponent.CENTER_ALIGNMENT); }
From source file:corelyzer.ui.CorelyzerGLCanvas.java
private void handleCutMouseReleased(final MouseEvent e) { // TODO: series of cutting actions if (selectedTrackSection != -1) { // Get selection info Point releasePos = e.getPoint(); float[] releaseScenePos = { 0.0f, 0.0f }; float[] releaseAbsPos = { 0.0f, 0.0f }; convertMousePointToSceneSpace(releasePos, releaseScenePos); if (!SceneGraph.getDepthOrientation()) { float t = scenePos[0]; scenePos[0] = scenePos[1];//from w w w . j a v a 2s .co m scenePos[1] = -t; } SceneGraph.addClastPoint2(scenePos[0], scenePos[1]); convertScenePointToAbsolute(scenePos, releaseAbsPos); CorelyzerApp.getApp().getToolFrame().setClastLowerRight(releaseAbsPos); float[] clastUpperLeft = CorelyzerApp.getApp().getToolFrame().getClastUpperLeft(); // Check whether this is the root section int parentTrackId = SceneGraph.getSectionParentTrackId(selectedTrack, selectedTrackSection); int parentSectionId = SceneGraph.getSectionParentSectionId(selectedTrack, selectedTrackSection); if (parentTrackId != -1 && parentSectionId != -1) { String mesg = "You can only cut the original sections"; JOptionPane.showMessageDialog(getPopupParent(), mesg); return; } // todo: disable original track in selection int newTrackId = CRUtility.getTargetTrackID(CorelyzerApp.getApp(), this.canvas); String newTrackName = SceneGraph.getTrackName(newTrackId); /* * String newSectionName = JOptionPane.showInputDialog(this.canvas, * "Enter the section name"); * * if(newTrackName == null || newTrackName.equals("") || * newSectionName.equals("")) { * JOptionPane.showMessageDialog(this.canvas, "Invalid inputs"); * return; } */ // convert to meter float startDepth = clastUpperLeft[0] / 100.0f; float endDepth = releaseAbsPos[0] / 100.0f; int[] loc = { selectedTrack, selectedTrackSection }; CRExperimentController.cutIntervalToNewTrack(loc, startDepth, endDepth, CRExperimentController.ABSOLUTE_DEPTH, newTrackName, null); } }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.AnnotationDataUI.java
/** Initializes the components composing the display. */ private void initComponents() { setLayout(new BorderLayout()); setBackground(UIUtilities.BACKGROUND); setBorder(new SeparatorOneLineBorder()); toReplace = new ArrayList<FileAnnotationData>(); IconManager icons = IconManager.getInstance(); filter = SHOW_ALL;/* ww w. j a v a2s . c o m*/ filterButton = new JButton(NAMES[SHOW_ALL]); filterButton.setToolTipText("Filter tags and attachments."); UIUtilities.unifiedButtonLookAndFeel(filterButton); Font font = filterButton.getFont(); filterButton.setFont(font.deriveFont(font.getStyle(), font.getSize() - 2)); filterButton.setIcon(icons.getIcon(IconManager.UP_DOWN_9_12)); filterButton.setBackground(UIUtilities.BACKGROUND_COLOR); filterButton.addMouseListener(new MouseAdapter() { /** * Brings up the menu. * @see MouseListener#mouseReleased(MouseEvent) */ public void mouseReleased(MouseEvent me) { Object source = me.getSource(); if (source instanceof Component) displayMenu((Component) source, me.getPoint()); } }); otherRating = new JLabel(); otherRating.setBackground(UIUtilities.BACKGROUND_COLOR); font = otherRating.getFont(); otherRating.setFont(font.deriveFont(Font.ITALIC, font.getSize() - 2)); content = new JPanel(); content.setBackground(UIUtilities.BACKGROUND_COLOR); content.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); tagFlag = false; docFlag = false; otherFlag = false; tagNames = new ArrayList<String>(); tagsDocList = new ArrayList<DocComponent>(); filesDocList = new ArrayList<DocComponent>(); otherList = new ArrayList<DocComponent>(); existingTags = new HashMap<String, TagAnnotationData>(); addTagsButton = new JButton(icons.getIcon(IconManager.PLUS_12)); UIUtilities.unifiedButtonLookAndFeel(addTagsButton); addTagsButton.setBackground(UIUtilities.BACKGROUND_COLOR); addTagsButton.setToolTipText("Add Tags."); addTagsButton.addActionListener(controller); addTagsButton.setActionCommand("" + EditorControl.ADD_TAGS); addDocsButton = new JButton(icons.getIcon(IconManager.PLUS_12)); addDocsButton.setBackground(UIUtilities.BACKGROUND_COLOR); addDocsButton.setToolTipText("Attach a document."); addDocsButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { if (addDocsButton.isEnabled()) { Point p = e.getPoint(); createDocSelectionMenu().show(addDocsButton, p.x, p.y); } } }); UIUtilities.unifiedButtonLookAndFeel(addDocsButton); removeTagsButton = new JButton(icons.getIcon(IconManager.MINUS_12)); UIUtilities.unifiedButtonLookAndFeel(removeTagsButton); removeTagsButton.setBackground(UIUtilities.BACKGROUND_COLOR); removeTagsButton.setToolTipText("Remove Tags."); removeTagsButton.addMouseListener(controller); removeTagsButton.setActionCommand("" + EditorControl.REMOVE_TAGS); removeDocsButton = new JButton(icons.getIcon(IconManager.MINUS_12)); UIUtilities.unifiedButtonLookAndFeel(removeDocsButton); removeDocsButton.setBackground(UIUtilities.BACKGROUND_COLOR); removeDocsButton.setToolTipText("Remove Attachments."); removeDocsButton.addMouseListener(controller); removeDocsButton.setActionCommand("" + EditorControl.REMOVE_DOCS); removeOtherAnnotationsButton = new JButton(icons.getIcon(IconManager.MINUS_12)); UIUtilities.unifiedButtonLookAndFeel(removeOtherAnnotationsButton); removeOtherAnnotationsButton.setBackground(UIUtilities.BACKGROUND_COLOR); removeOtherAnnotationsButton.setToolTipText("Remove Annotations."); removeOtherAnnotationsButton.addMouseListener(controller); removeOtherAnnotationsButton.setActionCommand("" + EditorControl.REMOVE_OTHER_ANNOTATIONS); selectedValue = 0; initialValue = selectedValue; rating = new RatingComponent(selectedValue, RatingComponent.MEDIUM_SIZE); rating.setOpaque(false); rating.setBackground(UIUtilities.BACKGROUND_COLOR); rating.addPropertyChangeListener(this); unrateButton = new JButton(icons.getIcon(IconManager.MINUS_12)); UIUtilities.unifiedButtonLookAndFeel(unrateButton); unrateButton.setBackground(UIUtilities.BACKGROUND_COLOR); unrateButton.setToolTipText("Unrate."); unrateButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rating.setValue(0); view.saveData(true); } }); tagsPane = new JPanel(); tagsPane.setLayout(new BoxLayout(tagsPane, BoxLayout.Y_AXIS)); tagsPane.setBackground(UIUtilities.BACKGROUND_COLOR); DocComponent doc = new DocComponent(null, model); tagsDocList.add(doc); tagsPane.add(doc); docPane = new JPanel(); docPane.setLayout(new BoxLayout(docPane, BoxLayout.Y_AXIS)); docPane.setBackground(UIUtilities.BACKGROUND_COLOR); docRef = docPane; doc = new DocComponent(null, model); filesDocList.add(doc); docPane.add(doc); publishedBox = new JCheckBox(); publishedBox.setBackground(UIUtilities.BACKGROUND_COLOR); publishedBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { firePropertyChange(EditorControl.SAVE_PROPERTY, Boolean.FALSE, Boolean.TRUE); } }); mapsPane = new MapAnnotationsComponent(model, view); otherPane = new JPanel(); otherPane.setLayout(new GridBagLayout()); otherPane.setBackground(UIUtilities.BACKGROUND_COLOR); }
From source file:cz.muni.fi.pv168.MainForm.java
public MainForm() { initComponents();/*from w ww. ja v a 2 s . c o m*/ carManager.setDataSource(dataSource); customerManager.setDataSource(dataSource); rentManager.setDataSource(dataSource); FileOutputStream fs = null; try { fs = new FileOutputStream("main.log", true); } catch (FileNotFoundException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex); } carManager.setLogger(fs); customerManager.setLogger(fs); rentManager.setLogger(fs); final SortFilterModel sorter = new SortFilterModel(rentTable.getModel()); rentTable.getTableHeader().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent event) { // check for double click if (event.getClickCount() < 2) { return; } // find column of click and int tableColumn = rentTable.columnAtPoint(event.getPoint()); // translate to table model index and sort int modelColumn = rentTable.convertColumnIndexToModel(tableColumn); sorter.sort(modelColumn); } }); jTabbedPane1.setTitleAt(0, localization.getString("cars")); jTabbedPane1.setTitleAt(1, localization.getString("customers")); jTabbedPane1.setTitleAt(2, localization.getString("rents")); carTable.setModel(new CarsTableModel(localization)); customerTable.setModel(new CustomersTableModel(localization)); rentTable.setModel(new RentsTableModel(localization)); jMenu1.setText(localization.getString("file")); jMenu2.setText(localization.getString("data")); jMenu3.setText(localization.getString("new")); jMenu4.setText(localization.getString("help")); jMenuItem1.setText(localization.getString("db_connect")); jMenuItem2.setText(localization.getString("db_disconnect")); jMenuItem9.setText(localization.getString("help")); jMenuItem10.setText(localization.getString("credits")); jMenuItem3.setAction(new ExitAction(localization.getString("exit"))); jMenuItem7.setAction(new AddRentAction(localization.getString("rent"))); jMenuItem8.setAction(new AddCarAction(localization.getString("car"))); jMenuItem11.setAction(new CommitAction(localization.getString("commit"))); jMenuItem18.setAction(new AddCustomerAction(localization.getString("customer"))); jButton1.setAction(new CommitAction(localization.getString("commit"))); jButton2.setAction(new AddCarAction(localization.getString("new_car"))); jButton3.setAction(new AddCustomerAction(localization.getString("new_customer"))); jButton4.setAction(new AddRentAction(localization.getString("new_rent"))); jMenuItem5.setText(localization.getString("find")); jButton9.setText(localization.getString("search")); jMenu6.setText(localization.getString("remove")); jMenuItem19.setText(localization.getString("car")); jMenuItem20.setText(localization.getString("customer")); jMenuItem21.setText(localization.getString("rent")); jMenuItem23.setAction(new CopyAction(localization.getString("copy"))); jMenuItem24.setAction(new CutAction(localization.getString("cut"))); jMenuItem25.setAction(new PasteAction(localization.getString("paste"))); }
From source file:org.pmedv.blackboard.components.BoardEditor.java
/** * Occurs usually if the right mouse button has been pressed * /*w ww . j ava2s.c o m*/ * @param event */ private void handleContextClick(MouseEvent event) { Point point = event.getPoint(); point = BoardUtil.mirrorTransform(point, zoomLayer, event); contextClickX = (int) point.x; contextClickY = (int) point.y; deleteCommand.setEnabled(selectedItem != null || selectedItems.size() > 0); popupMenu.show(zoomLayer, point.x, point.y); }
From source file:org.gumtree.vis.awt.JChartPanel.java
private void moveSelectedText(MouseEvent e) { Point2D screenPoint = translateScreenToJava2D(e.getPoint()); Rectangle2D screenArea = getScreenDataArea(); if (screenArea.contains(screenPoint)) { if (textMovePoint != null) { // Point2D point = translateScreenToChart(translateScreenToJava2D(e.getPoint())); double screenX = ChartMaskingUtilities.translateScreenX(e.getX() / getScaleX(), getScreenDataArea(), getChart());//from w w w. j av a 2 s . c o m double screenY = ChartMaskingUtilities.translateScreenY(e.getY(), getScreenDataArea(), getChart(), 0); // Point2D point = translateScreenToChart(translateScreenToJava2D(e.getPoint())); Point2D point = new Point2D.Double(screenX, screenY); selectedTextWrapper.setRect(selectedTextWrapper.getMinX() + point.getX() - textMovePoint.getX(), selectedTextWrapper.getMinY() + point.getY() - textMovePoint.getY(), selectedTextWrapper.getWidth(), selectedTextWrapper.getHeight()); if (point != null) { this.textMovePoint = point; } repaint(); } } }
From source file:org.openconcerto.erp.model.FamilleArticleTree.java
public void mousePressed(MouseEvent e) { Object o = this.getSelectionPath().getLastPathComponent(); int id = 1;/*from w w w . j ava 2 s. c om*/ if (e.getButton() == MouseEvent.BUTTON3) { if (o instanceof FamilleTreeNode) { final FamilleTreeNode nodeSelect = (FamilleTreeNode) o; id = nodeSelect.getId(); } final int idSelect = id; // Ajouter, supprimer, modifier une famille JPopupMenu menu = new JPopupMenu(); menu.add(new AbstractAction("Ajouter une famille") { public void actionPerformed(ActionEvent e) { EditFrame frameAddFamille = new EditFrame(familleElt, EditFrame.CREATION); SQLRowValues rowVals = new SQLRowValues(familleElt.getTable()); rowVals.put("ID_FAMILLE_ARTICLE_PERE", idSelect); frameAddFamille.getSQLComponent().select(rowVals); frameAddFamille.setVisible(true); } }); if (idSelect > 1) { menu.add(new AbstractAction("Modifier") { public void actionPerformed(ActionEvent e) { EditFrame frameModFamille = new EditFrame(familleElt, EditFrame.MODIFICATION); frameModFamille.selectionId(idSelect, 1); frameModFamille.setVisible(true); } }); menu.add(new AbstractAction("Supprimer") { public void actionPerformed(ActionEvent e) { try { familleElt.archive(idSelect); } catch (SQLException e1) { e1.printStackTrace(); } } }); } menu.show(e.getComponent(), e.getPoint().x, e.getPoint().y); } }
From source file:org.gumtree.vis.plot1d.Plot1DPanel.java
@Override public void mousePressed(MouseEvent e) { int mods = e.getModifiers(); // if (isMaskingEnabled() && (mods & maskingKeyMask) != 0) { if (isInternalLegendEnabled && isInternalLegendSelected) { int cursorType = findCursorOnSelectedItem(e.getX(), e.getY()); if (cursorType == Cursor.DEFAULT_CURSOR) { Rectangle2D screenDataArea = getScreenDataArea(e.getX(), e.getY()); if (screenDataArea != null) { legendPoint = e.getPoint(); } else { legendPoint = null;/*from w ww. j ava 2 s.c o m*/ } } else { if (cursorType == Cursor.MOVE_CURSOR) { legendPoint = e.getPoint(); } } } if (isMaskingEnabled()) { // Prepare masking service. int cursorType = findCursorOnSelectedItem(e.getX(), e.getY()); if (cursorType == Cursor.DEFAULT_CURSOR && (mods & maskingKeyMask) != 0) { Rectangle2D screenDataArea = getScreenDataArea(e.getX(), e.getY()); if (screenDataArea != null) { this.maskPoint = getPointInRectangle(e.getX(), e.getY(), screenDataArea).getX(); } else { this.maskPoint = Double.NaN; } } else { if (cursorType == Cursor.MOVE_CURSOR) { // this.maskMovePoint = translateScreenToChart( // translateScreenToJava2D(e.getPoint())).getX(); Insets insets = getInsets(); this.maskMovePoint = ChartMaskingUtilities.translateScreenX( (e.getX() - insets.left) / getScaleX(), getScreenDataArea(), getChart()); } setMaskDragIndicator(cursorType); } } if (getMaskDragIndicator() == Cursor.DEFAULT_CURSOR) { super.mousePressed(e); } }
From source file:erigo.ctstream.CTstream.java
/** * //from ww w. j a va2 s .c om * mouseMoved * * Implement the mouseMoved method defined by interface MouseMotionListener. * * This method is part of our homemade window manager; specifically, this method * handles setting the appropriate mouse cursor based on where the user has * positioned the mouse on the JFrame window. * * Why have we implemented our own window manager? Since translucent panels * can only be contained within undecorated Frames (see comments in the top * header above) and since undecorated Frames don't support moving/resizing, * we implement our own basic "window manager" by catching mouse move and drag * events. * * @author John P. Wilson * @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent) */ @Override public void mouseMoved(MouseEvent mouseEventI) { // System.err.println("mouseMoved: " + mouseEventI.getX() + "," + mouseEventI.getY()); mouseCommandMode = NO_COMMAND; // Set mouse Cursor based on the current mouse position int commandMode = getGUIFrameCommandMode(mouseEventI.getPoint()); switch (commandMode) { case NO_COMMAND: guiFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); break; case MOVE_FRAME: guiFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); break; case RESIZE_FRAME_NW: guiFrame.setCursor(new Cursor(Cursor.NW_RESIZE_CURSOR)); break; case RESIZE_FRAME_N: guiFrame.setCursor(new Cursor(Cursor.N_RESIZE_CURSOR)); break; case RESIZE_FRAME_NE: guiFrame.setCursor(new Cursor(Cursor.NE_RESIZE_CURSOR)); break; case RESIZE_FRAME_E: guiFrame.setCursor(new Cursor(Cursor.E_RESIZE_CURSOR)); break; case RESIZE_FRAME_SE: guiFrame.setCursor(new Cursor(Cursor.SE_RESIZE_CURSOR)); break; case RESIZE_FRAME_S: guiFrame.setCursor(new Cursor(Cursor.S_RESIZE_CURSOR)); break; case RESIZE_FRAME_SW: guiFrame.setCursor(new Cursor(Cursor.SW_RESIZE_CURSOR)); break; case RESIZE_FRAME_W: guiFrame.setCursor(new Cursor(Cursor.W_RESIZE_CURSOR)); break; default: guiFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); break; } }
From source file:org.pmedv.blackboard.components.BoardEditor.java
/** * Setup the listeners/* ww w.j a va 2 s . c om*/ */ private void initListeners() { addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseDragged(MouseEvent e) { handleMouseDragged(e); } @Override public void mouseMoved(MouseEvent e) { Point p = e.getPoint(); p = BoardUtil.mirrorTransform(p, zoomLayer, e); if (editorMode.equals(EditorMode.CHECK_CONNECTIONS)) { mouseOverLine = EditorUtils.findMouseOverLine(e, BoardEditor.this); } else { mouseOverPin = EditorUtils.findPin(e.getX(), e.getY(), BoardEditor.this); } win.getCustomLabel().setText("x : " + e.getX() + " y : " + e.getY()); if (mouseOverPin != null) { tooltipBuffer.delete(0, tooltipBuffer.length()); tooltipBuffer.append(mouseOverPin.getNum()); if (mouseOverPin.getName() != null) { tooltipBuffer.append(" " + mouseOverPin.getName()); } BoardEditor.this.setToolTipText(tooltipBuffer.toString()); ToolTipManager.sharedInstance() .mouseMoved(new MouseEvent(BoardEditor.this, 0, 0, 0, (int) p.getX(), (int) p.getY(), // X-Y of the mouse for the tool tip 0, false)); } else if (mouseOverLine != null) { tooltipBuffer.delete(0, tooltipBuffer.length()); tooltipBuffer.append("net : " + mouseOverLine.getNetIndex()); BoardEditor.this.setToolTipText(tooltipBuffer.toString()); ToolTipManager.sharedInstance() .mouseMoved(new MouseEvent(BoardEditor.this, 0, 0, 0, (int) p.getX(), (int) p.getY(), // X-Y of the mouse for the tool tip 0, false)); } else { BoardEditor.this.setToolTipText(null); } } }); addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { handleMousePressed(e); } @Override public void mouseReleased(MouseEvent e) { handleMouseReleased(e); } }); addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { Boolean invertMouse = (Boolean) Preferences.values .get("org.pmedv.blackboard.BoardDesignerPerspective.invertMouse"); if (invertMouse) { if (currentZoomIndex - e.getWheelRotation() < zoomLevels.length && currentZoomIndex - e.getWheelRotation() > 0) { currentZoomIndex -= e.getWheelRotation(); } } else { if (currentZoomIndex + e.getWheelRotation() < zoomLevels.length && currentZoomIndex + e.getWheelRotation() > 0) { currentZoomIndex += e.getWheelRotation(); } } JXLayer<?> layer = getZoomLayer(); TransformUI ui = (TransformUI) (Object) layer.getUI(); DefaultTransformModel model = (DefaultTransformModel) ui.getModel(); model.setScale(zoomLevels[currentZoomIndex]); ctx.getBean(ApplicationWindow.class).getZoomCombo().setSelectedItem(zoomLevels[currentZoomIndex]); } }); addMouseMotionListener(AppContext.getContext().getBean(AddTextCommand.class)); }