Example usage for com.jgoodies.looks Options HEADER_STYLE_KEY

List of usage examples for com.jgoodies.looks Options HEADER_STYLE_KEY

Introduction

In this page you can find the example usage for com.jgoodies.looks Options HEADER_STYLE_KEY.

Prototype

String HEADER_STYLE_KEY

To view the source code for com.jgoodies.looks Options HEADER_STYLE_KEY.

Click Source Link

Document

A client property key for JMenuBar and JToolBar style hints.

Usage

From source file:at.lux.fotoannotation.AnnotationFrame.java

License:Open Source License

private void init() {
    try {//  www .  j a va 2s.  c o m
        LoggerInit.configureLog4j("log4j.properties", "INFO");
        this.setIconImage(ImageIO.read(AnnotationFrame.class.getResource("data/caliph-icon.png")));
        //            this.setIconImage(ImageIO.read(AnnotationFrame.class.getResource("data/icon.gif")));
    } catch (Exception e) {
        debug("Couldn't set Icon: IOException " + e.getMessage());
    }
    df = (DecimalFormat) DecimalFormat.getInstance();
    df.setMaximumFractionDigits(2);

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent event) {
            super.windowClosing(event);
            exitApplication();
        }
    });
    // -------------------------------------------------------------------------------
    // Ueberpruefung ob das agent file existiert, sonst muss es angelegt werden ...
    // Eine sicherheitskopie befindet sich im package ...
    // -------------------------------------------------------------------------------
    debug("Checking if agentfile is here ...");
    File agentsFile = new File(AnnotationToolkit.AGENTS_FILE);
    if (!agentsFile.exists()) {
        try {
            debug("Generating sample agents file");
            Document d = new SAXBuilder().build(AnnotationFrame.class.getResource("data/agents.mp7.xml"));
            FileOutputStream fos = new FileOutputStream(agentsFile);
            OutputStreamWriter osw = new OutputStreamWriter(fos, "utf-8");
            new XMLOutputter(Format.getPrettyFormat()).output(d, osw);
            osw.close();
            fos.close();
            debug("Finished generating sample agents file");
        } catch (Exception e) {
            debug("Error generating sample agents file " + e.toString() + ", " + e.getMessage());
        }
    } else {
        debug("agentfile found :)");
    }
    debug("reading configurationfile ... ");
    // -------------------------------------------------------------------------------
    // Ueberpruefung ob das base-object file existiert, sonst muss es angelegt werden.
    // Eine sicherheitskopie befindet sich im package ...
    // -------------------------------------------------------------------------------
    debug("Checking if agentfile is here ...");
    File baseobjectsFile = new File("base-objects.mp7.xml");
    if (!baseobjectsFile.exists()) {
        try {
            debug("Generating sample base-objects file");
            Document d = new SAXBuilder().build(AnnotationFrame.class.getResource("data/base-objects.mp7.xml"));
            FileOutputStream fos = new FileOutputStream(baseobjectsFile);
            OutputStreamWriter osw = new OutputStreamWriter(fos, "utf-8");
            new XMLOutputter(Format.getPrettyFormat()).output(d, osw);
            osw.close();
            fos.close();
            debug("Finished generating sample base-objects file");
        } catch (Exception e) {
            debug("Error generating sample base-objects file " + e.toString() + ", " + e.getMessage());
        }
    } else {
        debug("base-objects file found :)");
    }
    debug("reading configurationfile ... ");
    // -------------------------------------------------------------------------------
    // Ueberpruefung ob das property file existiert, sonst muss es angelegt werden ...
    // Eine sicherheitskopie befindet sich im package ...
    // -------------------------------------------------------------------------------
    File pFile = new File("properties.xml");
    if (!pFile.exists()) {
        try {
            debug("Generating sample property file");
            Document d = new SAXBuilder().build(AnnotationFrame.class.getResource("data/properties.xml"));
            FileOutputStream fos = new FileOutputStream(pFile);
            OutputStreamWriter osw = new OutputStreamWriter(fos, "utf-8");
            new XMLOutputter(Format.getPrettyFormat()).output(d, osw);
            osw.close();
            fos.close();
            debug("Finished generating sample property file");
        } catch (Exception e) {
            debug("Error generating sample property file " + e.toString() + ", " + e.getMessage());
        }
    }
    properties = new AnnotationFrameProperties(new File("properties.xml"), this);
    debug("finished reading configurationfile");
    JMenuBar menuBar = properties.getMenuBar();
    // For JGoodies Look & Feel:
    menuBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
    menuBar.putClientProperty(PlasticLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR);
    this.setJMenuBar(menuBar);
    debug("finished creating menu");

    fileTree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent tse) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) tse.getNewLeadSelectionPath()
                    .getLastPathComponent();
            if (node.getUserObject() instanceof FileNodeObject) {
                File f = ((FileNodeObject) node.getUserObject()).getContent();
                if (!f.isDirectory()) {
                    try {
                        setCurrentFile(f);
                    } catch (IOException e) {
                        System.err.println("Error opening file: " + f.toString());
                        System.err.println(e.toString());
                        //                            e.printStackTrace();
                    }
                }
            }
        }
    });
    setToCurrentLocation(fileTree);

    // -------------------------------------
    // Initialising main Objects ...
    // -------------------------------------
    // TextChangeListener intialization for detecting changes of the document.
    TextChangesListener.createInstance(this);
    // -------------------------------------
    // Adding Components
    // -------------------------------------

    beePanel = new IMBeeApplicationPanel(this);
    colorPanel = new ColorLayoutPanel();

    lrSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    lrSplit.setBorder(BorderFactory.createEmptyBorder());
    lrSplit.setDividerSize(3);
    tbSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    tbSplit.setBorder(BorderFactory.createEmptyBorder());
    tbSplit.setDividerSize(3);

    mdPanel = new MetadataDescriptionPanel(new AgentComboBoxModel(this));
    imagePanel = new ImageThumbPanel();
    //        fp = new FilePanel(new File("."), this);
    qualityPanel = new QualityPanel(new AgentComboBoxModel(this));
    textPanel = new TextDescriptionPanel(this);
    creationPanel = new CreationPanel(new AgentComboBoxModel(this));
    shapePanel = new ShapePanel(this);

    JPanel qualTextPanel = new JPanel(new BorderLayout());
    qualTextPanel.add(qualityPanel, BorderLayout.SOUTH);
    qualTextPanel.add(textPanel, BorderLayout.CENTER);
    gridPanel1 = new JPanel(new GridLayout(0, 2));
    JPanel _leftPanel1 = new JPanel(new BorderLayout());
    //        gridPanel2.add(textPanel);
    _leftPanel1.add(qualTextPanel, BorderLayout.CENTER);
    _leftPanel1.add(mdPanel, BorderLayout.SOUTH);
    gridPanel1.add(_leftPanel1);
    gridPanel1.add(creationPanel);
    JPanel gridPanel3 = new JPanel(new GridLayout(0, 1));
    gridPanel3.add(colorPanel);
    //        gridPanel3.add(qualTextPanel);

    tabs = new JTabbedPane(JTabbedPane.TOP);
    tabs.setBorder(BorderFactory.createEmptyBorder());
    tabs.add("Image Information", gridPanel1);
    tabs.add("Semantics", beePanel);
    tabs.add("Shape", shapePanel);
    tabs.add("Visuals", gridPanel3);

    // file tree ....
    // ---------------
    JScrollPane fileTreeScrollPane = new JScrollPane(fileTree);
    JPanel filePanel = new JPanel(new BorderLayout());
    filePanel.add(fileTreeScrollPane, BorderLayout.CENTER);
    // TODO: remove error here ...
    fileComboBox = new JComboBox(File.listRoots());
    fileComboBox.setActionCommand("rootChanged");
    fileComboBox.addActionListener(this);
    filePanel.add(fileComboBox, BorderLayout.NORTH);
    tbSplit.add(filePanel, JSplitPane.TOP);
    tbSplit.add(imagePanel, JSplitPane.BOTTOM);

    lrSplit.add(tbSplit, JSplitPane.LEFT);
    lrSplit.add(tabs, JSplitPane.RIGHT);

    lrSplit.setDividerLocation(properties.getLrSplit());
    tbSplit.setDividerLocation(properties.getTbSplit());

    status = new JLabel(TITLE_BAR);
    status.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0));
    garbageState = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);
    garbageState.setStringPainted(true);
    garbageState.setPreferredSize(new Dimension(100, 18));
    garbageState.setToolTipText(
            "This bar shows the memory allocated by the VM and how much of it is already in use.");
    garbageState.setBorder(BorderFactory.createEmptyBorder());
    gtracker = new GarbageTracker(garbageState);

    JPanel sgcPanel = new JPanel(new BorderLayout());
    sgcPanel.add(garbageState, BorderLayout.EAST);
    sgcPanel.add(status, BorderLayout.CENTER);

    this.getContentPane().add(lrSplit, BorderLayout.CENTER);
    this.getContentPane().add(sgcPanel, BorderLayout.SOUTH);

    this.setSize(properties.getFrameWidth(), properties.getFrameHeigth());
    this.setLocation(properties.getFrameLocationX(), properties.getFrameLocationY());

    beePanel.reArrange();
    //beePanel.revalidate();
    gtracker.start();
    // call init from global configuration while splash is on screen :)
    IconCache.getInstance();
}

From source file:com.eviware.soapui.SoapUI.java

License:EUPL

private JComponent buildToolbar() {
    mainToolbar = new JXToolBar();
    mainToolbar.setFloatable(false);//w  ww . j  a  v a  2s  . co m
    mainToolbar.setRollover(true);
    mainToolbar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
    mainToolbar.add(new NewWsdlProjectActionDelegate());
    mainToolbar.add(new ImportWsdlProjectActionDelegate());
    mainToolbar.add(new SaveAllActionDelegate());
    mainToolbar.addSpace(2);
    mainToolbar.add(new ShowOnlineHelpAction("Forum", HelpUrls.FORUMS_HELP_URL,
            "Opens the SoapUI Forum in a browser", "/group_go.png"));
    mainToolbar.addSpace(2);
    mainToolbar.add(new ShowOnlineHelpAction("Trial", HelpUrls.TRIAL_URL, "Apply for SoapUI Pro Trial License",
            "/favicon.png"));
    mainToolbar.addSpace(2);
    mainToolbar.add(new PreferencesActionDelegate());
    applyProxyButton = (JToggleButton) mainToolbar.add(new JToggleButton(new ApplyProxyButtonAction()));
    updateProxyButtonAndTooltip();

    mainToolbar.addGlue();

    searchField = new JTextField(20);
    searchField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyTyped(KeyEvent e) {
            if (e.getKeyChar() == '\n') {
                doForumSearch(searchField.getText());
            }
        }
    });

    JLabel searchLabel = new JLabel("Search Forum");
    // Extra width to avoid label to be truncated
    searchLabel.setPreferredSize(new Dimension((int) (searchLabel.getPreferredSize().getWidth() * 1.1),
            (int) searchLabel.getPreferredSize().getHeight()));
    mainToolbar.addFixed(searchLabel);
    mainToolbar.addSeparator(new Dimension(3, 3));
    mainToolbar.addFixed(searchField);
    mainToolbar.add(new ToolbarForumSearchAction());
    mainToolbar.add(new ShowOnlineHelpAction(HelpUrls.USERGUIDE_HELP_URL));

    for (int i = 0; i < mainToolbar.getComponentCount(); i++) {
        if (mainToolbar.getComponent(i) instanceof JComponent) {
            ((JComponent) mainToolbar.getComponent(i)).setBorder(BorderFactory.createEmptyBorder(4, 2, 4, 2));
        }
    }

    mainToolbar.setBorder(BorderFactory.createEmptyBorder(3, 1, 3, 1));

    return mainToolbar;
}

From source file:com.eviware.soapui.SoapUI.java

License:EUPL

private JMenuBar buildMainMenu() {
    menuBar = new JMenuBar();
    menuBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);

    menuBar.add(buildFileMenu());//from w ww . java 2  s  . c o m
    menuBar.add(buildToolsMenu());
    menuBar.add(buildDesktopMenu());
    menuBar.add(buildHelpMenu());

    return menuBar;
}

From source file:com.eviware.soapui.support.action.swing.JXSoapUIActionListToolBar.java

License:EUPL

@SuppressWarnings("unchecked")
public JXSoapUIActionListToolBar(ActionList actions, ModelItem modelItem) {
    addSpace(1);//from w  ww . j  a v a2  s  .  c  o  m
    setRollover(true);
    putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.SINGLE);
    setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0));

    for (int i = 0; i < actions.getActionCount(); i++) {
        Action action = actions.getActionAt(i);

        if (action instanceof MarkerAction) {
            continue;
        }

        if (action == ActionSupport.SEPARATOR_ACTION) {
            addSeparator();
        } else if (action instanceof ActionSupport.ActionListAction) {
            // JMenu subMenu = buildMenu(
            // ((ActionListAction)action).getActionList() );
            // if( subMenu == null )
            // subMenu = new JMenu(
            // ((ActionListAction)action).getActionList().getLabel() );
            // menu.add( subMenu);
        } else if (action != null) {
            JComponent component = null;

            if (action instanceof SoapUIActionMarker) {
                SoapUIAction soapUIAction = ((SoapUIActionMarker) action).getSoapUIAction();
                component = ActionComponentRegistry.buildActionComponent(soapUIAction, modelItem);
                actionMap.put(soapUIAction.getId(), action);
            }

            if (component != null) {
                add(component);
            } else {
                add(action);
            }
        }
    }
}

From source file:com.eviware.soapui.support.components.JInspectorPanelImpl.java

License:EUPL

private JXToolBar createInspectButtons() {
    inspectToolbar = new JXToolBar() {
        @Override//from w ww.j  a v a 2  s.  com
        public Dimension getMinimumSize() {
            return new Dimension(10, 10);
        }
    };

    inspectToolbar.setFloatable(false);
    inspectToolbar.setRollover(true);
    inspectToolbar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.SINGLE);
    inspectToolbar.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0));

    if (orientation == SwingConstants.TOP || orientation == SwingConstants.BOTTOM) {
        inspectToolbar.addSpace(10);
    }
    inspectToolbar.setBackground(Color.WHITE);
    inspectToolbar.setOpaque(true);
    return inspectToolbar;
}

From source file:com.eviware.soapui.support.UISupport.java

License:EUPL

public static JXToolBar createToolbar() {
    JXToolBar toolbar = new JXToolBar();
    toolbar.setFloatable(false);//  w w w  .  j  a  v  a 2  s  .  c o  m
    toolbar.addSpace(1);
    toolbar.setRollover(true);
    toolbar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.SINGLE);
    toolbar.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0));
    toolbar.setMinimumSize(new Dimension(20, 20));
    return toolbar;
}

From source file:com.eviware.soapui.support.UISupport.java

License:EUPL

public static JXToolBar createSmallToolbar() {
    JXToolBar toolbar = new JXToolBar();
    toolbar.setFloatable(false);//from   w  ww  .  j  av  a  2  s.  c o m
    toolbar.addSpace(1);
    toolbar.setRollover(true);
    toolbar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.SINGLE);
    toolbar.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    toolbar.setMinimumSize(new Dimension(20, 20));
    return toolbar;
}

From source file:com.salas.bb.views.mainframe.BBMenuBuilder.java

License:Open Source License

/**
 * Build BlogBridge menu bar.//w ww . j a v a  2 s .c  om
 *
 * @return the resulting menu bar.
 */
public JMenuBar buildMenuBar() {
    JMenuBar myMenu = new JMenuBar();
    myMenu.setMargin(MENUBAR_MARGIN);

    // Apply some special style hints for JGoodies
    myMenu.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
    myMenu.putClientProperty(WindowsLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR);
    myMenu.putClientProperty(PlasticLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR);

    myMenu.add(buildGuidesMenu());
    myMenu.add(buildFeedsMenu());
    myMenu.add(buildArticlesMenu());
    myMenu.add(buildToolsMenu());
    myMenu.add(buildHelpMenu());
    return myMenu;
}

From source file:com.salas.bb.views.mainframe.BBToolBarBuilder.java

License:Open Source License

/**
 * JGoodies specific setup./*  w  w w  . j av  a 2  s .  com*/
 *
 * @param bldr builder.
 */
private void setToolBarJGoodiesSettings(ToolBarBuilder bldr) {
    JToolBar toolBar = bldr.getToolBar();

    toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
    toolBar.putClientProperty(PlasticLookAndFeel.IS_3D_KEY, Boolean.TRUE);
    toolBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.SINGLE);

    // Set a hint so that JGoodies Looks will detect it as being in the header.
    //        toolBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);

    // Unlike the default, use a separator border.
    toolBar.putClientProperty(WindowsLookAndFeel.BORDER_STYLE_KEY, BorderStyle.EMPTY);
    toolBar.putClientProperty(PlasticLookAndFeel.BORDER_STYLE_KEY, BorderStyle.EMPTY);
}

From source file:com.zeroc.IceGridGUI.LiveDeployment.GraphView.java

License:Open Source License

public GraphView(Coordinator coordinator, String title) {
    _coordinator = coordinator;//w w w.j a v  a 2 s. co m
    setTitle(title);

    _preferences = Preferences.userNodeForPackage(getClass());

    //
    // Don't destroy JavaFX when the frame is disposed.
    //
    Platform.setImplicitExit(false);
    setIconImage(Utils.getIcon("/icons/16x16/metrics_graph.png").getImage());
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            close();
        }
    });

    //
    // Graph preferences.
    //
    Action preferences = new AbstractAction("Preferences") {
        @Override
        public void actionPerformed(ActionEvent event) {
            //
            // Set the title
            //
            JTextField title = new JTextField(getTitle());
            JPanel titlePanel;
            {
                DefaultFormBuilder builder = new DefaultFormBuilder(
                        new FormLayout("pref,2dlu,pref:grow", "pref"));
                builder.append("Title:", title);
                titlePanel = builder.getPanel();
            }

            //
            // SpinnerNumberModel to set a refresh period.
            //
            SpinnerNumberModel refreshPeriod = new SpinnerNumberModel(getRefreshPeriod(), _minRefreshPeriod,
                    _maxRefreshPeriod, 1);

            //
            // SpinnerNumberModel to set the maximum number of samples to keep in X axis.
            //
            final SpinnerNumberModel samples = new SpinnerNumberModel(_samples, _minSamples, _maxSamples, 1);

            JPanel refreshPanel;
            {
                DefaultFormBuilder builder = new DefaultFormBuilder(
                        new FormLayout("pref,2dlu,pref:grow", "pref"));
                builder.rowGroupingEnabled(true);
                final JSpinner spinner = new JSpinner(refreshPeriod);
                builder.append("Sample interval:", spinner);
                builder.append("", new JLabel("<html><p>Sample interval in seconds; must be between 1"
                        + "<br/>and 3600 seconds.</p></html>"));
                refreshPanel = builder.getPanel();
            }

            //
            // JComboBox to select time format used in X Axis
            //
            JComboBox<String> dateFormats = new JComboBox<>(_dateFormats);
            dateFormats.setSelectedItem(getDateFormat());
            JPanel xAxisPanel;
            {
                DefaultFormBuilder builder = new DefaultFormBuilder(
                        new FormLayout("pref,2dlu,pref:grow", "pref"));

                builder.append("Samples displayed:", new JSpinner(samples));
                builder.append("", new JLabel("<html><p>The number of samples displayed on a graph;"
                        + "<br/>must be between 2 and 300." + "</p></html>"));
                builder.append("Time format:", dateFormats);

                xAxisPanel = builder.getPanel();
            }

            FormLayout layout = new FormLayout("fill:pref:grow", "pref");
            final DefaultFormBuilder builder = new DefaultFormBuilder(layout);
            builder.border(Borders.DIALOG);
            builder.append(titlePanel);
            builder.nextLine();
            builder.append(refreshPanel);
            builder.nextLine();
            builder.append(xAxisPanel);

            if (JOptionPane.showConfirmDialog(GraphView.this, builder.getPanel(), "Metrics Graph Preferences",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) != JOptionPane.OK_OPTION) {
                return;
            }

            setTitle(title.getText());
            setRefreshPeriod(refreshPeriod.getNumber().intValue());
            setMaximumSamples(samples.getNumber().intValue());
            setDateFormat((String) dateFormats.getSelectedItem());
        }
    };

    _legendTable = new JTable(_legendModel) {
        //Implement table cell tool tips.
        @Override
        public String getToolTipText(java.awt.event.MouseEvent e) {
            if (convertColumnIndexToModel(columnAtPoint(e.getPoint())) == 6) {
                return _legendModel.getRows(new int[] { rowAtPoint(e.getPoint()) })[0].cell.getField()
                        .getColumnToolTip();
            } else {
                return null;
            }
        }
    };

    //
    // Adjust row height for larger fonts
    //
    int fontSize = _legendTable.getFont().getSize();
    int minRowHeight = fontSize + fontSize / 3;
    if (_legendTable.getRowHeight() < minRowHeight) {
        _legendTable.setRowHeight(minRowHeight);
    }

    //
    // Graph preferences.
    //
    final Action delete = new AbstractAction("Delete") {
        @Override
        public void actionPerformed(ActionEvent event) {
            int[] selectedRows = _legendTable.getSelectedRows();
            for (int i = 0; i < selectedRows.length; ++i) {
                selectedRows[i] = _legendTable.convertRowIndexToModel(selectedRows[i]);
            }
            //
            // Remove selected rows from the legend model.
            //
            final MetricsRow[] rows = _legendModel.removeRows(selectedRows);

            //
            // Remove rows from series hash maps
            //
            for (MetricsRow row : rows) {
                Map<String, Map<String, Map<String, MetricsRow>>> j = _series.get(row.info);
                Map<String, Map<String, MetricsRow>> k = j.get(row.cell.getField().getMetricsName());
                Map<String, MetricsRow> l = k.get(row.cell.getId());
                l.remove(row.cell.getField().getFieldName());
                if (l.size() == 0) {
                    k.remove(row.cell.getId());
                    if (k.size() == 0) {
                        j.remove(row.cell.getField().getMetricsName());
                        if (j.size() == 0) {
                            _series.remove(row.info);
                            if (_series.size() == 0) {
                                stopRefresh();
                            }
                        }
                    }
                }
            }

            //
            // Remove series from the chart, in JavaFx thread.
            //
            enqueueJFX(new Runnable() {
                @Override
                public void run() {
                    for (MetricsRow row : rows) {
                        for (int i = 0; i < row.series.size(); ++i) {
                            XYChart.Series<Number, Number> series = row.series.get(i);
                            String seriesClass = getSeriesClass(series);
                            if (seriesClass != null) {
                                _styles.remove(seriesClass);
                            }
                            //
                            // Don't remove the XYChart.Series object here, to avoid the series
                            // style classes to be reasign by JavaFX.
                            //
                            // _chart.getData().remove(row.series);
                            try {
                                series.getData().clear();
                            } catch (NullPointerException ex) {
                                // JavaFX bug
                            }
                        }
                    }
                }
            });
        }
    };
    delete.setEnabled(false);
    delete.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));

    _legendTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                delete.setEnabled(_legendTable.getSelectedRows().length > 0);
            }
        }
    });

    //
    // Create the tool bar
    //
    class ToolBar extends JToolBar {
        public ToolBar() {
            putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
            putClientProperty(PlasticLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR);
            setFloatable(false);
            putClientProperty("JToolBar.isRollover", Boolean.TRUE);

            JButton button = new JButton(delete);
            button.setText(null);
            button.setIcon(Utils.getIcon("/icons/24x24/delete.png"));
            add(button);
        }
    }

    //
    // Create menus
    //
    JMenuBar menuBar = new JMenuBar();

    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(java.awt.event.KeyEvent.VK_F);
    fileMenu.add(preferences);
    menuBar.add(fileMenu);

    JMenu editMenu = new JMenu("Edit");
    editMenu.setMnemonic(java.awt.event.KeyEvent.VK_E);
    editMenu.add(delete);
    menuBar.add(editMenu);

    setJMenuBar(menuBar);

    //
    // Set default renderer for numeric values.
    //
    _legendTable.setDefaultRenderer(Double.class, new FormatedNumberRenderer("#0.000"));

    //
    // Set a combobox to edit the scale factors.
    //
    JComboBox<Double> scales = new JComboBox<>(_scales);
    scales.setRenderer(new DecimalRenderer(scales.getRenderer()));
    _legendTable.getColumnModel().getColumn(7).setCellEditor(new DefaultCellEditor(scales));

    //
    // Set default renderer and editor for Color.class column.
    //
    _legendTable.setDefaultRenderer(Color.class, new ColorRenderer(true));
    _legendTable.setDefaultEditor(Color.class, new ColorEditor());

    _legendTable.setAutoCreateRowSorter(true);

    final JFXPanel fxPanel = new JFXPanel();
    fxPanel.setMinimumSize(new Dimension(0, 200));
    fxPanel.setPreferredSize(new Dimension(800, 400));
    //
    // Build the split pane, with the chart graph and the legend table.
    //
    _splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    _splitPane.setTopComponent(fxPanel);
    JScrollPane scrollPane = new JScrollPane(_legendTable);
    scrollPane.setTransferHandler(new TransferHandler());
    scrollPane.setMinimumSize(new Dimension(0, 50));
    scrollPane.setPreferredSize(new Dimension(800, 200));
    _splitPane.setBottomComponent(scrollPane);

    DefaultFormBuilder builder = new DefaultFormBuilder(
            new FormLayout("fill:pref:grow", "fill:pref:grow, pref"));
    builder.append(_splitPane);
    builder.nextLine();

    JPanel panel = builder.getPanel();
    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    getContentPane().add(new ToolBar(), BorderLayout.PAGE_START);
    getContentPane().add(panel, BorderLayout.CENTER);
    setPreferredSize(new Dimension(800, 600));

    //
    // initialize the scene in JavaFX thread.
    //
    enqueueJFX(() -> {
        _xAxis = new NumberAxis();
        _yAxis = new NumberAxis();

        _chart = new LineChart<>(_xAxis, _yAxis);
        _chart.setCreateSymbols(false);
        _xAxis.setLabel("Time (" + getDateFormat() + ")");
        _xAxis.setTickLabelFormatter(_timeFormater);
        _xAxis.setForceZeroInRange(false);
        _chart.setAnimated(true);
        _chart.setLegendVisible(false);

        final Scene scene = new Scene(_chart);
        scene.setOnDragOver(new EventHandler<DragEvent>() {
            @Override
            public void handle(DragEvent event) {
                Dragboard db = event.getDragboard();
                if (event.getGestureSource() != scene && db.hasContent(LocalObjectMimeType)) {
                    Object object = db.getContent(LocalObjectMimeType);
                    if (object instanceof MetricsViewTransferableData) {
                        event.acceptTransferModes(TransferMode.COPY);
                    }
                }
                event.consume();
            }
        });

        scene.setOnDragDropped(new EventHandler<DragEvent>() {
            @Override
            public void handle(DragEvent event) {
                boolean success = false;
                Dragboard db = event.getDragboard();
                if (event.getGestureSource() != scene && db.hasContent(LocalObjectMimeType)) {
                    Object object = db.getContent(LocalObjectMimeType);
                    if (object instanceof MetricsViewTransferableData) {
                        addSeries((MetricsViewTransferableData) object);
                        success = true;
                    }
                }
                event.setDropCompleted(success);
                event.consume();
            }
        });
        fxPanel.setScene(scene);
    });

    pack();
    if (!loadPreferences()) {
        _splitPane.setDividerLocation(400);
    }
    setVisible(true);

    //
    // Show info dialog if required.
    //
    if (showInfo()) {
        JCheckBox checkbox = new JCheckBox("Do not show this message again.");
        String message = "Drop metrics cells to add them to the graph.";

        JOptionPane.showConfirmDialog(this, new Object[] { message, checkbox }, "Information",
                JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE);
        if (checkbox.isSelected()) {
            _preferences.node("GraphView").putBoolean("showInfo", false);
        }
    }
}