List of usage examples for javax.swing ButtonGroup ButtonGroup
public ButtonGroup()
ButtonGroup
. From source file:com.mirth.connect.connectors.file.AdvancedSftpSettingsDialog.java
private void initComponents() { authenticationLabel = new JLabel("Authentication:"); usePasswordRadio = new JRadioButton("Password"); usePasswordRadio.setFocusable(false); usePasswordRadio.setBackground(new Color(255, 255, 255)); usePasswordRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); usePasswordRadio.setToolTipText("Select this option to use a password to gain access to the server."); usePasswordRadio.addActionListener(new ActionListener() { @Override//from w w w . ja v a 2 s .com public void actionPerformed(ActionEvent e) { authenticationRadioButtonActionPerformed(); } }); usePrivateKeyRadio = new JRadioButton("Public Key"); usePrivateKeyRadio.setSelected(true); usePrivateKeyRadio.setFocusable(false); usePrivateKeyRadio.setBackground(UIConstants.BACKGROUND_COLOR); usePrivateKeyRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); usePrivateKeyRadio .setToolTipText("Select this option to use a public/private keypair to gain access to the server."); usePrivateKeyRadio.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { authenticationRadioButtonActionPerformed(); } }); useBothRadio = new JRadioButton("Both"); useBothRadio.setSelected(true); useBothRadio.setFocusable(false); useBothRadio.setBackground(UIConstants.BACKGROUND_COLOR); useBothRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); useBothRadio.setToolTipText( "Select this option to use both a password and a public/private keypair to gain access to the server."); useBothRadio.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { authenticationRadioButtonActionPerformed(); } }); privateKeyButtonGroup = new ButtonGroup(); privateKeyButtonGroup.add(usePasswordRadio); privateKeyButtonGroup.add(usePrivateKeyRadio); privateKeyButtonGroup.add(useBothRadio); keyLocationLabel = new JLabel("Public/Private Key File:"); keyLocationField = new JTextField(); keyLocationField.setToolTipText( "The absolute file path of the public/private keypair used to gain access to the remote server."); passphraseLabel = new JLabel("Passphrase:"); passphraseField = new JPasswordField(); passphraseField.setToolTipText("The passphrase associated with the public/private keypair."); useKnownHostsLabel = new JLabel("Host Key Checking:"); useKnownHostsYesRadio = new JRadioButton("Yes"); useKnownHostsYesRadio.setFocusable(false); useKnownHostsYesRadio.setBackground(UIConstants.BACKGROUND_COLOR); useKnownHostsYesRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); useKnownHostsYesRadio.setToolTipText( "<html>Select this option to validate the server's host key within the provided<br>Known Hosts file. Known Hosts file is required.</html>"); useKnownHostsAskRadio = new JRadioButton("Ask"); useKnownHostsAskRadio.setFocusable(false); useKnownHostsAskRadio.setBackground(UIConstants.BACKGROUND_COLOR); useKnownHostsAskRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); useKnownHostsAskRadio.setToolTipText( "<html>Select this option to ask the user to add the server's host key to the provided<br>Known Hosts file. Known Hosts file is optional.</html>"); useKnownHostsNoRadio = new JRadioButton("No"); useKnownHostsNoRadio.setSelected(true); useKnownHostsNoRadio.setFocusable(false); useKnownHostsNoRadio.setBackground(UIConstants.BACKGROUND_COLOR); useKnownHostsNoRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); useKnownHostsNoRadio.setToolTipText( "<html>Select this option to always add the server's host key to the provided<br>Known Hosts file. Known Hosts file is optional.</html>"); knownHostsButtonGroup = new ButtonGroup(); knownHostsButtonGroup.add(useKnownHostsYesRadio); knownHostsButtonGroup.add(useKnownHostsAskRadio); knownHostsButtonGroup.add(useKnownHostsNoRadio); knownHostsLocationLabel = new JLabel("Known Hosts File:"); knownHostsField = new JTextField(); knownHostsField .setToolTipText("The path to the local Known Hosts file used to authenticate the remote server."); configurationsLabel = new JLabel("Configuration Options:"); configurationsTable = new MirthTable(); Object[][] tableData = new Object[0][1]; configurationsTable.setModel(new RefreshTableModel(tableData, new String[] { "Name", "Value" })); configurationsTable.setOpaque(true); configurationsTable.getColumnModel() .getColumn(configurationsTable.getColumnModel().getColumnIndex(NAME_COLUMN_NAME)) .setCellEditor(new ConfigTableCellEditor(true)); configurationsTable.getColumnModel() .getColumn(configurationsTable.getColumnModel().getColumnIndex(VALUE_COLUMN_NAME)) .setCellEditor(new ConfigTableCellEditor(false)); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); configurationsTable.setHighlighters(highlighter); } configurationsScrollPane = new JScrollPane(); configurationsScrollPane.getViewport().add(configurationsTable); newButton = new JButton("New"); newButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DefaultTableModel model = (DefaultTableModel) configurationsTable.getModel(); Vector<String> row = new Vector<String>(); String header = "Property"; for (int i = 1; i <= configurationsTable.getRowCount() + 1; i++) { boolean exists = false; for (int index = 0; index < configurationsTable.getRowCount(); index++) { if (((String) configurationsTable.getValueAt(index, 0)).equalsIgnoreCase(header + i)) { exists = true; } } if (!exists) { row.add(header + i); break; } } model.addRow(row); int rowSelectionNumber = configurationsTable.getRowCount() - 1; configurationsTable.setRowSelectionInterval(rowSelectionNumber, rowSelectionNumber); Boolean enabled = deleteButton.isEnabled(); if (!enabled) { deleteButton.setEnabled(true); } } }); deleteButton = new JButton("Delete"); deleteButton.setEnabled(false); deleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int rowSelectionNumber = configurationsTable.getSelectedRow(); if (rowSelectionNumber > -1) { DefaultTableModel model = (DefaultTableModel) configurationsTable.getModel(); model.removeRow(rowSelectionNumber); rowSelectionNumber--; if (rowSelectionNumber > -1) { configurationsTable.setRowSelectionInterval(rowSelectionNumber, rowSelectionNumber); } if (configurationsTable.getRowCount() == 0) { deleteButton.setEnabled(false); } } } }); okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { okCancelButtonActionPerformed(); } }); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { dispose(); } }); authenticationRadioButtonActionPerformed(); }
From source file:livecanvas.mesheditor.MeshEditor.java
private JToolBar createTools() { JToolBar toolbar = new JToolBar(JToolBar.VERTICAL); ButtonGroup toolsBg = new ButtonGroup(); JToggleButton toolsButton;//ww w .j a va 2s . c o m toolbar.add(toolsButton = Utils.createToolBarToggleButton("Brush", new ImageIcon(clazz.getResource("res/brush.png")), ButtonType.ICON_ONLY, TOOLS_BRUSH, "Brush", toolsBg, this)); toolsButton.setSelected(true); toolbar.add(toolsButton = Utils.createToolBarToggleButton("Pen", new ImageIcon(clazz.getResource("res/pen.png")), ButtonType.ICON_ONLY, TOOLS_PEN, "Pen", toolsBg, this)); toolbar.add(toolsButton = Utils.createToolBarToggleButton("MagicWand", new ImageIcon(clazz.getResource("res/wand.png")), ButtonType.ICON_ONLY, TOOLS_MAGICWAND, "Magic Wand", toolsBg, this)); toolbar.add(toolsButton = Utils.createToolBarToggleButton("SetControlPoints", new ImageIcon(clazz.getResource("res/set_controls.png")), ButtonType.ICON_ONLY, TOOLS_SETCONTROLPOINTS, "Set Control Points", toolsBg, this)); toolbar.add(toolsButton = Utils.createToolBarToggleButton("Pointer", new ImageIcon(clazz.getResource("res/pointer.png")), ButtonType.ICON_ONLY, TOOLS_POINTER, "Pointer", toolsBg, this)); toolbar.add(toolsButton = Utils.createToolBarToggleButton("PanZoom", new ImageIcon(clazz.getResource("res/panzoom.png")), ButtonType.ICON_ONLY, TOOLS_PANZOOM, "Pan or Zoom Canvas", toolsBg, this)); // toolsButton.setSelected(true); return toolbar; }
From source file:com.igormaznitsa.sciareto.ui.MainFrame.java
public MainFrame(@Nonnull @MustNotContainNull final String... args) { super();/*from w ww .j a v a 2 s .co m*/ initComponents(); this.stackPanel = new JPanel(); this.stackPanel.setFocusable(false); this.stackPanel.setOpaque(false); this.stackPanel.setBorder(BorderFactory.createEmptyBorder(32, 32, 16, 32)); this.stackPanel.setLayout(new BoxLayout(this.stackPanel, BoxLayout.Y_AXIS)); final JPanel glassPanel = (JPanel) this.getGlassPane(); glassPanel.setOpaque(false); this.setGlassPane(glassPanel); glassPanel.setLayout(new BorderLayout(8, 8)); glassPanel.add(Box.createGlue(), BorderLayout.CENTER); final JPanel ppanel = new JPanel(new BorderLayout(0, 0)); ppanel.setFocusable(false); ppanel.setOpaque(false); ppanel.setCursor(null); ppanel.add(this.stackPanel, BorderLayout.SOUTH); glassPanel.add(ppanel, BorderLayout.EAST); this.stackPanel.add(Box.createGlue()); glassPanel.setVisible(false); this.setTitle("Scia Reto"); setIconImage(UiUtils.loadImage("logo256x256.png")); this.stateless = args.length > 0; final MainFrame theInstance = this; this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(@Nonnull final WindowEvent e) { if (doClosing()) { dispose(); } } }); this.tabPane = new EditorTabPane(this); this.explorerTree = new ExplorerTree(this); final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(250); splitPane.setResizeWeight(0.0d); splitPane.setLeftComponent(this.explorerTree); splitPane.setRightComponent(this.tabPane); add(splitPane, BorderLayout.CENTER); this.menuOpenRecentProject.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { final File[] lastOpenedProjects = FileHistoryManager.getInstance().getLastOpenedProjects(); if (lastOpenedProjects.length > 0) { for (final File folder : lastOpenedProjects) { final JMenuItem item = new JMenuItem(folder.getName()); item.setToolTipText(folder.getAbsolutePath()); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openProject(folder, false); } }); menuOpenRecentProject.add(item); } } } @Override public void menuDeselected(MenuEvent e) { menuOpenRecentProject.removeAll(); } @Override public void menuCanceled(MenuEvent e) { } }); this.menuOpenRecentFile.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { final File[] lastOpenedFiles = FileHistoryManager.getInstance().getLastOpenedFiles(); if (lastOpenedFiles.length > 0) { for (final File file : lastOpenedFiles) { final JMenuItem item = new JMenuItem(file.getName()); item.setToolTipText(file.getAbsolutePath()); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openFileAsTab(file); } }); menuOpenRecentFile.add(item); } } } @Override public void menuDeselected(MenuEvent e) { menuOpenRecentFile.removeAll(); } @Override public void menuCanceled(MenuEvent e) { } }); if (!this.stateless) { restoreState(); } else { boolean openedProject = false; for (final String filePath : args) { final File file = new File(filePath); if (file.isDirectory()) { openedProject = true; openProject(file, true); } else if (file.isFile()) { openFileAsTab(file); } } if (!openedProject) { //TODO try to hide project panel! } } final LookAndFeel current = UIManager.getLookAndFeel(); final ButtonGroup lfGroup = new ButtonGroup(); final String currentLFClassName = current.getClass().getName(); for (final UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { final JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(info.getName()); lfGroup.add(menuItem); if (currentLFClassName.equals(info.getClassName())) { menuItem.setSelected(true); } menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(@Nonnull final ActionEvent e) { try { UIManager.setLookAndFeel(info.getClassName()); SwingUtilities.updateComponentTreeUI(theInstance); PreferencesManager.getInstance().getPreferences().put(Main.PROPERTY_LOOKANDFEEL, info.getClassName()); PreferencesManager.getInstance().flush(); } catch (Exception ex) { LOGGER.error("Can't change LF", ex); } } }); this.menuLookAndFeel.add(menuItem); } }
From source file:com.mirth.connect.client.ui.components.rsta.FindReplaceDialog.java
private void initComponents() { setLayout(new MigLayout("insets 11, novisualpadding, hidemode 3, fill, gap 6")); setBackground(UIConstants.COMBO_BOX_BACKGROUND); getContentPane().setBackground(getBackground()); findPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3, fill, gap 6")); findPanel.setBackground(getBackground()); ActionListener findActionListener = new ActionListener() { @Override//from w w w . j a va 2 s . com public void actionPerformed(ActionEvent evt) { find(); } }; findLabel = new JLabel("Find text:"); findComboBox = new JComboBox<String>(); findComboBox.setEditable(true); findComboBox.setBackground(UIConstants.BACKGROUND_COLOR); findComboBox.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() { @Override public void keyReleased(final KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_ENTER && evt.getModifiers() == 0) { find(); } } }); ActionListener replaceActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { replace(); } }; replaceLabel = new JLabel("Replace with:"); replaceComboBox = new JComboBox<String>(); replaceComboBox.setEditable(true); replaceComboBox.setBackground(UIConstants.BACKGROUND_COLOR); directionPanel = new JPanel(new MigLayout("insets 8, novisualpadding, hidemode 3, fill, gap 6")); directionPanel.setBackground(getBackground()); directionPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createLineBorder(new Color(150, 150, 150)), "Direction", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11))); ButtonGroup directionButtonGroup = new ButtonGroup(); directionForwardRadio = new JRadioButton("Forward"); directionForwardRadio.setBackground(directionPanel.getBackground()); directionButtonGroup.add(directionForwardRadio); directionBackwardRadio = new JRadioButton("Backward"); directionBackwardRadio.setBackground(directionPanel.getBackground()); directionButtonGroup.add(directionBackwardRadio); optionsPanel = new JPanel(new MigLayout("insets 8, novisualpadding, hidemode 3, fill, gap 6")); optionsPanel.setBackground(getBackground()); optionsPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createLineBorder(new Color(150, 150, 150)), "Options", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11))); wrapSearchCheckBox = new JCheckBox("Wrap Search"); matchCaseCheckBox = new JCheckBox("Match Case"); regularExpressionCheckBox = new JCheckBox("Regular Expression"); wholeWordCheckBox = new JCheckBox("Whole Word"); findButton = new JButton("Find"); findButton.addActionListener(findActionListener); replaceButton = new JButton("Replace"); replaceButton.addActionListener(replaceActionListener); replaceAllButton = new JButton("Replace All"); replaceAllButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { replaceAll(); } }); warningLabel = new JLabel(); closeButton = new JButton("Close"); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { dispose(); } }); }
From source file:interfazGrafica.loginInterface.java
/** * Creates new form loginInterface//w ww . j a va2 s. c o m */ public loginInterface() { initComponents(); id_usuario_global = ""; tipoReporte = -1; //Inicializacion de paneles como no visibles panelContenedor.setVisible(true); panelContenedorJefe.setVisible(true); panelContenedorVendedor.setVisible(true); panelCrearUsuario.setVisible(false); panelModificarUsuario.setVisible(false); panelCrearSede.setVisible(false); panelModificarSede.setVisible(false); panelAgregarVehiculos.setVisible(false); panelModificarVehiculo.setVisible(false); panelAgregarPartes.setVisible(false); panelModificarPartes.setVisible(false); panelGenerarReportes.setVisible(false); //Adicion de paneles al card layout del gerente panelContenedor.setLayout(new CardLayout()); panelContenedor.add(panelVacio, "Inicio"); panelContenedor.add(panelCrearUsuario, "Crear Usuario"); panelContenedor.add(panelCrearSede, "Crear Sede"); panelContenedor.add(panelModificarUsuario, "Modificar Usuario"); panelContenedor.add(panelModificarSede, "Modificar Sede"); panelContenedor.add(panelAgregarVehiculos, "Agregar Vehiculo"); panelContenedor.add(panelModificarVehiculo, "Modificar Vehiculo"); panelContenedor.add(panelAgregarPartes, "Agregar Partes"); panelContenedor.add(panelModificarPartes, "Modificar Partes"); panelContenedor.add(panelGenerarReportes, "Generar reportes"); panelContenedor.add(panelConsultas, "Consultas"); panelContenedor.add(panelReporteFinal, "Reporte"); cl = (CardLayout) (panelContenedor.getLayout()); //Adicion de paneles al card layout del vendedor panelContenedorVendedor.setLayout(new CardLayout()); panelContenedorVendedor.add(panelVacio1, "Inicio"); panelContenedorVendedor.add(panelCrearCotizacion, "Crear cotizacion"); panelContenedorVendedor.add(panelConsultarCotizacion, "Consultar cotizacion"); panelContenedorVendedor.add(panelVender, "Vender"); clVendedor = (CardLayout) (panelContenedorVendedor.getLayout()); //Adicion de paneles al card layout del jefe de taller panelContenedorJefe.setLayout(new CardLayout()); panelContenedorJefe.add(panelVacio2, "Inicio"); panelContenedorJefe.add(panelCrearOrden, "Crear orden"); panelContenedorJefe.add(panelConsultarOrden, "Consultar orden"); clJefe = (CardLayout) panelContenedorJefe.getLayout(); //Adicion de paneles al cardlayout del panel de inventario panel.setLayout(new CardLayout()); panel.add(panelGestion, "Gestion"); panel.add(manejoVehiculos, "Vehiculos"); panel.add(manejoPartes, "Partes"); //System.out.println(""+panelContenedorInventario.getLayout()); clInventario = (CardLayout) panel.getLayout(); //Creacion de ButtonGroups modUsuario = new ButtonGroup(); agregarVehiculos = new ButtonGroup(); modVehiculos = new ButtonGroup(); tiempoReporte = new ButtonGroup(); espacioReporte = new ButtonGroup(); modUsuario.add(modificarActivoRB); modUsuario.add(modificarInactivoRB); agregarVehiculos.add(crearVehiculoNuevoRB); agregarVehiculos.add(crearVehiculoUsadoRB); modVehiculos.add(modificarVehiculoNuevoRB); modVehiculos.add(modificarVehiculoUsadoRB); tiempoReporte.add(semanalOpcionesReportes); tiempoReporte.add(todoOpcionesReportes); espacioReporte.add(sedesOpcionesReportes); espacioReporte.add(empresaOpcionesReportes); }
From source file:gov.loc.repository.bagger.ui.SaveBagFrame.java
private JPanel createComponents() { Border border = new EmptyBorder(5, 5, 5, 5); TitlePane titlePane = new TitlePane(); initStandardCommands();//from w ww . j a va 2 s .c om JPanel pageControl = new JPanel(new BorderLayout()); JPanel titlePaneContainer = new JPanel(new BorderLayout()); titlePane.setTitle(bagView.getPropertyMessage("SaveBagFrame.title")); titlePane.setMessage(new DefaultMessage(bagView.getPropertyMessage("Define the Bag settings"))); titlePaneContainer.add(titlePane.getControl()); titlePaneContainer.add(new JSeparator(), BorderLayout.SOUTH); pageControl.add(titlePaneContainer, BorderLayout.NORTH); JPanel contentPane = new JPanel(); // TODO: Add bag name field // TODO: Add save name file selection button JLabel location = new JLabel("Save in:"); browseButton = new JButton(getMessage("bag.button.browse")); browseButton.addActionListener(new SaveBagAsHandler()); browseButton.setEnabled(true); browseButton.setToolTipText(getMessage("bag.button.browse.help")); String fileName = ""; DefaultBag bag = bagView.getBag(); if (bag != null) { fileName = bag.getName(); } bagNameField = new JTextField(fileName); bagNameField.setCaretPosition(fileName.length()); bagNameField.setEditable(false); bagNameField.setEnabled(false); // Holey bag control JLabel holeyLabel = new JLabel(bagView.getPropertyMessage("bag.label.isholey")); holeyLabel.setToolTipText(bagView.getPropertyMessage("bag.isholey.help")); holeyCheckbox = new JCheckBox(bagView.getPropertyMessage("bag.checkbox.isholey")); holeyCheckbox.setBorder(border); holeyCheckbox.setSelected(bag.isHoley()); holeyCheckbox.addActionListener(new HoleyBagHandler()); holeyCheckbox.setToolTipText(bagView.getPropertyMessage("bag.isholey.help")); urlLabel = new JLabel(bagView.getPropertyMessage("baseURL.label")); urlLabel.setToolTipText(bagView.getPropertyMessage("baseURL.description")); urlLabel.setEnabled(bag.isHoley()); urlField = new JTextField(""); try { urlField.setText(bag.getFetch().getBaseURL()); } catch (Exception e) { log.error("fetch baseURL: " + e.getMessage()); } urlField.setEnabled(false); // TODO: Add format label JLabel serializeLabel; serializeLabel = new JLabel(getMessage("bag.label.ispackage")); serializeLabel.setToolTipText(getMessage("bag.serializetype.help")); // TODO: Add format selection panel noneButton = new JRadioButton(getMessage("bag.serializetype.none")); noneButton.setEnabled(true); AbstractAction serializeListener = new SerializeBagHandler(); noneButton.addActionListener(serializeListener); noneButton.setToolTipText(getMessage("bag.serializetype.none.help")); zipButton = new JRadioButton(getMessage("bag.serializetype.zip")); zipButton.setEnabled(true); zipButton.addActionListener(serializeListener); zipButton.setToolTipText(getMessage("bag.serializetype.zip.help")); /* tarButton = new JRadioButton(getMessage("bag.serializetype.tar")); tarButton.setEnabled(true); tarButton.addActionListener(serializeListener); tarButton.setToolTipText(getMessage("bag.serializetype.tar.help")); tarGzButton = new JRadioButton(getMessage("bag.serializetype.targz")); tarGzButton.setEnabled(true); tarGzButton.addActionListener(serializeListener); tarGzButton.setToolTipText(getMessage("bag.serializetype.targz.help")); tarBz2Button = new JRadioButton(getMessage("bag.serializetype.tarbz2")); tarBz2Button.setEnabled(true); tarBz2Button.addActionListener(serializeListener); tarBz2Button.setToolTipText(getMessage("bag.serializetype.tarbz2.help")); */ short mode = bag.getSerialMode(); if (mode == DefaultBag.NO_MODE) { this.noneButton.setEnabled(true); } else if (mode == DefaultBag.ZIP_MODE) { this.zipButton.setEnabled(true); } /*else if (mode == DefaultBag.TAR_MODE) { this.tarButton.setEnabled(true); } else if (mode == DefaultBag.TAR_GZ_MODE) { this.tarGzButton.setEnabled(true); } else if (mode == DefaultBag.TAR_BZ2_MODE) { this.tarBz2Button.setEnabled(true); } */else { this.noneButton.setEnabled(true); } ButtonGroup serializeGroup = new ButtonGroup(); serializeGroup.add(noneButton); serializeGroup.add(zipButton); //serializeGroup.add(tarButton); //serializeGroup.add(tarGzButton); //serializeGroup.add(tarBz2Button); serializeGroupPanel = new JPanel(new FlowLayout()); serializeGroupPanel.add(serializeLabel); serializeGroupPanel.add(noneButton); serializeGroupPanel.add(zipButton); //serializeGroupPanel.add(tarButton); //serializeGroupPanel.add(tarGzButton); //serializeGroupPanel.add(tarBz2Button); serializeGroupPanel.setBorder(border); serializeGroupPanel.setEnabled(true); serializeGroupPanel.setToolTipText(bagView.getPropertyMessage("bag.serializetype.help")); JLabel tagLabel = new JLabel(getMessage("bag.label.istag")); tagLabel.setToolTipText(getMessage("bag.label.istag.help")); isTagCheckbox = new JCheckBox(); isTagCheckbox.setBorder(border); isTagCheckbox.setSelected(bag.isBuildTagManifest()); isTagCheckbox.addActionListener(new TagManifestHandler()); isTagCheckbox.setToolTipText(getMessage("bag.checkbox.istag.help")); JLabel tagAlgorithmLabel = new JLabel(getMessage("bag.label.tagalgorithm")); tagAlgorithmLabel.setToolTipText(getMessage("bag.label.tagalgorithm.help")); ArrayList<String> listModel = new ArrayList<String>(); for (Algorithm algorithm : Algorithm.values()) { listModel.add(algorithm.bagItAlgorithm); } tagAlgorithmList = new JComboBox(listModel.toArray()); tagAlgorithmList.setName(getMessage("bag.tagalgorithmlist")); tagAlgorithmList.setSelectedItem(bag.getTagManifestAlgorithm()); tagAlgorithmList.addActionListener(new TagAlgorithmListHandler()); tagAlgorithmList.setToolTipText(getMessage("bag.tagalgorithmlist.help")); JLabel payloadLabel = new JLabel(getMessage("bag.label.ispayload")); payloadLabel.setToolTipText(getMessage("bag.ispayload.help")); isPayloadCheckbox = new JCheckBox(); isPayloadCheckbox.setBorder(border); isPayloadCheckbox.setSelected(bag.isBuildPayloadManifest()); isPayloadCheckbox.addActionListener(new PayloadManifestHandler()); isPayloadCheckbox.setToolTipText(getMessage("bag.ispayload.help")); JLabel payAlgorithmLabel = new JLabel(bagView.getPropertyMessage("bag.label.payalgorithm")); payAlgorithmLabel.setToolTipText(getMessage("bag.payalgorithm.help")); payAlgorithmList = new JComboBox(listModel.toArray()); payAlgorithmList.setName(getMessage("bag.payalgorithmlist")); payAlgorithmList.setSelectedItem(bag.getPayloadManifestAlgorithm()); payAlgorithmList.addActionListener(new PayAlgorithmListHandler()); payAlgorithmList.setToolTipText(getMessage("bag.payalgorithmlist.help")); GridBagLayout layout = new GridBagLayout(); GridBagConstraints glbc = new GridBagConstraints(); JPanel panel = new JPanel(layout); panel.setBorder(new EmptyBorder(10, 10, 10, 10)); int row = 0; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(location, glbc); panel.add(location); buildConstraints(glbc, 2, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.EAST); glbc.ipadx = 5; layout.setConstraints(browseButton, glbc); glbc.ipadx = 0; panel.add(browseButton); buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); glbc.ipadx = 5; layout.setConstraints(bagNameField, glbc); glbc.ipadx = 0; panel.add(bagNameField); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(holeyLabel, glbc); panel.add(holeyLabel); buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.WEST, GridBagConstraints.WEST); layout.setConstraints(holeyCheckbox, glbc); panel.add(holeyCheckbox); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(urlLabel, glbc); panel.add(urlLabel); buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); layout.setConstraints(urlField, glbc); panel.add(urlField); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(serializeLabel, glbc); panel.add(serializeLabel); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); layout.setConstraints(serializeGroupPanel, glbc); panel.add(serializeGroupPanel); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(tagLabel, glbc); panel.add(tagLabel); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); layout.setConstraints(isTagCheckbox, glbc); panel.add(isTagCheckbox); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(tagAlgorithmLabel, glbc); panel.add(tagAlgorithmLabel); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); layout.setConstraints(tagAlgorithmList, glbc); panel.add(tagAlgorithmList); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(payloadLabel, glbc); panel.add(payloadLabel); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); layout.setConstraints(isPayloadCheckbox, glbc); panel.add(isPayloadCheckbox); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(payAlgorithmLabel, glbc); panel.add(payAlgorithmLabel); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); layout.setConstraints(payAlgorithmList, glbc); panel.add(payAlgorithmList); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); GuiStandardUtils.attachDialogBorder(contentPane); pageControl.add(panel); JComponent buttonBar = createButtonBar(); pageControl.add(buttonBar, BorderLayout.SOUTH); this.pack(); return pageControl; }
From source file:apidemo.PanScrollZoomDemo.java
/** * Creates the toolbar./*from w w w. jav a 2s . co m*/ * * @return the toolbar. */ private JToolBar createToolbar() { final JToolBar toolbar = new JToolBar(); final ButtonGroup groupedButtons = new ButtonGroup(); // ACTION_CMD_PAN this.panButton = new JToggleButton(); prepareButton(this.panButton, ACTION_CMD_PAN, " Pan ", "Pan mode"); groupedButtons.add(this.panButton); toolbar.add(this.panButton); // ACTION_CMD_ZOOM_BOX this.zoomButton = new JToggleButton(); prepareButton(this.zoomButton, ACTION_CMD_ZOOM_BOX, " Zoom ", "Zoom mode"); groupedButtons.add(this.zoomButton); this.zoomButton.setSelected(true); // no other makes sense after startup toolbar.add(this.zoomButton); // end of toggle-button group for select/pan/zoom-box toolbar.addSeparator(); // ACTION_CMD_ZOOM_IN this.zoomInButton = new JButton(); prepareButton(this.zoomInButton, ACTION_CMD_ZOOM_IN, " + ", "Zoom in"); toolbar.add(this.zoomInButton); // ACTION_CMD_ZOOM_OUT this.zoomOutButton = new JButton(); prepareButton(this.zoomOutButton, ACTION_CMD_ZOOM_OUT, " - ", "Zoom out"); toolbar.add(this.zoomOutButton); // ACTION_CMD_ZOOM_TO_FIT this.fitButton = new JButton(); prepareButton(this.fitButton, ACTION_CMD_ZOOM_TO_FIT, " Fit ", "Fit all"); toolbar.add(this.fitButton); toolbar.addSeparator(); this.scrollBar = new JScrollBar(JScrollBar.HORIZONTAL); // int ht = (int) zoomButton.getPreferredSize().getHeight(); // scrollBar.setPreferredSize(new Dimension(0, ht)); this.scrollBar.setModel(new DefaultBoundedRangeModel()); toolbar.add(this.scrollBar); this.zoomOutButton.setEnabled(false); this.fitButton.setEnabled(false); this.scrollBar.setEnabled(false); toolbar.setFloatable(false); return toolbar; }
From source file:org.cds06.speleograph.graph.SeriesMenu.java
private JPopupMenu createPopupMenuForSeries(final Series series) { if (series == null) return new JPopupMenu(); final JPopupMenu menu = new JPopupMenu(series.getName()); menu.removeAll();/*from www .jav a 2 s . c o m*/ menu.add(new AbstractAction() { { putValue(NAME, "Renommer la srie"); } @Override public void actionPerformed(ActionEvent e) { menu.setVisible(false); String newName = ""; while (newName == null || newName.equals("")) { newName = (String) JOptionPane.showInputDialog(application, "Entrez un nouveau nom pour la srie", null, JOptionPane.QUESTION_MESSAGE, null, null, series.getName()); } series.setName(newName); } }); if (series.hasOwnAxis()) { menu.add(new AbstractAction() { { putValue(NAME, "Supprimer l'axe spcifique"); } @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes vous sr de vouloir supprimer cet axe ?", "Confirmation", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { series.setAxis(null); } } }); } else { menu.add(new JMenuItem(new AbstractAction() { { putValue(NAME, "Crer un axe spcifique pour la srie"); } @Override public void actionPerformed(ActionEvent e) { String name = JOptionPane.showInputDialog(application, "Quel titre pour cet axe ?", series.getAxis().getLabel()); if (name == null || "".equals(name)) return; // User has canceled series.setAxis(new NumberAxis(name)); } })); } menu.add(new SetTypeMenu(series)); if (series.isWater()) { menu.addSeparator(); menu.add(new SumOnPeriodAction(series)); menu.add(new CreateCumulAction(series)); } if (series.isWaterCumul()) { menu.addSeparator(); menu.add(new SamplingAction(series)); } if (series.isPressure()) { menu.addSeparator(); menu.add(new CorrelateAction(series)); menu.add(new WaterHeightAction(series)); } menu.addSeparator(); menu.add(new AbstractAction() { { String name; if (series.canUndo()) name = "Annuler " + series.getItemsName(); else name = series.getLastUndoName(); putValue(NAME, name); if (series.canUndo()) setEnabled(true); else { setEnabled(false); } } @Override public void actionPerformed(ActionEvent e) { series.undo(); } }); menu.add(new AbstractAction() { { String name; if (series.canRedo()) { name = "Refaire " + series.getNextRedoName(); setEnabled(true); } else { name = series.getNextRedoName(); setEnabled(false); } putValue(NAME, name); } @Override public void actionPerformed(ActionEvent e) { series.redo(); } }); menu.add(new AbstractAction() { { putValue(NAME, I18nSupport.translate("menus.serie.resetSerie")); if (series.canUndo()) setEnabled(true); else setEnabled(false); } @Override public void actionPerformed(ActionEvent e) { series.reset(); } }); menu.add(new LimitDateRangeAction(series)); menu.add(new HourSettingAction(series)); menu.addSeparator(); { JMenuItem deleteItem = new JMenuItem("Supprimer la srie"); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes-vous sur de vouloir supprimer cette srie ?\n" + "Cette action est dfinitive.", "Confirmation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { series.delete(); } } }); menu.add(deleteItem); } menu.addSeparator(); { final JMenuItem up = new JMenuItem("Remonter dans la liste"), down = new JMenuItem("Descendre dans la liste"); ActionListener listener = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (e.getSource().equals(up)) { series.upSeriesInList(); } else { series.downSeriesInList(); } } }; up.addActionListener(listener); down.addActionListener(listener); if (series.isFirst()) { menu.add(down); } else if (series.isLast()) { menu.add(up); } else { menu.add(up); menu.add(down); } } menu.addSeparator(); { menu.add(new SeriesInfoAction(series)); } { JMenuItem colorItem = new JMenuItem("Couleur de la srie"); colorItem.addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { series.setColor(JColorChooser.showDialog(application, I18nSupport.translate("actions.selectColorForSeries"), series.getColor())); } }); menu.add(colorItem); } { JMenu plotRenderer = new JMenu("Affichage de la srie"); final ButtonGroup modes = new ButtonGroup(); java.util.List<DrawStyle> availableStyles; if (series.isMinMax()) { availableStyles = DrawStyles.getDrawableStylesForHighLow(); } else { availableStyles = DrawStyles.getDrawableStyles(); } for (final DrawStyle s : availableStyles) { final JRadioButtonMenuItem item = new JRadioButtonMenuItem(DrawStyles.getHumanCheckboxText(s)); item.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (item.isSelected()) series.setStyle(s); } }); modes.add(item); if (s.equals(series.getStyle())) { modes.setSelected(item.getModel(), true); } plotRenderer.add(item); } menu.add(plotRenderer); } menu.addSeparator(); menu.add(new AbstractAction() { { putValue(Action.NAME, "Fermer le fichier"); } @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes-vous sur de vouloir fermer toutes les sries du fichier ?", "Confirmation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { final File f = series.getOrigin(); for (final Series s : Series.getInstances().toArray(new Series[Series.getInstances().size()])) { if (s.getOrigin().equals(f)) s.delete(); } } } }); return menu; }
From source file:graph.jung2.MyLensDemo.java
public void init() { // create a simple graph for the demo TemporalNetworkOfWikipediaNodes net = null; try {/*from w w w .j av a 2 s . c o m*/ // net = new TemporalNetworkOfWikipediaNodes(null, null); net = new TemporalNetworkOfWikipediaNodes(r, level); graph = net.createSampleNetwork(); //getCC_EDIT_Graph(); } catch (Exception ex) { Logger.getLogger(MyLensDemo.class.getName()).log(Level.SEVERE, null, ex); } // if ( net == null ) { // graph = TemporalNetworkOfWikipediaNodes.createSampleNetwork(); // } // else { // graph = net.getGraph(); // } graphLayout = new FRLayout<String, Number>(graph); ((FRLayout) graphLayout).setMaxIterations(1000); Dimension preferredSize = new Dimension(600, 600); Map<String, Point2D> map = new HashMap<String, Point2D>(); Transformer<String, Point2D> vlf = TransformerUtils.mapTransformer(map); grid = this.generateVertexGrid(map, preferredSize, 25); gridLayout = new StaticLayout<String, Number>(grid, vlf, preferredSize); final VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>( graphLayout, preferredSize); vv = new VisualizationViewer<String, Number>(visualizationModel, preferredSize); PickedState<String> ps = vv.getPickedVertexState(); PickedState<Number> pes = vv.getPickedEdgeState(); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow)); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.cyan)); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); final Transformer<String, Shape> ovals = vv.getRenderContext().getVertexShapeTransformer(); final Transformer<String, Shape> squares = new ConstantTransformer(new Rectangle2D.Float(-10, -10, 20, 20)); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); Container content = getContentPane(); GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv); content.add(gzsp); /** * the regular graph mouse for the normal view */ final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); hyperbolicViewSupport = new ViewLensSupport<String, Number>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); hyperbolicLayoutSupport = new LayoutLensSupport<String, Number>(vv, new HyperbolicTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)), new ModalLensGraphMouse()); magnifyViewSupport = new ViewLensSupport<String, Number>(vv, new MagnifyShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f))); magnifyLayoutSupport = new LayoutLensSupport<String, Number>(vv, new MagnifyTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)), new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f))); hyperbolicLayoutSupport.getLensTransformer() .setLensShape(hyperbolicViewSupport.getLensTransformer().getLensShape()); magnifyViewSupport.getLensTransformer() .setLensShape(hyperbolicLayoutSupport.getLensTransformer().getLensShape()); magnifyLayoutSupport.getLensTransformer() .setLensShape(magnifyViewSupport.getLensTransformer().getLensShape()); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); ButtonGroup radio = new ButtonGroup(); JRadioButton normal = new JRadioButton("None"); normal.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (hyperbolicViewSupport != null) { hyperbolicViewSupport.deactivate(); } if (hyperbolicLayoutSupport != null) { hyperbolicLayoutSupport.deactivate(); } if (magnifyViewSupport != null) { magnifyViewSupport.deactivate(); } if (magnifyLayoutSupport != null) { magnifyLayoutSupport.deactivate(); } } } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton hyperModel = new JRadioButton("Hyperbolic Layout"); hyperModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton magnifyView = new JRadioButton("Magnified View"); magnifyView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { magnifyViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); final JRadioButton magnifyModel = new JRadioButton("Magnified Layout"); magnifyModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { magnifyLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JLabel modeLabel = new JLabel(" Mode Menu >>"); modeLabel.setUI(new VerticalLabelUI(false)); radio.add(normal); radio.add(hyperModel); radio.add(hyperView); radio.add(magnifyModel); radio.add(magnifyView); normal.setSelected(true); graphMouse.addItemListener(hyperbolicLayoutSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(magnifyLayoutSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(magnifyViewSupport.getGraphMouse().getModeListener()); ButtonGroup graphRadio = new ButtonGroup(); JRadioButton graphButton = new JRadioButton("Graph"); graphButton.setSelected(true); graphButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(graphLayout); vv.getRenderContext().setVertexShapeTransformer(ovals); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.repaint(); } } }); JRadioButton gridButton = new JRadioButton("Grid"); gridButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { visualizationModel.setGraphLayout(gridLayout); vv.getRenderContext().setVertexShapeTransformer(squares); vv.getRenderContext().setVertexLabelTransformer(new ConstantTransformer(null)); vv.repaint(); } } }); graphRadio.add(graphButton); graphRadio.add(gridButton); JPanel modePanel = new JPanel(new GridLayout(3, 1)); modePanel.setBorder(BorderFactory.createTitledBorder("Display")); modePanel.add(graphButton); modePanel.add(gridButton); JMenuBar menubar = new JMenuBar(); menubar.add(graphMouse.getModeMenu()); gzsp.setCorner(menubar); Box controls = Box.createHorizontalBox(); JPanel zoomControls = new JPanel(new GridLayout(2, 1)); zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel hyperControls = new JPanel(new GridLayout(3, 2)); hyperControls.setBorder(BorderFactory.createTitledBorder("Examiner Lens")); zoomControls.add(plus); zoomControls.add(minus); hyperControls.add(normal); hyperControls.add(new JLabel()); hyperControls.add(hyperModel); hyperControls.add(magnifyModel); hyperControls.add(hyperView); hyperControls.add(magnifyView); controls.add(zoomControls); controls.add(hyperControls); controls.add(modePanel); controls.add(modeLabel); content.add(controls, BorderLayout.SOUTH); }
From source file:org.geopublishing.atlasViewer.swing.AtlasChartJPanel.java
/** * Creates a {@link JToolBar} that has buttons to interact with the Chart * and it's SelectionModel.//from w ww . j av a 2 s .co m * * @return */ public JToolBar getToolBar() { if (toolBar == null) { toolBar = new JToolBar(); toolBar.setFloatable(false); ButtonGroup bg = new ButtonGroup(); /** * Add an Action to ZOOM/MOVE in the chart */ JToggleButton zoomToolButton = new SmallToggleButton(new AbstractAction("", ICON_ZOOM) { @Override public void actionPerformed(ActionEvent e) { getSelectableChartPanel().setWindowSelectionMode(WindowSelectionMode.ZOOM_IN_CHART); } }, GpCoreUtil.R("AtlasChartJPanel.zoom.tt")); toolBar.add(zoomToolButton); bg.add(zoomToolButton); toolBar.addSeparator(); /** * Add an Action not change the selection but just move through the * chart */ JToggleButton setSelectionButton = new SmallToggleButton(new AbstractAction("", ICON_SELECTION_SET) { @Override public void actionPerformed(ActionEvent e) { getSelectableChartPanel().setWindowSelectionMode(WindowSelectionMode.SELECT_SET); } }); setSelectionButton.setToolTipText(MapPaneToolBar.R("MapPaneButtons.Selection.SetSelection.TT")); toolBar.add(setSelectionButton); bg.add(setSelectionButton); /** * Add an Action to ADD the selection. */ JToggleButton addSelectionButton = new SmallToggleButton(new AbstractAction("", ICON_SELECTION_ADD) { @Override public void actionPerformed(ActionEvent e) { getSelectableChartPanel().setWindowSelectionMode(WindowSelectionMode.SELECT_ADD); } }); addSelectionButton.setToolTipText(MapPaneToolBar.R("MapPaneButtons.Selection.AddSelection.TT")); toolBar.add(addSelectionButton); bg.add(addSelectionButton); /** * Add an Action to REMOVE the selection. */ JToggleButton removeSelectionButton = new SmallToggleButton( new AbstractAction("", ICON_SELECTION_REMOVE) { @Override public void actionPerformed(ActionEvent e) { getSelectableChartPanel().setWindowSelectionMode(WindowSelectionMode.SELECT_REMOVE); } }); removeSelectionButton.setToolTipText(MapPaneToolBar.R("MapPaneButtons.Selection.RemoveSelection.TT")); toolBar.add(removeSelectionButton); bg.add(removeSelectionButton); toolBar.addSeparator(); /** * Add a normal Button to clear the selection. The Chart's selection * models are cleared. If a relation to a JMapPane exists, they will * be synchronized. */ final SmallButton clearSelectionButton = new SmallButton(new AbstractAction("", ICON_SELECTION_CLEAR) { @Override public void actionPerformed(ActionEvent e) { // getSelectionModel().clearSelection(); // get the selectionmodel(s) of the chart List<FeatureDatasetSelectionModel<?, ?, ?>> datasetSelectionModelFor = FeatureChartUtil .getFeatureDatasetSelectionModelFor(getSelectableChartPanel().getChart()); for (FeatureDatasetSelectionModel dsm : datasetSelectionModelFor) { dsm.clearSelection(); } } }, MapPaneToolBar.R("MapPaneButtons.Selection.ClearSelection.TT")); { // Add listeners to the selection model, so we knwo when to // disable/enable the button // get the selectionmodel(s) of the chart List<FeatureDatasetSelectionModel<?, ?, ?>> datasetSelectionModelFor = FeatureChartUtil .getFeatureDatasetSelectionModelFor(getSelectableChartPanel().getChart()); for (final FeatureDatasetSelectionModel selModel : datasetSelectionModelFor) { DatasetSelectionListener listener_ClearSelectionButtonEnbled = new DatasetSelectionListener() { @Override public void selectionChanged(DatasetSelectionChangeEvent e) { if (!e.getSource().getValueIsAdjusting()) { // Update the clearSelectionButton clearSelectionButton.setEnabled(selModel.getSelectedFeatures().size() > 0); } } }; insertedListeners.add(listener_ClearSelectionButtonEnbled); selModel.addSelectionListener(listener_ClearSelectionButtonEnbled); clearSelectionButton.setEnabled(selModel.getSelectedFeatures().size() > 0); } } toolBar.add(clearSelectionButton); toolBar.addSeparator(); /** * Add a normal Button which opens the Chart'S print dialog */ SmallButton printChartButton = new SmallButton(new AbstractAction("", Icons.ICON_PRINT_24) { @Override public void actionPerformed(ActionEvent e) { getSelectableChartPanel().createChartPrintJob(); } }); printChartButton.setToolTipText(GpCoreUtil.R("AtlasChartJPanel.PrintChartButton.TT")); toolBar.add(printChartButton); /** * Add a normal Button which opens the Chart's export/save dialog */ SmallButton saveChartAction = new SmallButton(new AbstractAction("", Icons.ICON_SAVEAS_24) { @Override public void actionPerformed(ActionEvent e) { try { getSelectableChartPanel().doSaveAs(); } catch (IOException e1) { LOGGER.info("Saving a chart to file failed", e1); ExceptionDialog.show(AtlasChartJPanel.this, e1); } } }); saveChartAction.setToolTipText(GpCoreUtil.R("AtlasChartJPanel.SaveChartButton.TT")); toolBar.add(saveChartAction); // // A JButton to open the attribute table // { final JButton openTable = new JButton(); openTable.setAction(new AbstractAction(GpCoreUtil.R("LayerToolMenu.table"), Icons.ICON_TABLE) { @Override public void actionPerformed(final ActionEvent e) { AVDialogManager.dm_AttributeTable.getInstanceFor(styledLayer, AtlasChartJPanel.this, styledLayer, mapLegend); } }); toolBar.addSeparator(); toolBar.add(openTable); } /* * Select/set data points button is activated by default */ getSelectableChartPanel().setWindowSelectionMode(WindowSelectionMode.SELECT_SET); setSelectionButton.setSelected(true); } return toolBar; }