List of usage examples for java.awt Font BOLD
int BOLD
To view the source code for java.awt Font BOLD.
Click Source Link
From source file:Main.java
public ListRenderingFrame() { setTitle("ListRendering"); setSize(400, 300);//ww w .j a v a 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:room.utilization.PieChart.java
private JFreeChart createChart(PieDataset dataset) { JFreeChart chart = null;//from w ww.j a v a2 s. c o m PieSectionLabelGenerator pl = null; PiePlot3D plot = null; chart = ChartFactory.createPieChart3D(chartTitle, dataset, true, true, false); pl = new StandardPieSectionLabelGenerator("{0} = {2}"); plot = (PiePlot3D) chart.getPlot(); plot.setLabelGenerator(pl); plot.setLabelFont(new Font("Helvatica", Font.BOLD, 10)); return chart; }
From source file:geneticalgorithm.gui.view.VGraphic.java
public VGraphic(String title, String xLabel, String yLabel) { setSize(800, 600);// w w w.j a v a 2 s . com setLocationRelativeTo(this); setTitle(title); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent arg0) { dispose(); } }); setLayout(new BorderLayout()); average = new XYSeries("Average"); offline = new XYSeries("Offline"); online = new XYSeries("Online"); dataset = new XYSeriesCollection(); dataset.addSeries(average); dataset.addSeries(offline); dataset.addSeries(online); chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, dataset, PlotOrientation.VERTICAL, true, true, false); add(new ChartPanel(chart), BorderLayout.CENTER); JPanel south = new JPanel(new MigLayout()); lblAverage = new JLabel(""); lblAverage.setHorizontalTextPosition(SwingConstants.LEFT); lblAverage.setFont(new Font("ARIAL", Font.BOLD, 26)); JLabel lblAverageTitle = new JLabel("Average: "); lblAverageTitle.setFont(new Font("ARIAL", Font.BOLD, 26)); south.add(lblAverageTitle); south.add(lblAverage, "wrap"); lblOffline = new JLabel(""); lblOffline.setHorizontalTextPosition(SwingConstants.LEFT); lblOffline.setFont(new Font("ARIAL", Font.BOLD, 26)); JLabel lblOfflineTitle = new JLabel("Offline: "); lblOfflineTitle.setFont(new Font("ARIAL", Font.BOLD, 26)); south.add(lblOfflineTitle); south.add(lblOffline, "wrap"); lblOnline = new JLabel(""); lblOnline.setHorizontalTextPosition(SwingConstants.LEFT); lblOnline.setFont(new Font("ARIAL", Font.BOLD, 26)); JLabel lblOnlineTitle = new JLabel("Online: "); lblOnlineTitle.setFont(new Font("ARIAL", Font.BOLD, 26)); south.add(lblOnlineTitle); south.add(lblOnline, "wrap"); add(south, BorderLayout.SOUTH); }
From source file:irille.pub.verify.RandomImageServlet.java
/** * ???,,?16,/*from www . jav a 2 s.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:com.synnex.saas.platform.core.servlet.CaptchaServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {//from ww w. j a v a 2s .com int width = 50; int height = 18; String captchaCode = RandomStringUtils.random(4, true, true); HttpSession session = request.getSession(true); session.setAttribute("captchaCode", captchaCode); response.setContentType("images/jpeg"); response.setHeader("Pragma", "No-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires", 0); ServletOutputStream out = response.getOutputStream(); BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics g = image.getGraphics(); g.setColor(getRandColor(200, 250)); g.fillRect(0, 0, width, height); Font mFont = new Font("Times New Roman", Font.BOLD, 18); g.setFont(mFont); g.setColor(getRandColor(160, 200)); Random random = new Random(); for (int i = 0; i < 155; i++) { int x2 = random.nextInt(width); int y2 = random.nextInt(height); int x3 = random.nextInt(12); int y3 = random.nextInt(12); g.drawLine(x2, y2, x2 + x3, y2 + y3); } g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110))); g.drawString(captchaCode, 2, 16); g.dispose(); ImageIO.write((BufferedImage) image, "JPEG", out); out.close(); } catch (Exception e) { logger.error("Generate captcha failed.", e); } }
From source file:org.gumtree.vis.awt.DefaultChartTheme.java
/** * @param name//from www. j av a 2 s . c o m */ public DefaultChartTheme(String name) { super(name); setExtraLargeFont(new Font("SansSerif", Font.BOLD, 16)); setLargeFont(new Font("SansSerif", Font.BOLD, 14)); setRegularFont(new Font("SansSerif", Font.PLAIN, 12)); setSmallFont(new Font("SansSerif", Font.PLAIN, 10)); setDrawingSupplier(new DefaultDrawingSupplier(createDefaultPaintArray(), DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); }
From source file:components.ColorChooserDemo2.java
public ColorChooserDemo2() { super(new BorderLayout()); //Set up banner to use as custom preview panel banner = new JLabel("Welcome to the Tutorial Zone!", JLabel.CENTER); banner.setForeground(Color.yellow); banner.setBackground(Color.blue); banner.setOpaque(true);//from w w w. j av a 2 s . c o m banner.setFont(new Font("SansSerif", Font.BOLD, 24)); banner.setPreferredSize(new Dimension(100, 65)); JPanel bannerPanel = new JPanel(new BorderLayout()); bannerPanel.add(banner, BorderLayout.CENTER); bannerPanel.setBorder(BorderFactory.createTitledBorder("Banner")); //Set up color chooser for setting background color JPanel panel = new JPanel(); //use FlowLayout JButton bcc = new JButton("Show Color Chooser..."); bcc.addActionListener(this); panel.add(bcc); panel.setBorder(BorderFactory.createTitledBorder("Choose Background Color")); //Set up color chooser for setting text color tcc = new JColorChooser(); tcc.getSelectionModel().addChangeListener(this); tcc.setBorder(BorderFactory.createTitledBorder("Choose Text Color")); //Remove the preview panel tcc.setPreviewPanel(new JPanel()); //Override the chooser panels with our own AbstractColorChooserPanel panels[] = { new CrayonPanel() }; tcc.setChooserPanels(panels); tcc.setColor(banner.getForeground()); add(bannerPanel, BorderLayout.PAGE_START); add(panel, BorderLayout.CENTER); add(tcc, BorderLayout.PAGE_END); }
From source file:net.roboconf.doc.generator.internal.GraphUtils.java
/** * @return the default font to use in graph diagrams */// w w w . j a v a 2 s. c om public static Font getDefaultFont() { return new Font("Helvetica Neue", Font.BOLD, 15); }
From source file:com.orsonpdf.demo.PDFPieChartDemo1.java
/** * Creates a chart./*from ww w. j av a2 s . co m*/ * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Smart Phones Manufactured / Q3 2011", dataset, false, false, false); chart.setBackgroundPaint( new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY)); // customise the title position and font TextTitle t = chart.getTitle(); t.setHorizontalAlignment(HorizontalAlignment.LEFT); t.setPaint(new Color(240, 240, 240)); t.setFont(new Font("Arial", Font.BOLD, 26)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setInteriorGap(0.04); plot.setOutlineVisible(false); plot.setShadowPaint(null); plot.setLabelShadowPaint(null); // use gradients and white borders for the section colours plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE)); plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED)); plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN)); plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW)); plot.setBaseSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); BasicStroke bs = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 1.0f); plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f)); // customise the section label appearance plot.setLabelFont(new Font("Courier New", Font.BOLD, 20)); plot.setLabelLinkPaint(Color.WHITE); plot.setLabelLinkStroke(new BasicStroke(2.0f)); plot.setLabelOutlineStroke(null); plot.setLabelPaint(Color.WHITE); plot.setLabelBackgroundPaint(null); // add a subtitle giving the data source TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", new Font("Courier New", Font.PLAIN, 12)); source.setPaint(Color.WHITE); source.setPosition(RectangleEdge.BOTTOM); source.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(source); return chart; }
From source file:Paints.java
/** Draw the example */ public void paint(Graphics g1) { Graphics2D g = (Graphics2D) g1; // Paint the entire background using a GradientPaint. // The background color varies diagonally from deep red to pale blue g.setPaint(new GradientPaint(0, 0, new Color(150, 0, 0), WIDTH, HEIGHT, new Color(200, 200, 255))); g.fillRect(0, 0, WIDTH, HEIGHT); // fill the background // Use a different GradientPaint to draw a box. // This one alternates between deep opaque green and transparent green. // Note: the 4th arg to Color() constructor specifies color opacity g.setPaint(new GradientPaint(0, 0, new Color(0, 150, 0), 20, 20, new Color(0, 150, 0, 0), true)); g.setStroke(new BasicStroke(15)); // use wide lines g.drawRect(25, 25, WIDTH - 50, HEIGHT - 50); // draw the box // The glyphs of fonts can be used as Shape objects, which enables // us to use Java2D techniques with letters Just as we would with // any other shape. Here we get some letter shapes to draw. Font font = new Font("Serif", Font.BOLD, 10); // a basic font Font bigfont = // a scaled up version font.deriveFont(AffineTransform.getScaleInstance(30.0, 30.0)); GlyphVector gv = bigfont.createGlyphVector(g.getFontRenderContext(), "JAV"); Shape jshape = gv.getGlyphOutline(0); // Shape of letter J Shape ashape = gv.getGlyphOutline(1); // Shape of letter A Shape vshape = gv.getGlyphOutline(2); // Shape of letter V // We're going to outline the letters with a 5-pixel wide line g.setStroke(new BasicStroke(5.0f)); // We're going to fake shadows for the letters using the // following Paint and AffineTransform objects Paint shadowPaint = new Color(0, 0, 0, 100); // Translucent black AffineTransform shadowTransform = AffineTransform.getShearInstance(-1.0, 0.0); // Shear to the right shadowTransform.scale(1.0, 0.5); // Scale height by 1/2 // Move to the baseline of our first letter g.translate(65, 270);/*w ww .j av a 2 s. c o m*/ // Draw the shadow of the J shape g.setPaint(shadowPaint); g.translate(15, 20); // Compensate for the descender of the J // transform the J into the shape of its shadow, and fill it g.fill(shadowTransform.createTransformedShape(jshape)); g.translate(-15, -20); // Undo the translation above // Now fill the J shape with a solid (and opaque) color g.setPaint(Color.blue); // Fill with solid, opaque blue g.fill(jshape); // Fill the shape g.setPaint(Color.black); // Switch to solid black g.draw(jshape); // And draw the outline of the J // Now draw the A shadow g.translate(75, 0); // Move to the right g.setPaint(shadowPaint); // Set shadow color g.fill(shadowTransform.createTransformedShape(ashape)); // draw shadow // Draw the A shape using a solid transparent color g.setPaint(new Color(0, 255, 0, 125)); // Transparent green as paint g.fill(ashape); // Fill the shape g.setPaint(Color.black); // Switch to solid back g.draw(ashape); // Draw the outline // Move to the right and draw the shadow of the letter V g.translate(175, 0); g.setPaint(shadowPaint); g.fill(shadowTransform.createTransformedShape(vshape)); // We're going to fill the next letter using a TexturePaint, which // repeatedly tiles an image. The first step is to obtain the image. // We could load it from an image file, but here we create it // ourselves by drawing a into an off-screen image. Note that we use // a GradientPaint to fill the off-screen image, so the fill pattern // combines features of both Paint classes. BufferedImage tile = // Create an image new BufferedImage(50, 50, BufferedImage.TYPE_INT_RGB); Graphics2D tg = tile.createGraphics(); // Get its Graphics for drawing tg.setColor(Color.pink); tg.fillRect(0, 0, 50, 50); // Fill tile background with pink tg.setPaint(new GradientPaint(40, 0, Color.green, // diagonal gradient 0, 40, Color.gray)); // green to gray tg.fillOval(5, 5, 40, 40); // Draw a circle with this gradient // Use this new tile to create a TexturePaint and fill the letter V g.setPaint(new TexturePaint(tile, new Rectangle(0, 0, 50, 50))); g.fill(vshape); // Fill letter shape g.setPaint(Color.black); // Switch to solid black g.draw(vshape); // Draw outline of letter // Move to the right and draw the shadow of the final A g.translate(160, 0); g.setPaint(shadowPaint); g.fill(shadowTransform.createTransformedShape(ashape)); g.fill(ashape); // Fill letter A g.setPaint(Color.black); // Revert to solid black g.draw(ashape); // Draw the outline of the A }