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.flexoodb.common.FlexUtils.java
static public BufferedImage createCaptcha(String text, Color background, Color fontcolor, int fontsize, int width, int height, int x, int y) throws Exception { BufferedImage img = new BufferedImage(width + 10, height, BufferedImage.TYPE_INT_RGB); img.createGraphics();/* w w w. j a va2 s.c o m*/ Graphics2D g = (Graphics2D) img.getGraphics(); g.setColor(background); g.fillRect(0, 0, img.getWidth(), img.getHeight()); Font font = new Font("Monospaced", Font.BOLD + Font.ITALIC, fontsize); g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); g.setFont(font); g.setColor(fontcolor); char[] c = text.toCharArray(); java.util.Random random = new java.util.Random(); for (int i = 0; i < c.length; i++) { int j = random.nextInt(9); if (j > 5) { j = j - 5; } else { j = -1 * (j - 2); } char[] c1 = new char[1]; c1[0] = c[i]; g.drawChars(c1, 0, 1, x + (i * 16), y + j); } for (int i = -10; i < 20; i++) { int j = random.nextInt(8); g.drawOval((i + j) - 20, ((i * 8) - (j > 3 ? 4 : -4)), width + 20, height); } //ImageIO.write(img,"png",new File(outputfile)); return img; }
From source file:lu.fisch.unimozer.Diagram.java
private void printHeaderFooter(Graphics g, PageFormat pageFormat, int page, String className) { int origPage = page + 1; // Add header g.setColor(Color.BLACK);/*w w w . jav a2s . c o m*/ int xOffset = (int) pageFormat.getImageableX(); int topOffset = (int) pageFormat.getImageableY() + 20; int bottom = (int) (pageFormat.getImageableY() + pageFormat.getImageableHeight()); // header line g.drawLine(xOffset, topOffset - 8, xOffset + (int) pageFormat.getImageableWidth(), topOffset - 8); // footer line g.drawLine(xOffset, bottom - 11, xOffset + (int) pageFormat.getImageableWidth(), bottom - 11); g.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 10)); Graphics2D gg = (Graphics2D) g; String pageString = "Page " + origPage; int tw = (int) gg.getFont().getStringBounds(pageString, gg.getFontRenderContext()).getWidth(); // footer text g.drawString(pageString, xOffset + (int) pageFormat.getImageableWidth() - tw, bottom - 2); //System.err.println("Printing: "+directoryName); if (directoryName != null) { g.setFont(new Font(g.getFont().getFontName(), Font.ITALIC, 10)); String filename = directoryName; if (!className.equals("")) filename += System.getProperty("file.separator") + className + ".java"; // header text g.drawString(filename, xOffset, bottom - 2); File f = new File(filename); //System.err.println("Printing: "+filename); if (f.exists()) { DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); java.util.Date date = new java.util.Date(); date.setTime(f.lastModified()); String myDate = dateFormat.format(date); int w = (int) gg.getFont().getStringBounds(myDate, gg.getFontRenderContext()).getWidth(); // header text g.drawString("File last modified on " + myDate, xOffset, topOffset - 10); } } }