List of usage examples for java.awt Font Font
private Font(String name, int style, float sizePts)
From source file:Main.java
public SplashScreen() { Container container = getContentPane(); JPanel panel = new JPanel(); panel.setBorder(new EtchedBorder()); container.add(panel, BorderLayout.CENTER); JLabel label = new JLabel("Hello World!"); label.setFont(new Font("Verdana", Font.BOLD, 14)); panel.add(label);//from w ww .ja v a 2s . com progressBar.setMaximum(PROGBAR_MAX); container.add(progressBar, BorderLayout.SOUTH); pack(); setVisible(true); startProgressBar(); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.scattercharts.SimpleScatter.java
public JFreeChart createChart(DatasetMap datasets) { DefaultXYDataset dataset = (DefaultXYDataset) datasets.getDatasets().get("1"); JFreeChart chart = ChartFactory.createScatterPlot(name, yLabel, xLabel, dataset, PlotOrientation.HORIZONTAL, false, true, false);/*from ww w . j av a 2 s .com*/ Font font = new Font("Tahoma", Font.BOLD, titleDimension); //TextTitle title = new TextTitle(name, font); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); chart.setBackgroundPaint(Color.white); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } XYPlot plot = (XYPlot) chart.getPlot(); plot.setForegroundAlpha(0.65f); XYItemRenderer renderer = plot.getRenderer(); int seriesN = dataset.getSeriesCount(); if (colorMap != null) { for (int i = 0; i < seriesN; i++) { String serieName = (String) dataset.getSeriesKey(i); Color color = (Color) colorMap.get(serieName); if (color != null) { renderer.setSeriesPaint(i, color); } } } // increase the margins to account for the fact that the auto-range // doesn't take into account the bubble size... NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRange(true); domainAxis.setRange(yMin, yMax); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRange(true); rangeAxis.setRange(xMin, xMax); if (legend == true) { drawLegend(chart); } return chart; }
From source file:AppletMenuBarDemo.java
public void init() { AppletMenuBar menubar = new AppletMenuBar(); menubar.setForeground(Color.black); menubar.setHighlightColor(Color.red); menubar.setFont(new Font("helvetica", Font.BOLD, 12)); this.setLayout(new BorderLayout()); this.add(menubar, BorderLayout.NORTH); PopupMenu file = new PopupMenu(); file.add("New..."); file.add("Open..."); file.add("Save As..."); PopupMenu edit = new PopupMenu(); edit.add("Cut"); edit.add("Copy"); edit.add("Paste"); menubar.addMenu("File", file); menubar.addMenu("Edit", edit); }
From source file:com.ohalo.cn.awt.JFreeChartTest2.java
public static JFreeChart createChart(CategoryDataset dataset) // ? { JFreeChart chart = ChartFactory.createBarChart("hi", "", "?", dataset, PlotOrientation.VERTICAL, true, true, false); // JFreeChart chart.setTitle(new TextTitle("??", new Font("", Font.BOLD + Font.ITALIC, 20)));// ???hi? CategoryPlot plot = (CategoryPlot) chart.getPlot();// ?plot CategoryAxis categoryAxis = plot.getDomainAxis();// ?? categoryAxis.setLabelFont(new Font("", Font.BOLD, 12));// ?? return chart; }
From source file:FontComboBox.java
public void actionPerformed(ActionEvent evt) { JComboBox source = (JComboBox) evt.getSource(); String item = (String) source.getSelectedItem(); fontLabel.setFont(new Font(item, Font.PLAIN, 12)); }
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); String s = "www.java2s.com"; Font font = new Font("Serif", Font.PLAIN, 32); if (mTextLayout == null) { FontRenderContext frc = g2.getFontRenderContext(); mTextLayout = new TextLayout(s, font, frc); }/* w w w . j av a 2 s .c o m*/ mTextLayout.draw(g2, mX, mY); }
From source file:com.globalsight.util.JfreeCharUtil.java
public static void drawPieChart2D(String title, Map<String, Double> datas, File OutFile) { PieDataset dataset = buildDatas(datas); JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})", NumberFormat.getNumberInstance(), new DecimalFormat("0.00%"))); plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})")); chart.setBackgroundPaint(Color.white); plot.setCircular(true);/*from w w w . j av a 2 s .c o m*/ TextTitle textTitle = new TextTitle(title); Font font = new Font(textTitle.getFont().getName(), Font.CENTER_BASELINE, 20); textTitle.setFont(font); chart.setTitle(textTitle); FileOutputStream fos_jpg = null; try { fos_jpg = new FileOutputStream(OutFile); ChartUtilities.writeChartAsJPEG(fos_jpg, 1, chart, 640, 480, null); fos_jpg.close(); } catch (Exception e) { s_logger.error(e.getMessage(), e); } }
From source file:FontList.java
public void paint(Graphics g) { for (int f = 0; f < families.length; f++) { // for each family for (int s = 0; s < styles.length; s++) { // for each style Font font = new Font(families[f], styles[s], 18); // create font g.setFont(font); // set font String name = families[f] + " " + stylenames[s]; // create name g.drawString(name, 20, (f * 4 + s + 1) * 20); // display name }/* ww w . j av a 2 s . c om*/ } }
From source file:com.polivoto.vistas.Editor.java
/** * Ventana Editor - configura el color de las preguntas. *///from ww w. j a v a 2 s.com public Editor(JSONArray js) { initComponents(); for (int i = 0; i < js.length(); i++) { try { JPanel panel = new JPanel(new GridLayout(0, 2, 10, 10)); panel.setBackground(new Color(255, 255, 255)); jTabbedPane.add(panel, "Pregunta " + (i + 1)); JLabel lab1 = new JLabel( "Pregunta " + (i + 1) + ": " + ((JSONObject) js.get(i)).getString("pregunta"), JLabel.LEFT); lab1.setFont(new Font("Roboto", 1, 18)); lab1.setForeground(new Color(134, 36, 31)); panel.add(lab1); panel.add(new JLabel("")); JSONArray jarr = ((JSONObject) js.get(i)).getJSONArray("opciones"); for (int j = 0; j < jarr.length(); j++) { JLabel lab2 = new JLabel("Opcin " + (j + 1) + ": " + jarr.getString(j), JLabel.LEFT); JButton colBut = new JButton("Seleccionar color de la opcin"); colBut.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { jFrame1.setVisible(true); } }); lab2.setFont(new Font("Roboto", 1, 15)); lab2.setForeground(new Color(0, 0, 0)); panel.add(lab2); panel.add(colBut); } } catch (JSONException ex) { Logger.getLogger(AnalistaLocal.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:ColorGradient.java
/** * Get the gradient start and end colors as applet parameter values, and * parse them using Color.decode(). If they are malformed, use white. *//*from w w w .j a va2 s . c o m*/ public void init() { try { startColor = Color.decode(getParameter("startColor")); endColor = Color.decode(getParameter("endColor")); } catch (Exception e) { startColor = Color.yellow; endColor = Color.red; } bigFont = new Font("Helvetica", Font.BOLD, 72); }