Example usage for javax.swing BorderFactory createTitledBorder

List of usage examples for javax.swing BorderFactory createTitledBorder

Introduction

In this page you can find the example usage for javax.swing BorderFactory createTitledBorder.

Prototype

public static TitledBorder createTitledBorder(Border border) 

Source Link

Document

Creates a new titled border with an empty title, the specified border object, the default text position (determined by the current look and feel), the default justification (leading), and the default font and text color (determined by the current look and feel).

Usage

From source file:jung.test.TreeLayoutDemo.java

public TreeLayoutDemo() {

    // create a simple graph for the demo
    //graph = new DelegateForest<String,DefaultWeightedEdge>();
    graph = new DelegateTree<String, DefaultWeightedEdge>();

    createTree();//ww  w .  jav a  2  s .c om

    treeLayout = new TreeLayout<String, DefaultWeightedEdge>(graph);
    radialLayout = new RadialTreeLayout<String, DefaultWeightedEdge>(graph);
    radialLayout.setSize(new Dimension(600, 600));
    vv = new VisualizationViewer<String, DefaultWeightedEdge>(treeLayout, 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();

    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) {

                LayoutTransition<String, DefaultWeightedEdge> lt = new LayoutTransition<String, DefaultWeightedEdge>(
                        vv, treeLayout, radialLayout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.addPreRenderPaintable(rings);
            } else {
                LayoutTransition<String, DefaultWeightedEdge> lt = new LayoutTransition<String, DefaultWeightedEdge>(
                        vv, radialLayout, treeLayout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.removePreRenderPaintable(rings);
            }
            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);

    content.add(controls, BorderLayout.SOUTH);
}

From source file:me.childintime.childintime.ui.window.tool.BmiToolDialog.java

private JPanel buildUiBodyStatePanel() {
    // Create a grid bag constraints configuration
    GridBagConstraints c = new GridBagConstraints();

    // Body state panel
    final JPanel bodyStatePanel = new JPanel(new GridBagLayout());
    bodyStatePanel.setBorder(new CompoundBorder(BorderFactory.createTitledBorder("BMI tool"),
            BorderFactory.createEmptyBorder(8, 8, 8, 8)));

    // Add the student panel to the body state panel
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;//from   ww  w . j  a  va  2 s.  c o m
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridheight = 2;
    c.insets = new Insets(0, 0, 0, 0);
    c.anchor = GridBagConstraints.CENTER;
    bodyStatePanel.add(buildUiStudentPanel(), c);

    // Add the input panel to the body state panel
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 1;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridheight = 1;
    c.insets = new Insets(0, 16, 0, 0);
    c.anchor = GridBagConstraints.NORTH;
    bodyStatePanel.add(buildUiChartPanel(), c);

    // Add the input panel to the body state panel
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 1;
    c.gridy = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.gridheight = 1;
    c.insets = new Insets(32, 16, 0, 0);
    c.anchor = GridBagConstraints.CENTER;
    bodyStatePanel.add(buildUiStudentBodyStatesPanel(), c);

    // Return the body state panel
    return bodyStatePanel;
}

From source file:com.mirth.connect.client.ui.RegexAttachmentDialog.java

private void initComponents() {
    regularExpressionPanel = new JPanel(new MigLayout("novisualpadding, hidemode 3, fill, insets 0"));
    regularExpressionPanel.setBackground(UIConstants.BACKGROUND_COLOR);
    regularExpressionPanel.setBorder(BorderFactory.createTitledBorder("Regular Expression"));

    regexTextField = new MirthTextField();
    regexTextField.setToolTipText(//from  w w w . j  a v  a2  s . c  o m
            "<html>The regular expression that will be used to match and extract attachments.<br>If capturing groups are used, only the last group will be extracted.</html>");

    regexExampleTextField = new JTextField();
    regexExampleTextField.setText("(?:OBX\\|(?:[^|]*\\|){4}(?:[^|^]*\\^){4})([^|^\\r\\n]*)(?:[|^\\r\\n]|$)");
    regexExampleTextField.setEditable(false);
    regexExampleTextField.setBorder(null);
    regexExampleTextField.setOpaque(false);

    mimeTypePanel = new JPanel(new MigLayout("novisualpadding, hidemode 3, fill, insets 0"));
    mimeTypePanel.setBackground(UIConstants.BACKGROUND_COLOR);
    mimeTypePanel.setBorder(BorderFactory.createTitledBorder("Mime Type"));

    mimeTypeField = new MirthTextField();
    mimeTypeField.setToolTipText("The mime type of the extracted attachment data.");

    stringReplacementPanel = new JPanel(new MigLayout("novisualpadding, hidemode 3, insets 0"));
    stringReplacementPanel.setBackground(UIConstants.BACKGROUND_COLOR);
    stringReplacementPanel.setBorder(BorderFactory.createTitledBorder("String Replacement"));

    stringReplacementLabel = new JLabel();
    stringReplacementLabel.setText(
            "<html>Replace strings on the matched data before storing. Do not use regular expressions in these fields or surround with quotes.<br>\nExample: Use <b>\\\\X0D0A\\\\</b> and <b>\\r\\n</b> to replace \\X0D0A\\ with actual CRLF characters. </html>");

    inboundReplacementTable = new MirthTable();

    inboundScrollPane = new JScrollPane();
    inboundScrollPane.setViewportView(inboundReplacementTable);

    outboundReplacementTable = new MirthTable();

    outboundScrollPane = new JScrollPane();
    outboundScrollPane.setViewportView(outboundReplacementTable);

    inboundButtonPanel = new JPanel(new MigLayout("novisualpadding, hidemode 3, insets 0", "", ""));
    inboundButtonPanel.setBackground(UIConstants.BACKGROUND_COLOR);

    inboundNewButton = new MirthButton("New");
    inboundNewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            inboundNewButtonActionPerformed(evt);
        }
    });

    inboundDeleteButton = new MirthButton("Delete");
    inboundDeleteButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            inboundDeleteButtonActionPerformed(evt);
        }
    });

    outboundButtonPanel = new JPanel(new MigLayout("novisualpadding, hidemode 3, insets 0", "", ""));
    outboundButtonPanel.setBackground(UIConstants.BACKGROUND_COLOR);

    outboundNewButton = new MirthButton("New");
    outboundNewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            outboundNewButtonActionPerformed(evt);
        }
    });

    outboundDeleteButton = new MirthButton("Delete");
    outboundDeleteButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            outboundDeleteButtonActionPerformed(evt);
        }
    });

    separator = new JSeparator();

    closeButton = new JButton("Close");
    closeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            closeButtonActionPerformed(evt);
        }
    });
}

From source file:misc.TablePrintDemo1.java

/**
 * Adds to and lays out all GUI components on the {@code contentPane} panel.
 * <p>/*  w  w w .  ja v  a2 s .  com*/
 * It is recommended that you <b>NOT</b> try to understand this code. It was
 * automatically generated by the NetBeans GUI builder.
 * 
 */
private void addComponentsToContentPane() {
    JPanel bottomPanel = new JPanel();
    bottomPanel.setBorder(BorderFactory.createTitledBorder("Printing"));

    GroupLayout bottomPanelLayout = new GroupLayout(bottomPanel);
    bottomPanel.setLayout(bottomPanelLayout);
    bottomPanelLayout.setHorizontalGroup(bottomPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(bottomPanelLayout.createSequentialGroup().addContainerGap()
                    .addGroup(bottomPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addComponent(headerBox).addComponent(footerBox))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(bottomPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                            .addComponent(footerField)
                            .addComponent(headerField, GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(bottomPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                            .addGroup(bottomPanelLayout.createSequentialGroup().addComponent(fitWidthBox)
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(printButton))
                            .addGroup(bottomPanelLayout.createSequentialGroup().addComponent(showPrintDialogBox)
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(interactiveBox)))
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    bottomPanelLayout.setVerticalGroup(bottomPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(bottomPanelLayout.createSequentialGroup()
                    .addGroup(bottomPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(headerBox)
                            .addComponent(headerField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addComponent(interactiveBox).addComponent(showPrintDialogBox))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(bottomPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(footerBox)
                            .addComponent(footerField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addComponent(fitWidthBox).addComponent(printButton))
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    GroupLayout layout = new GroupLayout(contentPane);
    contentPane.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap()
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addComponent(scroll, GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE)
                            .addComponent(gradesLabel).addComponent(bottomPanel, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap().addComponent(gradesLabel)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(scroll, GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(bottomPanel,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));
}

From source file:com.isencia.passerelle.hmi.specific.HMITest.java

public JPanel getEditSequencePanelRM4() {
    final JPanel editSequencePanelRM4 = new JPanel(new BorderLayout());

    final JPanel rockingCurvePanel = getRockingCurvePanel();
    // JPanel startOptionPanel = getStartOptionPanel();
    final JPanel tableScrollPanel = getTableScrollPane();
    final JPanel temperaturePanel = getTemperaturePanel();
    final JPanel buttonPanel = getButtonPanel();

    final JPanel topPanel = new JPanel(new GridLayout());
    topPanel.add("West", rockingCurvePanel);
    // topPanel.add("Center", startOptionPanel);

    final JPanel lowPanel = new JPanel(new GridLayout());
    lowPanel.add("West", temperaturePanel);
    lowPanel.add("Center", buttonPanel);

    editSequencePanelRM4.add("North", topPanel);
    editSequencePanelRM4.add("Center", tableScrollPanel);
    editSequencePanelRM4.add("South", lowPanel);

    final TitledBorder borderTitle = BorderFactory
            .createTitledBorder("Edit sequence with temperature and positioner");
    editSequencePanelRM4.setBorder(borderTitle);

    return editSequencePanelRM4;
}

From source file:au.edu.uwa.csse.plot.Clustering.java

private void setUpView(Graph graph) throws IOException {

    //Create a simple layout frame
    //specify the Fruchterman-Rheingold layout algorithm
    final AggregateLayout<Integer, Number> layout = new AggregateLayout<Integer, Number>(
            new FRLayout<Integer, Number>(graph));

    vv = new VisualizationViewer<Integer, Number>(layout);
    vv.setBackground(Color.white);
    vv.setVertexToolTipTransformer(Plot.vertexLabelTransformer);
    //Tell the renderer to use our own customized color rendering
    vv.getRenderContext()//from   w w w  .ja  v  a  2s . c om
            .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.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:eu.europeana.sip.gui.SipCreatorGUI.java

private Component createFilterPanel() {
    JPanel p = new JPanel(new BorderLayout());
    p.setBorder(BorderFactory.createTitledBorder("Filter"));
    filterTimer = new Timer(300, new ActionListener() {
        @Override/*ww  w  . j av  a  2  s  . c  o m*/
        public void actionPerformed(ActionEvent actionEvent) {
            dataSetList.clearSelection();
            dataSetListModel.setPattern(filter.getText());
        }
    });
    filterTimer.setRepeats(false);
    filter.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void insertUpdate(DocumentEvent documentEvent) {
            filterTimer.restart();
        }

        @Override
        public void removeUpdate(DocumentEvent documentEvent) {
            filterTimer.restart();
        }

        @Override
        public void changedUpdate(DocumentEvent documentEvent) {
            filterTimer.restart();
        }
    });
    p.add(filter, BorderLayout.CENTER);
    return p;
}

From source file:instance.gui.InstanceGUI.java

private void createCPULoadDiagramPanel() {
    cpuLoadDiagramPanel = new JPanel();
    cpuLoadDiagramPanel.setBorder(BorderFactory.createTitledBorder("CPU Load"));
    cpuLoadDiagramPanel.setLayout(new GridLayout(1, 0));
}

From source file:com.google.code.facebook.graph.sna.applet.RadialTreeLensDemo.java

/**
 * create an instance of a simple graph with controls to
 * demo the zoomand hyperbolic features.
 * /*from   w  w  w . jav  a  2s. c o m*/
 */
public RadialTreeLensDemo() {

    // create a simple graph for the demo
    // create a simple graph for the demo
    graph = new DelegateForest<String, Integer>();

    createTree();

    layout = new TreeLayout<String, Integer>(graph);
    radialLayout = new RadialTreeLayout<String, Integer>(graph);
    radialLayout.setSize(new Dimension(600, 600));

    Dimension preferredSize = new Dimension(600, 600);

    final VisualizationModel<String, Integer> visualizationModel = new DefaultVisualizationModel<String, Integer>(
            radialLayout, preferredSize);
    vv = new VisualizationViewer<String, Integer>(visualizationModel, preferredSize);

    PickedState<String> ps = vv.getPickedVertexState();
    PickedState<Integer> pes = vv.getPickedEdgeState();
    vv.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow));
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Integer>(pes, Color.black, Color.cyan));
    vv.setBackground(Color.white);

    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>());
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());

    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller<String>());

    Container content = getContentPane();
    GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv);
    content.add(gzsp);

    /**
     * the regular graph mouse for the normal view
     */
    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());
    rings = new Rings();
    vv.addPreRenderPaintable(rings);

    hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv,
            new HyperbolicShapeTransformer(vv,
                    vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)),
            new ModalLensGraphMouse());

    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());
        }
    });

    final JRadioButton hyperView = new JRadioButton("Hyperbolic View");
    hyperView.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener());

    JMenuBar menubar = new JMenuBar();
    menubar.add(graphMouse.getModeMenu());
    gzsp.setCorner(menubar);

    JPanel controls = new JPanel();
    JPanel zoomControls = new JPanel(new GridLayout(2, 1));
    zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom"));
    JPanel hyperControls = new JPanel(new GridLayout(3, 2));
    hyperControls.setBorder(BorderFactory.createTitledBorder("Examiner Lens"));
    zoomControls.add(plus);
    zoomControls.add(minus);
    JPanel modeControls = new JPanel(new BorderLayout());
    modeControls.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modeControls.add(graphMouse.getModeComboBox());
    hyperControls.add(hyperView);

    controls.add(zoomControls);
    controls.add(hyperControls);
    controls.add(modeControls);
    content.add(controls, BorderLayout.SOUTH);
}

From source file:edu.uci.ics.jung.samples.RadialTreeLensDemo.java

/**
 * create an instance of a simple graph with controls to
 * demo the zoomand hyperbolic features.
 * //from   w w  w . j a  v a2s.c  o  m
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public RadialTreeLensDemo() {

    // create a simple graph for the demo
    // create a simple graph for the demo
    graph = new DelegateForest<String, Integer>();

    createTree();

    layout = new TreeLayout<String, Integer>(graph);
    radialLayout = new RadialTreeLayout<String, Integer>(graph);
    radialLayout.setSize(new Dimension(600, 600));

    Dimension preferredSize = new Dimension(600, 600);

    final VisualizationModel<String, Integer> visualizationModel = new DefaultVisualizationModel<String, Integer>(
            radialLayout, preferredSize);
    vv = new VisualizationViewer<String, Integer>(visualizationModel, preferredSize);

    PickedState<String> ps = vv.getPickedVertexState();
    PickedState<Integer> pes = vv.getPickedEdgeState();
    vv.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow));
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Integer>(pes, Color.black, Color.cyan));
    vv.setBackground(Color.white);

    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>());
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());

    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller<String>());

    Container content = getContentPane();
    GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv);
    content.add(gzsp);

    /**
     * the regular graph mouse for the normal view
     */
    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());
    rings = new Rings();
    vv.addPreRenderPaintable(rings);

    hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv,
            new HyperbolicShapeTransformer(vv,
                    vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)),
            new ModalLensGraphMouse());

    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());
        }
    });

    final JRadioButton hyperView = new JRadioButton("Hyperbolic View");
    hyperView.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener());

    JMenuBar menubar = new JMenuBar();
    menubar.add(graphMouse.getModeMenu());
    gzsp.setCorner(menubar);

    JPanel controls = new JPanel();
    JPanel zoomControls = new JPanel(new GridLayout(2, 1));
    zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom"));
    JPanel hyperControls = new JPanel(new GridLayout(3, 2));
    hyperControls.setBorder(BorderFactory.createTitledBorder("Examiner Lens"));
    zoomControls.add(plus);
    zoomControls.add(minus);
    JPanel modeControls = new JPanel(new BorderLayout());
    modeControls.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modeControls.add(graphMouse.getModeComboBox());
    hyperControls.add(hyperView);

    controls.add(zoomControls);
    controls.add(hyperControls);
    controls.add(modeControls);
    content.add(controls, BorderLayout.SOUTH);
}