List of usage examples for java.awt Font getStyle
public int getStyle()
From source file:com.github.fritaly.dualcommander.Utils.java
public static Font getBoldFont(Font font) { Validate.notNull(font, "The given font is null"); return new Font(font.getName(), font.getStyle() | Font.BOLD, font.getSize()); }
From source file:com.diversityarrays.kdxplore.KDXplore.java
static public void setUIfontSize(float multiplier) { UIDefaults defaults = UIManager.getDefaults(); for (Enumeration<?> e = defaults.keys(); e.hasMoreElements();) { Object key = e.nextElement(); Object value = defaults.get(key); if (value instanceof Font) { Font font = (Font) value; int newSize = Math.round(font.getSize() * multiplier); if (value instanceof FontUIResource) { defaults.put(key, new FontUIResource(font.getName(), font.getStyle(), newSize)); } else { defaults.put(key, new Font(font.getName(), font.getStyle(), newSize)); }//from w w w . ja v a 2 s. co m } else if (value instanceof Integer) { if ("Tree.rowHeight".equals(key)) { //$NON-NLS-1$ // System.out.println(key+": "+value); Integer rh = (Integer) value; rh = (int) (rh * multiplier * 1.4); defaults.put(key, rh); } } } }
From source file:fxts.stations.util.UserPreferences.java
public static String getStringValue(Font aValue) { return clipFontFamily(aValue.getFamily()) + "," + aValue.getStyle() + "," + aValue.getSize(); }
From source file:com.rapidminer.gui.viewer.metadata.model.AbstractAttributeStatisticsModel.java
/** * Changes the font of {@link JFreeChart}s to Sans Serif. This method uses a * {@link StandardChartTheme} to do so, so any changes to the look of the chart must be done * after calling this method.// w w w .j a v a 2s . co m * * @param chart * the chart to change fonts for */ protected static void setDefaultChartFonts(JFreeChart chart) { final ChartTheme chartTheme = StandardChartTheme.createJFreeTheme(); if (StandardChartTheme.class.isAssignableFrom(chartTheme.getClass())) { StandardChartTheme standardTheme = (StandardChartTheme) chartTheme; // The default font used by JFreeChart cannot render japanese etc symbols final Font oldExtraLargeFont = standardTheme.getExtraLargeFont(); final Font oldLargeFont = standardTheme.getLargeFont(); final Font oldRegularFont = standardTheme.getRegularFont(); final Font oldSmallFont = standardTheme.getSmallFont(); final Font extraLargeFont = new Font(Font.SANS_SERIF, oldExtraLargeFont.getStyle(), oldExtraLargeFont.getSize()); final Font largeFont = new Font(Font.SANS_SERIF, oldLargeFont.getStyle(), oldLargeFont.getSize()); final Font regularFont = new Font(Font.SANS_SERIF, oldRegularFont.getStyle(), oldRegularFont.getSize()); final Font smallFont = new Font(Font.SANS_SERIF, oldSmallFont.getStyle(), oldSmallFont.getSize()); standardTheme.setExtraLargeFont(extraLargeFont); standardTheme.setLargeFont(largeFont); standardTheme.setRegularFont(regularFont); standardTheme.setSmallFont(smallFont); standardTheme.apply(chart); } }
From source file:org.yccheok.jstock.charting.Utils.java
/** * Applying chart theme based on given JFreeChart. * * @param chart the JFreeChart//from ww w .jav a 2 s. com */ public static void applyChartThemeEx(JFreeChart chart) { final StandardChartTheme chartTheme; final JStockOptions.ChartTheme theme = JStock.instance().getJStockOptions().getChartTheme(); if (theme == JStockOptions.ChartTheme.Light) { applyChartTheme(chart); return; } else { assert (theme == JStockOptions.ChartTheme.Dark); chartTheme = (StandardChartTheme) org.jfree.chart.StandardChartTheme.createDarknessTheme(); } // 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); } // Apply and return early. chartTheme.apply(chart); }
From source file:org.yccheok.jstock.charting.Utils.java
/** * Applying chart theme based on given JFreeChart. * * @param chart the JFreeChart//from w w w . ja v a2s . 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);// ww w . j a v a 2 s .c om }
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);// ww w . j a v a 2s .c o m }
From source file:net.sourceforge.atunes.kernel.modules.state.FontBean.java
/** * @param font/* w w w. j a v a 2 s .com*/ */ public FontBean(final Font font) { this.name = font.getName(); this.style = font.getStyle(); this.size = font.getSize(); }
From source file:org.fhcrc.cpl.toolbox.gui.chart.PanelWithPieChart.java
public void setLabelFontSize(int labelFontSize) { Font labelFont = ((PiePlot) getPlot()).getLabelFont(); Font newFont = new Font(labelFont.getName(), labelFont.getStyle(), labelFontSize); ((PiePlot) getPlot()).setLabelFont(newFont); }