List of usage examples for java.awt Font Font
private Font(String name, int style, float sizePts)
From source file:net.shopxx.CaptchaEngine.java
public void afterPropertiesSet() throws Exception { Assert.state(imageWidth > 0);// w ww . j av a 2s . co m Assert.state(imageHeight > 0); Assert.state(minFontSize > 0); Assert.state(maxFontSize > 0); Assert.state(minWordLength > 0); Assert.state(maxWordLength > 0); Assert.hasText(charString); Font[] fonts = new Font[] { new Font("Arial", Font.BOLD, maxFontSize), new Font("Bell", Font.BOLD, maxFontSize), new Font("Credit", Font.BOLD, maxFontSize), new Font("Impact", Font.BOLD, maxFontSize) }; FontGenerator fontGenerator = new RandomFontGenerator(minFontSize, maxFontSize, fonts); BackgroundGenerator backgroundGenerator = StringUtils.isNotEmpty(backgroundImagePath) ? new FileReaderRandomBackgroundGenerator(imageWidth, imageHeight, servletContext.getRealPath(backgroundImagePath)) : new FunkyBackgroundGenerator(imageWidth, imageHeight); TextPaster textPaster = new RandomTextPaster(minWordLength, maxWordLength, Color.WHITE); CaptchaFactory[] captchaFactories = new CaptchaFactory[] { new GimpyFactory(new RandomWordGenerator(charString), new ComposedWordToImage(fontGenerator, backgroundGenerator, textPaster)) }; super.setFactories(captchaFactories); }
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.demo.TextBlockDemo.java
/** * Creates the content pane for the demo frame. * * @return The content pane.//ww w .j a v a 2 s. c om */ private JPanel createContentPane() { final JPanel content = new TextBlockPanel( "This is some really long text that we will use " + "for testing purposes. You'll need to resize the window to see how the TextBlock " + "is dynamically updated. Also note what happens when there is a really long " + "word like ABCDEFGHIJKLMNOPQRSTUVWXYZ (OK, that's not really a word).", new Font("Serif", Font.PLAIN, 14)); return content; }
From source file:TrackerPanel.java
public TrackerPanel() { setBackground(Color.GRAY);//w w w. ja v a 2 s. com df = new DecimalFormat("0.#"); // 1 dp msgFont = new Font("SansSerif", Font.BOLD, 13); configOpenNI(); histogram = new float[MAX_DEPTH_SIZE]; imWidth = depthMD.getFullXRes(); imHeight = depthMD.getFullYRes(); setSize(imWidth * 2, imHeight); System.out.println("Image dimensions (" + imWidth + ", " + imHeight + ")"); // create empty image bytes array of correct size and type imgbytes = new byte[imWidth * imHeight * 3]; hideBGPixel = new Color(0, 0, 255, 0).getRGB(); // create d.s for holding camera pixels and image cameraPixels = new int[imWidth * imHeight]; cameraImage = new BufferedImage(imWidth, imHeight, BufferedImage.TYPE_INT_ARGB); // the image must have an alpha channel for the transparent blue pixels new Thread(this).start(); // start updating the panel }
From source file:scheduler.benchmarker.manager.CreateSimpleSplineChart.java
public ChartPanel createChartPanel() { XYDataset dataset = createDataset(); NumberAxis numberaxis = new NumberAxis("EMAILS"); numberaxis.setAutoRangeIncludesZero(true); numberaxis.setRange(0, dataset.getItemCount(1)); numberaxis.setVisible(false);/* w w w. j a va 2 s . com*/ NumberAxis numberaxis1 = new NumberAxis("TIME CONSUMED"); numberaxis1.setAutoRangeIncludesZero(false); XYSplineRenderer xysplinerenderer = new XYSplineRenderer(); XYPlot xyplot = new XYPlot(dataset, numberaxis, numberaxis1, xysplinerenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); //xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); JFreeChart jfreechart = new JFreeChart("PLAN VALUES FOR '" + sName + "' SCHEDULER", new Font(Font.SANS_SERIF, Font.PLAIN, 11), xyplot, true); chartPanel = new ChartPanel(jfreechart, true); //Creating listener chartPanel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent e) { ChartEntity entity = e.getEntity(); if (entity != null && (entity instanceof XYItemEntity)) { XYItemEntity item = (XYItemEntity) entity; String chartTitle = "RULE ARRANGEMENT INFORMATION FOR EMAIL \"" + dataSource.get(item.getItem()).getEmailName() + "\""; createSubChart( new CreateStackedBarChart3D(dataSource.get(item.getItem()), pluginColor, chartTitle) .createChartPanel()); } } @Override public void chartMouseMoved(ChartMouseEvent e) { //DO NOTHING } }); return chartPanel; }
From source file:org.webcat.grader.graphs.WCChartTheme.java
/** * Initializes a new WCChartTheme, which is a JFreeChart theme that is * customized for Web-CAT and can eventually pull values directly from the * user's currently selected Web-CAT theme. * * @param theme the user's currently selected Web-CAT theme *///from ww w . j a v a 2 s .c om public WCChartTheme(Theme theme) { super("Web-CAT"); if (theme != null) { this.theme = theme; } else { this.theme = Theme.defaultTheme(); } // Use the font that we currently have as the default Web-CAT font. String fontName = defaultFontName(); setExtraLargeFont(new Font(fontName, Font.BOLD, 20)); setLargeFont(new Font(fontName, Font.BOLD, 14)); setRegularFont(new Font(fontName, Font.BOLD, 12)); setSmallFont(new Font(fontName, Font.BOLD, 10)); // Set the text color based on whether the theme is light or dark. Color textColor = textColor(); setAxisLabelPaint(textColor); setItemLabelPaint(textColor); setLegendItemPaint(textColor); setSubtitlePaint(textColor); setTickLabelPaint(textColor); setTitlePaint(textColor); // Make the background of the charts transparent. setPlotBackgroundPaint(new Color(144, 144, 144, 128)); Color transparent = new Color(0, 0, 0, 0); setChartBackgroundPaint(transparent); setLegendBackgroundPaint(transparent); // Kill the gradients that newer versions of JFreeChart add by default. setDrawingSupplier(new ThemeBasedDrawingSupplier()); setBarPainter(new StandardBarPainter()); setXYBarPainter(new StandardXYBarPainter()); }
From source file:DashboardInterface.TensionSpeedDial.java
public TensionSpeedDial(JPanel parentIn) { super(new BorderLayout()); parent = parentIn;//from w w w . j av a 2 s . c om dataset1 = new DefaultValueDataset(0D); dataset2 = new DefaultValueDataset(0D); pipe = MessagePipeline.getInstance(); pipe.attach(this); DialPlot dialplot = new DialPlot(); dialplot.setView(0.0D, 0.0D, 1.0D, 1.0D); dialplot.setDataset(0, dataset1); dialplot.setDataset(1, dataset2); setBackground(Color.WHITE); StandardDialFrame standarddialframe = new StandardDialFrame(); standarddialframe.setBackgroundPaint(Color.lightGray); standarddialframe.setForegroundPaint(Color.darkGray); dialplot.setDialFrame(standarddialframe); DialBackground dialbackground = new DialBackground(Color.LIGHT_GRAY); dialbackground.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL)); dialplot.setBackground(dialbackground); DialTextAnnotation dialtextannotation = new DialTextAnnotation("Tension (lbf)"); dialtextannotation.setFont(new Font("Dialog", 1, 12)); dialtextannotation.setPaint(Color.RED); dialtextannotation.setRadius(0.47999999999999996D); dialplot.addLayer(dialtextannotation); DialTextAnnotation dialtextannotation2 = new DialTextAnnotation("Speed (kts)"); dialtextannotation2.setFont(new Font("Dialog", 1, 12)); dialtextannotation2.setPaint(Color.BLUE); dialtextannotation2.setRadius(0.78999999999999996D); dialplot.addLayer(dialtextannotation2); /*DialValueIndicator dialvalueindicator = new DialValueIndicator(0); dialvalueindicator.setFont(new Font("Dialog", 0, 10)); dialvalueindicator.setOutlinePaint(Color.BLACK); dialvalueindicator.setRadius(0.84999999999999998D); dialvalueindicator.setAngle(-90D); dialplot.addLayer(dialvalueindicator); DialValueIndicator dialvalueindicator1 = new DialValueIndicator(1); dialvalueindicator1.setFont(new Font("Dialog", 0, 10)); dialvalueindicator1.setOutlinePaint(Color.BLACK); dialvalueindicator1.setRadius(0.60999999999999998D); dialvalueindicator1.setAngle(-90D); dialplot.addLayer(dialvalueindicator1);*/ StandardDialScale standarddialscale = new StandardDialScale(0D, 90D, -120D, -300D, 10D, 4); standarddialscale.setTickRadius(0.88D); standarddialscale.setTickLabelOffset(0.14999999999999999D); standarddialscale.setTickLabelFont(new Font("Dialog", 0, 14)); standarddialscale.setTickLabelPaint(Color.BLUE); standarddialscale.setMajorTickPaint(Color.BLUE); standarddialscale.setMinorTickPaint(Color.BLUE); dialplot.addScale(0, standarddialscale); StandardDialScale standarddialscale1 = new StandardDialScale(0.0D, 2500D, -120D, -300D, 500D, 4); standarddialscale1.setTickRadius(0.5D); standarddialscale1.setTickLabelOffset(0.14999999999999999D); standarddialscale1.setTickLabelFont(new Font("Dialog", 0, 10)); standarddialscale1.setTickLabelPaint(Color.RED); standarddialscale1.setMajorTickPaint(Color.RED); standarddialscale1.setMinorTickPaint(Color.RED); dialplot.addScale(1, standarddialscale1); dialplot.mapDatasetToScale(1, 1); org.jfree.chart.plot.dial.DialPointer.Pointer pointer = new org.jfree.chart.plot.dial.DialPointer.Pointer( 0); pointer.setFillPaint(Color.BLUE); dialplot.addPointer(pointer); org.jfree.chart.plot.dial.DialPointer.Pointer pin = new org.jfree.chart.plot.dial.DialPointer.Pointer(1); pin.setRadius(0.55000000000000004D); pin.setFillPaint(Color.RED); dialplot.addPointer(pin); DialCap dialcap = new DialCap(); dialcap.setRadius(0.10000000000000001D); dialplot.setCap(dialcap); Dimension size = parent.getBounds().getSize(); int width = parent.getWidth(); int height = parent.getHeight(); width = 200; JFreeChart jfreechart = new JFreeChart(dialplot); jfreechart.setBackgroundPaint(Color.WHITE); ChartPanel chartpanel = new ChartPanel(jfreechart); chartpanel.setPreferredSize(new Dimension(width, width)); add(chartpanel); }
From source file:org.openfaces.component.chart.impl.plots.MultiplePiePlotAdapter.java
private TextTitle getSeriesTitle(Chart chart) { StyleObjectModel cssChartViewModel = chart.getChartView().getStyleObjectModel(); TextTitle seriesTitle;/*ww w. j av a2 s . c om*/ Font f = CSSUtil.getFont(cssChartViewModel); if (f != null) { seriesTitle = new TextTitle("Series Title", f); } else { seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12)); } if (cssChartViewModel.getColor() != null) { seriesTitle.setPaint(cssChartViewModel.getColor()); } seriesTitle.setPosition(RectangleEdge.BOTTOM); return seriesTitle; }
From source file:org.jfree.chart.demo.PieChartDemo3.java
/** * Default constructor.// w w w . ja v a2 s . c om * * @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:StreamConverter.java
ShowString(String target, String title) { setTitle(title);// www. j a va2s .c o m outString = target; Font font = new Font("Monospaced", Font.PLAIN, 36); fontM = getFontMetrics(font); setFont(font); int size = 0; for (int i = 0; i < outString.length(); i++) { size += fontM.charWidth(outString.charAt(i)); } size += 24; setSize(size, fontM.getHeight() + 60); setLocation(getSize().width / 2, getSize().height / 2); show(); }