List of usage examples for java.awt Font Font
private Font(String name, int style, float sizePts)
From source file:de.hs.mannheim.modUro.diagram.JCellCountDiagram.java
protected JFreeChart createChart(XYDataset dataset, String name) { String title = name;/* w w w. j a v a 2 s . c o m*/ JFreeChart xyLineChart = ChartFactory.createXYLineChart(title, // title "t", // x-axis label "n", // y-axis label dataset); String fontName = "Palatino"; xyLineChart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); XYPlot plot = (XYPlot) xyLineChart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(true); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.getRangeAxis().setLowerMargin(0.0); // plot.getRangeAxis().setRange(0.0, 1.01); plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.gray); xyLineChart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); xyLineChart.getLegend().setFrame(BlockBorder.NONE); xyLineChart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER); XYItemRenderer r = plot.getRenderer(); // set the default stroke for all series int i = 0; for (String celltype : getTimeSeries().getDataSeriesNames()) { r.setSeriesPaint(i, CellTypeColor.getColor(celltype)); i++; } r.setSeriesPaint(i, Color.BLACK); return xyLineChart; }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int cx = getSize().width / 2; int cy = getSize().height / 2; g2.translate(cx, cy);/*from w w w. j a v a 2s . c o m*/ g2.rotate(theta * Math.PI / 180); Shape oldClip = g2.getClip(); Shape e = new Ellipse2D.Float(-cx, -cy, cx * 2, cy * 2); g2.clip(e); Shape c = new Ellipse2D.Float(-cx, -cy, cx * 3 / 4, cy * 2); g2.setPaint(new GradientPaint(40, 40, Color.blue, 60, 50, Color.white, true)); g2.fill(c); g2.setPaint(Color.yellow); g2.fillOval(cx / 4, 0, cx, cy); g2.setClip(oldClip); g2.setFont(new Font("Times New Roman", Font.PLAIN, 64)); g2.setPaint(new GradientPaint(-cx, 0, Color.red, cx, 0, Color.black, false)); g2.drawString("Hello, 2D!", -cx * 3 / 4, cy / 4); AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) .75); g2.setComposite(ac); Shape r = new RoundRectangle2D.Float(0, -cy * 3 / 4, cx * 3 / 4, cy * 3 / 4, 20, 20); g2.setStroke(new BasicStroke(4)); g2.setPaint(Color.magenta); g2.fill(r); g2.setPaint(Color.green); g2.draw(r); g2.drawImage(image, -cx / 2, -cy / 2, this); }
From source file:de.hs.mannheim.modUro.controller.diagram.DiagramController.java
/** * Creates JFreeChart. XYLineDiagram.//from www .j ava 2 s . c om * * @param dataset * @return */ protected JFreeChart createChart(XYDataset dataset, String metricTypeName) { String title = metricTypeName; JFreeChart xyLineChart = ChartFactory.createXYLineChart(title, // title "t", // x-axis label "f", // y-axis label dataset); String fontName = "Palatino"; xyLineChart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); XYPlot plot = (XYPlot) xyLineChart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(true); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.getRangeAxis().setLowerMargin(0.0); plot.getRangeAxis().setRange(0.0, 1.01); plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); xyLineChart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); xyLineChart.getLegend().setFrame(BlockBorder.NONE); xyLineChart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); renderer.setDrawSeriesLineAsPath(true); // set the default stroke for all series renderer.setAutoPopulateSeriesStroke(false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, new Color(24, 123, 58)); renderer.setSeriesPaint(2, new Color(149, 201, 136)); renderer.setSeriesPaint(3, new Color(1, 62, 29)); renderer.setSeriesPaint(4, new Color(81, 176, 86)); renderer.setSeriesPaint(5, new Color(0, 55, 122)); renderer.setSeriesPaint(6, new Color(0, 92, 165)); } return xyLineChart; }
From source file:Highlights.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); String s = "Drag the text to highlight Java Source and Support."; Font font = new Font("Serif", Font.PLAIN, 32); if (textLayout == null) { FontRenderContext frc = g2.getFontRenderContext(); textLayout = new TextLayout(s, font, frc); }/*w w w . ja v a 2 s . c o m*/ // Draw the highlight. if (firstHit != null && secondHit != null) { Shape base = textLayout.getLogicalHighlightShape(firstHit.getInsertionIndex(), secondHit.getInsertionIndex()); AffineTransform at = AffineTransform.getTranslateInstance(x, y); Shape highlight = at.createTransformedShape(base); g2.setPaint(Color.white); g2.fill(highlight); } g2.setPaint(Color.black); textLayout.draw(g2, x, y); }
From source file:org.quickserver.net.qsadmin.plugin.stats.ThermometerChart.java
public ThermometerChart(String title) { bgColor = new Color(238, 238, 230, 255); thermo1.setValue(value);//w w w .j a v a2 s .c o m thermo1.setBackground(bgColor); thermo1.setOutlinePaint(null); thermo1.setUnits(0); thermo1.setShowValueLines(true); thermo1.setFollowDataInSubranges(true); //thermo1.setForeground(Color.blue); thermo1.setValuePaint(Color.BLACK); setRange(0, 300); /* setSubrangeInfo(0, 0, 50, 0, 60); setSubrangeInfo(1, 50, 100, 40, 110); setSubrangeInfo(2, 110, 250, 100, 300); */ thermo1.addSubtitle(title, new Font("Dialog", Font.BOLD, 15)); thermo1.setToolTipText(title); setToolTipText(title); setLayout(new BorderLayout()); add(thermo1, BorderLayout.CENTER); }
From source file:charts.ErrorPorcentajePie.java
private JFreeChart createChart(PieDataset dataset, String title) { JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("no data"); plot.setCircular(false);/* ww w . j av a 2s .co m*/ plot.setLabelGap(0.02); return chart; }
From source file:org.jfree.chart.demo.XYBlockChartDemo1.java
private static JFreeChart createChart(XYZDataset xyzdataset) { NumberAxis numberaxis = new NumberAxis("X"); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setLowerMargin(0.0D);//www. ja v a2 s . c om numberaxis.setUpperMargin(0.0D); numberaxis.setAxisLinePaint(Color.white); numberaxis.setTickMarkPaint(Color.white); NumberAxis numberaxis1 = new NumberAxis("Y"); numberaxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis1.setLowerMargin(0.0D); numberaxis1.setUpperMargin(0.0D); numberaxis1.setAxisLinePaint(Color.white); numberaxis1.setTickMarkPaint(Color.white); XYBlockRenderer xyblockrenderer = new XYBlockRenderer(); GrayPaintScale graypaintscale = new GrayPaintScale(-2D, 1.0D); xyblockrenderer.setPaintScale(graypaintscale); XYPlot xyplot = new XYPlot(xyzdataset, numberaxis, numberaxis1, xyblockrenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinesVisible(false); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setOutlinePaint(Color.blue); JFreeChart jfreechart = new JFreeChart("XYBlockChartDemo1", xyplot); jfreechart.removeLegend(); NumberAxis numberaxis2 = new NumberAxis("Scale"); numberaxis2.setAxisLinePaint(Color.white); numberaxis2.setTickMarkPaint(Color.white); numberaxis2.setTickLabelFont(new Font("Dialog", 0, 7)); PaintScaleLegend paintscalelegend = new PaintScaleLegend(new GrayPaintScale(), numberaxis2); paintscalelegend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT); paintscalelegend.setAxisOffset(5D); paintscalelegend.setMargin(new RectangleInsets(5D, 5D, 5D, 5D)); paintscalelegend.setFrame(new BlockBorder(Color.red)); paintscalelegend.setPadding(new RectangleInsets(10D, 10D, 10D, 10D)); paintscalelegend.setStripWidth(10D); paintscalelegend.setPosition(RectangleEdge.RIGHT); paintscalelegend.setBackgroundPaint(new Color(120, 120, 180)); jfreechart.addSubtitle(paintscalelegend); jfreechart.setBackgroundPaint(new Color(180, 180, 250)); return jfreechart; }
From source file:net.noday.core.utils.Captcha.java
public static BufferedImage gen(String text, int width, int height) throws IOException { BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR); Graphics2D g = (Graphics2D) bi.getGraphics(); g.setColor(Color.GRAY);//from w ww . ja v a2s . c om g.fillRect(0, 0, width, height); for (int i = 0; i < 10; i++) { g.setColor(randColor(150, 250)); g.drawOval(random.nextInt(110), random.nextInt(24), 5 + random.nextInt(10), 5 + random.nextInt(10)); Font f = new Font("Arial", Font.ITALIC, 20); g.setFont(f); g.setColor(randColor(10, 240)); g.drawString(text, 4, 24); } return bi; }
From source file:com.stam.batchmove.BatchMoveUtils.java
public static void showFilesFrame(Object[][] data, String[] columnNames, final JFrame callerFrame) { final FilesFrame filesFrame = new FilesFrame(); DefaultTableModel model = new DefaultTableModel(data, columnNames) { private static final long serialVersionUID = 1L; @Override//ww w . jav a2s . c om public Class<?> getColumnClass(int column) { return getValueAt(0, column).getClass(); } @Override public boolean isCellEditable(int row, int column) { return column == 0; } }; DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setHorizontalAlignment(JLabel.CENTER); final JTable table = new JTable(model); for (int i = 1; i < table.getColumnCount(); i++) { table.setDefaultRenderer(table.getColumnClass(i), renderer); } // table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.setRowHeight(30); table.getTableHeader().setFont(new Font("Serif", Font.BOLD, 14)); table.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14)); table.setRowSelectionAllowed(false); table.getColumnModel().getColumn(0).setMaxWidth(35); table.getColumnModel().getColumn(1).setPreferredWidth(350); table.getColumnModel().getColumn(2).setPreferredWidth(90); table.getColumnModel().getColumn(2).setMaxWidth(140); table.getColumnModel().getColumn(3).setMaxWidth(90); JPanel tblPanel = new JPanel(); JPanel btnPanel = new JPanel(); tblPanel.setLayout(new BorderLayout()); if (table.getRowCount() > 15) { JScrollPane scrollPane = new JScrollPane(table); tblPanel.add(scrollPane, BorderLayout.CENTER); } else { tblPanel.add(table.getTableHeader(), BorderLayout.NORTH); tblPanel.add(table, BorderLayout.CENTER); } btnPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); filesFrame.setMinimumSize(new Dimension(800, 600)); filesFrame.setLayout(new BorderLayout()); filesFrame.add(tblPanel, BorderLayout.NORTH); filesFrame.add(btnPanel, BorderLayout.SOUTH); final JLabel resultsLabel = new JLabel(); JButton cancelBtn = new JButton("Cancel"); cancelBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { filesFrame.setVisible(false); callerFrame.setVisible(true); } }); JButton moveBtn = new JButton("Copy"); moveBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setDialogTitle("Choose target directory"); int selVal = fileChooser.showOpenDialog(null); if (selVal == JFileChooser.APPROVE_OPTION) { File selection = fileChooser.getSelectedFile(); String targetPath = selection.getAbsolutePath(); DefaultTableModel dtm = (DefaultTableModel) table.getModel(); int nRow = dtm.getRowCount(); int copied = 0; for (int i = 0; i < nRow; i++) { Boolean selected = (Boolean) dtm.getValueAt(i, 0); String filePath = dtm.getValueAt(i, 1).toString(); if (selected) { try { FileUtils.copyFileToDirectory(new File(filePath), new File(targetPath)); dtm.setValueAt("Copied", i, 3); copied++; } catch (Exception ex) { Logger.getLogger(SelectionFrame.class.getName()).log(Level.SEVERE, null, ex); dtm.setValueAt("Failed", i, 3); } } } resultsLabel.setText(copied + " files copied. Finished!"); } } }); btnPanel.add(cancelBtn); btnPanel.add(moveBtn); btnPanel.add(resultsLabel); filesFrame.revalidate(); filesFrame.setVisible(true); callerFrame.setVisible(false); }
From source file:com.rapidminer.gui.plotter.charts.RingChartPlotter.java
@Override public JFreeChart createChart(PieDataset pieDataSet, boolean createLegend) { JFreeChart chart = ChartFactory.createRingChart(null, pieDataSet, createLegend, // legend true, false);/* w w w . j a v a 2 s . c o m*/ PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 11)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; }