List of usage examples for java.awt Font getSize
public int getSize()
From source file:org.yccheok.jstock.charting.Utils.java
/** * Applying chart theme based on given JFreeChart. * * @param chart the JFreeChart/* w w w . ja v a 2 s . c om*/ */ public static void applyChartTheme(JFreeChart chart) { final StandardChartTheme chartTheme = (StandardChartTheme) org.jfree.chart.StandardChartTheme .createJFreeTheme(); chartTheme.setXYBarPainter(barPainter); chartTheme.setShadowVisible(false); chartTheme.setPlotBackgroundPaint(Color.WHITE); chartTheme.setDomainGridlinePaint(Color.LIGHT_GRAY); chartTheme.setRangeGridlinePaint(Color.LIGHT_GRAY); chartTheme.setPlotOutlinePaint(Color.LIGHT_GRAY); // The default font used by JFreeChart unable to render Chinese properly. // We need to provide font which is able to support Chinese rendering. final Locale defaultLocale = Locale.getDefault(); if (org.yccheok.jstock.gui.Utils.isSimplifiedChinese(defaultLocale) || org.yccheok.jstock.gui.Utils.isTraditionalChinese(defaultLocale)) { final Font oldExtraLargeFont = chartTheme.getExtraLargeFont(); final Font oldLargeFont = chartTheme.getLargeFont(); final Font oldRegularFont = chartTheme.getRegularFont(); final Font oldSmallFont = chartTheme.getSmallFont(); final Font extraLargeFont = new Font("Sans-serif", oldExtraLargeFont.getStyle(), oldExtraLargeFont.getSize()); final Font largeFont = new Font("Sans-serif", oldLargeFont.getStyle(), oldLargeFont.getSize()); final Font regularFont = new Font("Sans-serif", oldRegularFont.getStyle(), oldRegularFont.getSize()); final Font smallFont = new Font("Sans-serif", oldSmallFont.getStyle(), oldSmallFont.getSize()); chartTheme.setExtraLargeFont(extraLargeFont); chartTheme.setLargeFont(largeFont); chartTheme.setRegularFont(regularFont); chartTheme.setSmallFont(smallFont); } if (chart.getPlot() instanceof CombinedDomainXYPlot) { @SuppressWarnings("unchecked") List<Plot> plots = ((CombinedDomainXYPlot) chart.getPlot()).getSubplots(); for (Plot plot : plots) { final int domainAxisCount = ((XYPlot) plot).getDomainAxisCount(); final int rangeAxisCount = ((XYPlot) plot).getRangeAxisCount(); for (int i = 0; i < domainAxisCount; i++) { ((XYPlot) plot).getDomainAxis(i).setAxisLinePaint(Color.LIGHT_GRAY); ((XYPlot) plot).getDomainAxis(i).setTickMarkPaint(Color.LIGHT_GRAY); } for (int i = 0; i < rangeAxisCount; i++) { ((XYPlot) plot).getRangeAxis(i).setAxisLinePaint(Color.LIGHT_GRAY); ((XYPlot) plot).getRangeAxis(i).setTickMarkPaint(Color.LIGHT_GRAY); } } } else { final Plot plot = chart.getPlot(); if (plot instanceof XYPlot) { final org.jfree.chart.plot.XYPlot xyPlot = (org.jfree.chart.plot.XYPlot) plot; final int domainAxisCount = xyPlot.getDomainAxisCount(); final int rangeAxisCount = xyPlot.getRangeAxisCount(); for (int i = 0; i < domainAxisCount; i++) { xyPlot.getDomainAxis(i).setAxisLinePaint(Color.LIGHT_GRAY); xyPlot.getDomainAxis(i).setTickMarkPaint(Color.LIGHT_GRAY); } for (int i = 0; i < rangeAxisCount; i++) { xyPlot.getRangeAxis(i).setAxisLinePaint(Color.LIGHT_GRAY); xyPlot.getRangeAxis(i).setTickMarkPaint(Color.LIGHT_GRAY); } } //else if (plot instanceof org.jfree.chart.plot.PiePlot) { // final org.jfree.chart.plot.PiePlot piePlot = (org.jfree.chart.plot.PiePlot)plot; // //} } chartTheme.apply(chart); }
From source file:Main.java
public void paint(Graphics g) { Font f = g.getFont(); int fontSize = f.getSize(); int fontStyle = f.getStyle(); String msg = ", Size: " + fontSize + ", Style: "; if ((fontStyle & Font.BOLD) == Font.BOLD) msg += "Bold "; if ((fontStyle & Font.ITALIC) == Font.ITALIC) msg += "Italic "; if ((fontStyle & Font.PLAIN) == Font.PLAIN) msg += "Plain "; g.drawString(msg, 4, 16);// www . j av a 2 s . c om }
From source file:processing.app.Theme.java
static public Font getFont(String attr) { Font font = PreferencesHelper.getFont(table, attr); if (font == null) { String value = getDefault(attr); set(attr, value);/*from ww w .ja v a 2 s .c o m*/ font = PreferencesHelper.getFont(table, attr); if (font == null) { return null; } } return font.deriveFont((float) scale(font.getSize())); }
From source file:Main.java
public void paint(Graphics g) { Font f = g.getFont(); String fontName = f.getName(); String fontFamily = f.getFamily(); int fontSize = f.getSize(); int fontStyle = f.getStyle(); String msg = "Family: " + fontName; msg += ", Font: " + fontFamily; msg += ", Size: " + fontSize + ", Style: "; if ((fontStyle & Font.BOLD) == Font.BOLD) msg += "Bold "; if ((fontStyle & Font.ITALIC) == Font.ITALIC) msg += "Italic "; if ((fontStyle & Font.PLAIN) == Font.PLAIN) msg += "Plain "; g.drawString(msg, 4, 16);//from ww w . ja va 2s. com }
From source file:util.ui.UiUtilities.java
/** * Creates a Html EditorPane that holds a HTML-Help Text. * * Add a Listener if you want to have clickable Links * * @param html//from www . j av a 2s . c o m * HTML-Text to display * @param listener * Link-Listener for this HelpText * @param background The color for the background. * @return EditorPane that holds a Help Text * @since 2.7.2 */ public static JEditorPane createHtmlHelpTextArea(String html, HyperlinkListener listener, Color background) { // Quick "hack". Remove HTML-Code and replace it with Code that includes the // correct Font if (html.indexOf("<html>") >= 0) { html = StringUtils.substringBetween(html, "<html>", "</html>"); } JLabel label = new JLabel(); Font font = label.getFont(); html = "<html><div style=\"color:" + UiUtilities.getHTMLColorCode(label.getForeground()) + ";font-family:" + font.getName() + "; font-size:" + font.getSize() + ";background-color:rgb(" + background.getRed() + "," + background.getGreen() + "," + background.getBlue() + ");\">" + html + "</div></html>"; final JEditorPane pane = new JEditorPane("text/html", html); pane.setBorder(BorderFactory.createEmptyBorder()); pane.setEditable(false); pane.setFont(font); pane.setOpaque(false); pane.setFocusable(false); if (listener != null) { pane.addHyperlinkListener(listener); } return pane; }
From source file:processing.app.Theme.java
public static Map<String, Object> getStyledFont(String what, Font font) { String split[] = get("editor." + what + ".style").split(","); Color color = PreferencesHelper.parseColor(split[0]); String style = split[1];/*from ww w .ja v a2s. c o m*/ boolean bold = style.contains("bold"); boolean italic = style.contains("italic"); boolean underlined = style.contains("underlined"); Font styledFont = new Font(font.getFamily(), (bold ? Font.BOLD : 0) | (italic ? Font.ITALIC : 0), font.getSize()); if (underlined) { Map<TextAttribute, Object> attr = new Hashtable<>(); attr.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); styledFont = styledFont.deriveFont(attr); } Map<String, Object> result = new HashMap<>(); result.put("color", color); result.put("font", styledFont); return result; }
From source file:net.sourceforge.atunes.kernel.modules.state.FontBean.java
/** * @param font// w w w . j av a2 s. c o m */ public FontBean(final Font font) { this.name = font.getName(); this.style = font.getStyle(); this.size = font.getSize(); }
From source file:uk.ac.ed.epcc.webapp.charts.jfreechart.JFreeBarTimeChartData.java
@Override public JFreeChart getJFreeChart() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); double counts[] = ds.getCounts(); String legends[] = ds.getLegends(); int max_len = 0; for (int i = 0; i < ds.getNumSets(); i++) { if (legends != null && legends.length > i) { dataset.addValue(new Double(counts[i]), "Series-1", legends[i]); int leg_len = legends[i].length(); if (leg_len > max_len) { max_len = leg_len;/*from w w w . ja v a 2s . com*/ } //System.out.println(legends[i] + counts[i]); } else { dataset.addValue(new Double(counts[i]), "Series-1", Integer.toString(i)); } } CategoryDataset data = dataset; JFreeChart chart = ChartFactory.createBarChart(title, null, quantity, data, PlotOrientation.VERTICAL, false, // include legends false, // tooltips false // urls ); CategoryPlot categoryPlot = chart.getCategoryPlot(); CategoryAxis axis = categoryPlot.getDomainAxis(); if (max_len > 8 || ds.getNumSets() > 16 || (max_len * ds.getNumSets()) > 50) { axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); } Font tickLabelFont = axis.getTickLabelFont(); if (ds.getNumSets() > 24) { axis.setTickLabelFont(tickLabelFont.deriveFont(tickLabelFont.getSize() - 2.0F)); } Font labelFont = axis.getLabelFont(); axis.setMaximumCategoryLabelLines(3); //axis.setLabelFont(labelFont.d); // axis.setLabel("Pingu"); This works so we can modify return chart; }
From source file:be.tutul.naheulcraft.launcher.auth.LogInForm.java
private void createInterface() { setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = 2;//from w w w. j av a2s . c o m constraints.gridx = 0; constraints.gridy = -1; constraints.weightx = 1.0D; add(Box.createGlue()); JLabel usernameLabel = new JLabel("Pseudo : "); Font labelFont = usernameLabel.getFont().deriveFont(1); Font smalltextFont = usernameLabel.getFont().deriveFont(labelFont.getSize() - 2.0F); usernameLabel.setFont(labelFont); add(usernameLabel, constraints); add(this.usernameField, constraints); add(Box.createVerticalStrut(10), constraints); JLabel passwordLabel = new JLabel("Mot de passe :"); passwordLabel.setFont(labelFont); add(passwordLabel, constraints); add(this.passwordField, constraints); JLabel forgotPasswordLabel = new JLabel("(oubli ?)"); forgotPasswordLabel.setCursor(new Cursor(12)); forgotPasswordLabel.setFont(smalltextFont); forgotPasswordLabel.setHorizontalAlignment(4); forgotPasswordLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { try { Util.openLink(Variables.lost); } catch (Exception e1) { LogInForm.this.login.getLauncher().getLogger() .error("Impossible d'ouvrir le lien pour les logins oublis"); JOptionPane.showMessageDialog(LogInForm.this.login.getLauncher().getPanel(), "Impossible d'ouvrir la page\nRendez-vous sur le site de NaheulCraft pour rcuprer vos identifiants", "Impossible d'ouvrir l'URL", 0); } } }); add(forgotPasswordLabel, constraints); createUserDropdownPanel(labelFont); add(this.userDropdownPanel, constraints); add(Box.createVerticalStrut(10), constraints); }
From source file:com.codedx.burp.security.InvalidCertificateDialogStrategy.java
@Override public CertificateAcceptance checkAcceptance(Certificate genericCert, CertificateException certError) { if (genericCert instanceof X509Certificate && defaultHostVerifier instanceof DefaultHostnameVerifier) { X509Certificate cert = (X509Certificate) genericCert; DefaultHostnameVerifier verifier = (DefaultHostnameVerifier) defaultHostVerifier; JPanel message = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = 2;//from w w w .j a va2 s . c om gbc.insets = new Insets(0, 0, 10, 0); gbc.anchor = GridBagConstraints.WEST; message.add( new JLabel("Unable to establish a secure connection because the certificate is not trusted"), gbc); gbc = new GridBagConstraints(); gbc.gridy = 2; gbc.insets = new Insets(2, 0, 2, 0); gbc.anchor = GridBagConstraints.WEST; JLabel issuer = new JLabel("Issuer: "); Font defaultFont = issuer.getFont(); Font bold = new Font(defaultFont.getName(), Font.BOLD, defaultFont.getSize()); issuer.setFont(bold); message.add(issuer, gbc); gbc.gridx = 1; message.add(new JLabel(cert.getIssuerDN().toString()), gbc); try { JLabel fingerprint = new JLabel("Thumbprint: "); fingerprint.setFont(bold); gbc.gridx = 0; gbc.gridy += 1; message.add(fingerprint, gbc); gbc.gridx = 1; message.add(new JLabel(toHexString(getSHA1(cert.getEncoded()), " ")), gbc); } catch (CertificateEncodingException e) { // this shouldn't actually ever happen } try { verifier.verify(host, cert); } catch (SSLException e) { String cn = getCN(cert); JLabel mismatch = new JLabel("Host Mismatch: "); mismatch.setFont(bold); gbc.gridx = 0; gbc.gridy += 1; message.add(mismatch, gbc); String msg; if (cn != null) { msg = String.format("Expected '%s', but the certificate is for '%s'.", host, cn); } else { msg = e.getMessage(); } gbc.gridx = 1; message.add(new JLabel(msg), gbc); } // Open the dialog, and return its result int choice = JOptionPane.showOptionDialog(burpExtender.getUiComponent(), message, dialogTitle, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, dialogButtons, null); switch (choice) { case (0): return CertificateAcceptance.REJECT; case (1): return CertificateAcceptance.ACCEPT_TEMPORARILY; case (2): return CertificateAcceptance.ACCEPT_PERMANENTLY; } } return CertificateAcceptance.REJECT; }