Example usage for javax.swing BoxLayout Y_AXIS

List of usage examples for javax.swing BoxLayout Y_AXIS

Introduction

In this page you can find the example usage for javax.swing BoxLayout Y_AXIS.

Prototype

int Y_AXIS

To view the source code for javax.swing BoxLayout Y_AXIS.

Click Source Link

Document

Specifies that components should be laid out top to bottom.

Usage

From source file:org.spf4j.ui.TSDBViewJInternalFrame.java

@edu.umd.cs.findbugs.annotations.SuppressWarnings("UP_UNUSED_PARAMETER")
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    TreePath[] selectionPaths = measurementTree.getSelectionPaths();
    JPanel content = new JPanel();
    content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
    chartPannel.setViewportView(content);
    try {/* w ww . j  a v  a 2  s. c o m*/
        List<String> selectedTables = getSelectedTables(selectionPaths);
        for (String tableName : selectedTables) {
            addChartToPanel(tableName, content);
        }
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
    chartPannel.repaint();
}

From source file:se.six.jmeter.visualizer.statagg.StatAggVisualizer.java

/**
 * Main visualizer setup./*  www .  j av  a 2 s .  co  m*/
 */
private void init() {
    this.setLayout(new BorderLayout());

    // MAIN PANEL
    JPanel mainPanel = new JPanel();
    Border margin = new EmptyBorder(10, 10, 5, 10);

    mainPanel.setBorder(margin);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

    //mainPanel.add(makeTitlePanel());
    _chart = createChart();
    _chartPanel = new ChartPanel(_chart);
    mainPanel.add(_chartPanel);

    _model = new StatAggTreeTableModel();
    _table = new JXTreeTable(_model);
    _table.setRootVisible(false);
    //table.setShowHorizontalLines(true);
    //table.setShowVerticalLines(true);
    _table.setLeafIcon(new ImageIcon(getClass().getResource("task.png")));
    _table.setRowSelectionAllowed(true);
    _table.setExpandsSelectedPaths(true);
    _table.setPreferredScrollableViewportSize(new Dimension(500, 70));

    JScrollPane scrollPane = new JScrollPane(_table);
    this.add(mainPanel, BorderLayout.NORTH);
    this.add(scrollPane, BorderLayout.CENTER);
}

From source file:org.broad.igv.util.stats.KMPlotFrame.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner non-commercial license
    dialogPane = new JPanel();
    contentPanel = new JPanel();
    panel1 = new JPanel();
    panel2 = new JPanel();
    label2 = new JLabel();
    survivalColumnControl = new JComboBox();
    panel3 = new JPanel();
    label3 = new JLabel();
    censurColumnControl = new JComboBox();
    panel4 = new JPanel();
    label4 = new JLabel();
    groupByControl = new JComboBox();

    //======== this ========
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("Kaplan-Meier Plot");
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    //======== dialogPane ========
    {/* w  ww.j  a v  a 2 s .c o m*/
        dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
        dialogPane.setLayout(new BorderLayout());

        //======== contentPanel ========
        {
            contentPanel.setLayout(new BorderLayout());

            //======== panel1 ========
            {
                panel1.setAlignmentX(0.0F);
                panel1.setLayout(new BoxLayout(panel1, BoxLayout.Y_AXIS));

                //======== panel2 ========
                {
                    panel2.setAlignmentX(1.0F);
                    panel2.setLayout(null);

                    //---- label2 ----
                    label2.setText("Survival column");
                    panel2.add(label2);
                    label2.setBounds(new Rectangle(new Point(5, 10), label2.getPreferredSize()));

                    //---- survivalColumnControl ----
                    survivalColumnControl.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            survivalColumnControlActionPerformed(e);
                        }
                    });
                    panel2.add(survivalColumnControl);
                    survivalColumnControl.setBounds(120, 5, 235,
                            survivalColumnControl.getPreferredSize().height);

                    { // compute preferred size
                        Dimension preferredSize = new Dimension();
                        for (int i = 0; i < panel2.getComponentCount(); i++) {
                            Rectangle bounds = panel2.getComponent(i).getBounds();
                            preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                            preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
                        }
                        Insets insets = panel2.getInsets();
                        preferredSize.width += insets.right;
                        preferredSize.height += insets.bottom;
                        panel2.setMinimumSize(preferredSize);
                        panel2.setPreferredSize(preferredSize);
                    }
                }
                panel1.add(panel2);

                //======== panel3 ========
                {
                    panel3.setAlignmentX(1.0F);
                    panel3.setLayout(null);

                    //---- label3 ----
                    label3.setText("Censure column");
                    panel3.add(label3);
                    label3.setBounds(new Rectangle(new Point(5, 10), label3.getPreferredSize()));

                    //---- censurColumnControl ----
                    censurColumnControl.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            survivalColumnControlActionPerformed(e);
                        }
                    });
                    panel3.add(censurColumnControl);
                    censurColumnControl.setBounds(120, 5, 235, censurColumnControl.getPreferredSize().height);

                    { // compute preferred size
                        Dimension preferredSize = new Dimension();
                        for (int i = 0; i < panel3.getComponentCount(); i++) {
                            Rectangle bounds = panel3.getComponent(i).getBounds();
                            preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                            preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
                        }
                        Insets insets = panel3.getInsets();
                        preferredSize.width += insets.right;
                        preferredSize.height += insets.bottom;
                        panel3.setMinimumSize(preferredSize);
                        panel3.setPreferredSize(preferredSize);
                    }
                }
                panel1.add(panel3);

                //======== panel4 ========
                {
                    panel4.setAlignmentX(1.0F);
                    panel4.setLayout(null);

                    //---- label4 ----
                    label4.setText("Group by");
                    panel4.add(label4);
                    label4.setBounds(new Rectangle(new Point(5, 10), label4.getPreferredSize()));

                    //---- groupByControl ----
                    groupByControl.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            survivalColumnControlActionPerformed(e);
                        }
                    });
                    panel4.add(groupByControl);
                    groupByControl.setBounds(120, 5, 235, groupByControl.getPreferredSize().height);

                    { // compute preferred size
                        Dimension preferredSize = new Dimension();
                        for (int i = 0; i < panel4.getComponentCount(); i++) {
                            Rectangle bounds = panel4.getComponent(i).getBounds();
                            preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                            preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
                        }
                        Insets insets = panel4.getInsets();
                        preferredSize.width += insets.right;
                        preferredSize.height += insets.bottom;
                        panel4.setMinimumSize(preferredSize);
                        panel4.setPreferredSize(preferredSize);
                    }
                }
                panel1.add(panel4);
            }
            contentPanel.add(panel1, BorderLayout.NORTH);
        }
        dialogPane.add(contentPanel, BorderLayout.CENTER);
    }
    contentPane.add(dialogPane, BorderLayout.CENTER);
    setSize(565, 510);
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:edu.ucla.stat.SOCR.chart.demo.DotChart.java

public void setChart() {
    // update graph
    /*System.out.println("setChart called");
    Exception e = new Exception();//from   w ww.j a  va 2  s  .  co m
    e.printStackTrace();*/

    graphPanel.removeAll();
    graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS));

    graphPanel.add(chartPanel1);
    graphPanel.add(chartPanel2);
    graphPanel.validate();

    // get the GRAPH panel to the front
    if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) != ALL)
        tabbedPanelContainer.setSelectedIndex(tabbedPanelContainer.indexOfComponent(graphPanel));
    else {
        graphPanel2.removeAll();
        chartPanel.setPreferredSize(new Dimension(CHART_SIZE_X * 2 / 3, CHART_SIZE_Y * 2 / 3));
        graphPanel2.add(chartPanel1);
        graphPanel2.add(chartPanel2);
        graphPanel2.validate();
        summaryPanel.validate();
    }
}

From source file:kg.apc.jmeter.vizualizers.SynthesisReportGui.java

/**
 * Main visualizer setup./*from   www .j  av  a 2 s .  c  o m*/
 */
private void init() {
    this.setLayout(new BorderLayout());

    // MAIN PANEL
    JPanel mainPanel = new JPanel();
    Border margin = new EmptyBorder(10, 10, 5, 10);

    mainPanel.setBorder(margin);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

    mainPanel.add(JMeterPluginsUtils.addHelpLinkToPanel(makeTitlePanel(), WIKIPAGE));

    // SortFilterModel mySortedModel =
    // new SortFilterModel(myStatTableModel);
    JTable myJTable = new JTable(model);
    myJTable.getTableHeader().setDefaultRenderer(new JMeterHeaderAsPropertyRenderer(COLUMNS_MSG_PARAMETERS));
    myJTable.setPreferredScrollableViewportSize(new Dimension(500, 70));
    RendererUtils.applyRenderers(myJTable, RENDERERS);
    JScrollPane myScrollPane = new JScrollPane(myJTable);
    this.add(mainPanel, BorderLayout.NORTH);
    this.add(myScrollPane, BorderLayout.CENTER);
    saveTable.addActionListener(this);
    JPanel opts = new JPanel();
    opts.add(useGroupName, BorderLayout.WEST);
    opts.add(saveTable, BorderLayout.CENTER);
    opts.add(saveHeaders, BorderLayout.EAST);
    this.add(opts, BorderLayout.SOUTH);
}

From source file:gui.WikiCorpusClusteringView.java

/**
 *
 * @param br//  w w w  . j  av  a 2  s . c om
 * @throws IOException
 */
private void setUpView(Graph graph) throws IOException {

    //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));

    //layout = new TreeLayout<String,Integer>(graph);
    Layout<Number, Number> layout = new KKLayout<Number, Number>(graph);
    layout.setSize(new Dimension(900, 900));

    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:SciTK.Plot.java

/** 
 * Load the initial UI/* w w w. java2  s.c  o  m*/
 */
protected final void initUI() {
    setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

    // create a ChartPanel, and make it default to 1/4 of screen size:
    chart_panel = new ChartPanel(chart);
    chart_panel.setPreferredSize(new Dimension(def_width, def_height));

    //add the chart to the window:
    getContentPane().add(chart_panel);

    // create a menu bar:
    menubar = new JMenuBar();
    // ---------------------------------------------------------
    //                 First dropdown menu: "File"
    // ---------------------------------------------------------
    file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);

    // Set up a save dialog option under the file menu:
    JMenuItem menu_file_save;
    ImageIcon menu_file_save_icon = null;
    try {
        menu_file_save_icon = new ImageIcon(getClass().getResource("/SciTK/resources/document-save-5.png"));
        menu_file_save = new JMenuItem("Save", menu_file_save_icon);
    } catch (Exception e) {
        menu_file_save = new JMenuItem("Save");
    }
    menu_file_save.setMnemonic(KeyEvent.VK_S);
    menu_file_save.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu_file_save.setToolTipText("Save an image");
    menu_file_save.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            saveImage();
        }
    });
    file.add(menu_file_save);

    // Set up a save SVG dialog option under the file menu:
    JMenuItem menu_file_save_svg;
    try {
        menu_file_save_svg = new JMenuItem("Save VG", menu_file_save_icon);
    } catch (Exception e) {
        menu_file_save_svg = new JMenuItem("Save VG");
    }
    menu_file_save_svg.setToolTipText("Save as vector graphics (SVG,PS,EPS)");
    menu_file_save_svg.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            saveVectorGraphics();
        }
    });
    file.add(menu_file_save_svg);

    // Set up a save data dialog option under the file menu:
    JMenuItem menu_file_save_data;
    try {
        menu_file_save_data = new JMenuItem("Save data", menu_file_save_icon);
    } catch (Exception e) {
        menu_file_save_data = new JMenuItem("Save data");
    }
    menu_file_save_data.setToolTipText("Save raw data to file");
    menu_file_save_data.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            saveData();
        }
    });
    file.add(menu_file_save_data);

    // Set up a save data dialog option under the file menu:
    JMenuItem menu_file_print;
    try {
        ImageIcon menu_file_print_icon = new ImageIcon(
                getClass().getResource("/SciTK/resources/document-print-5.png"));
        menu_file_print = new JMenuItem("Print", menu_file_print_icon);
    } catch (Exception e) {
        menu_file_print = new JMenuItem("Print");
    }
    menu_file_print.setToolTipText("Print image of chart");
    menu_file_print.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            printPlot();
        }
    });
    file.add(menu_file_print);

    // menu item for exiting
    JMenuItem menu_file_exit;
    try {
        ImageIcon menu_file_exit_icon = new ImageIcon(
                getClass().getResource("/SciTK/resources/application-exit.png"));
        menu_file_exit = new JMenuItem("Exit", menu_file_exit_icon);
    } catch (Exception e) {
        menu_file_exit = new JMenuItem("Exit");
    }
    menu_file_exit.setMnemonic(KeyEvent.VK_X);
    menu_file_exit.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu_file_exit.setToolTipText("Exit application");
    menu_file_exit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dispose();
        }

    });
    file.add(menu_file_exit);

    // ---------------------------------------------------------
    //                 Second dropdown menu: "Edit"
    // ---------------------------------------------------------
    edit = new JMenu("Edit");
    edit.setMnemonic(KeyEvent.VK_E);

    // copy to clipboard
    JMenuItem menu_edit_copy_image;
    ImageIcon menu_edit_copy_icon = null;
    try {
        menu_edit_copy_icon = new ImageIcon(getClass().getResource("/SciTK/resources/edit-copy-7.png"));
        menu_edit_copy_image = new JMenuItem("Copy", menu_edit_copy_icon);
    } catch (Exception e) {
        menu_edit_copy_image = new JMenuItem("Copy");
    }
    menu_edit_copy_image.setMnemonic(KeyEvent.VK_C);
    menu_edit_copy_image.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu_edit_copy_image.setToolTipText("Copy image to clipboard");
    menu_edit_copy_image.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            copyImage();
        }
    });
    edit.add(menu_edit_copy_image);

    // copy data to clipboard
    JMenuItem menu_edit_copy_data;
    try {
        menu_edit_copy_data = new JMenuItem("Copy data", menu_edit_copy_icon);
    } catch (Exception e) {
        menu_edit_copy_data = new JMenuItem("Copy data");
    }
    menu_edit_copy_data.setToolTipText("Copy data to clipboard");
    menu_edit_copy_data.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            copyData();
        }
    });
    edit.add(menu_edit_copy_data);

    // set background color
    JMenuItem menu_edit_BackgroundColor;
    ImageIcon menu_edit_Color_icon = null;
    try {
        menu_edit_Color_icon = new ImageIcon(getClass().getResource("/SciTK/resources/color-wheel.png"));
        menu_edit_BackgroundColor = new JMenuItem("Background Color", menu_edit_Color_icon);
    } catch (Exception e) {
        menu_edit_BackgroundColor = new JMenuItem("Background Color");
    }
    menu_edit_BackgroundColor.setToolTipText("Select background color");
    menu_edit_BackgroundColor.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            Color bgColor = plotColorChooser("Choose background color", (Color) chart.getBackgroundPaint());
            setBackgroundColor(bgColor);
        }
    });
    edit.add(menu_edit_BackgroundColor);

    // set plot color
    JMenuItem menu_edit_PlotColor;
    try {
        menu_edit_PlotColor = new JMenuItem("Window Color", menu_edit_Color_icon);
    } catch (Exception e) {
        menu_edit_PlotColor = new JMenuItem("Window Color");
    }
    menu_edit_PlotColor.setToolTipText("Select plot window color");
    menu_edit_PlotColor.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            Color plotColor = plotColorChooser("Choose plot color",
                    (Color) chart.getPlot().getBackgroundPaint());
            setWindowBackground(plotColor);
        }
    });
    edit.add(menu_edit_PlotColor);

    // set gridline color
    JMenuItem menu_edit_GridlineColor;
    try {
        menu_edit_GridlineColor = new JMenuItem("Gridline Color", menu_edit_Color_icon);
    } catch (Exception e) {
        menu_edit_GridlineColor = new JMenuItem("Gridline Color");
    }
    menu_edit_GridlineColor.setToolTipText("Select grid color");
    menu_edit_GridlineColor.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            Color gridColor = plotColorChooser("Choose grid color",
                    (Color) chart.getPlot().getBackgroundPaint());
            setGridlineColor(gridColor);
        }
    });
    edit.add(menu_edit_GridlineColor);

    // edit chart preferences
    JMenuItem menu_edit_preferences;
    try {
        ImageIcon menu_edit_preferences_icon = new ImageIcon(
                getClass().getResource("/SciTK/resources/preferences-desktop-3.png"));
        menu_edit_preferences = new JMenuItem("Preferences", menu_edit_preferences_icon);
    } catch (Exception e) {
        menu_edit_preferences = new JMenuItem("Preferences");
    }
    menu_edit_preferences.setToolTipText("Edit chart preferences");
    menu_edit_preferences.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            chart_panel.doEditChartProperties();
        }
    });
    edit.add(menu_edit_preferences);

    // ---------------------------------------------------------
    //                 Third dropdown menu: "Plot"
    // ---------------------------------------------------------
    plot = new JMenu("Plot");
    plot.setMnemonic(KeyEvent.VK_P);

    // Options to set log axes
    JCheckBoxMenuItem menu_plot_ylog = new JCheckBoxMenuItem("Log y axis");
    menu_plot_ylog.setToolTipText("Set y axis to logarithmic");
    menu_plot_ylog.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            AbstractButton aButton = (AbstractButton) event.getSource();
            boolean selected = aButton.getModel().isSelected();
            setRangeAxisLog(selected);
        }
    });
    plot.add(menu_plot_ylog);

    JCheckBoxMenuItem menu_plot_xlog = new JCheckBoxMenuItem("Log x axis");
    menu_plot_xlog.setToolTipText("Set x axis to logarithmic");
    menu_plot_xlog.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            AbstractButton aButton = (AbstractButton) event.getSource();
            boolean selected = aButton.getModel().isSelected();
            setDomainAxisLog(selected);
        }
    });
    plot.add(menu_plot_xlog);

    // grid line display
    JCheckBoxMenuItem menu_plot_grid = new JCheckBoxMenuItem("Grid lines");
    menu_plot_grid.setToolTipText("Show plot grid lines?");
    menu_plot_grid.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            AbstractButton aButton = (AbstractButton) event.getSource();
            boolean selected = aButton.getModel().isSelected();
            setGridlineVisible(selected);
        }
    });
    // set appropirate checkbox state:
    menu_plot_grid.setState(chart.getXYPlot().isDomainGridlinesVisible());
    plot.add(menu_plot_grid);

    // control for displaying plot legend
    JCheckBoxMenuItem menu_plot_legend = new JCheckBoxMenuItem("Legend");
    menu_plot_legend.setToolTipText("Show plot legend?");
    menu_plot_legend.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            AbstractButton aButton = (AbstractButton) event.getSource();
            boolean selected = aButton.getModel().isSelected();
            setLegend(selected);
        }
    });
    // set appropirate checkbox state:
    menu_plot_legend.setState((chart.getLegend() instanceof LegendTitle));
    plot.add(menu_plot_legend);

    // ---------------------------------------------------------
    //                 General UI
    // ---------------------------------------------------------
    // Add menus to the menu bar:
    menubar.add(file);
    menubar.add(edit);
    menubar.add(plot);
    // Set menubar as this JFrame's menu
    setJMenuBar(menubar);

    // set default plot colors:
    chart.setBackgroundPaint(new Color(255, 255, 255, 0));
    chart.getPlot().setBackgroundPaint(new Color(255, 255, 255, 255));
    setBackgroundAlpha(0.0f);

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    pack();
    setTitle(window_title);
    setLocationRelativeTo(null);
    setVisible(true);
}

From source file:edu.ucla.stat.SOCR.chart.SuperPowerChart.java

protected void initGraphPanel() {
    //System.out.println("initGraphPanel called");
    graphPanel = new JPanel();

    graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS));

    JFreeChart chart = createEmptyChart(null); //create a empty graph first
    chartPanel = new ChartPanel(chart, false);
    chartPanel.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y - 100));

    /*   sliderPanel = new JPanel();
             /*from   w w  w. j  av a  2s .c o  m*/
       // ValueSetter(String title, int type int min, int max, int initial,boolean minimumRange10) 
          powerSlider = new ValueSlider("Power", -10, 10, 1,true);
            
          reset_slider();// the range will need to be reset
          powerSlider.setPreferredSize(new Dimension(CHART_SIZE_X-10,100));
          powerSlider.addObserver(this);
          sliderPanel.add(this.powerSlider);
          sliderPanel.setPreferredSize(new Dimension(CHART_SIZE_X-10,100));*/

    graphPanel.add(chartPanel);
    //   graphPanel.add(sliderPanel);
    //System.out.println("added SliderPanel");
    graphPanel.validate();
}

From source file:edu.ucla.stat.SOCR.chart.SuperBoxAndWhiskerChart_Vertical.java

protected void setChart() {
    // update graph
    //   System.out.println("setChart called");

    graphPanel.removeAll();//  w  w w.  ja v a 2  s .  c  o  m
    graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS));

    chartPanel.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y));

    if (legendPanelOn) {
        JFreeChart chart2 = createLegendChart(createLegend(dataset));
        legendPanel = new ChartPanel(chart2, false);
        //legendPanel.setPreferredSize(new Dimension(CHART_SIZE_X,CHART_SIZE_Y*2/3));
    }

    graphPanel.add(chartPanel);
    JScrollPane legendPane = new JScrollPane(legendPanel);
    if (legendPanelOn) {
        legendPane.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y / 5));
        graphPanel.add(legendPane);
    }

    graphPanel.validate();

    // get the GRAPH panel to the front
    if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) != ALL) {
        tabbedPanelContainer.setSelectedIndex(tabbedPanelContainer.indexOfComponent(graphPanel));
        graphPanel.removeAll();
        graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS));

        graphPanel.add(chartPanel);

        if (legendPanelOn) {
            legendPane = new JScrollPane(legendPanel);
            legendPane.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y / 5));
            graphPanel.add(legendPane);
        }
        graphPanel.validate();
    } else {
        graphPanel2.removeAll();
        chartPanel.setPreferredSize(new Dimension(CHART_SIZE_X * 2 / 3, CHART_SIZE_Y * 2 / 3));
        //legendPanel.setPreferredSize(new Dimension(CHART_SIZE_X*2/3,CHART_SIZE_Y*2/5));
        graphPanel2.add(chartPanel);
        if (legendPanelOn) {
            legendPane = new JScrollPane(legendPanel);
            legendPane.setPreferredSize(new Dimension(CHART_SIZE_X * 2 / 3, CHART_SIZE_Y * 2 / 5));
            graphPanel2.add(legendPane);
        }
        graphPanel2.validate();
        summaryPanel.validate();
    }
}

From source file:fungus.JungVisualizer.java

public JungVisualizer(String name) {
    this.name = name;

    showEdges = Configuration.getBoolean(name + "." + PAR_SHOW_EDGES);
    scaleShapes = Configuration.getBoolean(name + "." + PAR_SCALE_SHAPES);
    labelNodes = Configuration.getBoolean(name + "." + PAR_LABEL_NODES);
    imageDir = Configuration.getString(name + "." + PAR_IMAGE_DIR);
    nameFragment = Configuration.getString(PAR_TESTNAME);

    if (vt == null) {
        try {//from   w w  w.j av a2  s. c om
            Class vtClass = Configuration.getClass(name + "." + PAR_TRANSFORMERS);
            if (VisualizerTransformers.class.isAssignableFrom(vtClass)) {
                vt = (VisualizerTransformers) vtClass.newInstance();
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    graph = JungGraphObserver.getGraph();

    vt.setGraph(graph); // Have to call this manually!

    JungGraphObserver.stepBlocked = true;
    JungGraphObserver.noBlock = false;

    layout = vt.makeLayout(graph);

    Dimension preferredSize = new Dimension(660, 660);
    visualizationModel = new DefaultVisualizationModel<MycoNode, MycoEdge>(layout, preferredSize);

    relaxer = visualizationModel.getRelaxer();

    visualizer = new VisualizationViewer<MycoNode, MycoEdge>(visualizationModel, preferredSize);
    visualizer.addGraphMouseListener(new InfoFrameVertexListener());

    visualizer.setDoubleBuffered(true);

    // final Color under50VertexColor = Color.BLACK;
    // final Stroke under50VertexStroke = new BasicStroke(1.0f,
    //                                                    BasicStroke.CAP_BUTT,
    //                                                    BasicStroke.JOIN_MITER);
    // final Color over50VertexColor = Color.MAGENTA;
    // final Stroke over50VertexStroke = new BasicStroke(2.0f,
    //                                                   BasicStroke.CAP_BUTT,
    //                                                   BasicStroke.JOIN_MITER);
    // final Color over80VertexColor = Color.BLUE;
    // final Stroke over80VertexStroke = new BasicStroke(2.0f,
    //                                                   BasicStroke.CAP_BUTT,
    //                                                   BasicStroke.JOIN_MITER);
    // final Color over95VertexColor = Color.GREEN;
    // final Stroke over95VertexStroke = new BasicStroke(2.0f,
    //                                                   BasicStroke.CAP_BUTT,
    //                                                   BasicStroke.JOIN_MITER);
    // final Color over100VertexColor = Color.RED;
    // final Stroke over100VertexStroke = new BasicStroke(5.0f,
    //                                                    BasicStroke.CAP_BUTT,
    //                                                    BasicStroke.JOIN_MITER);
    // Transformer<MycoNode,Stroke> nodeStrokeRenderer =
    //     new Transformer<MycoNode, Stroke>() {
    //   public Stroke transform(MycoNode n){
    //     int capacity = n.getHyphaData().getMax();
    //     int attached = n.getHyphaLink().degree();
    //     double ratio = ((double) attached) / ((double) capacity);

    //     if (ratio > 1.0) {
    //       return over100VertexStroke;
    //     } else if (ratio > 0.95) {
    //       return over95VertexStroke;
    //     } else if (ratio > 0.80) {
    //       return over80VertexStroke;
    //     } else if (ratio > 0.50) {
    //       return over50VertexStroke;
    //     } else {
    //       return under50VertexStroke;
    //     }
    //   }
    // };
    // Transformer<MycoNode,Paint> nodeOutlineRenderer =
    //     new Transformer<MycoNode, Paint>() {
    //   public Paint transform(MycoNode n) {
    //     int capacity = n.getHyphaData().getMax();
    //     int attached = n.getHyphaLink().degree();
    //     double ratio = ((double) attached) / ((double) capacity);

    //     if (ratio > 1.0) {
    //       return over100VertexColor;
    //     } else if (ratio > 0.95) {
    //       return over95VertexColor;
    //     } else if (ratio > 0.80) {
    //       return over80VertexColor;
    //     } else if (ratio > 0.50) {
    //       return over50VertexColor;
    //     } else {
    //       return under50VertexColor;
    //     }
    //   }
    // };

    /*Transformer<MycoNode,Paint> nodeFillRenderer = new Transformer<MycoNode,Paint>() {
      public Paint transform(MycoNode n) {
      HyphaData data = n.getHyphaData();
      if (!n.isUp()) { return Color.BLACK; }
      if (data.isBiomass()) { return Color.BLUE; }
      else if (data.isExtending()) { return Color.RED; }
      else if (data.isBranching()) { return Color.YELLOW; }
      else { return Color.GREEN; }
      }
      };*/

    /*Transformer<MycoNode,Paint> nodeFillRenderer = new Transformer<MycoNode,Paint>() {
      public Paint transform(MycoNode n) {
      HyphaData data = n.getHyphaData();
      if (data.isBiomass()) { return Color.BLUE; }
      else if (data.isExtending()) { return Color.RED; }
      else if (data.isBranching()) { return Color.YELLOW; }
      else { return Color.GREEN; }
      }
      };*/

    final Color transparent = new Color(0, 0, 0, 0);

    Transformer<MycoEdge, Paint> transparentEdges = new Transformer<MycoEdge, Paint>() {
        public Paint transform(MycoEdge e) {
            return transparent;
        }
    };

    visualizer.setBackground(Color.WHITE);

    visualizer.getRenderContext().setVertexFillPaintTransformer(vt.getNodeFillRenderer());
    visualizer.getRenderContext().setVertexShapeTransformer(vt.getShapeTransformer(scaleShapes));
    if (labelNodes) {
        visualizer.getRenderContext().setVertexLabelTransformer(vt.getNodeLabeller());
    }
    visualizer.getRenderContext().setVertexStrokeTransformer(vt.getVertexStrokeTransformer());
    visualizer.getRenderContext().setVertexDrawPaintTransformer(vt.getVertexDrawPaintTransformer());
    //visualizer.setVertexToolTipTransformer(new ToStringLabeller());

    if (showEdges) {
        visualizer.getRenderContext().setEdgeStrokeTransformer(vt.getEdgeStrokeTransformer());
        visualizer.getRenderContext().setEdgeDrawPaintTransformer(vt.getEdgeDrawPaintTransformer());
        visualizer.getRenderContext().setArrowDrawPaintTransformer(vt.getEdgeDrawPaintTransformer());
        visualizer.getRenderContext().setArrowFillPaintTransformer(vt.getEdgeDrawPaintTransformer());
    } else {
        visualizer.getRenderContext().setEdgeDrawPaintTransformer(transparentEdges);
        visualizer.getRenderContext().setArrowDrawPaintTransformer(transparentEdges);
        visualizer.getRenderContext().setArrowFillPaintTransformer(transparentEdges);
    }

    frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Container c = frame.getContentPane();
    c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS));

    //JScrollPane scrollPane = new JScrollPane(visualizer);
    //c.add(scrollPane);
    c.add(visualizer);

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));

    final JButton captureButton = new JButton("capture");
    ActionListener capturer = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            saveAsPNG();
        }
    };
    captureButton.addActionListener(capturer);

    final JButton freezeButton = new JButton("freeze");
    ActionListener freezer = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (freezeButton.getText().equals("freeze")) {
                relaxer.pause();
                freezeButton.setText("unfreeze");
            } else {
                relaxer.resume();
                freezeButton.setText("freeze");
            }
        }
    };
    freezeButton.addActionListener(freezer);

    JButton pauseButton = new JButton("pause");
    ActionListener pauser = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //e.consume();
            JungGraphObserver.pauseAction();
        }
    };
    pauseButton.addActionListener(pauser);

    JButton stepButton = new JButton("step");
    ActionListener stepper = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Clicked!\n");
            //e.consume();
            JungGraphObserver.stepAction();
        }
    };
    stepButton.addActionListener(stepper);

    JButton walkButton = new JButton("walk");
    ActionListener walker = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Clicked!\n");
            //e.consume();
            JungGraphObserver.walkAction();
        }
    };
    walkButton.addActionListener(walker);

    JButton runButton = new JButton("run");
    ActionListener runner = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //e.consume();
            JungGraphObserver.runAction();
        }
    };
    runButton.addActionListener(runner);

    roundField = new JTextField("0");

    buttonPane.add(freezeButton);
    buttonPane.add(captureButton);
    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(pauseButton);
    buttonPane.add(stepButton);
    buttonPane.add(walkButton);
    buttonPane.add(runButton);
    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(roundField);
    c.add(buttonPane);

    frame.pack();
    frame.setVisible(true);

    JungGraphObserver.setVisualizer(visualizer);
}