List of usage examples for java.awt.event MouseEvent getPoint
public Point getPoint()
From source file:org.openmicroscopy.shoola.agents.metadata.editor.DocComponent.java
/** Initializes the components composing the display. */ private void initComponents() { isModulo = model.isModulo(data);//from w ww .j a v a2 s .c o m imageToLoad = -1; initButtons(); label = new JLabel(); label.setForeground(UIUtilities.DEFAULT_FONT_COLOR); if (data == null) { label.setText(AnnotationUI.DEFAULT_TEXT); } else { if (data instanceof FileAnnotationData) { FileAnnotationData f = (FileAnnotationData) data; String fileName = f.getFileName(); String s = fileName; if (FileAnnotationData.MEASUREMENT_NS.equals(f.getNameSpace())) { String desc = f.getDescription(); if (desc != null && desc.trim().length() > 0) label.setText(desc); else { label.setText(UIUtilities.formatPartialName(EditorUtil.getPartialName(fileName))); } s = label.getText(); } else { label.setText(UIUtilities.formatPartialName(EditorUtil.getPartialName(fileName))); } label.setToolTipText(formatToolTip(f, s)); Iterator<CustomizedFileFilter> i = FILTERS.iterator(); CustomizedFileFilter filter; long id = f.getId(); while (i.hasNext()) { filter = i.next(); if (filter.accept(fileName)) { if (id > 0) imageToLoad = LOAD_FROM_SERVER; else imageToLoad = LOAD_FROM_LOCAL; break; } } if (id < 0) label.setForeground(DataObjectListCellRenderer.NEW_FOREGROUND_COLOR); switch (imageToLoad) { case LOAD_FROM_LOCAL: if (thumbnail == null) setThumbnail(f.getFilePath()); break; /* case LOAD_FROM_SERVER: if (thumbnail == null) { model.loadFile((FileAnnotationData) data, this); } */ } } else if (data instanceof File) { File f = (File) data; label.setText(EditorUtil.getPartialName(f.getName())); label.setForeground(Color.BLUE); } else if (data instanceof TagAnnotationData) { TagAnnotationData tag = (TagAnnotationData) data; label.setText(tag.getTagValue()); label.setToolTipText(formatToolTip(tag, null)); if (tag.getId() < 0) label.setForeground(DataObjectListCellRenderer.NEW_FOREGROUND_COLOR); } else if (data instanceof XMLAnnotationData) { XMLAnnotationData tag = (XMLAnnotationData) data; label.setText(EditorUtil.truncate(tag.getText(), TEXT_LENGTH, false)); label.setToolTipText(formatToolTip(tag, null)); if (tag.getId() < 0) label.setForeground(DataObjectListCellRenderer.NEW_FOREGROUND_COLOR); } else if (data instanceof TermAnnotationData) { TermAnnotationData tag = (TermAnnotationData) data; label.setText(tag.getTerm()); label.setToolTipText(formatToolTip(tag, null)); if (tag.getId() < 0) label.setForeground(DataObjectListCellRenderer.NEW_FOREGROUND_COLOR); } else if (data instanceof LongAnnotationData) { LongAnnotationData tag = (LongAnnotationData) data; label.setText(tag.getContentAsString()); label.setToolTipText(formatToolTip(tag, null)); if (tag.getId() < 0) label.setForeground(DataObjectListCellRenderer.NEW_FOREGROUND_COLOR); } else if (data instanceof DoubleAnnotationData) { DoubleAnnotationData tag = (DoubleAnnotationData) data; label.setText(tag.getContentAsString()); label.setToolTipText(formatToolTip(tag, null)); if (tag.getId() < 0) label.setForeground(DataObjectListCellRenderer.NEW_FOREGROUND_COLOR); } } label.addMouseListener(new MouseAdapter() { /** * Posts an event to edit the file. * @see MouseAdapter#mouseReleased(MouseEvent) */ public void mouseReleased(MouseEvent e) { if (e.getClickCount() == 1) { if (e.isPopupTrigger()) showMenu(label, e.getPoint()); } else if (e.getClickCount() == 2) postFileClicked(); } /** * Shows menu * @see MouseAdapter#mouseReleased(MouseEvent) */ public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) showMenu(label, e.getPoint()); } }); }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.PeakListChartPanel.java
public void mouseDragged(MouseEvent e) { if (mouse_start_point != null && theDocument.size() > 0) { if (is_moving) { // moving double mz_delta = screenToDataX(mouse_start_point.getX() - e.getPoint().getX()); if (mz_delta > 0.) { double old_upper_bound = thePlot.getDomainAxis().getUpperBound(); double old_lower_bound = thePlot.getDomainAxis().getLowerBound(); double new_upper_bound = Math.min(old_upper_bound + mz_delta, theDocument.getMaxMZ()); double new_lower_bound = old_lower_bound + new_upper_bound - old_upper_bound; thePlot.getDomainAxis().setRange(new Range(new_lower_bound, new_upper_bound)); } else { double old_upper_bound = thePlot.getDomainAxis().getUpperBound(); double old_lower_bound = thePlot.getDomainAxis().getLowerBound(); double new_lower_bound = Math.max(old_lower_bound + mz_delta, theDocument.getMinMZ()); double new_upper_bound = old_upper_bound + new_lower_bound - old_lower_bound; thePlot.getDomainAxis().setRange(new Range(new_lower_bound, new_upper_bound)); }//from ww w . j a va 2 s.c o m mouse_start_point = e.getPoint(); } else { // zooming Graphics2D g2 = (Graphics2D) theChartPanel.getGraphics(); g2.setXORMode(java.awt.Color.gray); // delete old rectangle if (zoom_rectangle != null) g2.draw(zoom_rectangle); // create new rectangle double start_x = Math.min(e.getX(), mouse_start_point.getX()); double end_x = Math.max(e.getX(), mouse_start_point.getX()); Rectangle2D data_area = theChartPanel.getScreenDataArea((int) start_x, (int) mouse_start_point.getY()); double xmax = Math.min(end_x, data_area.getMaxX()); zoom_rectangle = new Rectangle2D.Double(start_x, data_area.getMinY(), xmax - start_x, data_area.getHeight()); // draw new rectangle g2.draw(zoom_rectangle); g2.dispose(); } } }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.SpectraPanel.java
public void mouseClicked(MouseEvent e) { // find peak under mouse current_peak = findPeakAt(e.getPoint()); if (MouseUtils.isSelectTrigger(e)) setSelection(current_peak);/*from w w w.jav a2 s . c o m*/ else if (MouseUtils.isAddSelectTrigger(e)) addSelection(current_peak); else if (MouseUtils.isActionTrigger(e)) { setSelection(current_peak); onAnnotatePeaks(null); } else if (MouseUtils.isCtrlActionTrigger(e)) { setSelection(current_peak); onAddPeaks(); } }
From source file:org.nuclos.client.customcomp.resplan.ResPlanPanel.java
private void initJResPlan() { resPlan = new JResPlanComponent<Collectable, Date, Collectable, Collectable>(resPlanModel, timeModel); resPlan.getTimelineHeader().setCategoryModel(timeGranularityModel.getSelectedItem()); resPlan.addMouseListener(new AbstractJPopupMenuListener() { @Override/*from w w w.j av a 2s . co m*/ protected JPopupMenu getJPopupMenu(MouseEvent evt) { JPopupMenu popupMenu = new JPopupMenu(); Point pt = evt.getPoint(); Area<Collectable, Date> blankSelection = resPlan.getSelectedBlankArea(); if (blankSelection != null) { popupMenu.add(new AddAction(blankSelection.getResource(), blankSelection.getInterval())); } else { popupMenu.add(new AddAction(resPlan.getResourceAt(pt), resPlan.getTimeIntervalAt(pt))); } List<Collectable> selectedEntries = selectEntriesForEvent(pt); List<Collectable> selectedRelations = selectRelationsForEvent(pt); if (resPlan.isEditable() && (!selectedEntries.isEmpty() || !selectedRelations.isEmpty())) { JMenuItem menuItem = popupMenu.add(removeAction); boolean enabled = true; for (Collectable clct : selectedEntries) { if (!resPlanModel.isRemoveEntryAllowed(clct)) { enabled = false; break; } } for (Collectable clct : selectedRelations) { if (!resPlanModel.isRemoveRelationAllowed(clct)) { enabled = false; break; } } // Note: just change the state of the menu item (and leave the action as is) menuItem.setEnabled(enabled); } if (!selectedEntries.isEmpty() || !selectedRelations.isEmpty()) { popupMenu.add(detailsAction); } if (selectedEntries.size() == 1 && resPlanModel.getRelationEntity() != null && resPlanModel.isCreateRelationAllowed()) { popupMenu.addSeparator(); if (resPlan.getRelateBegin() != null) { Collectable to = selectedEntries.get(0); if (to != resPlan.getRelateBegin()) { popupMenu.add(relateFinishAction); } } popupMenu.add(relateBeginAction); } return popupMenu; } private List<Collectable> selectEntriesForEvent(Point pt) { List<Collectable> selection = resPlan.getSelectedEntries(); Collectable entryAt = resPlan.getEntryAt(pt); if (entryAt != null && (selection.isEmpty() || !selection.contains(entryAt))) { selection = Collections.singletonList(entryAt); resPlan.setSelectedEntries(selection); } return selection; } private List<Collectable> selectRelationsForEvent(Point pt) { List<Collectable> selection = resPlan.getSelectedRelations(); Collectable relAt = resPlan.getRelationAt(pt); if (relAt != null && (selection.isEmpty() || !selection.contains(relAt))) { selection = Collections.singletonList(relAt); resPlan.setSelectedRelations(selection); } return selection; } @Override public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { Collectable clct = resPlan.getEntryAt(evt.getPoint()); if (clct == null) { clct = resPlan.getRelationAt(evt.getPoint()); if (clct != null) { runDetailsCollectable(resPlanModel.getRelationEntity().getEntityName(), clct); } } else { runDetailsCollectable(resPlanModel.getEntryEntity().getEntityName(), clct); } evt.consume(); } } }); resPlan.getResourceHeader().addMouseListener(new AbstractJPopupMenuListener() { @Override public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { Collectable clct = resPlan.getResourceHeader().getValueAt(evt.getPoint()); runDetailsCollectable(resPlanModel.getResourceEntity().getEntityName(), clct); evt.consume(); } } @Override protected JPopupMenu getJPopupMenu(MouseEvent evt) { final Collectable clct = resPlan.getResourceHeader().getValueAt(evt.getPoint()); if (clct != null) { JPopupMenu popupMenu = new JPopupMenu(); popupMenu.add(new AbstractAction( SpringLocaleDelegate.getInstance().getText("nuclos.resplan.action.showDetails")) { @Override public void actionPerformed(ActionEvent e) { runDetailsCollectable(resPlanModel.getResourceEntity().getEntityName(), clct); } }); return popupMenu; } return null; } }); Date start = DateUtils.addDays(DateUtils.getPureDate(new Date()), -5); Date end = DateUtils.addDays(start, 30); resPlan.setTimeHorizon(new Interval<Date>(start, end)); }
From source file:SortableTable.java
/** * Handle a mouse press event - if the user is NOT resizing a column and NOT dragging a column * then give visual feedback that the column header has been pressed. * * @param e the mouse event.//from w ww . j a va 2 s . c o m */ public void mousePressed(final MouseEvent e) { final JTableHeader header = (JTableHeader) e.getComponent(); if (header.getResizingColumn() == null) { // resizing takes precedence over sorting if (header.getDraggedDistance() < 1) { // dragging also takes precedence over sorting final int columnIndex = header.columnAtPoint(e.getPoint()); final int modelColumnIndex = header.getTable().convertColumnIndexToModel(columnIndex); if (this.model.isSortable(modelColumnIndex)) { this.sortColumnIndex = header.getTable().convertColumnIndexToModel(columnIndex); this.renderer.setPressedColumn(this.sortColumnIndex); header.repaint(); if (header.getTable().isEditing()) { header.getTable().getCellEditor().stopCellEditing(); } } else { this.sortColumnIndex = -1; } } } }
From source file:org.openmicroscopy.shoola.agents.treeviewer.view.ToolBar.java
/** * Helper method to create the tool bar hosting the management items. * //w ww .j a v a2s . c o m * @return See above. */ private JComponent createManagementBar() { bar = new JToolBar(); bar.setFloatable(false); bar.setRollover(true); bar.setBorder(null); JToggleButton button = new JToggleButton(controller.getAction(TreeViewerControl.INSPECTOR)); button.setSelected(true); bar.add(button); button = new JToggleButton(controller.getAction(TreeViewerControl.METADATA)); button.setSelected(true); bar.add(button); JButton b = new JButton(controller.getAction(TreeViewerControl.BROWSE)); UIUtilities.unifiedButtonLookAndFeel(b); bar.add(b); switch (TreeViewerAgent.runAsPlugin()) { case TreeViewer.IMAGE_J: b = UIUtilities.formatButtonFromAction(controller.getAction(TreeViewerControl.VIEW)); UIUtilities.unifiedButtonLookAndFeel(b); b.addMouseListener(new MouseAdapter() { /** * Displays the menu when the user releases the mouse. * @see MouseListener#mouseReleased(MouseEvent) */ public void mouseReleased(MouseEvent e) { controller.showMenu(TreeViewer.VIEW_MENU, (JComponent) e.getSource(), e.getPoint()); } }); bar.add(b); break; default: b = new JButton(controller.getAction(TreeViewerControl.VIEW)); UIUtilities.unifiedButtonLookAndFeel(b); bar.add(b); } bar.add(new JSeparator(JSeparator.VERTICAL)); //Now register the agent if any TaskBar tb = TreeViewerAgent.getRegistry().getTaskBar(); List<JComponent> l = tb.getToolBarEntries(TaskBar.AGENTS); if (l != null) { Iterator<JComponent> i = l.iterator(); JComponent comp; while (i.hasNext()) { comp = i.next(); UIUtilities.unifiedButtonLookAndFeel(comp); bar.add(comp); } bar.add(new JSeparator(JSeparator.VERTICAL)); } fullScreen = new JToggleButton(controller.getAction(TreeViewerControl.FULLSCREEN)); fullScreen.setSelected(model.isFullScreen()); //bar.add(fullScreen); if (TreeViewerAgent.isAdministrator()) { b = new JButton(controller.getAction(TreeViewerControl.UPLOAD_SCRIPT)); UIUtilities.unifiedButtonLookAndFeel(b); bar.add(b); } TreeViewerAction a = controller.getAction(TreeViewerControl.AVAILABLE_SCRIPTS); b = new JButton(a); Icon icon = b.getIcon(); Dimension d = new Dimension(UIUtilities.DEFAULT_ICON_WIDTH, UIUtilities.DEFAULT_ICON_HEIGHT); if (icon != null) d = new Dimension(icon.getIconWidth(), icon.getIconHeight()); busyLabel = new JXBusyLabel(d); busyLabel.setVisible(true); b.addMouseListener((RunScriptAction) a); UIUtilities.unifiedButtonLookAndFeel(b); scriptButton = b; bar.add(b); index = bar.getComponentCount() - 1; bar.add(new JSeparator(JSeparator.VERTICAL)); MouseAdapter adapter = new MouseAdapter() { /** * Shows the menu corresponding to the display mode. */ public void mousePressed(MouseEvent me) { createGroupsAndUsersMenu((Component) me.getSource(), me.getPoint()); } }; a = controller.getAction(TreeViewerControl.SWITCH_USER); IconManager icons = IconManager.getInstance(); menuButton = new JButton(icons.getIcon(IconManager.FILTER_MENU)); menuButton.setVisible(true); menuButton.setText(GROUP_DISPLAY_TEXT); menuButton.setHorizontalTextPosition(SwingConstants.LEFT); menuButton.addMouseListener(adapter); bar.add(menuButton); setPermissions(); return bar; }
From source file:org.ut.biolab.medsavant.client.view.component.SearchableTablePanel.java
public SearchableTablePanel(String pageName, String[] columnNames, Class[] columnClasses, int[] hiddenColumns, boolean allowSearch, boolean allowSort, int defaultRows, boolean allowPages, TableSelectionType selectionType, int defaultRowsRetrieved, DataRetriever<Object[]> retriever) { this.pageName = pageName; this.rowsPerPageX = defaultRows; this.defaultRowsRetrieved = defaultRowsRetrieved; this.retriever = retriever; this.hiddenColumns = hiddenColumns; table = new SortableTable() { @Override//from ww w . j av a2 s.c o m public Component prepareRenderer(TableCellRenderer renderer, int row, int col) { synchronized (SearchableTablePanel.this) { JComponent comp = (JComponent) super.prepareRenderer(renderer, row, col); // Even index, selected or not selected if (isRowToggled(TableModelWrapperUtils.getActualRowAt(this.getSortableTableModel(), row))) { //this.getActualRowAt(this.getSortedRowAt(row)))) { comp.setBackground(new Color(178, 225, 92)); } else if (isCellSelected(row, col)) { //comp.setBackground(new Color(75, 149, 229)); comp.setBackground(SELECTED_COLOUR); } else if (selectedRows != null && selectedRows.contains(TableModelWrapperUtils.getActualRowAt(getModel(), row))) { //comp.setBackground(SELECTED_COLOUR); } else if (row % 2 == 0 && !isCellSelected(row, col)) { comp.setBackground(Color.WHITE); } else { comp.setBackground(DARK_COLOUR); } comp.setBorder(BorderFactory.createEmptyBorder(0, 7, 0, 7)); return comp; } } @Override public String getToolTipText(MouseEvent e) { return getToolTip( TableModelWrapperUtils.getActualRowAt(table.getModel(), table.rowAtPoint(e.getPoint()))); } }; table.setToolTipText(""); //necessary to force check for tooltip text table.setClearSelectionOnTableDataChanges(true); table.setOptimized(true); table.setColumnAutoResizable(true); table.setAutoResort(false); table.setRowHeight(20); table.setSortable(allowSort); table.setSortingEnabled(allowSort); table.setFocusable(selectionType != TableSelectionType.DISABLED); //table.setCellSelectionEnabled(allowSelection); table.setCellSelectionEnabled(selectionType == TableSelectionType.CELL); table.setRowSelectionAllowed(selectionType == TableSelectionType.ROW); table.setAutoResizeMode(SortableTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); //column chooser TableHeaderPopupMenuInstaller installer = new TableHeaderPopupMenuInstaller(table); installer.addTableHeaderPopupMenuCustomizer(new AutoResizePopupMenuCustomizer()); columnChooser = new ColumnChooser(table); installer.addTableHeaderPopupMenuCustomizer(columnChooser); AutoFilterTableHeader header = new AutoFilterTableHeader(table); header.setAutoFilterEnabled(true); header.setShowFilterIcon(true); header.setShowFilterName(true); table.setTableHeader(header); filterField = new QuickTableFilterField(model); if (allowPages) { filterField.setHintText("Search for anything on the page"); } else { filterField.setHintText("Search for anything"); } setLayout(new BorderLayout(3, 3)); fieldPanel = ViewUtil.getClearPanel(); if (allowSearch) { fieldPanel.add(filterField); } chooseColumnButton = new JButton("Columns"); chooseColumnButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { columnChooser.showDialog(); } }); helpButton = ViewUtil.getHelpButton("About Variant List", "Variants are sorted first by DNA ID, then by position. The list of variants within each page can be sorted by various fields by clicking the corresponding column name, but note that this will only sort the current page."); exportButton = new JButton("Export"); exportButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { try { ExportTable.exportTable(table); } catch (Exception ex) { LOG.error("Error while exporting.", ex); DialogUtils.displayException("MedSavant", "<HTML>A problem occurred while exporting.<BR>Make sure the output file is not already in use.</HTML>", ex); } } }); fieldPanel.add(helpButton); fieldPanel.add(chooseColumnButton); fieldPanel.add(exportButton); bottomPanel = ViewUtil.getClearPanel(); bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS)); gotoFirst = niceButton(); gotoPrevious = niceButton(); gotoNext = niceButton(); gotoLast = niceButton(); gotoFirst.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.FIRST)); gotoPrevious.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.PREVIOUS)); gotoNext.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.NEXT)); gotoLast.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.LAST)); gotoFirst.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToFirstPage(); } }); gotoPrevious.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToPreviousPage(); } }); gotoNext.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToNextPage(); } }); gotoLast.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToLastPage(); } }); pageText = new JTextField(); ViewUtil.makeSmall(pageText); pageText.setColumns(5); pageText.setMaximumSize(new Dimension(50, 20)); pageText.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { int key = e.getKeyCode(); if (key == KeyEvent.VK_ENTER) { try { setPageNumber(Integer.parseInt(pageText.getText())); } catch (NumberFormatException ex) { setPageNumber(0); } } } }); amountLabel = new JLabel(); ViewUtil.makeSmall(amountLabel); bottomPanel.add(amountLabel); pageLabel1 = new JLabel("Page "); ViewUtil.makeSmall(pageLabel1); pageLabel2 = new JLabel(); ViewUtil.makeSmall(pageLabel2); bottomPanel.add(Box.createHorizontalGlue()); bottomPanel.add(gotoFirst); bottomPanel.add(gotoPrevious); strut(bottomPanel); bottomPanel.add(pageLabel1); bottomPanel.add(pageText); bottomPanel.add(pageLabel2); strut(bottomPanel); bottomPanel.add(gotoNext); bottomPanel.add(gotoLast); bottomPanel.add(Box.createHorizontalGlue()); strut(bottomPanel); JLabel perpageL = new JLabel("Per page:"); ViewUtil.makeSmall(perpageL); bottomPanel.add(perpageL); strut(bottomPanel); boolean hasDefaultRowsPerPage = true; if (rowsPerPageX == ROWSPERPAGE_1 || rowsPerPageX == ROWSPERPAGE_2 || rowsPerPageX == ROWSPERPAGE_3) { hasDefaultRowsPerPage = false; } ArrayList<Integer> rowsList = new ArrayList<Integer>(); rowsList.add(ROWSPERPAGE_1); rowsList.add(ROWSPERPAGE_2); rowsList.add(ROWSPERPAGE_3); Integer[] finalList = new Integer[3]; if (hasDefaultRowsPerPage) { rowsList.add(rowsPerPageX); Collections.sort(rowsList); } finalList = rowsList.toArray(finalList); rowsPerPageDropdown = new JComboBox(finalList); ViewUtil.makeSmall(rowsPerPageDropdown); rowsPerPageDropdown.setPrototypeDisplayValue(ROWSPERPAGE_3); if (hasDefaultRowsPerPage) { rowsPerPageDropdown.setSelectedIndex(rowsList.indexOf(rowsPerPageX)); } else { rowsPerPageDropdown.setSelectedIndex(1); } rowsPerPageDropdown.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox) e.getSource(); int rowsPerPage = (Integer) cb.getSelectedItem(); setNumRowsPerPage(rowsPerPage); } }); rowsPerPageDropdown.setPreferredSize(new Dimension(100, 25)); rowsPerPageDropdown.setMaximumSize(new Dimension(100, 25)); bottomPanel.add(rowsPerPageDropdown); setTableModel(data, columnNames, columnClasses); JPanel tablePanel = new JPanel(new BorderLayout(3, 3)); JScrollPane jsp = new JScrollPane(table); jsp.setBorder(null); tablePanel.add(jsp); if (allowSort) { add(fieldPanel, BorderLayout.NORTH); } if (allowPages) { add(bottomPanel, BorderLayout.SOUTH); } add(tablePanel, BorderLayout.CENTER); initEmpty(); }
From source file:org.wandora.application.gui.OccurrenceTableSingleType.java
public Point getTableModelPoint(java.awt.event.MouseEvent event) { try {/*w ww. j a va 2s . c om*/ Point coords = event.getPoint(); return getTableModelPoint(coords); } catch (Exception ex) { return null; } }
From source file:org.wandora.application.gui.OccurrenceTableSingleType.java
public Point getTablePoint(java.awt.event.MouseEvent e) { try {//from w ww.j ava 2 s . co m java.awt.Point p = e.getPoint(); int row = rowAtPoint(p); int col = columnAtPoint(p); return new Point(col, row); } catch (Exception ex) { wandora.handleError(ex); return null; } }
From source file:eu.esdihumboldt.hale.ui.views.styledmap.tool.InstanceTool.java
/** * @see AbstractMapTool#click(MouseEvent, GeoPosition) *///w ww. j a v a2 s . c o m @Override public void click(MouseEvent me, GeoPosition pos) { if (me.getClickCount() == 2) { mapKit.setCenterPosition(pos); mapKit.setZoom(mapKit.getMainMap().getZoom() - 1); } else if (me.getClickCount() == 1) { if (me.isAltDown() && getPositions().size() < 1) { // add pos addPosition(pos); } else if (getPositions().size() == 1) { // finish box selection // action & reset addPosition(pos); // action try { List<Point2D> points = getPoints(); Rectangle rect = new Rectangle((int) points.get(0).getX(), (int) points.get(0).getY(), 0, 0); rect.add(points.get(1)); updateSelection(rect, me.isControlDown() || me.isMetaDown(), true); } catch (IllegalGeoPositionException e) { log.error("Error calculating selection box", e); //$NON-NLS-1$ } reset(); } else { // click selection reset(); updateSelection(me.getPoint(), me.isControlDown() || me.isMetaDown(), true); } } }