List of usage examples for javax.swing Box add
public Component add(Component comp)
From source file:geovista.network.gui.NodeLinkView.java
protected void addControls(final JPanel jp) { // Satellite/* w w w. j a va 2s .c o m*/ // JComboBox modeBox = graphMouse.getModeComboBox(); // modeBox.addItemListener(((DefaultModalGraphMouse)satellite.getGraphMouse()).getModeListener()); // Control Panel jp.setBackground(Color.WHITE); jp.setLayout(new BorderLayout()); jp.add(vv, BorderLayout.CENTER); JPanel control_panel = new JPanel(new GridLayout(5, 1)); jp.add(control_panel, BorderLayout.EAST); // File_Layout Panel Class[] combos = getCombos(); final JComboBox jcb = new JComboBox(combos); jcb.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String valueString = value.toString(); valueString = valueString.substring(valueString.lastIndexOf('.') + 1); return super.getListCellRendererComponent(list, valueString, index, isSelected, cellHasFocus); } }); jcb.addActionListener(new LayoutChooser(jcb, vv)); jcb.setSelectedItem(FRLayout.class); final Box file_layout_panel = Box.createVerticalBox(); file_layout_panel.setBorder(BorderFactory.createTitledBorder("File_Layout")); final JComboBox graph_chooser = new JComboBox(g_names); graph_chooser.addActionListener(new GraphChooser(jcb)); JPanel layoutPanel = new JPanel(); jcb.setAlignmentX(Component.CENTER_ALIGNMENT); layoutPanel.add(jcb); graph_chooser.setAlignmentX(Component.CENTER_ALIGNMENT); layoutPanel.add(graph_chooser); file_layout_panel.add(layoutPanel); // Basic Operation Panel 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()); } }); JButton reset = new JButton("reset"); reset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Layout<Integer, Number> layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if (relaxer != null) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); // Tranform and picking part final DefaultModalGraphMouse<Integer, Number> graphMouse = new DefaultModalGraphMouse<Integer, Number>(); vv.setGraphMouse(graphMouse); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(((DefaultModalGraphMouse<Integer, Number>) vv.getGraphMouse()).getModeListener()); JButton collapse = new JButton("Collapse"); JButton expand = new JButton("Expand"); final Box basic_panel = Box.createVerticalBox(); basic_panel.setBorder(BorderFactory.createTitledBorder("Basic_Operation")); JPanel zoomPanel = new JPanel(); // plus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(plus); // minus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(minus); // modeBox.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(modeBox); // reset.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(reset); // collapse.setAlignmentY(Component.CENTER_ALIGNMENT); zoomPanel.add(collapse); // expand.setAlignmentY(Component.CENTER_ALIGNMENT); zoomPanel.add(expand); basic_panel.add(zoomPanel); // Vertex Part String[] vertexScoreType = { "VertexScore", "Degree", "BarycenterScorer", "BetweennessCentrality", "ClosenessCentrality", "DistanceCentralityScorer", "EigenvectorCentrality" }; final JComboBox vertexScoreList = new JComboBox(vertexScoreType); vertexScoreList.setSelectedIndex(0); vertexScoreList.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { // Renderer.VertexLabel.Position position = // (Renderer.VertexLabel.Position)e.getItem(); // vv.getRenderer().getVertexLabelRenderer().setPosition(position); if (vertexScoreList.getSelectedIndex() == 0) { // vertexScores = new VertexScoreTransformer<Integer, // Double>(voltage_scores); // vv.getRenderContext().setVertexShapeTransformer(new // ConstantTransformer(null)); // vssa.setScaling(false); vv.getRenderContext().setVertexLabelTransformer(nonvertexLabel); vv.repaint(); } if (vertexScoreList.getSelectedIndex() == 1) { // vertexScores = new VertexScoreTransformer<Integer, // Double>(degreeScorer); /* * vssa = new * VertexShapeSizeAspect<Integer,Number>((Graph<Integer * ,Number>)g, transformerDegree); * vv.getRenderContext().setVertexShapeTransformer(vssa); * vssa.setScaling(true); */ vv.getRenderContext().setVertexLabelTransformer(vertexLabelDegree); vv.repaint(); } if (vertexScoreList.getSelectedIndex() == 2) { vssa = new VertexShapeSizeAspect<Integer, Number>((Graph<Integer, Number>) g, transformerBarycenter); vv.getRenderContext().setVertexShapeTransformer(vssa); vssa.setScaling(true); vv.getRenderContext().setVertexLabelTransformer(vertexLabelBarycenter); vv.repaint(); } if (vertexScoreList.getSelectedIndex() == 3) { // betweennessCentrality= new BetweennessCentrality(g); // voltages = new VertexScoreTransformer<Integer, // Double>(betweennessCentrality); vssa = new VertexShapeSizeAspect<Integer, Number>((Graph<Integer, Number>) g, transformerBetweenness); vv.getRenderContext().setVertexShapeTransformer(vssa); vssa.setScaling(true); vv.getRenderContext().setVertexLabelTransformer(vertexLabelBetweenness); vv.repaint(); } if (vertexScoreList.getSelectedIndex() == 4) { vssa = new VertexShapeSizeAspect<Integer, Number>((Graph<Integer, Number>) g, transformerCloseness); vv.getRenderContext().setVertexShapeTransformer(vssa); vssa.setScaling(true); vv.getRenderContext().setVertexLabelTransformer(vertexLabelCloseness); vv.repaint(); } if (vertexScoreList.getSelectedIndex() == 5) { vssa = new VertexShapeSizeAspect<Integer, Number>((Graph<Integer, Number>) g, transformerDistanceCentrality); vv.getRenderContext().setVertexShapeTransformer(vssa); vssa.setScaling(true); vv.getRenderContext().setVertexLabelTransformer(vertexLabelDistanceCentrality); vv.repaint(); } if (vertexScoreList.getSelectedIndex() == 6) { vssa = new VertexShapeSizeAspect<Integer, Number>((Graph<Integer, Number>) g, transformerEigenvector); vv.getRenderContext().setVertexShapeTransformer(vssa); vssa.setScaling(true); vv.getRenderContext().setVertexLabelTransformer(vertexLabelEigenvector); vv.repaint(); } } }); // cb.setSelectedItem(Renderer.VertexLabel.Position.SE); /* * v_shape = new JCheckBox("shape by degree"); * v_shape.addActionListener(this); v_size = new * JCheckBox("size by vertexScores"); v_size.addActionListener(this); * v_size.setSelected(true); v_aspect = new * JCheckBox("stretch by degree ratio"); * v_aspect.addActionListener(this); */ v_small = new JCheckBox("filter when degree < " + VertexDisplayPredicate.MIN_DEGREE); v_small.addActionListener(this); e_labels = new JCheckBox("show edge labels"); e_labels.addActionListener(this); // Vertex Panel final Box vertex_panel = Box.createVerticalBox(); vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices")); // vertex_panel.add(v_stroke); vertex_panel.add(vertexScoreList); // vertex_panel.add(v_degree_labels); /* * vertex_panel.add(v_shape); vertex_panel.add(v_size); * vertex_panel.add(v_aspect); */ vertex_panel.add(v_small); // Edge Part final Box edge_panel = Box.createVerticalBox(); edge_panel.setBorder(BorderFactory.createTitledBorder("Edges")); edge_panel.add(e_labels); final JToggleButton groupVertices = new JToggleButton("Group Clusters"); // Create slider to adjust the number of edges to remove when clustering final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL); edgeBetweennessSlider.setBackground(Color.WHITE); edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50)); edgeBetweennessSlider.setPaintTicks(true); edgeBetweennessSlider.setMaximum(g.getEdgeCount()); edgeBetweennessSlider.setMinimum(0); edgeBetweennessSlider.setValue(0); edgeBetweennessSlider.setMajorTickSpacing(10); edgeBetweennessSlider.setPaintLabels(true); edgeBetweennessSlider.setPaintTicks(true); // Cluster Part final Box cluster_panel = Box.createVerticalBox(); cluster_panel.setBorder(BorderFactory.createTitledBorder("Cluster")); cluster_panel.add(edgeBetweennessSlider); final String COMMANDSTRING = "Edges removed for clusters: "; final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue(); final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize); cluster_panel.setBorder(sliderBorder); cluster_panel.add(Box.createVerticalGlue()); groupVertices.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors, e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected()); edgeBetweennessSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (!source.getValueIsAdjusting()) { int numEdgesToRemove = source.getValue(); clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected()); sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue()); cluster_panel.repaint(); vv.validate(); vv.repaint(); } } }); cluster_panel.add(groupVertices); control_panel.add(file_layout_panel); control_panel.add(vertex_panel); control_panel.add(edge_panel); control_panel.add(cluster_panel); control_panel.add(basic_panel); }
From source file:savant.view.swing.Savant.java
/** * == [[ DOCKING ]] == Components (such as frames, the Task Pane, etc.) can * be docked to regions of the UI/*from w w w .j av a 2s. c om*/ */ private void initDocking() { JPanel masterPlaceholderPanel = new JPanel(); masterPlaceholderPanel.setLayout(new BorderLayout()); panel_main.setLayout(new BorderLayout()); panel_main.add(masterPlaceholderPanel, BorderLayout.CENTER); auxDockingManager = new DefaultDockingManager(this, masterPlaceholderPanel); masterPlaceholderPanel.setBackground(ColourSettings.getColor(ColourKey.SPLITTER)); auxDockingManager.setSidebarRollover(false); auxDockingManager.getWorkspace().setBackground(ColourSettings.getColor(ColourKey.SPLITTER)); auxDockingManager.setInitSplitPriority(DockingManager.SPLIT_EAST_SOUTH_WEST_NORTH); JPanel trackPanel = new JPanel(); trackPanel.setLayout(new BorderLayout()); auxDockingManager.getWorkspace().add(trackPanel, BorderLayout.CENTER); trackDockingManager = new DefaultDockingManager(this, trackPanel); trackPanel.setBackground(ColourSettings.getColor(ColourKey.SPLITTER)); trackDockingManager.getWorkspace().setBackground(ColourSettings.getColor(ColourKey.SPLITTER)); trackDockingManager.getWorkspace().setBackground(Color.red); trackDockingManager.setInitNorthSplit(JideSplitPane.VERTICAL_SPLIT); auxDockingManager.setShowInitial(false); trackDockingManager.setShowInitial(false); auxDockingManager.loadLayoutData(); trackDockingManager.loadLayoutData(); rangeSelector = new RangeSelectionPanel(); rangeSelector.setPreferredSize(new Dimension(10000, 23)); rangeSelector.setMaximumSize(new Dimension(10000, 23)); locationController.addListener(rangeSelector); rangeSelector.setVisible(false); ruler = new Ruler(); ruler.setPreferredSize(new Dimension(10000, 23)); ruler.setMaximumSize(new Dimension(10000, 23)); ruler.setVisible(false); Box box2 = Box.createVerticalBox(); box2.add(rangeSelector); box2.add(ruler); trackPanel.add(box2, BorderLayout.NORTH); trackBackground = new JPanel(); trackBackground.setBackground(Color.darkGray); trackBackground.setLayout(new BorderLayout()); trackDockingManager.getWorkspace().add(trackBackground); trackDockingManager.setAllowedDockSides(DockContext.DOCK_SIDE_HORIZONTAL); }
From source file:satalitelist.EdgeLabelDemo.java
/** * create an instance of a simple graph with controls to * demo the label positioning features//from ww w .j ava 2 s .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:org.neuroph.netbeans.main.easyneurons.NeuralGraphRenderer.java
/** * @param jp/*from ww w . jav a2s . co m*/ * panel to which controls will be added */ protected void addControls(final JPanel jp) { final JPanel control_panel = new JPanel(); jp.add(control_panel, BorderLayout.EAST); control_panel.setLayout(new GridBagLayout()); java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 5); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; // control_panel.setBackground(new Color(00, 255, 00)); final Box vertex_panel = Box.createVerticalBox(); vertex_panel.setBorder(BorderFactory.createTitledBorder("Neurons")); final Box edge_panel = Box.createVerticalBox(); edge_panel.setBorder(BorderFactory.createTitledBorder("Connections")); final Box edges_and_vertex_panel = Box.createVerticalBox(); // Box zoom_and_mode_panel = Box.createVerticalBox(); // zoom_and_mode_panel.setBorder(BorderFactory.createTitledBorder("Other controls")); // final Box layout_panel = Box.createVerticalBox(); // layout_panel.setBorder(BorderFactory.createTitledBorder("Layout")); // JPanel zoom_and_mode_panel = new JPanel(); // zoom_and_mode_panel.setLayout(new GridBagLayout() ); // //GridLayout(3,1) // zoom_and_mode_panel.setBackground(new Color(0,255,0)); edges_and_vertex_panel.add(vertex_panel); edges_and_vertex_panel.add(edge_panel); // edges_and_vertex_panel.add(layout_panel); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; control_panel.add(edges_and_vertex_panel, gridBagConstraints); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; // control_panel.add(layout_panel, gridBagConstraints); // originalni layout // control_panel.add(vertex_panel, BorderLayout.WEST); // control_panel.add(edge_panel, BorderLayout.EAST); // control_panel.add(edges_and_vertex_panel, BorderLayout.CENTER); // set up vertex controls v_color = new JCheckBox("vertex seed coloring"); v_color.addActionListener(this); // v_stroke = new JCheckBox("<html>stroke highlight selected</html>"); // v_stroke.addActionListener(this); v_shape = new JCheckBox("vertex degree shapes"); v_shape.addActionListener(this); v_size = new JCheckBox("activation size"); v_size.addActionListener(this); v_size.setSelected(false); 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_labels); // vertex_panel.add(v_shape); vertex_panel.add(v_size); // vertex_panel.add(v_aspect); // vertex_panel.add(v_small); // vertex_panel.add(v_stroke); // 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("Connection 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("weight highlighting"); e_color.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); // Class<?>[] combos = getLayoutOptions(); // final JComboBox layoutCombo = new JComboBox(combos); // // use a renderer to shorten the layout name presentation // layoutCombo.setRenderer(new DefaultListCellRenderer() { // public Component getListCellRendererComponent(JList list, // Object value, int index, boolean isSelected, // boolean cellHasFocus) { // String valueString = value.toString(); // valueString = valueString.substring(valueString // .lastIndexOf('.') + 1); // return super.getListCellRendererComponent(list, valueString, // index, isSelected, cellHasFocus); // } // }); // layoutCombo.addActionListener(new LayoutChooser(layoutCombo, vv)); //// UNDO: layoutCombo.setSelectedItem(FRLayout.class); // layout_panel.add(layoutCombo); // 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() { @Override public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JPanel zoomPanel = new JPanel(); zoomPanel.setAlignmentX(Component.RIGHT_ALIGNMENT); zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom")); zoomPanel.add(plus); zoomPanel.add(minus); gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 5); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.setAlignmentX(Component.RIGHT_ALIGNMENT); JPanel modePanel = new JPanel(new BorderLayout()) { @Override public Dimension getMaximumSize() { return getPreferredSize(); } }; modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; control_panel.add(modePanel, gridBagConstraints); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 3; control_panel.add(zoomPanel, gridBagConstraints); // add font control to center panel font = new JCheckBox("bold text"); font.addActionListener(this); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; control_panel.add(font, gridBagConstraints); }
From source file:EdgeLabelDemo.java
/** * create an instance of a simple graph with controls to * demo the label positioning features//w w w . jav a2s. c o m * */ @SuppressWarnings("serial") public EdgeLabelDemo() { // create a simple graph for the demo graph = new SparseMultigraph<Integer, Number>(); Integer[] v = createVertices(3); createEdges(v); Layout<Integer, Number> layout = new CircleLayout<Integer, Number>(graph); vv = new VisualizationViewer<Integer, Number>(layout, new Dimension(600, 400)); vv.setBackground(Color.white); vertexLabelRenderer = vv.getRenderContext().getVertexLabelRenderer(); edgeLabelRenderer = vv.getRenderContext().getEdgeLabelRenderer(); Transformer<Number, String> stringer = new Transformer<Number, String>() { public String transform(Number e) { return "Edge:" + graph.getEndpoints(e).toString(); } }; vv.getRenderContext().setEdgeLabelTransformer(stringer); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan)); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<Integer>(vv.getPickedVertexState(), Color.red, Color.yellow)); // add my listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Integer>()); // 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, Number>()); 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, Number>()); 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, Number>()); vv.repaint(); } } }); radio.add(lineButton); radio.add(quadButton); radio.add(cubicButton); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); JCheckBox rotate = new JCheckBox("<html><center>EdgeType<p>Parallel</center></html>"); rotate.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { AbstractButton b = (AbstractButton) e.getSource(); edgeLabelRenderer.setRotateEdgeLabels(b.isSelected()); vv.repaint(); } }); rotate.setSelected(true); MutableDirectionalEdgeValue mv = new MutableDirectionalEdgeValue(.5, .7); vv.getRenderContext().setEdgeLabelClosenessTransformer(mv); JSlider directedSlider = new JSlider(mv.getDirectedModel()) { public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.width /= 2; return d; } }; JSlider undirectedSlider = new JSlider(mv.getUndirectedModel()) { public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.width /= 2; return d; } }; JSlider edgeOffsetSlider = new JSlider(0, 50) { public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.width /= 2; return d; } }; edgeOffsetSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider s = (JSlider) e.getSource(); AbstractEdgeShapeTransformer<Integer, Number> aesf = (AbstractEdgeShapeTransformer<Integer, Number>) vv .getRenderContext().getEdgeShapeTransformer(); aesf.setControlOffsetIncrement(s.getValue()); vv.repaint(); } }); 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(rotate); JPanel labelPanel = new JPanel(new BorderLayout()); JPanel sliderPanel = new JPanel(new GridLayout(3, 1)); JPanel sliderLabelPanel = new JPanel(new GridLayout(3, 1)); JPanel offsetPanel = new JPanel(new BorderLayout()); offsetPanel.setBorder(BorderFactory.createTitledBorder("Offset")); sliderPanel.add(directedSlider); sliderPanel.add(undirectedSlider); sliderPanel.add(edgeOffsetSlider); sliderLabelPanel.add(new JLabel("Directed", JLabel.RIGHT)); sliderLabelPanel.add(new JLabel("Undirected", JLabel.RIGHT)); sliderLabelPanel.add(new JLabel("Edges", JLabel.RIGHT)); offsetPanel.add(sliderLabelPanel, BorderLayout.WEST); offsetPanel.add(sliderPanel); labelPanel.add(offsetPanel); labelPanel.add(rotatePanel, BorderLayout.WEST); JPanel modePanel = new JPanel(new GridLayout(2, 1)); modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(graphMouse.getModeComboBox()); controls.add(zoomPanel); controls.add(edgePanel); controls.add(labelPanel); controls.add(modePanel); content.add(controls, BorderLayout.SOUTH); quadButton.setSelected(true); }
From source file:com.diversityarrays.kdxplore.trials.TrialExplorerPanel.java
public TrialExplorerPanel(KdxApp app, KdxPluginInfo pluginInfo, KDXDeviceService deviceService, TrialExplorerManager manager, OfflineData offlineData, DriverType dType, ImageIcon barcodeIcon, ClientUrlChanger clientUrlChanger, Consumer<Void> trialsChangedConsumer, Consumer<Collection<Trait>> traitRemovalHandler) { super(new BorderLayout()); this.kdxApp = app; this.messagePrinter = pluginInfo.getMessagePrinter(); this.messageLogger = pluginInfo.getMessageLogger(); this.windowOpener = pluginInfo.getWindowOpener(); this.backgroundRunner = pluginInfo.getBackgroundRunner(); this.clientProvider = pluginInfo.getClientProvider(); this.userDataFolder = pluginInfo.getUserDataFolder(); this.kdxDeviceService = deviceService; this.trialsChangedConsumer = trialsChangedConsumer; this.traitRemovalHandler = traitRemovalHandler; Predicate<SeedPrepHarvestService> onHarvestFound = new Predicate<SeedPrepHarvestService>() { @Override// w w w . j av a2 s . com public boolean test(SeedPrepHarvestService t) { seedPrepHarvestService = t; return false; } }; Shared.detectServices(SeedPrepHarvestService.class, onHarvestFound, SEEDPREP_HARVEST_SERVICE_IMPL_CLASSNAME); if (this.seedPrepHarvestService != null) { PreferenceCollection pc = seedPrepHarvestService.getPreferenceCollection(kdxApp); if (pc != null) { KdxplorePreferences.getInstance().addPreferenceCollection(pc); } } PreferenceCollection pc = BarcodePreferences.getInstance().getPreferenceCollection(app, "Barcode"); if (pc != null) { KdxplorePreferences.getInstance().addPreferenceCollection(pc); } this.trialExplorerManager = manager; this.clientUrlChanger = clientUrlChanger; this.driverType = dType; this.offlineData = offlineData; this.pluginInfo = pluginInfo; this.trialOverviewPanel = new TrialOverviewPanel("Trials Available", offlineData, trialExplorerManager, flth, messagePrinter, onTrialSelected); this.trialDetailsPanel = new TrialDetailsPanel(windowOpener, messagePrinter, backgroundRunner, offlineData, editTrialAction, seedPrepAction, harvestAction, uploadTrialAction, refreshTrialInfoAction, barcodeIcon, checkIfEditorActive, onTraitInstancesRemoved); // addTrialsAction.setEnabled(false); currentTrialCardPanel.add( // NOTE: the null introduces a spacer new JustLabelPanel(new String[] { Msg.HTML_NO_TRIALS_LOADED() }, addTrialsAction), CARD_NO_TRIALS_LOADED); currentTrialCardPanel.add(new JustLabelPanel(new String[] { Msg.HTML_NO_TRIAL_SELECTED() }), CARD_NO_TRIAL_SELECTED); currentTrialCardPanel.add(trialDetailsPanel, CARD_TRIAL); currentTrialCardPanel.add(errorsGettingTrialData, CARD_ERRORS_GETTING_TRIAL_DATA); offlineData.addOfflineDataChangeListener(offlineDataChangeListener); // KDClientUtils.initAction(ImageId.EXPAND_ALL, expandAllAction, // "Expand All"); // KDClientUtils.initAction(ImageId.COLLAPSE_ALL, collapseAllAction, // "Collapse All"); KDClientUtils.initAction(ImageId.TRASH_24, removeTrialAction, "<HTML>Remove Trial from Offline storage<BR>(Shift-Click to also remove Traits)"); // TODO i18n removeTrialAction.setEnabled(false); KDClientUtils.initAction(ImageId.ADD_TRIALS_24, addTrialsAction, ADD_TRIALS); addDatabaseTrialsButton = new JButton(addTrialsAction); KDClientUtils.initAction(ImageId.EDIT_BLUE_24, editTrialAction, "Edit current Trial"); // TODO i18n editTrialAction.setEnabled(false); KDClientUtils.initAction(ImageId.UPLOAD_24, uploadTrialAction, "Store Trial in Database"); // TODO i18n uploadTrialAction.setEnabled(false); KDClientUtils.initAction(ImageId.GET_TRIALINFO_24, refreshTrialInfoAction, REFRESH_TRIAL_INFO + " from Database"); // TODO // i18n refreshTrialInfoAction.setEnabled(false); KdxploreConfig config = KdxploreConfig.getInstance(); KDClientUtils.initAction(ImageId.SEED_PREP_24, seedPrepAction, "Seed Preparation Wizard" + AbstractMsg.BETA_SUFFIX); // TODO // i18n seedPrepAction.setEnabled(0 != (CONFIG_FLAG_SEEDPREP & config.getFlags())); KDClientUtils.initAction(ImageId.HARVEST_WHEAT_24, harvestAction, "Harvest Wizard" + AbstractMsg.BETA_SUFFIX); // TODO i18n harvestAction.setEnabled(0 != (CONFIG_FLAG_HARVEST & config.getFlags())); @SuppressWarnings("rawtypes") DartEntityFeature[] descriptors = DartEntityBeanRegistry.TRIAL_BEAN_INFO.findDescriptors( Trial.COLNAME_TRIAL_NAME, Trial.COLNAME_TRIAL_ACRONYM, Trial.COLNAME_ORGANISM_TYPE, Trial.COLNAME_TRIAL_LAYOUT); // trialOverviewPanel.initialiseStructure(descriptors); trialOverviewPanel.setTransferHandler(flth); trialOverviewPanel.addActionListener(trialOverviewActionListener); trialOverviewPanel.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { updateCurrentTrial(); } } }); // trialListSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, // new JScrollPane(trialOverviewPanel), // currentTrialCardPanel); // trialListSplit.setResizeWeight(0.7); // trialListSplit.setOneTouchExpandable(true); Box leftButtons = Box.createHorizontalBox(); leftButtons.add(addDatabaseTrialsButton); leftButtons.add(Box.createHorizontalGlue()); leftButtons.add(new JButton(removeTrialAction)); // TODO enable this after fixing the // use of SampleGroup in the wizard // importCsvAction.setEnabled(false); // leftButtons.add(new JButton(importCsvAction)); // leftButtons.add(Box.createHorizontalGlue()); JPanel left = new JPanel(new BorderLayout()); left.add(leftButtons, BorderLayout.NORTH); left.add(trialOverviewPanel, BorderLayout.CENTER); // trialTable.setDefaultRenderer(Integer.class, new // NumberCellRenderer()); // trialTable.setDefaultRenderer(String.class, new // StringCellRenderer(trialTableModel)); lrSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, createCurrentTrialPanel()); lrSplitPane.setResizeWeight(0.5); lrSplitPane.setOneTouchExpandable(true); add(lrSplitPane, BorderLayout.CENTER); // GuiUtil.setVisibleRowCount(todoTable, 6); }
From source file:org.forester.archaeopteryx.ControlPanel.java
void addSecondLevelJCheckBox(final JCheckBox jcb, final JPanel p) { jcb.setFocusPainted(false);/*from ww w. j a v a 2 s.c om*/ jcb.setFont(ControlPanel.jcb_font); if (!_configuration.isUseNativeUI()) { jcb.setBackground(ControlPanel.jcb_background_color); jcb.setForeground(ControlPanel.jcb_text_color); } Box box = Box.createHorizontalBox(); p.setBackground(background_color); box.add(Box.createRigidArea(new Dimension(12, 0))); jcb.setVisible(_color_branches_cb.isSelected()); box.add(jcb); p.add(box, "Center"); jcb.addActionListener(this); }
From source file:org.forester.archaeopteryx.ControlPanel.java
void addSecondLevelJCheckBoxWithSlider(final JCheckBox jcb, final JPanel p) { jcb.setFocusPainted(false);//from ww w. java 2s . co m jcb.setFont(ControlPanel.jcb_font); if (!_configuration.isUseNativeUI()) { jcb.setBackground(ControlPanel.jcb_background_color); jcb.setForeground(ControlPanel.jcb_text_color); } Box box = Box.createHorizontalBox(); p.setBackground(background_color); box.add(Box.createRigidArea(new Dimension(12, 0))); jcb.setVisible(_color_branches_cb.isSelected()); box.add(jcb); buildJSlider(60, _slider_min, _slider_max); getColorBranchesEdplSlider().setVisible(_color_branches_cb.isSelected()); getColorBranchesEdplSlider().setEnabled(_color_branches_edpl.isSelected()); box.add(getColorBranchesEdplSlider()); p.add(box, "Center"); jcb.addActionListener(this); }
From source file:samples.graph.PluggableRendererDemo.java
/** * @param jp panel to which controls will be added */// ww w . j av a 2 s. com 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:test.visualization.PluggableRendererDemo.java
/** * @param jp panel to which controls will be added *///from w ww .j av a2s .c o m @SuppressWarnings("serial") protected void addBottomControls(final JPanel jp) { final JPanel control_panel = new JPanel(); jp.add(control_panel, BorderLayout.EAST); control_panel.setLayout(new BorderLayout()); final Box vertex_panel = Box.createVerticalBox(); vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices")); final Box edge_panel = Box.createVerticalBox(); edge_panel.setBorder(BorderFactory.createTitledBorder("Edges")); final Box both_panel = Box.createVerticalBox(); control_panel.add(vertex_panel, BorderLayout.NORTH); control_panel.add(edge_panel, BorderLayout.SOUTH); control_panel.add(both_panel, BorderLayout.CENTER); // set up vertex controls v_color = new JCheckBox("seed highlight"); v_color.addActionListener(this); v_stroke = new JCheckBox("stroke highlight on selection"); v_stroke.addActionListener(this); v_labels = new JCheckBox("show voltage values"); v_labels.addActionListener(this); v_shape = new JCheckBox("shape by degree"); v_shape.addActionListener(this); v_size = new JCheckBox("size by voltage"); v_size.addActionListener(this); v_size.setSelected(true); v_aspect = new JCheckBox("stretch by degree ratio"); v_aspect.addActionListener(this); v_small = new JCheckBox("filter when degree < " + VertexDisplayPredicate.MIN_DEGREE); v_small.addActionListener(this); vertex_panel.add(v_color); vertex_panel.add(v_stroke); vertex_panel.add(v_labels); vertex_panel.add(v_shape); vertex_panel.add(v_size); vertex_panel.add(v_aspect); vertex_panel.add(v_small); // set up edge controls JPanel gradient_panel = new JPanel(new GridLayout(1, 0)); gradient_panel.setBorder(BorderFactory.createTitledBorder("Edge paint")); no_gradient = new JRadioButton("Solid color"); no_gradient.addActionListener(this); no_gradient.setSelected(true); // gradient_absolute = new JRadioButton("Absolute gradient"); // gradient_absolute.addActionListener(this); gradient_relative = new JRadioButton("Gradient"); gradient_relative.addActionListener(this); ButtonGroup bg_grad = new ButtonGroup(); bg_grad.add(no_gradient); bg_grad.add(gradient_relative); //bg_grad.add(gradient_absolute); gradient_panel.add(no_gradient); //gradientGrid.add(gradient_absolute); gradient_panel.add(gradient_relative); JPanel shape_panel = new JPanel(new GridLayout(3, 2)); shape_panel.setBorder(BorderFactory.createTitledBorder("Edge shape")); e_line = new JRadioButton("line"); e_line.addActionListener(this); e_line.setSelected(true); // e_bent = new JRadioButton("bent line"); // e_bent.addActionListener(this); e_wedge = new JRadioButton("wedge"); e_wedge.addActionListener(this); e_quad = new JRadioButton("quad curve"); e_quad.addActionListener(this); e_cubic = new JRadioButton("cubic curve"); e_cubic.addActionListener(this); e_ortho = new JRadioButton("orthogonal"); e_ortho.addActionListener(this); ButtonGroup bg_shape = new ButtonGroup(); bg_shape.add(e_line); // bg.add(e_bent); bg_shape.add(e_wedge); bg_shape.add(e_quad); bg_shape.add(e_ortho); bg_shape.add(e_cubic); shape_panel.add(e_line); // shape_panel.add(e_bent); shape_panel.add(e_wedge); shape_panel.add(e_quad); shape_panel.add(e_cubic); shape_panel.add(e_ortho); fill_edges = new JCheckBox("fill edge shapes"); fill_edges.setSelected(false); fill_edges.addActionListener(this); shape_panel.add(fill_edges); shape_panel.setOpaque(true); e_color = new JCheckBox("highlight edge weights"); e_color.addActionListener(this); e_labels = new JCheckBox("show edge weight values"); e_labels.addActionListener(this); e_uarrow_pred = new JCheckBox("undirected"); e_uarrow_pred.addActionListener(this); e_darrow_pred = new JCheckBox("directed"); e_darrow_pred.addActionListener(this); e_darrow_pred.setSelected(true); 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); zoom_at_mouse.setSelected(true); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JPanel zoomPanel = new JPanel(); zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom")); plus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(plus); minus.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(minus); zoom_at_mouse.setAlignmentX(Component.CENTER_ALIGNMENT); zoomPanel.add(zoom_at_mouse); JPanel fontPanel = new JPanel(); // add font and zoom controls to center panel font = new JCheckBox("bold text"); font.addActionListener(this); font.setAlignmentX(Component.CENTER_ALIGNMENT); fontPanel.add(font); both_panel.add(zoomPanel); both_panel.add(fontPanel); JComboBox modeBox = gm.getModeComboBox(); modeBox.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel modePanel = new JPanel(new BorderLayout()) { public Dimension getMaximumSize() { return getPreferredSize(); } }; modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); JPanel comboGrid = new JPanel(new GridLayout(0, 1)); comboGrid.add(modePanel); fontPanel.add(comboGrid); JComboBox cb = new JComboBox(); cb.addItem(Renderer.VertexLabel.Position.N); cb.addItem(Renderer.VertexLabel.Position.NE); cb.addItem(Renderer.VertexLabel.Position.E); cb.addItem(Renderer.VertexLabel.Position.SE); cb.addItem(Renderer.VertexLabel.Position.S); cb.addItem(Renderer.VertexLabel.Position.SW); cb.addItem(Renderer.VertexLabel.Position.W); cb.addItem(Renderer.VertexLabel.Position.NW); cb.addItem(Renderer.VertexLabel.Position.N); cb.addItem(Renderer.VertexLabel.Position.CNTR); cb.addItem(Renderer.VertexLabel.Position.AUTO); cb.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { Renderer.VertexLabel.Position position = (Renderer.VertexLabel.Position) e.getItem(); vv.getRenderer().getVertexLabelRenderer().setPosition(position); vv.repaint(); } }); cb.setSelectedItem(Renderer.VertexLabel.Position.SE); JPanel positionPanel = new JPanel(); positionPanel.setBorder(BorderFactory.createTitledBorder("Label Position")); positionPanel.add(cb); comboGrid.add(positionPanel); }