List of usage examples for java.awt Font ITALIC
int ITALIC
To view the source code for java.awt Font ITALIC.
Click Source Link
From source file:com.haulmont.cuba.desktop.theme.impl.DesktopThemeLoaderImpl.java
private Integer convertFontStyle(String styleStr) { if ("bold".equals(styleStr)) { return Font.BOLD; } else if ("italic".equals(styleStr)) { return Font.ITALIC; } else if ("bold-italic".equals(styleStr)) { return Font.BOLD | Font.ITALIC; } else if (styleStr == null || "plain".equals(styleStr)) { return Font.PLAIN; } else {/*from ww w .j a v a 2 s . com*/ log.error("Unknown font style: " + styleStr); return null; } }
From source file:lcmc.gui.resources.EditableInfo.java
/** Returns a more panel with "more options are available" message. */ protected final JPanel getMoreOptionsPanel(final int width) { final JLabel l = new JLabel(Tools.getString("EditableInfo.MoreOptions")); final Font font = l.getFont(); final String name = font.getFontName(); final int style = Font.ITALIC; final int size = font.getSize(); l.setFont(new Font(name, style, size - 3)); moreOptionsPanel.setBackground(Browser.PANEL_BACKGROUND); moreOptionsPanel.add(l);//w w w . j ava2 s . co m final Dimension d = moreOptionsPanel.getPreferredSize(); d.width = width; moreOptionsPanel.setMaximumSize(d); return moreOptionsPanel; }
From source file:controller.CCInstance.java
public final boolean signPdf(final String pdfPath, final String destination, final CCSignatureSettings settings, final SignatureListener sl) throws CertificateException, IOException, DocumentException, KeyStoreException, SignatureFailedException, FileNotFoundException, NoSuchAlgorithmException, InvalidAlgorithmParameterException { PrivateKey pk;/*from w w w . j av a2 s .c o m*/ final PdfReader reader = new PdfReader(pdfPath); pk = getPrivateKeyFromAlias(settings.getCcAlias().getAlias()); if (getCertificationLevel(pdfPath) == PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED) { String message = Bundle.getBundle().getString("fileDoesNotAllowChanges"); if (sl != null) { sl.onSignatureComplete(pdfPath, false, message); } throw new SignatureFailedException(message); } if (reader.getNumberOfPages() - 1 < settings.getPageNumber()) { settings.setPageNumber(reader.getNumberOfPages() - 1); } if (null == pk) { String message = Bundle.getBundle().getString("noSmartcardFound"); if (sl != null) { sl.onSignatureComplete(pdfPath, false, message); } throw new CertificateException(message); } if (null == pkcs11ks.getCertificateChain(settings.getCcAlias().getAlias())) { String message = Bundle.getBundle().getString("certificateNullChain"); if (sl != null) { sl.onSignatureComplete(pdfPath, false, message); } throw new CertificateException(message); } final ArrayList<Certificate> embeddedCertificateChain = settings.getCcAlias().getCertificateChain(); final Certificate owner = embeddedCertificateChain.get(0); final Certificate lastCert = embeddedCertificateChain.get(embeddedCertificateChain.size() - 1); if (null == owner) { String message = Bundle.getBundle().getString("certificateNameUnknown"); if (sl != null) { sl.onSignatureComplete(pdfPath, false, message); } throw new CertificateException(message); } final X509Certificate X509C = ((X509Certificate) lastCert); final Calendar now = Calendar.getInstance(); final Certificate[] filledMissingCertsFromChainInTrustedKeystore = getCompleteTrustedCertificateChain( X509C); final Certificate[] fullCertificateChain; if (filledMissingCertsFromChainInTrustedKeystore.length < 2) { fullCertificateChain = new Certificate[embeddedCertificateChain.size()]; for (int i = 0; i < embeddedCertificateChain.size(); i++) { fullCertificateChain[i] = embeddedCertificateChain.get(i); } } else { fullCertificateChain = new Certificate[embeddedCertificateChain.size() + filledMissingCertsFromChainInTrustedKeystore.length - 1]; int i = 0; for (i = 0; i < embeddedCertificateChain.size(); i++) { fullCertificateChain[i] = embeddedCertificateChain.get(i); } for (int f = 1; f < filledMissingCertsFromChainInTrustedKeystore.length; f++, i++) { fullCertificateChain[i] = filledMissingCertsFromChainInTrustedKeystore[f]; } } // Leitor e Stamper FileOutputStream os = null; try { os = new FileOutputStream(destination); } catch (FileNotFoundException e) { String message = Bundle.getBundle().getString("outputFileError"); if (sl != null) { sl.onSignatureComplete(pdfPath, false, message); } throw new IOException(message); } // Aparncia da Assinatura final char pdfVersion; switch (Settings.getSettings().getPdfVersion()) { case "/1.2": pdfVersion = PdfWriter.VERSION_1_2; break; case "/1.3": pdfVersion = PdfWriter.VERSION_1_3; break; case "/1.4": pdfVersion = PdfWriter.VERSION_1_4; break; case "/1.5": pdfVersion = PdfWriter.VERSION_1_5; break; case "/1.6": pdfVersion = PdfWriter.VERSION_1_6; break; case "/1.7": pdfVersion = PdfWriter.VERSION_1_7; break; default: pdfVersion = PdfWriter.VERSION_1_7; } final PdfStamper stamper = (getNumberOfSignatures(pdfPath) == 0 ? PdfStamper.createSignature(reader, os, pdfVersion) : PdfStamper.createSignature(reader, os, pdfVersion, null, true)); final PdfSignatureAppearance appearance = stamper.getSignatureAppearance(); appearance.setSignDate(now); appearance.setReason(settings.getReason()); appearance.setLocation(settings.getLocation()); appearance.setCertificationLevel(settings.getCertificationLevel()); appearance.setSignatureCreator(SIGNATURE_CREATOR); appearance.setCertificate(owner); final String fieldName = settings.getPrefix() + " " + (1 + getNumberOfSignatures(pdfPath)); if (settings.isVisibleSignature()) { appearance.setVisibleSignature(settings.getPositionOnDocument(), settings.getPageNumber() + 1, fieldName); appearance.setRenderingMode(PdfSignatureAppearance.RenderingMode.DESCRIPTION); if (null != settings.getAppearance().getImageLocation()) { appearance.setImage(Image.getInstance(settings.getAppearance().getImageLocation())); } com.itextpdf.text.Font font = new com.itextpdf.text.Font(FontFactory .getFont(settings.getAppearance().getFontLocation(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 0) .getBaseFont()); font.setColor(new BaseColor(settings.getAppearance().getFontColor().getRGB())); if (settings.getAppearance().isBold() && settings.getAppearance().isItalic()) { font.setStyle(Font.BOLD + Font.ITALIC); } else if (settings.getAppearance().isBold()) { font.setStyle(Font.BOLD); } else if (settings.getAppearance().isItalic()) { font.setStyle(Font.ITALIC); } else { font.setStyle(Font.PLAIN); } appearance.setLayer2Font(font); String text = ""; if (settings.getAppearance().isShowName()) { if (!settings.getCcAlias().getName().isEmpty()) { text += settings.getCcAlias().getName() + "\n"; } } if (settings.getAppearance().isShowReason()) { if (!settings.getReason().isEmpty()) { text += settings.getReason() + "\n"; } } if (settings.getAppearance().isShowLocation()) { if (!settings.getLocation().isEmpty()) { text += settings.getLocation() + "\n"; } } if (settings.getAppearance().isShowDate()) { DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("Z"); text += df.format(now.getTime()) + " " + sdf.format(now.getTime()) + "\n"; } if (!settings.getText().isEmpty()) { text += settings.getText(); } PdfTemplate layer2 = appearance.getLayer(2); Rectangle rect = settings.getPositionOnDocument(); Rectangle sr = new Rectangle(rect.getWidth(), rect.getHeight()); float size = ColumnText.fitText(font, text, sr, 1024, PdfWriter.RUN_DIRECTION_DEFAULT); ColumnText ct = new ColumnText(layer2); ct.setRunDirection(PdfWriter.RUN_DIRECTION_DEFAULT); ct.setAlignment(Element.ALIGN_MIDDLE); int align; switch (settings.getAppearance().getAlign()) { case 0: align = Element.ALIGN_LEFT; break; case 1: align = Element.ALIGN_CENTER; break; case 2: align = Element.ALIGN_RIGHT; break; default: align = Element.ALIGN_LEFT; } ct.setSimpleColumn(new Phrase(text, font), sr.getLeft(), sr.getBottom(), sr.getRight(), sr.getTop(), size, align); ct.go(); } else { appearance.setVisibleSignature(new Rectangle(0, 0, 0, 0), 1, fieldName); } // CRL <- Pesado! final ArrayList<CrlClient> crlList = null; // OCSP OcspClient ocspClient = new OcspClientBouncyCastle(); // TimeStamp TSAClient tsaClient = null; if (settings.isTimestamp()) { tsaClient = new TSAClientBouncyCastle(settings.getTimestampServer(), null, null); } final String hashAlg = getHashAlgorithm(X509C.getSigAlgName()); final ExternalSignature es = new PrivateKeySignature(pk, hashAlg, pkcs11Provider.getName()); final ExternalDigest digest = new ProviderDigest(pkcs11Provider.getName()); try { MakeSignature.signDetached(appearance, digest, es, fullCertificateChain, crlList, ocspClient, tsaClient, 0, MakeSignature.CryptoStandard.CMS); if (sl != null) { sl.onSignatureComplete(pdfPath, true, ""); } return true; } catch (Exception e) { os.flush(); os.close(); new File(destination).delete(); if ("sun.security.pkcs11.wrapper.PKCS11Exception: CKR_FUNCTION_CANCELED".equals(e.getMessage())) { throw new SignatureFailedException(Bundle.getBundle().getString("userCanceled")); } else if ("sun.security.pkcs11.wrapper.PKCS11Exception: CKR_GENERAL_ERROR".equals(e.getMessage())) { throw new SignatureFailedException(Bundle.getBundle().getString("noPermissions")); } else if (e instanceof ExceptionConverter) { String message = Bundle.getBundle().getString("timestampFailed"); if (sl != null) { sl.onSignatureComplete(pdfPath, false, message); } throw new SignatureFailedException(message); } else { if (sl != null) { sl.onSignatureComplete(pdfPath, false, Bundle.getBundle().getString("unknownErrorLog")); } controller.Logger.getLogger().addEntry(e); } return false; } }
From source file:net.sf.jasperreports.engine.fonts.FontUtil.java
/** * Returns a java.awt.Font instance by converting a JRFont instance. * Mostly used in combination with third-party visualization packages such as JFreeChart (for chart themes). * Unless the font parameter is null, this method always returns a non-null AWT font, regardless whether it was * found in the font extensions or not. This is because we do need a font to draw with and there is no point * in raising a font missing exception here, as it is not JasperReports who does the drawing. *///from w w w . jav a 2 s . c o m public Font getAwtFont(JRFont font, Locale locale) { if (font == null) { return null; } // ignoring missing font as explained in the Javadoc Font awtFont = getAwtFontFromBundles(font.getFontName(), ((font.isBold() ? Font.BOLD : Font.PLAIN) | (font.isItalic() ? Font.ITALIC : Font.PLAIN)), font.getFontsize(), locale, true); if (awtFont == null) { awtFont = new Font(getAttributesWithoutAwtFont(new HashMap<Attribute, Object>(), font)); } else { // add underline and strikethrough attributes since these are set at // style/font level Map<Attribute, Object> attributes = new HashMap<Attribute, Object>(); if (font.isUnderline()) { attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); } if (font.isStrikeThrough()) { attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON); } if (!attributes.isEmpty()) { awtFont = awtFont.deriveFont(attributes); } } return awtFont; }
From source file:CircleOfSquares.java
ControlPanel() { setLayout(new BorderLayout(5, 5)); Panel leftButtonPanel = new Panel(); leftButtonPanel.setLayout(new GridLayout(2, 1, 0, 5)); leftButtonPanel.add(new GrayButton(StringTable.step)); resetButton.disable();/*from w w w . j a va 2s. c om*/ leftButtonPanel.add(resetButton); explanationLabel = new ColoredLabel("This is where the explanation goes...", Label.CENTER, Color.lightGray); explanationLabel.setBackground(ColorTable.explanationLabel); Font plainFont = new Font("TimesRoman", Font.ITALIC, 12); explanationLabel.setFont(plainFont); add("West", leftButtonPanel); add("Center", explanationLabel); }
From source file:org.deegree.graphics.charts.ChartsBuilder.java
/** * Finds the appropriate integer that represents either one of the following "PLAIN","BOLD" or "ITALIC" * * @param fontType/*w w w . j a va2 s .c om*/ * @return font type */ private int findFontType(String fontType) { if (fontType.toUpperCase().equals("ITALIC")) { return Font.ITALIC; } else if (fontType.toUpperCase().equals("BOLD")) { return Font.BOLD; } return Font.PLAIN; }
From source file:skoa.helpers.Graficos.java
private void barras() { unificarDatosFicheros();// w w w . j a va 2s . c o m Vector<String> vectorOrdenUnidades = new Vector<String>(); vectorOrdenUnidades = ordenDeUnidades(); aplicarDiferencia(vectorOrdenUnidades); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset = obtenerSerieBarras(vectorOrdenUnidades); String unidad = ""; //for (int i=0;i<vectorOrdenUnidades.size();i++) unidad=unidad+vectorOrdenUnidades.elementAt(i)+", "; for (int i = 0; i < vectorOrdenUnidades.size(); i++) { if (vectorOrdenUnidades.elementAt(i).indexOf("W") >= 0 || vectorOrdenUnidades.elementAt(i).indexOf("L") >= 0 || vectorOrdenUnidades.elementAt(i).indexOf("m") >= 0 || vectorOrdenUnidades.elementAt(i).indexOf("B") >= 0) unidad = unidad + vectorOrdenUnidades.elementAt(i) + ", "; else if (vectorOrdenUnidades.elementAt(i).indexOf("C") >= 0) unidad = unidad + "C, "; else unidad = unidad + ", "; } unidad = unidad.substring(0, unidad.length() - 2); //Quita el ultimo espacio y la ultima coma. JFreeChart grafica = ChartFactory.createBarChart("Valores medidos de las direcciones de grupo", "Fechas", //titulo eje x "Mediciones (" + unidad + ")", dataset, PlotOrientation.VERTICAL, true, //leyenda true, false); if (fechaInicial.isEmpty()) { fechaInicial = fechaFinal = "?"; } TextTitle t = new TextTitle("desde " + fechaInicial + " hasta " + fechaFinal, new Font("SanSerif", Font.ITALIC, 12)); grafica.addSubtitle(t); CategoryPlot plot = grafica.getCategoryPlot(); //Modificar eje X CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); domainAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 8)); //Letra de las fechas ms pequea //Esconder las sombras de las barras del barchart. CategoryPlot categoryPlot = (CategoryPlot) grafica.getPlot(); BarRenderer renderer = new BarRenderer(); renderer.setShadowVisible(false); categoryPlot.setRenderer(renderer); //------------------------------------------------- try { ChartUtilities.saveChartAsJPEG(new File(ruta + "BarrasSmall.jpg"), grafica, 400, 300); ChartUtilities.saveChartAsJPEG(new File(ruta + "BarrasBig.jpg"), grafica, 900, 600); } catch (IOException e) { System.err.println("Problem occurred creating chart."); } }
From source file:MainUI.java
public static JFreeChart createChart(CategoryDataset dataset) //? { JFreeChart chart = ChartFactory.createBarChart("hi", "", "?", dataset, PlotOrientation.VERTICAL, true, true, false); //JFreeChart chart.setTitle(new TextTitle("??", new Font("", Font.BOLD + Font.ITALIC, 20)));//???hi? CategoryPlot plot = (CategoryPlot) chart.getPlot();//?plot CategoryAxis categoryAxis = plot.getDomainAxis();//?? categoryAxis.setLabelFont(new Font("", Font.BOLD, 12));//?? return chart; }
From source file:org.simmi.GeneSetHead.java
License:asdf
public void repaintGCSkew(List<Sequence> selclist, Graphics2D g2, int size, GeneGroup gg, String selspec) { g2.setColor(Color.white);/* w ww . j a va 2s .com*/ g2.fillRect(0, 0, 1024, 1024); g2.setFont(g2.getFont().deriveFont(10.0f)); int total = 0; int g = 0; int c = 0; double gcstotal = 0.0; for (Sequence ctg : selclist) { //Sequence ctg = clist.get( u ); if (gg != null) { for (Tegeval tv : gg.getTegevals()) { if (tv.getContshort() == ctg) { int i = tv.start; int x1 = (int) (512.0 + (384.0 - 100.0) * Math.cos((i + total) * 2.0 * Math.PI / size)); int y1 = (int) (512.0 + (384.0 - 100.0) * Math.sin((i + total) * 2.0 * Math.PI / size)); int x2 = (int) (512.0 + (384.0 + 100.0) * Math.cos((i + total) * 2.0 * Math.PI / size)); int y2 = (int) (512.0 + (384.0 + 100.0) * Math.sin((i + total) * 2.0 * Math.PI / size)); g2.setColor(Color.green); g2.drawLine(x1, y1, x2, y2); } } } double horn = total * 2.0 * Math.PI / size; double horn2 = (total + ctg.length()) * 2.0 * Math.PI / size; int x1 = (int) (512.0 + (384.0 - 100.0) * Math.cos(horn)); int y1 = (int) (512.0 + (384.0 - 100.0) * Math.sin(horn)); int x2 = (int) (512.0 + (384.0 + 100.0) * Math.cos(horn)); int y2 = (int) (512.0 + (384.0 + 100.0) * Math.sin(horn)); g2.setColor(Color.black); g2.drawLine(x1, y1, x2, y2); int xoff = (int) (512.0 + (384.0 + 100.0) * Math.cos(horn2)); int yoff = (int) (512.0 + (384.0 + 100.0) * Math.sin(horn2)); if (horn < Math.PI) { g2.translate(x2, y2); g2.rotate(horn + Math.PI / 2.0); g2.drawString(ctg.getName(), 0, 0); g2.rotate(-horn - Math.PI / 2.0); g2.translate(-x2, -y2); } else { g2.translate(xoff, yoff); g2.rotate(horn2 + Math.PI / 2.0); g2.drawString(ctg.getName(), -g2.getFontMetrics().stringWidth(ctg.getName()), 0); g2.rotate(-horn2 - Math.PI / 2.0); g2.translate(-xoff, -yoff); } for (int i = 0; i < ctg.length(); i += 500) { for (int k = i; k < Math.min(ctg.length(), i + 500); k++) { char chr = ctg.charAt(k); if (chr == 'g' || chr == 'G') { g++; } else if (chr == 'c' || chr == 'C') { c++; } } int gcount = 0; int ccount = 0; int acount = 0; int tcount = 0; for (int k = i; k < Math.min(ctg.length(), i + 10000); k++) { char chr = k - 5000 < 0 ? ctg.charAt(ctg.length() + (k - 5000)) : ctg.charAt(k - 5000); if (chr == 'g' || chr == 'G') { gcount++; } else if (chr == 'c' || chr == 'C') { ccount++; } else if (chr == 'a' || chr == 'A') acount++; else if (chr == 't' || chr == 'T') tcount++; } if (gcount > 0 || ccount > 0) { double gcskew = (gcount - ccount) / (double) (gcount + ccount); gcstotal += gcskew; x1 = (int) (512.0 + (384.0) * Math.cos((i + total) * 2.0 * Math.PI / size)); y1 = (int) (512.0 + (384.0) * Math.sin((i + total) * 2.0 * Math.PI / size)); x2 = (int) (512.0 + (384.0 + gcskew * 100.0) * Math.cos((i + total) * 2.0 * Math.PI / size)); y2 = (int) (512.0 + (384.0 + gcskew * 100.0) * Math.sin((i + total) * 2.0 * Math.PI / size)); if (gcskew >= 0) g2.setColor(Color.blue); else g2.setColor(Color.red); g2.drawLine(x1, y1, x2, y2); } if (acount > 0 || tcount > 0) { double atskew = (acount - tcount) / (double) (acount + tcount); x1 = (int) (512.0 + (300.0) * Math.cos((i + total) * 2.0 * Math.PI / size)); y1 = (int) (512.0 + (300.0) * Math.sin((i + total) * 2.0 * Math.PI / size)); x2 = (int) (512.0 + (300.0 + atskew * 100.0) * Math.cos((i + total) * 2.0 * Math.PI / size)); y2 = (int) (512.0 + (300.0 + atskew * 100.0) * Math.sin((i + total) * 2.0 * Math.PI / size)); if (atskew >= 0) g2.setColor(Color.blue); else g2.setColor(Color.red); g2.drawLine(x1, y1, x2, y2); } } total += ctg.length(); } g2.setColor(Color.black); g2.setFont(g2.getFont().deriveFont(java.awt.Font.ITALIC).deriveFont(32.0f)); String[] specsplit; // = selspec.split("_"); if (selspec.contains("hermus")) specsplit = selspec.split("_"); else { Matcher m = Pattern.compile("\\d").matcher(selspec); int firstDigitLocation = m.find() ? m.start() : 0; if (firstDigitLocation == 0) specsplit = new String[] { "Thermus", selspec }; else specsplit = new String[] { "Thermus", selspec.substring(0, firstDigitLocation), selspec.substring(firstDigitLocation) }; } int k = 0; for (String spec : specsplit) { int strw = g2.getFontMetrics().stringWidth(spec); g2.drawString(spec, (1024 - strw) / 2, 1024 / 2 - specsplit.length * 32 / 2 + 32 + k * 32); k++; } /*double gcs = gcstotal/total; //(g-c)/(g+c); String gcstr = Double.toString( Math.round( gcs*1000000.0 ) ); g2.drawString( gcstr+"ppm", 768, 512 );*/ }
From source file:ro.nextreports.engine.exporter.ResultExporter.java
private void buildCellFont(Map<String, Object> format, Font font) { format.put(StyleFormatConstants.FONT_FAMILY_KEY, font.getFamily()); format.put(StyleFormatConstants.FONT_NAME_KEY, font.getName()); format.put(StyleFormatConstants.FONT_SIZE, new Float(font.getSize())); if (Font.PLAIN == font.getStyle()) { format.put(StyleFormatConstants.FONT_STYLE_KEY, StyleFormatConstants.FONT_STYLE_NORMAL); }/*from www . j ava 2 s .c o m*/ if (Font.BOLD == font.getStyle()) { format.put(StyleFormatConstants.FONT_STYLE_KEY, StyleFormatConstants.FONT_STYLE_BOLD); } if (Font.ITALIC == font.getStyle()) { format.put(StyleFormatConstants.FONT_STYLE_KEY, StyleFormatConstants.FONT_STYLE_ITALIC); } if ((Font.BOLD | Font.ITALIC) == font.getStyle()) { format.put(StyleFormatConstants.FONT_STYLE_KEY, StyleFormatConstants.FONT_STYLE_BOLDITALIC); } }