List of usage examples for java.awt Font TRUETYPE_FONT
int TRUETYPE_FONT
To view the source code for java.awt Font TRUETYPE_FONT.
Click Source Link
From source file:qic.ui.GuildPanel.java
public GuildPanel() { super(new BorderLayout(1, 1)); textArea.setFont(new Font("Consolas", Font.TRUETYPE_FONT, 12)); add(new JScrollPane(textArea), BorderLayout.CENTER); JPanel southPanel = new JPanel(); JButton guildBtn = new JButton("Append with Guildmates"); JButton saveBtn = new JButton("Save"); JTextField guildUrl = new JTextField(50); // https://www.pathofexile.com/guild/profile/162231 southPanel.add(new JLabel("Guild Profile No./Url")); southPanel.add(guildUrl);//from w w w. j a v a 2s . co m southPanel.add(guildBtn); southPanel.add(new JLabel("Discount: " + Config.getPropety(Config.GUILD_DISCOUNT_STRING, Config.GUILD_DISCOUNT_STRING_DEFAULT))); add(southPanel, BorderLayout.SOUTH); southPanel.add(saveBtn); loadConfigToTextArea(); guildBtn.addActionListener(e -> { String url = guildUrl.getText(); if (!url.isEmpty()) { Worker<List<String>> worker = new Worker<List<String>>(() -> { List<String> members = Collections.emptyList(); String urlFinal = StringUtils.isNumeric(url) ? "https://www.pathofexile.com/guild/profile/" + url : url; try { members = GuildPageScraper.scrapeMembers(urlFinal); } catch (Exception ex) { logger.error("Error while scraping guild page: " + urlFinal); showError(ex); } return members; }, guildNames -> { if (!guildNames.isEmpty()) { guildNames.stream().forEach(name -> { String ls = textArea.getText().isEmpty() ? "" : System.lineSeparator(); textArea.append(ls + name); }); } }); worker.execute(); } }); saveBtn.addActionListener(e -> save()); }
From source file:net.team2xh.crt.gui.util.GUIToolkit.java
/** * Register a local font to the graphical environment. * * After registering a font, its font family can be used normally as if * the font was installed on the OS.//from ww w . j a va 2 s . co m * * @param caller Caller instance for resource aquisition * @param path Font file path */ public static void registerFont(Object caller, String path) { try { URI uri = caller.getClass().getResource(path).toURI(); File fontFile = new File(uri); Font font = Font.createFont(Font.TRUETYPE_FONT, fontFile); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); ge.registerFont(font); } catch (FontFormatException | IOException | URISyntaxException e) { System.out.println(e.getMessage()); } }
From source file:sagan.projects.support.VersionBadgeService.java
@PostConstruct public void postConstruct() throws Exception { Font font;/*from w ww .j a v a2s .c o m*/ try (InputStream is = VERDANA_FONT.openStream()) { font = Font.createFont(Font.TRUETYPE_FONT, is).deriveFont(0, 11); } graphics = DUMMY.getGraphics(); graphics.setFont(font); DefaultXMLFactoriesConfig myConfig = new DefaultXMLFactoriesConfig(); myConfig.setNamespacePhilosophy(NamespacePhilosophy.NIHILISTIC); xbProjector = new XBProjector(myConfig, Flags.TO_STRING_RENDERS_XML); }
From source file:org.apache.pdfbox.pdmodel.font.PDCIDFontType2Font.java
/** * {@inheritDoc}/*from ww w . ja v a 2 s. com*/ */ public Font getawtFont() throws IOException { Font awtFont = null; PDFontDescriptorDictionary fd = (PDFontDescriptorDictionary) getFontDescriptor(); PDStream ff2Stream = fd.getFontFile2(); if (ff2Stream != null) { try { // create a font with the embedded data awtFont = Font.createFont(Font.TRUETYPE_FONT, ff2Stream.createInputStream()); } catch (FontFormatException f) { LOG.info("Can't read the embedded font " + fd.getFontName()); } if (awtFont == null) { awtFont = FontManager.getAwtFont(fd.getFontName()); if (awtFont != null) { LOG.info("Using font " + awtFont.getName() + " instead"); } setIsFontSubstituted(true); } } // TODO FontFile3 return awtFont; }
From source file:org.rockyroadshub.planner.core.utils.Utilities.java
/** * /*from ww w .j a v a 2 s. c om*/ * @param jarPath * @return * @throws IOException * @throws FontFormatException */ @LogExceptions public static Font getFont(String jarPath) throws IOException, FontFormatException { try (InputStream in = Utilities.class.getResourceAsStream(jarPath)) { return Font.createFont(Font.TRUETYPE_FONT, in); } }
From source file:org.shredzone.commons.captcha.impl.DefaultCaptchaGenerator.java
/** * Sets up the captcha generator.//from w w w. j a va 2 s.com */ @PostConstruct public void setup() { if (width <= 0 || height <= 0) { throw new IllegalStateException("Captcha size is not set"); } if (fontPath == null) { throw new IllegalStateException("Font is not set"); } try (InputStream fontStream = DefaultCaptchaGenerator.class.getResourceAsStream(fontPath)) { font = Font.createFont(Font.TRUETYPE_FONT, fontStream); } catch (Exception ex) { LOG.error("Could not open font " + fontPath, ex); throw new IllegalStateException(); } }
From source file:CheckFonts.java
protected static Font getDialogFont(ResourceDialog dialog) throws Exception { Font r = FONTS.get(dialog.typeface); if (r == null) { r = Font.createFont(Font.TRUETYPE_FONT, new File("fonts/" + dialog.typeface.replace(' ', '_') + ".ttf")); FONTS.put(dialog.typeface, r);//from w w w. ja v a2 s .c o m } return r; }
From source file:net.technicpack.ui.lang.ResourceLoader.java
public Font getFontByName(String fontName) { Font font;// w w w .j av a 2 s.c om if (fontCache.containsKey(fontName)) return fontCache.get(fontName); if (launcherAssets == null) return fallbackFont; InputStream fontStream = null; try { String fullName = getString(fontName); fontStream = FileUtils.openInputStream(new File(launcherAssets, fullName)); if (fontStream == null) return fallbackFont; font = Font.createFont(Font.TRUETYPE_FONT, fontStream); GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment(); genv.registerFont(font); } catch (Exception e) { e.printStackTrace(); // Fallback return fallbackFont; } finally { if (fontStream != null) IOUtils.closeQuietly(fontStream); } fontCache.put(fontName, font); if (font == null) return fallbackFont; return font; }
From source file:qic.ui.EditorPanel.java
private void setupTextArea() { textArea = new RSyntaxTextArea(20, 60); textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT); textArea.setCodeFoldingEnabled(true); textArea.setFont(new Font("Consolas", Font.TRUETYPE_FONT, 12)); add(new RTextScrollPane(textArea), BorderLayout.CENTER); }
From source file:com.netsteadfast.greenstep.action.CommonPieChartAction.java
private void fillChart(String title, List<String> names, List<String> colors, List<Float> values) throws Exception { DefaultPieDataset data = new DefaultPieDataset(); for (int ix = 0; ix < names.size(); ix++) { data.setValue(names.get(ix), values.get(ix)); }//from w w w . j ava 2 s .c o m this.chart = ChartFactory.createPieChart3D(title, data, true, true, false); LegendTitle legend = this.chart.getLegend(); legend.setItemFont(new Font("", Font.TRUETYPE_FONT, 9)); PiePlot plot = (PiePlot) this.chart.getPlot(); plot.setCircular(true); plot.setBackgroundAlpha(0.9f); plot.setForegroundAlpha(0.5f); plot.setLabelFont(new Font("", Font.TRUETYPE_FONT, 9)); this.setPlotColor(plot, names, colors); this.chart.setTitle(new TextTitle(title, new Font("", Font.TRUETYPE_FONT, 9))); }