List of usage examples for javax.swing JPopupMenu remove
public void remove(int pos)
From source file:net.sourceforge.processdash.ev.ui.chart.EVHiddenOrShownSeriesXYChartPanel.java
private void reloadSeriesMenus() { JPopupMenu menu = getPopupMenu(); while (menu.getComponent(0) instanceof ShowChartLineMenuItem) menu.remove(0); XYDataset data = filteredData.getSourceDataset(); for (int i = data.getSeriesCount(); i-- > 0;) menu.insert(new ShowChartLineMenuItem(filteredData, i), 0); }
From source file:slash.navigation.converter.gui.profileview.LazyToolTipChartPanel.java
protected JPopupMenu createPopupMenu(boolean properties, boolean copy, boolean save, boolean print, boolean zoom) { JPopupMenu popupMenu = super.createPopupMenu(properties, copy, save, print, zoom); // remove Zoom in/out plus separator from default menu popupMenu.remove(6); popupMenu.remove(5);/*from w w w . ja v a 2 s .co m*/ popupMenu.remove(4); JMenu menu = createMenu("show-profile"); new ProfileModeMenu(menu, profileModeModel); popupMenu.add(menu, 0); popupMenu.add(new JPopupMenu.Separator(), 1); return popupMenu; }
From source file:org.jax.bham.test.HaplotypeAssociationTestGraphPanel.java
private void updateClickPosition(int x, int y) { this.lastClickedIntervalIndex = this.getMaximalIntervalIndex(x, y); // remove the old menu items JPopupMenu popupMenu = this.chartPanel.getPopupMenu(); for (int i = 0; i < this.lastMenuItems.size(); i++) { popupMenu.remove(0); }/*from www. j a v a 2 s. c o m*/ // now replace the old menus with some new ones this.lastMenuItems = this.createContextMenuItems(); for (int i = 0; i < this.lastMenuItems.size(); i++) { popupMenu.insert(this.lastMenuItems.get(i), i); } }
From source file:com.AandR.beans.plotting.LinePlotPanel.LinePlotPanel.java
private ChartPanel createChartPanel() { JFreeChart xyChart = ChartFactory.createXYLineChart("f", "x", "y", plotSeries, PlotOrientation.VERTICAL, false, true, false);// www . ja v a 2s.c om RenderingHints hints = xyChart.getRenderingHints(); hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); hints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); xyChart.setBackgroundPaint(Color.WHITE); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyChart.getXYPlot().getRenderer(); renderer.setBaseLinesVisible(isLineVisible); renderer.setBaseShapesVisible(isSymbolVisible); LegendTitle legend = new LegendTitle(renderer); legend.setPosition(RectangleEdge.BOTTOM); xyChart.addLegend(legend); xyChart.getXYPlot().getRangeAxis().setStandardTickUnits(createTickUnits()); //xyChart.getXYPlot().getRangeAxis().setStandardTickUnits(new StandardTickUnitSource()); xyChart.getXYPlot().getRangeAxis().setAutoRangeMinimumSize(1.0e-45); chartPanel = new ChartPanel(xyChart); JPopupMenu popup = chartPanel.getPopupMenu(); popup.remove(1); // removes separator popup.remove(1); // removes save as... popup.add(createLinePropMenu()); popup.add(createAxesPropMenu()); popup.addSeparator(); popup.add(createExportMenu()); return chartPanel; }
From source file:org.rdv.ui.ChannelListPanel.java
private JPopupMenu getChannelPopup() { JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem;//from w ww . ja v a 2 s. c o m final List<String> channels = getSelectedChannels(); if (channels.isEmpty()) { return null; } String plural = (channels.size() == 1) ? "" : "s"; List<Extension> extensions = dataPanelManager.getExtensions(channels); if (extensions.size() > 0) { for (final Extension extension : extensions) { menuItem = new JMenuItem("View channel" + plural + " with " + extension.getName()); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { viewChannels(channels, extension); } }); popup.add(menuItem); } popup.addSeparator(); } if (dataPanelManager.isAnyChannelSubscribed(channels)) { menuItem = new JMenuItem("Unsubscribe from channel" + plural); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { dataPanelManager.unsubscribeChannels(channels); } }); popup.add(menuItem); popup.addSeparator(); } // menu item to remove local channels if (areLocal(channels)) { menuItem = new JMenuItem("Remove channel" + plural); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { LocalChannelManager lcm = LocalChannelManager.getInstance(); lcm.removeChannels(channels); } }); popup.add(menuItem); popup.addSeparator(); } String mime = getMime(channels); if (mime != null) { if (mime.equals("application/octet-stream")) { menuItem = new JMenuItem("Export data channel" + plural + "...", DataViewer.getIcon("icons/export.gif")); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { ActionFactory.getInstance().getDataExportAction().exportData(channels); } }); popup.add(menuItem); } else if (mime.equals("image/jpeg")) { menuItem = new JMenuItem("Export video channel" + plural + "...", DataViewer.getIcon("icons/export.gif")); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { JFrame frame = RDV.getInstance(RDV.class).getMainFrame(); new ExportVideoDialog(frame, rbnb, channels); } }); popup.add(menuItem); } else { popup.remove(popup.getComponentCount() - 1); } } return popup; }
From source file:org.ut.biolab.medsavant.client.view.genetics.variantinfo.VariantFrequencyAggregatePane.java
public void setVariantRecords(Set<VariantRecord> records) { innerPanel.removeAll();// w w w. java 2s . co m //This function executes quickly, no need for waitPanel. //innerPanel.add(new WaitPanel("Loading DNA Ids...")); tableModel.setValues(records); aggregateTable = new AggregateTable(tableModel) { @Override //Necessary to enable buttons within the table. public boolean isCellEditable(int rowIndex, int colIndex) { return colIndex == buttonIndex; } //"Disables" selection within the aggregateTable. @Override public TableCellRenderer getCellRenderer(final int rowIndex, final int columnIndex) { final TableCellRenderer renderer = super.getCellRenderer(rowIndex, columnIndex); return new TableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable jtable, final Object o, boolean bln, boolean bln1, int i, int i1) { return renderer.getTableCellRendererComponent(jtable, o, false, false, i, i1); } }; } //This overridden method, together with the custom mouse listener on the //AggregateTable header, disallows moving the first column, and columns //>= dnaIDIndex @Override protected AggregateTable.DraggingHandler createDraggingColumnPropertyChangeListener() { return new AggregateTable.DraggingHandler() { @Override public void columnMoved(TableColumnModelEvent e) { if (fromColumnIndex == -1) { fromColumnIndex = e.getFromIndex(); } toColumnIndex = e.getToIndex(); } }; } }; header = new AggregateTableHeader(aggregateTable); header.addMouseListener(new MouseAdapter() { //Disable moving the first column, or columns with index //>=dnaIDIndex @Override public void mouseReleased(MouseEvent e) { if (toColumnIndex != -1 && ((toColumnIndex == 0 || fromColumnIndex == 0) || (toColumnIndex >= dnaIDIndex || fromColumnIndex >= dnaIDIndex))) { aggregateTable.moveColumn(toColumnIndex, fromColumnIndex); String msg = "This column cannot be moved."; DialogUtils.displayMessage(msg); } else { for (int columnHeaderIndex = 0; columnHeaderIndex < header.getColumnModel().getColumnCount() - 2; columnHeaderIndex++) { String columnTitle = (String) header.getColumnModel().getColumn(columnHeaderIndex) .getHeaderValue(); aggregateColumns[columnHeaderIndex] = columnTitle; } reaggregate(); } //aggregateTable.aggregate(this.aggregateColumns); fromColumnIndex = -1; toColumnIndex = -1; //expandAllButLast(); } }); header.setAutoFilterEnabled(false); header.setReorderingAllowed(true); header.setFont(TABLE_FONT_LARGE); aggregateTable.setTableHeader(header); aggregateTable.setAutoResizeMode(AggregateTable.AUTO_RESIZE_ALL_COLUMNS); aggregateTable.setFont(TABLE_FONT_LARGE); //Setup a custom "summary". This is what calculates frequencies when cells are //collapsed PivotField f = aggregateTable.getAggregateTableModel().getField(BasicVariantColumns.DNA_ID.getAlias()); f.setSummaryType(PivotConstants.SUMMARY_RESERVED_MAX + 1); aggregateTable.getAggregateTableModel().setSummaryCalculator(new SummaryCalculator() { private Set<String> collapsedDNAIDs = new HashSet<String>(); private Values lastRowValues; private int valueCount = 0; private final int SUMMARY_FREQ = PivotConstants.SUMMARY_RESERVED_MAX + 1; @Override public void addValue(PivotValueProvider dataModel, PivotField field, Values rowValues, Values columnValues, Object object) { //this gets called multiple times for all the cells that disappear when //something is collapsed. // row[0] is the value of the corresponding first column: e.g. a Cohort or Family. // columnValues can be ignored (blank) // Object is the value of the item in the cell that disappeared. (i.e. those cells which are being summarized) // field.getName() is the column name corresponding to Object // Useful Debugging code: //if(field.getName().equals(BasicVariantColumns.DNA_ID.getAlias())){ /* System.out.println("=========="); System.out.println("Field : " + field.getName()); System.out.println("Row values: "); for (int i = 0; i < rowValues.getCount(); ++i) { System.out.println("\trow[" + i + "] = " + rowValues.getValueAt(i).getValue()); } System.out.println("Column values: "); for (int i = 0; i < columnValues.getCount(); ++i) { System.out.println("\tcol[" + i + "] = " + columnValues.getValueAt(i).getValue()); } System.out.println("Object: "); System.out.println("\t" + object); System.out.println("=========="); */ // } if (field.getName().equals(BasicVariantColumns.DNA_ID.getAlias())) { collapsedDNAIDs.add((String) object); lastRowValues = rowValues; } else { lastRowValues = null; } valueCount++; } //Should never be called @Override public void addValue(Object o) { LOG.error("Unexpected method invocation in OtherIndividualsSubInspector (1)"); } //Should never be called @Override public void addValue(IPivotDataModel ipdm, PivotField pf, int i, int i1, Object o) { LOG.error("Unexpected method invocation in OtherIndividualsSubInspector (2)"); } //Should never be called @Override public void addValue(PivotValueProvider pvp, PivotField pf, Object o) { LOG.error("Unexpected method invocation in OtherIndividualsSubInspector (3)"); } @Override public void clear() { collapsedDNAIDs.clear(); valueCount = 0; lastRowValues = null; } @Override public Object getSummaryResult(int type) { //if null, then we're not in the DNAId column. Return null //to show a blank in this cell if (lastRowValues == null) { return null; } int numIndividuals = getNumberOfIndividualsInGroup(lastRowValues.getValueAt(0)); return new Frequency(collapsedDNAIDs.size(), numIndividuals); } private int getNumberOfIndividualsInGroup(Value v) { if (aggregateColumns[0].equals("Cohort")) { //LOG.debug("Getting number of individuals in group " + v.getValue()); Set<String> dnaIds = cohortDNAIDMap.get((Cohort) v.getValue()); //for (String id : dnaIds) { //LOG.debug("\tGot id " + id); //} return cohortDNAIDMap.get((Cohort) v.getValue()).size(); } else if (aggregateColumns[0].equals(BasicPatientColumns.FAMILY_ID.getAlias())) { return familyIDdnaIDMap.get((String) v.getValue()).size(); } else { LOG.error("Invalid first column"); return -1; } } @Override public long getCount() { return valueCount; } @Override public int getNumberOfSummaries() { return 1; } @Override public String getSummaryName(Locale locale, int i) { return "Frequency"; } @Override public int[] getAllowedSummaries(Class<?> type) { return new int[] { SUMMARY_FREQ }; } @Override public int[] getAllowedSummaries(Class<?> type, ConverterContext cc) { return new int[] { SUMMARY_FREQ }; } }); //Sets up the context menu for clicking column headers. This will probably not be used //frequently. Limit the available operations to collapsing, expanding, and grouping. TableHeaderPopupMenuInstaller installer = new TableHeaderPopupMenuInstaller(aggregateTable); installer.addTableHeaderPopupMenuCustomizer(new AggregateTablePopupMenuCustomizer() { @Override public void customizePopupMenu(JTableHeader header, JPopupMenu popup, int clickingColumn) { super.customizePopupMenu(header, popup, clickingColumn); for (int i = 0; i < popup.getComponentCount(); i++) { String menuItemName = popup.getComponent(i).getName(); if (!(CONTEXT_MENU_COLLAPSE.equals(menuItemName) || CONTEXT_MENU_COLLAPSE_ALL.equals(menuItemName) || CONTEXT_MENU_EXPAND.equals(menuItemName) || CONTEXT_MENU_EXPAND_ALL.equals(menuItemName) || CONTEXT_MENU_GROUP.equals(menuItemName) || CONTEXT_MENU_UNGROUP.equals(menuItemName))) { popup.remove(popup.getComponent(i)); } } } }); aggregateTable.getAggregateTableModel().setSummaryMode(true); aggregateTable.aggregate(aggregateColumns); aggregateTable.setShowContextMenu(false); expandAllButLast(); setupButtonColumn(); JScrollPane jsp = new JScrollPane(aggregateTable); jsp.setPreferredSize(PREFERRED_SIZE); JPanel bp = new JPanel(); bp.setLayout(new BoxLayout(bp, BoxLayout.X_AXIS)); JButton closeButton = new JButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.CLOSE)); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { unsplitScreen(); } }); bp.add(Box.createHorizontalGlue()); bp.add(title); bp.add(Box.createHorizontalGlue()); bp.add(closeButton); innerPanel.add(bp); innerPanel.add(jsp); reaggregate(); innerPanel.revalidate(); innerPanel.repaint(); }