List of usage examples for java.awt Font getFamily
public String getFamily()
From source file:edu.ku.brc.specify.utilapps.ERDTable.java
/** * @param font/* w w w .j a v a2s . c o m*/ */ public void build(final Font font) { int numRows = 7; switch (displayType) { case All: numRows = 7; break; case MainFields: numRows = 7; break; case Title: numRows = 1; break; case TitleAndRel: numRows = 4; break; } Font bold = new Font(font.getFamily(), Font.BOLD, font.getSize()); Font italic = new Font(font.getFamily(), Font.ITALIC, font.getSize()); PanelBuilder pb = new PanelBuilder( new FormLayout("f:p:g", UIHelper.createDuplicateJGoodiesDef("p", "2px", numRows))); CellConstraints cc = new CellConstraints(); String className = StringUtils.substringAfterLast(table.getClassName(), "."); DBTableInfo tblInfo = DBTableIdMgr.getInstance().getByShortClassName(className); if (tblInfo == null) { throw new RuntimeException("Couldn't find table for className[" + className + "]"); } String tblName = tblInfo.getTitle(); int y = 1; pb.add(ERDVisualizer.mkLabel(bold, tblName, SwingConstants.CENTER), cc.xy(1, y)); y += 2; boolean doingAll = displayType == DisplayType.All; if (displayType == DisplayType.All || displayType == DisplayType.MainFields) { pb.addSeparator("", cc.xy(1, y)); y += 2; pb.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_FIELDS"), SwingConstants.CENTER), cc.xy(1, y)); y += 2; String colsDef = "p:g,4px,p:g,4px" + (doingAll ? ",p:g,4px,p:g,4px" : "") + ",f:p:g"; PanelBuilder fieldsPB = new PanelBuilder(new FormLayout(colsDef, UIHelper.createDuplicateJGoodiesDef("p", "2px", table.getFields().size() + 2))); int yy = 1; fieldsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_FIELD"), SwingConstants.LEFT), cc.xy(1, yy)); fieldsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_TYPE"), SwingConstants.CENTER), cc.xy(3, yy)); fieldsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_LENGTH"), SwingConstants.CENTER), cc.xy(5, yy)); if (doingAll) { fieldsPB.add( ERDVisualizer.mkLabel(italic, getResourceString("ERD_REQUIRED"), SwingConstants.CENTER), cc.xy(7, yy)); fieldsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_UNIQUE"), SwingConstants.CENTER), cc.xy(9, yy)); } yy += 2; if (StringUtils.isNotEmpty(table.getIdColumnName())) { build(fieldsPB, table, font, yy, doingAll); // does ID yy += 2; } for (DBFieldInfo f : table.getFields()) { build(fieldsPB, f, font, yy, doingAll); yy += 2; } pb.add(fieldsPB.getPanel(), cc.xy(1, y)); y += 2; } if ((displayType == DisplayType.All || displayType == DisplayType.TitleAndRel) && table.getRelationships().size() > 0) { pb.addSeparator("", cc.xy(1, y)); y += 2; pb.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_RELATIONSHIPS"), SwingConstants.CENTER), cc.xy(1, y)); y += 2; String colsDef = "p:g,4px,p:g,4px" + (doingAll ? ",p:g,4px" : "") + ",f:p:g"; PanelBuilder relsPB = new PanelBuilder(new FormLayout(colsDef, UIHelper.createDuplicateJGoodiesDef("p", "2px", table.getRelationships().size() + 1))); int yy = 1; relsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_TABLE"), SwingConstants.LEFT), cc.xy(1, yy)); relsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_NAME"), SwingConstants.CENTER), cc.xy(3, yy)); relsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_TYPE"), SwingConstants.CENTER), cc.xy(5, yy)); if (doingAll) { relsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_REQUIRED"), SwingConstants.CENTER), cc.xy(7, yy)); } yy += 2; Vector<DBRelationshipInfo> orderedList = new Vector<DBRelationshipInfo>(table.getRelationships()); Collections.sort(orderedList, new Comparator<DBRelationshipInfo>() { public int compare(DBRelationshipInfo o1, DBRelationshipInfo o2) { String name1 = ((DBRelationshipInfo) o1).getClassName(); if (name1.startsWith("Sp")) { name1 = name1.substring(2, name1.length()); } String name2 = ((DBRelationshipInfo) o2).getClassName(); if (name2.startsWith("Sp")) { name2 = name2.substring(2, name2.length()); } return name1.compareTo(name2); } }); for (DBRelationshipInfo r : orderedList) { //System.out.println(r.getName()+" "+r.getType()); if (!r.getName().toLowerCase().endsWith("iface")) { JComponent p = build(relsPB, r, font, yy, doingAll); relUIHash.put(r, p); yy += 2; } } pb.add(relsPB.getPanel(), cc.xy(1, y)); y += 2; //fieldsPB.getPanel().setBackground(Color.GREEN); //relsPB.getPanel().setBackground(Color.BLUE); } inner = pb.getPanel(); //inner.setBorder(BorderFactory.createEmptyBorder(BRD_GAP, BRD_GAP, BRD_GAP, BRD_GAP)); inner.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK), BorderFactory.createEmptyBorder(BRD_GAP, BRD_GAP, BRD_GAP, BRD_GAP))); setBackground(Color.WHITE); add(inner, BorderLayout.CENTER); }
From source file:net.sf.taverna.t2.workbench.ui.credentialmanager.WarnUserAboutJCEPolicyDialog.java
private void initComponents() { // Base font for all components on the form Font baseFont = new JLabel("base font").getFont().deriveFont(11f); // Message saying that updates are available JPanel messagePanel = new JPanel(new BorderLayout()); messagePanel.setBorder(new CompoundBorder(new EmptyBorder(10, 10, 10, 10), new EtchedBorder(LOWERED))); JEditorPane message = new JEditorPane(); message.setEditable(false);/* w ww . j a v a 2 s .c o m*/ message.setBackground(this.getBackground()); message.setFocusable(false); HTMLEditorKit kit = new HTMLEditorKit(); message.setEditorKit(kit); StyleSheet styleSheet = kit.getStyleSheet(); //styleSheet.addRule("body {font-family:"+baseFont.getFamily()+"; font-size:"+baseFont.getSize()+";}"); // base font looks bigger when rendered as HTML styleSheet.addRule("body {font-family:" + baseFont.getFamily() + "; font-size:10px;}"); Document doc = kit.createDefaultDocument(); message.setDocument(doc); message.setText( "<html><body>In order for Taverna's security features to function properly - you need to install<br>" + "'Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy'. <br><br>" + "If you do not already have it, for <b>Java 6</b> you can get it from:<br>" + "<a href=\"http://www.oracle.com/technetwork/java/javase/downloads/index.html\">http://www.oracle.com/technetwork/java/javase/downloads/index.html</a><br<br>" + "Installation instructions are contained in the bundle you download." + "</body><html>"); message.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent he) { HyperlinkEvent.EventType type = he.getEventType(); if (type == ACTIVATED) // Open a Web browser try { getDesktop().browse(he.getURL().toURI()); // BrowserLauncher launcher = new BrowserLauncher(); // launcher.openURLinBrowser(he.getURL().toString()); } catch (Exception ex) { logger.error("Failed to launch browser to fetch JCE " + he.getURL()); } } }); message.setBorder(new EmptyBorder(5, 5, 5, 5)); messagePanel.add(message, CENTER); doNotWarnMeAgainCheckBox = new JCheckBox("Do not warn me again"); doNotWarnMeAgainCheckBox.setFont(baseFont.deriveFont(12f)); messagePanel.add(doNotWarnMeAgainCheckBox, SOUTH); // Buttons JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); JButton okButton = new JButton("OK"); okButton.setFont(baseFont); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { okPressed(); } }); buttonsPanel.add(okButton); getContentPane().setLayout(new BorderLayout()); getContentPane().add(messagePanel, CENTER); getContentPane().add(buttonsPanel, SOUTH); pack(); setResizable(false); // Center the dialog on the screen (we do not have the parent) Dimension dimension = getToolkit().getScreenSize(); Rectangle abounds = getBounds(); setLocation((dimension.width - abounds.width) / 2, (dimension.height - abounds.height) / 2); setSize(getPreferredSize()); }
From source file:org.tinymediamanager.ui.tvshows.settings.TvShowScraperSettingsPanel.java
/** * Instantiates a new movie scraper settings panel. *//*from ww w . j a va 2s . c o m*/ public TvShowScraperSettingsPanel() { // data init MediaScraper defaultMediaScraper = TvShowList.getInstance().getDefaultMediaScraper(); int selectedIndex = 0; int counter = 0; for (MediaScraper scraper : TvShowList.getInstance().getAvailableMediaScrapers()) { TvShowScraper tvShowScraper = new TvShowScraper(scraper); if (scraper.equals(defaultMediaScraper)) { tvShowScraper.defaultScraper = true; selectedIndex = counter; } scrapers.add(tvShowScraper); counter++; } List<String> enabledArtworkProviders = settings.getTvShowArtworkScrapers(); int artworkSelectedIndex = -1; int counterAW = 0; for (MediaScraper scraper : TvShowList.getInstance().getAvailableArtworkScrapers()) { ArtworkScraper artworkScraper = new ArtworkScraper(scraper); if (enabledArtworkProviders.contains(artworkScraper.getScraperId())) { artworkScraper.active = true; if (artworkSelectedIndex < 0) { artworkSelectedIndex = counterAW; } } artworkScrapers.add(artworkScraper); counterAW++; } // 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, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JPanel panelTvShowScrapers = new JPanel(); panelTvShowScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), BUNDLE.getString("scraper.metadata.defaults"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$ add(panelTvShowScrapers, "2, 2, fill, top"); panelTvShowScrapers.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"), FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, })); scrollPaneScraper = new JScrollPane(); panelTvShowScrapers.add(scrollPaneScraper, "1, 2, 3, 1, fill, fill"); tableScraper = new JTable(); tableScraper.setRowHeight(29); scrollPaneScraper.setViewportView(tableScraper); scrollPaneScraperDetails = new JScrollPane(); scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPaneScraperDetails.setBorder(null); panelTvShowScrapers.add(scrollPaneScraperDetails, "5, 2, fill, fill"); panelScraperDetails = new ScrollablePanel(); scrollPaneScraperDetails.setViewportView(panelScraperDetails); panelScraperDetails.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("200dlu: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 JPanel(); panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT)); panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top"); JSeparator separator = new JSeparator(); panelTvShowScrapers.add(separator, "1, 4, 5, 1"); JLabel lblScraperLanguage = new JLabel(BUNDLE.getString("Settings.preferredLanguage")); //$NON-NLS-1$ panelTvShowScrapers.add(lblScraperLanguage, "1, 6, right, default"); cbScraperTmdbLanguage = new JComboBox(MediaLanguages.values()); panelTvShowScrapers.add(cbScraperTmdbLanguage, "3, 6"); JLabel lblCountry = new JLabel(BUNDLE.getString("Settings.certificationCountry")); //$NON-NLS-1$ panelTvShowScrapers.add(lblCountry, "1, 8, right, default"); cbCountry = new JComboBox(CountryCode.values()); panelTvShowScrapers.add(cbCountry, "3, 8, fill, default"); btnGroupThumbFilenaming = new ButtonGroup(); panelArtworkScrapers = new JPanel(); panelArtworkScrapers.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.images"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelArtworkScrapers, "2, 4, fill, fill"); panelArtworkScrapers.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("80dlu:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, })); scrollPaneArtworkScraper = new JScrollPane(); panelArtworkScrapers.add(scrollPaneArtworkScraper, "2, 2, fill, fill"); tableArtworkScraper = new JTable(); tableArtworkScraper.setRowHeight(29); scrollPaneArtworkScraper.setViewportView(tableArtworkScraper); scrollPaneArtworkScraperDetails = new JScrollPane(); scrollPaneArtworkScraperDetails.setBorder(null); panelArtworkScrapers.add(scrollPaneArtworkScraperDetails, "4, 2, fill, fill"); panelArtworkScraperDetails = new JPanel(); scrollPaneArtworkScraperDetails.setViewportView(panelArtworkScraperDetails); panelArtworkScraperDetails.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"), }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), })); tpArtworkScraperDescription = new JTextPane(); tpArtworkScraperDescription.setEditorKit(new HTMLEditorKit()); ((HTMLDocument) tpArtworkScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule); tpArtworkScraperDescription.setOpaque(false); panelArtworkScraperDetails.add(tpArtworkScraperDescription, "2, 2, fill, fill"); panelArtworkScraperOptions = new JPanel(); panelArtworkScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT)); panelArtworkScraperDetails.add(panelArtworkScraperOptions, "2, 4, fill, fill"); separator = new JSeparator(); panelArtworkScrapers.add(separator, "2, 4, 3, 1"); panelImages = new JPanel(); panelArtworkScrapers.add(panelImages, "2, 6, 3, 1, fill, fill"); panelImages.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { RowSpec.decode("23px"), })); lblNewLabel = new JLabel(BUNDLE.getString("image.thumb.naming")); panelImages.add(lblNewLabel, "1, 1, left, center"); rdbtnThumbWithPostfix = new JRadioButton("<dynamic>-thumb.ext"); panelImages.add(rdbtnThumbWithPostfix, "3, 1, fill, top"); btnGroupThumbFilenaming.add(rdbtnThumbWithPostfix); rdbtnThumbTbn = new JRadioButton("<dynamic>.tbn"); btnGroupThumbFilenaming.add(rdbtnThumbTbn); rdbtnThumbWoPostfix = new JRadioButton("<dynamic>.ext"); panelImages.add(rdbtnThumbWoPostfix, "5, 1, fill, top"); btnGroupThumbFilenaming.add(rdbtnThumbWoPostfix); panelImages.add(rdbtnThumbTbn, "7, 1"); panelScraperMetadataContainer = new JPanel(); panelScraperMetadataContainer.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), BUNDLE.getString("scraper.metadata.defaults"), TitledBorder.LEADING, TitledBorder.TOP, null, //$NON-NLS-1$ new Color(51, 51, 51))); add(panelScraperMetadataContainer, "2, 6, fill, top"); panelScraperMetadataContainer.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); panelScraperMetadata = new TvShowScraperMetadataPanel( Settings.getInstance().getTvShowScraperMetadataConfig()); panelScraperMetadataContainer.add(panelScraperMetadata, "1, 1, 2, 1, fill, default"); chckbxAutomaticallyScrapeImages = new JCheckBox(BUNDLE.getString("Settings.default.autoscrape")); //$NON-NLS-1$ panelScraperMetadataContainer.add(chckbxAutomaticallyScrapeImages, "2, 3"); 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); TableColumnResizer.setMaxWidthForColumn(tableArtworkScraper, 0, 2); TableColumnResizer.setMaxWidthForColumn(tableArtworkScraper, 1, 2); TableColumnResizer.adjustColumnPreferredWidths(tableArtworkScraper, 5); // implement listener to simulate button group tableScraper.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { // click on the checkbox if (arg0.getColumn() == 0) { int row = arg0.getFirstRow(); TvShowScraper changedScraper = scrapers.get(row); // if flag inNFO was changed, change all other trailers flags if (changedScraper.getDefaultScraper()) { settings.setTvShowScraper(changedScraper.getScraperId()); for (TvShowScraper scraper : scrapers) { if (scraper != changedScraper) { scraper.setDefaultScraper(Boolean.FALSE); } } } } } }); // 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(); } } }); tableArtworkScraper.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { // click on the checkbox if (arg0.getColumn() == 0) { int row = arg0.getFirstRow(); ArtworkScraper changedScraper = artworkScrapers.get(row); if (changedScraper.active) { settings.addTvShowArtworkScraper(changedScraper.getScraperId()); } else { settings.removeTvShowArtworkScraper(changedScraper.getScraperId()); } } } }); // implement selection listener to load settings tableArtworkScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { int index = tableArtworkScraper.convertRowIndexToModel(tableArtworkScraper.getSelectedRow()); if (index > -1) { panelArtworkScraperOptions.removeAll(); if (artworkScrapers.get(index).getMediaProvider().getProviderInfo().getConfig() .hasConfig()) { panelArtworkScraperOptions.add(new MediaScraperConfigurationPanel( artworkScrapers.get(index).getMediaProvider())); } panelArtworkScraperOptions.revalidate(); } } }); // select default TV show scraper if (counter > 0) { tableScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex); } // select default artwork scraper if (counterAW > 0) { tableArtworkScraper.getSelectionModel().setSelectionInterval(artworkSelectedIndex, artworkSelectedIndex); } ItemListener itemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { checkChanges(); } }; rdbtnThumbWoPostfix.addItemListener(itemListener); rdbtnThumbWithPostfix.addItemListener(itemListener); rdbtnThumbTbn.addItemListener(itemListener); switch (settings.getTvShowEpisodeThumbFilename()) { case FILENAME_THUMB_POSTFIX: rdbtnThumbWithPostfix.setSelected(true); break; case FILENAME_THUMB: rdbtnThumbWoPostfix.setSelected(true); break; case FILENAME_THUMB_TBN: rdbtnThumbTbn.setSelected(true); break; default: break; } } }
From source file:de.ailis.xadrian.components.ComplexEditor.java
/** * Constructor/*from ww w . j a va 2 s .c o m*/ * * @param complex * The complex to edit * @param file * The file from which the complex was loaded. Null if it not * loaded from a file. */ public ComplexEditor(final Complex complex, final File file) { super(); setLayout(new BorderLayout()); this.complex = complex; this.file = file; // Create the text pane this.textPane = new JTextPane(); this.textPane.setEditable(false); this.textPane.setBorder(null); this.textPane.setContentType("text/html"); this.textPane.setDoubleBuffered(true); this.textPane.addHyperlinkListener(this); this.textPane.addCaretListener(this); // Create the popup menu for the text pane final JPopupMenu popupMenu = new JPopupMenu(); popupMenu.add(new CopyAction(this)); popupMenu.add(new SelectAllAction(this)); popupMenu.addSeparator(); popupMenu.add(new AddFactoryAction(this)); popupMenu.add(new ChangeSectorAction(this.complex, this, "complex")); popupMenu.add(new ChangeSunsAction(this)); popupMenu.add(new ChangePricesAction(this)); popupMenu.add(new JCheckBoxMenuItem(new ToggleBaseComplexAction(this))); SwingUtils.setPopupMenu(this.textPane, popupMenu); final HTMLDocument document = (HTMLDocument) this.textPane.getDocument(); // Set the base URL of the text pane document.setBase(Main.class.getResource("templates/")); // Modify the body style so it matches the system font final Font font = UIManager.getFont("Label.font"); final String bodyRule = "body { font-family: " + font.getFamily() + "; font-size: " + font.getSize() + "pt; }"; document.getStyleSheet().addRule(bodyRule); // Create the scroll pane final JScrollPane scrollPane = new JScrollPane(this.textPane); add(scrollPane); // Redraw the content redraw(); fireComplexState(); }
From source file:org.tinymediamanager.ui.movies.settings.MovieImageSettingsPanel.java
/** * Instantiates a new movie image settings panel. *///from ww w.j a va 2 s . c o m public MovieImageSettingsPanel() { // data init List<String> enabledArtworkProviders = settings.getMovieArtworkScrapers(); int selectedIndex = -1; int counter = 0; for (MediaScraper scraper : MovieList.getInstance().getAvailableArtworkScrapers()) { ArtworkScraper artworkScraper = new ArtworkScraper(scraper); if (enabledArtworkProviders.contains(artworkScraper.getScraperId())) { artworkScraper.active = true; if (selectedIndex < 0) { selectedIndex = counter; } } scrapers.add(artworkScraper); counter++; } // init UI setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JPanel panelMovieImages = new JPanel(); panelMovieImages.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.poster"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelMovieImages, "2, 2, default, fill"); panelMovieImages.setLayout(new FormLayout(new ColumnSpec[] { 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.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); scrollPaneScraperDetails = new JScrollPane(); scrollPaneScraperDetails.setBorder(null); scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); panelMovieImages.add(scrollPaneScraperDetails, "6, 1, 1, 7, fill, fill"); panelScraperDetails = new ScrollablePanel(); scrollPaneScraperDetails.setViewportView(panelScraperDetails); panelScraperDetails .setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, 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 JPanel(); panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT)); panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top"); scrollPaneScraper = new JScrollPane(); panelMovieImages.add(scrollPaneScraper, "2, 2, 3, 1, fill, fill"); tableScraper = new JTable(); tableScraper.setRowHeight(29); scrollPaneScraper.setViewportView(tableScraper); JSeparator separator = new JSeparator(); panelMovieImages.add(separator, "2, 3, 3, 1"); JLabel lblImageTmdbPosterSize = new JLabel(BUNDLE.getString("image.poster.size")); panelMovieImages.add(lblImageTmdbPosterSize, "2, 5"); cbImagePosterSize = new JComboBox(PosterSizes.values()); panelMovieImages.add(cbImagePosterSize, "4, 5"); JLabel lblImageTmdbFanartSize = new JLabel(BUNDLE.getString("image.fanart.size")); panelMovieImages.add(lblImageTmdbFanartSize, "2, 7"); cbImageFanartSize = new JComboBox(FanartSizes.values()); panelMovieImages.add(cbImageFanartSize, "4, 7"); separator = new JSeparator(); panelMovieImages.add(separator, "2, 9, 5, 1"); panelFileNaming = new JPanel(); panelMovieImages.add(panelFileNaming, "2, 11, 5, 1, fill, fill"); panelFileNaming.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JLabel lblPosterFilename = new JLabel(BUNDLE.getString("image.poster.naming")); panelFileNaming.add(lblPosterFilename, "1, 1"); cbMoviePosterFilename7 = new JCheckBox("<dynamic>.ext"); panelFileNaming.add(cbMoviePosterFilename7, "3, 1"); cbMoviePosterFilename4 = new JCheckBox("poster.ext"); panelFileNaming.add(cbMoviePosterFilename4, "5, 1"); cbMoviePosterFilename2 = new JCheckBox("movie.ext"); panelFileNaming.add(cbMoviePosterFilename2, "7, 1"); cbMoviePosterFilename8 = new JCheckBox("<dynamic>-poster.ext"); panelFileNaming.add(cbMoviePosterFilename8, "9, 1"); cbMoviePosterFilename6 = new JCheckBox("folder.ext"); panelFileNaming.add(cbMoviePosterFilename6, "11, 1"); JLabel lblFanartFileNaming = new JLabel(BUNDLE.getString("image.fanart.naming")); panelFileNaming.add(lblFanartFileNaming, "1, 3"); cbMovieFanartFilename1 = new JCheckBox("<dynamic>-fanart.ext"); panelFileNaming.add(cbMovieFanartFilename1, "3, 3"); cbMovieFanartFilename3 = new JCheckBox("<dynamic>.fanart.ext"); panelFileNaming.add(cbMovieFanartFilename3, "5, 3"); cbMovieFanartFilename2 = new JCheckBox("fanart.ext"); panelFileNaming.add(cbMovieFanartFilename2, "7, 3"); tpFileNamingHint = new JTextPane(); panelFileNaming.add(tpFileNamingHint, "1, 5, 11, 1, fill, fill"); tpFileNamingHint.setText(BUNDLE.getString("Settings.naming.info")); //$NON-NLS-1$ tpFileNamingHint.setBackground(UIManager.getColor("Panel.background")); TmmFontHelper.changeFont(tpFileNamingHint, 0.833); panelExtraArtwork = new JPanel(); panelExtraArtwork.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.extraartwork"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelExtraArtwork, "2, 4, default, fill"); panelExtraArtwork.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); chckbxBanner = new JCheckBox(BUNDLE.getString("mediafiletype.banner")); panelExtraArtwork.add(chckbxBanner, "2, 2"); chckbxClearArt = new JCheckBox(BUNDLE.getString("mediafiletype.clearart")); panelExtraArtwork.add(chckbxClearArt, "4, 2"); chckbxThumb = new JCheckBox(BUNDLE.getString("mediafiletype.thumb")); panelExtraArtwork.add(chckbxThumb, "6, 2"); chckbxLogo = new JCheckBox(BUNDLE.getString("mediafiletype.logo")); panelExtraArtwork.add(chckbxLogo, "8, 2"); chckbxDiscArt = new JCheckBox(BUNDLE.getString("mediafiletype.discart")); panelExtraArtwork.add(chckbxDiscArt, "10, 2"); separator = new JSeparator(); panelExtraArtwork.add(separator, "2, 4, 9, 1"); chckbxEnableExtrathumbs = new JCheckBox(BUNDLE.getString("Settings.enable.extrathumbs")); panelExtraArtwork.add(chckbxEnableExtrathumbs, "2, 6, 3, 1"); chckbxResizeExtrathumbsTo = new JCheckBox(BUNDLE.getString("Settings.resize.extrathumbs")); panelExtraArtwork.add(chckbxResizeExtrathumbsTo, "6, 6, 3, 1"); spExtrathumbWidth = new JSpinner(); panelExtraArtwork.add(spExtrathumbWidth, "10, 6"); spExtrathumbWidth.setPreferredSize(new Dimension(49, 20)); lblDownload = new JLabel(BUNDLE.getString("Settings.amount.autodownload")); panelExtraArtwork.add(lblDownload, "2, 8, 7, 1, right, default"); spDownloadCountExtrathumbs = new JSpinner(); panelExtraArtwork.add(spDownloadCountExtrathumbs, "10, 8"); spDownloadCountExtrathumbs.setPreferredSize(new Dimension(49, 20)); chckbxEnableExtrafanart = new JCheckBox(BUNDLE.getString("Settings.enable.extrafanart")); panelExtraArtwork.add(chckbxEnableExtrafanart, "2, 10, 9, 1"); lblDownloadCount = new JLabel(BUNDLE.getString("Settings.amount.autodownload")); panelExtraArtwork.add(lblDownloadCount, "2, 12, 7, 1, right, default"); spDownloadCountExtrafanart = new JSpinner(); panelExtraArtwork.add(spDownloadCountExtrafanart, "10, 12"); spDownloadCountExtrafanart.setPreferredSize(new Dimension(49, 20)); separator = new JSeparator(); panelExtraArtwork.add(separator, "2, 14, 9, 1"); cbActorImages = new JCheckBox(BUNDLE.getString("Settings.actor.download")); panelExtraArtwork.add(cbActorImages, "2, 16, 9, 1"); separator = new JSeparator(); panelExtraArtwork.add(separator, "2, 18, 9, 1"); chckbxMovieSetArtwork = new JCheckBox(BUNDLE.getString("Settings.movieset.store.movie")); //$NON-NLS-1$ panelExtraArtwork.add(chckbxMovieSetArtwork, "2, 20, 9, 1"); chckbxStoreMoviesetArtwork = new JCheckBox(BUNDLE.getString("Settings.movieset.store")); //$NON-NLS-1$ panelExtraArtwork.add(chckbxStoreMoviesetArtwork, "2, 22, 9, 1"); lblFoldername = new JLabel(BUNDLE.getString("Settings.movieset.foldername")); //$NON-NLS-1$ panelExtraArtwork.add(lblFoldername, "2, 24, 3, 1, right, default"); tfMovieSetArtworkFolder = new JTextField(); panelExtraArtwork.add(tfMovieSetArtworkFolder, "6, 24, 3, 1"); tfMovieSetArtworkFolder.setColumns(10); btnSelectFolder = new JButton(BUNDLE.getString("Settings.movieset.buttonselect")); //$NON-NLS-1$ panelExtraArtwork.add(btnSelectFolder, "10, 24"); btnSelectFolder.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Path file = TmmUIHelper.selectDirectory(BUNDLE.getString("Settings.movieset.folderchooser")); //$NON-NLS-1$ if (file != null && Files.isDirectory(file)) { tfMovieSetArtworkFolder.setText(file.toAbsolutePath().toString()); } } }); initDataBindings(); // poster filenames List<MoviePosterNaming> moviePosterFilenames = settings.getMoviePosterFilenames(); if (moviePosterFilenames.contains(MoviePosterNaming.MOVIE_JPG)) { cbMoviePosterFilename2.setSelected(true); } if (moviePosterFilenames.contains(MoviePosterNaming.POSTER_JPG)) { cbMoviePosterFilename4.setSelected(true); } if (moviePosterFilenames.contains(MoviePosterNaming.FOLDER_JPG)) { cbMoviePosterFilename6.setSelected(true); } if (moviePosterFilenames.contains(MoviePosterNaming.FILENAME_JPG)) { cbMoviePosterFilename7.setSelected(true); } if (moviePosterFilenames.contains(MoviePosterNaming.FILENAME_POSTER_JPG)) { cbMoviePosterFilename8.setSelected(true); } // fanart filenames List<MovieFanartNaming> movieFanartFilenames = settings.getMovieFanartFilenames(); if (movieFanartFilenames.contains(MovieFanartNaming.FILENAME_FANART_JPG)) { cbMovieFanartFilename1.setSelected(true); } if (movieFanartFilenames.contains(MovieFanartNaming.FANART_JPG)) { cbMovieFanartFilename2.setSelected(true); } if (movieFanartFilenames.contains(MovieFanartNaming.FILENAME_FANART2_JPG)) { cbMovieFanartFilename3.setSelected(true); } // listen to changes of the checkboxes ItemListener listener = new ItemListener() { public void itemStateChanged(ItemEvent e) { checkChanges(); } }; cbMovieFanartFilename2.addItemListener(listener); cbMovieFanartFilename3.addItemListener(listener); cbMovieFanartFilename1.addItemListener(listener); cbMoviePosterFilename2.addItemListener(listener); cbMoviePosterFilename4.addItemListener(listener); cbMoviePosterFilename7.addItemListener(listener); cbMoviePosterFilename8.addItemListener(listener); cbMoviePosterFilename6.addItemListener(listener); // 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(); ArtworkScraper changedScraper = scrapers.get(row); if (changedScraper.active) { settings.addMovieArtworkScraper(changedScraper.getScraperId()); } else { settings.removeMovieArtworkScraper(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 artwork scraper if (selectedIndex < 0) { selectedIndex = 0; } if (counter > 0) { tableScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex); } }
From source file:util.program.ProgramTextCreator.java
/** * * @param prog/*from ww w . j a v a 2 s. co m*/ * The Program to show * @param doc * The HTMLDocument. * @param fieldArr * The object array with the field types. * @param tFont * The title Font. * @param bFont * The body Font. * @param settings * Settings of the ProgramPanel * @param showHelpLinks * Show the Help-Links (Quality of Data, ShowView) * @param zoom * The zoom value for the picture. * @param showPluginIcons * If the plugin icons should be shown. * @return The HTML String. * @since 3.0 */ public static String createInfoText(Program prog, ExtendedHTMLDocument doc, Object[] fieldArr, Font tFont, Font bFont, ProgramPanelSettings settings, boolean showHelpLinks, int zoom, boolean showPluginIcons, boolean showPersonLinks) { String debugTables = "0"; //set to "1" for debugging, to "0" for no debugging try { // NOTE: All field types are included until type 25 (REPETITION_ON_TYPE) StringBuilder buffer = new StringBuilder(1024); String titleFont, titleSize, bodyFont; int bodyStyle; int titleStyle; if (tFont == null && bFont != null) { titleFont = bodyFont = bFont.getFamily(); titleSize = mBodyFontSize = String.valueOf(bFont.getSize()); titleStyle = bodyStyle = bFont.getStyle(); } else if (tFont != null && bFont != null) { titleFont = tFont.getFamily(); bodyFont = bFont.getFamily(); titleSize = String.valueOf(tFont.getSize()); mBodyFontSize = String.valueOf(bFont.getSize()); titleStyle = tFont.getStyle(); bodyStyle = bFont.getStyle(); } else { return null; } if (fieldArr == null) { return null; } buffer.append("<html>"); buffer.append("<table width=\"100%\" border=\"" + debugTables + "\" style=\"font-family:"); buffer.append(bodyFont); buffer.append(";").append(getCssStyle(bodyStyle)).append("\"><tr>"); buffer.append("<td width=\"60\">"); buffer.append("<p \"align=center\">"); JLabel channelLogo = new JLabel(prog.getChannel().getIcon()); channelLogo.setToolTipText(prog.getChannel().getName()); buffer.append(doc.createCompTag(channelLogo)); buffer.append( "</p></td><td><table width=\"100%\" border=\"" + debugTables + "\" cellpadding=\"0\"><tr><td>"); buffer.append("<div style=\"color:#ff0000; font-size:"); buffer.append(mBodyFontSize); buffer.append(";\"><b>"); Date currentDate = Date.getCurrentDate(); Date programDate = prog.getDate(); if (programDate.equals(currentDate.addDays(-1))) { buffer.append(Localizer.getLocalization(Localizer.I18N_YESTERDAY)); buffer.append(" "); } else if (programDate.equals(currentDate)) { buffer.append(Localizer.getLocalization(Localizer.I18N_TODAY)); buffer.append(" "); } else if (programDate.equals(currentDate.addDays(1))) { buffer.append(Localizer.getLocalization(Localizer.I18N_TOMORROW)); buffer.append(" "); } buffer.append(prog.getDateString()); buffer.append(" "); buffer.append(prog.getTimeString()); if (prog.getLength() > 0) { buffer.append('-'); buffer.append(prog.getEndTimeString()); } buffer.append(" "); buffer.append(prog.getChannel()); buffer.append("</b></div><div style=\"color:#003366; font-size:"); buffer.append(titleSize); buffer.append("; line-height:2.5em; font-family:"); buffer.append(titleFont).append(";").append(getCssStyle(titleStyle)); buffer.append("\">"); buffer.append(prog.getTitle()); buffer.append("</div>"); String episode = CompoundedProgramFieldType.EPISODE_COMPOSITION.getFormattedValueForProgram(prog); if (episode != null && episode.trim().length() > 0) { buffer.append("<div style=\"color:#808080; font-size:"); buffer.append(mBodyFontSize); buffer.append("\">"); buffer.append(episode); buffer.append("</div>"); } buffer.append("</td><td align=\"right\" valign=\"top\"><table border=\"" + debugTables + "\"><tr><td>"); JButton btn = new JButton(TVBrowserIcons.left(TVBrowserIcons.SIZE_SMALL)); buffer.append(doc.createCompTag(btn)); btn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ProgramInfo.getInstance().historyBack(); } }); btn.setEnabled(ProgramInfo.getInstance().canNavigateBack()); btn.setToolTipText(ProgramInfo.getInstance().navigationBackwardText()); buffer.append("</td><td>"); btn = new JButton(TVBrowserIcons.right(TVBrowserIcons.SIZE_SMALL)); buffer.append(doc.createCompTag(btn)); btn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ProgramInfo.getInstance().historyForward(); } }); btn.setEnabled(ProgramInfo.getInstance().canNavigateForward()); btn.setToolTipText(ProgramInfo.getInstance().navigationForwardText()); buffer.append("</td></tr></table></td></tr></table></td></tr>"); boolean show = false; if (settings.isShowingPictureForPlugins()) { String[] pluginIds = settings.getPluginIds(); Marker[] markers = prog.getMarkerArr(); if (markers != null && pluginIds != null) { for (Marker marker : markers) { for (String pluginId : pluginIds) { if (marker.getId().compareTo(pluginId) == 0) { show = true; break; } } } } } Color foreground = Color.black;//Settings.propProgramPanelForegroundColor.getColor(); if (settings.isShowingPictureEver() || (settings.isShowingPictureInTimeRange() && !ProgramUtilities.isNotInTimeRange(settings.getPictureTimeRangeStart(), settings.getPictureTimeRangeEnd(), prog)) || show || (settings.isShowingPictureForDuration() && settings.getDuration() <= prog.getLength())) { byte[] image = prog.getBinaryField(ProgramFieldType.PICTURE_TYPE); if (image != null) { String line = "<tr><td></td><td valign=\"top\" style=\"color:rgb(" + foreground.getRed() + "," + foreground.getGreen() + "," + foreground.getBlue() + "); font-size:0\">"; buffer.append(line); try { ImageIcon imageIcon = new ImageIcon(image); if (zoom != 100) { imageIcon = (ImageIcon) UiUtilities.scaleIcon(imageIcon, imageIcon.getIconWidth() * zoom / 100); } StringBuilder value = new StringBuilder(); String textField = prog.getTextField(ProgramFieldType.PICTURE_COPYRIGHT_TYPE); if (textField != null) { value.append(textField); } if (settings.isShowingPictureDescription()) { textField = prog.getTextField(ProgramFieldType.PICTURE_DESCRIPTION_TYPE); if (textField != null) { value.append("<br>").append(textField); } } buffer.append(doc.createCompTag(new JLabel(imageIcon))); buffer.append("<div style=\"font-size:"); buffer.append(mBodyFontSize); buffer.append("\">"); buffer.append(value); buffer.append("</div>"); buffer.append("</td></tr>"); } catch (Exception e) { // Picture was wrong; buffer.delete(buffer.length() - line.length(), buffer.length()); } } } Marker[] pluginArr = prog.getMarkerArr(); if (showPluginIcons && (pluginArr != null) && (pluginArr.length != 0)) { addSeparator(doc, buffer); buffer.append("<tr><td valign=\"top\" style=\"color:#808080; font-size:"); buffer.append(mBodyFontSize); buffer.append("\"><b>"); buffer.append(mLocalizer.msg("markedBy", "Marked by")); buffer.append("</b></td><td valign=\"middle\" style=\"font-size:4\">"); openPara(buffer, "info"); // Workaround: Without the the component are not put in one line. buffer.append(" "); for (int markerCount = pluginArr.length - 1; markerCount >= 0; markerCount--) { Icon[] icons = pluginArr[markerCount].getMarkIcons(prog); if (icons != null) { for (int i = icons.length - 1; i >= 0; i--) { JLabel iconLabel = new JLabel(icons[i]); PluginAccess plugin = Plugin.getPluginManager() .getActivatedPluginForId(pluginArr[markerCount].getId()); if (plugin != null) { iconLabel.setToolTipText(plugin.getInfo().getName()); } else { InternalPluginProxyIf internalPlugin = InternalPluginProxyList.getInstance() .getProxyForId(pluginArr[markerCount].getId()); if (internalPlugin != null) { iconLabel.setToolTipText(internalPlugin.getName()); if (internalPlugin.equals(FavoritesPluginProxy.getInstance())) { // if this is a favorite, add the names of the favorite String favTitles = ""; for (Favorite favorite : FavoriteTreeModel.getInstance() .getFavoritesContainingProgram(prog)) { if (favTitles.length() > 0) { favTitles = favTitles + ", "; } favTitles = favTitles + favorite.getName(); } if (favTitles.length() > 0) { iconLabel.setToolTipText( iconLabel.getToolTipText() + " (" + favTitles + ")"); } } } else { iconLabel.setToolTipText(pluginArr[markerCount].toString()); } } buffer.append(doc.createCompTag(iconLabel)); buffer.append(" "); } } } closePara(buffer); buffer.append("</td></tr>"); } PluginAccess[] plugins = Plugin.getPluginManager().getActivatedPlugins(); ArrayList<JLabel> iconLabels = new ArrayList<JLabel>(); for (PluginAccess plugin : plugins) { Icon[] icons = plugin.getProgramTableIcons(prog); if (icons != null) { for (Icon icon : icons) { JLabel iconLabel = new JLabel(icon); iconLabel.setToolTipText(plugin.getInfo().getName()); iconLabels.add(iconLabel); } } } if (showPluginIcons && iconLabels.size() > 0) { addSeparator(doc, buffer); buffer.append("<tr><td valign=\"middle\" style=\"color:#808080; font-size:"); buffer.append(mBodyFontSize); buffer.append("\"><b>"); buffer.append("Plugin-Icons"); buffer.append("</b></td><td valign=\"top\" style=\"font-size:4\">"); openPara(buffer, "info"); // Workaround: Without the the component are not put in one line. buffer.append(" "); for (JLabel iconLabel : iconLabels) { buffer.append(doc.createCompTag(iconLabel)); buffer.append(" "); } closePara(buffer); buffer.append("</td></tr>"); } addSeparator(doc, buffer); for (Object id : fieldArr) { ProgramFieldType type = null; if (id instanceof String) { if (((String) id).matches("\\d+")) { try { type = ProgramFieldType.getTypeForId(Integer.parseInt((String) id, 10)); } catch (Exception e) { // Empty Catch } } if (type == null) { int length = prog.getLength(); if (length > 0 && ((String) id).trim().length() > 0) { buffer.append("<tr><td valign=\"top\" style=\"color:gray; font-size:"); buffer.append(mBodyFontSize); buffer.append("\"><b>"); buffer.append(mLocalizer.msg("duration", "Program duration/<br>-end")); buffer.append("</b></td><td style=\"color:rgb(" + foreground.getRed() + "," + foreground.getGreen() + "," + foreground.getBlue() + "); font-size:"); buffer.append(mBodyFontSize); buffer.append("\">"); openPara(buffer, "time"); String msg = mLocalizer.msg("minutes", "{0} min", length); buffer.append(msg).append(" ("); buffer.append(mLocalizer.msg("until", "until {0}", prog.getEndTimeString())); int netLength = prog.getIntField(ProgramFieldType.NET_PLAYING_TIME_TYPE); if (netLength != -1) { msg = mLocalizer.msg("netMinuted", "{0} min net", netLength); buffer.append(" - ").append(msg); } buffer.append(')'); closePara(buffer); buffer.append("</td></tr>"); addSeparator(doc, buffer); } } } else if (id instanceof CompoundedProgramFieldType) { CompoundedProgramFieldType value = (CompoundedProgramFieldType) id; String entry = value.getFormattedValueForProgram(prog); if (entry != null) { startInfoSection(buffer, value.getName()); buffer.append(HTMLTextHelper.convertTextToHtml(entry, false)); addSeparator(doc, buffer); } } else { type = (ProgramFieldType) id; if (type == ProgramFieldType.DESCRIPTION_TYPE) { String description = checkDescription(prog.getDescription()); if (description != null && description.length() > 0) { addEntry(doc, buffer, prog, ProgramFieldType.DESCRIPTION_TYPE, true, showHelpLinks, showPersonLinks); } else { addEntry(doc, buffer, prog, ProgramFieldType.SHORT_DESCRIPTION_TYPE, true, showHelpLinks, showPersonLinks); } } else if (type == ProgramFieldType.INFO_TYPE) { int info = prog.getInfo(); if ((info != -1) && (info != 0)) { buffer.append("<tr><td valign=\"top\" style=\"color:gray; font-size:"); buffer.append(mBodyFontSize); buffer.append("\"><b>"); buffer.append(type.getLocalizedName()); buffer.append("</b></td><td valign=\"middle\" style=\"font-size:5\">"); openPara(buffer, "info"); // Workaround: Without the the component are not put in one // line. buffer.append(" "); int[] infoBitArr = ProgramInfoHelper.getInfoBits(); Icon[] infoIconArr = ProgramInfoHelper.getInfoIcons(); String[] infoMsgArr = ProgramInfoHelper.getInfoIconMessages(); for (int i = 0; i < infoBitArr.length; i++) { if (ProgramInfoHelper.bitSet(info, infoBitArr[i])) { JLabel iconLabel; if (infoIconArr[i] != null) { iconLabel = new JLabel(infoIconArr[i]); } else { iconLabel = new JLabel(infoMsgArr[i]); } iconLabel.setToolTipText(infoMsgArr[i]); buffer.append(doc.createCompTag(iconLabel)); buffer.append(" "); } } closePara(buffer); buffer.append("</td></tr>"); addSeparator(doc, buffer); } } else if (type == ProgramFieldType.URL_TYPE) { addEntry(doc, buffer, prog, ProgramFieldType.URL_TYPE, true, showHelpLinks, showPersonLinks); } else if (type == ProgramFieldType.ACTOR_LIST_TYPE) { ArrayList<String> knownNames = new ArrayList<String>(); String[] recognizedActors = ProgramUtilities.getActorNames(prog); if (recognizedActors != null) { knownNames.addAll(Arrays.asList(recognizedActors)); } String actorField = prog.getTextField(type); if (actorField != null) { ArrayList<String>[] lists = ProgramUtilities.splitActors(prog); if (lists == null) { lists = splitActorsSimple(prog); } if (lists != null && lists[0].size() > 0) { startInfoSection(buffer, type.getLocalizedName()); buffer.append("<table border=\"0\" cellpadding=\"0\" style=\"font-family:"); buffer.append(bodyFont); buffer.append(";\">"); for (int i = 0; i < lists[0].size(); i++) { String[] parts = new String[2]; parts[0] = lists[0].get(i); parts[1] = ""; if (i < lists[1].size()) { parts[1] = lists[1].get(i); } int actorIndex = 0; if (showPersonLinks) { if (knownNames.contains(parts[0])) { parts[0] = addPersonLink(parts[0]); } else if (knownNames.contains(parts[1])) { parts[1] = addPersonLink(parts[1]); actorIndex = 1; } } buffer.append("<tr><td valign=\"top\">• </td><td valign=\"top\">"); buffer.append(parts[actorIndex]); buffer.append("</td><td width=\"10\"> </td>"); if (parts[1 - actorIndex].length() > 0) { buffer.append("<td valign=\"top\">"); buffer.append(parts[1 - actorIndex]); buffer.append("</td>"); } else { // if roles are missing add next actor in the same line if (i + 1 < lists[0].size() && lists[1].size() == 0) { i++; buffer.append( "<td valign=\"top\">• </td><td valign=\"top\">"); if (showPersonLinks) { buffer.append(addSearchLink(lists[0].get(i))); } else { buffer.append(lists[0].get(i)); } buffer.append("</td>"); } } buffer.append("</td></tr>"); } buffer.append("</table>"); buffer.append("</td></tr>"); addSeparator(doc, buffer); } else { addEntry(doc, buffer, prog, type, showHelpLinks, showPersonLinks); } } } else { addEntry(doc, buffer, prog, type, showHelpLinks, showPersonLinks); } } } if (showHelpLinks) { buffer.append( "<tr><td colspan=\"2\" valign=\"top\" align=\"center\" style=\"color:#808080; font-size:"); buffer.append(mBodyFontSize).append("\">"); buffer.append("<a href=\""); buffer.append( mLocalizer.msg("dataInfo", "http://wiki.tvbrowser.org/index.php/Qualit%C3%A4t_der_Daten")) .append("\">"); buffer.append(mLocalizer.msg("dataQuality", "Details of the data quality")); buffer.append("</a>"); buffer.append("</td></tr>"); } buffer.append("</table></html>"); return buffer.toString(); } catch (Exception e) { e.printStackTrace(); } return ""; }
From source file:edu.harvard.i2b2.analysis.ui.AnalysisComposite.java
private JFreeChart createWaitingChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart("Working .............", // chart // title "", // domain axis label "", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips? false // URLs? );/* w ww.jav a 2 s.co m*/ CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); Font f = chart.getTitle().getFont(); chart.getTitle().setFont(new java.awt.Font(f.getFamily(), 1, 12)); return chart; }
From source file:edu.harvard.i2b2.analysis.ui.AnalysisComposite.java
private JFreeChart createEmptyChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart("", // chart // title "", // domain axis label "", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips? false // URLs? );/*from w w w. ja v a2s . com*/ CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); plot.getRangeAxis().setRangeWithMargins(0.0, 100.0); Font f = chart.getTitle().getFont(); chart.getTitle().setFont(new java.awt.Font(f.getFamily(), 1, 12)); return chart; }
From source file:edu.harvard.i2b2.analysis.ui.AnalysisComposite.java
private JFreeChart createNoDataChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart("No results to display", // chart // title "", // domain axis label "", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips? false // URLs? );// w w w . j a v a 2s. c om CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); Font f = chart.getTitle().getFont(); chart.getTitle().setFont(new java.awt.Font(f.getFamily(), 1, 12)); return chart; }
From source file:edu.harvard.i2b2.analysis.ui.AnalysisComposite.java
/** * Creates a chart./*from w w w.j av a 2 s. com*/ * * @param dataset * dataset. * * @return A chart. */ private JFreeChart createChart(CategoryDataset dataset, String title) { JFreeChart chart = ChartFactory.createBarChart(title, // chart // title "", // domain axis label "", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips? false // URLs? ); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); if (plot.getCategories().size() > 10) { plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); } Font f = chart.getTitle().getFont(); chart.getTitle().setFont(new java.awt.Font(f.getFamily(), 1, 12)); return chart; }