List of usage examples for javax.swing JComboBox setAlignmentX
@BeanProperty(description = "The preferred horizontal alignment of the component.") public void setAlignmentX(float alignmentX)
From source file:SimpleDateFormatDemo.java
public SimpleDateFormatDemo() { today = new Date(); availableLocales = new LocaleGroup(); String[] patternExamples = { "dd MMMMM yyyy", "dd.MM.yy", "MM/dd/yy", "yyyy.MM.dd G 'at' hh:mm:ss z", "EEE, MMM d, ''yy", "h:mm a", "H:mm:ss:SSS", "K:mm a,z", "yyyy.MMMMM.dd GGG hh:mm aaa" }; currentPattern = patternExamples[0]; // Set up the UI for selecting a pattern. JLabel patternLabel1 = new JLabel("Enter the pattern string or"); JLabel patternLabel2 = new JLabel("select one from the list:"); patternLabel1.setAlignmentX(Component.LEFT_ALIGNMENT); patternLabel2.setAlignmentX(Component.LEFT_ALIGNMENT); JComboBox patternList = new JComboBox(patternExamples); patternList.setSelectedIndex(0);//from w ww . j av a 2s . c om patternList.setEditable(true); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); PatternListener patternListener = new PatternListener(); patternList.addActionListener(patternListener); // Set up the UI for selecting a locale. JLabel localeLabel = new JLabel("Select a Locale from the list:"); localeLabel.setAlignmentX(Component.LEFT_ALIGNMENT); JComboBox localeList = new JComboBox(availableLocales.getStrings()); localeList.setSelectedIndex(0); localeList.setAlignmentX(Component.LEFT_ALIGNMENT); LocaleListener localeListener = new LocaleListener(); localeList.addActionListener(localeListener); // Create the UI for displaying result JLabel resultLabel = new JLabel("Current Date and Time", JLabel.LEFT); resultLabel.setAlignmentX(Component.LEFT_ALIGNMENT); result = new JLabel(" "); result.setForeground(Color.black); result.setAlignmentX(Component.LEFT_ALIGNMENT); result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Lay out everything JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.Y_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternPanel.add(patternList); JPanel localePanel = new JPanel(); localePanel.setLayout(new BoxLayout(localePanel, BoxLayout.Y_AXIS)); localePanel.add(localeLabel); localePanel.add(localeList); JPanel resultPanel = new JPanel(); resultPanel.setLayout(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); patternPanel.setAlignmentX(Component.CENTER_ALIGNMENT); localePanel.setAlignmentX(Component.CENTER_ALIGNMENT); resultPanel.setAlignmentX(Component.CENTER_ALIGNMENT); add(patternPanel); add(Box.createVerticalStrut(10)); add(localePanel); add(Box.createVerticalStrut(10)); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); reformat(); }
From source file:DecimalFormatDemo.java
public DecimalFormatDemo() { availableLocales = new LocaleGroup(); inputFormatter = NumberFormat.getNumberInstance(); String[] patternExamples = { "##.##", "###,###.##", "##,##,##.##", "#", "000,000.0000", "##.0000", "'hello'###.##" }; currentPattern = patternExamples[0]; // Set up the UI for entering a number. JLabel numberLabel = new JLabel("Enter the number to format:"); numberLabel.setAlignmentX(Component.LEFT_ALIGNMENT); JTextField numberField = new JTextField(); numberField.setEditable(true);// w w w . ja v a 2 s . c o m numberField.setAlignmentX(Component.LEFT_ALIGNMENT); NumberListener numberListener = new NumberListener(); numberField.addActionListener(numberListener); // Set up the UI for selecting a pattern. JLabel patternLabel1 = new JLabel("Enter the pattern string or"); JLabel patternLabel2 = new JLabel("select one from the list:"); patternLabel1.setAlignmentX(Component.LEFT_ALIGNMENT); patternLabel2.setAlignmentX(Component.LEFT_ALIGNMENT); JComboBox patternList = new JComboBox(patternExamples); patternList.setSelectedIndex(0); patternList.setEditable(true); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); PatternListener patternListener = new PatternListener(); patternList.addActionListener(patternListener); // Set up the UI for selecting a locale. JLabel localeLabel = new JLabel("Select a Locale from the list:"); localeLabel.setAlignmentX(Component.LEFT_ALIGNMENT); JComboBox localeList = new JComboBox(availableLocales.getStrings()); localeList.setSelectedIndex(0); localeList.setAlignmentX(Component.LEFT_ALIGNMENT); LocaleListener localeListener = new LocaleListener(); localeList.addActionListener(localeListener); // Create the UI for displaying result. JLabel resultLabel = new JLabel("Result", JLabel.LEFT); resultLabel.setAlignmentX(Component.LEFT_ALIGNMENT); result = new JLabel(" "); result.setForeground(Color.black); result.setAlignmentX(Component.LEFT_ALIGNMENT); result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Lay out everything JPanel numberPanel = new JPanel(); numberPanel.setLayout(new GridLayout(0, 1)); numberPanel.add(numberLabel); numberPanel.add(numberField); JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.Y_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternPanel.add(patternList); JPanel localePanel = new JPanel(); localePanel.setLayout(new BoxLayout(localePanel, BoxLayout.Y_AXIS)); localePanel.add(localeLabel); localePanel.add(localeList); JPanel resultPanel = new JPanel(); resultPanel.setLayout(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); patternPanel.setAlignmentX(Component.CENTER_ALIGNMENT); numberPanel.setAlignmentX(Component.CENTER_ALIGNMENT); localePanel.setAlignmentX(Component.CENTER_ALIGNMENT); resultPanel.setAlignmentX(Component.CENTER_ALIGNMENT); add(numberPanel); add(Box.createVerticalStrut(10)); add(patternPanel); add(Box.createVerticalStrut(10)); add(localePanel); add(Box.createVerticalStrut(10)); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); reformat(); numberField.setText(result.getText()); }
From source file:net.pandoragames.far.ui.swing.dialog.SettingsDialog.java
private void init() { this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS)); this.setResizable(false); JPanel basePanel = new JPanel(); basePanel.setLayout(new BoxLayout(basePanel, BoxLayout.Y_AXIS)); basePanel.setBorder(// w w w .j a va 2 s. co m BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING)); registerCloseWindowKeyListener(basePanel); // sink for error messages MessageLabel errorField = new MessageLabel(); errorField.setMinimumSize(new Dimension(100, swingConfig.getStandardComponentHight())); errorField.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING)); TwoComponentsPanel lineError = new TwoComponentsPanel(errorField, Box.createRigidArea(new Dimension(1, swingConfig.getStandardComponentHight()))); lineError.setAlignmentX(Component.LEFT_ALIGNMENT); basePanel.add(lineError); // character set JLabel labelCharset = new JLabel(swingConfig.getLocalizer().localize("label.default-characterset")); labelCharset.setAlignmentX(Component.LEFT_ALIGNMENT); basePanel.add(labelCharset); JComboBox listCharset = new JComboBox(swingConfig.getCharsetList().toArray()); listCharset.setAlignmentX(Component.LEFT_ALIGNMENT); listCharset.setSelectedItem(swingConfig.getDefaultCharset()); listCharset.setEditable(true); listCharset.setMaximumSize( new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, swingConfig.getStandardComponentHight())); listCharset.addActionListener(new CharacterSetListener(errorField)); listCharset.setEditor(new CharacterSetEditor(errorField)); basePanel.add(listCharset); basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); // select the group selector JPanel selectorPanel = new JPanel(); selectorPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); selectorPanel.setAlignmentX(Component.LEFT_ALIGNMENT); // linePattern.setAlignmentX( Component.LEFT_ALIGNMENT ); JLabel labelSelector = new JLabel(swingConfig.getLocalizer().localize("label.group-ref-indicator")); selectorPanel.add(labelSelector); JComboBox selectorBox = new JComboBox(FARConfig.GROUPREFINDICATORLIST); selectorBox.setSelectedItem(Character.toString(groupReference)); selectorBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { JComboBox cbox = (JComboBox) event.getSource(); String indicator = (String) cbox.getSelectedItem(); groupReference = indicator.charAt(0); } }); selectorPanel.add(selectorBox); basePanel.add(selectorPanel); basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); // checkbox DO BACKUP JCheckBox doBackupFlag = new JCheckBox(swingConfig.getLocalizer().localize("label.create-backup")); doBackupFlag.setAlignmentX(Component.LEFT_ALIGNMENT); doBackupFlag.setHorizontalTextPosition(SwingConstants.LEADING); doBackupFlag.setSelected(replaceForm.isDoBackup()); doBackupFlag.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { doBackup = ItemEvent.SELECTED == event.getStateChange(); backupFlagEvent = event; } }); basePanel.add(doBackupFlag); JTextField backupDirPathTextField = new JTextField(); backupDirPathTextField.setPreferredSize( new Dimension(SwingConfig.COMPONENT_WIDTH, swingConfig.getStandardComponentHight())); backupDirPathTextField.setMaximumSize( new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, swingConfig.getStandardComponentHight())); backupDirPathTextField.setText(backupDirectory.getPath()); backupDirPathTextField.setToolTipText(backupDirectory.getPath()); backupDirPathTextField.setEditable(false); JButton openBaseDirFileChooserButton = new JButton(swingConfig.getLocalizer().localize("button.browse")); BrowseButtonListener backupDirButtonListener = new BrowseButtonListener(backupDirPathTextField, new BackUpDirectoryRepository(swingConfig, findForm, replaceForm, errorField), swingConfig.getLocalizer().localize("label.choose-backup-directory")); openBaseDirFileChooserButton.addActionListener(backupDirButtonListener); TwoComponentsPanel lineBaseDir = new TwoComponentsPanel(backupDirPathTextField, openBaseDirFileChooserButton); lineBaseDir.setAlignmentX(Component.LEFT_ALIGNMENT); basePanel.add(lineBaseDir); basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); JPanel fileInfoPanel = new JPanel(); fileInfoPanel .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), swingConfig.getLocalizer().localize("label.default-file-info"))); fileInfoPanel.setAlignmentX(Component.LEFT_ALIGNMENT); fileInfoPanel.setLayout(new BoxLayout(fileInfoPanel, BoxLayout.Y_AXIS)); JLabel fileInfoLabel = new JLabel(swingConfig.getLocalizer().localize("message.displayed-in-info-column")); fileInfoLabel.setAlignmentX(Component.LEFT_ALIGNMENT); fileInfoPanel.add(fileInfoLabel); fileInfoPanel.add(Box.createHorizontalGlue()); JRadioButton nothingRadio = new JRadioButton(swingConfig.getLocalizer().localize("label.nothing")); nothingRadio.setAlignmentX(Component.LEFT_ALIGNMENT); nothingRadio.setActionCommand(SwingConfig.DefaultFileInfo.NOTHING.name()); nothingRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.NOTHING); fileInfoOptions.add(nothingRadio); fileInfoPanel.add(nothingRadio); JRadioButton readOnlyRadio = new JRadioButton( swingConfig.getLocalizer().localize("label.read-only-warning")); readOnlyRadio.setAlignmentX(Component.LEFT_ALIGNMENT); readOnlyRadio.setActionCommand(SwingConfig.DefaultFileInfo.READONLY.name()); readOnlyRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.READONLY); fileInfoOptions.add(readOnlyRadio); fileInfoPanel.add(readOnlyRadio); JRadioButton sizeRadio = new JRadioButton(swingConfig.getLocalizer().localize("label.filesize")); sizeRadio.setAlignmentX(Component.LEFT_ALIGNMENT); sizeRadio.setActionCommand(SwingConfig.DefaultFileInfo.SIZE.name()); sizeRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.SIZE); fileInfoOptions.add(sizeRadio); fileInfoPanel.add(sizeRadio); JCheckBox showPlainBytesFlag = new JCheckBox( " " + swingConfig.getLocalizer().localize("label.show-plain-bytes")); showPlainBytesFlag.setAlignmentX(Component.LEFT_ALIGNMENT); showPlainBytesFlag.setHorizontalTextPosition(SwingConstants.LEADING); showPlainBytesFlag.setSelected(swingConfig.isShowPlainBytes()); showPlainBytesFlag.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { showBytes = ItemEvent.SELECTED == event.getStateChange(); } }); fileInfoPanel.add(showPlainBytesFlag); JRadioButton lastModifiedRadio = new JRadioButton( swingConfig.getLocalizer().localize("label.last-modified")); lastModifiedRadio.setAlignmentX(Component.LEFT_ALIGNMENT); lastModifiedRadio.setActionCommand(SwingConfig.DefaultFileInfo.LAST_MODIFIED.name()); lastModifiedRadio .setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.LAST_MODIFIED); fileInfoOptions.add(lastModifiedRadio); fileInfoPanel.add(lastModifiedRadio); basePanel.add(fileInfoPanel); // buttons JPanel buttonPannel = new JPanel(); buttonPannel.setAlignmentX(Component.LEFT_ALIGNMENT); buttonPannel.setLayout(new FlowLayout(FlowLayout.TRAILING)); // cancel JButton cancelButton = new JButton(swingConfig.getLocalizer().localize("button.cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { SettingsDialog.this.dispose(); } }); buttonPannel.add(cancelButton); // save JButton saveButton = new JButton(swingConfig.getLocalizer().localize("button.save")); saveButton.addActionListener(new SaveButtonListener()); buttonPannel.add(saveButton); this.getRootPane().setDefaultButton(saveButton); this.add(basePanel); this.add(buttonPannel); placeOnScreen(swingConfig.getScreenCenter()); }
From source file:components.ComboBoxDemo2.java
public ComboBoxDemo2() { setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); String[] patternExamples = { "dd MMMMM yyyy", "dd.MM.yy", "MM/dd/yy", "yyyy.MM.dd G 'at' hh:mm:ss z", "EEE, MMM d, ''yy", "h:mm a", "H:mm:ss:SSS", "K:mm a,z", "yyyy.MMMMM.dd GGG hh:mm aaa" }; currentPattern = patternExamples[0]; //Set up the UI for selecting a pattern. JLabel patternLabel1 = new JLabel("Enter the pattern string or"); JLabel patternLabel2 = new JLabel("select one from the list:"); JComboBox patternList = new JComboBox(patternExamples); patternList.setEditable(true);/* www . j a v a 2 s . c om*/ patternList.addActionListener(this); //Create the UI for displaying result. JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); //== LEFT result = new JLabel(" "); result.setForeground(Color.black); result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Lay out everything. JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); patternPanel.add(patternList); JPanel resultPanel = new JPanel(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT); resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT); add(patternPanel); add(Box.createRigidArea(new Dimension(0, 10))); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); reformat(); }
From source file:ComboBoxDemo2.java
public ComboBoxDemo2() { setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); String[] patternExamples = { "dd MMMMM yyyy", "dd.MM.yy", "MM/dd/yy", "yyyy.MM.dd G 'at' hh:mm:ss z", "EEE, MMM d, ''yy", "h:mm a", "H:mm:ss:SSS", "K:mm a,z", "yyyy.MMMMM.dd GGG hh:mm aaa" }; currentPattern = patternExamples[0]; //Set up the UI for selecting a pattern. JLabel patternLabel1 = new JLabel("Enter the pattern string or"); JLabel patternLabel2 = new JLabel("select one from the list:"); JComboBox patternList = new JComboBox(patternExamples); patternList.setEditable(true);//from w w w .j av a 2 s . c o m patternList.addActionListener(this); //Create the UI for displaying result. JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); //== // LEFT result = new JLabel(" "); result.setForeground(Color.black); result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Lay out everything. JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); patternPanel.add(patternList); JPanel resultPanel = new JPanel(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT); resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT); add(patternPanel); add(Box.createRigidArea(new Dimension(0, 10))); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); reformat(); }
From source file:ComboBoxDemo2.java
public ComboBoxDemo2() { setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); String[] patternExamples = { "dd MMMMM yyyy", "dd.MM.yy", "MM/dd/yy", "yyyy.MM.dd G 'at' hh:mm:ss z", "EEE, MMM d, ''yy", "h:mm a", "H:mm:ss:SSS", "K:mm a,z", "yyyy.MMMMM.dd GGG hh:mm aaa" }; currentPattern = patternExamples[0]; // Set up the UI for selecting a pattern. JLabel patternLabel1 = new JLabel("Enter the pattern string or"); JLabel patternLabel2 = new JLabel("select one from the list:"); JComboBox patternList = new JComboBox(patternExamples); patternList.setEditable(true);/*from www . j av a 2 s .c o m*/ patternList.addActionListener(this); // Create the UI for displaying result. JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); // == // LEFT result = new JLabel(" "); result.setForeground(Color.black); result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Lay out everything. JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); patternPanel.add(patternList); JPanel resultPanel = new JPanel(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT); resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT); add(patternPanel); add(Box.createRigidArea(new Dimension(0, 10))); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); reformat(); }
From source file:com.google.code.facebook.graph.sna.applet.PluggableRendererDemo.java
/** * @param jp panel to which controls will be added *///from w ww . ja va 2 s . c o m @SuppressWarnings("serial") protected void addBottomControls(final JPanel jp) { final JPanel control_panel = new JPanel(); jp.add(control_panel, BorderLayout.EAST); control_panel.setLayout(new BorderLayout()); final Box vertex_panel = Box.createVerticalBox(); vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices")); final Box edge_panel = Box.createVerticalBox(); edge_panel.setBorder(BorderFactory.createTitledBorder("Edges")); final Box both_panel = Box.createVerticalBox(); control_panel.add(vertex_panel, BorderLayout.NORTH); control_panel.add(edge_panel, BorderLayout.SOUTH); control_panel.add(both_panel, BorderLayout.CENTER); // set up vertex controls v_color = new JCheckBox("seed highlight"); v_color.addActionListener(this); v_stroke = new JCheckBox("stroke highlight on selection"); v_stroke.addActionListener(this); v_labels = new JCheckBox("show voltage values"); v_labels.addActionListener(this); v_shape = new JCheckBox("shape by degree"); v_shape.addActionListener(this); v_size = new JCheckBox("size by voltage"); v_size.addActionListener(this); v_size.setSelected(true); v_aspect = new JCheckBox("stretch by degree ratio"); v_aspect.addActionListener(this); v_small = new JCheckBox("filter when degree < " + VertexDisplayPredicate.MIN_DEGREE); v_small.addActionListener(this); vertex_panel.add(v_color); vertex_panel.add(v_stroke); vertex_panel.add(v_labels); vertex_panel.add(v_shape); vertex_panel.add(v_size); vertex_panel.add(v_aspect); vertex_panel.add(v_small); // set up edge controls JPanel gradient_panel = new JPanel(new GridLayout(1, 0)); gradient_panel.setBorder(BorderFactory.createTitledBorder("Edge paint")); no_gradient = new JRadioButton("Solid color"); no_gradient.addActionListener(this); no_gradient.setSelected(true); // gradient_absolute = new JRadioButton("Absolute gradient"); // gradient_absolute.addActionListener(this); gradient_relative = new JRadioButton("Gradient"); gradient_relative.addActionListener(this); ButtonGroup bg_grad = new ButtonGroup(); bg_grad.add(no_gradient); bg_grad.add(gradient_relative); //bg_grad.add(gradient_absolute); gradient_panel.add(no_gradient); //gradientGrid.add(gradient_absolute); gradient_panel.add(gradient_relative); JPanel shape_panel = new JPanel(new GridLayout(3, 2)); shape_panel.setBorder(BorderFactory.createTitledBorder("Edge shape")); e_line = new JRadioButton("line"); e_line.addActionListener(this); e_line.setSelected(true); // e_bent = new JRadioButton("bent line"); // e_bent.addActionListener(this); e_wedge = new JRadioButton("wedge"); e_wedge.addActionListener(this); e_quad = new JRadioButton("quad curve"); e_quad.addActionListener(this); e_cubic = new JRadioButton("cubic curve"); e_cubic.addActionListener(this); e_ortho = new JRadioButton("orthogonal"); e_ortho.addActionListener(this); ButtonGroup bg_shape = new ButtonGroup(); bg_shape.add(e_line); // bg.add(e_bent); bg_shape.add(e_wedge); bg_shape.add(e_quad); bg_shape.add(e_ortho); bg_shape.add(e_cubic); shape_panel.add(e_line); // shape_panel.add(e_bent); shape_panel.add(e_wedge); shape_panel.add(e_quad); shape_panel.add(e_cubic); shape_panel.add(e_ortho); fill_edges = new JCheckBox("fill edge shapes"); fill_edges.setSelected(false); fill_edges.addActionListener(this); shape_panel.add(fill_edges); shape_panel.setOpaque(true); e_color = new JCheckBox("highlight edge weights"); e_color.addActionListener(this); e_labels = new JCheckBox("show edge weight values"); e_labels.addActionListener(this); e_uarrow_pred = new JCheckBox("undirected"); e_uarrow_pred.addActionListener(this); e_darrow_pred = new JCheckBox("directed"); e_darrow_pred.addActionListener(this); e_darrow_pred.setSelected(true); e_arrow_centered = new JCheckBox("centered"); e_arrow_centered.addActionListener(this); JPanel arrow_panel = new JPanel(new GridLayout(1, 0)); arrow_panel.setBorder(BorderFactory.createTitledBorder("Show arrows")); arrow_panel.add(e_uarrow_pred); arrow_panel.add(e_darrow_pred); arrow_panel.add(e_arrow_centered); e_show_d = new JCheckBox("directed"); e_show_d.addActionListener(this); e_show_d.setSelected(true); e_show_u = new JCheckBox("undirected"); e_show_u.addActionListener(this); e_show_u.setSelected(true); JPanel show_edge_panel = new JPanel(new GridLayout(1, 0)); show_edge_panel.setBorder(BorderFactory.createTitledBorder("Show edges")); show_edge_panel.add(e_show_u); show_edge_panel.add(e_show_d); shape_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(shape_panel); gradient_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(gradient_panel); show_edge_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(show_edge_panel); arrow_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(arrow_panel); e_color.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(e_color); e_labels.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(e_labels); // set up zoom controls zoom_at_mouse = new JCheckBox("<html><center>zoom at mouse<p>(wheel only)</center></html>"); zoom_at_mouse.addActionListener(this); zoom_at_mouse.setSelected(true); 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()); } }); JPanel zoomPanel = new JPanel(); zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom")); plus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(plus); minus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(minus); zoom_at_mouse.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(zoom_at_mouse); JPanel fontPanel = new JPanel(); // add font and zoom controls to center panel font = new JCheckBox("bold text"); font.addActionListener(this); font.setAlignmentX(Component.CENTER_ALIGNMENT); fontPanel.add(font); both_panel.add(zoomPanel); both_panel.add(fontPanel); JComboBox modeBox = gm.getModeComboBox(); modeBox.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel modePanel = new JPanel(new BorderLayout()) { public Dimension getMaximumSize() { return getPreferredSize(); } }; modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); JPanel comboGrid = new JPanel(new GridLayout(0, 1)); comboGrid.add(modePanel); fontPanel.add(comboGrid); JComboBox cb = new JComboBox(); cb.addItem(Renderer.VertexLabel.Position.N); cb.addItem(Renderer.VertexLabel.Position.NE); cb.addItem(Renderer.VertexLabel.Position.E); cb.addItem(Renderer.VertexLabel.Position.SE); cb.addItem(Renderer.VertexLabel.Position.S); cb.addItem(Renderer.VertexLabel.Position.SW); cb.addItem(Renderer.VertexLabel.Position.W); cb.addItem(Renderer.VertexLabel.Position.NW); cb.addItem(Renderer.VertexLabel.Position.N); cb.addItem(Renderer.VertexLabel.Position.CNTR); cb.addItem(Renderer.VertexLabel.Position.AUTO); cb.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { Renderer.VertexLabel.Position position = (Renderer.VertexLabel.Position) e.getItem(); vv.getRenderer().getVertexLabelRenderer().setPosition(position); vv.repaint(); } }); cb.setSelectedItem(Renderer.VertexLabel.Position.SE); JPanel positionPanel = new JPanel(); positionPanel.setBorder(BorderFactory.createTitledBorder("Label Position")); positionPanel.add(cb); comboGrid.add(positionPanel); }
From source file:edu.uci.ics.jung.samples.PluggableRendererDemo.java
/** * @param jp panel to which controls will be added *///from w w w .j a va 2 s. com @SuppressWarnings({ "rawtypes", "unchecked" }) protected void addBottomControls(final JPanel jp) { final JPanel control_panel = new JPanel(); jp.add(control_panel, BorderLayout.EAST); control_panel.setLayout(new BorderLayout()); final Box vertex_panel = Box.createVerticalBox(); vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices")); final Box edge_panel = Box.createVerticalBox(); edge_panel.setBorder(BorderFactory.createTitledBorder("Edges")); final Box both_panel = Box.createVerticalBox(); control_panel.add(vertex_panel, BorderLayout.NORTH); control_panel.add(edge_panel, BorderLayout.SOUTH); control_panel.add(both_panel, BorderLayout.CENTER); // set up vertex controls v_color = new JCheckBox("seed highlight"); v_color.addActionListener(this); v_stroke = new JCheckBox("stroke highlight on selection"); v_stroke.addActionListener(this); v_labels = new JCheckBox("show voltage values"); v_labels.addActionListener(this); v_shape = new JCheckBox("shape by degree"); v_shape.addActionListener(this); v_size = new JCheckBox("size by voltage"); v_size.addActionListener(this); v_size.setSelected(true); v_aspect = new JCheckBox("stretch by degree ratio"); v_aspect.addActionListener(this); v_small = new JCheckBox("filter when degree < " + VertexDisplayPredicate.MIN_DEGREE); v_small.addActionListener(this); vertex_panel.add(v_color); vertex_panel.add(v_stroke); vertex_panel.add(v_labels); vertex_panel.add(v_shape); vertex_panel.add(v_size); vertex_panel.add(v_aspect); vertex_panel.add(v_small); // set up edge controls JPanel gradient_panel = new JPanel(new GridLayout(1, 0)); gradient_panel.setBorder(BorderFactory.createTitledBorder("Edge paint")); no_gradient = new JRadioButton("Solid color"); no_gradient.addActionListener(this); no_gradient.setSelected(true); // gradient_absolute = new JRadioButton("Absolute gradient"); // gradient_absolute.addActionListener(this); gradient_relative = new JRadioButton("Gradient"); gradient_relative.addActionListener(this); ButtonGroup bg_grad = new ButtonGroup(); bg_grad.add(no_gradient); bg_grad.add(gradient_relative); //bg_grad.add(gradient_absolute); gradient_panel.add(no_gradient); //gradientGrid.add(gradient_absolute); gradient_panel.add(gradient_relative); JPanel shape_panel = new JPanel(new GridLayout(3, 2)); shape_panel.setBorder(BorderFactory.createTitledBorder("Edge shape")); e_line = new JRadioButton("line"); e_line.addActionListener(this); e_line.setSelected(true); // e_bent = new JRadioButton("bent line"); // e_bent.addActionListener(this); e_wedge = new JRadioButton("wedge"); e_wedge.addActionListener(this); e_quad = new JRadioButton("quad curve"); e_quad.addActionListener(this); e_cubic = new JRadioButton("cubic curve"); e_cubic.addActionListener(this); e_ortho = new JRadioButton("orthogonal"); e_ortho.addActionListener(this); ButtonGroup bg_shape = new ButtonGroup(); bg_shape.add(e_line); // bg.add(e_bent); bg_shape.add(e_wedge); bg_shape.add(e_quad); bg_shape.add(e_ortho); bg_shape.add(e_cubic); shape_panel.add(e_line); // shape_panel.add(e_bent); shape_panel.add(e_wedge); shape_panel.add(e_quad); shape_panel.add(e_cubic); shape_panel.add(e_ortho); fill_edges = new JCheckBox("fill edge shapes"); fill_edges.setSelected(false); fill_edges.addActionListener(this); shape_panel.add(fill_edges); shape_panel.setOpaque(true); e_color = new JCheckBox("highlight edge weights"); e_color.addActionListener(this); e_labels = new JCheckBox("show edge weight values"); e_labels.addActionListener(this); e_uarrow_pred = new JCheckBox("undirected"); e_uarrow_pred.addActionListener(this); e_darrow_pred = new JCheckBox("directed"); e_darrow_pred.addActionListener(this); e_darrow_pred.setSelected(true); e_arrow_centered = new JCheckBox("centered"); e_arrow_centered.addActionListener(this); JPanel arrow_panel = new JPanel(new GridLayout(1, 0)); arrow_panel.setBorder(BorderFactory.createTitledBorder("Show arrows")); arrow_panel.add(e_uarrow_pred); arrow_panel.add(e_darrow_pred); arrow_panel.add(e_arrow_centered); e_show_d = new JCheckBox("directed"); e_show_d.addActionListener(this); e_show_d.setSelected(true); e_show_u = new JCheckBox("undirected"); e_show_u.addActionListener(this); e_show_u.setSelected(true); JPanel show_edge_panel = new JPanel(new GridLayout(1, 0)); show_edge_panel.setBorder(BorderFactory.createTitledBorder("Show edges")); show_edge_panel.add(e_show_u); show_edge_panel.add(e_show_d); shape_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(shape_panel); gradient_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(gradient_panel); show_edge_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(show_edge_panel); arrow_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(arrow_panel); e_color.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(e_color); e_labels.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(e_labels); // set up zoom controls zoom_at_mouse = new JCheckBox("<html><center>zoom at mouse<p>(wheel only)</center></html>"); zoom_at_mouse.addActionListener(this); zoom_at_mouse.setSelected(true); 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()); } }); JPanel zoomPanel = new JPanel(); zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom")); plus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(plus); minus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(minus); zoom_at_mouse.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(zoom_at_mouse); JPanel fontPanel = new JPanel(); // add font and zoom controls to center panel font = new JCheckBox("bold text"); font.addActionListener(this); font.setAlignmentX(Component.CENTER_ALIGNMENT); fontPanel.add(font); both_panel.add(zoomPanel); both_panel.add(fontPanel); JComboBox modeBox = gm.getModeComboBox(); modeBox.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel modePanel = new JPanel(new BorderLayout()) { public Dimension getMaximumSize() { return getPreferredSize(); } }; modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); JPanel comboGrid = new JPanel(new GridLayout(0, 1)); comboGrid.add(modePanel); fontPanel.add(comboGrid); JComboBox cb = new JComboBox(); cb.addItem(Renderer.VertexLabel.Position.N); cb.addItem(Renderer.VertexLabel.Position.NE); cb.addItem(Renderer.VertexLabel.Position.E); cb.addItem(Renderer.VertexLabel.Position.SE); cb.addItem(Renderer.VertexLabel.Position.S); cb.addItem(Renderer.VertexLabel.Position.SW); cb.addItem(Renderer.VertexLabel.Position.W); cb.addItem(Renderer.VertexLabel.Position.NW); cb.addItem(Renderer.VertexLabel.Position.N); cb.addItem(Renderer.VertexLabel.Position.CNTR); cb.addItem(Renderer.VertexLabel.Position.AUTO); cb.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { Renderer.VertexLabel.Position position = (Renderer.VertexLabel.Position) e.getItem(); vv.getRenderer().getVertexLabelRenderer().setPosition(position); vv.repaint(); } }); cb.setSelectedItem(Renderer.VertexLabel.Position.SE); JPanel positionPanel = new JPanel(); positionPanel.setBorder(BorderFactory.createTitledBorder("Label Position")); positionPanel.add(cb); comboGrid.add(positionPanel); }
From source file:metdemo.Finance.SHNetworks.java
/** * //from ww w. ja va 2 s .c o m * @param jp * @param usersarray * @param viphm_hashmap */ protected void addBottomControls(final JPanel jp, String[] usersarray) { // create the control panel which will hold settings and picked list final JPanel control_panel = new JPanel(); jp.add(control_panel, BorderLayout.SOUTH); control_panel.setLayout(new BorderLayout()); // create the settings panel which will hold all of the settings Box settings_box = Box.createVerticalBox(); settings_box.setBorder(BorderFactory.createTitledBorder("Display Settings")); control_panel.add(settings_box, BorderLayout.NORTH); JPanel settings_panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10)); // add the zoom controls to the settings panel JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // call listener in GraphMouse instead of manipulating vv scale // directly // this is so the crossover from zoom to scale works with the // buttons // as well as with the mouse wheel Dimension d = m_visualizationview.getSize(); m_graphmouse.mouseWheelMoved( new MouseWheelEvent(m_visualizationview, MouseEvent.MOUSE_WHEEL, System.currentTimeMillis(), 0, d.width / 2, d.height / 2, 1, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, 1)); } }); JButton minus = new JButton(" - "); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // call listener in GraphMouse instead of manipulating vv scale // directly // this is so the crossover from zoom to scale works with the // buttons // as well as with the mouse wheel Dimension d = m_visualizationview.getSize(); m_graphmouse.mouseWheelMoved( new MouseWheelEvent(m_visualizationview, MouseEvent.MOUSE_WHEEL, System.currentTimeMillis(), 0, d.width / 2, d.height / 2, 1, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, -1)); } }); Box zoomPanel = Box.createHorizontalBox(); zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom")); minus.setAlignmentX(Component.LEFT_ALIGNMENT); plus.setAlignmentX(Component.RIGHT_ALIGNMENT); zoomPanel.add(minus); zoomPanel.add(plus); settings_panel.add(zoomPanel); // add the mouse mode combo box to the settings panel JComboBox modeBox = m_graphmouse.getModeComboBox(); modeBox.setAlignmentX(Component.CENTER_ALIGNMENT); m_graphmouse.setMode(ModalGraphMouse.Mode.PICKING); JPanel modePanel = new JPanel(new BorderLayout()) { public Dimension getMaximumSize() { return getPreferredSize(); } }; modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); settings_panel.add(modePanel); // add the display type combo box to the settings panel String[] layoutTypeStrings = { "OrgChart Layout", "FR Layout" }; layoutTypeBox = new JComboBox(layoutTypeStrings); layoutTypeBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (layoutTypeBox.getSelectedIndex() == 0) moveVertices();//viphm_hashmap); else m_visualizationview.restart(); } }); layoutTypeBox.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel displayTypePanel = new JPanel(new BorderLayout()) { public Dimension getMaximumSize() { return getPreferredSize(); } }; displayTypePanel.setBorder(BorderFactory.createTitledBorder("Display Type")); displayTypePanel.add(layoutTypeBox); settings_panel.add(displayTypePanel); // add user search to the panel - SHLOMO JPanel searchPanel = new JPanel(new BorderLayout()) { public Dimension getMaximumSize() { return getPreferredSize(); } }; // take the users and organize it sorted /* * ArrayList<String> ta = new ArrayList<String>(userlist); String [] * usersarray = (String[]) ta.toArray(new String[ta.size()]); */Arrays.sort(usersarray); usercombolist = new JComboBox(usersarray); usercombolist.insertItemAt("Anyone", 0); usercombolist.setSelectedIndex(0);// show only anyone choice // lets add all current users to the list searchPanel.setBorder(BorderFactory.createTitledBorder("Search User")); searchPanel.add(usercombolist); //add a check box to show not show labels on all vertices m_showLabels = new JCheckBox("Show name?", false); settings_panel.add(m_showLabels); settings_panel.add(searchPanel); usercombolist.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // will need to react to the choice list if (usercombolist.getSelectedIndex() == 0) { // might have to reset something in case they move back PickedState picked_state = m_visualizationview.getPickedState(); picked_state.clearPickedVertices(); return; } String username = (String) usercombolist.getSelectedItem(); for (Iterator walker = m_layout.getVertexIterator(); walker.hasNext();) { VIPVertex V = (VIPVertex) walker.next(); // Integer indexNum = (Integer)index.getNumber(V); String seeName = V.getAcct();// accounts_arraylist.get(indexNum); if (username.equals(seeName)) { PickedState picked_state = m_visualizationview.getPickedState(); picked_state.clearPickedVertices(); picked_state.pick(V, true); /* * int x= (int)m_layout.getX(V); int y= * (int)m_layout.getY(V); //lets trigger the event * m_graphmouse.mousePressed(new * MouseEvent(m_visualizationview,MouseEvent.MOUSE_CLICKED,System.currentTimeMillis(),0,x,y,2,false)); */return; } } } }); // add the settings panel to the settings box settings_box.add(settings_panel); // add the vip table to the control panel SortTableModel model = new SortTableModel(); model.addColumn("Account"); model.addColumn("ResponseScore"); model.addColumn("SocialScore"); m_timeTable = new JTable(model); model.addMouseListenerToHeaderInTable(m_timeTable); m_timeTable.setRowSelectionAllowed(true); m_timeTable.setColumnSelectionAllowed(false); m_timeTable.getTableHeader().setReorderingAllowed(false); m_timeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); m_timeTable.setDefaultRenderer(model.getColumnClass(1), md5Renderer); tablePane = new JScrollPane(m_timeTable); tablePane.setPreferredSize(new Dimension(300, 150)); control_panel.add(tablePane, BorderLayout.SOUTH); }
From source file:metdemo.Finance.Pluggable.java
protected void addBottomControls(final JPanel jp) { final JPanel control_panel = new JPanel(); jp.add(control_panel, BorderLayout.SOUTH); control_panel.setLayout(new BorderLayout()); final Box vertex_panel = Box.createVerticalBox(); vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices")); final Box edge_panel = Box.createVerticalBox(); edge_panel.setBorder(BorderFactory.createTitledBorder("Edges")); final Box both_panel = Box.createVerticalBox(); control_panel.add(vertex_panel, BorderLayout.WEST); control_panel.add(edge_panel, BorderLayout.EAST); control_panel.add(both_panel, BorderLayout.CENTER); // set up vertex controls v_color = new JCheckBox("vertex seed coloring"); v_color.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { vcf.setSeedColoring(v_color.isSelected()); }// w w w . java2 s . com }); v_stroke = new JCheckBox("<html>vertex selection<p>stroke highlighting</html>"); v_stroke.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { vsh.setHighlight(v_stroke.isSelected()); } }); v_labels = new JCheckBox("show vertex ranks (voltages)"); v_labels.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (v_labels.isSelected()) pr.setVertexStringer(vs); else pr.setVertexStringer(vs_none); } }); v_shape = new JCheckBox("vertex degree shapes"); v_shape.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { vssa.useFunnyShapes(v_shape.isSelected()); } }); v_size = new JCheckBox("vertex voltage size"); v_size.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { vssa.setScaling(v_size.isSelected()); } }); v_aspect = new JCheckBox("vertex degree ratio stretch"); v_aspect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { vssa.setStretching(v_aspect.isSelected()); } }); v_small = new JCheckBox("filter vertices of degree < " + VertexDisplayPredicate.MIN_DEGREE); v_small.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { show_vertex.filterSmall(v_small.isSelected()); } }); vertex_panel.add(v_color); vertex_panel.add(v_stroke); vertex_panel.add(v_labels); vertex_panel.add(v_shape); vertex_panel.add(v_size); vertex_panel.add(v_aspect); vertex_panel.add(v_small); // set up edge controls JPanel gradient_panel = new JPanel(new GridLayout(1, 0)); gradient_panel.setBorder(BorderFactory.createTitledBorder("Edge paint")); no_gradient = new JRadioButton("Solid color"); no_gradient.setSelected(true); no_gradient.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { gradient_level = GRADIENT_NONE; } }); // gradient_absolute = new JRadioButton("Absolute gradient"); // gradient_absolute.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { gradient_level = GRADIENT_ABSOLUTE;}}); gradient_relative = new JRadioButton("Gradient"); gradient_relative.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { gradient_level = GRADIENT_RELATIVE; } }); ButtonGroup bg_grad = new ButtonGroup(); bg_grad.add(no_gradient); bg_grad.add(gradient_relative); //bg_grad.add(gradient_absolute); gradient_panel.add(no_gradient); //gradientGrid.add(gradient_absolute); gradient_panel.add(gradient_relative); JPanel shape_panel = new JPanel(new GridLayout(3, 2)); shape_panel.setBorder(BorderFactory.createTitledBorder("Edge shape")); e_line = new JRadioButton("line"); e_line.setSelected(true); e_line.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pr.setEdgeShapeFunction(new EdgeShape.Line()); } }); // e_bent = new JRadioButton("bent line"); // e_bent.setSelected(true); e_wedge = new JRadioButton("wedge"); e_wedge.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pr.setEdgeShapeFunction(new EdgeShape.Wedge(10)); } }); e_quad = new JRadioButton("quad curve"); e_quad.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pr.setEdgeShapeFunction(new EdgeShape.QuadCurve()); } }); e_cubic = new JRadioButton("cubic curve"); e_cubic.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pr.setEdgeShapeFunction(new EdgeShape.CubicCurve()); } }); ButtonGroup bg_shape = new ButtonGroup(); bg_shape.add(e_line); // bg.add(e_bent); bg_shape.add(e_wedge); bg_shape.add(e_quad); bg_shape.add(e_cubic); shape_panel.add(e_line); // shape_panel.add(e_bent); shape_panel.add(e_wedge); shape_panel.add(e_quad); shape_panel.add(e_cubic); fill_edges = new JCheckBox("fill edge shapes"); fill_edges.setSelected(false); fill_edges.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { edgePaint.useFill(fill_edges.isSelected()); } }); shape_panel.add(fill_edges); shape_panel.setOpaque(true); e_color = new JCheckBox("edge weight highlighting"); e_color.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ewcs.setWeighted(e_color.isSelected()); } }); e_labels = new JCheckBox("show edge weights"); e_labels.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e_labels.isSelected()) pr.setEdgeStringer(es); else pr.setEdgeStringer(es_none); } }); e_uarrow_pred = new JCheckBox("undirected"); e_uarrow_pred.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { show_arrow.showUndirected(e_uarrow_pred.isSelected()); } }); e_darrow_pred = new JCheckBox("directed"); e_darrow_pred.setSelected(true); e_darrow_pred.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { show_arrow.showDirected(e_darrow_pred.isSelected()); } }); JPanel arrow_panel = new JPanel(new GridLayout(1, 0)); arrow_panel.setBorder(BorderFactory.createTitledBorder("Show arrows")); arrow_panel.add(e_uarrow_pred); arrow_panel.add(e_darrow_pred); e_show_d = new JCheckBox("directed"); e_show_d.setSelected(true); e_show_d.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { show_edge.showDirected(e_show_d.isSelected()); } }); e_show_u = new JCheckBox("undirected"); e_show_u.setSelected(true); e_show_u.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { show_edge.showUndirected(e_show_u.isSelected()); } }); JPanel show_edge_panel = new JPanel(new GridLayout(1, 0)); show_edge_panel.setBorder(BorderFactory.createTitledBorder("Show edges")); show_edge_panel.add(e_show_u); show_edge_panel.add(e_show_d); shape_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(shape_panel); gradient_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(gradient_panel); show_edge_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(show_edge_panel); arrow_panel.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(arrow_panel); e_color.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(e_color); e_labels.setAlignmentX(Component.LEFT_ALIGNMENT); edge_panel.add(e_labels); // set up zoom controls zoom_at_mouse = new JCheckBox("<html><center>zoom at mouse<p>(wheel only)</center></html>"); zoom_at_mouse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { gm.setZoomAtMouse(zoom_at_mouse.isSelected()); } }); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // call listener in GraphMouse instead of manipulating vv scale directly // this is so the crossover from zoom to scale works with the buttons // as well as with the mouse wheel Dimension d = vv.getSize(); gm.mouseWheelMoved(new MouseWheelEvent(vv, MouseEvent.MOUSE_WHEEL, System.currentTimeMillis(), 0, d.width / 2, d.height / 2, 1, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, 1)); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // call listener in GraphMouse instead of manipulating vv scale directly // this is so the crossover from zoom to scale works with the buttons // as well as with the mouse wheel Dimension d = vv.getSize(); gm.mouseWheelMoved(new MouseWheelEvent(vv, MouseEvent.MOUSE_WHEEL, System.currentTimeMillis(), 0, d.width / 2, d.height / 2, 1, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, -1)); } }); Box zoomPanel = Box.createVerticalBox(); zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom")); plus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(plus); minus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(minus); zoom_at_mouse.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(zoom_at_mouse); // add font and zoom controls to center panel font = new JCheckBox("bold text"); font.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ff.setBold(font.isSelected()); } }); font.setAlignmentX(Component.CENTER_ALIGNMENT); both_panel.add(zoomPanel); both_panel.add(font); JComboBox modeBox = gm.getModeComboBox(); modeBox.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel modePanel = new JPanel(new BorderLayout()) { public Dimension getMaximumSize() { return getPreferredSize(); } }; modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); both_panel.add(modePanel); }