List of usage examples for javax.swing ButtonGroup add
public void add(AbstractButton b)
From source file:psidev.psi.mi.tab.client.gui.DragAndDropConverter.java
public static void addProcessorMenu(JMenuBar menuBar) { // Create a menu JMenu menu = new JMenu("Processing"); menuBar.add(menu);/*from w w w . java 2 s.c o m*/ ButtonGroup itemGroup = new ButtonGroup(); // Create none item JMenuItem noneItem = new JRadioButtonMenuItem("None"); noneItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { log.debug("Disables post processing."); postProcessorStrategy = null; } }); itemGroup.add(noneItem); menu.add(noneItem); // Create a clustering item JMenuItem clusteringInteractorItem = new JRadioButtonMenuItem("Clustering interactor pairs"); clusteringInteractorItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { log.debug("Enables post processing: ClusterPerInteractorProcessor"); postProcessorStrategy = new ClusterInteractorPairProcessor(); } }); itemGroup.add(clusteringInteractorItem); clusteringInteractorItem.setSelected(true); menu.add(clusteringInteractorItem); }
From source file:renderer.DependencyGrapher.java
/** * create an instance of a simple graph in two views with controls to * demo the features.//from w w w . j a va 2s .com * */ public DependencyGrapher() { // create a simple graph for the demo final DependencyDirectedSparceMultiGraph<String, Number> graph = createGraph(); //TestGraphs.getOneComponentGraph(); // the preferred sizes for the two views // create one layout for the graph final FRLayout2<String, Number> layout = new FRLayout2<String, Number>(graph); layout.setMaxIterations(500); VisualizationModel<String, Number> vm = new DefaultVisualizationModel<String, Number>(layout, preferredSize1); Transformer<Number, String> stringer = new Transformer<Number, String>() { public String transform(Number e) { if (graph.getEdgeAttributes(e) != null) { return graph.getEdgeAttributes(e).toString(); } return null; } }; // create 2 views that share the same model final VisualizationViewer<String, Number> vv = new VisualizationViewer<String, Number>(vm, preferredSize1); vv.setBackground(Color.white); vv.getRenderContext().setEdgeLabelTransformer(stringer); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<String, Number>(vv.getPickedEdgeState(), Color.black, Color.cyan)); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(vv.getPickedVertexState(), Color.red, Color.yellow)); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>()); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.AUTO); // add default listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<String>()); // ToolTipManager.sharedInstance().setDismissDelay(10000); Container content = getContentPane(); Container panel = new JPanel(new BorderLayout()); GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv); panel.add(gzsp); helpDialog = new JDialog(); helpDialog.getContentPane().add(new JLabel(instructions)); RenderContext<String, Number> rc = vv.getRenderContext(); AnnotatingGraphMousePlugin annotatingPlugin = new AnnotatingGraphMousePlugin(rc); // create a GraphMouse for the main view // final AnnotatingModalGraphMouse graphMouse = new AnnotatingModalGraphMouse(rc, annotatingPlugin); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); final ScalingControl scaler = new CrossoverScalingControl(); JButton filterReset = new JButton("Reset"); filterReset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { vv.getModel().setGraphLayout(layout); } }); JButton filterFilter = new JButton("Filter"); filterReset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { vv.getModel().setGraphLayout(layout); } }); JRadioButton filterDirectionInOut = new JRadioButton("In/Out"); filterDirectionInOut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Dependency Direction: " + EdgeType.IN_OUT); _filterEdgeDirection = EdgeType.IN_OUT; filterLayout = getNewLayout(graph, layout); vv.getModel().setGraphLayout(filterLayout); } }); JRadioButton filterDirectionIn = new JRadioButton("In"); filterDirectionIn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Dependency Direction: " + EdgeType.IN); _filterEdgeDirection = EdgeType.IN; filterLayout = getNewLayout(graph, layout); vv.getModel().setGraphLayout(filterLayout); } }); JRadioButton filterDirectionOut = new JRadioButton("Out"); filterDirectionOut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Dependency Direction: " + EdgeType.OUT); _filterEdgeDirection = EdgeType.OUT; filterLayout = getNewLayout(graph, layout); vv.getModel().setGraphLayout(filterLayout); } }); ButtonGroup filterRadios = new ButtonGroup(); filterRadios.add(filterDirectionInOut); filterRadios.add(filterDirectionIn); filterRadios.add(filterDirectionOut); filterRadios.setSelected(filterDirectionInOut.getModel(), true); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.setSelectedItem(ModalGraphMouse.Mode.PICKING); final JComboBox filterBox = new JComboBox(graph.getVertices().toArray()); filterBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { _filterChoice = filterBox.getSelectedItem().toString(); System.out.println(_filterChoice); filterLayout = getNewLayout(graph, layout); vv.getModel().setGraphLayout(filterLayout); } }); JButton help = new JButton("Help"); help.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { helpDialog.pack(); helpDialog.setVisible(true); } }); JPanel controls = new JPanel(); JPanel modeControls = new JPanel(); modeControls.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modeControls.add(graphMouse.getModeComboBox()); controls.add(modeControls); JPanel annotationControlPanel = new JPanel(); annotationControlPanel.setBorder(BorderFactory.createTitledBorder("Annotation Controls")); AnnotationControls annotationControls = new AnnotationControls(annotatingPlugin); annotationControlPanel.add(annotationControls.getAnnotationsToolBar()); controls.add(annotationControlPanel); JPanel helpControls = new JPanel(); helpControls.setBorder(BorderFactory.createTitledBorder("Help")); helpControls.add(help); controls.add(helpControls); JPanel filterControls = new JPanel(); filterControls.setBorder(BorderFactory.createTitledBorder("Filter")); filterControls.add(filterBox); filterControls.add(filterDirectionInOut); filterControls.add(filterDirectionIn); filterControls.add(filterDirectionOut); filterControls.add(filterReset); controls.add(filterControls); content.add(panel); content.add(controls, BorderLayout.SOUTH); }
From source file:ro.nextreports.designer.wizrep.QueryWizardPanel.java
private void init() { setLayout(new BorderLayout()); ButtonGroup bg = new ButtonGroup(); bg.add(selectionRB); bg.add(queryRB);//from w w w.ja v a2 s.com bg.add(editRB); selectionRB.setSelected(true); selectionRB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selection(); } }); queryRB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selection(); } }); editRB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selection(); } }); editor = new EditorPanel(); parametersPanel = new ParametersPanel(); parametersPanel.setPreferredSize(new Dimension(120, 200)); queryPanel = new QueryBrowserPanel() { protected void selection() { String name = queryPanel.getSelectedFilePath(); if (queryPanel.querySelected()) { ReportPersistence repPersist = ReportPersistenceFactory .createReportPersistence(Globals.getReportPersistenceType()); Report report = repPersist.loadReport(name); context.setAttribute(WizardConstants.LOAD_REPORT, report); String sql = report.getSql(); if (sql == null) { sql = report.getQuery().toString(); } editor.setText(sql); parametersPanel.set(report.getParameters()); } else { context.setAttribute(WizardConstants.LOAD_REPORT, null); editor.setText(""); parametersPanel.set(new ArrayList<QueryParameter>()); } } }; sqlLabel = new JLabel("<html><b>Sql</b></html>"); easyPanel = new EasySelectColumnsPanel(); JPanel qPanel = new JPanel(new GridBagLayout()); JPanel radioPanel = new JPanel(); radioPanel.setLayout(new BoxLayout(radioPanel, BoxLayout.X_AXIS)); radioPanel.add(selectionRB); radioPanel.add(Box.createHorizontalStrut(5)); radioPanel.add(queryRB); radioPanel.add(Box.createHorizontalStrut(5)); radioPanel.add(editRB); qPanel.add(radioPanel, new GridBagConstraints(0, 0, 4, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); queryLabel = new JLabel(I18NSupport.getString("query.name")); qPanel.add(queryLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0)); qPanel.add(queryPanel, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 0, 0), 0, 0)); qPanel.add(sqlLabel, new GridBagConstraints(0, 2, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0)); qPanel.add(editor, new GridBagConstraints(0, 3, 3, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); qPanel.add(parametersPanel, new GridBagConstraints(3, 2, 1, 2, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0, 5, 5, 5), 0, 0)); qPanel.add(emptyLabel, new GridBagConstraints(0, 4, 4, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); qPanel.add(easyPanel, new GridBagConstraints(0, 2, 4, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); selection(); add(qPanel, BorderLayout.CENTER); }
From source file:ru.apertum.qsystem.client.forms.FReception.java
/** * Creates new form FReception//from w ww . j av a2s .com * * @param netProperty */ public FReception(IClientNetProperty netProperty) { this.netProperty = netProperty; initComponents(); setTitle(getTitle() + " " + Uses.getLocaleMessage("project.name" + FAbout.getCMRC_SUFF())); //NOI18N try { setIconImage(ImageIO .read(FAdmin.class.getResource("/ru/apertum/qsystem/client/forms/resources/monitor.png"))); //NOI18N } catch (IOException ex) { System.err.println(ex); } // . Escape // ? esc getRootPane().registerKeyboardAction((ActionEvent e) -> { setVisible(false); }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); // trayIcon, .. setSituation() ? tray final JFrame fr = this; tray = QTray.getInstance(fr, "/ru/apertum/qsystem/client/forms/resources/monitor.png", getTitle()); //NOI18N tray.addItem(getLocaleMessage("messages.tray.showClient"), (ActionEvent e) -> { setVisible(true); setState(JFrame.NORMAL); }); tray.addItem("-", (ActionEvent e) -> { }); tray.addItem(getLocaleMessage("messages.tray.close"), (ActionEvent e) -> { dispose(); System.exit(0); }); int ii = 1; final ButtonGroup bg = new ButtonGroup(); final String currLng = Locales.getInstance().getLangCurrName(); for (String lng : Locales.getInstance().getAvailableLocales()) { final JRadioButtonMenuItem item = new JRadioButtonMenuItem( org.jdesktop.application.Application.getInstance(ru.apertum.qsystem.QSystem.class).getContext() .getActionMap(FReception.class, fr).get("setCurrentLang")); //NOI18N bg.add(item); item.setSelected(lng.equals(currLng)); item.setText(lng); // NOI18N item.setName("QRadioButtonMenuItem" + (ii++)); // NOI18N menuLangs.add(item); } treeServices.addTreeSelectionListener((TreeSelectionEvent e) -> { serviceListChange(); }); // ?? ??. listUsers.addListSelectionListener((ListSelectionEvent e) -> { userListChange(); }); }
From source file:samples.graph.PluggableRendererDemo.java
/** * @param jp panel to which controls will be added *//*from w w w.j a va 2 s.co m*/ 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(this); v_stroke = new JCheckBox("<html>vertex selection<p>stroke highlighting</html>"); v_stroke.addActionListener(this); v_labels = new JCheckBox("show vertex ranks (voltages)"); v_labels.addActionListener(this); v_shape = new JCheckBox("vertex degree shapes"); v_shape.addActionListener(this); v_size = new JCheckBox("vertex voltage size"); v_size.addActionListener(this); v_size.setSelected(true); v_aspect = new JCheckBox("vertex degree ratio stretch"); v_aspect.addActionListener(this); v_small = new JCheckBox("filter vertices of 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); 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(this); shape_panel.add(fill_edges); shape_panel.setOpaque(true); e_color = new JCheckBox("edge weight highlighting"); e_color.addActionListener(this); e_labels = new JCheckBox("show edge weights"); 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); 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.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); 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()); } }); 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(this); 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); }
From source file:satalitelist.EdgeLabelDemo.java
/** * create an instance of a simple graph with controls to * demo the label positioning features//from w w w.j a va2s. c om * */ @SuppressWarnings("serial") public EdgeLabelDemo(StemAndCycleList al) { cities = (ArrayList<INode>) al.list; list = al; al.score = al.getCycleScore(); // create a simple graph for the demo graph = new SparseMultigraph<Integer, MyEdge>(); //Integer[] v = createVertices(7); fillSevenCitiesWithPrices(); for (INode n : cities) { graph.addVertex(Integer.parseInt(n.toString())); } createVertices(); //createEdges(v); Layout<Integer, MyEdge> layout = new FRLayout2<Integer, MyEdge>(graph); vv = new VisualizationViewer<Integer, MyEdge>(layout, new Dimension(1000, 800)); vv.setBackground(Color.white); vertexLabelRenderer = vv.getRenderContext().getVertexLabelRenderer(); edgeLabelRenderer = vv.getRenderContext().getEdgeLabelRenderer(); vv.getRenderContext().setEdgeLabelTransformer(new Transformer<MyEdge, String>() { public String transform(MyEdge i) { return i.toString(); } }); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<MyEdge>(vv.getPickedEdgeState(), Color.black, Color.cyan)); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<Integer>(vv.getPickedVertexState(), Color.red, Color.yellow)); // add my listener for ToolTips vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Integer>()); vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<MyEdge, Stroke>() { public Stroke transform(MyEdge i) { switch (i.kind) { case NORMAL: return new BasicStroke(2, 1, 1, 0, new float[] { 10, 0 }, 0); case VIRTUAL: return new BasicStroke(2, 1, 1, 0, new float[] { 5 }, 0); case INVISIBLE: return new BasicStroke(1, 1, 1, 0, new float[] { 1, 10 }, 0); } throw new RuntimeException("No such a type"); } }); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR); // create a frome to hold the graph final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); Container content = getContentPane(); content.add(panel); final DefaultModalGraphMouse<Integer, Number> graphMouse = new DefaultModalGraphMouse<Integer, Number>(); vv.setGraphMouse(graphMouse); 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 lineButton = new JRadioButton("Line"); lineButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<Integer, MyEdge>()); vv.repaint(); } } }); JRadioButton quadButton = new JRadioButton("QuadCurve"); quadButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<Integer, MyEdge>()); vv.repaint(); } } }); JRadioButton cubicButton = new JRadioButton("CubicCurve"); cubicButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve<Integer, MyEdge>()); vv.repaint(); } } }); radio.add(quadButton); radio.add(cubicButton); radio.add(lineButton); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); Box controls = Box.createHorizontalBox(); JPanel zoomPanel = new JPanel(new GridLayout(0, 1)); zoomPanel.setBorder(BorderFactory.createTitledBorder("Scale")); zoomPanel.add(plus); zoomPanel.add(minus); JPanel edgePanel = new JPanel(new GridLayout(0, 1)); edgePanel.setBorder(BorderFactory.createTitledBorder("EdgeType Type")); edgePanel.add(lineButton); edgePanel.add(quadButton); edgePanel.add(cubicButton); JPanel rotatePanel = new JPanel(); rotatePanel.setBorder(BorderFactory.createTitledBorder("Alignment")); rotatePanel.add(cycleLabel); rotatePanel.add(stemLabel); rotatePanel.add(otherEndLabel); JPanel labelPanel = new JPanel(new BorderLayout()); labelPanel.add(rotatePanel, BorderLayout.WEST); JPanel modePanel = new JPanel(new GridLayout(2, 1)); modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(graphMouse.getModeComboBox()); JPanel movePanel = new JPanel(new GridLayout(2, 1)); modePanel.setBorder(BorderFactory.createTitledBorder("Make move")); JButton button = new JButton("Make move"); button.addActionListener(new StemAndCycleAl()); modePanel.add(button); controls.add(zoomPanel); controls.add(edgePanel); controls.add(labelPanel); controls.add(modePanel); controls.add(movePanel); content.add(controls, BorderLayout.SOUTH); lineButton.setSelected(true); }
From source file:sc.fiji.kappa.gui.KappaMenuBar.java
/** * Creates a menu-bar and adds menu items to it *///w w w .j a va2 s . co m public KappaMenuBar(Context context, KappaFrame frame) { context.inject(this); this.frame = frame; // File chooser for curve data FileNameExtensionFilter kappaFilter = new FileNameExtensionFilter("Kappa Files", "kapp"); kappaLoad = new JFileChooser(); kappaLoad.setFileFilter(kappaFilter); kappaLoad.setDialogTitle("Load Existing Curve Data"); kappaSave = new JFileChooser(); kappaSave.setFileFilter(kappaFilter); kappaSave.setDialogTitle("Save Curve Data"); // Declares the file menu JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('F'); /* * // Menu Items for file operations // Creates a new file chooser. Same native * image support as ImageJ since ImageJ // libraries are used. kappaOpen = new * JFileChooser(); FileNameExtensionFilter filter = new * FileNameExtensionFilter("Image Files", "tif", "tiff", "jpeg", "jpg", "bmp", * "fits", "pgm", "ppm", "pbm", "gif", "png", "dic", "dcm", "dicom", "lsm", * "avi"); kappaOpen.setFileFilter(filter); * * JMenuItem openMenu = new JMenuItem("Open Image File"); * openMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, DEFAULT_MASK)); * openMenu.addActionListener(e -> { int returnVal = * kappaOpen.showOpenDialog(this.frame); if (returnVal == * JFileChooser.APPROVE_OPTION) { openImageFile(kappaOpen.getSelectedFile()); } * }); fileMenu.add(openMenu); */ JMenuItem openActiveMenu = new JMenuItem("Open Active Image"); openActiveMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, DEFAULT_MASK)); openActiveMenu.addActionListener(e -> { openActiveImage(context); }); fileMenu.add(openActiveMenu); fileMenu.addSeparator(); JMenuItem importROIsAsCurvesMenu = new JMenuItem("Import ROIs as curves"); importROIsAsCurvesMenu.addActionListener(e -> { importROIsAsCurves(context); }); fileMenu.add(importROIsAsCurvesMenu); fileMenu.addSeparator(); JMenuItem loadMenu = new JMenuItem("Load Curve Data"); loadMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, DEFAULT_MASK)); loadMenu.addActionListener(e -> { // Handle open button action. int returnVal = kappaLoad.showOpenDialog(this.frame); if (returnVal == JFileChooser.APPROVE_OPTION) { file = kappaLoad.getSelectedFile(); loadCurveFile(file); } }); fileMenu.add(loadMenu); JMenuItem saveMenu = new JMenuItem("Save Curve Data"); saveMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, DEFAULT_MASK)); saveMenu.addActionListener(e -> { String dirPath = frame.getImageStack().getOriginalFileInfo().directory; if (dirPath != null) { String kappaPath = FilenameUtils .removeExtension(frame.getImageStack().getOriginalFileInfo().fileName); kappaPath += ".kapp"; File fullPath = new File(dirPath, kappaPath); kappaSave.setSelectedFile(fullPath); } // Handles save button action. int returnVal = kappaSave.showSaveDialog(this.frame); if (returnVal == JFileChooser.APPROVE_OPTION) { file = kappaSave.getSelectedFile(); // Appends a .kapp if (!file.getPath().toLowerCase().endsWith(".kapp")) { file = new File(file.getPath() + ".kapp"); } saveCurveFile(file); } }); fileMenu.add(saveMenu); this.add(fileMenu); // Menu Items for all the tools JMenu toolMenu = new JMenu("Tools"); for (int i = 0; i < ToolPanel.NO_TOOLS; i++) { toolMenuItems[i] = new JMenuItem(ToolPanel.TOOL_MENU_NAMES[i]); toolMenuItems[i].setEnabled(false); toolMenuItems[i].setAccelerator(KeyStroke.getKeyStroke(ToolPanel.TOOL_MNEMONICS[i], 0)); final int j = i; toolMenuItems[i].addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { frame.getToolPanel().setSelected(j, true); frame.getScrollPane().setCursor(ToolPanel.TOOL_CURSORS[j]); } }); toolMenu.add(toolMenuItems[i]); } // We also add a menu item for deleting Bezier Curves via the Backspace key. setDelete(new JMenuItem("Delete Curves")); getDelete().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { frame.deleteCurve(); } }); getDelete().setEnabled(false); getDelete().setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)); toolMenu.addSeparator(); toolMenu.add(getDelete()); setEnter(new JMenuItem("Enter Curve")); getEnter().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { frame.enterCurve(); } }); getEnter().setEnabled(false); getEnter().setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)); toolMenu.add(getEnter()); fit = new JMenuItem("Fit Curve"); fit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { frame.fitCurves(); } }); fit.setEnabled(false); fit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, 0)); toolMenu.add(fit); toolMenu.addSeparator(); // TODO remove this later // JMenuItem runTestScript = new JMenuItem ("Run Testing Script"); // runTestScript.addActionListener (new ActionListener(){ // public void actionPerformed (ActionEvent event){ // try{frame.testingScript();} // catch(IOException e){System.out.println("Script Error");} // }}); // runTestScript.setAccelerator (KeyStroke.getKeyStroke(KeyEvent.VK_S, 0)); // toolMenu.add(runTestScript); JCheckBoxMenuItem toggleCtrlPtAdjustment = new JCheckBoxMenuItem("Enable Control Point Adjustment"); toggleCtrlPtAdjustment.setState(frame.isEnableCtrlPtAdjustment()); toggleCtrlPtAdjustment.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { frame.setEnableCtrlPtAdjustment(!frame.isEnableCtrlPtAdjustment()); ; } }); toggleCtrlPtAdjustment.setEnabled(true); toolMenu.add(toggleCtrlPtAdjustment); this.add(toolMenu); // Navigation Menu // TODO FIX action listeners to these. JMenu navigateMenu = new JMenu("Navigate"); prevFrame = new JMenuItem("Previous Frame"); nextFrame = new JMenuItem("Next Frame"); prevKeyframe = new JMenuItem("Previous Keyframe"); nextKeyframe = new JMenuItem("Next Keyframe"); prevFrame.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ActionEvent.ALT_MASK)); nextFrame.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, ActionEvent.ALT_MASK)); prevKeyframe.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, DEFAULT_MASK)); nextKeyframe.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, DEFAULT_MASK)); prevFrame.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { frame.getControlPanel().getCurrentLayerSlider() .setValue(Math.max(frame.getControlPanel().getCurrentLayerSlider().getValue() - 1, frame.getControlPanel().getCurrentLayerSlider().getMinimum())); } }); nextFrame.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { frame.getControlPanel().getCurrentLayerSlider() .setValue(Math.min(frame.getControlPanel().getCurrentLayerSlider().getValue() + 1, frame.getControlPanel().getCurrentLayerSlider().getMaximum())); } }); prevKeyframe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { } }); nextKeyframe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { } }); prevFrame.setEnabled(false); nextFrame.setEnabled(false); prevKeyframe.setEnabled(false); nextKeyframe.setEnabled(false); navigateMenu.add(prevFrame); navigateMenu.add(nextFrame); navigateMenu.add(prevKeyframe); navigateMenu.add(nextKeyframe); this.add(navigateMenu); // Image options. JMenu imageMenu = new JMenu("Image"); // Brightness and Contrast tool. Taken from ImageJ. adjustBrightnessContrast = new JMenuItem("Adjust Brightness/Contrast"); adjustBrightnessContrast.setEnabled(false); adjustBrightnessContrast.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ContrastAdjuster c = new ContrastAdjuster(frame); c.run("Brightness/Contrast...[C]"); } }); imageMenu.add(adjustBrightnessContrast); this.add(imageMenu); // Zoom-In and Zoom-Out Commands JMenu viewMenu = new JMenu("View"); zoomIn = new JMenuItem("Zoom In"); zoomOut = new JMenuItem("Zoom Out"); zoomIn.addActionListener(new ZoomInListener(frame.getControlPanel())); zoomOut.addActionListener(new ZoomOutListener(frame.getControlPanel())); zoomIn.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, DEFAULT_MASK)); zoomOut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, DEFAULT_MASK)); zoomIn.setEnabled(false); zoomOut.setEnabled(false); // Menu Item for showing bounding boxes setBoundingBoxMenu(new JCheckBoxMenuItem("Show Bounding Boxes")); getBoundingBoxMenu().setState(false); getBoundingBoxMenu().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent a) { frame.drawImageOverlay(); } }); getBoundingBoxMenu().setEnabled(false); // Menu Item for choosing the x-axis values for the curvature and intensity // display // For instance, you can display x vs. curvature, or current arc length vs // curvature, or the point index vs curvature // The default is the point index. distributionDisplay = DEFAULT_DISTRIBUTION_DISPLAY; JMenu xAxisSubmenu = new JMenu("Curve Distribution X-Axis:"); ButtonGroup xAxisGroup = new ButtonGroup(); JMenuItem xValue = new JCheckBoxMenuItem("X-Coordinate"); JMenuItem curveLength = new JCheckBoxMenuItem("Arc Length"); JMenuItem pointIndex = new JCheckBoxMenuItem("Point Index"); xAxisGroup.add(xValue); xAxisGroup.add(curveLength); xAxisGroup.add(pointIndex); xAxisSubmenu.add(xValue); xAxisSubmenu.add(curveLength); xAxisSubmenu.add(pointIndex); xValue.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent a) { distributionDisplay = 0; frame.getInfoPanel().updateHistograms(); } }); curveLength.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent a) { distributionDisplay = 1; frame.getInfoPanel().updateHistograms(); } }); pointIndex.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent a) { distributionDisplay = 2; frame.getInfoPanel().updateHistograms(); } }); if (DEFAULT_DISTRIBUTION_DISPLAY == 0) { xValue.setSelected(true); } else if (DEFAULT_DISTRIBUTION_DISPLAY == 1) { curveLength.setSelected(true); } else { pointIndex.setSelected(true); } // Menu Item for scaling curve strokes when zooming in or out setScaleCurvesMenu(new JCheckBoxMenuItem("Scale Curve Strokes")); getScaleCurvesMenu().setState(true); getScaleCurvesMenu().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent a) { frame.drawImageOverlay(); } }); getScaleCurvesMenu().setEnabled(false); // Menu Item for image antialiasing setAntialiasingMenu(new JCheckBoxMenuItem("Enable Antialiasing")); getAntialiasingMenu().setState(false); getAntialiasingMenu().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent a) { frame.setScaledImage(frame.getControlPanel().getScaleSlider().getValue() / 100.0); frame.drawImageOverlay(); } }); getAntialiasingMenu().setEnabled(false); // Menu Item for displaying tangent and normal curves. setTangentMenu(new JCheckBoxMenuItem("Show Tangent and Normal Vectors")); getTangentMenu().setState(false); getTangentMenu().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent a) { frame.drawImageOverlay(); } }); getTangentMenu().setEnabled(false); viewMenu.add(zoomIn); viewMenu.add(zoomOut); viewMenu.addSeparator(); viewMenu.add(xAxisSubmenu); viewMenu.addSeparator(); viewMenu.add(getScaleCurvesMenu()); viewMenu.add(getTangentMenu()); viewMenu.add(getBoundingBoxMenu()); viewMenu.add(getAntialiasingMenu()); this.add(viewMenu); // Sets a "Help" menu list JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic('H'); // Adds an "About" option to the menu list JMenuItem aboutMenuItem = new JMenuItem("About...", 'A'); aboutMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { JOptionPane.showMessageDialog(frame, "Developed by the Brouhard lab, 2016-2017.", KappaFrame.APPLICATION_NAME, JOptionPane.INFORMATION_MESSAGE); } }); // Adds a link to the User Manual JMenuItem userManualLink = new JMenuItem("User Manual"); userManualLink.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { try { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().browse(new URI( "https://dl.dropboxusercontent.com/u/157117/KappaFrame%20User%20Manual.pdf")); } } catch (Exception e) { System.out.println("Incorrect URL Syntax"); } ; } }); // Adds all newly created menu items to the "Help" list helpMenu.add(userManualLink); helpMenu.add(aboutMenuItem); this.add(helpMenu); }
From source file:se.llbit.chunky.renderer.ui.RenderControls.java
private JPanel buildSkyPane() { JLabel skyModeLbl = new JLabel("Sky Mode:"); skyModeCB.setModel(new DefaultComboBoxModel(Sky.SkyMode.values())); skyModeCB.addActionListener(skyModeListener); updateSkyMode();/* w ww.java 2 s .co m*/ JLabel skymapRotationLbl = new JLabel("Skymap rotation:"); skymapRotationSlider.setMinimum(1); skymapRotationSlider.setMaximum(100); skymapRotationSlider.addChangeListener(skyRotationListener); skymapRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap"); JLabel lightProbeRotationLbl = new JLabel("Skymap rotation:"); lightProbeRotationSlider.setMinimum(1); lightProbeRotationSlider.setMaximum(100); lightProbeRotationSlider.addChangeListener(skyRotationListener); lightProbeRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap"); JLabel skyboxRotationLbl = new JLabel("Skybox rotation:"); skyboxRotationSlider.setMinimum(1); skyboxRotationSlider.setMaximum(100); skyboxRotationSlider.addChangeListener(skyRotationListener); skyboxRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap"); updateSkyRotation(); skyHorizonOffset.update(); cloudSize.update(); cloudXOffset.update(); cloudYOffset.update(); cloudZOffset.update(); JLabel verticalResolutionLbl = new JLabel("Vertical resolution (degrees):"); ButtonGroup verticalResolution = new ButtonGroup(); v90Btn.setSelected(true); v180Btn.setSelected(false); verticalResolution.add(v90Btn); verticalResolution.add(v180Btn); v90Btn.addActionListener(v90Listener); v180Btn.addActionListener(v180Listener); updateVerticalResolution(); simulatedSkyPanel.setBorder(BorderFactory.createTitledBorder("Simulated Sky Settings")); GroupLayout simulatedSkyLayout = new GroupLayout(simulatedSkyPanel); simulatedSkyPanel.setLayout(simulatedSkyLayout); simulatedSkyLayout.setAutoCreateContainerGaps(true); simulatedSkyLayout.setAutoCreateGaps(true); simulatedSkyLayout.setHorizontalGroup(simulatedSkyLayout.createParallelGroup() .addGroup(skyHorizonOffset.horizontalGroup(simulatedSkyLayout))); simulatedSkyLayout.setVerticalGroup(simulatedSkyLayout.createSequentialGroup() .addGroup(skyHorizonOffset.verticalGroup(simulatedSkyLayout))); skymapPanel.setBorder(BorderFactory.createTitledBorder("Skymap Settings")); GroupLayout skymapLayout = new GroupLayout(skymapPanel); skymapPanel.setLayout(skymapLayout); skymapLayout.setAutoCreateContainerGaps(true); skymapLayout.setAutoCreateGaps(true); skymapLayout.setHorizontalGroup(skymapLayout.createParallelGroup().addComponent(loadSkymapBtn) .addGroup(skymapLayout.createSequentialGroup().addComponent(skymapRotationLbl) .addComponent(skymapRotationSlider)) .addGroup(skymapLayout.createSequentialGroup().addComponent(verticalResolutionLbl) .addPreferredGap(ComponentPlacement.RELATED).addComponent(v90Btn) .addPreferredGap(ComponentPlacement.RELATED).addComponent(v180Btn))); skymapLayout.setVerticalGroup(skymapLayout.createSequentialGroup().addComponent(loadSkymapBtn) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(skymapLayout.createParallelGroup(Alignment.BASELINE).addComponent(verticalResolutionLbl) .addComponent(v90Btn).addComponent(v180Btn)) .addPreferredGap(ComponentPlacement.RELATED).addGroup(skymapLayout.createParallelGroup() .addComponent(skymapRotationLbl).addComponent(skymapRotationSlider))); loadSkymapBtn.setText("Load Skymap"); loadSkymapBtn.setToolTipText("Use a panoramic skymap"); loadSkymapBtn.addActionListener(new SkymapTextureLoader(renderMan)); lightProbePanel.setBorder(BorderFactory.createTitledBorder("Spherical Skymap Settings")); GroupLayout lightProbeLayout = new GroupLayout(lightProbePanel); lightProbePanel.setLayout(lightProbeLayout); lightProbeLayout.setAutoCreateContainerGaps(true); lightProbeLayout.setAutoCreateGaps(true); lightProbeLayout.setHorizontalGroup(lightProbeLayout.createParallelGroup().addComponent(loadLightProbeBtn) .addGroup(lightProbeLayout.createSequentialGroup().addComponent(lightProbeRotationLbl) .addComponent(lightProbeRotationSlider))); lightProbeLayout.setVerticalGroup(lightProbeLayout.createSequentialGroup().addComponent(loadLightProbeBtn) .addPreferredGap(ComponentPlacement.RELATED).addGroup(lightProbeLayout.createParallelGroup() .addComponent(lightProbeRotationLbl).addComponent(lightProbeRotationSlider))); loadLightProbeBtn.setText("Load Spherical Skymap"); loadLightProbeBtn.setToolTipText("Select the spherical skymap to use"); loadLightProbeBtn.addActionListener(new SkymapTextureLoader(renderMan)); skyGradientPanel.setBorder(BorderFactory.createTitledBorder("Sky Gradient")); gradientEditor = new GradientEditor(); gradientEditor.addGradientListener(gradientListener); updateSkyGradient(); skyGradientPanel.add(gradientEditor); GroupLayout skyboxLayout = new GroupLayout(skyboxPanel); skyboxPanel.setLayout(skyboxLayout); skyboxPanel.setBorder(BorderFactory.createTitledBorder("Skybox")); JLabel skyboxLbl = new JLabel("Load skybox textures:"); JButton loadUpTexture = new JButton("Up"); loadUpTexture.setToolTipText("Load up texture"); loadUpTexture.setIcon(Icon.skyboxUp.imageIcon()); loadUpTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_UP)); JButton loadDownTexture = new JButton("Down"); loadDownTexture.setToolTipText("Load down texture"); loadDownTexture.setIcon(Icon.skyboxDown.imageIcon()); loadDownTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_DOWN)); JButton loadFrontTexture = new JButton("Front"); loadFrontTexture.setToolTipText("Load front (north) texture"); loadFrontTexture.setIcon(Icon.skyboxFront.imageIcon()); loadFrontTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_FRONT)); JButton loadBackTexture = new JButton("Back"); loadBackTexture.setToolTipText("Load back (south) texture"); loadBackTexture.setIcon(Icon.skyboxBack.imageIcon()); loadBackTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_BACK)); JButton loadRightTexture = new JButton("Right"); loadRightTexture.setToolTipText("Load right (east) texture"); loadRightTexture.setIcon(Icon.skyboxRight.imageIcon()); loadRightTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_RIGHT)); JButton loadLeftTexture = new JButton("Left"); loadLeftTexture.setToolTipText("Load left (west) texture"); loadLeftTexture.setIcon(Icon.skyboxLeft.imageIcon()); loadLeftTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_LEFT)); skyboxLayout.setAutoCreateContainerGaps(true); skyboxLayout.setAutoCreateGaps(true); skyboxLayout.setHorizontalGroup(skyboxLayout.createParallelGroup() .addGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxLbl) .addGroup(skyboxLayout.createParallelGroup().addComponent(loadUpTexture) .addComponent(loadFrontTexture).addComponent(loadRightTexture)) .addGroup(skyboxLayout.createParallelGroup().addComponent(loadDownTexture) .addComponent(loadBackTexture).addComponent(loadLeftTexture))) .addGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxRotationLbl) .addComponent(skyboxRotationSlider))); skyboxLayout.setVerticalGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxLbl) .addGroup(skyboxLayout.createParallelGroup().addComponent(loadUpTexture) .addComponent(loadDownTexture)) .addGroup(skyboxLayout.createParallelGroup().addComponent(loadFrontTexture) .addComponent(loadBackTexture)) .addGroup(skyboxLayout.createParallelGroup().addComponent(loadRightTexture) .addComponent(loadLeftTexture)) .addGroup(skyboxLayout.createParallelGroup().addComponent(skyboxRotationLbl) .addComponent(skyboxRotationSlider))); atmosphereEnabled.setText("enable atmosphere"); atmosphereEnabled.addActionListener(atmosphereListener); updateAtmosphereCheckBox(); transparentSky.setText("transparent sky"); transparentSky.addActionListener(transparentSkyListener); updateTransparentSky(); volumetricFogEnabled.setText("enable volumetric fog"); volumetricFogEnabled.addActionListener(volumetricFogListener); updateVolumetricFogCheckBox(); cloudsEnabled.setText("enable clouds"); cloudsEnabled.addActionListener(cloudsEnabledListener); updateCloudsEnabledCheckBox(); JPanel panel = new JPanel(); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout .createParallelGroup() .addGroup(layout.createSequentialGroup().addComponent(skyModeLbl) .addPreferredGap(ComponentPlacement.RELATED).addComponent(skyModeCB, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(simulatedSkyPanel).addComponent(skymapPanel).addComponent(lightProbePanel) .addComponent(skyGradientPanel).addComponent(skyboxPanel).addComponent(atmosphereEnabled) .addComponent(transparentSky).addComponent(volumetricFogEnabled).addComponent(cloudsEnabled) .addGroup(cloudSize.horizontalGroup(layout)).addGroup(cloudXOffset.horizontalGroup(layout)) .addGroup(cloudYOffset.horizontalGroup(layout)).addGroup(cloudZOffset.horizontalGroup(layout))) .addContainerGap()); layout.setVerticalGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(skyModeLbl) .addComponent(skyModeCB)) .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(simulatedSkyPanel) .addComponent(skymapPanel).addComponent(lightProbePanel).addComponent(skyGradientPanel) .addComponent(skyboxPanel).addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(atmosphereEnabled).addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(transparentSky).addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(volumetricFogEnabled).addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(cloudsEnabled).addPreferredGap(ComponentPlacement.RELATED) .addGroup(cloudSize.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED) .addGroup(cloudXOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED) .addGroup(cloudYOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED) .addGroup(cloudZOffset.verticalGroup(layout)).addContainerGap()); return panel; }
From source file:se.llbit.chunky.renderer.ui.tabs.SkyTab.java
public SkyTab(RenderControls renderControls) { super(renderControls); JLabel skyModeLbl = new JLabel("Sky Mode:"); skyModeCB.setModel(new DefaultComboBoxModel(Sky.SkyMode.values())); skyModeCB.addActionListener(skyModeListener); // Need to hide these to not warp the Swing layout: simulatedSkyPanel.setVisible(false); skymapPanel.setVisible(false);/*w w w.j a va2 s. c o m*/ lightProbePanel.setVisible(false); skyGradientPanel.setVisible(false); skyboxPanel.setVisible(false); JLabel skymapRotationLbl = new JLabel("Skymap rotation:"); skymapRotationSlider.setMinimum(1); skymapRotationSlider.setMaximum(100); skymapRotationSlider.addChangeListener(skyRotationListener); skymapRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap"); JLabel lightProbeRotationLbl = new JLabel("Skymap rotation:"); lightProbeRotationSlider.setMinimum(1); lightProbeRotationSlider.setMaximum(100); lightProbeRotationSlider.addChangeListener(skyRotationListener); lightProbeRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap"); JLabel skyboxRotationLbl = new JLabel("Skybox rotation:"); skyboxRotationSlider.setMinimum(1); skyboxRotationSlider.setMaximum(100); skyboxRotationSlider.addChangeListener(skyRotationListener); skyboxRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap"); JLabel verticalResolutionLbl = new JLabel("Vertical resolution (degrees):"); ButtonGroup verticalResolution = new ButtonGroup(); v90Btn.setSelected(true); v180Btn.setSelected(false); verticalResolution.add(v90Btn); verticalResolution.add(v180Btn); v90Btn.addActionListener(v90Listener); v180Btn.addActionListener(v180Listener); simulatedSkyPanel.setBorder(BorderFactory.createTitledBorder("Simulated Sky Settings")); GroupLayout simulatedSkyLayout = new GroupLayout(simulatedSkyPanel); simulatedSkyPanel.setLayout(simulatedSkyLayout); simulatedSkyLayout.setAutoCreateContainerGaps(true); simulatedSkyLayout.setAutoCreateGaps(true); simulatedSkyLayout.setHorizontalGroup(simulatedSkyLayout.createParallelGroup() .addGroup(skyHorizonOffset.horizontalGroup(simulatedSkyLayout))); simulatedSkyLayout.setVerticalGroup(simulatedSkyLayout.createSequentialGroup() .addGroup(skyHorizonOffset.verticalGroup(simulatedSkyLayout))); skymapPanel.setBorder(BorderFactory.createTitledBorder("Skymap Settings")); GroupLayout skymapLayout = new GroupLayout(skymapPanel); skymapPanel.setLayout(skymapLayout); skymapLayout.setAutoCreateContainerGaps(true); skymapLayout.setAutoCreateGaps(true); skymapLayout.setHorizontalGroup(skymapLayout.createParallelGroup().addComponent(loadSkymapBtn) .addGroup(skymapLayout.createSequentialGroup().addComponent(skymapRotationLbl) .addComponent(skymapRotationSlider)) .addGroup(skymapLayout.createSequentialGroup().addComponent(verticalResolutionLbl) .addPreferredGap(ComponentPlacement.RELATED).addComponent(v90Btn) .addPreferredGap(ComponentPlacement.RELATED).addComponent(v180Btn))); skymapLayout.setVerticalGroup(skymapLayout.createSequentialGroup().addComponent(loadSkymapBtn) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(skymapLayout.createParallelGroup(Alignment.BASELINE).addComponent(verticalResolutionLbl) .addComponent(v90Btn).addComponent(v180Btn)) .addPreferredGap(ComponentPlacement.RELATED).addGroup(skymapLayout.createParallelGroup() .addComponent(skymapRotationLbl).addComponent(skymapRotationSlider))); loadSkymapBtn.setText("Load Skymap"); loadSkymapBtn.setToolTipText("Use a panoramic skymap"); loadSkymapBtn.addActionListener(new SkymapTextureLoader(renderMan)); lightProbePanel.setBorder(BorderFactory.createTitledBorder("Spherical Skymap Settings")); GroupLayout lightProbeLayout = new GroupLayout(lightProbePanel); lightProbePanel.setLayout(lightProbeLayout); lightProbeLayout.setAutoCreateContainerGaps(true); lightProbeLayout.setAutoCreateGaps(true); lightProbeLayout.setHorizontalGroup(lightProbeLayout.createParallelGroup().addComponent(loadLightProbeBtn) .addGroup(lightProbeLayout.createSequentialGroup().addComponent(lightProbeRotationLbl) .addComponent(lightProbeRotationSlider))); lightProbeLayout.setVerticalGroup(lightProbeLayout.createSequentialGroup().addComponent(loadLightProbeBtn) .addPreferredGap(ComponentPlacement.RELATED).addGroup(lightProbeLayout.createParallelGroup() .addComponent(lightProbeRotationLbl).addComponent(lightProbeRotationSlider))); loadLightProbeBtn.setText("Load Spherical Skymap"); loadLightProbeBtn.setToolTipText("Select the spherical skymap to use"); loadLightProbeBtn.addActionListener(new SkymapTextureLoader(renderMan)); skyGradientPanel.setBorder(BorderFactory.createTitledBorder("Sky Gradient")); gradientEditor = new GradientEditor(); gradientEditor.addGradientListener(gradientListener); skyGradientPanel.add(gradientEditor); GroupLayout skyboxLayout = new GroupLayout(skyboxPanel); skyboxPanel.setLayout(skyboxLayout); skyboxPanel.setBorder(BorderFactory.createTitledBorder("Skybox")); JLabel skyboxLbl = new JLabel("Load skybox textures:"); JButton loadUpTexture = new JButton("Up"); loadUpTexture.setToolTipText("Load up texture"); loadUpTexture.setIcon(Icon.skyboxUp.imageIcon()); loadUpTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_UP)); JButton loadDownTexture = new JButton("Down"); loadDownTexture.setToolTipText("Load down texture"); loadDownTexture.setIcon(Icon.skyboxDown.imageIcon()); loadDownTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_DOWN)); JButton loadFrontTexture = new JButton("Front"); loadFrontTexture.setToolTipText("Load front (north) texture"); loadFrontTexture.setIcon(Icon.skyboxFront.imageIcon()); loadFrontTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_FRONT)); JButton loadBackTexture = new JButton("Back"); loadBackTexture.setToolTipText("Load back (south) texture"); loadBackTexture.setIcon(Icon.skyboxBack.imageIcon()); loadBackTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_BACK)); JButton loadRightTexture = new JButton("Right"); loadRightTexture.setToolTipText("Load right (east) texture"); loadRightTexture.setIcon(Icon.skyboxRight.imageIcon()); loadRightTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_RIGHT)); JButton loadLeftTexture = new JButton("Left"); loadLeftTexture.setToolTipText("Load left (west) texture"); loadLeftTexture.setIcon(Icon.skyboxLeft.imageIcon()); loadLeftTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_LEFT)); skyboxLayout.setAutoCreateContainerGaps(true); skyboxLayout.setAutoCreateGaps(true); skyboxLayout.setHorizontalGroup(skyboxLayout.createParallelGroup() .addGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxLbl) .addGroup(skyboxLayout.createParallelGroup().addComponent(loadUpTexture) .addComponent(loadFrontTexture).addComponent(loadRightTexture)) .addGroup(skyboxLayout.createParallelGroup().addComponent(loadDownTexture) .addComponent(loadBackTexture).addComponent(loadLeftTexture))) .addGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxRotationLbl) .addComponent(skyboxRotationSlider))); skyboxLayout.setVerticalGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxLbl) .addGroup(skyboxLayout.createParallelGroup().addComponent(loadUpTexture) .addComponent(loadDownTexture)) .addGroup(skyboxLayout.createParallelGroup().addComponent(loadFrontTexture) .addComponent(loadBackTexture)) .addGroup(skyboxLayout.createParallelGroup().addComponent(loadRightTexture) .addComponent(loadLeftTexture)) .addGroup(skyboxLayout.createParallelGroup().addComponent(skyboxRotationLbl) .addComponent(skyboxRotationSlider))); transparentSky.setText("transparent sky"); transparentSky.setToolTipText("Disables rendering the skybox"); transparentSky.addActionListener(transparentSkyListener); JLabel fogColorLbl = new JLabel( "<html>Hint: set fog density > 0.1 for thick fog,<br>set it < 0.1 for haze/atmosphere effect"); fogColorBtn.setIcon(Icon.colors.imageIcon()); fogColorBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ColorPicker picker = new ColorPicker(fogColorBtn, renderMan.scene().getFogColor()); picker.addColorListener(new ColorListener() { @Override public void onColorPicked(Vector3d color) { renderMan.scene().setFogColor(color); } }); } }); cloudsEnabled.setText("enable clouds"); cloudsEnabled.addActionListener(cloudsEnabledListener); GroupLayout layout = new GroupLayout(this); setLayout(layout); layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout .createParallelGroup() .addGroup(layout.createSequentialGroup().addComponent(skyModeLbl) .addPreferredGap(ComponentPlacement.RELATED).addComponent(skyModeCB, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(simulatedSkyPanel).addComponent(skymapPanel).addComponent(lightProbePanel) .addComponent(skyGradientPanel).addComponent(skyboxPanel).addComponent(transparentSky) .addComponent(cloudsEnabled).addGroup(cloudSize.horizontalGroup(layout)) .addGroup(cloudXOffset.horizontalGroup(layout)).addGroup(cloudYOffset.horizontalGroup(layout)) .addGroup(cloudZOffset.horizontalGroup(layout)).addGroup(fogDensity.horizontalGroup(layout)) .addGroup(layout.createSequentialGroup().addComponent(fogColorBtn) .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(fogColorLbl))) .addContainerGap()); layout.setVerticalGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(skyModeLbl) .addComponent(skyModeCB)) .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(simulatedSkyPanel) .addComponent(skymapPanel).addComponent(lightProbePanel).addComponent(skyGradientPanel) .addComponent(skyboxPanel).addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(transparentSky).addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(cloudsEnabled).addPreferredGap(ComponentPlacement.RELATED) .addGroup(cloudSize.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED) .addGroup(cloudXOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED) .addGroup(cloudYOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED) .addGroup(cloudZOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(fogDensity.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup().addComponent(fogColorBtn).addComponent(fogColorLbl)) .addContainerGap()); }
From source file:sim.graph.MyPluggableRendererDemo.java
/** * @param jp panel to which controls will be added */// w ww.j a va2s.c om protected void addBottomControls(/*final JPanel jp*/) { /*final JPanel*/ control_panel = new JPanel(); // jp.add(control_panel, BorderLayout.SOUTH); // control_panel.setLayout(new BorderLayout()); control_panel.setLayout(new FlowLayout()); 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("dimer coloring"); v_color.addActionListener(this); v_stroke = new JCheckBox("<html>vertex selection<p>stroke highlighting</html>"); v_stroke.addActionListener(this); v_labels = new JCheckBox("show vertex ranks (voltages)"); v_labels.addActionListener(this); v_shape = new JCheckBox("vertex degree shapes"); v_shape.addActionListener(this); v_size = new JCheckBox("vertex voltage size"); v_size.addActionListener(this); v_size.setSelected(true); v_aspect = new JCheckBox("vertex degree ratio stretch"); v_aspect.addActionListener(this); v_small = new JCheckBox("filter vertices of 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); 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(this); shape_panel.add(fill_edges); shape_panel.setOpaque(true); e_color = new JCheckBox("edge weight highlighting"); e_color.addActionListener(this); e_labels = new JCheckBox("show edge weights"); 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); 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.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); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(visViewer, 1.1f, visViewer.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(visViewer, 1 / 1.1f, visViewer.getCenter()); } }); 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(this); 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); }