List of usage examples for java.awt.event MouseEvent getX
public int getX()
From source file:ucar.unidata.idv.control.chart.TimeSeriesChartWrapper.java
/** * Callback method for receiving notification of a mouse click on a chart. * * @param event information about the event. * * @return Did we handle this event//from w w w . j a v a 2 s. co m */ public boolean chartPanelMousePressed(MouseEvent event) { if (SwingUtilities.isRightMouseButton(event)) { closestAnnotation = findClosestAnnotation(getAllAnnotations(), event.getX(), event.getY(), false, false); } return EVENT_PASSON; }
From source file:nosqltools.MainForm.java
public void connect() { String user;/*from w ww .java2s .com*/ String pass; String dbname; String serveradd; int port; LoginDialog dlg_login = new LoginDialog(null); dlg_login.setVisible(true); //If user chose login and not cancel option on dialog box if (dlg_login.isToLogin()) { Text_MessageBar.setText(Initializations.DBATTEMPTING); Text_MessageBar.setForeground(Color.ORANGE); user = dlg_login.getUsername(); pass = dlg_login.getPassword(); dbname = dlg_login.getDatabase(); serveradd = dlg_login.getServerAddr(); port = dlg_login.getPort(); if (dbcon.connect(user, pass, dbname, serveradd, port)) { DefaultTreeModel defTableMod = dbcon.buildDBTree(); if (defTableMod != null && dbcon.isConnectionSuccess()) { jTree1.setModel(defTableMod); Text_MessageBar.setText(Initializations.DBCONNSUCCESS); Text_MessageBar.setForeground(Color.GREEN); Menu_Collections.setEnabled(true); //load the data of collection in panel_text on double click jTree1.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if (me.getButton() == MouseEvent.BUTTON1) { if (me.getClickCount() == 2) { //get the path of the mouse click ex:[localhost,test,testData] Op_Refresh.setEnabled(true); tp = jTree1.getPathForLocation(me.getX(), me.getY()); if (tp != null) { List<String> coll_db = dbcon.getAllCollections(); int cnt = tp.getPathCount(); for (int i = 0; i < cnt; i++) { //if one of the collection matches the coll that was clicked by the user load data if (coll_db.contains(tp.getPathComponent(i).toString())) { indexOfCurrentCollection = i; sb = dbcon.getCollectionData(tp.getPathComponent(i).toString()); if (sb != null) { Panel_Text.setVisible(true); JsonNode jNode1; try { jNode1 = mapper.readTree(sb.toString()); textArea.setText(mapper.writerWithDefaultPrettyPrinter() .writeValueAsString(jNode1)); } catch (IOException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex); } Text_MessageBar.setText(Initializations.INITSTRING); // textArea.setText(sb.toString()); validateDataPanel_text(sb); /* if (json_util.isValid(sb.toString())) { json_util.isDataParsed(textArea.getText()); Text_MessageBar.setText(Initializations.JSONFILESUCCESS); } else { sb.setLength(0); //JOptionPane.showMessageDialog(this, Initializations.JSONINCORRECTFORMAT , Initializations.VALIDATIONERROR , JOptionPane.ERROR_MESSAGE); try { Object obj = parser.parse(sb.toString()); } catch(org.json.simple.parser.ParseException pe) { Text_MessageBar.setText(Initializations.ERRORLINE + json_util.getLineNumber(pe.getPosition(), textArea.getText()) + " - " + pe); } } */ } else { Panel_Text.setVisible(false); Text_MessageBar.setText(Initializations.SYSTEMCOLL); Text_MessageBar.setForeground(Color.RED); } } } } } } } }); } else { jTree1.setModel(null); Text_MessageBar.setText(Initializations.DBCONNFAIL); Text_MessageBar.setForeground(Color.RED); } } else { jTree1.setModel(null); Text_MessageBar.setText(Initializations.DBCONNFAIL); Text_MessageBar.setForeground(Color.RED); } } else { jTree1.setModel(null); Text_MessageBar.setText(Initializations.DBCONNFAIL); Text_MessageBar.setForeground(Color.RED); } }
From source file:com.mirth.connect.client.ui.DashboardPanel.java
/** * Makes the status table with all current server information. *//*from www .j ava 2 s .c o m*/ public void makeStatusTable() { List<String> columns = new ArrayList<String>(); for (DashboardColumnPlugin plugin : LoadedExtensions.getInstance().getDashboardColumnPlugins().values()) { if (plugin.isDisplayFirst()) { columns.add(plugin.getColumnHeader()); } } columns.addAll(Arrays.asList(defaultColumns)); for (DashboardColumnPlugin plugin : LoadedExtensions.getInstance().getDashboardColumnPlugins().values()) { if (!plugin.isDisplayFirst()) { columns.add(plugin.getColumnHeader()); } } DashboardTreeTableModel model = new DashboardTreeTableModel(); model.setColumnIdentifiers(columns); model.setNodeFactory(new DefaultDashboardTableNodeFactory()); for (DashboardTablePlugin plugin : LoadedExtensions.getInstance().getDashboardTablePlugins().values()) { dashboardTable = plugin.getTable(); if (dashboardTable != null) { break; } } defaultVisibleColumns.addAll(columns); if (dashboardTable == null) { dashboardTable = new MirthTreeTable("dashboardPanel", defaultVisibleColumns); } dashboardTable.setColumnFactory(new DashboardTableColumnFactory()); dashboardTable.setTreeTableModel(model); dashboardTable.setDoubleBuffered(true); dashboardTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); dashboardTable.setHorizontalScrollEnabled(true); dashboardTable.packTable(UIConstants.COL_MARGIN); dashboardTable.setRowHeight(UIConstants.ROW_HEIGHT); dashboardTable.setOpaque(true); dashboardTable.setRowSelectionAllowed(true); dashboardTable.setSortable(true); dashboardTable.putClientProperty("JTree.lineStyle", "Horizontal"); dashboardTable.setAutoCreateColumnsFromModel(false); dashboardTable.setShowGrid(true, true); dashboardTable.restoreColumnPreferences(); dashboardTable.setMirthColumnControlEnabled(true); dashboardTable.setTreeCellRenderer(new DefaultTreeCellRenderer() { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { JLabel label = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); TreePath path = dashboardTable.getPathForRow(row); if (path != null) { AbstractDashboardTableNode node = ((AbstractDashboardTableNode) path.getLastPathComponent()); if (node.isGroupNode()) { setIcon(UIConstants.ICON_GROUP); } else { DashboardStatus status = node.getDashboardStatus(); if (status.getStatusType() == StatusType.CHANNEL) { setIcon(UIConstants.ICON_CHANNEL); } else { setIcon(UIConstants.ICON_CONNECTOR); } } } return label; } }); dashboardTable.setLeafIcon(UIConstants.ICON_CONNECTOR); dashboardTable.setOpenIcon(UIConstants.ICON_CHANNEL); dashboardTable.setClosedIcon(UIConstants.ICON_CHANNEL); dashboardTableScrollPane.setViewportView(dashboardTable); dashboardTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent event) { checkSelectionAndPopupMenu(event); } @Override public void mouseReleased(MouseEvent event) { checkSelectionAndPopupMenu(event); } @Override public void mouseClicked(MouseEvent event) { int clickedRow = dashboardTable.rowAtPoint(new Point(event.getX(), event.getY())); if (clickedRow == -1) { return; } TreePath path = dashboardTable.getPathForRow(clickedRow); if (path != null && ((AbstractDashboardTableNode) path.getLastPathComponent()).isGroupNode()) { return; } if (event.getClickCount() >= 2 && dashboardTable.getSelectedRowCount() == 1 && dashboardTable.getSelectedRow() == clickedRow) { parent.doShowMessages(); } } }); dashboardTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { /* * MIRTH-3199: Only update the panel plugin if the selection is finished. This does * mean that the logs aren't updated live when adding to or removing from a * currently adjusting selection, but it's much more efficient when it comes to the * number of requests being done from the client. Plus, it actually will still * update while a selection is adjusting if the refresh interval on the dashboard * elapses. We can change this so that plugins are updated during a selection * adjustment, but it would first require a major rewrite of the connection log / * status column plugin. */ updatePopupMenu(!event.getValueIsAdjusting()); } }); }
From source file:de.tor.tribes.ui.panels.MinimapPanel.java
/** * Creates new form MinimapPanel//ww w . java 2 s . com */ MinimapPanel() { initComponents(); setSize(300, 300); mMinimapListeners = new LinkedList<>(); mToolChangeListeners = new LinkedList<>(); setCursor(ImageManager.getCursor(iCurrentCursor)); mScreenshotPanel = new ScreenshotPanel(); minimapButtons.put(ID_MINIMAP, new Rectangle(2, 2, 26, 26)); minimapButtons.put(ID_ALLY_CHART, new Rectangle(30, 2, 26, 26)); minimapButtons.put(ID_TRIBE_CHART, new Rectangle(60, 2, 26, 26)); try { minimapIcons.put(ID_MINIMAP, ImageIO.read(new File("./graphics/icons/minimap.png"))); minimapIcons.put(ID_ALLY_CHART, ImageIO.read(new File("./graphics/icons/ally_chart.png"))); minimapIcons.put(ID_TRIBE_CHART, ImageIO.read(new File("./graphics/icons/tribe_chart.png"))); } catch (Exception ignored) { } jPanel1.add(mScreenshotPanel); rVisiblePart = new Rectangle(ServerSettings.getSingleton().getMapDimension()); zoomed = false; MarkerManager.getSingleton().addManagerListener(this); TagManager.getSingleton().addManagerListener(this); MinimapRepaintThread.getSingleton().setVisiblePart(rVisiblePart); if (!GlobalOptions.isMinimal()) { MinimapRepaintThread.getSingleton().start(); } addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (!showControls && e.getButton() != MouseEvent.BUTTON1) { //show controls Point p = e.getPoint(); p.translate(-5, -5); showControls(p); return; } if (!showControls && iCurrentView == ID_MINIMAP) { Point p = mousePosToMapPosition(e.getX(), e.getY()); DSWorkbenchMainFrame.getSingleton().centerPosition(p.getX(), p.getY()); MapPanel.getSingleton().getMapRenderer().initiateRedraw(MapRenderer.ALL_LAYERS); if (MinimapZoomFrame.getSingleton().isVisible()) { MinimapZoomFrame.getSingleton().toFront(); } } else { if (minimapButtons.get(ID_MINIMAP).contains(e.getPoint())) { iCurrentView = ID_MINIMAP; mBuffer = null; showControls = false; MinimapRepaintThread.getSingleton().update(); } else if (minimapButtons.get(ID_ALLY_CHART).contains(e.getPoint())) { iCurrentView = ID_ALLY_CHART; lastHash = 0; showControls = false; updateComplete(); } else if (minimapButtons.get(ID_TRIBE_CHART).contains(e.getPoint())) { iCurrentView = ID_TRIBE_CHART; lastHash = 0; showControls = false; updateComplete(); } } } @Override public void mousePressed(MouseEvent e) { if (iCurrentView != ID_MINIMAP) { return; } if (iCurrentCursor == ImageManager.CURSOR_SHOT || iCurrentCursor == ImageManager.CURSOR_ZOOM) { iXDown = e.getX(); iYDown = e.getY(); } } @Override public void mouseReleased(MouseEvent e) { if (iCurrentView != ID_MINIMAP) { return; } if (rDrag == null) { return; } if (iCurrentCursor == ImageManager.CURSOR_SHOT) { try { BufferedImage i = MinimapRepaintThread.getSingleton().getImage(); double widthFactor = ((double) ServerSettings.getSingleton().getMapDimension().width) / getWidth(); double heightFactor = ((double) ServerSettings.getSingleton().getMapDimension().height) / getHeight(); int x = (int) Math.rint(widthFactor * rDrag.getX()); int y = (int) Math.rint(heightFactor * rDrag.getY()); int w = (int) Math.rint(widthFactor * (rDrag.getWidth() - rDrag.getX())); int h = (int) Math.rint(heightFactor * (rDrag.getHeight() - rDrag.getY())); BufferedImage sub = i.getSubimage(x, y, w, h); mScreenshotPanel.setBuffer(sub); jPanel1.setSize(mScreenshotPanel.getSize()); jPanel1.setPreferredSize(mScreenshotPanel.getSize()); jPanel1.setMinimumSize(mScreenshotPanel.getSize()); jPanel1.setMaximumSize(mScreenshotPanel.getSize()); jScreenshotPreview.pack(); jScreenshotControl.pack(); jScreenshotPreview.setVisible(true); jScreenshotControl.setVisible(true); } catch (Exception ie) { logger.error("Failed to initialize mapshot", ie); } } else if (iCurrentCursor == ImageManager.CURSOR_ZOOM) { if (!zoomed) { Rectangle mapDim = ServerSettings.getSingleton().getMapDimension(); double widthFactor = ((double) mapDim.width) / getWidth(); double heightFactor = ((double) mapDim.height) / getHeight(); int x = (int) Math.rint(widthFactor * rDrag.getX() + mapDim.getMinX()); int y = (int) Math.rint(heightFactor * rDrag.getY() + mapDim.getMinY()); int w = (int) Math.rint(widthFactor * (rDrag.getWidth() - rDrag.getX())); if (w >= 10) { rVisiblePart = new Rectangle(x, y, w, w); MinimapRepaintThread.getSingleton().setVisiblePart(rVisiblePart); redraw(); zoomed = true; } } else { rVisiblePart = new Rectangle(ServerSettings.getSingleton().getMapDimension()); MinimapRepaintThread.getSingleton().setVisiblePart(rVisiblePart); redraw(); zoomed = false; } MinimapZoomFrame.getSingleton().setVisible(false); } iXDown = 0; iYDown = 0; rDrag = null; } @Override public void mouseEntered(MouseEvent e) { if (iCurrentView != ID_MINIMAP) { return; } switch (iCurrentCursor) { case ImageManager.CURSOR_ZOOM: { MinimapZoomFrame.getSingleton().setVisible(true); } } } @Override public void mouseExited(MouseEvent e) { if (MinimapZoomFrame.getSingleton().isVisible()) { MinimapZoomFrame.getSingleton().setVisible(false); } iXDown = 0; iYDown = 0; rDrag = null; } }); addMouseMotionListener(new MouseMotionListener() { @Override public void mouseDragged(MouseEvent e) { if (iCurrentView != ID_MINIMAP) { return; } switch (iCurrentCursor) { case ImageManager.CURSOR_MOVE: { Point p = mousePosToMapPosition(e.getX(), e.getY()); DSWorkbenchMainFrame.getSingleton().centerPosition(p.x, p.y); rDrag = null; break; } case ImageManager.CURSOR_SHOT: { rDrag = new Rectangle2D.Double(iXDown, iYDown, e.getX(), e.getY()); break; } case ImageManager.CURSOR_ZOOM: { rDrag = new Rectangle2D.Double(iXDown, iYDown, e.getX(), e.getY()); break; } } } @Override public void mouseMoved(MouseEvent e) { if (iCurrentView == ID_MINIMAP) { switch (iCurrentCursor) { case ImageManager.CURSOR_ZOOM: { if (!MinimapZoomFrame.getSingleton().isVisible()) { MinimapZoomFrame.getSingleton().setVisible(true); } int mapWidth = (int) ServerSettings.getSingleton().getMapDimension().getWidth(); int mapHeight = (int) ServerSettings.getSingleton().getMapDimension().getHeight(); int x = (int) Math.rint((double) mapWidth / (double) getWidth() * (double) e.getX()); int y = (int) Math.rint((double) mapHeight / (double) getHeight() * (double) e.getY()); MinimapZoomFrame.getSingleton().updatePosition(x, y); break; } default: { if (MinimapZoomFrame.getSingleton().isVisible()) { MinimapZoomFrame.getSingleton().setVisible(false); } } } } Point location = minimapButtons.get(ID_MINIMAP).getLocation(); location.translate(-2, -2); if (!new Rectangle(location.x, location.y, 88, 30).contains(e.getPoint())) { //hide controls showControls = false; repaint(); } } }); addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { if (iCurrentView != ID_MINIMAP) { return; } iCurrentCursor += e.getWheelRotation(); if (iCurrentCursor == ImageManager.CURSOR_DEFAULT + e.getWheelRotation()) { if (e.getWheelRotation() < 0) { iCurrentCursor = ImageManager.CURSOR_SHOT; } else { iCurrentCursor = ImageManager.CURSOR_MOVE; } } else if (iCurrentCursor < ImageManager.CURSOR_MOVE) { iCurrentCursor = ImageManager.CURSOR_DEFAULT; } else if (iCurrentCursor > ImageManager.CURSOR_SHOT) { iCurrentCursor = ImageManager.CURSOR_DEFAULT; } if (iCurrentCursor != ImageManager.CURSOR_ZOOM) { if (MinimapZoomFrame.getSingleton().isVisible()) { MinimapZoomFrame.getSingleton().setVisible(false); } } else { MinimapZoomFrame.getSingleton().setVisible(true); } setCurrentCursor(iCurrentCursor); } }); }
From source file:com.t3.client.ui.T3Frame.java
private JComponent createTokenTreePanel() { final JTree tree = new JTree(); tokenPanelTreeModel = new TokenPanelTreeModel(tree); tree.setModel(tokenPanelTreeModel);// w w w . j ava 2s.c o m tree.setCellRenderer(new TokenPanelTreeCellRenderer()); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); tree.addMouseListener(new MouseAdapter() { // TODO: Make this a handler class, not an aic @Override public void mousePressed(MouseEvent e) { // tree.setSelectionPath(tree.getPathForLocation(e.getX(), e.getY())); TreePath path = tree.getPathForLocation(e.getX(), e.getY()); if (path == null) { return; } Object row = path.getLastPathComponent(); int rowIndex = tree.getRowForLocation(e.getX(), e.getY()); if (SwingUtilities.isLeftMouseButton(e)) { if (!SwingUtil.isShiftDown(e)) { tree.clearSelection(); } tree.addSelectionInterval(rowIndex, rowIndex); if (row instanceof Token) { if (e.getClickCount() == 2) { Token token = (Token) row; getCurrentZoneRenderer().clearSelectedTokens(); getCurrentZoneRenderer().centerOn(new ZonePoint(token.getX(), token.getY())); // Pick an appropriate tool getToolbox().setSelectedTool(token.isToken() ? PointerTool.class : StampTool.class); getCurrentZoneRenderer().setActiveLayer(token.getLayer()); getCurrentZoneRenderer().selectToken(token.getId()); getCurrentZoneRenderer().requestFocusInWindow(); } } } if (SwingUtilities.isRightMouseButton(e)) { if (!isRowSelected(tree.getSelectionRows(), rowIndex) && !SwingUtil.isShiftDown(e)) { tree.clearSelection(); tree.addSelectionInterval(rowIndex, rowIndex); } final int x = e.getX(); final int y = e.getY(); EventQueue.invokeLater(new Runnable() { @Override public void run() { Token firstToken = null; Set<GUID> selectedTokenSet = new HashSet<GUID>(); for (TreePath path : tree.getSelectionPaths()) { if (path.getLastPathComponent() instanceof Token) { Token token = (Token) path.getLastPathComponent(); if (firstToken == null) { firstToken = token; } if (AppUtil.playerOwns(token)) { selectedTokenSet.add(token.getId()); } } } if (!selectedTokenSet.isEmpty()) { try { if (firstToken.isStamp()) { new StampPopupMenu(selectedTokenSet, x, y, getCurrentZoneRenderer(), firstToken).showPopup(tree); } else { new TokenPopupMenu(selectedTokenSet, x, y, getCurrentZoneRenderer(), firstToken).showPopup(tree); } } catch (IllegalComponentStateException icse) { log.info(tree.toString(), icse); } } } }); } } }); TabletopTool.getEventDispatcher().addListener(new AppEventListener() { @Override public void handleAppEvent(AppEvent event) { tokenPanelTreeModel.setZone((Zone) event.getNewValue()); } }, TabletopTool.ZoneEvent.Activated); return tree; }
From source file:org.gumtree.vis.hist2d.Hist2DPanel.java
@Override public void mousePressed(MouseEvent e) { // int mods = e.getModifiers(); // if (isMaskingEnabled() && (mods & maskingKeyMask) != 0) { if (isMaskingEnabled()) { // Prepare masking service. int cursorType = findCursorOnSelectedItem(e.getX(), e.getY()); if (cursorType == Cursor.DEFAULT_CURSOR) { Rectangle2D screenDataArea = getScreenDataArea(e.getX(), e.getY()); if (screenDataArea != null) { this.maskPoint = getPointInRectangle(e.getX(), e.getY(), screenDataArea); } else { this.maskPoint = null; }/*w ww. ja v a 2 s . c o m*/ } else { if (cursorType == Cursor.MOVE_CURSOR) { Point2D point = translateScreenToChart(translateScreenToJava2D(e.getPoint())); if (point != null) { this.maskMovePoint = point; } } setMaskDragIndicator(cursorType); } } if (getMaskDragIndicator() == Cursor.DEFAULT_CURSOR) { if (e.getX() < getScreenDataArea().getMaxX()) { super.mousePressed(e); } } }
From source file:gda.gui.mca.McaGUI.java
private SimplePlot getSimplePlot() { if (simplePlot == null) { simplePlot = new SimplePlot(); simplePlot.setYAxisLabel("Values"); simplePlot.setTitle("MCA"); /*/*from w w w . j a v a2 s. c o m*/ * do not attempt to get calibration until the analyser is available getEnergyCalibration(); */ simplePlot.setXAxisLabel("Channel Number"); simplePlot.setTrackPointer(true); JPopupMenu menu = simplePlot.getPopupMenu(); JMenuItem item = new JMenuItem("Add Region Of Interest"); menu.add(item); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null, "To add a region of interest, please click on region low" + " and region high channels\n" + "in the graph and set the index\n"); regionClickCount = 0; } }); JMenuItem calibitem = new JMenuItem("Calibrate Energy"); /* * Comment out as calibration is to come from the analyser directly menu.add(calibitem); */ calibitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { // regionClickCount = 0; int[] data = (int[]) analyser.getData(); double[] dData = new double[data.length]; for (int i = 0; i < dData.length; i++) { dData[i] = data[i]; } if (energyCalibrationDialog == null) { energyCalibrationDialog = new McaCalibrationPanel( (EpicsMCARegionOfInterest[]) analyser.getRegionsOfInterest(), dData, mcaName); energyCalibrationDialog.addIObserver(McaGUI.this); } energyCalibrationDialog.setVisible(true); } catch (DeviceException e1) { logger.error("Exception: " + e1.getMessage()); } catch (Exception ex) { JOptionPane.showMessageDialog(null, ex.getMessage()); ex.printStackTrace(); } } }); simplePlot.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { // /////////System.out.println("Mouse clicked " + // me.getX() + " " // /////// + me.getY()); SimpleDataCoordinate coordinates = simplePlot.convertMouseEvent(me); if (simplePlot.getScreenDataArea().contains(me.getX(), me.getY()) && regionClickCount == 0) { regionLow = coordinates.toArray(); regionClickCount++; } else if (simplePlot.getScreenDataArea().contains(me.getX(), me.getY()) && regionClickCount == 1) { regionHigh = coordinates.toArray(); regionClickCount++; if (regionValid(regionLow[0], regionHigh[0])) { final String s = (String) JOptionPane.showInputDialog(null, "Please select the Region Index:\n", "Region Of Interest", JOptionPane.PLAIN_MESSAGE, null, null, String.valueOf(getNextRegion())); Thread t1 = uk.ac.gda.util.ThreadManager.getThread(new Runnable() { @Override public void run() { try { if (s != null) { int rIndex = Integer.parseInt(s); EpicsMCARegionOfInterest[] epc = { new EpicsMCARegionOfInterest() }; epc[0].setRegionLow(regionLow[0]); epc[0].setRegionHigh(regionHigh[0]); epc[0].setRegionIndex(rIndex); epc[0].setRegionName("region " + rIndex); analyser.setRegionsOfInterest(epc); addRegionMarkers(rIndex, regionLow[0], regionHigh[0]); } } catch (DeviceException e) { logger.error("Unable to set the table values"); } } }); t1.start(); } } } }); // TODO note that selectePlot cannot be changed runtime simplePlot.initializeLine(selectedPlot); simplePlot.setLineName(selectedPlot, getSelectedPlotString()); simplePlot.setLineColor(selectedPlot, getSelectedPlotColor()); simplePlot.setLineType(selectedPlot, "LineOnly"); } return simplePlot; }
From source file:net.rptools.maptool.client.ui.MapToolFrame.java
private JComponent createDrawTreePanel() { final JTree tree = new JTree(); drawablesPanel = new DrawablesPanel(); drawPanelTreeModel = new DrawPanelTreeModel(tree); tree.setModel(drawPanelTreeModel);//from www.j a v a2 s . c om tree.setCellRenderer(new DrawPanelTreeCellRenderer()); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setContinuousLayout(true); splitPane.setTopComponent(new JScrollPane(tree)); splitPane.setBottomComponent(drawablesPanel); splitPane.setDividerLocation(100); // Add mouse Event for right click menu tree.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { TreePath path = tree.getPathForLocation(e.getX(), e.getY()); if (path == null) { return; } Object row = path.getLastPathComponent(); int rowIndex = tree.getRowForLocation(e.getX(), e.getY()); if (SwingUtilities.isLeftMouseButton(e)) { if (!SwingUtil.isShiftDown(e) && !SwingUtil.isControlDown(e)) { tree.clearSelection(); } tree.addSelectionInterval(rowIndex, rowIndex); if (row instanceof DrawnElement) { if (e.getClickCount() == 2) { DrawnElement de = (DrawnElement) row; getCurrentZoneRenderer() .centerOn(new ZonePoint((int) de.getDrawable().getBounds().getCenterX(), (int) de.getDrawable().getBounds().getCenterY())); } } int[] treeRows = tree.getSelectionRows(); java.util.Arrays.sort(treeRows); drawablesPanel.clearSelectedIds(); for (int i = 0; i < treeRows.length; i++) { TreePath p = tree.getPathForRow(treeRows[i]); if (p.getLastPathComponent() instanceof DrawnElement) { DrawnElement de = (DrawnElement) p.getLastPathComponent(); drawablesPanel.addSelectedId(de.getDrawable().getId()); } } } if (SwingUtilities.isRightMouseButton(e)) { if (!isRowSelected(tree.getSelectionRows(), rowIndex) && !SwingUtil.isShiftDown(e)) { tree.clearSelection(); tree.addSelectionInterval(rowIndex, rowIndex); drawablesPanel.clearSelectedIds(); } final int x = e.getX(); final int y = e.getY(); EventQueue.invokeLater(new Runnable() { public void run() { DrawnElement firstElement = null; Set<GUID> selectedDrawSet = new HashSet<GUID>(); for (TreePath path : tree.getSelectionPaths()) { if (path.getLastPathComponent() instanceof DrawnElement) { DrawnElement de = (DrawnElement) path.getLastPathComponent(); if (firstElement == null) { firstElement = de; } selectedDrawSet.add(de.getDrawable().getId()); } } if (!selectedDrawSet.isEmpty()) { try { new DrawPanelPopupMenu(selectedDrawSet, x, y, getCurrentZoneRenderer(), firstElement).showPopup(tree); } catch (IllegalComponentStateException icse) { log.info(tree.toString(), icse); } } } }); } } }); // Add Zone Change event MapTool.getEventDispatcher().addListener(new AppEventListener() { public void handleAppEvent(AppEvent event) { drawPanelTreeModel.setZone((Zone) event.getNewValue()); } }, MapTool.ZoneEvent.Activated); return splitPane; }
From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java
private double userX(MouseEvent event) { Rectangle2D rectangle = getScaledDataArea(); double minX = rectangle.getMinX(); double maxX = rectangle.getMaxX(); Plot plot = chart.getPlot();//from ww w . ja v a 2s . c o m int xc = event.getX(); ValueAxis xa = this.getHorizontalValueAxis(plot); double xmin = xa.getLowerBound(); double xmax = xa.getUpperBound(); double u = (xc - minX) / (maxX - minX); return (u * (xmax - xmin) + xmin); }
From source file:base.BasePlayer.ClusterTable.java
public void mousePressed(MouseEvent event) { switch (event.getModifiers()) { case InputEvent.BUTTON1_MASK: { if (!this.isEnabled()) { break; }//from w ww . j a v a 2s .c o m this.dragX = event.getX(); if (headerHover > -1) { if (resizeColumn == -1) { if (sorter.ascending) { sorter.ascending = false; } else { sorter.ascending = true; } sorter.index = headerHover; Collections.sort(Main.drawCanvas.clusterNodes, sorter); createPolygon(); repaint(); } } } if (hoverNode != null || hoverVar != null) { Main.chromDraw.repaint(); } } }