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:ToolbarDemo.java
protected void updateMonitor() { int index = -1; for (int k = 0; k < fontMenus.length; k++) { if (fontMenus[k].isSelected()) { index = k;//from w ww . j a v a 2 s . co m break; } } if (index == -1) return; if (index == 2) // Courier { boldMenu.setSelected(false); boldMenu.setEnabled(false); italicMenu.setSelected(false); italicMenu.setEnabled(false); } else { boldMenu.setEnabled(true); italicMenu.setEnabled(true); } int style = Font.PLAIN; if (boldMenu.isSelected()) style |= Font.BOLD; if (italicMenu.isSelected()) style |= Font.ITALIC; Font fn = fonts[index].deriveFont(style); }
From source file:playground.dgrether.analysis.charts.DgModalSplitDiffQuantilesChart.java
public JFreeChart createChart() { CategoryAxis categoryAxis = this.axisBuilder.createCategoryAxis(xLabel); categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); ValueAxis valueAxis = this.axisBuilder.createValueAxis(yLabel); //RANGE/*www. j a v a 2 s .c om*/ // valueAxis.setRange(-50.0, 50.0); //test valueAxis.setRange(-20.0, 20.0); //zh DgColorScheme colorScheme = new DgColorScheme(); CategoryPlot plot = new CategoryPlot(); plot.setDomainAxis(categoryAxis); // plot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT); plot.setRangeAxis(valueAxis); plot.setDataset(0, this.dataset); // plot.setDomainGridlinePosition(CategoryAnchor.END); // plot.setDomainGridlinesVisible(true); BarRenderer carRenderer = new BarRenderer(); carRenderer.setSeriesPaint(0, colorScheme.COLOR1A); carRenderer.setSeriesPaint(1, colorScheme.COLOR3A); carRenderer.setSeriesItemLabelGenerator(0, this.labelgenerator); carRenderer.setSeriesItemLabelGenerator(1, this.labelgenerator); Font labelFont = new Font("Helvetica", Font.BOLD, 14); carRenderer.setSeriesItemLabelFont(0, labelFont); carRenderer.setSeriesItemLabelFont(1, labelFont); carRenderer.setSeriesItemLabelsVisible(0, true); carRenderer.setSeriesItemLabelsVisible(1, true); carRenderer.setItemMargin(0.15); plot.setRenderer(0, carRenderer); JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(ChartColor.WHITE); chart.removeLegend(); // chart.getLegend().setItemFont(this.axisBuilder.getAxisFont()); return chart; }
From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV2.EICPlot.java
public EICPlot(List<List<NavigableMap<Double, Double>>> clusters, List<Double> colors, List<List<String>> info, List<NavigableMap<Double, Double>> modelPeaks) { super(null, true); setBackground(Color.white);//from w w w .ja va2 s.c om setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); NumberAxis xAxis = new NumberAxis("Retention Time"); xAxis.setAutoRangeIncludesZero(false); xAxis.setUpperMargin(0); xAxis.setLowerMargin(0); NumberAxis yAxis = new NumberAxis("Intensity"); yAxis.setAutoRangeIncludesZero(false); yAxis.setUpperMargin(0); yAxis.setLowerMargin(0); xyDataset = new XYSeriesCollection(); colorDataset = new ArrayList<>(); toolTips = new ArrayList<>(); widths = new ArrayList<>(); int seriesID = 0; for (int i = 0; i < clusters.size(); ++i) { List<NavigableMap<Double, Double>> cluster = clusters.get(i); double color = colors.get(i); for (int j = 0; j < cluster.size(); ++j) { XYSeries series = new XYSeries(seriesID++); for (Entry<Double, Double> e : cluster.get(j).entrySet()) series.add(e.getKey(), e.getValue()); xyDataset.addSeries(series); colorDataset.add(color); toolTips.add(info.get(i).get(j)); } } XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer() { @Override public Paint getItemPaint(int row, int col) { String type = xyDataset.getSeries(row).getDescription(); Paint color; if (type.equals(PeakType.MODEL.name())) color = COLORS[row % COLORS.length]; else color = new Color(0, 0, 0, 50); return color; } @Override public Stroke getSeriesStroke(int series) { XYSeries s = xyDataset.getSeries(series); String type = s.getDescription(); float width; if (type.equals((PeakType.MODEL.name()))) width = 2.0f; else width = 1.0f; return new BasicStroke(width); } }; renderer.setDefaultShapesVisible(false); renderer.setDefaultToolTipGenerator(new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { try { return toolTips.get(series); } catch (NullPointerException | IndexOutOfBoundsException e) { return ""; } } }); XYPlot plot = new XYPlot(xyDataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); JFreeChart chart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 12), plot, false); chart.setBackgroundPaint(Color.white); super.setChart(chart); }
From source file:ImageOps.java
/** Draw the example */ public void paint(Graphics g1) { Graphics2D g = (Graphics2D) g1; // Create a BufferedImage big enough to hold the Image loaded // in the constructor. Then copy that image into the new // BufferedImage object so that we can process it. BufferedImage bimage = new BufferedImage(image.getWidth(this), image.getHeight(this), BufferedImage.TYPE_INT_RGB); Graphics2D ig = bimage.createGraphics(); ig.drawImage(image, 0, 0, this); // copy the image // Set some default graphics attributes g.setFont(new Font("SansSerif", Font.BOLD, 12)); // 12pt bold text g.setColor(Color.green); // Draw in green g.translate(10, 10); // Set some margins // Loop through the filters for (int i = 0; i < filters.length; i++) { // If the filter is null, draw the original image, otherwise, // draw the image as processed by the filter if (filters[i] == null) g.drawImage(bimage, 0, 0, this); else/* ww w .ja va 2s .c o m*/ g.drawImage(filters[i].filter(bimage, null), 0, 0, this); g.drawString(filterNames[i], 0, 205); // Label the image g.translate(137, 0); // Move over if (i % 4 == 3) g.translate(-137 * 4, 215); // Move down after 4 } }
From source file:edu.ku.brc.af.ui.forms.formatters.DataObjAggregatorDlg.java
/** * @param key//from w w w . j av a 2 s.c o m * @return */ protected JLabel createI18NFormLabelBold(final String key) { JLabel lbl = createI18NFormLabel(key); Font lblFont = lbl.getFont().deriveFont(Font.BOLD); lbl.setFont(lblFont); return lbl; }
From source file:asl.util.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); return;//from www. j ava 2 s . co m } NumberAxis horizontalAxis = new NumberAxis("x-axis default"); // x = domain if (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("nlnm") || fileName.contains("stn")) { // NLNM or StationDeviation verticalAxis = new NumberAxis("PSD 10log10(m**2/s**4)/Hz dB"); verticalAxis.setRange(new Range(-190, -95)); 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(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); XYPlot xyplot = new XYPlot((XYDataset) 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()); renderer.setSeriesLinesVisible(iTrace, true); renderer.setSeriesShapesVisible(iTrace, false); 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")) { // 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."); } }
From source file:net.sf.dynamicreports.test.jasper.chart.CandlestickChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);/*from w ww .jav a 2 s . co m*/ JFreeChart chart = getChart("summary.chart1", 0); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); Assert.assertEquals("renderer", CandlestickRenderer.class, renderer.getClass()); Assert.assertEquals("show volume", false, ((CandlestickRenderer) renderer).getDrawVolume()); 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:edu.ucla.stat.SOCR.analyses.gui.PrincipalComponentAnalysis.java
/**Initialize the Analysis*/ public void init() { mapIndep = false;/* ww w . j a v a 2 s . c o m*/ showMapping = false; // added showDendro = false; // added: only for Clustering showGraph = true; showPCA = true; showInput = false; showSelect = false; showVisualize = false; super.init(); analysisType = AnalysisType.PRINCIPAL_COMPONENT_ANALYSIS; useInputExample = false; useLocalExample = false; useRandomExample = false; useServerExample = false; useStaticExample = ClusteringExamples.availableExamples; onlineDescription = "http://en.wikipedia.org/wiki/Logistic_regression"; depMax = 1; // max number of dependent var indMax = 15; // max number of independent var resultPanelTextArea.setFont(new Font(outputFontFace, Font.BOLD, outputFontSize)); frame = getFrame(this); setName("Regression & Correlation Analysis"); // Create the toolBar toolBar = new JToolBar(); createActionComponents(toolBar); this.getContentPane().add(toolBar, BorderLayout.NORTH); setPCADataPanel(); // use the new JFreeChar function. annie che 20060312 chartFactory = new Chart(); resetGraph(); validate(); }
From source file:org.yccheok.jstock.gui.charting.InvestmentFlowLayerUI.java
private void drawTitle(Graphics2D g2) { final Object oldValueAntiAlias = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING); final Color oldColor = g2.getColor(); final Font oldFont = g2.getFont(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); final Font titleFont = oldFont.deriveFont(oldFont.getStyle() | Font.BOLD, (float) oldFont.getSize() * 1.5f); final int margin = 5; final FontMetrics titleFontMetrics = g2.getFontMetrics(titleFont); final FontMetrics oldFontMetrics = g2.getFontMetrics(oldFont); final java.text.NumberFormat numberFormat = java.text.NumberFormat.getInstance(); numberFormat.setMaximumFractionDigits(2); numberFormat.setMinimumFractionDigits(2); final double totalInvestValue = this.investmentFlowChartJDialog.getTotalInvestValue(); final double totalROIValue = this.investmentFlowChartJDialog.getTotalROIValue(); final DecimalPlace decimalPlace = JStock.instance().getJStockOptions().getDecimalPlace(); final String invest = org.yccheok.jstock.portfolio.Utils.toCurrencyWithSymbol(decimalPlace, totalInvestValue);/* w ww. j a v a2s. co m*/ final String roi = org.yccheok.jstock.portfolio.Utils.toCurrencyWithSymbol(decimalPlace, totalROIValue); final double gain = totalROIValue - totalInvestValue; final double percentage = totalInvestValue > 0.0 ? gain / totalInvestValue * 100.0 : 0.0; final String gain_str = org.yccheok.jstock.portfolio.Utils.toCurrencyWithSymbol(decimalPlace, gain); final String percentage_str = numberFormat.format(percentage); final String SELECTED = this.investmentFlowChartJDialog.getCurrentSelectedString(); final String INVEST = GUIBundle.getString("InvestmentFlowLayerUI_Invest"); final String RETURN = GUIBundle.getString("InvestmentFlowLayerUI_Return"); final String GAIN = (SELECTED.length() > 0 ? SELECTED + " " : "") + GUIBundle.getString("InvestmentFlowLayerUI_Gain"); final String LOSS = (SELECTED.length() > 0 ? SELECTED + " " : "") + GUIBundle.getString("InvestmentFlowLayerUI_Loss"); final int string_width = oldFontMetrics.stringWidth(INVEST + ": ") + titleFontMetrics.stringWidth(invest + " ") + oldFontMetrics.stringWidth(RETURN + ": ") + titleFontMetrics.stringWidth(roi + " ") + oldFontMetrics.stringWidth((gain >= 0 ? GAIN : LOSS) + ": ") + titleFontMetrics.stringWidth(gain_str + " (" + percentage_str + "%)"); int x = (int) (this.investmentFlowChartJDialog.getChartPanel().getWidth() - string_width) >> 1; final int y = margin + titleFontMetrics.getAscent(); g2.setFont(oldFont); g2.drawString(INVEST + ": ", x, y); x += oldFontMetrics.stringWidth(INVEST + ": "); g2.setFont(titleFont); g2.drawString(invest + " ", x, y); x += titleFontMetrics.stringWidth(invest + " "); g2.setFont(oldFont); g2.drawString(RETURN + ": ", x, y); x += oldFontMetrics.stringWidth(RETURN + ": "); g2.setFont(titleFont); g2.drawString(roi + " ", x, y); x += titleFontMetrics.stringWidth(roi + " "); g2.setFont(oldFont); if (gain >= 0) { if (gain > 0) { if (org.yccheok.jstock.engine.Utils.isFallBelowAndRiseAboveColorReverse()) { g2.setColor(JStock.instance().getJStockOptions().getLowerNumericalValueForegroundColor()); } else { g2.setColor(JStock.instance().getJStockOptions().getHigherNumericalValueForegroundColor()); } } g2.drawString(GAIN + ": ", x, y); x += oldFontMetrics.stringWidth(GAIN + ": "); } else { if (org.yccheok.jstock.engine.Utils.isFallBelowAndRiseAboveColorReverse()) { g2.setColor(JStock.instance().getJStockOptions().getHigherNumericalValueForegroundColor()); } else { g2.setColor(JStock.instance().getJStockOptions().getLowerNumericalValueForegroundColor()); } g2.drawString(LOSS + ": ", x, y); x += oldFontMetrics.stringWidth(LOSS + ": "); } g2.setFont(titleFont); g2.drawString(gain_str + " (" + percentage_str + "%)", x, y); g2.setColor(oldColor); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldValueAntiAlias); g2.setFont(oldFont); }
From source file:edu.ku.brc.af.tasks.subpane.StatsPane.java
/** * Creates a StatsPane./*ww w. j av a 2 s.c o m*/ * @param name name of pane * @param task the owning task * @param resourceName the name of the resource that contains the configuration * @param useSeparatorTitles indicates the group panels should use separator titles instead of boxes * @param bgColor the background color * @param upperDisplayComp a display component for the upper half of the screen */ public StatsPane(final String name, final Taskable task, final String resourceName, final boolean useSeparatorTitles, final Color bgColor, final JComponent upperDisplayComp) { super(name, task); this.resourceName = resourceName; this.useSeparatorTitles = useSeparatorTitles; this.upperDisplayComp = upperDisplayComp; if (bgColor != null) { this.bgColor = bgColor; } else { this.bgColor = Color.WHITE; } setBackground(this.bgColor); setOpaque(true); setLayout(new BorderLayout()); if (upperDisplayComp == null) { JLabel lbl = UIHelper.createI18NLabel("COLL_STATS", SwingConstants.CENTER); int pntSize = lbl.getFont().getSize(); lbl.setFont(lbl.getFont().deriveFont((float) pntSize + 2).deriveFont(Font.BOLD)); add(lbl, BorderLayout.NORTH); } init(); registerPrintContextMenu(); }