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:irille.pub.verify.RandomImageServlet.java
/** * ???,,?16,/*from w w w .j av a2s .c o m*/ * @param num ?? * @param out ? * @throws IOException */ protected static void render(String num, boolean gif, OutputStream out) throws IOException { if (num.getBytes().length > 4) throw new IllegalArgumentException("The length of param num cannot exceed 4."); int width = 50; int height = 18; BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D g = (Graphics2D) bi.getGraphics(); g.setColor(Color.WHITE); g.fillRect(0, 0, width, height); Font mFont = new Font("Tahoma", Font.BOLD | Font.ITALIC, 16); g.setFont(mFont); g.setColor(Color.BLACK); g.drawString(num, 2, 15); if (gif) { AnimatedGifEncoder e = new AnimatedGifEncoder(); e.setTransparent(Color.WHITE); e.start(out); e.setDelay(0); e.addFrame(bi); e.finish(); } else { ImageIO.write(bi, "png", out); } }
From source file:Main.java
public ListRenderingFrame() { setTitle("ListRendering"); setSize(400, 300);/*from ww w .ja va 2 s .c o m*/ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); Vector fonts = new Vector(); fonts.add(new Font("Serif", Font.PLAIN, 8)); fonts.add(new Font("SansSerif", Font.BOLD, 12)); fonts.add(new Font("Monospaced", Font.PLAIN, 16)); fonts.add(new Font("Dialog", Font.ITALIC, 12)); fonts.add(new Font("DialogInput", Font.PLAIN, 12)); JList fontList = new JList(fonts); fontList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); fontList.setCellRenderer(new FontCellRenderer()); JScrollPane scrollPane = new JScrollPane(fontList); JPanel p = new JPanel(); p.add(scrollPane); fontList.addListSelectionListener(this); getContentPane().add(p, "Center"); getContentPane().add(label, "South"); }
From source file:jmbench.plots.SummaryWhiskerPlot.java
public JFreeChart createChart() { JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(title, "Matrix Libraries", "Relative Performance", dataSet, true);// w w w. jav a2s . c o m CategoryPlot plot = chart.getCategoryPlot(); plot.setDomainGridlinesVisible(true); plot.setBackgroundPaint(new Color(230, 230, 230)); plot.setDomainGridlinePaint(new Color(50, 50, 50, 50)); plot.setDomainGridlineStroke(new BasicStroke(78f)); chart.getTitle().setFont(new Font("Times New Roman", Font.BOLD, 24)); String foo = "( Higher is Better )"; if (subtitle != null) foo += " ( " + subtitle + " )"; chart.addSubtitle(new TextTitle(foo, new Font("SansSerif", Font.ITALIC, 12))); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:components.SplitPaneDemo.java
public SplitPaneDemo() { //Create the list of images and put it in a scroll pane. list = new JList(imageNames); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0);// w ww .ja va 2 s.c o m list.addListSelectionListener(this); JScrollPane listScrollPane = new JScrollPane(list); picture = new JLabel(); picture.setFont(picture.getFont().deriveFont(Font.ITALIC)); picture.setHorizontalAlignment(JLabel.CENTER); JScrollPane pictureScrollPane = new JScrollPane(picture); //Create a split pane with the two scroll panes in it. splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, listScrollPane, pictureScrollPane); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(150); //Provide minimum sizes for the two components in the split pane. Dimension minimumSize = new Dimension(100, 50); listScrollPane.setMinimumSize(minimumSize); pictureScrollPane.setMinimumSize(minimumSize); //Provide a preferred size for the split pane. splitPane.setPreferredSize(new Dimension(400, 200)); updateLabel(imageNames[list.getSelectedIndex()]); }
From source file:org.eclipse.wb.internal.swing.model.property.editor.font.DerivedFontInfo.java
public DerivedFontInfo(Font baseFont, String baseFontSource, String baseFontClipboardSource, String newFamily, Boolean newBold, Boolean newItalic, Integer deltaSize, Integer newSize) { m_baseFont = baseFont;// ww w . j a v a 2 s. c o m m_baseFontSource = baseFontSource; m_baseFontClipboardSource = baseFontClipboardSource; m_newFamily = newFamily; m_newBold = newBold; m_newItalic = newItalic; m_deltaSize = deltaSize; m_newSize = newSize; // create derived Font { String family = newFamily != null ? newFamily : baseFont.getFamily(); // style int style = baseFont.getStyle(); if (newBold != null) { if (newBold.booleanValue()) { style |= Font.BOLD; } else { style &= ~Font.BOLD; } } if (newItalic != null) { if (newItalic.booleanValue()) { style |= Font.ITALIC; } else { style &= ~Font.ITALIC; } } // size int size = baseFont.getSize(); if (deltaSize != null) { size += deltaSize.intValue(); } else if (newSize != null) { size = newSize.intValue(); } // create derived Font m_font = new Font(family, style, size); } }
From source file:com.lixiaocong.service.ImageCodeService.java
public BufferedImage getImage(HttpSession session) { //background/*w w w. j ava 2 s .c o m*/ BufferedImage bi = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB); Graphics graphics = bi.getGraphics(); graphics.setColor(randomColor()); graphics.fillRect(0, 0, WIDTH, HEIGHT); //content StringBuilder sb = new StringBuilder(); int len = ch.length; Random random = new Random(); for (int i = 0; i < 4; i++) { int index = random.nextInt(len); graphics.setColor(randomColor()); graphics.setFont(new Font(null, Font.BOLD + Font.ITALIC, 30)); graphics.drawString(ch[index] + "", i * 15 + 5, 25); sb.append(ch[index]); } session.setAttribute("imagecode", sb.toString()); //lines for (int i = 0; i < 4; i++) { graphics.setColor(randomColor()); graphics.drawLine(random.nextInt(WIDTH), random.nextInt(HEIGHT), random.nextInt(WIDTH), random.nextInt(HEIGHT)); } return bi; }
From source file:jmbench.plots.OperationsVersusSizePlot.java
public void setSubTitle(String title) { chart.addSubtitle(new TextTitle(title, new Font("SansSerif", Font.ITALIC, 12))); }
From source file:org.jfree.chart.demo.PieChartDemo3.java
/** * Default constructor./*from www.j ava2s . c o m*/ * * @param title the frame title. */ public PieChartDemo3(final String title) { super(title); // create a dataset... final DefaultPieDataset data = new DefaultPieDataset(); // create the chart... final JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo 3", // chart title data, // data true, // include legend true, false); final PiePlot plot = (PiePlot) chart.getPlot(); plot.setNoDataMessage("No data available"); plot.setNoDataMessageFont(new Font("Serif", Font.ITALIC, 10)); plot.setNoDataMessagePaint(Color.red); // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:ComboBoxDemo.java
public ComboBoxDemo() { super(new BorderLayout()); String[] petStrings = { "Bird", "Cat", "Dog", "Rabbit", "Pig" }; //Create the combo box, select the item at index 4. //Indices start at 0, so 4 specifies the pig. JComboBox petList = new JComboBox(petStrings); petList.setSelectedIndex(4);//from w ww. j av a 2s . com petList.addActionListener(this); //Set up the picture. picture = new JLabel(); picture.setFont(picture.getFont().deriveFont(Font.ITALIC)); picture.setHorizontalAlignment(JLabel.CENTER); updateLabel(petStrings[petList.getSelectedIndex()]); picture.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); //The preferred size is hard-coded to be the width of the //widest image and the height of the tallest image + the border. //A real program would compute this. picture.setPreferredSize(new Dimension(177, 122 + 10)); //Lay out the demo. add(petList, BorderLayout.PAGE_START); add(picture, BorderLayout.PAGE_END); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:com.cburch.logisim.gui.start.AboutCredits.java
public AboutCredits() { scroll = 0;/*from ww w . j ava2s. co m*/ setOpaque(false); int prefWidth = About.IMAGE_WIDTH + 2 * About.IMAGE_BORDER; int prefHeight = About.IMAGE_HEIGHT / 2 + About.IMAGE_BORDER; setPreferredSize(new Dimension(prefWidth, prefHeight)); fadeStop = (float) (About.IMAGE_HEIGHT / 4.0); colorBase = new Color[] { new Color(143, 0, 0), new Color(48, 0, 96), new Color(48, 0, 96), }; font = new Font[] { new Font("Sans Serif", Font.ITALIC, 20), new Font("Sans Serif", Font.BOLD, 24), new Font("Sans Serif", Font.BOLD, 18), }; paintSteady = new Paint[colorBase.length]; for (int i = 0; i < colorBase.length; i++) { Color hue = colorBase[i]; paintSteady[i] = new GradientPaint(0.0f, 0.0f, derive(hue, 0), 0.0f, fadeStop, hue); } URL url = AboutCredits.class.getClassLoader().getResource(HENDRIX_PATH); Image hendrixLogo = null; if (url != null) { hendrixLogo = getToolkit().createImage(url); } // Logisim's policy concerning who is given credit: // Past contributors are not acknowledged in the About dialog for the current // version, but they do appear in the acknowledgements section of the User's // Guide. Current contributors appear in both locations. lines = new ArrayList<CreditsLine>(); linesHeight = 0; // computed in paintComponent lines.add(new CreditsLine(1, "www.cburch.com/logisim/")); lines.add(new CreditsLine(0, Strings.get("creditsRoleLead"), hendrixLogo, HENDRIX_WIDTH)); lines.add(new CreditsLine(1, "Carl Burch")); lines.add(new CreditsLine(2, "Hendrix College")); initialLines = lines.size(); lines.add(new CreditsLine(0, Strings.get("creditsRoleGerman"))); lines.add(new CreditsLine(1, "Uwe Zimmerman")); lines.add(new CreditsLine(2, "Uppsala universitet")); lines.add(new CreditsLine(0, Strings.get("creditsRoleGreek"))); lines.add(new CreditsLine(1, "Thanos Kakarountas")); lines.add(new CreditsLine(2, "\u03A4.\u0395.\u0399 \u0399\u03BF\u03BD\u03AF\u03C9\u03BD \u039D\u03AE\u03C3\u03C9\u03BD")); lines.add(new CreditsLine(0, Strings.get("creditsRolePortuguese"))); lines.add(new CreditsLine(1, "Theldo Cruz Franqueira")); lines.add(new CreditsLine(2, "PUC Minas")); lines.add(new CreditsLine(0, Strings.get("creditsRoleRussian"))); lines.add(new CreditsLine(1, "Ilia Lilov")); lines.add(new CreditsLine(2, "\u041C\u043E\u0441\u043A\u043E\u0432\u0441\u043A\u0438\u0439 \u0433\u043E\u0441\u0443\u0434\u0430\u0440\u0441\u0442\u0432\u0435\u043D\u043D\u044B\u0439")); lines.add(new CreditsLine(2, "\u0443\u043D\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442 \u043F\u0435\u0447\u0430\u0442\u0438")); lines.add(new CreditsLine(0, Strings.get("creditsRoleTesting"))); lines.add(new CreditsLine(1, "Ilia Lilov")); lines.add(new CreditsLine(2, "\u041C\u043E\u0441\u043A\u043E\u0432\u0441\u043A\u0438\u0439 \u0433\u043E\u0441\u0443\u0434\u0430\u0440\u0441\u0442\u0432\u0435\u043D\u043D\u044B\u0439")); lines.add(new CreditsLine(2, "\u0443\u043D\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442 \u043F\u0435\u0447\u0430\u0442\u0438")); /* If you fork Logisim, feel free to change the above lines, but * please do not change these last four lines! */ lines.add(new CreditsLine(0, Strings.get("creditsRoleOriginal"), hendrixLogo, HENDRIX_WIDTH)); lines.add(new CreditsLine(1, "Carl Burch")); lines.add(new CreditsLine(2, "Hendrix College")); lines.add(new CreditsLine(1, "www.cburch.com/logisim/")); }