List of usage examples for javax.swing JCheckBoxMenuItem JCheckBoxMenuItem
public JCheckBoxMenuItem(Action a)
From source file:com.mirth.connect.client.ui.components.MirthTreeTable.java
private JPopupMenu getColumnMenu() { SortableTreeTableModel model = (SortableTreeTableModel) getTreeTableModel(); JPopupMenu columnMenu = new JPopupMenu(); for (int i = 0; i < model.getColumnCount(); i++) { final String columnName = model.getColumnName(i); // Get the column object by name. Using an index may not return the column object if the column is hidden TableColumnExt column = getColumnExt(columnName); // Create the menu item final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(columnName); // Show or hide the checkbox menuItem.setSelected(column.isVisible()); menuItem.addActionListener(new ActionListener() { @Override/*from ww w . j a v a2s . c o m*/ public void actionPerformed(ActionEvent arg0) { TableColumnExt column = getColumnExt(menuItem.getText()); // Determine whether to show or hide the selected column boolean enable = !column.isVisible(); // Do not hide a column if it is the last remaining visible column if (enable || getColumnCount() > 1) { column.setVisible(enable); Set<String> customHiddenColumns = customHiddenColumnMap.get(channelId); if (customHiddenColumns != null) { if (enable) { customHiddenColumns.remove(columnName); } else { customHiddenColumns.add(columnName); } } } saveColumnOrder(); } }); columnMenu.add(menuItem); } columnMenu.addSeparator(); JMenuItem menuItem = new JMenuItem("Collapse All"); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { collapseAll(); } }); columnMenu.add(menuItem); menuItem = new JMenuItem("Expand All"); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { expandAll(); } }); columnMenu.add(menuItem); columnMenu.addSeparator(); menuItem = new JMenuItem("Restore Default"); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (metaDataColumns != null) { defaultVisibleColumns.addAll(metaDataColumns); } restoreDefaultColumnPreferences(); } }); columnMenu.add(menuItem); return columnMenu; }
From source file:ec.ui.view.MarginView.java
private JMenu buildMenu() { JMenu result = new JMenu(); result.add(new JCheckBoxMenuItem(new AbstractAction() { @Override//from ww w. j a v a 2 s. co m public void actionPerformed(ActionEvent e) { setPrecisionMarkersVisible(!isPrecisionMarkersVisible()); } })).setText("Show precision gradient"); result.add(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { TsCollection col = TsFactory.instance.createTsCollection(); col.add(TsFactory.instance.createTs("series", null, data.series)); col.add(TsFactory.instance.createTs("lower", null, data.lower)); col.add(TsFactory.instance.createTs("upper", null, data.upper)); Transferable t = TssTransferSupport.getDefault().fromTsCollection(col); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(t, null); } }).setText("Copy all series"); JMenu export = new JMenu("Export image to"); export.add(ChartCommand.printImage().toAction(chartPanel)).setText("Printer..."); export.add(ChartCommand.copyImage().toAction(chartPanel)).setText("Clipboard"); export.add(ChartCommand.saveImage().toAction(chartPanel)).setText("File..."); result.add(export); return result; }
From source file:daylightchart.gui.DaylightChartGui.java
private void createOptionsMenu(final JMenuBar menuBar, final JToolBar toolBar) { final JMenu menu = new JMenu(Messages.getString("DaylightChartGui.Menu.Options")); //$NON-NLS-1$ menu.setMnemonic('O'); final GuiAction options = new OptionsAction(this); menu.add(options);/* w w w . j a va 2 s. c om*/ final GuiAction chartOptions = new ChartOptionsAction(this); menu.add(chartOptions); final GuiAction resetAll = new ResetAllAction(this); menu.add(resetAll); menu.addSeparator(); final JCheckBoxMenuItem slimUiMenuItem = new JCheckBoxMenuItem( Messages.getString("DaylightChartGui.Menu.Options.SlimUi")); //$NON-NLS-1$ slimUiMenuItem.setState(isSlimUi()); slimUiMenuItem.addItemListener(new ItemListener() { @Override public void itemStateChanged(final ItemEvent e) { final boolean slimUi = e.getStateChange() == ItemEvent.SELECTED; final Options options = UserPreferences.optionsFile().getData(); options.setSlimUi(slimUi); UserPreferences.optionsFile().save(options); ResetAllAction.restart(DaylightChartGui.this, slimUi); } }); menu.add(slimUiMenuItem); menuBar.add(menu); toolBar.add(options); toolBar.add(chartOptions); toolBar.addSeparator(); }
From source file:ch.algotrader.client.chart.ChartTab.java
private void initOHLCSeries(int datasetNumber, XYDataset dataset, SeriesDefinitionVO seriesDefinition) { BarDefinitionVO barDefinition = (BarDefinitionVO) seriesDefinition; OHLCSeriesCollection ohlcSeriesCollection = (OHLCSeriesCollection) dataset; ohlcSeriesCollection.setXPosition(TimePeriodAnchor.START); // create the TimeSeries OHLCSeries series = new OHLCSeries(barDefinition.getLabel()); ohlcSeriesCollection.addSeries(series); this.bars.put(barDefinition.getSecurityId(), series); // get the seriesNumber & color final int seriesNumber = ohlcSeriesCollection.getSeriesCount() - 1; // configure the renderer final CandlestickRenderer renderer = (CandlestickRenderer) getPlot().getRenderer(datasetNumber); renderer.setSeriesPaint(seriesNumber, getColor(barDefinition.getColor())); renderer.setSeriesVisible(seriesNumber, seriesDefinition.isSelected()); renderer.setAutoWidthMethod(HideableCandlestickRenderer.WIDTHMETHOD_SMALLEST); // add the menu item JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(seriesDefinition.getLabel()); menuItem.setSelected(seriesDefinition.isSelected()); menuItem.addActionListener(new ActionListener() { @Override/*from ww w .ja v a 2s. c om*/ public void actionPerformed(ActionEvent e) { resetAxis(); renderer.setSeriesVisible(seriesNumber, ((JCheckBoxMenuItem) e.getSource()).isSelected(), true); initAxis(); } }); this.getPopupMenu().add(menuItem); }
From source file:org.jax.maanova.fit.gui.ResidualPlotPanel.java
@SuppressWarnings("serial") private JMenuBar createMenu() { JMenuBar menuBar = new JMenuBar(); // the file menu JMenu fileMenu = new JMenu("File"); fileMenu.add(this.saveGraphImageAction); menuBar.add(fileMenu);/* w w w. j a va 2s. co m*/ // the tools menu JMenu toolsMenu = new JMenu("Tools"); JMenuItem configureGraphItem = new JMenuItem("Configure Graph..."); configureGraphItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { ResidualPlotPanel.this.chartConfigurationDialog.setVisible(true); } }); toolsMenu.add(configureGraphItem); toolsMenu.addSeparator(); toolsMenu.add(new AbstractAction("Zoom Out") { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { ResidualPlotPanel.this.autoRangeChart(); } }); toolsMenu.addSeparator(); JCheckBoxMenuItem showTooltipCheckbox = new JCheckBoxMenuItem("Show Info Popup for Nearest Point"); showTooltipCheckbox.setSelected(true); this.showTooltip = true; showTooltipCheckbox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { ResidualPlotPanel.this.showTooltip = e.getStateChange() == ItemEvent.SELECTED; ResidualPlotPanel.this.clearProbePopup(); } }); toolsMenu.add(showTooltipCheckbox); menuBar.add(toolsMenu); // the help menu JMenu helpMenu = new JMenu("Help"); JMenuItem helpMenuItem = new JMenuItem("Help...", new ImageIcon(ResidualPlotAction.class.getResource("/images/action/help-16x16.png"))); helpMenuItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { Maanova.getInstance().showHelp("residual-plot", ResidualPlotPanel.this); } }); helpMenu.add(helpMenuItem); menuBar.add(helpMenu); return menuBar; }
From source file:net.nikr.eve.jeveasset.gui.tabs.tracker.TrackerTab.java
public TrackerTab(Program program) { super(program, TabsTracker.get().title(), Images.TOOL_TRACKER.getIcon(), true); filterDialog = new TrackerFilterDialog(program); jPopupMenu = new JPopupMenu(); jPopupMenu.addPopupMenuListener(listener); JMenuItem jMenuItem;// www .j a v a2s. co m jMenuItem = new JMenuItem(TabsTracker.get().edit(), Images.EDIT_EDIT.getIcon()); jMenuItem.setActionCommand(TrackerAction.EDIT.name()); jMenuItem.addActionListener(listener); jPopupMenu.add(jMenuItem); jMenuItem = new JMenuItem(TabsTracker.get().delete(), Images.EDIT_DELETE.getIcon()); jMenuItem.setActionCommand(TrackerAction.DELETE.name()); jMenuItem.addActionListener(listener); jPopupMenu.add(jMenuItem); JMenuInfo.createDefault(jPopupMenu); jIskValue = new JMenuItem(); jIskValue.setEnabled(false); jIskValue.setForeground(Color.BLACK); jIskValue.setHorizontalAlignment(SwingConstants.RIGHT); jIskValue.setDisabledIcon(Images.TOOL_VALUES.getIcon()); jPopupMenu.add(jIskValue); jDateValue = new JMenuItem(); jDateValue.setEnabled(false); jDateValue.setForeground(Color.BLACK); jDateValue.setHorizontalAlignment(SwingConstants.RIGHT); jPopupMenu.add(jDateValue); jEditDialog = new JTrackerEditDialog(program); jSelectionDialog = new JSelectionDialog(program); JSeparator jDateSeparator = new JSeparator(); jQuickDate = new JComboBox<QuickDate>(QuickDate.values()); jQuickDate.setActionCommand(TrackerAction.QUICK_DATE.name()); jQuickDate.addActionListener(listener); JLabel jFromLabel = new JLabel(TabsTracker.get().from()); jFrom = createDateChooser(); JLabel jToLabel = new JLabel(TabsTracker.get().to()); jTo = createDateChooser(); jAll = new JCheckBox(General.get().all()); jAll.setSelected(true); jAll.setActionCommand(TrackerAction.ALL.name()); jAll.addActionListener(listener); jAll.setFont(new Font(jAll.getFont().getName(), Font.ITALIC, jAll.getFont().getSize())); jTotal = new JCheckBox(TabsTracker.get().total()); jTotal.setSelected(true); jTotal.setActionCommand(TrackerAction.UPDATE_SHOWN.name()); jTotal.addActionListener(listener); jWalletBalance = new JCheckBox(TabsTracker.get().walletBalance()); jWalletBalance.setSelected(true); jWalletBalance.setActionCommand(TrackerAction.UPDATE_SHOWN.name()); jWalletBalance.addActionListener(listener); jWalletBalanceFilters = new JButton(Images.LOC_INCLUDE.getIcon()); jWalletBalanceFilters.setActionCommand(TrackerAction.FILTER_WALLET_BALANCE.name()); jWalletBalanceFilters.addActionListener(listener); jAssets = new JCheckBox(TabsTracker.get().assets()); jAssets.setSelected(true); jAssets.setActionCommand(TrackerAction.UPDATE_SHOWN.name()); jAssets.addActionListener(listener); jAssetsFilters = new JButton(Images.LOC_INCLUDE.getIcon()); jAssetsFilters.setActionCommand(TrackerAction.FILTER_ASSETS.name()); jAssetsFilters.addActionListener(listener); jSellOrders = new JCheckBox(TabsTracker.get().sellOrders()); jSellOrders.setSelected(true); jSellOrders.setActionCommand(TrackerAction.UPDATE_SHOWN.name()); jSellOrders.addActionListener(listener); jEscrows = new JCheckBox(TabsTracker.get().escrows()); jEscrows.setSelected(true); jEscrows.setActionCommand(TrackerAction.UPDATE_SHOWN.name()); jEscrows.addActionListener(listener); jEscrowsToCover = new JCheckBox(TabsTracker.get().escrowsToCover()); jEscrowsToCover.setSelected(true); jEscrowsToCover.setActionCommand(TrackerAction.UPDATE_SHOWN.name()); jEscrowsToCover.addActionListener(listener); jManufacturing = new JCheckBox(TabsTracker.get().manufacturing()); jManufacturing.setSelected(true); jManufacturing.setActionCommand(TrackerAction.UPDATE_SHOWN.name()); jManufacturing.addActionListener(listener); jContractCollateral = new JCheckBox(TabsTracker.get().contractCollateral()); jContractCollateral.setSelected(true); jContractCollateral.setActionCommand(TrackerAction.UPDATE_SHOWN.name()); jContractCollateral.addActionListener(listener); jContractValue = new JCheckBox(TabsTracker.get().contractValue()); jContractValue.setSelected(true); jContractValue.setActionCommand(TrackerAction.UPDATE_SHOWN.name()); jContractValue.addActionListener(listener); JSeparator jOwnersSeparator = new JSeparator(); jAllProfiles = new JCheckBox(TabsTracker.get().allProfiles()); jAllProfiles.setActionCommand(TrackerAction.PROFILE.name()); jAllProfiles.addActionListener(listener); jOwners = new JMultiSelectionList<String>(); jOwners.getSelectionModel().addListSelectionListener(listener); JScrollPane jOwnersScroll = new JScrollPane(jOwners); JLabel jHelp = new JLabel(TabsTracker.get().help()); jHelp.setIcon(Images.MISC_HELP.getIcon()); JLabel jNoFilter = new JLabel(TabsTracker.get().helpLegacyData()); jNoFilter.setIcon(new ShapeIcon(NO_FILTER)); JLabel jFilter = new JLabel(TabsTracker.get().helpNewData()); jFilter.setIcon(new ShapeIcon(FILTER_AND_DEFAULT)); JDropDownButton jSettings = new JDropDownButton(Images.DIALOG_SETTINGS.getIcon()); jIncludeZero = new JCheckBoxMenuItem(TabsTracker.get().includeZero()); jIncludeZero.setSelected(true); jIncludeZero.setActionCommand(TrackerAction.INCLUDE_ZERO.name()); jIncludeZero.addActionListener(listener); jSettings.add(jIncludeZero); DateAxis domainAxis = new DateAxis(); domainAxis.setDateFormatOverride(dateFormat); domainAxis.setVerticalTickLabels(true); domainAxis.setAutoTickUnitSelection(true); domainAxis.setAutoRange(true); domainAxis.setTickLabelFont(jFromLabel.getFont()); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAutoRange(true); rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); rangeAxis.setTickLabelFont(jFromLabel.getFont()); //XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, new XYLineAndShapeRenderer(true, true)); render = new MyRender(); XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, render); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.getRenderer() .setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: {2} ({1})", dateFormat, iskFormat)); plot.setDomainCrosshairLockedOnData(true); plot.setDomainCrosshairStroke(new BasicStroke(1)); plot.setDomainCrosshairPaint(Color.BLACK); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairLockedOnData(true); plot.setRangeCrosshairVisible(false); jNextChart = new JFreeChart(plot); jNextChart.setAntiAlias(true); jNextChart.setBackgroundPaint(jPanel.getBackground()); jNextChart.addProgressListener(null); jNextChart.getLegend().setItemFont(jFrom.getFont()); jChartPanel = new ChartPanel(jNextChart); jChartPanel.addMouseListener(listener); jChartPanel.setDomainZoomable(false); jChartPanel.setRangeZoomable(false); jChartPanel.setPopupMenu(null); jChartPanel.addChartMouseListener(listener); jChartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); jChartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); jChartPanel.setMinimumDrawWidth(10); jChartPanel.setMinimumDrawHeight(10); int AssetsGapWidth = PANEL_WIDTH - jAssets.getPreferredSize().width - jAssetsFilters.getPreferredSize().width; if (AssetsGapWidth < 0) { AssetsGapWidth = 0; } int WalletGapWidth = PANEL_WIDTH - jWalletBalance.getPreferredSize().width - jWalletBalanceFilters.getPreferredSize().width; if (WalletGapWidth < 0) { WalletGapWidth = 0; } layout.setHorizontalGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup() .addGroup(layout.createSequentialGroup().addComponent(jHelp).addGap(20).addComponent(jNoFilter) .addGap(20).addComponent(jFilter).addGap(20, 20, Integer.MAX_VALUE).addComponent(jSettings) .addGap(6)) .addComponent(jChartPanel)).addGroup( layout.createParallelGroup().addComponent(jQuickDate, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup() .addComponent(jFromLabel, LABEL_WIDTH, LABEL_WIDTH, LABEL_WIDTH) .addComponent(jToLabel, LABEL_WIDTH, LABEL_WIDTH, LABEL_WIDTH)) .addGap(0) .addGroup(layout.createParallelGroup() .addComponent(jFrom, PANEL_WIDTH - LABEL_WIDTH, PANEL_WIDTH - LABEL_WIDTH, PANEL_WIDTH - LABEL_WIDTH) .addComponent(jTo, PANEL_WIDTH - LABEL_WIDTH, PANEL_WIDTH - LABEL_WIDTH, PANEL_WIDTH - LABEL_WIDTH))) .addComponent(jDateSeparator, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addComponent(jAll, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addComponent(jTotal, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addGroup(layout.createSequentialGroup().addComponent(jWalletBalance) .addGap(0, 0, WalletGapWidth).addComponent(jWalletBalanceFilters)) .addGroup(layout.createSequentialGroup().addComponent(jAssets) .addGap(0, 0, AssetsGapWidth).addComponent(jAssetsFilters)) .addComponent(jSellOrders, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addComponent(jEscrows, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addComponent(jEscrowsToCover, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addComponent(jManufacturing, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addComponent(jContractCollateral, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addComponent(jContractValue, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addComponent(jOwnersSeparator, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addComponent(jAllProfiles, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH) .addComponent(jOwnersScroll, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH))); layout.setVerticalGroup(layout.createParallelGroup() .addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup() .addComponent(jHelp, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jNoFilter, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jFilter, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jSettings, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())) .addComponent(jChartPanel)) .addGroup(layout.createSequentialGroup() .addComponent(jQuickDate, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addGroup(layout.createParallelGroup() .addComponent(jFromLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jFrom, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())) .addGroup(layout.createParallelGroup() .addComponent(jToLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jTo, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())) .addComponent(jDateSeparator, 3, 3, 3) .addComponent(jAll, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jTotal, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addGroup(layout.createParallelGroup() .addComponent(jWalletBalance, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jWalletBalanceFilters, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())) .addGroup(layout.createParallelGroup() .addComponent(jAssets, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jAssetsFilters, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())) .addComponent(jSellOrders, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jEscrows, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jEscrowsToCover, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jManufacturing, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jContractCollateral, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jContractValue, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jOwnersSeparator, 3, 3, 3) .addComponent(jAllProfiles, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jOwnersScroll, 70, 70, Integer.MAX_VALUE))); }
From source file:org.jax.maanova.test.gui.VolcanoPlotPanel.java
@SuppressWarnings("serial") private JMenuBar createMenu() { JMenuBar menuBar = new JMenuBar(); // the file menu JMenu fileMenu = new JMenu("File"); fileMenu.add(this.saveGraphImageAction); menuBar.add(fileMenu);/*from ww w .j a va 2 s . c o m*/ // the tools menu JMenu toolsMenu = new JMenu("Tools"); JMenuItem configureGraphItem = new JMenuItem("Configure Graph..."); configureGraphItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.chartConfigurationDialog.setVisible(true); } }); toolsMenu.add(configureGraphItem); toolsMenu.addSeparator(); toolsMenu.add(new AbstractAction("Clear Selections") { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.setSelectedIndices(new int[0]); } }); toolsMenu.addSeparator(); ButtonGroup dragButtonGroup = new ButtonGroup(); JCheckBoxMenuItem selectModeCheckBox = new JCheckBoxMenuItem("Drag Cursor to Select"); selectModeCheckBox.setSelected(true); this.dragToSelect = true; selectModeCheckBox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { VolcanoPlotPanel.this.dragToSelect = e.getStateChange() == ItemEvent.SELECTED; } }); dragButtonGroup.add(selectModeCheckBox); toolsMenu.add(selectModeCheckBox); JCheckBoxMenuItem zoomModeCheckBox = new JCheckBoxMenuItem("Drag Cursor to Zoom"); zoomModeCheckBox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { VolcanoPlotPanel.this.dragToZoom = e.getStateChange() == ItemEvent.SELECTED; } }); dragButtonGroup.add(zoomModeCheckBox); toolsMenu.add(zoomModeCheckBox); toolsMenu.addSeparator(); toolsMenu.add(new AbstractAction("Zoom Out") { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.autoRangeChart(); } }); toolsMenu.addSeparator(); JCheckBoxMenuItem showTooltipCheckbox = new JCheckBoxMenuItem("Show Info Popup for Nearest Point"); showTooltipCheckbox.setSelected(true); this.showTooltip = true; showTooltipCheckbox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { VolcanoPlotPanel.this.showTooltip = e.getStateChange() == ItemEvent.SELECTED; VolcanoPlotPanel.this.clearProbePopup(); } }); toolsMenu.add(showTooltipCheckbox); toolsMenu.addSeparator(); toolsMenu.add(this.displayTestResultsAction); toolsMenu.addSeparator(); toolsMenu.add(this.saveSelectedPointsMenuItem); JMenu selectPointsFromLisMenu = new JMenu("Select Points From Gene List"); List<String> geneListNames = this.maanovaTestResult.getParentExperiment().getGeneListNames(); if (geneListNames.isEmpty()) { JMenuItem noListsMenuItem = new JMenuItem("No Gene Lists Available"); noListsMenuItem.setEnabled(false); selectPointsFromLisMenu.add(noListsMenuItem); } else { for (final String geneListName : geneListNames) { JMenuItem currGeneListMenuItem = new JMenuItem( RUtilities.fromRIdentifierToReadableName(geneListName)); currGeneListMenuItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.selectedIndicesFromGeneList(geneListName); } }); selectPointsFromLisMenu.add(currGeneListMenuItem); } } toolsMenu.add(selectPointsFromLisMenu); menuBar.add(toolsMenu); // the help menu JMenu helpMenu = new JMenu("Help"); JMenuItem helpMenuItem = new JMenuItem("Help..."); Icon helpIcon = new ImageIcon(VolcanoPlotPanel.class.getResource("/images/action/help-16x16.png")); helpMenuItem.setIcon(helpIcon); helpMenuItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { Maanova.getInstance().showHelp("volcano-plot", VolcanoPlotPanel.this); } }); helpMenu.add(helpMenuItem); menuBar.add(helpMenu); return menuBar; }
From source file:javazoom.jlgui.player.amp.PlayerUI.java
public void loadSkin() { log.info("Load PlayerUI (EDT=" + SwingUtilities.isEventDispatchThread() + ")"); removeAll();/* www. j a v a 2s . com*/ // Load skin specified in args if (ui.getPath() != null) { log.info("Load default skin from " + ui.getPath()); ui.loadSkin(ui.getPath()); config.setDefaultSkin(ui.getPath()); } // Load skin specified in jlgui.ini else if ((config.getDefaultSkin() != null) && (!config.getDefaultSkin().trim().equals(""))) { log.info("Load default skin from " + config.getDefaultSkin()); ui.loadSkin(config.getDefaultSkin()); } // Default included skin else { ClassLoader cl = getClass().getClassLoader(); InputStream sis = cl.getResourceAsStream("javazoom/jlgui/player/amp/metrix.wsz"); log.info("Load default skin for JAR"); ui.loadSkin(sis); } // Background ImageBorder border = new ImageBorder(); border.setImage(ui.getMainImage()); setBorder(border); // Buttons add(ui.getAcPrevious(), ui.getAcPrevious().getConstraints()); ui.getAcPrevious().removeActionListener(this); ui.getAcPrevious().addActionListener(this); add(ui.getAcPlay(), ui.getAcPlay().getConstraints()); ui.getAcPlay().removeActionListener(this); ui.getAcPlay().addActionListener(this); add(ui.getAcPause(), ui.getAcPause().getConstraints()); ui.getAcPause().removeActionListener(this); ui.getAcPause().addActionListener(this); add(ui.getAcStop(), ui.getAcStop().getConstraints()); ui.getAcStop().removeActionListener(this); ui.getAcStop().addActionListener(this); add(ui.getAcNext(), ui.getAcNext().getConstraints()); ui.getAcNext().removeActionListener(this); ui.getAcNext().addActionListener(this); add(ui.getAcEject(), ui.getAcEject().getConstraints()); ui.getAcEject().removeActionListener(this); ui.getAcEject().addActionListener(this); // EqualizerUI toggle add(ui.getAcEqualizer(), ui.getAcEqualizer().getConstraints()); ui.getAcEqualizer().removeActionListener(this); ui.getAcEqualizer().addActionListener(this); // Playlist toggle add(ui.getAcPlaylist(), ui.getAcPlaylist().getConstraints()); ui.getAcPlaylist().removeActionListener(this); ui.getAcPlaylist().addActionListener(this); // Shuffle toggle add(ui.getAcShuffle(), ui.getAcShuffle().getConstraints()); ui.getAcShuffle().removeActionListener(this); ui.getAcShuffle().addActionListener(this); // Repeat toggle add(ui.getAcRepeat(), ui.getAcRepeat().getConstraints()); ui.getAcRepeat().removeActionListener(this); ui.getAcRepeat().addActionListener(this); // Volume add(ui.getAcVolume(), ui.getAcVolume().getConstraints()); ui.getAcVolume().removeChangeListener(this); ui.getAcVolume().addChangeListener(this); // Balance add(ui.getAcBalance(), ui.getAcBalance().getConstraints()); ui.getAcBalance().removeChangeListener(this); ui.getAcBalance().addChangeListener(this); // Seek bar add(ui.getAcPosBar(), ui.getAcPosBar().getConstraints()); ui.getAcPosBar().removeChangeListener(this); ui.getAcPosBar().addChangeListener(this); // Mono add(ui.getAcMonoIcon(), ui.getAcMonoIcon().getConstraints()); // Stereo add(ui.getAcStereoIcon(), ui.getAcStereoIcon().getConstraints()); // Title label add(ui.getAcTitleLabel(), ui.getAcTitleLabel().getConstraints()); // Sample rate label add(ui.getAcSampleRateLabel(), ui.getAcSampleRateLabel().getConstraints()); // Bit rate label add(ui.getAcBitRateLabel(), ui.getAcBitRateLabel().getConstraints()); // Play icon add(ui.getAcPlayIcon(), ui.getAcPlayIcon().getConstraints()); // Time icon add(ui.getAcTimeIcon(), ui.getAcTimeIcon().getConstraints()); // MinuteH number add(ui.getAcMinuteH(), ui.getAcMinuteH().getConstraints()); // MinuteL number add(ui.getAcMinuteL(), ui.getAcMinuteL().getConstraints()); // SecondH number add(ui.getAcSecondH(), ui.getAcSecondH().getConstraints()); // SecondL number add(ui.getAcSecondL(), ui.getAcSecondL().getConstraints()); // TitleBar add(ui.getAcTitleBar(), ui.getAcTitleBar().getConstraints()); add(ui.getAcMinimize(), ui.getAcMinimize().getConstraints()); ui.getAcMinimize().removeActionListener(this); ui.getAcMinimize().addActionListener(this); add(ui.getAcExit(), ui.getAcExit().getConstraints()); ui.getAcExit().removeActionListener(this); ui.getAcExit().addActionListener(this); // DSP if (ui.getAcAnalyzer() != null) { add(ui.getAcAnalyzer(), ui.getAcAnalyzer().getConstraints()); } // Popup menu mainpopup = new JPopupMenu(ui.getResource("popup.title")); JMenuItem mi = new JMenuItem(Skin.TITLETEXT + "- JavaZOOM"); //mi.removeActionListener(this); //mi.addActionListener(this); mainpopup.add(mi); mainpopup.addSeparator(); JMenu playSubMenu = new JMenu(ui.getResource("popup.play")); miPlayFile = new JMenuItem(ui.getResource("popup.play.file")); miPlayFile.setActionCommand(PlayerActionEvent.MIPLAYFILE); miPlayFile.removeActionListener(this); miPlayFile.addActionListener(this); miPlayLocation = new JMenuItem(ui.getResource("popup.play.location")); miPlayLocation.setActionCommand(PlayerActionEvent.MIPLAYLOCATION); miPlayLocation.removeActionListener(this); miPlayLocation.addActionListener(this); playSubMenu.add(miPlayFile); playSubMenu.add(miPlayLocation); mainpopup.add(playSubMenu); mainpopup.addSeparator(); miPlaylist = new JCheckBoxMenuItem(ui.getResource("popup.playlist")); miPlaylist.setActionCommand(PlayerActionEvent.MIPLAYLIST); if (config.isPlaylistEnabled()) miPlaylist.setState(true); miPlaylist.removeActionListener(this); miPlaylist.addActionListener(this); mainpopup.add(miPlaylist); miEqualizer = new JCheckBoxMenuItem(ui.getResource("popup.equalizer")); miEqualizer.setActionCommand(PlayerActionEvent.MIEQUALIZER); if (config.isEqualizerEnabled()) miEqualizer.setState(true); miEqualizer.removeActionListener(this); miEqualizer.addActionListener(this); mainpopup.add(miEqualizer); mainpopup.addSeparator(); mi = new JMenuItem(ui.getResource("popup.preferences")); mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK, false)); mi.setActionCommand(PlayerActionEvent.MIPREFERENCES); mi.removeActionListener(this); mi.addActionListener(this); mainpopup.add(mi); JMenu skinsSubMenu = new JMenu(ui.getResource("popup.skins")); mi = new JMenuItem(ui.getResource("popup.skins.browser")); mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.ALT_MASK, false)); mi.setActionCommand(PlayerActionEvent.MISKINBROWSER); mi.removeActionListener(this); mi.addActionListener(this); skinsSubMenu.add(mi); mi = new JMenuItem(ui.getResource("popup.skins.load")); mi.setActionCommand(PlayerActionEvent.MILOADSKIN); mi.removeActionListener(this); mi.addActionListener(this); skinsSubMenu.add(mi); mainpopup.add(skinsSubMenu); JMenu playbackSubMenu = new JMenu(ui.getResource("popup.playback")); mi = new JMenuItem(ui.getResource("popup.playback.jump")); mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J, 0, false)); mi.setActionCommand(PlayerActionEvent.MIJUMPFILE); mi.removeActionListener(this); mi.addActionListener(this); playbackSubMenu.add(mi); mi = new JMenuItem(ui.getResource("popup.playback.stop")); mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, 0, false)); mi.setActionCommand(PlayerActionEvent.MISTOP); mi.removeActionListener(this); mi.addActionListener(this); playbackSubMenu.add(mi); mainpopup.add(playbackSubMenu); mainpopup.addSeparator(); mi = new JMenuItem(ui.getResource("popup.exit")); mi.setActionCommand(PlayerActionEvent.ACEXIT); mi.removeActionListener(this); mi.addActionListener(this); mainpopup.add(mi); // Popup menu on TitleBar ui.getAcTitleBar().removeMouseListener(popupAdapter); popupAdapter = new PopupAdapter(mainpopup); ui.getAcTitleBar().addMouseListener(popupAdapter); // Popup menu on Eject button ejectpopup = new JPopupMenu(); mi = new JMenuItem(ui.getResource("popup.eject.openfile")); mi.setActionCommand(PlayerActionEvent.MIPLAYFILE); mi.removeActionListener(this); mi.addActionListener(this); ejectpopup.add(mi); mi = new JMenuItem(ui.getResource("popup.eject.openlocation")); mi.setActionCommand(PlayerActionEvent.MIPLAYLOCATION); mi.removeActionListener(this); mi.addActionListener(this); ejectpopup.add(mi); ui.getAcEject().removeMouseListener(ejectpopupAdapter); ejectpopupAdapter = new PopupAdapter(ejectpopup); ui.getAcEject().addMouseListener(ejectpopupAdapter); // EqualizerUI if (equalizerUI != null) equalizerUI.loadUI(); if (playlistUI != null) playlistUI.loadUI(); validate(); loader.loaded(); }
From source file:ch.algotrader.client.chart.ChartTab.java
private void initTimeSeries(int datasetNumber, XYDataset dataset, SeriesDefinitionVO seriesDefinition) { IndicatorDefinitionVO indicatorDefinition = (IndicatorDefinitionVO) seriesDefinition; TimeSeriesCollection timeSeriesCollection = (TimeSeriesCollection) dataset; // create the TimeSeries TimeSeries series = new TimeSeries(indicatorDefinition.getLabel()); timeSeriesCollection.addSeries(series); this.indicators.put(indicatorDefinition.getName(), series); // get the seriesNumber & color final int seriesNumber = timeSeriesCollection.getSeriesCount() - 1; // configure the renderer final XYItemRenderer renderer = getPlot().getRenderer(datasetNumber); renderer.setSeriesPaint(seriesNumber, getColor(indicatorDefinition.getColor())); renderer.setSeriesVisible(seriesNumber, seriesDefinition.isSelected()); renderer.setBaseToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); if (seriesDefinition.isDashed()) { renderer.setSeriesStroke(seriesNumber, new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[] { 5.0f }, 0.0f)); } else {/*from ww w. ja v a 2 s .c o m*/ renderer.setSeriesStroke(seriesNumber, new BasicStroke(0.5f)); } // add the menu item JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(seriesDefinition.getLabel()); menuItem.setSelected(seriesDefinition.isSelected()); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { resetAxis(); renderer.setSeriesVisible(seriesNumber, ((JCheckBoxMenuItem) e.getSource()).isSelected()); initAxis(); } }); this.getPopupMenu().add(menuItem); }
From source file:es.darkhogg.hazelnutt.EditorFrame.java
private void initializeGui() { setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setBounds(100, 100, 640, 480);//ww w . j a v a2 s. com addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent arg0) { actionExit(); } }); fileChooser = new JFileChooser(); //fileChooser.setFileFilter( hlfFileFilter ); hlfFileChooser = new JFileChooser(); hlfFileChooser.setFileFilter(hlfFileFilter); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu mnFile = new JMenu("File"); mnFile.setMnemonic('F'); menuBar.add(mnFile); menuLoadRom = new JMenuItem("Load ROM..."); menuLoadRom.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK)); menuLoadRom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionOpenRom(null); } }); menuLoadRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_open.png"))); menuLoadRom.setMnemonic('O'); mnFile.add(menuLoadRom); menuSaveRom = new JMenuItem("Save ROM"); menuSaveRom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveRom(); } }); menuSaveRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save.png"))); menuSaveRom.setMnemonic('S'); menuSaveRom.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK)); mnFile.add(menuSaveRom); menuSaveRomAs = new JMenuItem("Save ROM As..."); menuSaveRomAs.setMnemonic('a'); menuSaveRomAs.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK)); menuSaveRomAs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveRomAs(); } }); menuSaveRomAs .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_as.png"))); mnFile.add(menuSaveRomAs); mnFile.addSeparator(); menuLoadLevel = new JMenuItem("Load Level..."); menuLoadLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)); menuLoadLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionLoadLevel(); } }); menuLoadLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_load_level.png"))); menuLoadLevel.setMnemonic('L'); mnFile.add(menuLoadLevel); menuReloadLevel = new JMenuItem("Reload Level"); menuReloadLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0)); menuReloadLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionReloadLevel(); } }); menuReloadLevel.setMnemonic('R'); menuReloadLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_reload_level.png"))); mnFile.add(menuReloadLevel); menuSaveLevel = new JMenuItem("Save Level"); menuSaveLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0)); menuSaveLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveLevel(); } }); menuSaveLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_level.png"))); menuSaveLevel.setMnemonic('v'); mnFile.add(menuSaveLevel); //* mnFile.addSeparator(); menuImportLevel = new JMenuItem("Import Level..."); menuImportLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)); menuImportLevel.setMnemonic('i'); menuImportLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionImportLevel(); } }); menuImportLevel .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_import.png"))); mnFile.add(menuImportLevel); menuExportLevel = new JMenuItem("Export Level..."); menuExportLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0)); menuExportLevel.setMnemonic('e'); menuExportLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionExportLevel(); } }); menuExportLevel .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_export.png"))); mnFile.add(menuExportLevel); //*/ mnFile.addSeparator(); menuExit = new JMenuItem("Exit"); menuExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)); menuExit.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_exit.png"))); menuExit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { actionExit(); } }); menuRecentFiles = new JMenu("Recent Files..."); mnFile.add(menuRecentFiles); mnFile.addSeparator(); menuExit.setMnemonic('X'); mnFile.add(menuExit); JMenu mnEdit = new JMenu("Edit"); mnEdit.setMnemonic('E'); menuBar.add(mnEdit); menuViewSpawn = new JCheckBoxMenuItem("View Spawn Point"); menuViewSpawn.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, 0)); menuViewSpawn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuClearLevel = new JMenuItem("Clear Level"); menuClearLevel.setMnemonic('c'); menuClearLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK)); menuClearLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionClearLevel(); } }); menuClearLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_clear_level.png"))); mnEdit.add(menuClearLevel); mnEdit.addSeparator(); menuViewSpawn .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_spawn.png"))); menuViewSpawn.setMnemonic('S'); menuViewSpawn.setSelected(true); mnEdit.add(menuViewSpawn); menuViewItems = new JCheckBoxMenuItem("View Items"); menuViewItems.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, 0)); menuViewItems.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuViewItems.setSelected(true); menuViewItems .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_items.png"))); menuViewItems.setMnemonic('I'); mnEdit.add(menuViewItems); menuViewDoorItems = new JCheckBoxMenuItem("View Door Items"); menuViewDoorItems.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_3, 0)); menuViewDoorItems.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuViewDoorItems.setSelected(true); menuViewDoorItems.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_door_items.png"))); menuViewDoorItems.setMnemonic('D'); mnEdit.add(menuViewDoorItems); menuViewEnemies = new JCheckBoxMenuItem("View Enemies"); menuViewEnemies.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_4, 0)); menuViewEnemies.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuViewEnemies.setSelected(true); menuViewEnemies .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_enemies.png"))); menuViewEnemies.setMnemonic('E'); mnEdit.add(menuViewEnemies); menuViewTypes = new JCheckBoxMenuItem("View Combo Types"); menuViewTypes.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_5, 0)); menuViewTypes.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(false); } }); menuViewTypes.setSelected(true); menuViewTypes.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_combo_infos.png"))); menuViewTypes.setMnemonic('C'); mnEdit.add(menuViewTypes); mnEdit.addSeparator(); scaleMenuItem = new JCheckBoxMenuItem("Scale Level Display"); scaleMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_6, 0)); scaleMenuItem.setMnemonic('l'); scaleMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionScale(false); } }); scaleMenuItem.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_x2.png"))); mnEdit.add(scaleMenuItem); gridMenuItem = new JCheckBoxMenuItem("Display grid"); gridMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_7, 0)); gridMenuItem.setMnemonic('G'); gridMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionGrid(false); } }); gridMenuItem.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_grid.png"))); mnEdit.add(gridMenuItem); //mnEdit.addSeparator(); mntmPreferences = new JMenuItem("Preferences..."); mntmPreferences.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionPreferences(); } }); mntmPreferences.setMnemonic('P'); mntmPreferences.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_preferences.png"))); //mnEdit.add(mntmPreferences); mnHelp = new JMenu("Help"); mnHelp.setMnemonic('H'); menuBar.add(mnHelp); mntmCheckUpdates = new JMenuItem("Check for Updates..."); mntmCheckUpdates.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_MASK)); mntmCheckUpdates.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionCheckUpdates(); } }); mntmCheckUpdates.setMnemonic('c'); mntmCheckUpdates .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_update.png"))); mnHelp.add(mntmCheckUpdates); mntmAbout = new JMenuItem("Readme..."); mntmAbout.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); mntmAbout.setMnemonic('r'); mntmAbout.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/about.png"))); mntmAbout.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionAbout(); } }); mnHelp.addSeparator(); mnHelp.add(mntmAbout); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); JToolBar toolBar = new JToolBar(); toolBar.setRollover(true); toolBar.setFloatable(false); contentPane.add(toolBar, BorderLayout.NORTH); barLoadRom = new JButton(""); barLoadRom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionOpenRom(null); } }); barLoadRom.setToolTipText("Open"); barLoadRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_open.png"))); toolBar.add(barLoadRom); barSaveRom = new JButton(""); barSaveRom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveRom(); } }); barSaveRom.setToolTipText("Save"); barSaveRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save.png"))); toolBar.add(barSaveRom); toolBar.addSeparator(); barImportLevel = new JButton(""); barImportLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionImportLevel(); } }); barImportLevel.setToolTipText("Import Level"); barImportLevel .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_import.png"))); toolBar.add(barImportLevel); barExportLevel = new JButton(""); barExportLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionExportLevel(); } }); barExportLevel.setToolTipText("Export Level"); barExportLevel .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_export.png"))); toolBar.add(barExportLevel); toolBar.addSeparator(); barLoadLevel = new JButton(""); barLoadLevel.setToolTipText("Load Level"); barLoadLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionLoadLevel(); } }); barLoadLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_load_level.png"))); toolBar.add(barLoadLevel); barReloadLevel = new JButton(""); barReloadLevel.setToolTipText("Reload Current Level"); barReloadLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionReloadLevel(); } }); barReloadLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_reload_level.png"))); toolBar.add(barReloadLevel); barSaveLevel = new JButton(""); barSaveLevel.setToolTipText("Save Level"); barSaveLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionSaveLevel(); } }); barSaveLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_level.png"))); toolBar.add(barSaveLevel); toolBar.addSeparator(); barViewItems = new JToggleButton(""); barViewItems.setToolTipText("Toggle View Items"); barViewItems.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barViewSpawn = new JToggleButton(""); barViewSpawn.setToolTipText("Toggle View Spawn"); barViewSpawn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barClearLevel = new JButton(""); barClearLevel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionClearLevel(); } }); barClearLevel.setToolTipText("Clear Level"); barClearLevel.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_clear_level.png"))); toolBar.add(barClearLevel); toolBar.addSeparator(); barViewSpawn.setSelected(true); barViewSpawn.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_spawn.png"))); toolBar.add(barViewSpawn); barViewItems.setSelected(true); barViewItems.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_items.png"))); toolBar.add(barViewItems); barViewDoorItems = new JToggleButton(""); barViewDoorItems.setToolTipText("Toggle View Door Items"); barViewDoorItems.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barViewDoorItems.setSelected(true); barViewDoorItems.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_door_items.png"))); toolBar.add(barViewDoorItems); barViewEnemies = new JToggleButton(""); barViewEnemies.setToolTipText("toggle View Enemies"); barViewEnemies.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barViewEnemies.setSelected(true); barViewEnemies .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_enemies.png"))); toolBar.add(barViewEnemies); barViewTypes = new JToggleButton(""); barViewTypes.setToolTipText("Toggle view Combo Help"); barViewTypes.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionToggle(true); } }); barViewTypes.setSelected(true); barViewTypes.setIcon( new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_combo_infos.png"))); toolBar.add(barViewTypes); barViewSpawn.setSelected(config.getBoolean("Hazelnutt.gui.viewSpawn", true)); barViewItems.setSelected(config.getBoolean("Hazelnutt.gui.viewItems", true)); barViewDoorItems.setSelected(config.getBoolean("Hazelnutt.gui.viewDoorItems", true)); barViewEnemies.setSelected(config.getBoolean("Hazelnutt.gui.viewEnemies", true)); barViewTypes.setSelected(config.getBoolean("Hazelnutt.gui.viewHelp", true)); panel = new JPanel(); contentPane.add(panel, BorderLayout.EAST); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); selectorPanel = new SelectorPanel(); selectorPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Combo & Entity Selector", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213))); panel.add(selectorPanel); propertiesPanel = new PropertiesPanel(null); propertiesPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Level Properties", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213))); panel.add(propertiesPanel); toolBar.addSeparator(); scaleButton = new JToggleButton(""); scaleButton.setToolTipText("Toggle Scale Display"); scaleButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionScale(true); } }); scaleButton.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_x2.png"))); toolBar.add(scaleButton); scaleButton.setSelected(config.getBoolean("Hazelnutt.gui.scaled", false)); gridButton = new JToggleButton(""); gridButton.setToolTipText("Display Grid"); gridButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { actionGrid(true); } }); gridButton.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_grid.png"))); toolBar.add(gridButton); gridButton.setSelected(config.getBoolean("Hazelnutt.gui.grid", false)); Component horizontalGlue = Box.createHorizontalGlue(); toolBar.add(horizontalGlue); Component verticalGlue = Box.createVerticalGlue(); panel.add(verticalGlue); levelWrapper = new JPanel(); levelWrapper.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Level", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213))); contentPane.add(levelWrapper, BorderLayout.CENTER); levelWrapper.setLayout(new BorderLayout(0, 0)); scrollPane = new JScrollPane(); scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0)); levelWrapper.add(scrollPane); levelDisplay = new LevelDisplay(); levelDisplay.addEditListener(new EditListener() { @Override public void leftPressed(int x, int y) { SelectionType st = selectorPanel.getSelectionType(); Object so = selectorPanel.getSelectedObject(); if (st == SelectionType.COMBO) { paintComboAt(x, y, ((Byte) so).byteValue()); } else if (st == SelectionType.SPAWN) { selectedLevel.getRomLevel().setSpawn(new IntVector(x, y)); levelHasChanged = true; } else if (st == SelectionType.ITEM) { Item ent = new Item((ItemType) so, x, y); EntityCollection<Item> ents = selectedLevel.getRomLevel().getItems(); for (Iterator<Item> it = ents.iterator(); it.hasNext();) { Item item = it.next(); if (item.getX() == x && item.getY() == y) { it.remove(); } } if (ents.size() <= ents.maxSize()) { ents.add(ent); levelHasChanged = true; } } else if (st == SelectionType.DOOR_ITEM) { Item ent = new Item((ItemType) so, x, y); EntityCollection<Item> ents = selectedLevel.getRomLevel().getDoorItems(); for (Iterator<Item> it = ents.iterator(); it.hasNext();) { Item item = it.next(); if (item.getX() == x && item.getY() == y) { it.remove(); } } if (ents.size() <= ents.maxSize()) { ents.add(ent); levelHasChanged = true; } } else if (st == SelectionType.ENEMY) { Enemy ent = new Enemy((EnemyType) so, x, y); EntityCollection<Enemy> ents = selectedLevel.getRomLevel().getEnemies(); for (Iterator<Enemy> it = ents.iterator(); it.hasNext();) { Enemy enem = it.next(); if (enem.getX() == x && enem.getY() == y) { it.remove(); } } if (ents.size() <= ents.maxSize()) { ents.add(ent); levelHasChanged = true; } } updateTitle(); levelDisplay.repaint(); levelHasChanged = true; } @Override public void centerPressed(int x, int y) { selectorPanel.forceComboSelection(selectedLevel.getRomLevel().getData()[x][y]); } @Override public void rightPressed(int x, int y) { deleteVisibleEntitiesAt(x, y); } @Override public void leftDragged(int x, int y) { if (selectorPanel.getSelectionType() == SelectionType.COMBO) { paintComboAt(x, y, ((Byte) selectorPanel.getSelectedObject()).byteValue()); } } @Override public void centerDragged(int x, int y) { // Nothing to de here } @Override public void rightDragged(int x, int y) { deleteVisibleEntitiesAt(x, y); } // Utility methods /*private void selectComboAt ( int x, int y ) { }/**/ private void paintComboAt(int x, int y, byte value) { selectedLevel.getRomLevel().getData()[x][y] = value; levelHasChanged = true; updateTitle(); levelDisplay.repaint(); } private void deleteVisibleEntitiesAt(int x, int y) { Collection<Item> items = selectedLevel.getRomLevel().getItems(); Collection<Item> doorItems = selectedLevel.getRomLevel().getDoorItems(); Collection<Enemy> enemies = selectedLevel.getRomLevel().getEnemies(); if (barViewItems.isSelected()) { for (Iterator<Item> it = items.iterator(); it.hasNext();) { Item item = it.next(); if (item.getX() == x && item.getY() == y) { it.remove(); levelHasChanged = true; } } } if (barViewDoorItems.isSelected()) { for (Iterator<Item> it = doorItems.iterator(); it.hasNext();) { Item doorItem = it.next(); if (doorItem.getX() == x && doorItem.getY() == y) { it.remove(); levelHasChanged = true; } } } if (barViewEnemies.isSelected()) { for (Iterator<Enemy> it = enemies.iterator(); it.hasNext();) { Enemy enem = it.next(); if (enem.getX() == x && enem.getY() == y) { it.remove(); levelHasChanged = true; } } } updateTitle(); levelDisplay.repaint(); } }); scrollPane.setViewportView(levelDisplay); updateTitle(); actionToggle(true); actionScale(true); actionGrid(true); setIconImage(Toolkit.getDefaultToolkit() .getImage(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/witch_hazel_big.png"))); setRomFeaturesEnabled(false); setLevelFeaturesEnabled(false); if (config.getBoolean("Hazelnutt.gui.maximum", false)) { setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH); } else { int x = config.getInt("Hazelnutt.gui.location.x", Integer.MIN_VALUE); int y = config.getInt("Hazelnutt.gui.location.y", Integer.MIN_VALUE); int w = config.getInt("Hazelnutt.gui.size.width", Integer.MIN_VALUE); int h = config.getInt("Hazelnutt.gui.size.height", Integer.MIN_VALUE); if (x == Integer.MIN_VALUE || x == Integer.MIN_VALUE || w == Integer.MIN_VALUE || h == Integer.MIN_VALUE) { setLocationRelativeTo(null); } else { setLocation(x, y); setSize(w, h); } } propertiesPanel.addApplyListener(new PropertiesPanel.ApplyListener() { @Override public void apply() { levelHasChanged = true; updateTitle(); updateDisplay(); } }); if (config.containsKey("Hazelnutt.gui.lastDirectory")) { File lastDir = new File(config.getString("Hazelnutt.gui.lastDirectory")); if (lastDir.exists() && lastDir.isDirectory()) { //logger.debug( "Resetting the last directory: '" + lastDir + "'" ); fileChooser.setCurrentDirectory(lastDir); } } // Configure the PgUp and PgDn shortcuts InputMap im = contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), "PgUp"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), "PgDn"); ActionMap am = contentPane.getActionMap(); am.put("PgUp", new AbstractAction() { @Override public void actionPerformed(ActionEvent arg0) { actionLevelUp(); } }); am.put("PgDn", new AbstractAction() { @Override public void actionPerformed(ActionEvent arg0) { actionLevelDown(); } }); // Get the recent files recentFiles = new LinkedList<String>(Arrays.asList(config.getStringArray("Hazelnutt.gui.recentFiles"))); updateRecentFiles(); }