List of usage examples for com.lowagie.text Font BOLD
int BOLD
To view the source code for com.lowagie.text Font BOLD.
Click Source Link
From source file:org.primefaces.component.export.PDFExporter.java
License:Open Source License
protected void applyFacetOptions(ExporterOptions options) { String facetBackground = options.getFacetBgColor(); if (facetBackground != null) { facetBgColor = Color.decode(facetBackground); }//from w w w . j a v a 2 s. c o m String facetFontColor = options.getFacetFontColor(); if (facetFontColor != null) { facetFont.setColor(Color.decode(facetFontColor)); } String facetFontSize = options.getFacetFontSize(); if (facetFontSize != null) { facetFont.setSize(Integer.valueOf(facetFontSize)); } String facetFontStyle = options.getFacetFontStyle(); if (facetFontStyle != null) { if (facetFontStyle.equalsIgnoreCase("NORMAL")) { facetFontStyle = "" + Font.NORMAL; } if (facetFontStyle.equalsIgnoreCase("BOLD")) { facetFontStyle = "" + Font.BOLD; } if (facetFontStyle.equalsIgnoreCase("ITALIC")) { facetFontStyle = "" + Font.ITALIC; } facetFont.setStyle(facetFontStyle); } }
From source file:org.primefaces.component.export.PDFExporter.java
License:Open Source License
protected void applyCellOptions(ExporterOptions options) { String cellFontColor = options.getCellFontColor(); if (cellFontColor != null) { cellFont.setColor(Color.decode(cellFontColor)); }/*ww w. j a va 2 s . co m*/ String cellFontSize = options.getCellFontSize(); if (cellFontSize != null) { cellFont.setSize(Integer.valueOf(cellFontSize)); } String cellFontStyle = options.getCellFontStyle(); if (cellFontStyle != null) { if (cellFontStyle.equalsIgnoreCase("NORMAL")) { cellFontStyle = "" + Font.NORMAL; } if (cellFontStyle.equalsIgnoreCase("BOLD")) { cellFontStyle = "" + Font.BOLD; } if (cellFontStyle.equalsIgnoreCase("ITALIC")) { cellFontStyle = "" + Font.ITALIC; } cellFont.setStyle(cellFontStyle); } }
From source file:org.primefaces.extensions.showcase.util.PDFCustomExporter.java
License:Apache License
@Override public void customFormat(String facetBackground, String facetFontSize, String facetFontColor, String facetFontStyle, String fontName, String cellFontSize, String cellFontColor, String cellFontStyle, String datasetPadding, String orientation) { this.facetFontSize = new Float(facetFontSize); this.cellFontSize = new Float(cellFontSize); this.datasetPadding = Integer.parseInt(datasetPadding); this.orientation = orientation; if (facetBackground != null) { this.facetBackground = Color.decode(facetBackground); }//from w w w .jav a2s . com if (facetFontColor != null) { this.facetFontColor = Color.decode(facetFontColor); } if (cellFontColor != null) { this.cellFontColor = Color.decode(cellFontColor); } if (fontName != null) { this.fontName = fontName; } if (facetFontStyle.equalsIgnoreCase("NORMAL")) { this.facetFontStyle = "" + Font.NORMAL; } if (facetFontStyle.equalsIgnoreCase("BOLD")) { this.facetFontStyle = "" + Font.BOLD; } if (facetFontStyle.equalsIgnoreCase("ITALIC")) { this.facetFontStyle = "" + Font.ITALIC; } if (cellFontStyle.equalsIgnoreCase("NORMAL")) { this.cellFontStyle = "" + Font.NORMAL; } if (cellFontStyle.equalsIgnoreCase("BOLD")) { this.cellFontStyle = "" + Font.BOLD; } if (cellFontStyle.equalsIgnoreCase("ITALIC")) { this.cellFontStyle = "" + Font.ITALIC; } }
From source file:org.pz.platypus.plugin.html.HtmlFont.java
License:Open Source License
/** * iText font style captures bold, italic, strikethru, underline. Since we handle * strikethrough and underline ourselves, we use it to communicate italic and bold * only. This computation done here.// w w w .j a va 2 s .com * * @return the iText Style */ int computeItextStyle() { int style = 0; if (italics && bold) { style |= Font.BOLDITALIC; } else if (italics) { style |= Font.ITALIC; } else if (bold) { style |= Font.BOLD; } return (style); }
From source file:org.pz.platypus.plugin.pdf.PdfFontFactory.java
License:Open Source License
/** * iText font style captures bold, italic, strikethru, underline. Since we handle * strikethrough and underline ourselves, we use it to communicate italic and bold * only. This computation done here.//w ww.j a va2 s. c om * * @param f the PdfFont whose style is being checked * @return the iText Style */ int computeItextStyle(PdfFont f) { int style = 0; if (f.getItalics() && f.getBold()) { style |= Font.BOLDITALIC; } else if (f.getItalics()) { style |= Font.ITALIC; } else if (f.getBold()) { style |= Font.BOLD; } return (style); }
From source file:org.revager.gui.aspects_manager.AspectsManagerFrame.java
License:Open Source License
/** * Creates the right pane./*from ww w . j av a2s . co m*/ */ private void createRightPane() { /* * Radio buttons to change the view */ ButtonGroup buttonsView = new ButtonGroup(); GridBagLayout gblView = new GridBagLayout(); final JPanel panelView = new JPanel(gblView); rbReviewersView = new JRadioButton(translate("Show Reviewers"), Data.getInstance().getIcon("reviewers_16x16.png")); rbAspectsView = new JRadioButton(translate("Show assigned Aspects"), Data.getInstance().getIcon("aspects_16x16.png")); rbReviewersView.setFont(UI.STANDARD_FONT.deriveFont(Font.BOLD)); rbReviewersView.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); rbReviewersView.setFocusPainted(false); rbReviewersView.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { rbReviewersView.setFont(UI.STANDARD_FONT.deriveFont(Font.BOLD)); rbAspectsView.setFont(UI.STANDARD_FONT); rightPanel.remove(panelAllAspects); rightPanel.add(panelReviewers, BorderLayout.CENTER); rightPanel.remove(panelView); rightPanel.add(panelView, BorderLayout.NORTH); updateReviewersView(); rightPanel.revalidate(); rightPanel.repaint(); } }); buttonsView.add(rbReviewersView); rbAspectsView.setFont(UI.STANDARD_FONT); rbAspectsView.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); rbAspectsView.setFocusPainted(false); rbAspectsView.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { rbReviewersView.setFont(UI.STANDARD_FONT); rbAspectsView.setFont(UI.STANDARD_FONT.deriveFont(Font.BOLD)); rightPanel.remove(panelReviewers); rightPanel.add(panelAllAspects, BorderLayout.CENTER); rightPanel.remove(panelView); rightPanel.add(panelView, BorderLayout.NORTH); updateAspectsView(); rightPanel.revalidate(); rightPanel.repaint(); } }); buttonsView.add(rbAspectsView); GUITools.addComponent(panelView, gblView, rbReviewersView, 0, 1, 1, 1, 1.0, 0.0, 0, 10, 0, 10, GridBagConstraints.NONE, GridBagConstraints.EAST); GUITools.addComponent(panelView, gblView, rbAspectsView, 1, 1, 1, 1, 1.0, 0.0, 0, 10, 0, 10, GridBagConstraints.NONE, GridBagConstraints.WEST); GUITools.addComponent(panelView, gblView, new JSeparator(SwingConstants.HORIZONTAL), 0, 2, 2, 1, 1.0, 0.0, 0, 0, 10, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); /* * ****** Prepare the reviewers view ****** */ GridBagLayout gblReviewers = new GridBagLayout(); panelReviewers = new JPanel(gblReviewers); panelReviewers.setBorder(new EmptyBorder(30, 30, 30, 30)); /* * Button to allocate aspects to all reviewers */ buttonAllocAll = GUITools.newImageButton(Data.getInstance().getIcon("allocAspAll_32x32_0.png"), Data.getInstance().getIcon("allocAspAll_32x32.png")); buttonAllocAll.setToolTipText(translate("Assign selected Aspects to all Reviewers")); buttonAllocAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingWorker<Void, Void> allocWorker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { notifySwitchToProgressMode(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { switchToProgressMode(translate("Allocating aspects ...")); } }); observeResiData(false); try { for (Attendee att : attMgmt.getAttendees()) { if (att.getRole() == Role.REVIEWER) { for (AppAspect asp : getCheckedAspects()) { attMgmt.addAspect(asp.getAsResiAspect(), att); } } } } catch (DataException exc) { JOptionPane.showMessageDialog(null, GUITools.getMessagePane(exc.getMessage()), translate("Error"), JOptionPane.ERROR_MESSAGE); } observeResiData(true); notifySwitchToEditMode(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { setStatusMessage(translate("Aspects allocated successfully."), false); switchToEditMode(); } }); return null; } }; GUITools.executeSwingWorker(allocWorker); } }); GUITools.addComponent(panelReviewers, gblReviewers, buttonAllocAll, 0, 0, 1, 1, 0.0, 0.0, 0, 0, 0, 5, GridBagConstraints.NONE, GridBagConstraints.WEST); /* * Prepare the panel for the reviewer buttons */ panelRevButtons = new JPanel(new ExtendedFlowLayout(FlowLayout.LEFT, 7, 7)); GUITools.addComponent(panelReviewers, gblReviewers, panelRevButtons, 1, 0, 1, 1, 1.0, 0.0, 0, 0, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST); /* * Button to allocate aspects to the selected reviewer */ buttonAlloc = GUITools.newImageButton(Data.getInstance().getIcon("allocAsp_32x32_0.png"), Data.getInstance().getIcon("allocAsp_32x32.png")); buttonAlloc.setToolTipText(translate("Assign selected Aspects to the displayed Reviewer")); buttonAlloc.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingWorker<Void, Void> allocWorker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { notifySwitchToProgressMode(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { switchToProgressMode(translate("Allocating aspects ...")); } }); observeResiData(false); try { for (AppAspect asp : getCheckedAspects()) { attMgmt.addAspect(asp.getAsResiAspect(), selectedReviewer); } } catch (DataException exc) { JOptionPane.showMessageDialog(null, GUITools.getMessagePane(exc.getMessage()), translate("Error"), JOptionPane.ERROR_MESSAGE); } observeResiData(true); notifySwitchToEditMode(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { setStatusMessage(translate("Aspects allocated successfully."), false); switchToEditMode(); } }); return null; } }; GUITools.executeSwingWorker(allocWorker); } }); GUITools.addComponent(panelReviewers, gblReviewers, buttonAlloc, 0, 1, 1, 1, 0.0, 0.0, 45, 0, 0, 5, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); /* * Prepare the panel for the reviewer table */ panelRevTable = new JPanel(new BorderLayout()); GUITools.addComponent(panelReviewers, gblReviewers, panelRevTable, 1, 1, 1, 1, 1.0, 1.0, 20, 7, 7, 7, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); /* * ****** Prepare the aspects view ****** */ panelAllAspects = new JPanel(new BorderLayout()); panelAllAspects.setBorder(new EmptyBorder(30, 40, 30, 40)); aspTabModel = new AspectTableModel(); final JTable tableAspects = GUITools.newStandardTable(aspTabModel, true); tableAspects.setShowGrid(true); tableAspects.getColumnModel().getColumn(1).setMaxWidth(200); tableAspects.getColumnModel().getColumn(1).setPreferredWidth(150); tableAspects.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { int selRow = tableAspects.getSelectedRow(); if (e.getClickCount() == 2 && selRow != -1) { Aspect aspect = aspTabModel.getAspect(selRow); EditAspectPopupWindow popup = new EditAspectPopupWindow( UI.getInstance().getAspectsManagerFrame(), aspect); popup.setVisible(true); aspMgmt.editAspect(aspect, aspect); tableAspects.setRowSelectionInterval(selRow, selRow); tableAspects.repaint(); aspTabModel.fireTableDataChanged(); } } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } }); /* * Tooltips */ DefaultTableCellRenderer cellRend = new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { String content = (String) value; setToolTipText(GUITools.getTextAsHtml(content)); content = content.split("\n")[0]; return super.getTableCellRendererComponent(table, content, isSelected, hasFocus, row, column); } }; tableAspects.getColumnModel().getColumn(0).setCellRenderer(cellRend); tableAspects.getColumnModel().getColumn(1).setCellRenderer(cellRend); panelAllAspects.add(GUITools.setIntoScrollPane(tableAspects), BorderLayout.CENTER); /* * ****** Add right panel to split panel ****** */ rightPanel = new JPanel(new BorderLayout()) { @Override public Dimension getMinimumSize() { return new Dimension(450, 400); } }; splitPane.setRightComponent(rightPanel); }
From source file:org.sakaiproject.evaluation.tool.reporting.EvalPDFReportBuilder.java
License:Educational Community License
public EvalPDFReportBuilder(OutputStream outputStream) { document = new Document(); try {/*from w ww . jav a 2 s .com*/ pdfWriter = PdfWriter.getInstance(document, outputStream); pdfWriter.setStrictImageSequence(true); document.open(); // attempting to handle i18n chars better // BaseFont evalBF = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.IDENTITY_H, // BaseFont.EMBEDDED); // paragraphFont = new Font(evalBF, 9, Font.NORMAL); // paragraphFont = new Font(Font.TIMES_ROMAN, 9, Font.NORMAL); titleTextFont = new Font(Font.TIMES_ROMAN, 22, Font.BOLD); boldTextFont = new Font(Font.TIMES_ROMAN, 10, Font.BOLD); questionTextFont = FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.BOLD); paragraphFont = FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.NORMAL); paragraphFontBold = FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD); frontTitleFont = FontFactory.getFont(FontFactory.TIMES_ROMAN, frontTitleSize, Font.NORMAL); frontAuthorFont = FontFactory.getFont(FontFactory.TIMES_ROMAN, 18, Font.NORMAL); frontInfoFont = FontFactory.getFont(FontFactory.TIMES_ROMAN, 16, Font.NORMAL); } catch (Exception e) { throw UniversalRuntimeException.accumulate(e, "Unable to start PDF Report"); } }
From source file:org.semtix.gui.filter.DialogAntragFilter.java
License:Open Source License
/** * Erstellt einne Dialog zur Antrgafilterung * @param control FilterControl/* w w w. j a v a2 s . c o m*/ */ public DialogAntragFilter(FilterControl control) { this.filterControl = control; dialog = new JDialog(); dialog.setTitle("Datenstze nach Antragsart filtern"); dialog.setSize(500, 300); dialog.setResizable(false); dialog.setLayout(new BorderLayout()); dialog.setModal(true); // ***** Panel erstellen ***** // TitelPanel JLabel lbTitel = new JLabel("Filter"); JLabel lbUni = new JLabel("Antrge fr " + UniConf.aktuelleUni); lbTitel.setFont(lbTitel.getFont().deriveFont(Font.BOLD, 14f)); lbUni.setFont(lbUni.getFont().deriveFont(Font.BOLD)); SForm titelPanel = new SForm(); titelPanel.setBackground(new Color(200, 200, 200)); titelPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 2, 0, Color.BLACK)); titelPanel.add(lbTitel, 0, 0, 1, 1, 0.0, 0.0, 0, 18, new Insets(5, 5, 5, 5)); titelPanel.add(lbUni, 0, 1, 1, 1, 1.0, 1.0, 0, 18, new Insets(5, 5, 5, 5)); // FilterPanel fr direkete Filter (ber Buttons) filterPanel = new FilterPanel(filterControl); // BuchstabenPanel mit den CheckBoxen und Anfangsbuchstaben fr die Filterauswahl buchstabenPanel = new BuchstabenPanel(filterControl); // SonstigeFilterPanel mit auswahlisten sonstigeFilterPanel = new SonstigeFilterPanel(filterControl); // Panel fr Button zum Abbrechen (Dialog schlieen) JPanel buttonPanel = new JPanel(); // Button zum Schlieen des Dialogs hinzufgen buttonPanel.add(new JButton(new ActionCloseDialog(dialog, "Beenden"))); buttonPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "actionEscapeDialog"); buttonPanel.getActionMap().put("actionEscapeDialog", new AbstractAction() { @Override public void actionPerformed(ActionEvent arg0) { dialog.dispose(); } }); SForm mainPanel = new SForm(); // leeren Rahmen erzeugen (Innenabstand des Panels) mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); mainPanel.add(titelPanel, 0, 0, 2, 1, 0.0, 0.0, 2, 18, new Insets(5, 5, 5, 5)); mainPanel.add(filterPanel, 0, 1, 1, 1, 0.5, 0.5, 2, 18, new Insets(5, 5, 5, 15)); mainPanel.add(sonstigeFilterPanel, 1, 1, 1, 1, 0.5, 0.5, 2, 18, new Insets(5, 15, 5, 5)); mainPanel.add(buchstabenPanel, 0, 2, 2, 1, 1.0, 1.0, 2, 18, new Insets(5, 5, 5, 5)); dialog.add(mainPanel, BorderLayout.CENTER); dialog.add(buttonPanel, BorderLayout.SOUTH); dialog.pack(); // Frame auf dem Bildschirm zentrieren dialog.setLocationRelativeTo(null); dialog.setVisible(true); }
From source file:org.semtix.gui.tabs.antrag.nachreichungen.pruefen.DialogNachreichung.java
License:Open Source License
/** * Erstellt einen neuen Dialog// ww w .jav a 2 s . co m * @param _control NachreichungControl */ public DialogNachreichung(NachreichungControl _control) { this.control = _control; setTitle("Ungeprfte Nachreichungen"); setSize(500, 300); setModal(true); //setResizable(false); setLayout(new BorderLayout(10, 10)); // ***** HeadPanel lbSemester = new JLabel(); lbName = new JLabel(); lbMatrikelnr = new JLabel(); lbName.setFont(lbName.getFont().deriveFont(Font.BOLD, 14f)); lbSemester.setFont(lbSemester.getFont().deriveFont(Font.BOLD, 14f)); lbMatrikelnr.setFont(lbMatrikelnr.getFont().deriveFont(Font.BOLD, 14f)); SForm headPanel = new SForm(); headPanel.setBackground(new Color(200, 200, 200)); headPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 2, 0, Color.BLACK)); headPanel.add(lbSemester, 0, 0, 2, 1, 0.0, 0.0, 0, 18, new Insets(5, 5, 5, 5)); headPanel.add(lbName, 0, 1, 1, 1, 0.0, 0.0, 0, 17, new Insets(10, 5, 5, 5)); headPanel.add(lbMatrikelnr, 1, 1, 1, 1, 1.0, 1.0, 0, 13, new Insets(10, 5, 5, 5)); // ***** ButtonPanel JPanel buttonPanel = new JPanel(); JButton exitButton = new JButton(new ActionCloseDialog(this, "Abbrechen")); exitButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "actionEscapeDialog"); exitButton.getActionMap().put("actionEscapeDialog", new AbstractAction() { @Override public void actionPerformed(ActionEvent arg0) { dispose(); } }); buttonPanel.add(exitButton); // ***** Panel fr neue Nachreichungen JLabel lbTextNeu = new JLabel("Neue Nachreichung"); rbPapier = new JRadioButton("Papier"); rbEmail = new JRadioButton("Email"); rbAusgedruckteEmail = new JRadioButton("ausgedruckte Email"); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(rbPapier); buttonGroup.add(rbEmail); buttonGroup.add(rbAusgedruckteEmail); // Radiobutton "Papier" zu Beginn auf ausgewhlt setzen rbPapier.setSelected(true); JButton addButton = new JButton("anlegen"); addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { addNachreichung(); } }); // Panel mit RadioButtons zum Hinzufgen neuer Nachreichungen SForm addPanel = new SForm(); addPanel.add(lbTextNeu, 0, 0, 1, 1, 0.0, 0.0, 0, 18, new Insets(2, 2, 10, 2)); addPanel.add(rbPapier, 0, 1, 1, 1, 0.0, 0.0, 0, 18, new Insets(2, 2, 2, 2)); addPanel.add(rbEmail, 0, 2, 1, 1, 0.0, 0.0, 0, 18, new Insets(2, 2, 2, 2)); addPanel.add(rbAusgedruckteEmail, 0, 3, 1, 1, 1.0, 1.0, 0, 18, new Insets(2, 2, 10, 2)); addPanel.add(addButton, 0, 4, 1, 1, 0.0, 0.0, 0, 16, new Insets(2, 2, 2, 2)); // ***** Panel zum Auflisten und prfen vorhandener Nachreichungen JLabel lbTextList = new JLabel("Vorhandene Nachreichungen"); nachreichungView = new SForm(); nachreichungView.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); nachreichungView.setBackground(new Color(235, 235, 235)); checkedButton = new JButton("geprft"); checkedButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { control.saveNachreichungen(); } }); // Panel mit der Auflistung der vorhandenen Nachreichungen SForm listPanel = new SForm(); listPanel.add(lbTextList, 0, 0, 1, 1, 0.0, 0.0, 0, 18, new Insets(2, 2, 10, 2)); listPanel.add(nachreichungView, 0, 1, 1, 1, 1.0, 1.0, 2, 18, new Insets(2, 2, 2, 2)); listPanel.add(checkedButton, 0, 2, 1, 1, 0.0, 0.0, 0, 16, new Insets(2, 2, 2, 2)); SForm mainPanel = new SForm(); mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); //mainPanel.add(titelPanel, 0, 0, 3, 1, 0.0, 0.0, 2, 18, new Insets(2, 2, 10, 2)); mainPanel.add(headPanel, 0, 0, 3, 1, 0.0, 0.0, 2, 18, new Insets(2, 2, 10, 2)); mainPanel.add(addPanel, 0, 1, 1, 1, 0.0, 0.0, 0, 18, new Insets(2, 2, 10, 2)); mainPanel.add(new JSeparator(JSeparator.VERTICAL), 1, 1, 1, 1, 0.0, 0.0, 1, 18, new Insets(2, 15, 10, 15)); mainPanel.add(listPanel, 2, 1, 1, 1, 1.0, 1.0, 1, 18, new Insets(2, 2, 10, 2)); add(mainPanel, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); }
From source file:org.sigmah.server.endpoint.export.sigmah.exporter.ProjectReportExporter.java
License:Open Source License
@Override public void export(OutputStream output) throws ExportException { loadReport();// w ww . j ava 2 s .c om // Label displayed instead of the Table of Contents during the export. final String tocLabel = localize("projectReportTableOfContents"); if (report != null) { final ProjectReportVersion version = report.getCurrentVersion(); final ProjectReportDTO reportDTO = GetProjectReportHandler.toDTO(report, version); // Generating the RTF try { final Document document = new Document(); final RtfWriter2 writer = RtfWriter2.getInstance(document, output); writer.setAutogenerateTOCEntries(true); document.open(); // Title final Paragraph titleParagraph = new Paragraph(report.getName()); titleParagraph.getFont().setSize(24); titleParagraph.getFont().setStyle(Font.BOLD); document.add(titleParagraph); document.add(new Paragraph()); // Empty paragraph // Table of contents final Paragraph tocParagraph = new Paragraph(); final RtfTableOfContents toc = new RtfTableOfContents(tocLabel); tocParagraph.add(toc); document.add(tocParagraph); // Sections final List<ProjectReportSectionDTO> sections = reportDTO.getSections(); final StringBuilder prefix = new StringBuilder(); for (int index = 0; index < sections.size(); index++) { final ProjectReportSectionDTO section = sections.get(index); prefix.append(index + 1).append('.'); addSection(section, prefix, index + 1, document); prefix.setLength(0); } document.close(); } catch (DocumentException ex) { LOG.error("An error occured while generating the RTF.", ex); } catch (IOException e) { LOG.debug("An error occured while converting HTML to RTF."); } } else { final String idAsString = requireParameter(ExportUtils.PARAM_EXPORT_PROJECT_ID); LOG.error("[export] No project report is identified by '" + idAsString + "'."); throw new ExportException("[export] No project report is identified by '" + idAsString + "'."); } }