List of usage examples for javax.swing BorderFactory createTitledBorder
public static TitledBorder createTitledBorder(Border border)
From source file:net.sourceforge.squirrel_sql.client.preferences.WikiTablePreferencesPanel.java
/** * Create the panel with a small help text for the user. * This panel indicates, which variables are allowed. *//* w w w . j a v a 2 s. c om*/ private Component createNotePanel() { JPanel jp = new JPanel(); jp.setBorder(BorderFactory.createTitledBorder("Note")); //$NON-NLS-1$ String text = "<html><body>" + //$NON-NLS-1$ s_stringMgr.getString("WikiTablePreferencesPanel.hintValueVariable") + //$NON-NLS-1$ "<br />" + //$NON-NLS-1$ s_stringMgr.getString("WikiTablePreferencesPanel.hintNewLine") + //$NON-NLS-1$ "</body></html>"; //$NON-NLS-1$ JLabel label = new JLabel(text); jp.add(label); return jp; }
From source file:com.google.code.facebook.graph.sna.applet.TreeCollapseDemo.java
@SuppressWarnings("unchecked") public TreeCollapseDemo() { // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree();/*from www . j av a2 s .c o m*/ layout = new TreeLayout<String, Integer>(graph); collapser = new TreeCollapser(); radialLayout = new RadialTreeLayout<String, Integer>(graph); radialLayout.setSize(new Dimension(600, 600)); vv = new VisualizationViewer<String, Integer>(layout, new Dimension(600, 600)); vv.setBackground(Color.white); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.getRenderContext().setVertexShapeTransformer(new ClusterVertexShapeFunction()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray)); rings = new Rings(); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(graphMouse.getModeListener()); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); 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()); } }); JToggleButton radial = new JToggleButton("Radial"); radial.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { // layout.setRadial(true); vv.setGraphLayout(radialLayout); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.addPreRenderPaintable(rings); } else { // layout.setRadial(false); vv.setGraphLayout(layout); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.removePreRenderPaintable(rings); } vv.repaint(); } }); JButton collapse = new JButton("Collapse"); collapse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Collection picked = new HashSet(vv.getPickedVertexState().getPicked()); if (picked.size() == 1) { Object root = picked.iterator().next(); Forest inGraph = (Forest) layout.getGraph(); try { collapser.collapse(vv.getGraphLayout(), inGraph, root); } catch (InstantiationException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IllegalAccessException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } vv.getPickedVertexState().clear(); vv.repaint(); } } }); JButton expand = new JButton("Expand"); expand.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Collection picked = vv.getPickedVertexState().getPicked(); for (Object v : picked) { if (v instanceof Forest) { Forest inGraph = (Forest) layout.getGraph(); collapser.expand(inGraph, (Forest) v); } vv.getPickedVertexState().clear(); vv.repaint(); } } }); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(radial); controls.add(scaleGrid); controls.add(modeBox); controls.add(collapse); controls.add(expand); content.add(controls, BorderLayout.SOUTH); }
From source file:eu.delving.sip.frames.AllFrames.java
public static JComponent miniScrollV(String title, JComponent content) { JPanel p = new JPanel(new BorderLayout()); p.setBorder(BorderFactory.createTitledBorder(title)); JScrollPane scroll = new JScrollPane(content); scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); scroll.setPreferredSize(new Dimension(200, 80)); p.add(scroll);// ww w .j a v a 2s. c om return p; }
From source file:geovista.network.gui.ClusteringDemo.java
private void setUpView() throws IOException { /*/*from ww w . j a v a 2s . c o m*/ * Factory<Integer> vertexFactory = new Factory<Integer>() { int n = 0; * public Integer create() { return n++; } }; Factory<Number> * edgeFactory = new Factory<Number>() { int n = 0; public Number * create() { return n++; } }; */ /* * PajekNetReader<Graph<Integer, Number>, Integer,Number> pnr = new * PajekNetReader<Graph<Integer, Number>, Integer,Number>(vertexFactory, * edgeFactory); * * final Graph<Integer,Number> graph = new SparseMultigraph<Integer, * Number>(); * * pnr.load(br, graph); */ // Create a simple layout frame // specify the Fruchterman-Rheingold layout algorithm layout = new AggregateLayout<Integer, Number>(new FRLayout<Integer, Number>(g)); vv = new VisualizationViewer<Integer, Number>(layout); vv.setBackground(Color.white); // Tell the renderer to use our own customized color rendering vv.getRenderContext() .setVertexFillPaintTransformer(MapTransformer.<Integer, Paint>getInstance(vertexPaints)); vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Integer, Paint>() { public Paint transform(Integer v) { if (vv.getPickedVertexState().isPicked(v)) { return Color.blue; } else { return Color.BLACK; } } }); vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints)); vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() { protected final Stroke THIN = new BasicStroke(1); protected final Stroke THICK = new BasicStroke(2); public Stroke transform(Number e) { Paint c = edgePaints.get(e); if (c == Color.LIGHT_GRAY) { return THIN; } else { return THICK; } } }); /* * //add restart button JButton scramble = new JButton("Restart"); * scramble.addActionListener(new ActionListener() { public void * actionPerformed(ActionEvent arg0) { Layout layout = * vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = * vv.getModel().getRelaxer(); if(relaxer != null) { relaxer.stop(); * relaxer.prerelax(); relaxer.relax(); } } * * }); * * DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); * vv.setGraphMouse(gm); */ 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); // edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black)); // TO DO: edgeBetweennessSlider.add(new // JLabel("Node Size (PageRank With Priors):")); // I also want the slider value to appear final JPanel eastControls = new JPanel(); /* * eastControls.setOpaque(true); eastControls.setLayout(new * BoxLayout(eastControls, BoxLayout.Y_AXIS)); * eastControls.add(Box.createVerticalGlue()); */ // eastControls.add(edgeBetweennessSlider); 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); /* * eastControls.setBorder(sliderBorder); //eastControls.add(eastSize); * eastControls.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()); eastControls.repaint(); vv.validate(); vv.repaint(); } } }); cluster_panel.add(groupVertices); Container content = getContentPane(); content.add(new GraphZoomScrollPane(vv)); JPanel south = new JPanel(); JPanel grid = new JPanel(new GridLayout(2, 1)); // grid.add(scramble); grid.add(cluster_panel); // south.add south.add(grid); south.add(eastControls); JPanel p = new JPanel(); // p.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); // p.add(gm.getModeComboBox()); south.add(p); content.add(south, BorderLayout.SOUTH); }
From source file:com.microsoft.alm.plugin.idea.tfvc.ui.settings.ProjectConfigurableForm.java
/** * Method generated by IntelliJ IDEA GUI Designer * >>> IMPORTANT!! <<< * DO NOT edit this method OR call it in your code! * * @noinspection ALL/*from www . ja va 2s . co m*/ */ private void $$$setupUI$$$() { myContentPane = new JPanel(); myContentPane.setLayout(new GridLayoutManager(5, 3, new Insets(0, 0, 0, 0), -1, -1)); serverLabel = new JPanel(); serverLabel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); myContentPane.add(serverLabel, new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); serverLabel.setBorder(BorderFactory.createTitledBorder("Servers and workspaces")); myManageButton = new JButton(); myManageButton.setText("Manage..."); myManageButton.setMnemonic('M'); myManageButton.setDisplayedMnemonicIndex(0); serverLabel.add(myManageButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final Spacer spacer1 = new Spacer(); serverLabel.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); myUseIdeaHttpProxyCheckBox = new JCheckBox(); myUseIdeaHttpProxyCheckBox.setEnabled(true); myUseIdeaHttpProxyCheckBox.setSelected(false); myUseIdeaHttpProxyCheckBox.setText("Use HTTP Proxy settings"); myUseIdeaHttpProxyCheckBox.setMnemonic('U'); myUseIdeaHttpProxyCheckBox.setDisplayedMnemonicIndex(0); serverLabel.add(myUseIdeaHttpProxyCheckBox, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); passwordLabel = new JPanel(); passwordLabel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); myContentPane.add(passwordLabel, new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); passwordLabel.setBorder(BorderFactory.createTitledBorder("Passwords")); final Spacer spacer2 = new Spacer(); passwordLabel.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); myResetPasswordsButton = new JButton(); myResetPasswordsButton.setText("Reset Saved Passwords"); myResetPasswordsButton.setMnemonic('R'); myResetPasswordsButton.setDisplayedMnemonicIndex(0); passwordLabel.add(myResetPasswordsButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); checkinPolicyLabel = new JPanel(); checkinPolicyLabel.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1)); myContentPane.add(checkinPolicyLabel, new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); checkinPolicyLabel.setBorder(BorderFactory.createTitledBorder("Checkin policies compatibility")); myReportNotInstalledPoliciesCheckBox = new JCheckBox(); myReportNotInstalledPoliciesCheckBox.setText("Warn about not installed policies"); myReportNotInstalledPoliciesCheckBox.setMnemonic('W'); myReportNotInstalledPoliciesCheckBox.setDisplayedMnemonicIndex(0); checkinPolicyLabel.add(myReportNotInstalledPoliciesCheckBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); noteLabel = new JLabel(); noteLabel.setText("(Note: these settings may be overridden for individual team project)"); checkinPolicyLabel.add(noteLabel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); myTFSCheckBox = new JCheckBox(); myTFSCheckBox.setText("Evaluate Team Explorer policies"); myTFSCheckBox.setMnemonic('T'); myTFSCheckBox.setDisplayedMnemonicIndex(9); checkinPolicyLabel.add(myTFSCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); myStatefulCheckBox = new JCheckBox(); myStatefulCheckBox.setText("Evaluate Teamprise policies"); myStatefulCheckBox.setMnemonic('E'); myStatefulCheckBox.setDisplayedMnemonicIndex(10); checkinPolicyLabel.add(myStatefulCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); pathLabel = new JLabel(); pathLabel.setText("Path to tf executable:"); myContentPane.add(pathLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); tfExeField = new TextFieldWithBrowseButton(); myContentPane.add(tfExeField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); testExeButton = new JButton(); testExeButton.setText("Test"); myContentPane.add(testExeButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); final Spacer spacer3 = new Spacer(); myContentPane.add(spacer3, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); }
From source file:cimat.tesis.sna.visualization.ClusteringDemo.java
private void setUpView(BufferedReader br) throws IOException { Factory<Number> vertexFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; }// ww w.j a v a2 s . c om }; Factory<Number> edgeFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; } }; PajekNetReader<Graph<Number, Number>, Number, Number> pnr = new PajekNetReader<Graph<Number, Number>, Number, Number>( vertexFactory, edgeFactory); final Graph<Number, Number> graph = new SparseMultigraph<Number, Number>(); pnr.load(br, graph); //Create a simple layout frame //specify the Fruchterman-Rheingold layout algorithm final AggregateLayout<Number, Number> layout = new AggregateLayout<Number, Number>( new FRLayout<Number, Number>(graph)); vv = new VisualizationViewer<Number, Number>(layout); vv.setBackground(Color.white); //Tell the renderer to use our own customized color rendering vv.getRenderContext() .setVertexFillPaintTransformer(MapTransformer.<Number, Paint>getInstance(vertexPaints)); vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Number, Paint>() { public Paint transform(Number v) { if (vv.getPickedVertexState().isPicked(v)) { return Color.cyan; } else { return Color.BLACK; } } }); vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints)); vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() { protected final Stroke THIN = new BasicStroke(1); protected final Stroke THICK = new BasicStroke(2); public Stroke transform(Number e) { Paint c = edgePaints.get(e); if (c == Color.LIGHT_GRAY) return THIN; else return THICK; } }); //add restart button JButton scramble = new JButton("Restart"); scramble.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Layout layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if (relaxer != null) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); vv.setGraphMouse(gm); 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(graph.getEdgeCount()); edgeBetweennessSlider.setMinimum(0); edgeBetweennessSlider.setValue(0); edgeBetweennessSlider.setMajorTickSpacing(10); edgeBetweennessSlider.setPaintLabels(true); edgeBetweennessSlider.setPaintTicks(true); // edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black)); //TO DO: edgeBetweennessSlider.add(new JLabel("Node Size (PageRank With Priors):")); //I also want the slider value to appear final JPanel eastControls = new JPanel(); eastControls.setOpaque(true); eastControls.setLayout(new BoxLayout(eastControls, BoxLayout.Y_AXIS)); eastControls.add(Box.createVerticalGlue()); eastControls.add(edgeBetweennessSlider); final String COMMANDSTRING = "Edges removed for clusters: "; final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue(); final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize); eastControls.setBorder(sliderBorder); //eastControls.add(eastSize); eastControls.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()); eastControls.repaint(); vv.validate(); vv.repaint(); } } }); Container content = getContentPane(); content.add(new GraphZoomScrollPane(vv)); JPanel south = new JPanel(); JPanel grid = new JPanel(new GridLayout(2, 1)); grid.add(scramble); grid.add(groupVertices); south.add(grid); south.add(eastControls); JPanel p = new JPanel(); p.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); p.add(gm.getModeComboBox()); south.add(p); content.add(south, BorderLayout.SOUTH); }
From source file:com.declarativa.interprolog.gui.Testo1.java
private void updateGUI(Forest<String, Integer> grapho) { layout = new TreeLayout<String, Integer>(grapho); radialLayout = new BalloonLayout<String, Integer>(grapho); radialLayout.setSize(new Dimension(900, 900)); vv = new VisualizationViewer<String, Integer>(layout, new Dimension(600, 600)); vv.setBackground(Color.white); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray)); rings = new Rings(radialLayout); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel);//from ww w . j av a 2 s .c o m final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(graphMouse.getModeListener()); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); final ScalingControl scaler = new CrossoverScalingControl(); vv.scaleToLayout(scaler); 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()); } }); JToggleButton radial = new JToggleButton("Balloon"); radial.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, layout, radialLayout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity(); vv.addPreRenderPaintable(rings); } else { LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, radialLayout, layout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity(); vv.removePreRenderPaintable(rings); } vv.repaint(); } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(radial); controls.add(scaleGrid); controls.add(modeBox); controls.add(jButton1); content.add(controls, BorderLayout.SOUTH); this.revalidate(); this.repaint(); }
From source file:com.mgmtp.jfunk.core.ui.JFunkFrame.java
private void buildToolBar() { // Toolbar for the first line JToolBar toolBarFirstLine = new JToolBar("Toolbar"); toolBarFirstLine.setRequestFocusEnabled(false); toolBarFirstLine.setFloatable(false); toolBarFirstLine.add(fileOpenScriptsAction); toolBarFirstLine.add(toolsRunAction); toolBarFirstLine.addSeparator();/* w w w .j av a 2s . com*/ // Build component jFunk property files jFunkPropertyFilesModel = new PropertiesComboBoxModel("config", "jfunk", PROPS_SUFFIX, null, true); jFunkPropertyFilesComboBox = new JComboBox(jFunkPropertyFilesModel); jFunkPropertyFilesComboBox.setBorder(BorderFactory.createTitledBorder("jFunk configuration")); // Multi-line tooltip jFunkPropertyFilesComboBox .setToolTipText("<html>List of jFunk property files containing listener and modules" + "<br>Location: all files in directory 'config'</br></html>"); toolBarFirstLine.add(jFunkPropertyFilesComboBox); // Build component testsystems testSystemsModel = new PropertiesComboBoxModel("config/system", null, PROPS_SUFFIX, "baseurl", false); testSystemsComboBox = new JComboBox(testSystemsModel); testSystemsComboBox.setBorder(BorderFactory.createTitledBorder("Test system")); // Multi-line tooltip testSystemsComboBox.setToolTipText( "<html>List of test systems" + "<br>Defined by all files in directory 'config/system'</br></html>"); testSystemsComboBox.setSelectedItem(0); toolBarFirstLine.add(testSystemsComboBox); // Toolbar for the second line JToolBar toolBarSecondLine = new JToolBar(); toolBarSecondLine.setRequestFocusEnabled(false); toolBarSecondLine.setFloatable(false); // Build component mail configuration mailConfigurationsModel = new PropertiesComboBoxModel(PATH_TO_MAIL_CONFIG_FILES, null, PROPS_SUFFIX, null, false); mailConfigurationsComboBox = new JComboBox(mailConfigurationsModel); mailConfigurationsComboBox.setBorder(BorderFactory.createTitledBorder("Mail configuration")); // Multi-line tooltip mailConfigurationsComboBox.setToolTipText("<html>List of mail configurations" + "<br>Defined by all files in directory 'config/email_accounts'</br></html>"); toolBarSecondLine.add(mailConfigurationsComboBox); // Build component thread count threadCountComboBox = new JComboBox(createNumberArray(30)); threadCountComboBox.setBorder(BorderFactory.createTitledBorder("Threads")); threadCountComboBox.setToolTipText( "Number of threads which will be used for the execution of the selected script files"); toolBarSecondLine.add(threadCountComboBox); // Build component parallel parallelComboBox = new JComboBox(new String[] { "yes", "no" }); parallelComboBox.setSelectedIndex(1); parallelComboBox.setBorder(BorderFactory.createTitledBorder("Parallel?")); parallelComboBox.setToolTipText("If set to 'yes', a single script will be executed " + "multiple times using the specified number of threads"); toolBarSecondLine.add(parallelComboBox); jPanelUtilities = new JPanel(); jPanelUtilities.setLayout(new BorderLayout()); jPanelUtilities.add(toolBarFirstLine, BorderLayout.NORTH); jPanelUtilities.add(toolBarSecondLine, BorderLayout.CENTER); }
From source file:com.hp.alm.ali.idea.content.settings.SettingsPanel.java
private void setCaption(String caption) { preview.setBorder(BorderFactory.createCompoundBorder(BorderFactory .createCompoundBorder(new EmptyBorder(0, 10, 10, 10), BorderFactory.createTitledBorder(caption)), new EmptyBorder(10, 10, 10, 10))); }
From source file:EdgeLabelDemo.java
/** * create an instance of a simple graph with controls to * demo the label positioning features//from w w w . java 2s . 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); }