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:MenuDemo.java
protected void updateMonitor() { int index = -1; for (int k = 0; k < menus.length; k++) { if (menus[k].isSelected()) { index = k;/*from www. j a v a 2 s .c o m*/ break; } } if (index == -1) return; if (index == 2) // Courier { boldMenuItem.setSelected(false); boldMenuItem.setEnabled(false); italicMenuItem.setSelected(false); italicMenuItem.setEnabled(false); } else { boldMenuItem.setEnabled(true); italicMenuItem.setEnabled(true); } int style = Font.PLAIN; if (boldMenuItem.isSelected()) style |= Font.BOLD; if (italicMenuItem.isSelected()) style |= Font.ITALIC; }
From source file:net.sf.dynamicreports.test.jasper.chart.HighLowChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);/* w w w .j a va 2 s. c o m*/ JFreeChart chart = getChart("summary.chart1", 0); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); Assert.assertEquals("renderer", HighLowRenderer.class, renderer.getClass()); Assert.assertEquals("show open ticks", true, ((HighLowRenderer) renderer).getDrawOpenTicks()); Assert.assertEquals("show close ticks", true, ((HighLowRenderer) renderer).getDrawCloseTicks()); highLowChartDataTest(chart, 0, new Object[][] { { "serie", date1, 50d, 35d, 40d, 47d, 70d }, { "serie", date2, 55d, 40d, 50d, 45d, 120d }, { "serie", date3, 48d, 41d, 42d, 47d, 90d } }); chart = getChart("summary.chart2", 0); Axis axis = chart.getXYPlot().getDomainAxis(); Assert.assertEquals("category label", "time", axis.getLabel()); Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); Assert.assertTrue("vertical tick labels", ((ValueAxis) axis).isVerticalTickLabels()); chart = getChart("summary.chart3", 0); axis = chart.getXYPlot().getRangeAxis(); Assert.assertEquals("value label", "value", axis.getLabel()); Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10)); //Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound()); Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound()); Assert.assertTrue("vertical tick labels", ((ValueAxis) axis).isVerticalTickLabels()); }
From source file:MultiLineLabel.java
public void setBold(boolean bold) { if (bold)/* w w w. j a v a 2s . c o m*/ fontAttributes |= Font.BOLD; else fontAttributes &= ~Font.BOLD; }
From source file:asl.plotmaker.PlotMaker2.java
public void writePlot(String fileName) { // System.out.format("== plotTitle=[%s] fileName=[%s]\n", plotTitle, // fileName); File outputFile = new File(fileName); // Check that we will be able to output the file without problems and if // not --> return if (!checkFileOut(outputFile)) { // System.out.format("== plotMaker: request to output plot=[%s] but we are unable to create it " // + " --> skip plot\n", fileName ); logger.warn("== Request to output plot=[{}] but we are unable to create it " + " --> skip plot\n", fileName);// ww w . j av a 2s . c o m return; } NumberAxis horizontalAxis = new NumberAxis("x-axis default"); // x = // domain if (fileName.contains("alnm") || fileName.contains("nlnm") || fileName.contains("coher") || fileName.contains("stn")) { // NLNM or StationDeviation horizontalAxis = new LogarithmicAxis("Period (sec)"); horizontalAxis.setRange(new Range(1, 11000)); horizontalAxis.setTickUnit(new NumberTickUnit(5.0)); } else { // EventCompareSynthetics/StrongMotion horizontalAxis = new NumberAxis("Time (s)"); double x[] = panels.get(0).getTraces().get(0).getxData(); horizontalAxis.setRange(new Range(x[0], x[x.length - 1])); } CombinedDomainXYPlot combinedPlot = new CombinedDomainXYPlot(horizontalAxis); combinedPlot.setGap(15.); // Loop over (3) panels for this plot: for (Panel panel : panels) { NumberAxis verticalAxis = new NumberAxis("y-axis default"); // y = // range if (fileName.contains("alnm") || fileName.contains("nlnm") || fileName.contains("stn")) { // NLNM // or // StationDeviation verticalAxis = new NumberAxis("PSD 10log10(m**2/s**4)/Hz dB"); verticalAxis.setRange(new Range(-190, -80)); verticalAxis.setTickUnit(new NumberTickUnit(5.0)); } else if (fileName.contains("coher")) { // Coherence verticalAxis = new NumberAxis("Coherence, Gamma"); verticalAxis.setRange(new Range(0, 1.2)); verticalAxis.setTickUnit(new NumberTickUnit(0.1)); } else { // EventCompareSynthetics/StrongMotion verticalAxis = new NumberAxis("Displacement (m)"); } Font fontPlain = new Font("Verdana", Font.PLAIN, 14); Font fontBold = new Font("Verdana", Font.BOLD, 18); verticalAxis.setLabelFont(fontBold); verticalAxis.setTickLabelFont(fontPlain); horizontalAxis.setLabelFont(fontBold); horizontalAxis.setTickLabelFont(fontPlain); XYSeriesCollection seriesCollection = new XYSeriesCollection(); XYDotRenderer renderer = new XYDotRenderer(); XYPlot xyplot = new XYPlot(seriesCollection, horizontalAxis, verticalAxis, renderer); xyplot.setDomainGridlinesVisible(true); xyplot.setRangeGridlinesVisible(true); xyplot.setRangeGridlinePaint(Color.black); xyplot.setDomainGridlinePaint(Color.black); // Plot each trace on this panel: int iTrace = 0; for (Trace trace : panel.getTraces()) { XYSeries series = new XYSeries(trace.getName()); double xdata[] = trace.getxData(); double ydata[] = trace.getyData(); for (int k = 0; k < xdata.length; k++) { series.add(xdata[k], ydata[k]); } renderer.setSeriesPaint(iTrace, trace.getColor()); renderer.setSeriesStroke(iTrace, trace.getStroke()); seriesCollection.addSeries(series); iTrace++; } // Add Annotations for each trace - This is done in a separate loop // so that // the upper/lower limits for this panel will be known double xmin = horizontalAxis.getRange().getLowerBound(); double xmax = horizontalAxis.getRange().getUpperBound(); double ymin = verticalAxis.getRange().getLowerBound(); double ymax = verticalAxis.getRange().getUpperBound(); double delX = Math.abs(xmax - xmin); double delY = Math.abs(ymax - ymin); // Annotation (x,y) in normalized units - where upper-right corner = // (1,1) double xAnn = 0.97; // Right center coords of the trace name (e.g., // "00-LHZ") double yAnn = 0.95; double yOff = 0.05; // Vertical distance between different trace // legends iTrace = 0; for (Trace trace : panel.getTraces()) { if (!trace.getName().contains("NLNM") && !trace.getName().contains("NHNM") && !trace.getName().contains("ALNM")) { // x1 > x2 > x3, e.g.: // o-------o 00-LHZ // x3 x2 x1 double scale = .01; // Controls distance between trace label // and line segment double xL = .04; // Length of trace line segment in legend double xAnn2 = xAnn - scale * trace.getName().length(); double xAnn3 = xAnn - scale * trace.getName().length() - xL; double x1 = xAnn * delX + xmin; // Right hand x-coord of // text in range units double x2 = xAnn2 * delX + xmin; // x-coord of line segment // end in range units double x3 = xAnn3 * delX + xmin; // x-coord of line segment // end in range units double y = (yAnn - (iTrace * yOff)) * delY + ymin; if (horizontalAxis instanceof LogarithmicAxis) { double logMin = Math.log10(xmin); double logMax = Math.log10(xmax); delX = logMax - logMin; x1 = Math.pow(10, xAnn * delX + logMin); x2 = Math.pow(10, xAnn2 * delX + logMin); x3 = Math.pow(10, xAnn3 * delX + logMin); } xyplot.addAnnotation(new XYLineAnnotation(x3, y, x2, y, trace.getStroke(), trace.getColor())); XYTextAnnotation xyText = new XYTextAnnotation(trace.getName(), x1, y); xyText.setFont(new Font("Verdana", Font.BOLD, 18)); xyText.setTextAnchor(TextAnchor.CENTER_RIGHT); xyplot.addAnnotation(xyText); } iTrace++; } combinedPlot.add(xyplot, 1); } // panel final JFreeChart chart = new JFreeChart(combinedPlot); chart.setTitle(new TextTitle(plotTitle, new Font("Verdana", Font.BOLD, 18))); chart.removeLegend(); try { ChartUtilities.saveChartAsPNG(outputFile, chart, 1400, 1400); } catch (IOException e) { // System.err.println("Problem occurred creating chart."); logger.error("IOException:", e); } }
From source file:edu.scripps.fl.pubchem.xmltool.gui.GUIComponent.java
public JButton createJButton(String text, String toolTip, String type) { JButton jbn = null;/* w w w .j a v a 2s . c o m*/ if (type.equals("icon")) { jbn = new JButton(createGeneralIcon(text)); } else if (type.equals("text")) { Font jbnFont = new Font(Font.SANS_SERIF, Font.BOLD, 10); jbn = new JButton(text); jbn.setFont(jbnFont); } jbn.setOpaque(true); jbn.setToolTipText(toolTip); return jbn; }
From source file:org.adempiere.webui.apps.graph.WPerformanceIndicator.java
private JFreeChart createChart() { JFreeChart chart = null;//from w w w . j av a 2 s. c o m // Set Text StringBuffer text = new StringBuffer(m_goal.getName()); if (m_goal.isTarget()) text.append(": ").append(m_goal.getPercent()).append("%"); else text.append(": ").append(s_format.format(m_goal.getMeasureActual())); m_text = text.toString(); // ToolTip text = new StringBuffer(); if (m_goal.getDescription() != null) text.append(m_goal.getDescription()).append(": "); text.append(s_format.format(m_goal.getMeasureActual())); if (m_goal.isTarget()) text.append(" ").append(Msg.getMsg(Env.getCtx(), "of")).append(" ") .append(s_format.format(m_goal.getMeasureTarget())); setTooltiptext(text.toString()); // DefaultValueDataset data = new DefaultValueDataset((float) m_goal.getPercent()); MeterPlot plot = new MeterPlot(data); MColorSchema colorSchema = m_goal.getColorSchema(); int rangeLo = 0; int rangeHi = 0; for (int i = 1; i <= 4; i++) { switch (i) { case 1: rangeHi = colorSchema.getMark1Percent(); break; case 2: rangeHi = colorSchema.getMark2Percent(); break; case 3: rangeHi = colorSchema.getMark3Percent(); break; case 4: rangeHi = colorSchema.getMark4Percent(); break; } if (rangeHi == 9999) rangeHi = (int) Math.floor(rangeLo * 1.5); if (rangeLo < rangeHi) { plot.addInterval(new MeterInterval("Normal", //label new Range(rangeLo, rangeHi), //range colorSchema.getColor(rangeHi), new BasicStroke(7.0f), new Color(-13091716))); rangeLo = rangeHi; } } plot.setRange(new Range(0, rangeLo)); plot.setDialBackgroundPaint(new Color(-13091716)); plot.setUnits(""); plot.setDialShape(DialShape.CHORD);//CIRCLE); plot.setNeedlePaint(Color.white); plot.setTickSize(2000); plot.setTickLabelFont(new Font("SansSerif", Font.BOLD, 8)); plot.setValueFont(new Font("SansSerif", Font.BOLD, 8)); plot.setNoDataMessageFont(new Font("SansSerif", Font.BOLD, 8)); plot.setTickLabelPaint(Color.white); plot.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); chart = new JFreeChart(m_text, new Font("SansSerif", Font.BOLD, 9), plot, false); return chart; }
From source file:ChartUsingJava.CombinedCategoryPlotDemo1.java
/** * Creates a chart./*from w w w . j a va 2 s . c o m*/ * * @return A chart. */ private static JFreeChart createChart() { CategoryDataset dataset1 = createDataset1(); NumberAxis rangeAxis1 = new NumberAxis("Value"); rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LineAndShapeRenderer renderer1 = new LineAndShapeRenderer(); renderer1.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); CategoryPlot subplot1 = new CategoryPlot(dataset1, null, rangeAxis1, renderer1); subplot1.setDomainGridlinesVisible(true); CategoryDataset dataset2 = createDataset2(); NumberAxis rangeAxis2 = new NumberAxis("Value"); rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer renderer2 = new BarRenderer(); renderer2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); CategoryPlot subplot2 = new CategoryPlot(dataset2, null, rangeAxis2, renderer2); subplot2.setDomainGridlinesVisible(true); CategoryAxis domainAxis = new CategoryAxis("Category"); CombinedCategoryPlot plot = new CombinedCategoryPlot(domainAxis, new NumberAxis("Range")); plot.add(subplot1, 2); plot.add(subplot2, 1); JFreeChart result = new JFreeChart("Combined Domain Category Plot Demo", new Font("SansSerif", Font.BOLD, 12), plot, true); return result; }
From source file:org.bench4Q.console.ui.section.S_LengthSection.java
/** * @return// www . j av a2s . c o m * @throws IOException */ public JPanel drawSessionPic() throws IOException { CategoryDataset dataset = getDataSet(); JFreeChart chart = ChartFactory.createBarChart3D("Session", "Session type", "Session number", dataset, PlotOrientation.VERTICAL, true, true, true); CategoryPlot plot = chart.getCategoryPlot(); org.jfree.chart.axis.CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(0.1); domainAxis.setUpperMargin(0.1); domainAxis.setCategoryLabelPositionOffset(10); domainAxis.setCategoryMargin(0.2); org.jfree.chart.axis.ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setUpperMargin(0.1); org.jfree.chart.renderer.category.BarRenderer3D renderer; renderer = new org.jfree.chart.renderer.category.BarRenderer3D(); renderer.setBaseOutlinePaint(Color.red); renderer.setSeriesPaint(0, new Color(0, 255, 255)); renderer.setSeriesOutlinePaint(0, Color.BLACK); renderer.setSeriesPaint(1, new Color(0, 255, 0)); renderer.setSeriesOutlinePaint(1, Color.red); renderer.setItemMargin(0.1); renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setItemLabelFont(new Font("", Font.BOLD, 12)); renderer.setItemLabelPaint(Color.black); renderer.setItemLabelsVisible(true); plot.setRenderer(renderer); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.setBackgroundPaint(Color.WHITE); return new ChartPanel(chart); }
From source file:com.joey.software.memoryToolkit.MemoryUsagePanel.java
/** * Creates a new application.// ww w. j a va 2 s. c o m * * @param historyCount * the history count (in milliseconds). */ public MemoryUsagePanel(int historyCount, int interval) { super(new BorderLayout()); // create two series that automatically discard data more than 30 // seconds old... this.total = new TimeSeries("Total Memory", Millisecond.class); this.total.setMaximumItemCount(historyCount); this.free = new TimeSeries("Free Memory", Millisecond.class); this.free.setMaximumItemCount(historyCount); this.used = new TimeSeries("Used Memory", Millisecond.class); this.used.setMaximumItemCount(historyCount); this.max = new TimeSeries("Used Memory", Millisecond.class); this.max.setMaximumItemCount(historyCount); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(this.total); dataset.addSeries(this.free); dataset.addSeries(this.used); dataset.addSeries(this.max); DateAxis domain = new DateAxis("Time"); NumberAxis range = new NumberAxis("Memory"); domain.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); range.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); domain.setLabelFont(new Font("SansSerif", Font.PLAIN, 14)); range.setLabelFont(new Font("SansSerif", Font.PLAIN, 14)); XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setSeriesPaint(0, Color.red); renderer.setSeriesPaint(1, Color.green); renderer.setSeriesPaint(2, Color.black); renderer.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); XYPlot plot = new XYPlot(dataset, domain, range, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); domain.setAutoRange(true); domain.setLowerMargin(0.0); domain.setUpperMargin(0.0); domain.setTickLabelsVisible(true); range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); JFreeChart chart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", Font.BOLD, 24), plot, true); chart.setBackgroundPaint(Color.white); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder(Color.black))); add(chartPanel); gen = new DataGenerator(interval); }
From source file:org.jfree.chart.demo.CombinedXYPlotDemo5.java
/** * Creates a combined XYPlot chart./*from w w w. ja va 2s . c o m*/ * * @return the combined chart. */ private JFreeChart createCombinedChart() { // create a default chart based on some sample data... final TimeSeriesCollection dataset0 = new TimeSeriesCollection(); final TimeSeries eur = DemoDatasetFactory.createEURTimeSeries(); dataset0.addSeries(eur); final TimeSeriesCollection dataset1 = new TimeSeriesCollection(); final TimeSeries mav = MovingAverage.createMovingAverage(eur, "EUR/GBP (30 Day MA)", 30, 30); dataset1.addSeries(eur); dataset1.addSeries(mav); final TimeSeriesCollection dataset2 = new TimeSeriesCollection(); dataset2.addSeries(eur); JFreeChart chart = null; // make a common vertical axis for all the sub-plots final NumberAxis valueAxis = new NumberAxis("Value"); valueAxis.setAutoRangeIncludesZero(false); // override default // make a horizontally combined plot final CombinedRangeXYPlot parent = new CombinedRangeXYPlot(valueAxis); // add subplot 1... final XYPlot subplot1 = new XYPlot(dataset0, new DateAxis("Date 1"), null, new StandardXYItemRenderer()); subplot1.setDomainCrosshairVisible(true); subplot1.setRangeCrosshairVisible(true); parent.add(subplot1, 1); // add subplot 2... final XYPlot subplot2 = new XYPlot(dataset1, new DateAxis("Date 2"), null, new StandardXYItemRenderer()); subplot2.setDomainCrosshairVisible(true); subplot2.setRangeCrosshairVisible(true); parent.add(subplot2, 1); // add subplot 3... final XYPlot subplot3 = new XYPlot(dataset2, new DateAxis("Date 3"), null, new XYBarRenderer(0.20)); subplot3.setDomainCrosshairVisible(true); subplot3.setRangeCrosshairVisible(true); parent.add(subplot3, 1); // now make the top level JFreeChart chart = new JFreeChart("Demo Chart", JFreeChart.DEFAULT_TITLE_FONT, parent, true); // then customise it a little... final TextTitle subtitle = new TextTitle("This is a subtitle", new Font("SansSerif", Font.BOLD, 12)); chart.addSubtitle(subtitle); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue)); return chart; }