Example usage for java.awt Font getFamily

List of usage examples for java.awt Font getFamily

Introduction

In this page you can find the example usage for java.awt Font getFamily.

Prototype

public String getFamily() 

Source Link

Document

Returns the family name of this Font .

Usage

From source file:org.tinymediamanager.ui.movies.settings.MovieSubtitleSettingsPanel.java

private void initComponents() {
    // data init//ww w  . j  av  a 2  s.co m
    List<String> enabledSubtitleProviders = settings.getMovieSubtitleScrapers();
    int selectedIndex = -1;
    int counter = 0;
    for (MediaScraper scraper : MovieList.getInstance().getAvailableSubtitleScrapers()) {
        SubtitleScraper subtitleScraper = new SubtitleScraper(scraper);
        if (enabledSubtitleProviders.contains(subtitleScraper.getScraperId())) {
            subtitleScraper.active = true;
            if (selectedIndex < 0) {
                selectedIndex = counter;
            }
        }
        scrapers.add(subtitleScraper);
        counter++;
    }

    // UI init
    setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    JPanel panelSubtitleScrapers = new JPanel();
    panelSubtitleScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"),
            BUNDLE.getString("scraper.subtitle"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$
    add(panelSubtitleScrapers, "2, 2, 5, 1, fill, fill");
    panelSubtitleScrapers.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"), }));

    final JScrollPane scrollPaneScraperDetails = new JScrollPane();
    scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPaneScraperDetails.setBorder(null);
    panelSubtitleScrapers.add(scrollPaneScraperDetails, "4, 1, 1, 2, fill, fill");

    JPanel panelScraperDetails = new JPanel();
    scrollPaneScraperDetails.setViewportView(panelScraperDetails);
    panelScraperDetails.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), },
            new RowSpec[] { RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, }));
    {
        // add a CSS rule to force body tags to use the default label font
        // instead of the value in javax.swing.text.html.default.csss
        Font font = UIManager.getFont("Label.font");
        String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize()
                + "pt; }";
        tpScraperDescription = new JTextPane();
        tpScraperDescription.setOpaque(false);
        tpScraperDescription.setEditorKit(new HTMLEditorKit());
        ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule);
        panelScraperDetails.add(tpScraperDescription, "1, 1, fill, top");
    }
    panelScraperOptions = new ScrollablePanel();
    panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT));
    panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top");

    JScrollPane scrollPaneScraper = new JScrollPane();
    panelSubtitleScrapers.add(scrollPaneScraper, "2, 2, fill, fill");

    tableScraper = new JTable();
    tableScraper.setRowHeight(29);
    scrollPaneScraper.setViewportView(tableScraper);

    final JLabel lblScraperLanguage = new JLabel(BUNDLE.getString("Settings.preferredLanguage")); //$NON-NLS-1$
    add(lblScraperLanguage, "2, 4, right, default");

    cbScraperLanguage = new JComboBox(MediaLanguages.values());
    add(cbScraperLanguage, "4, 4, fill, default");

    initDataBindings();

    // adjust table columns
    // Checkbox and Logo shall have minimal width
    TableColumnResizer.setMaxWidthForColumn(tableScraper, 0, 2);
    TableColumnResizer.setMaxWidthForColumn(tableScraper, 1, 2);
    TableColumnResizer.adjustColumnPreferredWidths(tableScraper, 5);

    tableScraper.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent arg0) {
            // click on the checkbox
            if (arg0.getColumn() == 0) {
                int row = arg0.getFirstRow();
                SubtitleScraper changedScraper = scrapers.get(row);
                if (changedScraper.active) {
                    settings.addMovieSubtitleScraper(changedScraper.getScraperId());
                } else {
                    settings.removeMovieSubtitleScraper(changedScraper.getScraperId());
                }
            }
        }
    });

    // implement selection listener to load settings
    tableScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            int index = tableScraper.convertRowIndexToModel(tableScraper.getSelectedRow());
            if (index > -1) {
                panelScraperOptions.removeAll();
                if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) {
                    panelScraperOptions
                            .add(new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider()));
                }
                panelScraperOptions.revalidate();
            }
        }
    });

    // select default movie scraper
    if (selectedIndex < 0) {
        selectedIndex = 0;
    }
    if (counter > 0) {
        tableScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);
    }
}

From source file:org.tinymediamanager.ui.tvshows.settings.TvShowSubtitleSettingsPanel.java

private void initComponents() {
    // data init//from  w  ww. j a  v a  2s  . c o  m
    List<String> enabledSubtitleProviders = settings.getTvShowSubtitleScrapers();
    int selectedIndex = -1;
    int counter = 0;
    for (MediaScraper scraper : TvShowList.getInstance().getAvailableSubtitleScrapers()) {
        SubtitleScraper subtitleScraper = new SubtitleScraper(scraper);
        if (enabledSubtitleProviders.contains(subtitleScraper.getScraperId())) {
            subtitleScraper.active = true;
            if (selectedIndex < 0) {
                selectedIndex = counter;
            }
        }
        scrapers.add(subtitleScraper);
        counter++;
    }

    // UI init
    setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    JPanel panelSubtitleScrapers = new JPanel();
    panelSubtitleScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"),
            BUNDLE.getString("scraper.subtitle"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$
    add(panelSubtitleScrapers, "2, 2, 5, 1, fill, fill");
    panelSubtitleScrapers.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"), }));

    final JScrollPane scrollPaneScraperDetails = new JScrollPane();
    scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPaneScraperDetails.setBorder(null);
    panelSubtitleScrapers.add(scrollPaneScraperDetails, "4, 1, 1, 2, fill, fill");

    JPanel panelScraperDetails = new JPanel();
    scrollPaneScraperDetails.setViewportView(panelScraperDetails);
    panelScraperDetails.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), },
            new RowSpec[] { RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, }));
    {
        // add a CSS rule to force body tags to use the default label font
        // instead of the value in javax.swing.text.html.default.csss
        Font font = UIManager.getFont("Label.font");
        String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize()
                + "pt; }";
        tpScraperDescription = new JTextPane();
        tpScraperDescription.setOpaque(false);
        tpScraperDescription.setEditorKit(new HTMLEditorKit());
        ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule);
        panelScraperDetails.add(tpScraperDescription, "1, 1, fill, top");
    }
    panelScraperOptions = new ScrollablePanel();
    panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT));
    panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top");

    JScrollPane scrollPaneScraper = new JScrollPane();
    panelSubtitleScrapers.add(scrollPaneScraper, "2, 2, fill, fill");

    tableScraper = new JTable();
    tableScraper.setRowHeight(29);
    scrollPaneScraper.setViewportView(tableScraper);

    final JLabel lblScraperLanguage = new JLabel(BUNDLE.getString("Settings.preferredLanguage")); //$NON-NLS-1$
    add(lblScraperLanguage, "2, 4, right, default");

    cbScraperLanguage = new JComboBox(MediaLanguages.values());
    add(cbScraperLanguage, "4, 4, fill, default");

    initDataBindings();

    // adjust table columns
    // Checkbox and Logo shall have minimal width
    TableColumnResizer.setMaxWidthForColumn(tableScraper, 0, 2);
    TableColumnResizer.setMaxWidthForColumn(tableScraper, 1, 2);
    TableColumnResizer.adjustColumnPreferredWidths(tableScraper, 5);

    tableScraper.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent arg0) {
            // click on the checkbox
            if (arg0.getColumn() == 0) {
                int row = arg0.getFirstRow();
                SubtitleScraper changedScraper = scrapers.get(row);
                if (changedScraper.active) {
                    settings.addTvShowSubtitleScraper(changedScraper.getScraperId());
                } else {
                    settings.removeTvShowSubtitleScraper(changedScraper.getScraperId());
                }
            }
        }
    });

    // implement selection listener to load settings
    tableScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            int index = tableScraper.convertRowIndexToModel(tableScraper.getSelectedRow());
            if (index > -1) {
                panelScraperOptions.removeAll();
                if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) {
                    panelScraperOptions
                            .add(new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider()));
                }
                panelScraperOptions.revalidate();
            }
        }
    });

    // select default tv show subtitle scraper
    if (selectedIndex < 0) {
        selectedIndex = 0;
    }
    if (counter > 0) {
        tableScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);
    }
}

From source file:FontChooser.java

public boolean doesFontMatch(Font font) {
    if (font == null) {
        return false;
    }/*w  w  w  . j av  a  2s  . c o m*/
    return font.getFamily().equals(_familyName) && font.getSize() == getSize()
            && font.getStyle() == generateStyle();
}

From source file:org.zephyrsoft.sdb2.presenter.SongView.java

private Style addStyleFromFont(String styleName, Font font) {
    return addStyle(styleName, font.isItalic(), font.isBold(), font.getFamily(), font.getSize());
}

From source file:ome.formats.importer.gui.OptionsDialog.java

/**
 * Initialize and show the options dialog
 * //  w  w w.jav a 2  s .  c o  m
 * @param config - ImportConfig to store/save settings too
 * @param owner - parent 
 * @param title - dialog title
 * @param modal - modal yes/no
 */
OptionsDialog(ImportConfig config, JFrame owner, String title, boolean modal) {
    super(owner);

    this.owner = owner;

    setLocation(200, 200);
    setTitle(title);
    setModal(modal);
    setResizable(false);
    setSize(new Dimension(dialogWidth, dialogHeight));
    setLocationRelativeTo(owner);

    tabbedPane = new JTabbedPane();
    tabbedPane.setOpaque(false); // content panes must be opaque

    this.config = config;

    oldQuaquaLevel = config.getUseQuaqua();
    oldUserDisableHistory = config.getUserDisableHistory();

    /////////////////////// START MAIN PANEL ////////////////////////

    // Set up the main pane
    double mainPanelTable[][] = { { TableLayout.FILL, 120, 5, 120, TableLayout.FILL }, // columns
            { TableLayout.FILL, 5, 30 } }; // rows     

    mainPanel = GuiCommonElements.addMainPanel(this, mainPanelTable, 10, 10, 10, 10, debug);

    // Buttons at the bottom of the form

    cancelBtn = GuiCommonElements.addButton(mainPanel, "Cancel", 'L', "Cancel", "1, 2, f, c", debug);
    cancelBtn.addActionListener(this);

    okBtn = GuiCommonElements.addButton(mainPanel, "OK", 'Q', "Import", "3, 2, f, c", debug);
    okBtn.addActionListener(this);

    this.getRootPane().setDefaultButton(okBtn);
    GuiCommonElements.enterPressesWhenFocused(okBtn);

    mainPanel.add(tabbedPane, "0,0,4,0");

    /////////////////////// START DEBUG OPTIONS PANEL ////////////////////////

    double debugOptionTable[][] = { { TableLayout.FILL }, // columns
            { 10, TableLayout.PREFERRED, 20, 30, 15, TableLayout.FILL } }; // rows

    debugOptionsPanel = GuiCommonElements.addMainPanel(tabbedPane, debugOptionTable, 0, 10, 10, 10, debug);

    String message = "Choose the level of detail for your log file's data.";
    GuiCommonElements.addTextPane(debugOptionsPanel, message, "0, 1, 0, 0", debug);
    dBox = GuiCommonElements.addComboBox(debugOptionsPanel, "Debug Level: ", debugItems, 'D',
            "Choose the level of detail for your log file's data.", 95, "0,3,F,C", debug);

    int debugLevel = config.getDebugLevel();

    for (int i = 0; i < dBox.getItemCount(); i++) {
        if (((DebugItem) dBox.getItemAt(i)).getLevel() == debugLevel)
            dBox.setSelectedIndex(i);
    }
    dBox.addActionListener(this);

    String description = ((DebugItem) dBox.getSelectedItem()).getDescription();
    descriptionText = GuiCommonElements.addTextPane(debugOptionsPanel, description, "0, 5", debug);
    final Font textFieldFont = (Font) UIManager.get("TextField.font");
    final Font font = new Font(textFieldFont.getFamily(), Font.ITALIC, textFieldFont.getSize());
    descriptionText.setFont(font);

    /////////////////////// START OTHER OPTIONS PANEL ////////////////////////

    double otherOptionTable[][] = { { TableLayout.FILL }, // columns
            { 10, TableLayout.PREFERRED, 20, 30, 15, TableLayout.FILL } }; // rows

    otherOptionsPanel = GuiCommonElements.addMainPanel(tabbedPane, otherOptionTable, 0, 10, 10, 10, debug);

    companionFileCheckbox = GuiCommonElements.addCheckBox(otherOptionsPanel,
            "<html>Attached a text file to each imported" + " file containing all collected metadata.</html>",
            "0,1", debug);

    companionFileCheckbox.setSelected(config.companionFile.get());

    disableHistoryCheckbox = GuiCommonElements.addCheckBox(otherOptionsPanel,
            "<html>Disable Import History. (Improves " + " import speed. Restart required if changed).</html>",
            "0,3", debug);

    disableHistoryCheckbox.setSelected(config.getUserDisableHistory());

    // If disabled by admin in import.config, disable this option
    if (config.getStaticDisableHistory()) {
        disableHistoryCheckbox.setEnabled(false);
    }

    /////////////////////// START FILECHOOSER PANEL ////////////////////////

    // Set up the import panel for tPane, quit, and send buttons

    double fileChooserTable[][] = { { TableLayout.FILL, 120, 5, 120, TableLayout.FILL }, // columns
            { TableLayout.PREFERRED, 15, TableLayout.FILL, 10 } }; // rows

    fileChooserPanel = GuiCommonElements.addMainPanel(tabbedPane, fileChooserTable, 0, 10, 0, 10, debug);

    message = "Switch between single pane view and triple pane view. "
            + "You will need to reboot the importer before your changes will take effect.";
    GuiCommonElements.addTextPane(fileChooserPanel, message, "0, 0, 4, 0", debug);

    // Set up single pane table
    double singlePaneTable[][] = { { 24, 5, TableLayout.FILL }, // columns
            { TableLayout.FILL } }; // rows

    // Panel containing the single pane layout

    singlePanePanel = GuiCommonElements.addMainPanel(fileChooserPanel, singlePaneTable, 0, 0, 0, 0, debug);

    singlePaneBtn = GuiCommonElements.addRadioButton(singlePanePanel, null, 'u', null, "0,0", debug);

    GuiCommonElements.addImagePanel(singlePanePanel, SINGLE_PANE_IMAGE, "2,0", debug);

    fileChooserPanel.add(singlePanePanel, "0, 2, 1, 2");

    // Set up triple pane table
    double triplePaneTable[][] = { { 24, 5, TableLayout.FILL }, // columns
            { TableLayout.FILL } }; // rows

    // Panel containing the triple pane layout

    triplePanePanel = GuiCommonElements.addMainPanel(fileChooserPanel, triplePaneTable, 0, 0, 0, 0, debug);

    triplePaneBtn = GuiCommonElements.addRadioButton(triplePanePanel, null, 'u', null, "0,0", debug);

    GuiCommonElements.addImagePanel(triplePanePanel, TRIPLE_PANE_IMAGE, "2,0", debug);

    fileChooserPanel.add(triplePanePanel, "3, 2, 4, 2");

    ButtonGroup group = new ButtonGroup();
    group.add(singlePaneBtn);
    group.add(triplePaneBtn);

    if (config.getUseQuaqua() == true) {
        triplePaneBtn.setSelected(true);
        singlePaneBtn.setSelected(false);
    } else {
        triplePaneBtn.setSelected(false);
        singlePaneBtn.setSelected(true);
    }

    /////////////////////// START TABBED PANE ////////////////////////

    //if (GuiCommonElements.getIsMac()) tabbedPane.addTab("FileChooser", null, fileChooserPanel, "FileChooser Settings");
    tabbedPane.addTab("Debug", null, debugOptionsPanel, "Debug Settings");
    tabbedPane.addTab("Other", null, otherOptionsPanel, "Other Settings");

    this.add(mainPanel);

    setVisible(true);
}

From source file:org.tinymediamanager.ui.movies.settings.MovieTrailerSettingsPanel.java

public MovieTrailerSettingsPanel() {
    // data init/*from   w  w w  . j  a  v a2s  .c  o m*/
    List<String> enabledTrailerProviders = settings.getMovieTrailerScrapers();
    int selectedIndex = -1;
    int counter = 0;
    for (MediaScraper scraper : MovieList.getInstance().getAvailableTrailerScrapers()) {
        TrailerScraper trailerScraper = new TrailerScraper(scraper);
        if (enabledTrailerProviders.contains(trailerScraper.getScraperId())) {
            trailerScraper.active = true;
            if (selectedIndex < 0) {
                selectedIndex = counter;
            }
        }
        scrapers.add(trailerScraper);
        counter++;
    }

    // UI init
    setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    JPanel panelTrailerScrapers = new JPanel();
    panelTrailerScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"),
            BUNDLE.getString("scraper.trailer"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$
    add(panelTrailerScrapers, "2, 2, fill, fill");
    panelTrailerScrapers.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("200dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.UNRELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    final JScrollPane scrollPaneScraperDetails = new JScrollPane();
    scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPaneScraperDetails.setBorder(null);
    panelTrailerScrapers.add(scrollPaneScraperDetails, "8, 1, 1, 2, fill, fill");

    JPanel panelScraperDetails = new JPanel();
    scrollPaneScraperDetails.setViewportView(panelScraperDetails);
    panelScraperDetails.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), },
            new RowSpec[] { RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, }));
    {
        // add a CSS rule to force body tags to use the default label font
        // instead of the value in javax.swing.text.html.default.csss
        Font font = UIManager.getFont("Label.font");
        String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize()
                + "pt; }";
        tpScraperDescription = new JTextPane();
        tpScraperDescription.setOpaque(false);
        tpScraperDescription.setEditorKit(new HTMLEditorKit());
        ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule);
        panelScraperDetails.add(tpScraperDescription, "1, 1, fill, top");
    }
    panelScraperOptions = new ScrollablePanel();
    panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT));
    panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top");

    JScrollPane scrollPaneScraper = new JScrollPane();
    panelTrailerScrapers.add(scrollPaneScraper, "2, 2, 5, 1, fill, fill");

    tableTrailerScraper = new JTable();
    tableTrailerScraper.setRowHeight(29);
    scrollPaneScraper.setViewportView(tableTrailerScraper);

    JSeparator separator = new JSeparator();
    panelTrailerScrapers.add(separator, "2, 4, 7, 1");

    checkBox = new JCheckBox(BUNDLE.getString("Settings.trailer.preferred")); //$NON-NLS-1$
    panelTrailerScrapers.add(checkBox, "2, 6, 7, 1");

    JLabel lblTrailerSource = new JLabel(BUNDLE.getString("Settings.trailer.source")); //$NON-NLS-1$
    panelTrailerScrapers.add(lblTrailerSource, "4, 8, right, default");

    cbTrailerSource = new JComboBox<>();
    cbTrailerSource.setModel(new DefaultComboBoxModel<>(MovieTrailerSources.values()));
    panelTrailerScrapers.add(cbTrailerSource, "6, 8, fill, default");

    JLabel lblTrailerQuality = new JLabel(BUNDLE.getString("Settings.trailer.quality")); //$NON-NLS-1$
    panelTrailerScrapers.add(lblTrailerQuality, "4, 10, right, default");

    cbTrailerQuality = new JComboBox<>();
    cbTrailerQuality.setModel(new DefaultComboBoxModel<>(MovieTrailerQuality.values()));
    panelTrailerScrapers.add(cbTrailerQuality, "6, 10, fill, default");

    chckbxAutomaticTrailerDownload = new JCheckBox(BUNDLE.getString("Settings.trailer.automaticdownload")); //$NON-NLS-1$
    panelTrailerScrapers.add(chckbxAutomaticTrailerDownload, "2, 12, 7, 1");

    JLabel lblAutomaticTrailerDownloadHint = new JLabel(
            BUNDLE.getString("Settings.trailer.automaticdownload.hint")); //$NON-NLS-1$
    TmmFontHelper.changeFont(lblAutomaticTrailerDownloadHint, 0.833);
    panelTrailerScrapers.add(lblAutomaticTrailerDownloadHint, "4, 14, 5, 1");

    initDataBindings();

    // adjust table columns
    // Checkbox and Logo shall have minimal width
    TableColumnResizer.setMaxWidthForColumn(tableTrailerScraper, 0, 2);
    TableColumnResizer.setMaxWidthForColumn(tableTrailerScraper, 1, 2);
    TableColumnResizer.adjustColumnPreferredWidths(tableTrailerScraper, 5);

    tableTrailerScraper.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent arg0) {
            // click on the checkbox
            if (arg0.getColumn() == 0) {
                int row = arg0.getFirstRow();
                TrailerScraper changedScraper = scrapers.get(row);
                if (changedScraper.active) {
                    settings.addMovieTrailerScraper(changedScraper.getScraperId());
                } else {
                    settings.removeMovieTrailerScraper(changedScraper.getScraperId());
                }
            }
        }
    });

    // implement selection listener to load settings
    tableTrailerScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            int index = tableTrailerScraper.convertRowIndexToModel(tableTrailerScraper.getSelectedRow());
            if (index > -1) {
                panelScraperOptions.removeAll();
                if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) {
                    panelScraperOptions
                            .add(new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider()));
                }
                panelScraperOptions.revalidate();
            }
        }
    });

    // select default movie scraper
    if (selectedIndex < 0) {
        selectedIndex = 0;
    }
    if (counter > 0) {
        tableTrailerScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);
    }
}

From source file:net.landora.video.infopanel.VideoInfoPanel.java

@Override
public void loadContext(MultiValueMap context) {
    Collection col = context.getCollection(VideoMetadata.class);

    VideoMetadata md = (VideoMetadata) UIUtils.select(col);

    byte[] data = md.getPosterImage();
    if (data == null) {
        lblPicture.setIcon(null);/*from   ww w.  j  a  v  a2  s  . c  o m*/
    } else {
        try {
            Image img = ImageIO.read(new ByteArrayInputStream(data));
            lblPicture.setIcon(new ImageIcon(img));
        } catch (IOException ex) {
            lblPicture.setIcon(null);
            LoggerFactory.getLogger(getClass()).warn("Error loading image.", ex);
        }
    }

    Map<String, String> values = md.getAllInformation(false);

    StringBuilder buffer = new StringBuilder();
    buffer.append("<html>");

    Font font = lblPicture.getFont();
    buffer.append("<head>");
    buffer.append("<style type=\"text/css\">");

    buffer.append(" { margin-top: 0px; margin-bottom: 0px; margin-right: 0px; margin-left: 0px;  }");

    buffer.append("table { border-collapse:collapse; }");

    buffer.append(" td { ");
    buffer.append(" font-family: \"");
    buffer.append(font.getFamily());
    buffer.append("\"; font-size: ");
    buffer.append(font.getSize() - 2);
    buffer.append("px; ");

    buffer.append(" }\n");

    buffer.append(" td.label { ");
    buffer.append("text-align: right; ");
    buffer.append("font-weight:bold; ");
    buffer.append("white-space:nowrap; ");

    buffer.append(" font-family: \"");
    buffer.append(font.getFamily());
    buffer.append("\"; font-size: ");
    buffer.append(font.getSize() - 2);
    buffer.append("px; ");

    buffer.append("} ");
    buffer.append("</style>");
    buffer.append("</head>");
    buffer.append("<body>");
    buffer.append("<table>");
    boolean first = true;
    for (Map.Entry<String, String> entry : values.entrySet()) {
        buffer.append("<tr><td class=\"label\">");
        buffer.append(StringEscapeUtils.escapeHtml(entry.getKey()));
        buffer.append("</td><td>");
        buffer.append(StringEscapeUtils.escapeHtml(entry.getValue()));
        buffer.append("</td></tr>");
    }

    buffer.append("</table>");
    buffer.append("</body>");
    buffer.append("</html>");

    txtInfo.setContentType("text/html");
    txtInfo.setText(buffer.toString());
}

From source file:com.rapidminer.gui.new_plotter.gui.GlobalConfigurationPanel.java

@Override
protected void adaptGUI() {

    // init title textfield
    String title = getPlotConfiguration().getTitleText();
    if (title == null) {
        title = "";
    }//w  w  w  . j a v a  2s  .  c  o  m
    if (!title.equals(titleTextField.getText())) {
        titleTextField.setText(title);
    }

    // init title font button
    Font titleFont = getPlotConfiguration().getTitleFont();
    if (titleFont != null) {
        titleTextField.setFont(new Font(titleFont.getFamily(), titleFont.getStyle(), fontSize));
    }

    plotOrientationChanged(getPlotConfiguration().getOrientation());

    // init plot background color label
    Color backgroundColor = getPlotConfiguration().getPlotBackgroundColor();
    if (backgroundColor == null) {
        backgroundColor = Color.white;
    }
    // plotBackgroundColorChooserButton.setIcon(createColoredRectangleIcon(backgroundColor));

    // init chart background color label
    Color chartBackgroundColor = getPlotConfiguration().getChartBackgroundColor();
    if (chartBackgroundColor == null) {
        chartBackgroundColor = Color.white;
    }
    // frameBackgroundColorChooserButton.setIcon(createColoredRectangleIcon(chartBackgroundColor));

    // init colors schemes comobox
    Map<String, ColorScheme> colorSchemes = getPlotConfiguration().getColorSchemes();
    colorsSchemesComboBoxModel.removeAllElements();
    for (ColorScheme scheme : colorSchemes.values()) {
        colorsSchemesComboBoxModel.addElement(scheme);
    }
    colorsSchemesComboBoxModel.setSelectedItem(getPlotConfiguration().getActiveColorScheme());

}

From source file:FontChooser.java

public void setFont(Font font) throws IllegalArgumentException {
    if (font == null) {
        throw new IllegalArgumentException("Null Font passed");
    }/*from   ww  w  .  jav a2s.  c  o  m*/
    _familyName = font.getFamily();
    _isBold = font.isBold();
    _isItalic = font.isItalic();
    _size = font.getSize();
}

From source file:org.pentaho.plugin.jfreereport.reportcharts.BarLineChartExpression.java

private String convertFontToString(final Font font) {
    if (font == null) {
        return null;
    }/*  w  w w  . ja  va2s  .c  om*/

    final String fontName = font.getFamily();
    final int fontSize = font.getSize();
    final int fontStyle = font.getStyle();
    final String fontStyleText;
    if ((fontStyle & (Font.BOLD | Font.ITALIC)) == (Font.BOLD | Font.ITALIC)) {
        fontStyleText = "BOLDITALIC";
    } else if ((fontStyle & Font.BOLD) == Font.BOLD) {
        fontStyleText = "BOLD";
    } else if ((fontStyle & Font.ITALIC) == Font.ITALIC) {
        fontStyleText = "ITALIC";
    } else {
        fontStyleText = "PLAIN";
    }
    return (fontName + "-" + fontStyleText + "-" + fontSize);
}