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