Example usage for java.awt Font BOLD

List of usage examples for java.awt Font BOLD

Introduction

In this page you can find the example usage for java.awt Font BOLD.

Prototype

int BOLD

To view the source code for java.awt Font BOLD.

Click Source Link

Document

The bold style constant.

Usage

From source file:org.martus.client.reports.MartusChartTheme.java

public MartusChartTheme() {
    super("Martus");

    // NOTE: JFreeChart default is "Tahoma", which somehow maps to Dialog,
    // which for some reason (in J6) doesn't fall back to the fallback fonts, 
    // and therefore doesn't work in Armenian, Bangla, Khmer, or Nepali 
    setExtraLargeFont(new Font(FontHandler.getDefaultFontName(), Font.BOLD, 20));
    setLargeFont(new Font(FontHandler.getDefaultFontName(), Font.BOLD, 14));
    setRegularFont(new Font(FontHandler.getDefaultFontName(), Font.PLAIN, 12));
    setSmallFont(new Font(FontHandler.getDefaultFontName(), Font.PLAIN, 10));
}

From source file:java2d.ps.EPSColorsExample.java

/**
 * Creates an EPS file. The contents are painted using a Graphics2D
 * implementation that generates an EPS file.
 * //  ww  w  .j ava  2  s  .c o  m
 * @param outputFile
 *            the target file
 * @throws IOException
 *             In case of an I/O error
 */
public static void generateEPSusingJava2D(final File outputFile) throws IOException {
    OutputStream out = new java.io.FileOutputStream(outputFile);
    out = new java.io.BufferedOutputStream(out);
    try {
        // Instantiate the EPSDocumentGraphics2D instance
        final EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false);
        g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());

        // Set up the document size
        g2d.setupDocument(out, 400, 200); // 400pt x 200pt

        // Paint a bounding box
        g2d.drawRect(0, 0, 400, 200);

        g2d.setFont(new Font("sans-serif", Font.BOLD, 14));
        g2d.drawString("Color usage example:", 10, 20);
        g2d.setFont(new Font("sans-serif", Font.PLAIN, 12));
        g2d.drawString("RGB", 10, 84);
        g2d.drawString("CMYK", 60, 84);
        g2d.drawString("(Lab)", 110, 84);
        g2d.drawString("(Named)", 160, 84);

        // We're creating a few boxes all filled with some variant of the
        // "Postgelb" (postal yellow) color as used by Swiss Post.

        final Color colRGB = new Color(255, 204, 0);
        g2d.setColor(colRGB);
        g2d.fillRect(10, 30, 40, 40);

        // Just convert RGB to CMYK and use that
        final float[] compsRGB = colRGB.getColorComponents(null);
        final DeviceCMYKColorSpace cmykCS = ColorSpaces.getDeviceCMYKColorSpace();
        final float[] compsCMYK = cmykCS.fromRGB(compsRGB);
        final Color colCMYK = DeviceCMYKColorSpace.createCMYKColor(compsCMYK);
        g2d.setColor(colCMYK);
        g2d.fillRect(60, 30, 40, 40);

        // Try CIELab (not implemented, yet)
        final CIELabColorSpace d50 = ColorSpaces.getCIELabColorSpaceD50();
        final Color colLab = d50.toColor(83.25f, 16.45f, 96.89f, 1.0f);
        g2d.setColor(colLab);
        g2d.fillRect(110, 30, 40, 40);

        // Try named color (Separation, not implemented, yet)
        final float[] c1xyz = d50.toCIEXYZNative(83.25f, 16.45f, 96.89f);
        final NamedColorSpace postgelb = new NamedColorSpace("Postgelb", c1xyz);
        final Color colNamed = new Color(postgelb, new float[] { 1.0f }, 1.0f);
        g2d.setColor(colNamed);
        g2d.fillRect(160, 30, 40, 40);

        // Cleanup
        g2d.finish();
    } finally {
        IOUtils.closeQuietly(out);
    }
}

From source file:com.ouc.cpss.view.SupTradeChartBuilder.java

private static JFreeChart createJFreeChart(PieDataset dataset) {
    /**//from   w  w  w  .  j a v  a 2 s. c o  m
     * JFreeChart
     */
    //?     
    StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
    //     
    standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20));
    //    
    standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 15));
    //?     
    standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 15));
    //?   
    ChartFactory.setChartTheme(standardChartTheme);
    //??  
    //createPieChart 2D; createPieChart3D  3D
    JFreeChart chart = ChartFactory.createPieChart("", dataset, true, true, false);

    //,?
    chart.setTitle(new TextTitle("", new Font("", Font.ITALIC, 22)));

    //?
    LegendTitle legend = chart.getLegend(0);
    //,ture,?
    legend.setItemFont(new Font("", Font.BOLD, 20));

    //?(??)
    PiePlot plot = (PiePlot) chart.getPlot();
    //?==?
    plot.setLabelFont(new Font("", Font.BOLD, 22));
    //
    plot.setBaseSectionOutlinePaint(Color.BLUE);
    //
    plot.setBaseSectionOutlineStroke(new BasicStroke(0.5f));
    //?,??,??
    plot.setDirection(Rotation.CLOCKWISE);//,Rotation.CLOCKWISE
    //()
    plot.setStartAngle(70);
    //???
    //plot.setExplodePercent(1, 0.5D);
    //plot.setExplodePercent("One", 0.5D);
    //,3D?
    plot.setExplodePercent(dataset.getKey(0), 0.1d);
    //
    plot.setLabelLinkPaint(Color.BLUE);
    //
    plot.setLabelOutlinePaint(Color.black);
    //
    plot.setLabelShadowPaint(Color.RED);
    //
    plot.setSectionPaint(1, Color.BLACK);
    // :,{0},{1},{2}?,???
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}:{1}\r\n{2}",
            NumberFormat.getNumberInstance(), new DecimalFormat("0.00%")));

    //
    plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}={2}"));
    //:(true),(false)
    plot.setCircular(true);
    //?
    plot.setNoDataMessage("??...");

    //???
    plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    //
    //plot.setURLGenerator(new StandardPieURLGenerator("detail.jsp"));

    return chart;
}

From source file:utils.ChartUtils.java

/**
 * Update values of a bar chart/*ww  w  .j  av a  2 s. c  om*/
 * 
 * @param labelsByFreq Labels ordered by frequency
 * @param nInstances Number of instances
 * @param cp CategoryPlot
 */
public static void updateValuesBarChart(ImbalancedFeature[] labelsByFreq, int nInstances, CategoryPlot cp) {
    DefaultCategoryDataset data = new DefaultCategoryDataset();

    double prob;

    labelsByFreq = MetricUtils.sortByFrequency(labelsByFreq);

    double sum = 0.0;
    for (int i = 0; i < labelsByFreq.length; i++) {
        prob = labelsByFreq[i].getAppearances() * 1.0 / nInstances;
        sum += prob;

        data.setValue(prob, labelsByFreq[i].getName(), " ");
    }

    cp.setDataset(data);

    // add mean mark
    sum = sum / labelsByFreq.length;
    Marker start = new ValueMarker(sum);
    start.setPaint(Color.red);
    start.setLabelFont(new Font("SansSerif", Font.BOLD, 12));
    start.setLabel("                        Mean: " + MetricUtils.truncateValue(sum, 3));
    cp.addRangeMarker(start);
}

From source file:com.ouc.cpss.view.ChartProBuilder.java

private static JFreeChart createJFreeChart(CategoryDataset dataset) {
    /**//  w ww  .  j  a v a 2s  . c  o  m
     * JFreeChart
     */
    //?     
    StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
    //     
    standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20));
    //    
    standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 15));
    //?     
    standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 15));
    //?   
    ChartFactory.setChartTheme(standardChartTheme);
    //?
    // ?
    JFreeChart jfreeChart = null;
    if (choice == 1) {
        jfreeChart = ChartFactory.createBarChart3D("? -- ?TOP10", "",
                "?", dataset, PlotOrientation.VERTICAL, true, false, false);
        /**
          * JFreeChart
          */
        jfreeChart.setTitle(new TextTitle("? -- ?TOP10",
                new Font("", Font.BOLD + Font.ITALIC, 20)));
        CategoryPlot plot = (CategoryPlot) jfreeChart.getPlot();
        CategoryAxis categoryAxis = plot.getDomainAxis();
        categoryAxis.setLabelFont(new Font("", Font.ROMAN_BASELINE, 12));
    } else {
        jfreeChart = ChartFactory.createBarChart3D("? -- ?TOP10", "",
                "?", dataset, PlotOrientation.VERTICAL, true, false, false);
        jfreeChart.setTitle(new TextTitle("? -- ?TOP10",
                new Font("", Font.BOLD + Font.ITALIC, 20)));
        CategoryPlot plot = (CategoryPlot) jfreeChart.getPlot();
        CategoryAxis categoryAxis = plot.getDomainAxis();
        categoryAxis.setLabelFont(new Font("", Font.ROMAN_BASELINE, 12));
    }
    return jfreeChart;
}

From source file:com.tencent.wstt.apt.chart.MemoryRealTimeChart.java

@Override
public JFreeChart createChart() {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("", "",
            "kB", dataset, true, true, false);

    //??/*from w  w w.j a va2s  .  co m*/
    chart.getTitle().setFont(new Font("", Font.BOLD, 20));

    XYPlot xyPlot = (XYPlot) chart.getXYPlot();
    ValueAxis domainAxis = xyPlot.getDomainAxis();
    ValueAxis rangeAxis = xyPlot.getRangeAxis();

    domainAxis.setLabelFont(new Font("", Font.BOLD, 14));
    domainAxis.setTickLabelFont(new Font("", Font.BOLD, 12));

    rangeAxis.setLabelFont(new Font("", Font.BOLD, 14));
    rangeAxis.setTickLabelFont(new Font("", Font.BOLD, 12));
    //rangeAxis.setAutoRange(true);

    //rangeAxis.setAutoTickUnitSelection(true);

    return chart;
}

From source file:QandE.MyDemo2.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread.//from w  w w  .j a  v  a2  s .c  o  m
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("MyDemo2");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JMenu menu = new JMenu("Menu");
    JMenuBar mb = new JMenuBar();
    mb.add(menu);
    frame.setJMenuBar(mb);

    //Add a label with bold italic font.
    JLabel label = new JLabel("My Demo");
    frame.getContentPane().add(BorderLayout.CENTER, label);
    if (true) {
        label.setFont(label.getFont().deriveFont(Font.ITALIC | Font.BOLD));
    } else {
        //another way of doing it, but not as appropriate since 
        //setFont is faster than using HTML.
        label.setText("<html><i>My Demo</i></html>");
    }
    label.setHorizontalAlignment(JLabel.CENTER);

    //Display the window, making it a little bigger than it really needs to be.
    frame.pack();
    frame.setSize(frame.getWidth() + 100, frame.getHeight() + 50);
    frame.setVisible(true);
}

From source file:BoxLayoutPane.java

public BoxLayoutPane() {
    // Use a BorderLayout layout manager to arrange various Box components
    this.setLayout(new BorderLayout());

    // Give the entire panel a margin by adding an empty border
    // We could also do this by overriding getInsets()
    this.setBorder(new EmptyBorder(10, 10, 10, 10));

    // Add a plain row of buttons along the top of the pane
    Box row = Box.createHorizontalBox();
    for (int i = 0; i < 4; i++) {
        JButton b = new JButton("B" + i);
        b.setFont(new Font("serif", Font.BOLD, 12 + i * 2));
        row.add(b);//from  w  w  w.j ava 2 s  .co m
    }
    this.add(row, BorderLayout.NORTH);

    // Add a plain column of buttons along the right edge
    // Use BoxLayout with a different kind of Swing container
    // Give the column a border: can't do this with the Box class
    JPanel col = new JPanel();
    col.setLayout(new BoxLayout(col, BoxLayout.Y_AXIS));
    col.setBorder(new TitledBorder(new EtchedBorder(), "Column"));
    for (int i = 0; i < 4; i++) {
        JButton b = new JButton("Button " + i);
        b.setFont(new Font("sanserif", Font.BOLD, 10 + i * 2));
        col.add(b);
    }
    this.add(col, BorderLayout.EAST); // Add column to right of panel

    // Add a button box along the bottom of the panel.
    // Use "Glue" to space the buttons evenly
    Box buttonbox = Box.createHorizontalBox();
    buttonbox.add(Box.createHorizontalGlue()); // stretchy space
    buttonbox.add(new JButton("Okay"));
    buttonbox.add(Box.createHorizontalGlue()); // stretchy space
    buttonbox.add(new JButton("Cancel"));
    buttonbox.add(Box.createHorizontalGlue()); // stretchy space
    buttonbox.add(new JButton("Help"));
    buttonbox.add(Box.createHorizontalGlue()); // stretchy space
    this.add(buttonbox, BorderLayout.SOUTH);

    // Create a component to display in the center of the panel
    JTextArea textarea = new JTextArea();
    textarea.setText("This component has 12-pixel margins on left and top"
            + " and has 72-pixel margins on right and bottom.");
    textarea.setLineWrap(true);
    textarea.setWrapStyleWord(true);

    // Use Box objects to give the JTextArea an unusual spacing
    // First, create a column with 3 kids. The first and last kids
    // are rigid spaces. The middle kid is the text area
    Box fixedcol = Box.createVerticalBox();
    fixedcol.add(Box.createVerticalStrut(12)); // 12 rigid pixels
    fixedcol.add(textarea); // Component fills in the rest
    fixedcol.add(Box.createVerticalStrut(72)); // 72 rigid pixels

    // Now create a row. Give it rigid spaces on the left and right,
    // and put the column from above in the middle.
    Box fixedrow = Box.createHorizontalBox();
    fixedrow.add(Box.createHorizontalStrut(12));
    fixedrow.add(fixedcol);
    fixedrow.add(Box.createHorizontalStrut(72));

    // Now add the JTextArea in the column in the row to the panel
    this.add(fixedrow, BorderLayout.CENTER);
}

From source file:SplashScreen.java

public void showSplash() {
    JPanel content = (JPanel) getContentPane();
    content.setBackground(Color.white);

    // Set the window's bounds, centering the window
    int width = 450;
    int height = 115;
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (screen.width - width) / 2;
    int y = (screen.height - height) / 2;
    setBounds(x, y, width, height);//from   w ww.  j av a  2  s  .c  o m

    // Build the splash screen
    JLabel label = new JLabel(new ImageIcon("1.gif"));
    JLabel copyrt = new JLabel("Copyright 2002, O'Reilly & Associates", JLabel.CENTER);
    copyrt.setFont(new Font("Sans-Serif", Font.BOLD, 12));
    content.add(label, BorderLayout.CENTER);
    content.add(copyrt, BorderLayout.SOUTH);
    Color oraRed = new Color(156, 20, 20, 255);
    content.setBorder(BorderFactory.createLineBorder(oraRed, 10));

    // Display it
    setVisible(true);

    // Wait a little while, maybe while loading resources
    try {
        Thread.sleep(duration);
    } catch (Exception e) {
    }

    setVisible(false);
}

From source file:de.hs.mannheim.modUro.diagram.JCellCountDiagram.java

protected JFreeChart createChart(XYDataset dataset, String name) {
    String title = name;/*from  www.j  av 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;
}