List of usage examples for javax.swing JRadioButton JRadioButton
public JRadioButton(String text)
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/*www .ja va2 s.c o m*/ 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:graphviewer.GraphCreate.java
/** * Create an instance of a directed graph *//* www. j a v a2 s . c o m*/ public GraphCreate() { super("SCCFinder"); this.graph = new DirectedSparseMultigraph<Integer, Integer>(); this.layout = new StaticLayout<Integer, Integer>(this.graph, new Dimension(600, 600)); final Transformer<Integer, Paint> redVertexPaint = new Transformer<Integer, Paint>() { public Paint transform(Integer i) { return Color.RED; } }; this.vv = new VisualizationViewer<Integer, Integer>(this.layout); this.vv.setBackground(Color.white); this.vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Integer>()); this.vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); Container content = getContentPane(); content.add(this.vv); this.vv.getRenderContext().setVertexFillPaintTransformer(redVertexPaint); // add listeners to our visual component Factory<Integer> vertexFactory = new VertexFactory(); Factory<Integer> edgeFactory = new EdgeFactory(); this.graphMouse = new EditingModalGraphMouse<Integer, Integer>(this.vv.getRenderContext(), vertexFactory, edgeFactory); this.vv.setGraphMouse(this.graphMouse); this.vv.addKeyListener(new MyKeyListener()); final MouseListener[] mls = (MouseListener[]) (this.vv.getListeners(MouseListener.class)); final MouseListener wrapper = new MyWrapperMouseListener(mls[1]); this.graphMouse.setMode(ModalGraphMouse.Mode.EDITING); this.vv.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); this.controls = new JPanel(); final ScalingControl scaler = new CrossoverScalingControl(); // add some buttons this.plus = new JButton("+"); this.plus.setToolTipText("Press this button or use the mouse wheel to zoom out"); this.plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); setFocusable(false); } }); this.minus = new JButton("-"); this.minus.setToolTipText("Press this button or use the mouse wheel to zoom in"); this.minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); setFocusable(false); } }); this.edit = new JRadioButton("Editing"); this.edit.setToolTipText("You can just press 'e' to select this radiobutton"); this.edit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { graphMouse.setMode(ModalGraphMouse.Mode.EDITING); vv.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); setFocusable(false); } }); this.transform = new JRadioButton("Transforming"); this.transform.setToolTipText("You can just press 't' to select this radiobutton"); this.transform.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); vv.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); setFocusable(false); } }); this.pick = new JRadioButton("Picking"); this.pick.setToolTipText("You can just press 'p' to select this radiobutton"); this.pick.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { graphMouse.setMode(ModalGraphMouse.Mode.PICKING); vv.setCursor(new Cursor(Cursor.HAND_CURSOR)); setFocusable(false); } }); GraphCreate.scc = new JButton("SCC"); GraphCreate.scc.setToolTipText("Strongly Connected Components algorithm"); GraphCreate.scc.setEnabled(false); GraphCreate.scc.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { createMathgraph(); GraphCreate.scc.setEnabled(false); edit.setEnabled(false); pick.setSelected(true); setFocusable(false); sccButtonPressed = true; graphMouse.setMode(ModalGraphMouse.Mode.PICKING); vv.setCursor(new Cursor(Cursor.HAND_CURSOR)); vv.removeMouseListener(mls[1]); vv.addMouseListener(wrapper); } }); GraphCreate.clear = new JButton("Clear"); GraphCreate.clear.setToolTipText("Clears our graph"); GraphCreate.clear.setEnabled(false); GraphCreate.clear.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { for (int k = 0; k <= numberOfVertices; k++) { graph.removeVertex(k); } GraphCreate.scc.setEnabled(false); GraphCreate.clear.setEnabled(false); edit.setEnabled(true); edit.setSelected(true); setFocusable(false); graphMouse.setMode(ModalGraphMouse.Mode.EDITING); vv.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); vv.getRenderContext().setVertexFillPaintTransformer(redVertexPaint); if (sccButtonPressed) { vv.removeMouseListener(wrapper); vv.addMouseListener(mls[1]); } vv.repaint(); // calling garbage collector here Runtime r = Runtime.getRuntime(); r.gc(); GraphCreate.numberOfEdges = 0; GraphCreate.numberOfVertices = 0; sccButtonPressed = false; } }); ButtonGroup actions = new ButtonGroup(); actions.add(this.edit); actions.add(this.transform); actions.add(this.pick); this.edit.setSelected(true); this.controls.add(this.plus); this.controls.add(this.minus); this.controls.add(this.edit); this.controls.add(this.transform); this.controls.add(this.pick); this.controls.add(GraphCreate.scc); controls.add(GraphCreate.clear); this.help = new JButton("Help"); this.help.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(vv, instructions); setFocusable(false); } }); this.controls.add(this.help); content.add(this.controls, BorderLayout.SOUTH); }
From source file:SoundBug.java
JPanel soundPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridLayout(4, 1)); // create the buttons soundNoneButton = new JRadioButton(soundNoneString); soundBackgroundButton = new JRadioButton(soundBackgroundString); soundPointButton = new JRadioButton(soundPointString); //soundConeButton = new JRadioButton(soundConeString); // set up the action commands soundNoneButton.setActionCommand(soundNoneString); soundBackgroundButton.setActionCommand(soundBackgroundActionString); soundPointButton.setActionCommand(soundPointActionString); //soundConeButton.setActionCommand(soundConeString); // add the buttons to a group so that only one can be selected ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(soundNoneButton);/*w w w .j a v a 2s . c o m*/ buttonGroup.add(soundBackgroundButton); buttonGroup.add(soundPointButton); //buttonGroup.add(soundConeButton); // register the applet as the listener for the buttons soundNoneButton.addActionListener(this); soundBackgroundButton.addActionListener(this); soundPointButton.addActionListener(this); // soundConeButton.addActionListener(this); // add the buttons to the panel panel.add(soundNoneButton); panel.add(soundBackgroundButton); panel.add(soundPointButton); //panel.add(soundConeButton); // set the default soundNoneButton.setSelected(true); return panel; }
From source file:net.sf.jabref.gui.preftabs.TableColumnsTab.java
/** * Customization of external program paths. * * @param prefs a <code>JabRefPreferences</code> value *///w w w. j ava 2 s. c o m public TableColumnsTab(JabRefPreferences prefs, JabRefFrame frame) { this.prefs = prefs; this.frame = frame; setLayout(new BorderLayout()); TableModel tm = new AbstractTableModel() { @Override public int getRowCount() { return rowCount; } @Override public int getColumnCount() { return 2; } @Override public Object getValueAt(int row, int column) { int internalRow = row; if (internalRow == 0) { return column == 0 ? InternalBibtexFields.NUMBER_COL : String.valueOf(ncWidth); } internalRow--; if (internalRow >= tableRows.size()) { return ""; } Object rowContent = tableRows.get(internalRow); if (rowContent == null) { return ""; } TableRow tr = (TableRow) rowContent; // Only two columns if (column == 0) { return tr.getName(); } else { return tr.getLength() > 0 ? Integer.toString(tr.getLength()) : ""; } } @Override public String getColumnName(int col) { return col == 0 ? Localization.lang("Field name") : Localization.lang("Column width"); } @Override public Class<?> getColumnClass(int column) { if (column == 0) { return String.class; } return Integer.class; } @Override public boolean isCellEditable(int row, int col) { return !((row == 0) && (col == 0)); } @Override public void setValueAt(Object value, int row, int col) { tableChanged = true; // Make sure the vector is long enough. while (row >= tableRows.size()) { tableRows.add(new TableRow("", -1)); } if ((row == 0) && (col == 1)) { ncWidth = Integer.parseInt(value.toString()); return; } TableRow rowContent = tableRows.get(row - 1); if (col == 0) { rowContent.setName(value.toString()); if ("".equals(getValueAt(row, 1))) { setValueAt(String.valueOf(BibtexSingleField.DEFAULT_FIELD_LENGTH), row, 1); } } else { if (value == null) { rowContent.setLength(-1); } else { rowContent.setLength(Integer.parseInt(value.toString())); } } } }; colSetup = new JTable(tm); TableColumnModel cm = colSetup.getColumnModel(); cm.getColumn(0).setPreferredWidth(140); cm.getColumn(1).setPreferredWidth(80); FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 4dlu, fill:pref", ""); DefaultFormBuilder builder = new DefaultFormBuilder(layout); JPanel pan = new JPanel(); JPanel tabPanel = new JPanel(); tabPanel.setLayout(new BorderLayout()); JScrollPane sp = new JScrollPane(colSetup, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); colSetup.setPreferredScrollableViewportSize(new Dimension(250, 200)); sp.setMinimumSize(new Dimension(250, 300)); tabPanel.add(sp, BorderLayout.CENTER); JToolBar toolBar = new OSXCompatibleToolbar(SwingConstants.VERTICAL); toolBar.setFloatable(false); AddRowAction addRow = new AddRowAction(); DeleteRowAction deleteRow = new DeleteRowAction(); MoveRowUpAction moveUp = new MoveRowUpAction(); MoveRowDownAction moveDown = new MoveRowDownAction(); toolBar.setBorder(null); toolBar.add(addRow); toolBar.add(deleteRow); toolBar.addSeparator(); toolBar.add(moveUp); toolBar.add(moveDown); tabPanel.add(toolBar, BorderLayout.EAST); fileColumn = new JCheckBox(Localization.lang("Show file column")); urlColumn = new JCheckBox(Localization.lang("Show URL/DOI column")); preferUrl = new JRadioButton(Localization.lang("Show URL first")); preferDoi = new JRadioButton(Localization.lang("Show DOI first")); ButtonGroup preferUrlDoiGroup = new ButtonGroup(); preferUrlDoiGroup.add(preferUrl); preferUrlDoiGroup.add(preferDoi); urlColumn.addChangeListener(arg0 -> { preferUrl.setEnabled(urlColumn.isSelected()); preferDoi.setEnabled(urlColumn.isSelected()); }); arxivColumn = new JCheckBox(Localization.lang("Show ArXiv column")); Collection<ExternalFileType> fileTypes = ExternalFileTypes.getInstance().getExternalFileTypeSelection(); String[] fileTypeNames = new String[fileTypes.size()]; int i = 0; for (ExternalFileType fileType : fileTypes) { fileTypeNames[i++] = fileType.getName(); } listOfFileColumns = new JList<>(fileTypeNames); JScrollPane listOfFileColumnsScrollPane = new JScrollPane(listOfFileColumns); listOfFileColumns.setVisibleRowCount(3); extraFileColumns = new JCheckBox(Localization.lang("Show extra columns")); extraFileColumns.addChangeListener(arg0 -> listOfFileColumns.setEnabled(extraFileColumns.isSelected())); /*** begin: special table columns and special fields ***/ JButton helpButton = new HelpAction(Localization.lang("Help on special fields"), HelpFile.SPECIAL_FIELDS) .getHelpButton(); rankingColumn = new JCheckBox(Localization.lang("Show rank")); qualityColumn = new JCheckBox(Localization.lang("Show quality")); priorityColumn = new JCheckBox(Localization.lang("Show priority")); relevanceColumn = new JCheckBox(Localization.lang("Show relevance")); printedColumn = new JCheckBox(Localization.lang("Show printed status")); readStatusColumn = new JCheckBox(Localization.lang("Show read status")); // "sync keywords" and "write special" fields may be configured mutually exclusive only // The implementation supports all combinations (TRUE+TRUE and FALSE+FALSE, even if the latter does not make sense) // To avoid confusion, we opted to make the setting mutually exclusive syncKeywords = new JRadioButton(Localization.lang("Synchronize with keywords")); writeSpecialFields = new JRadioButton( Localization.lang("Write values of special fields as separate fields to BibTeX")); ButtonGroup group = new ButtonGroup(); group.add(syncKeywords); group.add(writeSpecialFields); specialFieldsEnabled = new JCheckBox(Localization.lang("Enable special fields")); specialFieldsEnabled.addChangeListener(event -> { boolean isEnabled = specialFieldsEnabled.isSelected(); rankingColumn.setEnabled(isEnabled); qualityColumn.setEnabled(isEnabled); priorityColumn.setEnabled(isEnabled); relevanceColumn.setEnabled(isEnabled); printedColumn.setEnabled(isEnabled); readStatusColumn.setEnabled(isEnabled); syncKeywords.setEnabled(isEnabled); writeSpecialFields.setEnabled(isEnabled); }); builder.appendSeparator(Localization.lang("Special table columns")); builder.nextLine(); builder.append(pan); DefaultFormBuilder specialTableColumnsBuilder = new DefaultFormBuilder( new FormLayout("8dlu, 8dlu, 8cm, 8dlu, 8dlu, left:pref:grow", "pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref")); CellConstraints cc = new CellConstraints(); specialTableColumnsBuilder.add(specialFieldsEnabled, cc.xyw(1, 1, 3)); specialTableColumnsBuilder.add(rankingColumn, cc.xyw(2, 2, 2)); specialTableColumnsBuilder.add(relevanceColumn, cc.xyw(2, 3, 2)); specialTableColumnsBuilder.add(qualityColumn, cc.xyw(2, 4, 2)); specialTableColumnsBuilder.add(priorityColumn, cc.xyw(2, 5, 2)); specialTableColumnsBuilder.add(printedColumn, cc.xyw(2, 6, 2)); specialTableColumnsBuilder.add(readStatusColumn, cc.xyw(2, 7, 2)); specialTableColumnsBuilder.add(syncKeywords, cc.xyw(2, 10, 2)); specialTableColumnsBuilder.add(writeSpecialFields, cc.xyw(2, 11, 2)); specialTableColumnsBuilder.add(helpButton, cc.xyw(1, 12, 2)); specialTableColumnsBuilder.add(fileColumn, cc.xyw(5, 1, 2)); specialTableColumnsBuilder.add(urlColumn, cc.xyw(5, 2, 2)); specialTableColumnsBuilder.add(preferUrl, cc.xy(6, 3)); specialTableColumnsBuilder.add(preferDoi, cc.xy(6, 4)); specialTableColumnsBuilder.add(arxivColumn, cc.xyw(5, 5, 2)); specialTableColumnsBuilder.add(extraFileColumns, cc.xyw(5, 6, 2)); specialTableColumnsBuilder.add(listOfFileColumnsScrollPane, cc.xywh(5, 7, 2, 6)); builder.append(specialTableColumnsBuilder.getPanel()); builder.nextLine(); /*** end: special table columns and special fields ***/ builder.appendSeparator(Localization.lang("Entry table columns")); builder.nextLine(); builder.append(pan); builder.append(tabPanel); builder.nextLine(); builder.append(pan); JButton buttonWidth = new JButton(new UpdateWidthsAction()); JButton buttonOrder = new JButton(new UpdateOrderAction()); builder.append(buttonWidth); builder.nextLine(); builder.append(pan); builder.append(buttonOrder); builder.nextLine(); builder.append(pan); builder.nextLine(); pan = builder.getPanel(); pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(pan, BorderLayout.CENTER); }
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 a v a2 s . c om*/ // 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:au.org.ala.delta.intkey.ui.DefineButtonDialog.java
public DefineButtonDialog(Frame owner, boolean modal) { super(owner, modal); setPreferredSize(new Dimension(500, 430)); ResourceMap resourceMap = Application.getInstance().getContext().getResourceMap(DefineButtonDialog.class); resourceMap.injectFields(this); ActionMap actionMap = Application.getInstance().getContext().getActionMap(DefineButtonDialog.class, this); setTitle(title);//from ww w . ja v a2 s. c om _okButtonPressed = false; _pnlButtons = new JPanel(); getContentPane().add(_pnlButtons, BorderLayout.SOUTH); _btnOk = new JButton(); _btnOk.setAction(actionMap.get("DefineButtonDialog_OK")); _pnlButtons.add(_btnOk); _btnCancel = new JButton(); _btnCancel.setAction(actionMap.get("DefineButtonDialog_Cancel")); _pnlButtons.add(_btnCancel); _btnHelp = new JButton(); _btnHelp.setAction(actionMap.get("DefineButtonDialog_Help")); _btnHelp.setEnabled(false); _pnlButtons.add(_btnHelp); _pnlMain = new JPanel(); getContentPane().add(_pnlMain, BorderLayout.CENTER); _pnlMain.setLayout(new BorderLayout(5, 0)); _pnlButtonProperties = new JPanel(); _pnlButtonProperties.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new CompoundBorder( new EtchedBorder(EtchedBorder.LOWERED, null, null), new EmptyBorder(5, 5, 5, 5)))); _pnlMain.add(_pnlButtonProperties, BorderLayout.NORTH); GridBagLayout gbl__pnlButtonProperties = new GridBagLayout(); gbl__pnlButtonProperties.columnWidths = new int[] { 475, 0 }; gbl__pnlButtonProperties.rowHeights = new int[] { 14, 23, 14, 20, 14, 20, 14, 0, 23, 23, 23, 23, 0 }; gbl__pnlButtonProperties.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl__pnlButtonProperties.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; _pnlButtonProperties.setLayout(gbl__pnlButtonProperties); _lblEnterNameOf = new JLabel(enterFileNameCaption); _lblEnterNameOf.setHorizontalAlignment(SwingConstants.LEFT); GridBagConstraints gbc__lblEnterNameOf = new GridBagConstraints(); gbc__lblEnterNameOf.anchor = GridBagConstraints.WEST; gbc__lblEnterNameOf.insets = new Insets(0, 0, 5, 0); gbc__lblEnterNameOf.gridx = 0; gbc__lblEnterNameOf.gridy = 0; _pnlButtonProperties.add(_lblEnterNameOf, gbc__lblEnterNameOf); _pnlFile = new JPanel(); GridBagConstraints gbc__pnlFile = new GridBagConstraints(); gbc__pnlFile.fill = GridBagConstraints.HORIZONTAL; gbc__pnlFile.insets = new Insets(0, 0, 5, 0); gbc__pnlFile.gridx = 0; gbc__pnlFile.gridy = 1; _pnlButtonProperties.add(_pnlFile, gbc__pnlFile); _pnlFile.setLayout(new BorderLayout(0, 0)); _txtFldFileName = new JTextField(); _pnlFile.add(_txtFldFileName, BorderLayout.CENTER); _txtFldFileName.setColumns(10); _btnBrowse = new JButton(); _btnBrowse.setAction(actionMap.get("DefineButtonDialog_Browse")); _pnlFile.add(_btnBrowse, BorderLayout.EAST); _lblEnterTheCommands = new JLabel(enterCommandsCaption); _lblEnterTheCommands.setHorizontalAlignment(SwingConstants.LEFT); GridBagConstraints gbc__lblEnterTheCommands = new GridBagConstraints(); gbc__lblEnterTheCommands.anchor = GridBagConstraints.WEST; gbc__lblEnterTheCommands.insets = new Insets(0, 0, 5, 0); gbc__lblEnterTheCommands.gridx = 0; gbc__lblEnterTheCommands.gridy = 2; _pnlButtonProperties.add(_lblEnterTheCommands, gbc__lblEnterTheCommands); _txtFldCommands = new JTextField(); GridBagConstraints gbc__txtFldCommands = new GridBagConstraints(); gbc__txtFldCommands.fill = GridBagConstraints.HORIZONTAL; gbc__txtFldCommands.insets = new Insets(0, 0, 5, 0); gbc__txtFldCommands.gridx = 0; gbc__txtFldCommands.gridy = 3; _pnlButtonProperties.add(_txtFldCommands, gbc__txtFldCommands); _txtFldCommands.setColumns(10); _lblEnterBriefHelp = new JLabel(enterBriefHelpCaption); _lblEnterBriefHelp.setAlignmentY(Component.TOP_ALIGNMENT); GridBagConstraints gbc__lblEnterBriefHelp = new GridBagConstraints(); gbc__lblEnterBriefHelp.anchor = GridBagConstraints.NORTHWEST; gbc__lblEnterBriefHelp.insets = new Insets(0, 0, 5, 0); gbc__lblEnterBriefHelp.gridx = 0; gbc__lblEnterBriefHelp.gridy = 4; _pnlButtonProperties.add(_lblEnterBriefHelp, gbc__lblEnterBriefHelp); _txtFldBriefHelp = new JTextField(); GridBagConstraints gbc__txtFldBriefHelp = new GridBagConstraints(); gbc__txtFldBriefHelp.fill = GridBagConstraints.HORIZONTAL; gbc__txtFldBriefHelp.insets = new Insets(0, 0, 5, 0); gbc__txtFldBriefHelp.gridx = 0; gbc__txtFldBriefHelp.gridy = 5; _pnlButtonProperties.add(_txtFldBriefHelp, gbc__txtFldBriefHelp); _txtFldBriefHelp.setColumns(10); _lblEnterMoreDetailed = new JLabel(enterDetailedHelpCaption); GridBagConstraints gbc__lblEnterMoreDetailed = new GridBagConstraints(); gbc__lblEnterMoreDetailed.anchor = GridBagConstraints.WEST; gbc__lblEnterMoreDetailed.insets = new Insets(0, 0, 5, 0); gbc__lblEnterMoreDetailed.gridx = 0; gbc__lblEnterMoreDetailed.gridy = 6; _pnlButtonProperties.add(_lblEnterMoreDetailed, gbc__lblEnterMoreDetailed); _txtFldDetailedHelp = new JTextField(); GridBagConstraints gbc__txtFldDetailedHelp = new GridBagConstraints(); gbc__txtFldDetailedHelp.insets = new Insets(0, 0, 5, 0); gbc__txtFldDetailedHelp.fill = GridBagConstraints.HORIZONTAL; gbc__txtFldDetailedHelp.gridx = 0; gbc__txtFldDetailedHelp.gridy = 7; _pnlButtonProperties.add(_txtFldDetailedHelp, gbc__txtFldDetailedHelp); _txtFldDetailedHelp.setColumns(10); _chckbxEnableOnlyIfUsedCharacters = new JCheckBox(enableOnlyIfUsedCaption); GridBagConstraints gbc__chckbxEnableOnlyIf = new GridBagConstraints(); gbc__chckbxEnableOnlyIf.anchor = GridBagConstraints.WEST; gbc__chckbxEnableOnlyIf.insets = new Insets(0, 0, 5, 0); gbc__chckbxEnableOnlyIf.gridx = 0; gbc__chckbxEnableOnlyIf.gridy = 8; _pnlButtonProperties.add(_chckbxEnableOnlyIfUsedCharacters, gbc__chckbxEnableOnlyIf); _rdbtnEnableInAll = new JRadioButton(enableInAllModesCaption); GridBagConstraints gbc__rdbtnEnableInAll = new GridBagConstraints(); gbc__rdbtnEnableInAll.anchor = GridBagConstraints.WEST; gbc__rdbtnEnableInAll.insets = new Insets(0, 0, 5, 0); gbc__rdbtnEnableInAll.gridx = 0; gbc__rdbtnEnableInAll.gridy = 9; _pnlButtonProperties.add(_rdbtnEnableInAll, gbc__rdbtnEnableInAll); _rdbtnEnableInNormal = new JRadioButton(enableInNormalModeCaption); GridBagConstraints gbc__rdbtnEnableInNormal = new GridBagConstraints(); gbc__rdbtnEnableInNormal.anchor = GridBagConstraints.WEST; gbc__rdbtnEnableInNormal.insets = new Insets(0, 0, 5, 0); gbc__rdbtnEnableInNormal.gridx = 0; gbc__rdbtnEnableInNormal.gridy = 10; _pnlButtonProperties.add(_rdbtnEnableInNormal, gbc__rdbtnEnableInNormal); _rdbtnEnableInAdvanced = new JRadioButton(enableInAdvancedModeCaption); GridBagConstraints gbc__rdbtnEnableInAdvanced = new GridBagConstraints(); gbc__rdbtnEnableInAdvanced.anchor = GridBagConstraints.WEST; gbc__rdbtnEnableInAdvanced.gridx = 0; gbc__rdbtnEnableInAdvanced.gridy = 11; _pnlButtonProperties.add(_rdbtnEnableInAdvanced, gbc__rdbtnEnableInAdvanced); _pnlSpaceRemoveAll = new JPanel(); _pnlSpaceRemoveAll.setBorder(new EmptyBorder(0, 10, 0, 0)); _pnlMain.add(_pnlSpaceRemoveAll, BorderLayout.SOUTH); _pnlSpaceRemoveAll.setLayout(new BoxLayout(_pnlSpaceRemoveAll, BoxLayout.Y_AXIS)); _chckbxInsertASpace = new JCheckBox(insertSpaceCaption); _chckbxInsertASpace.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { _insertSpace = !_insertSpace; if (_insertSpace) { _removeAllButtons = false; _chckbxRemoveAllButtons.setSelected(false); } updateButtonPropertyControls(); } }); _pnlSpaceRemoveAll.add(_chckbxInsertASpace); _chckbxRemoveAllButtons = new JCheckBox(removeAllCaption); _chckbxRemoveAllButtons.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { _removeAllButtons = !_removeAllButtons; if (_removeAllButtons) { _insertSpace = false; _chckbxInsertASpace.setSelected(false); } updateButtonPropertyControls(); } }); _pnlSpaceRemoveAll.add(_chckbxRemoveAllButtons); _pnlButtonProperties.setEnabled(false); ButtonGroup btnGroup = new ButtonGroup(); btnGroup.add(_rdbtnEnableInAll); btnGroup.add(_rdbtnEnableInNormal); btnGroup.add(_rdbtnEnableInAdvanced); _rdbtnEnableInAll.setSelected(true); }
From source file:edu.uci.ics.jung.samples.HyperbolicVertexImageShaperDemo.java
/** * create an instance of a simple graph with controls to * demo the zoom features./* ww w .ja va 2 s.com*/ * */ public HyperbolicVertexImageShaperDemo() { // create a simple graph for the demo graph = new DirectedSparseMultigraph<Number, Number>(); Number[] vertices = createVertices(11); // a Map for the labels Map<Number, String> map = new HashMap<Number, String>(); for (int i = 0; i < vertices.length; i++) { map.put(vertices[i], iconNames[i % iconNames.length]); } // a Map for the Icons Map<Number, Icon> iconMap = new HashMap<Number, Icon>(); for (int i = 0; i < vertices.length; i++) { String name = "/images/topic" + iconNames[i] + ".gif"; try { Icon icon = new LayeredIcon( new ImageIcon(HyperbolicVertexImageShaperDemo.class.getResource(name)).getImage()); iconMap.put(vertices[i], icon); } catch (Exception ex) { System.err.println("You need slashdoticons.jar in your classpath to see the image " + name); } } createEdges(vertices); FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph); layout.setMaxIterations(100); vv = new VisualizationViewer<Number, Number>(layout, new Dimension(400, 400)); Transformer<Number, Paint> vpf = new PickableVertexPaintTransformer<Number>(vv.getPickedVertexState(), Color.white, Color.yellow); vv.getRenderContext().setVertexFillPaintTransformer(vpf); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan)); vv.setBackground(Color.white); final Transformer<Number, String> vertexStringerImpl = new VertexStringerImpl<Number>(map); vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl); vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan)); vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan)); // features on and off. For a real application, use VertexIconAndShapeFunction instead. final VertexIconShapeTransformer<Number> vertexImageShapeFunction = new VertexIconShapeTransformer<Number>( new EllipseVertexShapeTransformer<Number>()); final DefaultVertexIconTransformer<Number> vertexIconFunction = new DefaultVertexIconTransformer<Number>(); vertexImageShapeFunction.setIconMap(iconMap); vertexIconFunction.setIconMap(iconMap); vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction); vv.getRenderContext().setVertexIconTransformer(vertexIconFunction); // Get the pickedState and add a listener that will decorate the // Vertex images with a checkmark icon when they are picked PickedState<Number> ps = vv.getPickedVertexState(); ps.addItemListener(new PickWithIconListener(vertexIconFunction)); vv.addPostRenderPaintable(new VisualizationServer.Paintable() { int x; int y; Font font; FontMetrics metrics; int swidth; int sheight; String str = "Thank You, slashdot.org, for the images!"; public void paint(Graphics g) { Dimension d = vv.getSize(); if (font == null) { font = new Font(g.getFont().getName(), Font.BOLD, 20); metrics = g.getFontMetrics(font); swidth = metrics.stringWidth(str); sheight = metrics.getMaxAscent() + metrics.getMaxDescent(); x = (d.width - swidth) / 2; y = (int) (d.height - sheight * 1.5); } g.setFont(font); Color oldColor = g.getColor(); g.setColor(Color.lightGray); g.drawString(str, x, y); g.setColor(oldColor); } public boolean useTransform() { return false; } }); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Number>()); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>(); vv.setGraphMouse(graphMouse); 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()); } }); JComboBox modeBox = graphMouse.getModeComboBox(); JPanel modePanel = new JPanel(); modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(scaleGrid); controls.add(modePanel); content.add(controls, BorderLayout.SOUTH); this.viewSupport = new HyperbolicImageLensSupport<Number, Number>(vv); this.modelSupport = new LayoutLensSupport<Number, Number>(vv); graphMouse.addItemListener(modelSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(viewSupport.getGraphMouse().getModeListener()); ButtonGroup radio = new ButtonGroup(); JRadioButton none = new JRadioButton("None"); none.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (viewSupport != null) { viewSupport.deactivate(); } if (modelSupport != null) { modelSupport.deactivate(); } } }); none.setSelected(true); JRadioButton hyperView = new JRadioButton("View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JRadioButton hyperModel = new JRadioButton("Layout"); hyperModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { modelSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); radio.add(none); radio.add(hyperView); radio.add(hyperModel); JMenuBar menubar = new JMenuBar(); JMenu modeMenu = graphMouse.getModeMenu(); menubar.add(modeMenu); JPanel lensPanel = new JPanel(new GridLayout(2, 0)); lensPanel.setBorder(BorderFactory.createTitledBorder("Lens")); lensPanel.add(none); lensPanel.add(hyperView); lensPanel.add(hyperModel); controls.add(lensPanel); }
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 ww.j a va 2 s. c om*/ 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:LightBug.java
JPanel lightPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridLayout(0, 1)); panel.add(new JLabel("Light type")); // create the buttons JRadioButton lightNoneButton = new JRadioButton(lightNoneString); JRadioButton lightDirectionalButton = new JRadioButton(lightDirectionalString); JRadioButton lightPointButton = new JRadioButton(lightPointString); JRadioButton lightSpotButton = new JRadioButton(lightSpotString); // set up the action commands lightNoneButton.setActionCommand(lightNoneString); lightDirectionalButton.setActionCommand(lightDirectionalString); lightPointButton.setActionCommand(lightPointString); lightSpotButton.setActionCommand(lightSpotString); // add the buttons to a group so that only one can be selected ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(lightNoneButton);//from w w w. ja va2 s . c o m buttonGroup.add(lightDirectionalButton); buttonGroup.add(lightPointButton); buttonGroup.add(lightSpotButton); // register the applet as the listener for the buttons lightNoneButton.addActionListener(this); lightDirectionalButton.addActionListener(this); lightPointButton.addActionListener(this); lightSpotButton.addActionListener(this); // add the buttons to the panel panel.add(lightNoneButton); panel.add(lightDirectionalButton); panel.add(lightPointButton); panel.add(lightSpotButton); // set the default lightDirectionalButton.setSelected(true); return panel; }
From source file:io.datalayer.jung.LensVertexImageShaperDemo.java
/** * create an instance of a simple graph with controls to * demo the zoom features.//from www . j av a 2 s . c o m * */ public LensVertexImageShaperDemo() { // create a simple graph for the demo graph = new DirectedSparseGraph<Number, Number>(); Number[] vertices = createVertices(11); // a Map for the labels Map<Number, String> map = new HashMap<Number, String>(); for (int i = 0; i < vertices.length; i++) { map.put(vertices[i], iconNames[i % iconNames.length]); } // a Map for the Icons Map<Number, Icon> iconMap = new HashMap<Number, Icon>(); for (int i = 0; i < vertices.length; i++) { String name = "/images/topic" + iconNames[i] + ".gif"; try { Icon icon = new LayeredIcon( new ImageIcon(LensVertexImageShaperDemo.class.getResource(name)).getImage()); iconMap.put(vertices[i], icon); } catch (Exception ex) { System.err.println("You need slashdoticons.jar in your classpath to see the image " + name); } } createEdges(vertices); FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph); layout.setMaxIterations(100); vv = new VisualizationViewer<Number, Number>(layout, new Dimension(600, 600)); Transformer<Number, Paint> vpf = new PickableVertexPaintTransformer<Number>(vv.getPickedVertexState(), Color.white, Color.yellow); vv.getRenderContext().setVertexFillPaintTransformer(vpf); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan)); vv.setBackground(Color.white); final Transformer<Number, String> vertexStringerImpl = new VertexStringerImpl<Number>(map); vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl); vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan)); vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan)); // features on and off. For a real application, use VertexIconAndShapeFunction instead. final VertexIconShapeTransformer<Number> vertexImageShapeFunction = new VertexIconShapeTransformer<Number>( new EllipseVertexShapeTransformer<Number>()); final DefaultVertexIconTransformer<Number> vertexIconFunction = new DefaultVertexIconTransformer<Number>(); vertexImageShapeFunction.setIconMap(iconMap); vertexIconFunction.setIconMap(iconMap); vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction); vv.getRenderContext().setVertexIconTransformer(vertexIconFunction); // Get the pickedState and add a listener that will decorate the // Vertex images with a checkmark icon when they are picked PickedState<Number> ps = vv.getPickedVertexState(); ps.addItemListener(new PickWithIconListener(vertexIconFunction)); vv.addPostRenderPaintable(new VisualizationViewer.Paintable() { int x; int y; Font font; FontMetrics metrics; int swidth; int sheight; String str = "Thank You, slashdot.org, for the images!"; public void paint(Graphics g) { Dimension d = vv.getSize(); if (font == null) { font = new Font(g.getFont().getName(), Font.BOLD, 20); metrics = g.getFontMetrics(font); swidth = metrics.stringWidth(str); sheight = metrics.getMaxAscent() + metrics.getMaxDescent(); x = (d.width - swidth) / 2; y = (int) (d.height - sheight * 1.5); } g.setFont(font); Color oldColor = g.getColor(); g.setColor(Color.lightGray); g.drawString(str, x, y); g.setColor(oldColor); } public boolean useTransform() { return false; } }); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Number>()); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); 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()); } }); JComboBox modeBox = graphMouse.getModeComboBox(); JPanel modePanel = new JPanel(); modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(scaleGrid); controls.add(modePanel); content.add(controls, BorderLayout.SOUTH); this.viewSupport = new MagnifyImageLensSupport<Number, Number>(vv); // new ViewLensSupport<Number,Number>(vv, new HyperbolicShapeTransformer(vv, // vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), // new ModalLensGraphMouse()); this.modelSupport = new LayoutLensSupport<Number, Number>(vv); graphMouse.addItemListener(modelSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(viewSupport.getGraphMouse().getModeListener()); ButtonGroup radio = new ButtonGroup(); JRadioButton none = new JRadioButton("None"); none.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (viewSupport != null) { viewSupport.deactivate(); } if (modelSupport != null) { modelSupport.deactivate(); } } }); none.setSelected(true); JRadioButton hyperView = new JRadioButton("View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JRadioButton hyperModel = new JRadioButton("Layout"); hyperModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { modelSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); radio.add(none); radio.add(hyperView); radio.add(hyperModel); JMenuBar menubar = new JMenuBar(); JMenu modeMenu = graphMouse.getModeMenu(); menubar.add(modeMenu); JPanel lensPanel = new JPanel(new GridLayout(2, 0)); lensPanel.setBorder(BorderFactory.createTitledBorder("Lens")); lensPanel.add(none); lensPanel.add(hyperView); lensPanel.add(hyperModel); controls.add(lensPanel); }