List of usage examples for java.awt Point Point
public Point(int x, int y)
From source file:com.igormaznitsa.ideamindmap.utils.IdeaUtils.java
public static void showPopup(@Nonnull final String text, @Nonnull final MessageType type) { SwingUtils.safeSwing(new Runnable() { @Override/*from ww w . j a v a 2s .c o m*/ public void run() { final JBPopupFactory factory = JBPopupFactory.getInstance(); final BalloonBuilder builder = factory .createHtmlTextBalloonBuilder(StringEscapeUtils.escapeHtml(text), type, null); final Balloon balloon = builder.createBalloon(); balloon.setAnimationEnabled(true); final Component frame = WindowManager.getInstance().findVisibleFrame(); if (frame != null) balloon.show(new RelativePoint(frame, new Point(frame.getWidth(), frame.getHeight())), Balloon.Position.below); } }); }
From source file:marytts.tools.redstart.AdminWindow.java
/** Further initialization of components on startup * (These can be edited in NetBeans, initComponents() cannot) *///from w ww . j a v a2 s . c o m private void initMoreComponents() { // Center window in the user's screen Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = getSize(); setLocation( new Point((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2)); // Set application icon in title bar left-hand corner this.setIconImage(Toolkit.getDefaultToolkit().getImage(IconSet.LOGO_16x16_URL)); // Change status icon in Admin window jLabel_SessionStatus.setIcon(IconSet.STOP_48X48); defaultPromptFont = jTextPane_PromptDisplay.getFont(); speakerWin.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { jCheckBoxMenuItem_SpeakerWindow.setSelected(false); } }); optionsDialog.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { speakerWin.showOrHidePromptCount(); } }); }
From source file:it.unibo.alchemist.boundary.monitors.Generic2DDisplay.java
/** * Gets the view center point. * * @return the center */ private Point getCenter() { return new Point(getWidth() / 2, getHeight() / 2); }
From source file:fr.landel.utils.commons.CollectionUtils2Test.java
/** * Test method for// w ww . ja v a 2s .c o m * {@link CollectionUtils2#transformIntoSet(I[], Transformer)} * {@link CollectionUtils2#transformIntoSet(I[], Function)} . */ @Test public void testTransformIntoSetIArrayTransformerOfIO() { try { Point[] points = new Point[3]; points[0] = new Point(1, 2); points[1] = new Point(2, 0); Set<String> pointsList = CollectionUtils2.transformIntoSet(points, TRANSFORMER); assertNotNull(pointsList); assertTrue(pointsList.size() > 0); assertThat(pointsList, Matchers.containsInAnyOrder("1, 2", "2, 0", null)); pointsList = CollectionUtils2.transformIntoSet(points, FUNCTION); assertNotNull(pointsList); assertTrue(pointsList.size() > 0); assertThat(pointsList, Matchers.containsInAnyOrder("1, 2", "2, 0", null)); } catch (IllegalArgumentException e) { fail("The test isn't correct"); } }
From source file:ca.uhn.hl7v2.testpanel.controller.Prefs.java
/** * Returns (-1,-1) if nothing was stored */// www .jav a 2s.com public Point getWindowPosition() { int x = myWindowPositionX != null ? myWindowPositionX : -1; int y = myWindowPositionY != null ? myWindowPositionY : -1; return new Point(x, y); }
From source file:dylemator.DylematorUI.java
private void createUserDialog() { ud = new UserDialog(this, true); int userInputWidth = ud.getWidth(); int userInputHeight = ud.getHeight(); int formInputWidth = this.getWidth(); int formInputHeight = this.getHeight(); int xposition = (formInputWidth - userInputWidth) / 2; int yposition = (formInputHeight - userInputHeight) / 2; Point p = new Point(xposition, yposition); ud.setLocation(p);//from ww w . ja v a2 s . c o m }
From source file:cn.pholance.datamanager.common.components.JRViewer.java
/** * *//*from w w w . jav a 2 s . c om*/ public void gotoHyperlink(JRPrintHyperlink hyperlink) { switch (hyperlink.getHyperlinkTypeValue()) { case REFERENCE: { if (isOnlyHyperlinkListener()) { System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference()); System.out.println("Implement your own JRHyperlinkListener to manage this type of event."); } break; } case LOCAL_ANCHOR: { if (hyperlink.getHyperlinkAnchor() != null) { Map<String, JRPrintAnchorIndex> anchorIndexes = jasperPrint.getAnchorIndexes(); JRPrintAnchorIndex anchorIndex = anchorIndexes.get(hyperlink.getHyperlinkAnchor()); if (anchorIndex.getPageIndex() != pageIndex) { setPageIndex(anchorIndex.getPageIndex()); refreshPage(); } Container container = pnlInScroll.getParent(); if (container instanceof JViewport) { JViewport viewport = (JViewport) container; int newX = (int) (anchorIndex.getElementAbsoluteX() * realZoom); int newY = (int) (anchorIndex.getElementAbsoluteY() * realZoom); int maxX = pnlInScroll.getWidth() - viewport.getWidth(); int maxY = pnlInScroll.getHeight() - viewport.getHeight(); if (newX < 0) { newX = 0; } if (newX > maxX) { newX = maxX; } if (newY < 0) { newY = 0; } if (newY > maxY) { newY = maxY; } viewport.setViewPosition(new Point(newX, newY)); } } break; } case LOCAL_PAGE: { int page = pageIndex + 1; if (hyperlink.getHyperlinkPage() != null) { page = hyperlink.getHyperlinkPage().intValue(); } if (page >= 1 && page <= jasperPrint.getPages().size() && page != pageIndex + 1) { setPageIndex(page - 1); refreshPage(); Container container = pnlInScroll.getParent(); if (container instanceof JViewport) { JViewport viewport = (JViewport) container; viewport.setViewPosition(new Point(0, 0)); } } break; } case REMOTE_ANCHOR: { if (isOnlyHyperlinkListener()) { System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference()); System.out.println("Hyperlink anchor : " + hyperlink.getHyperlinkAnchor()); System.out.println("Implement your own JRHyperlinkListener to manage this type of event."); } break; } case REMOTE_PAGE: { if (isOnlyHyperlinkListener()) { System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference()); System.out.println("Hyperlink page : " + hyperlink.getHyperlinkPage()); System.out.println("Implement your own JRHyperlinkListener to manage this type of event."); } break; } case CUSTOM: { if (isOnlyHyperlinkListener()) { System.out.println("Hyperlink of type " + hyperlink.getLinkType()); System.out.println("Implement your own JRHyperlinkListener to manage this type of event."); } break; } case NONE: default: { break; } } }
From source file:com.mirth.connect.client.ui.codetemplate.CodeTemplateImportDialog.java
private void initComponents() { setBackground(UIConstants.BACKGROUND_COLOR); getContentPane().setBackground(getBackground()); topPanel = new JPanel(); topPanel.setBackground(getBackground()); linkPanel = new JPanel(); linkPanel.setBackground(topPanel.getBackground()); linkLeftPanel = new JPanel(); linkLeftPanel.setBackground(linkPanel.getBackground()); linkLeftSelectAllLabel = new JLabel("<html><u>All</u></html>"); linkLeftSelectAllLabel.setForeground(Color.BLUE); linkLeftSelectAllLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); linkLeftSelectAllLabel.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent evt) { for (int row = 0; row < importTreeTable.getRowCount(); row++) { importTreeTable.getModel().setValueAt(true, row, IMPORT_SELECTED_COLUMN); }//from w w w. j a v a 2 s .c om } }); linkLeftDeselectAllLabel = new JLabel("<html><u>None</u></html>"); linkLeftDeselectAllLabel.setForeground(Color.BLUE); linkLeftDeselectAllLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); linkLeftDeselectAllLabel.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent evt) { for (int row = 0; row < importTreeTable.getRowCount(); row++) { importTreeTable.getModel().setValueAt(false, row, IMPORT_SELECTED_COLUMN); } } }); linkRightPanel = new JPanel(); linkRightPanel.setBackground(linkPanel.getBackground()); linkRightOverwriteAllLabel = new JLabel("<html><u>All</u></html>"); linkRightOverwriteAllLabel.setForeground(Color.BLUE); linkRightOverwriteAllLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); linkRightOverwriteAllLabel.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent evt) { for (int row = 0; row < importTreeTable.getRowCount(); row++) { TreePath path = importTreeTable.getPathForRow(row); if (path != null) { ImportTreeTableNode node = (ImportTreeTableNode) path.getLastPathComponent(); if (node instanceof ImportLibraryTreeTableNode) { ImportLibraryTreeTableNode libraryNode = (ImportLibraryTreeTableNode) node; if (libraryNode.getConflicts().getMatchingLibrary() != null) { importTreeTable.getModel().setValueAt(true, row, IMPORT_OVERWRITE_COLUMN); } } else if (node instanceof ImportCodeTemplateTreeTableNode) { ImportCodeTemplateTreeTableNode codeTemplateNode = (ImportCodeTemplateTreeTableNode) node; if (codeTemplateNode.getConflicts().getMatchingCodeTemplate() != null) { importTreeTable.getModel().setValueAt(true, row, IMPORT_OVERWRITE_COLUMN); } } } } } }); linkRightOverwriteNoneLabel = new JLabel("<html><u>None</u></html>"); linkRightOverwriteNoneLabel.setForeground(Color.BLUE); linkRightOverwriteNoneLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); linkRightOverwriteNoneLabel.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent evt) { for (int row = 0; row < importTreeTable.getRowCount(); row++) { TreePath path = importTreeTable.getPathForRow(row); if (path != null) { ImportTreeTableNode node = (ImportTreeTableNode) path.getLastPathComponent(); if (node instanceof ImportLibraryTreeTableNode) { ImportLibraryTreeTableNode libraryNode = (ImportLibraryTreeTableNode) node; if (libraryNode.getConflicts().getMatchingLibrary() != null) { importTreeTable.getModel().setValueAt(false, row, IMPORT_OVERWRITE_COLUMN); } } else if (node instanceof ImportCodeTemplateTreeTableNode) { ImportCodeTemplateTreeTableNode codeTemplateNode = (ImportCodeTemplateTreeTableNode) node; if (codeTemplateNode.getConflicts().getMatchingCodeTemplate() != null) { importTreeTable.getModel().setValueAt(false, row, IMPORT_OVERWRITE_COLUMN); } } } } } }); final TableCellEditor templateCellEditor = new NameCellEditor(); importTreeTable = new JXTreeTable() { @Override public boolean isCellEditable(int row, int column) { return (column == IMPORT_OVERWRITE_COLUMN || column == IMPORT_SELECTED_COLUMN || column == IMPORT_NAME_COLUMN); } @Override public TableCellEditor getCellEditor(int row, int column) { if (isHierarchical(column)) { return templateCellEditor; } else { return super.getCellEditor(row, column); } } }; importTreeTable.setLargeModel(true); DefaultTreeTableModel model = new ImportTreeTableModel(); model.setColumnIdentifiers(Arrays.asList(new String[] { "", "Name", "Overwrite", "Conflicts", "Id" })); DefaultMutableTreeTableNode rootNode = new DefaultMutableTreeTableNode(); model.setRoot(rootNode); importTreeTable.setTreeTableModel(model); Set<String> addedCodeTemplateIds = new HashSet<String>(); if (unassignedCodeTemplates) { ImportTreeTableNode libraryNode = new ImportUnassignedLibraryTreeTableNode("Select a library", ""); CodeTemplateLibrary library = importLibraries.get(0); for (CodeTemplate codeTemplate : library.getCodeTemplates()) { if (!addedCodeTemplateIds.contains(codeTemplate.getId())) { libraryNode .add(new ImportCodeTemplateTreeTableNode(codeTemplate.getName(), codeTemplate.getId())); addedCodeTemplateIds.add(codeTemplate.getId()); importCodeTemplateMap.put(codeTemplate.getId(), codeTemplate); } } rootNode.add(libraryNode); } else { Set<String> addedLibraryIds = new HashSet<String>(); for (CodeTemplateLibrary library : importLibraries) { if (!addedLibraryIds.contains(library.getId())) { ImportTreeTableNode libraryNode = new ImportLibraryTreeTableNode(library.getName(), library.getId()); importLibraryMap.put(library.getId(), library); for (CodeTemplate codeTemplate : library.getCodeTemplates()) { if (!addedCodeTemplateIds.contains(codeTemplate.getId())) { libraryNode.add(new ImportCodeTemplateTreeTableNode(codeTemplate.getName(), codeTemplate.getId())); addedCodeTemplateIds.add(codeTemplate.getId()); importCodeTemplateMap.put(codeTemplate.getId(), codeTemplate); } } rootNode.add(libraryNode); addedLibraryIds.add(library.getId()); } } } importTreeTable.setOpenIcon(null); importTreeTable.setClosedIcon(null); importTreeTable.setLeafIcon(null); importTreeTable.setRootVisible(false); importTreeTable.setDoubleBuffered(true); importTreeTable.setDragEnabled(false); importTreeTable.setRowSelectionAllowed(true); importTreeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); importTreeTable.setRowHeight(UIConstants.ROW_HEIGHT); importTreeTable.setFocusable(true); importTreeTable.setOpaque(true); importTreeTable.getTableHeader().setReorderingAllowed(false); importTreeTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); importTreeTable.setEditable(true); importTreeTable.setSortable(false); importTreeTable.setAutoCreateColumnsFromModel(false); importTreeTable.setShowGrid(true, true); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { importTreeTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } importTreeTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent evt) { checkSelection(evt); } @Override public void mouseReleased(MouseEvent evt) { checkSelection(evt); } private void checkSelection(MouseEvent evt) { int row = importTreeTable.rowAtPoint(new Point(evt.getX(), evt.getY())); if (row < 0) { importTreeTable.clearSelection(); } } }); importTreeTable.addTreeWillExpandListener(new TreeWillExpandListener() { @Override public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { } @Override public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException { throw new ExpandVetoException(event); } }); importTreeTable.setTreeCellRenderer(new NameCellRenderer()); importTreeTable.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent evt) { if (evt.getColumn() != IMPORT_CONFLICTS_COLUMN) { for (int row = evt.getFirstRow(); row <= evt.getLastRow() && row < importTreeTable.getRowCount(); row++) { TreePath path = importTreeTable.getPathForRow(row); if (path != null) { ImportTreeTableNode node = (ImportTreeTableNode) path.getLastPathComponent(); if (path.getPathCount() == 2) { if (node instanceof ImportUnassignedLibraryTreeTableNode) { String libraryName = (String) node.getValueAt(IMPORT_NAME_COLUMN); String libraryId = null; for (CodeTemplateLibrary library : PlatformUI.MIRTH_FRAME.codeTemplatePanel .getCachedCodeTemplateLibraries().values()) { if (library.getName().equals(libraryName)) { libraryId = library.getId(); break; } } node.setValueAt(libraryId, IMPORT_ID_COLUMN); } else if (node instanceof ImportLibraryTreeTableNode) { ImportLibraryTreeTableNode libraryNode = (ImportLibraryTreeTableNode) node; libraryNode.setConflicts(getLibraryConflicts(node)); } for (Enumeration<? extends TreeTableNode> codeTemplateNodes = node .children(); codeTemplateNodes.hasMoreElements();) { ImportCodeTemplateTreeTableNode codeTemplateNode = (ImportCodeTemplateTreeTableNode) codeTemplateNodes .nextElement(); codeTemplateNode.setConflicts(getCodeTemplateConflicts(codeTemplateNode)); } importTreeTable.updateUI(); } else if (path.getPathCount() == 3) { ImportCodeTemplateTreeTableNode codeTemplateNode = (ImportCodeTemplateTreeTableNode) node; codeTemplateNode.setConflicts(getCodeTemplateConflicts(node)); } } } } updateImportButton(); updateErrorsAndWarnings(); } }); importTreeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { updateImportButton(); updateErrorsAndWarnings(); } } }); importTreeTable.expandAll(); importTreeTable.getColumnModel().getColumn(IMPORT_SELECTED_COLUMN).setMinWidth(20); importTreeTable.getColumnModel().getColumn(IMPORT_SELECTED_COLUMN).setMaxWidth(20); importTreeTable.getColumnModel().getColumn(IMPORT_SELECTED_COLUMN) .setCellRenderer(new ImportSelectedCellRenderer()); importTreeTable.getColumnModel().getColumn(IMPORT_SELECTED_COLUMN) .setCellEditor(new ImportSelectedCellEditor()); importTreeTable.getColumnModel().getColumn(IMPORT_OVERWRITE_COLUMN).setMinWidth(60); importTreeTable.getColumnModel().getColumn(IMPORT_OVERWRITE_COLUMN).setMaxWidth(60); importTreeTable.getColumnModel().getColumn(IMPORT_OVERWRITE_COLUMN) .setCellRenderer(new OverwriteCellRenderer()); importTreeTable.getColumnModel().getColumn(IMPORT_OVERWRITE_COLUMN) .setCellEditor(new OverwriteCellEditor()); importTreeTable.getColumnModel().getColumn(IMPORT_CONFLICTS_COLUMN).setMinWidth(60); importTreeTable.getColumnModel().getColumn(IMPORT_CONFLICTS_COLUMN).setMaxWidth(60); importTreeTable.getColumnModel().getColumn(IMPORT_CONFLICTS_COLUMN).setCellRenderer(new IconCellRenderer()); importTreeTable.getColumnModel().removeColumn(importTreeTable.getColumnModel().getColumn(IMPORT_ID_COLUMN)); importTreeTableScrollPane = new JScrollPane(importTreeTable); importTreeTableScrollPane.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new Color(0x6E6E6E))); warningsPanel = new JPanel(); warningsPanel.setBackground(getBackground()); warningsPanel.setVisible(false); warningsLabel = new JLabel(UIConstants.ICON_WARNING); warningsTextArea = new JTextArea(); warningsTextArea.setLineWrap(true); warningsTextArea.setWrapStyleWord(true); errorsPanel = new JPanel(); errorsPanel.setBackground(getBackground()); errorsPanel.setVisible(false); errorsLabel = new JLabel(UIConstants.ICON_ERROR); errorsTextArea = new JTextArea(); errorsTextArea.setLineWrap(true); errorsTextArea.setWrapStyleWord(true); separator = new JSeparator(); buttonPanel = new JPanel(); buttonPanel.setBackground(getBackground()); importButton = new JButton("Import"); importButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { boolean warnings = false; for (Enumeration<? extends TreeTableNode> libraryNodes = ((TreeTableNode) importTreeTable .getTreeTableModel().getRoot()).children(); libraryNodes.hasMoreElements();) { for (Enumeration<? extends TreeTableNode> codeTemplateNodes = libraryNodes.nextElement() .children(); codeTemplateNodes.hasMoreElements();) { ImportCodeTemplateTreeTableNode codeTemplateNode = (ImportCodeTemplateTreeTableNode) codeTemplateNodes .nextElement(); if ((boolean) codeTemplateNode.getValueAt(IMPORT_SELECTED_COLUMN)) { CodeTemplateConflicts conflicts = codeTemplateNode.getConflicts(); if (conflicts.getMatchingCodeTemplate() != null) { warnings = true; break; } } } if (warnings) { break; } } if (!warnings || PlatformUI.MIRTH_FRAME.alertOption(CodeTemplateImportDialog.this, "Some selected rows have warnings. Are you sure you wish to continue?")) { save(); dispose(); } } catch (Exception e) { PlatformUI.MIRTH_FRAME.alertThrowable(CodeTemplateImportDialog.this, e, "Unable to import: " + e.getMessage()); } } }); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { if (confirmClose()) { dispose(); } } }); updateImportButton(); }
From source file:es.emergya.ui.gis.FleetControlMapViewer.java
@Override protected JPopupMenu getContextMenu() { JPopupMenu menu = new JPopupMenu(); menu.setBackground(Color.decode("#E8EDF6")); // Ttulo//from w w w . jav a 2s . c om final JMenuItem titulo = new JMenuItem(i18n.getString("map.menu.titulo.puntoGenerico")); titulo.setFont(LogicConstants.deriveBoldFont(10.0f)); titulo.setBackground(Color.decode("#A4A4A4")); titulo.setFocusable(false); menu.add(titulo); menu.addSeparator(); // Actualizar posicin final JMenuItem gps = new JMenuItem(i18n.getString("map.menu.gps"), KeyEvent.VK_P); gps.setIcon(LogicConstants.getIcon("menucontextual_icon_actualizargps")); menu.add(gps); gps.addActionListener(this); gps.setEnabled(false); menu.addSeparator(); // Mostrar ms cercanos final JMenuItem mmc = new JMenuItem(i18n.getString("map.menu.showNearest"), KeyEvent.VK_M); mmc.setIcon(LogicConstants.getIcon("menucontextual_icon_mascercano")); mmc.addActionListener(this); menu.add(mmc); // Centrar aqui final JMenuItem cent = new JMenuItem(i18n.getString("map.menu.centerHere"), KeyEvent.VK_C); cent.setIcon(LogicConstants.getIcon("menucontextual_icon_centrar")); cent.addActionListener(this); menu.add(cent); // Nueva Incidencia final JMenuItem newIncidence = new JMenuItem(i18n.getString("map.menu.newIncidence"), KeyEvent.VK_I); newIncidence.setIcon(LogicConstants.getIcon("menucontextual_icon_newIncidence")); newIncidence.addActionListener(this); menu.add(newIncidence); // Calcular ruta desde aqui final JMenuItem from = new JMenuItem(i18n.getString("map.menu.route.from"), KeyEvent.VK_D); from.setIcon(LogicConstants.getIcon("menucontextual_icon_origenruta")); from.addActionListener(this); menu.add(from); // Calcular ruta hasta aqui final JMenuItem to = new JMenuItem(i18n.getString("map.menu.route.to"), KeyEvent.VK_H); to.setIcon(LogicConstants.getIcon("menucontextual_icon_destinoruta")); to.addActionListener(this); menu.add(to); menu.addSeparator(); // Ver ficha [recurso / incidencia] final JMenuItem summary = new JMenuItem(i18n.getString("map.menu.summary"), KeyEvent.VK_F); summary.setIcon(LogicConstants.getIcon("menucontextual_icon_ficha")); summary.addActionListener(this); menu.add(summary); summary.setEnabled(false); menu.addPopupMenuListener(new PopupMenuListener() { @SuppressWarnings("unchecked") @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { eventOriginal = FleetControlMapViewer.this.mapView.lastMEvent; gps.setEnabled(false); summary.setEnabled(false); titulo.setText(i18n.getString("map.menu.titulo.puntoGenerico")); menuObjective = null; Point p = new Point(mapView.lastMEvent.getX(), mapView.lastMEvent.getY()); for (Layer l : mapView.getAllLayers()) { // por cada capa... if (l instanceof MarkerLayer) { // ...de marcadores for (Marker marker : ((MarkerLayer) l).data) { // miramos // los // marcadores if ((marker instanceof CustomMarker) && marker.containsPoint(p)) { // y si // estamos // pinchando // en uno CustomMarker m = (CustomMarker) marker; log.trace("Hemos pinchado en " + marker); switch (m.getType()) { case RESOURCE: Recurso r = (Recurso) m.getObject(); log.trace("Es un recurso: " + r); if (r != null) { menuObjective = r; if (r.getPatrullas() != null) { titulo.setText( i18n.getString(Locale.ROOT, "map.menu.titulo.recursoPatrulla", r.getIdentificador(), r.getPatrullas())); } else { titulo.setText(r.getIdentificador()); } gps.setEnabled(true); summary.setEnabled(true); } break; case INCIDENCE: Incidencia i = (Incidencia) m.getObject(); log.trace("Es una incidencia: " + i); if (i != null) { menuObjective = i; titulo.setText(i.getTitulo()); gps.setEnabled(false); summary.setEnabled(true); } break; case UNKNOWN: log.trace("Hemos pinchado en un marcador desconocido"); break; } } } } } } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } @Override public void popupMenuCanceled(PopupMenuEvent e) { } }); return menu; }
From source file:edu.purdue.cc.bionet.ui.GraphVisualizer.java
/** * Scales to the given zoom level, 1.0 being 100%, centered on the * given point./*from w w w . j av a2 s .c o m*/ * * @param level The level to zoom to. * @param center The center point for the scaling operation. * @return The new zoom level. */ public float scaleTo(float level, Point2D center) { if (this.scrollPane == null) return 1.0f; float oldZoom = this.currentZoom; this.currentZoom = Math.max(minimumZoom, level); // this.absoluteViewScaler.scale( this, level, center ); Dimension viewSize; if (level < 1.0f) { viewSize = this.scrollPane.getSize(); } else { viewSize = this.scrollPane.getViewport().getExtentSize(); } Dimension newSize = new Dimension((int) (viewSize.width * currentZoom), (int) (viewSize.height * currentZoom)); this.setPreferredSize(newSize); this.setSize(newSize); // new LayoutScaler( this.getGraphLayout( )).setSize( newSize ); if (Float.compare(level, 1.0f) <= 0) this.center(); // translate the new view position so the mouse is in the same place // on the scaled view. JViewport vp = this.scrollPane.getViewport(); double centerX = center.getX(); double centerY = center.getY(); double viewPortMouseX = centerX - vp.getViewPosition().getX(); double viewPortMouseY = centerY - vp.getViewPosition().getY(); centerX *= currentZoom / oldZoom; centerY *= currentZoom / oldZoom; viewPortMouseX = centerX - viewPortMouseX; viewPortMouseY = centerY - viewPortMouseY; vp.setViewPosition(new Point((int) viewPortMouseX, (int) viewPortMouseY)); return this.currentZoom; }