Search in sources :

Example 1 with Sponsor

use of pcgen.cdom.content.Sponsor in project pcgen by PCGen.

the class MainAbout method buildSponsorsPanel.

private JPanel buildSponsorsPanel() {
    TitledBorder title = BorderFactory.createTitledBorder(null, //$NON-NLS-1$
    LanguageBundle.getString("in_abt_sponsorsTitle"));
    title.setTitleJustification(TitledBorder.CENTER);
    JLabelPane sponsorLabel = new JLabelPane();
    JScrollPane sp = new JScrollPane(sponsorLabel);
    sp.setBorder(title);
    JPanel panel = new JPanel(new BorderLayout());
    sponsorLabel.setBackground(panel.getBackground());
    panel.add(sp, BorderLayout.CENTER);
    Collection<Sponsor> sponsors = Globals.getGlobalContext().getReferenceContext().getConstructedCDOMObjects(Sponsor.class);
    StringBuilder sb = new StringBuilder();
    sb.append("<html><b>");
    sb.append(LanguageBundle.getString("in_abt_ourSponsors")).append("</b><br>");
    for (Sponsor sponsor : sponsors) {
        if ("PCGEN".equals(sponsor.getKeyName())) {
            continue;
        }
        sb.append("<img src='").append(sponsor.getBannerImage()).append("'><br>");
    }
    sb.append("</html>");
    sponsorLabel.setText(sb.toString());
    return panel;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) JLabelPane(pcgen.gui2.util.JLabelPane) BorderLayout(java.awt.BorderLayout) Sponsor(pcgen.cdom.content.Sponsor) TitledBorder(javax.swing.border.TitledBorder)

Example 2 with Sponsor

use of pcgen.cdom.content.Sponsor in project pcgen by PCGen.

the class PCGenFrame method showSponsorsDialog.

public void showSponsorsDialog() {
    Collection<Sponsor> sponsors = Globals.getGlobalContext().getReferenceContext().getConstructedCDOMObjects(Sponsor.class);
    if (sponsors.size() <= 1) {
        return;
    }
    //$NON-NLS-1$
    String title = LanguageBundle.getString("in_sponsorTitle");
    final JDialog aFrame = new JDialog(this, title, true);
    //$NON-NLS-1$
    final JButton jClose = new JButton(LanguageBundle.getString("in_close"));
    //$NON-NLS-1$
    jClose.setMnemonic(LanguageBundle.getMnemonic("in_mn_close"));
    final JPanel jPanel = new JPanel();
    //$NON-NLS-1$
    final JCheckBox jCheckBox = new JCheckBox(LanguageBundle.getString("in_licShowOnLoad"));
    jPanel.add(jCheckBox);
    final PropertyContext context = PCGenSettings.OPTIONS_CONTEXT;
    jCheckBox.setSelected(context.getBoolean(PCGenSettings.OPTION_SHOW_SPONSORS_ON_LOAD));
    jCheckBox.addItemListener(evt -> context.setBoolean(PCGenSettings.OPTION_SHOW_SPONSORS_ON_LOAD, jCheckBox.isSelected()));
    jPanel.add(jClose);
    jClose.addActionListener(evt -> aFrame.dispose());
    StringBuilder sb = new StringBuilder(500);
    sb.append("<html>");
    for (Sponsor sponsor : sponsors) {
        if (!"PCGEN".equals(sponsor.getKeyName())) {
            continue;
        }
        sb.append("<img src='").append(sponsor.getBannerImage()).append("'><br>");
    }
    String s = "";
    if (sponsors.size() > 2) {
        s = "s";
    }
    sb.append("<H2><CENTER>").append(LanguageBundle.getString("in_sponsorThanks")).append(//$NON-NLS-1$
    s).append(":</CENTER></h2>");
    int size = 172;
    for (Sponsor sponsor : sponsors) {
        if ("PCGEN".equals(sponsor.getKeyName())) {
            continue;
        }
        size += 70;
        sb.append("<img src='").append(sponsor.getBannerImage()).append("'><br>");
    }
    sb.append("</html>");
    HtmlPanel htmlPanel = new HtmlPanel();
    HtmlRendererContext theRendererContext = new SimpleHtmlRendererContext(htmlPanel, new SimpleUserAgentContext());
    htmlPanel.setHtml(sb.toString(), "", theRendererContext);
    aFrame.getContentPane().setLayout(new BorderLayout());
    aFrame.getContentPane().add(htmlPanel, BorderLayout.CENTER);
    aFrame.getContentPane().add(jPanel, BorderLayout.SOUTH);
    aFrame.setSize(new Dimension(505, size));
    Utility.setComponentRelativeLocation(this, aFrame);
    aFrame.setVisible(true);
}
Also used : SimpleHtmlRendererContext(org.lobobrowser.html.test.SimpleHtmlRendererContext) HtmlRendererContext(org.lobobrowser.html.HtmlRendererContext) SimpleHtmlRendererContext(org.lobobrowser.html.test.SimpleHtmlRendererContext) JPanel(javax.swing.JPanel) JButton(javax.swing.JButton) Sponsor(pcgen.cdom.content.Sponsor) SimpleUserAgentContext(org.lobobrowser.html.test.SimpleUserAgentContext) Dimension(java.awt.Dimension) JCheckBox(javax.swing.JCheckBox) BorderLayout(java.awt.BorderLayout) PropertyContext(pcgen.system.PropertyContext) HtmlPanel(org.lobobrowser.html.gui.HtmlPanel) JDialog(javax.swing.JDialog)

Aggregations

BorderLayout (java.awt.BorderLayout)2 JPanel (javax.swing.JPanel)2 Sponsor (pcgen.cdom.content.Sponsor)2 Dimension (java.awt.Dimension)1 JButton (javax.swing.JButton)1 JCheckBox (javax.swing.JCheckBox)1 JDialog (javax.swing.JDialog)1 JScrollPane (javax.swing.JScrollPane)1 TitledBorder (javax.swing.border.TitledBorder)1 HtmlRendererContext (org.lobobrowser.html.HtmlRendererContext)1 HtmlPanel (org.lobobrowser.html.gui.HtmlPanel)1 SimpleHtmlRendererContext (org.lobobrowser.html.test.SimpleHtmlRendererContext)1 SimpleUserAgentContext (org.lobobrowser.html.test.SimpleUserAgentContext)1 JLabelPane (pcgen.gui2.util.JLabelPane)1 PropertyContext (pcgen.system.PropertyContext)1