List of usage examples for java.awt Font deriveFont
public Font deriveFont(int style, AffineTransform trans)
From source file:Main.java
public static void main(String[] args) throws Exception { String fontFileName = "yourfont.ttf"; InputStream is = new FileInputStream(fontFileName); Font ttfBase = Font.createFont(Font.TRUETYPE_FONT, is); Font ttfReal = ttfBase.deriveFont(Font.PLAIN, 24); }
From source file:Main.java
public static void main(String[] args) throws Exception { String fontFileName = "yourfont.ttf"; InputStream is = new FileInputStream(fontFileName); Font ttfBase = Font.createFont(Font.TRUETYPE_FONT, is); Font ttfReal = ttfBase.deriveFont(Font.BOLD, AffineTransform.getRotateInstance(0.5)); }
From source file:Main.java
public static JLabel modifyLabelFont(JLabel label, int style, int delta) { Font font = label.getFont(); label.setFont(font.deriveFont(style, font.getSize() + delta)); label.setForeground(new Color(140, 140, 140)); return label; }
From source file:com.moneydance.modules.features.importlist.util.Preferences.java
public static Font getHeaderFont() { final Font baseFont = UIManager.getFont("Label.font"); return baseFont.deriveFont(Font.PLAIN, baseFont.getSize2D() + 2.0F); }
From source file:MainClass.java
public void loadFont() throws FontFormatException, IOException { String fontFileName = "yourfont.ttf"; InputStream is = this.getClass().getResourceAsStream(fontFileName); Font ttfBase = Font.createFont(Font.TRUETYPE_FONT, is); Font ttfReal = ttfBase.deriveFont(Font.PLAIN, 24); }
From source file:jmemorize.gui.swing.panels.CardCounterPanel.java
private void setupPieLegend(JFreeChart chart) { LegendTitle legend = chart.getLegend(); Font legendFont = legend.getItemFont(); legend.setItemFont(legendFont.deriveFont(Font.BOLD, 20)); }
From source file:nu.nethome.home.items.web.GraphServlet.java
/** * This is the main enterence point of the class. This is called when a http request is * routed to this servlet./*from ww w . java 2 s. co m*/ */ public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { ServletOutputStream p = res.getOutputStream(); Date startTime = null; Date stopTime = null; // Analyse arguments String fileName = req.getParameter("file"); if (fileName != null) fileName = getFullFileName(fromURL(fileName)); String startTimeString = req.getParameter("start"); String stopTimeString = req.getParameter("stop"); try { if (startTimeString != null) { startTime = m_Format.parse(startTimeString); } if (stopTimeString != null) { stopTime = m_Format.parse(stopTimeString); } } catch (ParseException e1) { e1.printStackTrace(); } String look = req.getParameter("look"); if (look == null) look = ""; TimeSeries timeSeries = new TimeSeries("Data", Minute.class); // Calculate time window Calendar cal = Calendar.getInstance(); Date currentTime = cal.getTime(); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); Date startOfDay = cal.getTime(); cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); Date startOfWeek = cal.getTime(); cal.set(Calendar.DAY_OF_MONTH, 1); Date startOfMonth = cal.getTime(); cal.set(Calendar.MONTH, Calendar.JANUARY); Date startOfYear = cal.getTime(); // if (startTime == null) startTime = startOfWeek; if (stopTime == null) stopTime = currentTime; if (startTime == null) startTime = new Date(stopTime.getTime() - 1000L * 60L * 60L * 24L * 2L); try { // Open the data file File logFile = new File(fileName); Scanner fileScanner = new Scanner(logFile); Long startTimeMs = startTime.getTime(); Long month = 1000L * 60L * 60L * 24L * 30L; boolean doOptimize = true; boolean justOptimized = false; try { while (fileScanner.hasNext()) { try { // Get next log entry String line = fileScanner.nextLine(); if (line.length() > 21) { // Adapt the time format String minuteTime = line.substring(0, 16).replace('.', '-'); // Parse the time stamp Minute min = Minute.parseMinute(minuteTime); // Ok, this is an ugly optimization. If the current time position in the file // is more than a month (30 days) ahead of the start of the time window, we // quick read two weeks worth of data, assuming that there is 4 samples per hour. // This may lead to scanning past start of window if there are holes in the data // series. if (doOptimize && ((startTimeMs - min.getFirstMillisecond()) > month)) { for (int i = 0; (i < (24 * 4 * 14)) && fileScanner.hasNext(); i++) { fileScanner.nextLine(); } justOptimized = true; continue; } // Detect if we have scanned past the window start position just after an optimization scan. // If this is the case it may be because of the optimization. In that case we have to switch // optimization off and start over. if ((min.getFirstMillisecond() > startTimeMs) && doOptimize && justOptimized) { logFile = new File(fileName); fileScanner = new Scanner(logFile); doOptimize = false; continue; } justOptimized = false; // Check if value is within time window if ((min.getFirstMillisecond() > startTimeMs) && (min.getFirstMillisecond() < stopTime.getTime())) { // Parse the value double value = Double.parseDouble((line.substring(20)).replace(',', '.')); // Add the entry timeSeries.add(min, value); doOptimize = false; } } } catch (SeriesException se) { // Bad entry, for example due to duplicates at daylight saving time switch } catch (NumberFormatException nfe) { // Bad number format in a line, try to continue } } } catch (Exception e) { System.out.println(e.toString()); } finally { fileScanner.close(); } } catch (FileNotFoundException f) { System.out.println(f.toString()); } // Create a collection for plotting TimeSeriesCollection data = new TimeSeriesCollection(); data.addSeries(timeSeries); JFreeChart chart; int xSize = 750; int ySize = 450; // Customize colors and look of the Graph. if (look.equals("mobtemp")) { // Look for the mobile GUI chart = ChartFactory.createTimeSeriesChart(null, null, null, data, false, false, false); XYPlot plot = chart.getXYPlot(); ValueAxis timeAxis = plot.getDomainAxis(); timeAxis.setAxisLineVisible(false); ValueAxis valueAxis = plot.getRangeAxis(0); valueAxis.setAxisLineVisible(false); xSize = 175; ySize = 180; } else { // Create a Chart with time range as heading SimpleDateFormat localFormat = new SimpleDateFormat(); String heading = localFormat.format(startTime) + " - " + localFormat.format(stopTime); chart = ChartFactory.createTimeSeriesChart(heading, null, null, data, false, false, false); Paint background = new Color(0x9D8140); chart.setBackgroundPaint(background); TextTitle title = chart.getTitle(); // fix title Font titleFont = title.getFont(); titleFont = titleFont.deriveFont(Font.PLAIN, (float) 14.0); title.setFont(titleFont); title.setPaint(Color.darkGray); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(background); plot.setDomainGridlinePaint(Color.darkGray); ValueAxis timeAxis = plot.getDomainAxis(); timeAxis.setAxisLineVisible(false); ValueAxis valueAxis = plot.getRangeAxis(0); valueAxis.setAxisLineVisible(false); plot.setRangeGridlinePaint(Color.darkGray); XYItemRenderer renderer = plot.getRenderer(0); renderer.setSeriesPaint(0, Color.darkGray); xSize = 750; ySize = 450; } try { res.setContentType("image/png"); res.setHeader("Cache-Control", "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); res.setHeader("Pragma", "no-cache"); res.setStatus(HttpServletResponse.SC_OK); ChartUtilities.writeChartAsPNG(p, chart, xSize, ySize); } catch (IOException e) { System.err.println("Problem occurred creating chart."); } p.flush(); p.close(); return; }
From source file:daylightchart.daylightchart.chart.DaylightChart.java
/** * {@inheritDoc}/*from ww w . ja v a 2 s.c o m*/ * * @see daylightchart.options.chart.ChartOptionsListener#afterSettingChartOptions(ChartOptions) */ @Override public void afterSettingChartOptions(final ChartOptions chartOptions) { Font titleFont; final TextTitle title = getTitle(); if (title != null) { titleFont = title.getFont(); } else { titleFont = ChartConfiguration.chartFont; } createTitles(chartOptions, titleFont.deriveFont(Font.BOLD, 18)); }
From source file:com.willwinder.universalgcodesender.uielements.panels.MachineStatusPanel.java
private void applyFont() { String fontPath = "/resources/"; String fontName = "LED.ttf"; InputStream is = getClass().getResourceAsStream(fontPath + fontName); Font font; Font big, small;/*from www.j a v a2 s . com*/ try { font = Font.createFont(Font.TRUETYPE_FONT, is); big = font.deriveFont(Font.PLAIN, 30); small = font.deriveFont(Font.PLAIN, 18); } catch (Exception ex) { ex.printStackTrace(); System.err.println(fontName + " not loaded. Using serif font."); big = new Font("serif", Font.PLAIN, 24); small = new Font("serif", Font.PLAIN, 17); } GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); ge.registerFont(big); ge.registerFont(small); this.machinePositionXValue.setFont(small); this.machinePositionXValue.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); this.machinePositionYValue.setFont(small); this.machinePositionYValue.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); this.machinePositionZValue.setFont(small); this.machinePositionZValue.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); this.workPositionXValue.setFont(big); this.workPositionXValue.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); this.workPositionYValue.setFont(big); this.workPositionYValue.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); this.workPositionZValue.setFont(big); this.workPositionZValue.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); }
From source file:org.openmicroscopy.shoola.agents.util.ui.ScriptComponent.java
/** * Sets the text explaining the component when the component is a list * or a map.//from w w w . ja v a 2 s . com * * @param text The value to set. */ void setInfo(String text) { if (StringUtils.isBlank(text)) return; info = new JLabel(); Font f = info.getFont(); info.setFont(f.deriveFont(Font.ITALIC, f.getSize() - 2)); }