List of usage examples for com.lowagie.text Font ITALIC
int ITALIC
To view the source code for com.lowagie.text Font ITALIC.
Click Source Link
From source file:org.eclipse.birt.report.engine.layout.area.impl.TextArea.java
License:Open Source License
public int getWidth() { int fontStyle = fi.getFontStyle(); //get width for text with simulated italic font. if (fi.getSimulation() && (Font.ITALIC == fontStyle || Font.BOLDITALIC == fontStyle)) { width = (int) (width + height * EmitterUtil.getItalicHorizontalCoefficient()); }//ww w . ja v a2 s .com return width; }
From source file:org.eclipse.birt.report.engine.layout.pdf.font.FontHandler.java
License:Open Source License
/** * The constructor//w w w . j a va2 s. c om * * @param textContent * the textContent whose font need to be handled * @param fontSubstitution * If it set to false, we needn't check if the character exists * in the selected font. * @param format * the output format type */ public FontHandler(FontMappingManager fontManager, ITextContent textContent, boolean fontSubstitution) { this.fontManager = fontManager; IStyle style = textContent.getComputedStyle(); CSSValueList families = (CSSValueList) style.getProperty(StyleConstants.STYLE_FONT_FAMILY); this.fontFamilies = new String[families.getLength()]; for (int i = 0; i < fontFamilies.length; i++) { fontFamilies[i] = families.item(i).getCssText(); } this.fontWeight = PropertyUtil.parseFontWeight(style.getProperty(StyleConstants.STYLE_FONT_WEIGHT)); if (CSSConstants.CSS_OBLIQUE_VALUE.equals(style.getFontStyle()) || CSSConstants.CSS_ITALIC_VALUE.equals(style.getFontStyle())) { this.fontStyle |= Font.ITALIC; } if (PropertyUtil.isBoldFont(fontWeight)) { this.fontStyle |= Font.BOLD; } this.fontSize = PropertyUtil.getDimensionValueConsiderDpi(style.getProperty(StyleConstants.STYLE_FONT_SIZE), textContent) / PDFConstants.LAYOUT_TO_PDF_RATIO; if (!fontSubstitution) { for (int i = 0; i < fontFamilies.length; i++) { String fontName = fontManager.getAliasedFont(fontFamilies[i]); bf = fontManager.createFont(fontName, fontStyle); if (bf != null) return; } bf = fontManager.createFont(FontMappingManager.DEFAULT_FONT, fontStyle); } }
From source file:org.eclipse.birt.report.engine.layout.pdf.font.FontHandler.java
License:Open Source License
/** * If the BaseFont can NOT find the correct physical glyph, we need to * simulate the proper style for the font. The "simulate" flag will be set * if we need to simulate it.//from w w w . j a va 2s . com */ private boolean needSimulate(BaseFont font) { if (fontStyle == Font.NORMAL) { return false; } String[][] fullNames = bf.getFullFontName(); String fullName = getEnglishName(fullNames); String lcf = fullName.toLowerCase(); int fs = Font.NORMAL; if (lcf.indexOf("bold") != -1) { fs |= Font.BOLD; } if (lcf.indexOf("italic") != -1 || lcf.indexOf("oblique") != -1) { fs |= Font.ITALIC; } if ((fontStyle & Font.BOLDITALIC) == fs) { if (fontWeight > 400 && fontWeight != 700) { // not a regular bold font. return true; } else { return false; } } return true; }
From source file:org.eclipse.birt.report.engine.layout.pdf.font.FontInfo.java
License:Open Source License
public int getItalicAdjust() { // get width for text with simulated italic font. if (simulation && (Font.ITALIC == fontStyle || Font.BOLDITALIC == fontStyle)) { return (int) (fontHeight * EmitterUtil.getItalicHorizontalCoefficient()); }//w ww. j ava 2s . c om return 0; }
From source file:org.eclipse.birt.report.engine.layout.pdf.util.PropertyUtil.java
License:Open Source License
public static int getFontStyle(String fontStyle, String fontWeight) { int styleValue = Font.NORMAL; if (CSSConstants.CSS_OBLIQUE_VALUE.equals(fontStyle) || CSSConstants.CSS_ITALIC_VALUE.equals(fontStyle)) { styleValue |= Font.ITALIC; }/* www . j a v a2 s . c om*/ if (CSSConstants.CSS_BOLD_VALUE.equals(fontWeight) || CSSConstants.CSS_BOLDER_VALUE.equals(fontWeight) || CSSConstants.CSS_600_VALUE.equals(fontWeight) || CSSConstants.CSS_700_VALUE.equals(fontWeight) || CSSConstants.CSS_800_VALUE.equals(fontWeight) || CSSConstants.CSS_900_VALUE.equals(fontWeight)) { styleValue |= Font.BOLD; } return styleValue; }
From source file:org.eclipse.birt.report.engine.nLayout.area.impl.TextArea.java
License:Open Source License
public int getWidth() { int fontStyle = style.getFontInfo().getFontStyle(); // get width for text with simulated italic font. if (style.getFontInfo().getSimulation() && (Font.ITALIC == fontStyle || Font.BOLDITALIC == fontStyle)) { width = (int) (width + height * EmitterUtil.getItalicHorizontalCoefficient()); }/*from w w w . ja va 2 s. com*/ return width; }
From source file:org.gtdfree.gui.DatabaseSelectionDialog.java
License:Open Source License
private void initialize() { setTitle(Messages.getString("DatabaseSelectionDialog.Title")); //$NON-NLS-1$ setModal(true);/* w w w. ja v a2 s . c om*/ JPanel p = new JPanel(); p.setLayout(new GridBagLayout()); ButtonGroup bg = new ButtonGroup(); int row = 0; JLabel l = new JLabel(Messages.getString("DatabaseSelectionDialog.DatabaseLoc") + " '" //$NON-NLS-1$//$NON-NLS-2$ + ApplicationHelper.getDataFolder() + "'."); //$NON-NLS-1$ p.add(l, new GridBagConstraints(0, row, 2, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(11, 11, 7, 11), 0, 0)); l = new JLabel(Messages.getString("DatabaseSelectionDialog.Question")); //$NON-NLS-1$ p.add(l, new GridBagConstraints(0, ++row, 2, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(4, 11, 4, 11), 0, 0)); rbXML = new JRadioButton(); rbXML.setText(Messages.getString("DatabaseSelectionDialog.XML")); //$NON-NLS-1$ bg.add(rbXML); p.add(rbXML, new GridBagConstraints(0, ++row, 2, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(4, 11, 4, 11), 0, 0)); l = new JLabel(Messages.getString("DatabaseSelectionDialog.XMl.desc")); //$NON-NLS-1$ l.setFont(l.getFont().deriveFont(Font.ITALIC)); p.add(l, new GridBagConstraints(0, ++row, 2, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 22, 4, 11), 0, 0)); cb = new JCheckBox(); rbODB = new JRadioButton(); rbODB.setText(Messages.getString("DatabaseSelectionDialog.ODB")); //$NON-NLS-1$ rbODB.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { cb.setEnabled(rbODB.isSelected()); } }); rbODB.setSelected(true); bg.add(rbODB); p.add(rbODB, new GridBagConstraints(0, ++row, 2, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(4, 11, 4, 11), 0, 0)); l = new JLabel(Messages.getString("DatabaseSelectionDialog.ODB.desc")); //$NON-NLS-1$ l.setFont(l.getFont().deriveFont(Font.ITALIC)); p.add(l, new GridBagConstraints(0, ++row, 2, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 22, 4, 11), 0, 0)); cb.setText(Messages.getString("DatabaseSelectionDialog.Import")); //$NON-NLS-1$ cb.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { upgrade = cb.isSelected(); } }); p.add(cb, new GridBagConstraints(0, ++row, 2, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(4, 22, 4, 11), 0, 0)); JButton b = new JButton(); b.setText(Messages.getString("DatabaseSelectionDialog.Continue")); //$NON-NLS-1$ b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cont = true; DatabaseSelectionDialog.this.dispose(); } }); p.add(b, new GridBagConstraints(0, ++row, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(11, 11, 11, 4), 0, 0)); b = new JButton(); b.setText(Messages.getString("DatabaseSelectionDialog.Abort")); //$NON-NLS-1$ b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DatabaseSelectionDialog.this.dispose(); } }); p.add(b, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(11, 4, 11, 11), 0, 0)); setContentPane(p); pack(); setLocationRelativeTo(null); }
From source file:org.gtdfree.gui.DatabaseToolsDialog.java
License:Open Source License
/** * @return//from w w w . j a v a 2 s . co m */ private JPanel getOdbTab() { JPanel jp; jp = new JPanel(); jp.setLayout(new GridBagLayout()); int row = 0; JTextArea ta = new JTextArea(); ta.setEditable(false); ta.setEnabled(false); ta.setWrapStyleWord(true); ta.setLineWrap(true); ta.setDisabledTextColor(ta.getForeground()); ta.setBorder(null); ta.setFont(ta.getFont().deriveFont(Font.ITALIC)); ta.setText(Messages.getString("DatabaseToolsDialog.Tools.desc")); //$NON-NLS-1$ jp.add(ta, new GridBagConstraints(0, row, 2, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(11, 11, 11, 11), 0, 0)); JButton b = new JButton(); b.setText(Messages.getString("DatabaseToolsDialog.Exp")); //$NON-NLS-1$ b.setToolTipText(Messages.getString("DatabaseToolsDialog.Exp.desc")); //$NON-NLS-1$ b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //int option= JOptionPane.showConfirmDialog(dialog, "Exporting all data to ODB database file\nAfter export GTD-Free will be closed and you will have to restart.\n\nDo you want to continue?", "Warning! Restart is required.", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); //if (option!=JOptionPane.OK_OPTION) { // return ; //} JFileChooser fc = getFileChooser(); fc.showSaveDialog(dialog); File f = fc.getSelectedFile(); if (f != null) { if (!f.getName().endsWith(".odb-xml")) { //$NON-NLS-1$ f = new File(f.getAbsolutePath() + ".odb-xml"); //$NON-NLS-1$ } try { getGTDDataODB().exportODB(f); JOptionPane.showMessageDialog(dialog, Messages.getString("DatabaseToolsDialog.Exp.1") + f.getAbsolutePath() //$NON-NLS-1$ + Messages.getString("DatabaseToolsDialog.Exp.2"), //$NON-NLS-1$ Messages.getString("DatabaseToolsDialog.Exp.title"), //$NON-NLS-1$ JOptionPane.INFORMATION_MESSAGE); engine.close(true, false); } catch (Exception e1) { org.apache.log4j.Logger.getLogger(this.getClass()).error("Export error.", e1); //$NON-NLS-1$ JOptionPane.showMessageDialog(dialog, Messages.getString("DatabaseToolsDialog.Exp.Fail.1") + " " + e1.toString(), //$NON-NLS-1$//$NON-NLS-2$ Messages.getString("DatabaseToolsDialog.Exp.Fail.2"), JOptionPane.ERROR_MESSAGE); //$NON-NLS-1$ } } } }); jp.add(b, new GridBagConstraints(0, ++row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 11, 11, 4), 0, 0)); b = new JButton(); b.setText(Messages.getString("DatabaseToolsDialog.Load")); //$NON-NLS-1$ b.setToolTipText(Messages.getString("DatabaseToolsDialog.Load.desc")); //$NON-NLS-1$ b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int option = JOptionPane.showConfirmDialog(dialog, Messages.getString("DatabaseToolsDialog.Load.Warn"), //$NON-NLS-1$ Messages.getString("DatabaseToolsDialog.Load.Warn.title"), JOptionPane.OK_CANCEL_OPTION, //$NON-NLS-1$ JOptionPane.WARNING_MESSAGE); if (option != JOptionPane.OK_OPTION) { return; } JFileChooser fc = getFileChooser(); int code = fc.showOpenDialog(dialog); File f = fc.getSelectedFile(); if (f != null && code == JFileChooser.APPROVE_OPTION) { try { getGTDDataODB().importODB(f); JOptionPane.showMessageDialog(dialog, Messages.getString("DatabaseToolsDialog.Load.OK"), //$NON-NLS-1$ Messages.getString("DatabaseToolsDialog.Load.OK.title"), //$NON-NLS-1$ JOptionPane.INFORMATION_MESSAGE); engine.close(true, false); } catch (Exception e1) { org.apache.log4j.Logger.getLogger(this.getClass()).error("Import error.", e1); //$NON-NLS-1$ JOptionPane.showMessageDialog(dialog, Messages.getString("DatabaseToolsDialog.Load.Fail") + " " + e1.toString(), //$NON-NLS-1$//$NON-NLS-2$ Messages.getString("DatabaseToolsDialog.Load.Fail.title"), //$NON-NLS-1$ JOptionPane.ERROR_MESSAGE); } } } }); jp.add(b, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 11, 11), 0, 0)); return jp; }
From source file:org.jivesoftware.openfire.archive.ConversationUtils.java
License:Open Source License
public ByteArrayOutputStream getConversationPDF(Conversation conversation) { Font red = FontFactory.getFont(FontFactory.HELVETICA, 12f, Font.BOLD, new Color(0xFF, 0x00, 0x00)); Font blue = FontFactory.getFont(FontFactory.HELVETICA, 12f, Font.ITALIC, new Color(0x00, 0x00, 0xFF)); Font black = FontFactory.getFont(FontFactory.HELVETICA, 12f, Font.BOLD, Color.BLACK); Map<String, Font> colorMap = new HashMap<String, Font>(); if (conversation != null) { Collection<JID> set = conversation.getParticipants(); int count = 0; for (JID jid : set) { if (conversation.getRoom() == null) { if (count == 0) { colorMap.put(jid.toString(), blue); } else { colorMap.put(jid.toString(), red); }//from w w w . ja v a2 s . c o m count++; } else { colorMap.put(jid.toString(), black); } } } return buildPDFContent(conversation, colorMap); }
From source file:org.jivesoftware.openfire.archive.ConversationUtils.java
License:Open Source License
private ByteArrayOutputStream buildPDFContent(Conversation conversation, Map<String, Font> colorMap) { Font roomEvent = FontFactory.getFont(FontFactory.HELVETICA, 12f, Font.ITALIC, new Color(0xFF, 0x00, 0xFF)); try {/*from w ww. ja va 2 s.c o m*/ Document document = new Document(PageSize.A4, 50, 50, 50, 50); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter writer = PdfWriter.getInstance(document, baos); writer.setPageEvent(new PDFEventListener()); document.open(); Paragraph p = new Paragraph( LocaleUtils.getLocalizedString("archive.search.pdf.title", MonitoringConstants.NAME), FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLD)); document.add(p); document.add(Chunk.NEWLINE); ConversationInfo coninfo = new ConversationUtils().getConversationInfo(conversation.getConversationID(), false); String participantsDetail; if (coninfo.getAllParticipants() == null) { participantsDetail = coninfo.getParticipant1() + ", " + coninfo.getParticipant2(); } else { participantsDetail = String.valueOf(coninfo.getAllParticipants().length); } Paragraph chapterTitle = new Paragraph( LocaleUtils.getLocalizedString("archive.search.pdf.participants", MonitoringConstants.NAME) + " " + participantsDetail, FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD)); document.add(chapterTitle); Paragraph startDate = new Paragraph( LocaleUtils.getLocalizedString("archive.search.pdf.startdate", MonitoringConstants.NAME) + " " + coninfo.getDate(), FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD)); document.add(startDate); Paragraph duration = new Paragraph( LocaleUtils.getLocalizedString("archive.search.pdf.duration", MonitoringConstants.NAME) + " " + coninfo.getDuration(), FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD)); document.add(duration); Paragraph messageCount = new Paragraph( LocaleUtils.getLocalizedString("archive.search.pdf.messagecount", MonitoringConstants.NAME) + " " + conversation.getMessageCount(), FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD)); document.add(messageCount); document.add(Chunk.NEWLINE); Paragraph messageParagraph; for (ArchivedMessage message : conversation.getMessages()) { String time = JiveGlobals.formatTime(message.getSentDate()); String from = message.getFromJID().getNode(); if (conversation.getRoom() != null) { from = message.getToJID().getResource(); } String body = message.getBody(); String prefix; if (!message.isRoomEvent()) { prefix = "[" + time + "] " + from + ": "; Font font = colorMap.get(message.getFromJID().toString()); if (font == null) { font = colorMap.get(message.getFromJID().toBareJID()); } if (font == null) { font = FontFactory.getFont(FontFactory.HELVETICA, 12f, Font.BOLD, Color.BLACK); } messageParagraph = new Paragraph(new Chunk(prefix, font)); } else { prefix = "[" + time + "] "; messageParagraph = new Paragraph(new Chunk(prefix, roomEvent)); } messageParagraph.add(body); messageParagraph.add(" "); document.add(messageParagraph); } document.close(); return baos; } catch (DocumentException e) { Log.error("error creating PDF document: " + e.getMessage(), e); return null; } }