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:unalcol.termites.boxplots.ECALMessages.java

/**
 * Creates a new demo.//from w  w  w.ja  v a 2s  . c  om
 *
 * @param title the frame title.
 * @param pf
 */
public ECALMessages(final String title, ArrayList<Double> pf) {

    super(title);

    final CategoryAxis xAxis = new CategoryAxis("");
    //final NumberAxis yAxis = new NumberAxis("Messages Sent");
    final NumberAxis yAxis = new NumberAxis("");

    yAxis.setAutoRangeIncludesZero(false);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf, renderer);
    renderer.setFillBox(false);
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    Font font = new Font("Dialog", Font.PLAIN, 13);
    xAxis.setTickLabelFont(font);
    yAxis.setTickLabelFont(font);
    yAxis.setLabelFont(font);

    final JFreeChart chart = new JFreeChart("Messages Sent " + getTitle(pf),
            new Font("SansSerif", Font.BOLD, 18), plot, true);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(650, 370));
    setContentPane(chartPanel);
    TextTitle legendText = null;
    if (pf.size() == 1) {
        legendText = new TextTitle("Population Size");
    } else {
        legendText = new TextTitle("Population Size - Probability of Failure");
    }
    legendText.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legendText);

    LegendTitle legend = chart.getLegend();
    legend.setPadding(new RectangleInsets(UnitType.RELATIVE, 0, 0.1, 0, 0));

    FileOutputStream output;
    try {
        output = new FileOutputStream("messagesECAL" + pf + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 670, 250, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(ECALMessages.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(ECALMessages.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:unalcol.termites.boxplots.MessagesSent2.java

/**
 * Creates a new demo.//from  w  ww  .  j a  v  a 2s . c  o  m
 *
 * @param title the frame title.
 * @param pf
 */
public MessagesSent2(final String title, ArrayList<Double> pf) {

    super(title);

    final CategoryAxis xAxis = new CategoryAxis("");
    //final NumberAxis yAxis = new NumberAxis("Messages Sent");
    final NumberAxis yAxis = new NumberAxis("");

    yAxis.setAutoRangeIncludesZero(false);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf, renderer);
    renderer.setFillBox(false);
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    Font font = new Font("Dialog", Font.PLAIN, 13);
    xAxis.setTickLabelFont(font);
    yAxis.setTickLabelFont(font);
    yAxis.setLabelFont(font);

    final JFreeChart chart = new JFreeChart("Messages Sent " + getTitle(pf),
            new Font("SansSerif", Font.BOLD, 18), plot, true);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(650, 370));
    setContentPane(chartPanel);
    TextTitle legendText = null;
    if (pf.size() == 1) {
        legendText = new TextTitle("Population Size");
    } else {
        legendText = new TextTitle("Population Size - Probability of Failure");
    }
    legendText.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legendText);

    LegendTitle legend = chart.getLegend();
    legend.setPadding(new RectangleInsets(UnitType.RELATIVE, 0, 0.1, 0, 0));

    FileOutputStream output;
    try {
        output = new FileOutputStream("messagesnumber2" + pf + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 670, 250, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(MessagesSent2.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(MessagesSent2.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.game.ui.views.WeaponEditorPanel.java

public void doGui() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JLabel noteLbl = new JLabel(
            "<html><div style='width : 500px;'>Pls select a value to choose an Weapon or you can create a new "
                    + "Weapon entity below. Once selected a weapon, its' details will be available below</div></html>");
    noteLbl.setAlignmentX(0);/*from   ww w .  ja va2 s .  c om*/
    add(noteLbl);
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (Item item : GameBean.weaponDetails) {
        if (item instanceof Weapon) {
            model.addElement(((Weapon) item).getName());
        }
    }
    comboBox = new JComboBox(model);
    comboBox.setSelectedIndex(-1);
    comboBox.setMaximumSize(new Dimension(100, 30));
    comboBox.setAlignmentX(0);
    comboBox.setActionCommand("dropDown");
    comboBox.addActionListener(this);
    add(Box.createVerticalStrut(10));
    add(comboBox);
    add(Box.createVerticalStrut(10));
    JPanel panel1 = new JPanel();
    panel1.setAlignmentX(0);
    panel1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel1.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(5, 5, 5, 5);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 2;
    JLabel weaponDtsLbl = new JLabel("Weapon Details : ");
    weaponDtsLbl.setFont(new Font("Times New Roman", Font.BOLD, 15));
    panel1.add(weaponDtsLbl, c);
    c.gridwidth = 1;
    c.gridy = 1;
    JLabel nameLbl = new JLabel("Name : ");
    panel1.add(nameLbl, c);
    c.gridx = 1;
    JTextField name = new JTextField("");
    name.setColumns(20);
    panel1.add(name, c);
    c.gridx = 0;
    c.gridy = 2;
    JLabel weaponTypeLbl = new JLabel("Weapon Type : ");
    panel1.add(weaponTypeLbl, c);
    c.gridx = 1;
    JComboBox weaponType = new JComboBox(Configuration.weaponTypes);
    weaponType.setSelectedIndex(0);
    weaponType.setPreferredSize(name.getPreferredSize());
    System.out.println(name.getPreferredSize());
    panel1.add(weaponType, c);
    c.gridx = 0;
    c.gridy = 3;
    JLabel attackRangeLbl = new JLabel("Attack Range : ");
    panel1.add(attackRangeLbl, c);
    c.gridx = 1;
    JTextField attackRange = new JTextField("");
    attackRange.setColumns(20);
    panel1.add(attackRange, c);
    c.gridx = 0;
    c.gridy = 4;
    JLabel attackPtsLbl = new JLabel("Attack Points : ");
    panel1.add(attackPtsLbl, c);
    c.gridx = 1;
    JTextField attackPts = new JTextField("");
    attackPts.setColumns(20);
    panel1.add(attackPts, c);
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 2;
    JButton submit = new JButton("Save");
    submit.addActionListener(this);
    submit.setActionCommand("button");
    panel1.add(submit, c);
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 2;
    c.weighty = 0;
    c.weightx = 1;
    validationMess = new JLabel("Pls enter all the fields or pls choose a weapon from the drop down");
    validationMess.setForeground(Color.red);
    validationMess.setVisible(false);
    panel1.add(validationMess, c);
    //        c.fill = GridBagConstraints.BOTH;
    //        c.gridy = 7;
    //        c.weightx = 1;
    //        c.weighty = 1;
    //        panel1.add(new JLabel(""), c);
    panel1.setBorder(LineBorder.createGrayLineBorder());
    add(panel1);
    add(Box.createVerticalGlue());
}

From source file:it.alus.GPSreceiver.instruments.Variometer.java

public Variometer() {
    super(null);//ww w  . j a va2  s  .c  o m
    dataset = new DefaultValueDataset(0.0);
    DialPlot plot = new DialPlot();
    plot.setView(0.0, 0.0, 1.0, 1.0);
    plot.setDataset(0, dataset);
    StandardDialFrame dialFrame = new StandardDialFrame();
    dialFrame.setBackgroundPaint(Color.lightGray);
    dialFrame.setForegroundPaint(Color.gray);
    DialTextAnnotation titleLabel = new DialTextAnnotation("Vertical speed");
    titleLabel.setFont(new Font("Arial", 1, 18));
    titleLabel.setRadius(0.45D);
    titleLabel.setAngle(90);
    titleLabel.setPaint(Color.lightGray);
    plot.addLayer(titleLabel);
    DialTextAnnotation unitLabel = new DialTextAnnotation("100 Ft/min");
    unitLabel.setFont(new Font("Arial", 1, 18));
    unitLabel.setRadius(0.3D);
    unitLabel.setAngle(90);
    unitLabel.setPaint(Color.white);
    plot.addLayer(unitLabel);
    DialValueIndicator valueindicator = new DialValueIndicator(0);
    plot.addLayer(valueindicator);
    DialTextAnnotation annotation = new DialTextAnnotation("Ft/min");
    annotation.setFont(new Font("Arial", 1, 14));
    annotation.setRadius(0.4D);
    annotation.setPaint(Color.lightGray);
    plot.addLayer(annotation);
    plot.setDialFrame(dialFrame);
    StandardDialScale realScale = new StandardDialScale(-3000, 3000, -10, -340, 100, 10);
    realScale.setVisible(false);
    plot.addScale(0, realScale);
    StandardDialScale dispScale = new StandardDialScale(-30, 30, -10, -340, 5, 10);
    dispScale.setMajorTickPaint(Color.white);
    dispScale.setMinorTickPaint(Color.lightGray);
    dispScale.setFirstTickLabelVisible(true);
    dispScale.setTickRadius(0.88);
    dispScale.setTickLabelOffset(0.15);
    NumberFormat formatter = new DecimalFormat("#");
    dispScale.setTickLabelFormatter(formatter);
    dispScale.setTickLabelFont(new Font("Arial", Font.BOLD, 24));
    dispScale.setTickLabelPaint(Color.white);
    plot.addScale(1, dispScale);
    plot.setBackground(new DialBackground(Color.black));
    Pointer needle = new Pointer(0);
    needle.setFillPaint(Color.white);
    plot.addLayer(needle);
    plot.mapDatasetToScale(1, 1);
    DialCap cap = new DialCap();
    cap.setRadius(0.10);
    cap.setFillPaint(Color.gray);
    plot.setCap(cap);
    jChart = new JFreeChart(plot);
    super.setChart(jChart);
    super.setPreferredSize(new Dimension(400, 400));
}

From source file:PieChartDemo1.java

/**
 * Creates a chart./*from  www. java 2 s  .c o m*/
 *
 * @param dataset  the dataset.
 *
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset) {

    JFreeChart chart = ChartFactory.createPieChart("Smart Phones Manufactured / Q3 2011", // chart title
            dataset, // data
            false, // no legend
            true, // tooltips
            false // no URL generation
    );

    // set a custom background for the chart
    chart.setBackgroundPaint(
            new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY));

    // customise the title position and font
    TextTitle t = chart.getTitle();
    t.setHorizontalAlignment(HorizontalAlignment.LEFT);
    t.setPaint(new Color(240, 240, 240));
    t.setFont(new Font("Arial", Font.BOLD, 26));

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setInteriorGap(0.04);
    plot.setOutlineVisible(false);

    // use gradients and white borders for the section colours
    plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE));
    plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED));
    plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN));
    plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW));
    plot.setBaseSectionOutlinePaint(Color.WHITE);
    plot.setSectionOutlinesVisible(true);
    plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f));

    // customise the section label appearance
    plot.setLabelFont(new Font("Courier New", Font.BOLD, 20));
    plot.setLabelLinkPaint(Color.WHITE);
    plot.setLabelLinkStroke(new BasicStroke(2.0f));
    plot.setLabelOutlineStroke(null);
    plot.setLabelPaint(Color.WHITE);
    plot.setLabelBackgroundPaint(null);

    // add a subtitle giving the data source
    TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523",
            new Font("Courier New", Font.PLAIN, 12));
    source.setPaint(Color.WHITE);
    source.setPosition(RectangleEdge.BOTTOM);
    source.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.addSubtitle(source);
    return chart;

}

From source file:playground.anhorni.surprice.analysis.SupriceBoxPlot.java

public JFreeChart createChart() {
    String title = chartTitle;/* www . ja v  a 2  s .  com*/

    final CategoryAxis xAxis = new CategoryAxis(this.xAxisName);
    xAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 10));
    xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    final NumberAxis yAxis = new NumberAxis(this.yAxisName);
    yAxis.setAutoRangeIncludesZero(true);

    if (Math.abs(yrangeLower - yrangeUpper) > Double.MIN_VALUE) {
        yAxis.setRange(yrangeLower, yrangeUpper);
    }

    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setSeriesPaint(0, Color.blue);
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false);
    return this.chart_;
}

From source file:org.codehaus.mojo.dashboard.report.plugin.chart.StackedBarChartRenderer.java

/**
 * //from   w  w w .  jav a2  s.c o  m
 */
public void createChart() {

    CategoryDataset categorydataset = (CategoryDataset) this.datasetStrategy.getDataset();
    report = ChartFactory.createStackedBarChart(this.datasetStrategy.getTitle(),
            this.datasetStrategy.getYAxisLabel(), this.datasetStrategy.getXAxisLabel(), categorydataset,
            PlotOrientation.HORIZONTAL, true, true, false);
    // report.setBackgroundPaint( Color.lightGray );
    report.setAntiAlias(false);
    report.setPadding(new RectangleInsets(5.0d, 5.0d, 5.0d, 5.0d));
    CategoryPlot categoryplot = (CategoryPlot) report.getPlot();
    categoryplot.setBackgroundPaint(Color.white);
    categoryplot.setRangeGridlinePaint(Color.lightGray);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    if (datasetStrategy instanceof CloverBarChartStrategy
            || datasetStrategy instanceof MultiCloverBarChartStrategy) {
        numberaxis.setRange(0.0D, StackedBarChartRenderer.NUMBER_AXIS_RANGE);
        numberaxis.setNumberFormatOverride(NumberFormat.getPercentInstance());
    } else {
        numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    }
    numberaxis.setLowerMargin(0.0D);
    StackedBarRenderer stackedbarrenderer = (StackedBarRenderer) categoryplot.getRenderer();
    stackedbarrenderer.setDrawBarOutline(false);
    stackedbarrenderer.setBaseItemLabelsVisible(true);
    stackedbarrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    stackedbarrenderer.setBaseItemLabelFont(StackedBarRenderer.DEFAULT_VALUE_LABEL_FONT.deriveFont(Font.BOLD));
    int height = (categorydataset.getColumnCount() * ChartUtils.STANDARD_BARCHART_ENTRY_HEIGHT * 2)
            + ChartUtils.STANDARD_BARCHART_ADDITIONAL_HEIGHT + 10;
    if (height > ChartUtils.MINIMUM_HEIGHT) {
        super.setHeight(height);
    } else {
        super.setHeight(ChartUtils.MINIMUM_HEIGHT);
    }
    Paint[] paints = this.datasetStrategy.getPaintColor();

    for (int i = 0; i < categorydataset.getRowCount() && i < paints.length; i++) {
        stackedbarrenderer.setSeriesPaint(i, paints[i]);
    }

}

From source file:com.neophob.sematrix.core.generator.Textwriter.java

/**
 * Instantiates a new textwriter.//from   w w w .ja v  a 2s. c o  m
 *
 * @param controller the controller
 * @param fontName the font name
 * @param fontSize the font size
 * @param text the text
 */
public Textwriter(MatrixData matrix, String fontName, int fontSize, FileUtils fu) {
    super(matrix, GeneratorName.TEXTWRITER, ResizeName.PIXEL_RESIZE);
    String filename = fu.getDataDir() + File.separator + fontName;
    InputStream is = null;
    try {
        is = new FileInputStream(filename);
        textAsImage = new int[internalBuffer.length];
        font = Font.createFont(Font.TRUETYPE_FONT, is).deriveFont(Font.BOLD, (float) fontSize);
        LOG.log(Level.INFO, "Loaded font " + fontName + ", size: " + fontSize);
    } catch (Exception e) {
        LOG.log(Level.WARNING, "Failed to load font " + filename + ":", e);
        throw new IllegalArgumentException(
                "Failed to load font " + filename + ". Check your config.properties file.");
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
                LOG.log(Level.WARNING, "Failed to close InputStream.", e);
            }
        }
    }
    createTextImage(INITIAL_STRING);
    scroller = new PingPongScroller();
}

From source file:smellminer.engine.JFreeChartDemo.java

/**
 * Creates a new demo./* w w  w  .ja va  2s .c  o  m*/
 *
 * @param title  the frame title.
 */
public JFreeChartDemo(final String title) {

    super(title);

    final BoxAndWhiskerCategoryDataset dataset = createSampleDataset();

    final CategoryAxis xAxis = new CategoryAxis("Type");
    final NumberAxis yAxis = new NumberAxis("Value");
    yAxis.setAutoRangeIncludesZero(false);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    final JFreeChart chart = new JFreeChart("Box-and-Whisker Demo", new Font("SansSerif", Font.BOLD, 14), plot,
            true);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(450, 270));
    setContentPane(chartPanel);

}

From source file:net.sf.jasperreports.engine.util.JRFontUtil.java

/**
 * Fills the supplied Map parameter with attributes copied from the JRFont parameter.
 * The attributes include the TextAttribute.FONT, which has a java.awt.Font object as value.
 * @deprecated Replaced by {@link #getAttributesWithoutAwtFont(Map, JRFont)}.
 *///w ww  .j  av  a2s  .c o  m
public static Map<Attribute, Object> getAttributes(Map<Attribute, Object> attributes, JRFont font,
        Locale locale) {
    //Font awtFont = getAwtFont(font);//FIXMEFONT optimize so that we don't load the AWT font for all exporters.
    Font awtFont = getAwtFontFromBundles(font.getFontName(),
            ((font.isBold() ? Font.BOLD : Font.PLAIN) | (font.isItalic() ? Font.ITALIC : Font.PLAIN)),
            font.getFontSize(), locale, true);
    if (awtFont != null) {
        attributes.put(TextAttribute.FONT, awtFont);
    }

    getAttributesWithoutAwtFont(attributes, font);

    return attributes;
}