Example usage for java.awt Font PLAIN

List of usage examples for java.awt Font PLAIN

Introduction

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

Prototype

int PLAIN

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

Click Source Link

Document

The plain style constant.

Usage

From source file:ToolbarDemo.java

public ToolbarDemo() {
    super("Toolbars & actions");
    setSize(450, 350);/* w  w w  . j a va 2 s .com*/

    fonts = new Font[FontNames.length];
    for (int i = 0; i < FontNames.length; i++)
        fonts[i] = new Font(FontNames[i], Font.PLAIN, 12);

    JMenuBar menuBar = createMenuBar();
    setJMenuBar(menuBar);

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);

    updateMonitor();
    setVisible(true);
}

From source file:ChartPanel.java

public void paintComponent(Graphics g) {
    super.paintComponent(g);
    if (values == null || values.length == 0)
        return;//w  w  w  .j  av  a 2s .co m
    double minValue = 0;
    double maxValue = 0;
    for (int i = 0; i < values.length; i++) {
        if (minValue > values[i])
            minValue = values[i];
        if (maxValue < values[i])
            maxValue = values[i];
    }

    Dimension d = getSize();
    int clientWidth = d.width;
    int clientHeight = d.height;
    int barWidth = clientWidth / values.length;

    Font titleFont = new Font("SansSerif", Font.BOLD, 20);
    FontMetrics titleFontMetrics = g.getFontMetrics(titleFont);
    Font labelFont = new Font("SansSerif", Font.PLAIN, 10);
    FontMetrics labelFontMetrics = g.getFontMetrics(labelFont);

    int titleWidth = titleFontMetrics.stringWidth(title);
    int y = titleFontMetrics.getAscent();
    int x = (clientWidth - titleWidth) / 2;
    g.setFont(titleFont);
    g.drawString(title, x, y);

    int top = titleFontMetrics.getHeight();
    int bottom = labelFontMetrics.getHeight();
    if (maxValue == minValue)
        return;
    double scale = (clientHeight - top - bottom) / (maxValue - minValue);
    y = clientHeight - labelFontMetrics.getDescent();
    g.setFont(labelFont);

    for (int i = 0; i < values.length; i++) {
        int valueX = i * barWidth + 1;
        int valueY = top;
        int height = (int) (values[i] * scale);
        if (values[i] >= 0)
            valueY += (int) ((maxValue - values[i]) * scale);
        else {
            valueY += (int) (maxValue * scale);
            height = -height;
        }

        g.setColor(Color.red);
        g.fillRect(valueX, valueY, barWidth - 2, height);
        g.setColor(Color.black);
        g.drawRect(valueX, valueY, barWidth - 2, height);
        int labelWidth = labelFontMetrics.stringWidth(names[i]);
        x = i * barWidth + (barWidth - labelWidth) / 2;
        g.drawString(names[i], x, y);
    }
}

From source file:cz.cuni.mff.ksi.jinfer.treeruledisplayer.logic.VertexFontTransformer.java

@Override
public Font transform(final Regexp<? extends AbstractNamedNode> regexp) {
    if (RegexpType.LAMBDA.equals(regexp.getType())) {
        return new Font(null, Font.BOLD, 20);
    }/*from  www . j  av  a2 s . c o  m*/

    return new Font(null, Font.PLAIN, 12);
}

From source file:FontComboBox.java

public void actionPerformed(ActionEvent evt) {
    JComboBox source = (JComboBox) evt.getSource();
    String item = (String) source.getSelectedItem();
    fontLabel.setFont(new Font(item, Font.PLAIN, 12));
}

From source file:MainClass.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    String s = "www.java2s.com";
    Font font = new Font("Serif", Font.PLAIN, 32);

    if (mTextLayout == null) {
        FontRenderContext frc = g2.getFontRenderContext();
        mTextLayout = new TextLayout(s, font, frc);
    }/*  w w  w . j av  a  2 s.  co  m*/

    mTextLayout.draw(g2, mX, mY);

}

From source file:no.imr.sea2data.guibase.chart.XYBarChart.java

public XYBarChart() {
    dataset = new XYSeriesCollection(new XYSeries("Series 1"));
    JFreeChart chart = ChartFactory.createXYBarChart("", "X axis", false, "Y axis", dataset,
            PlotOrientation.VERTICAL, false, true, false);
    chart.setBackgroundPaint(Color.white);
    chart.getTitle().setPaint(Color.black);
    chart.getTitle().setFont(new Font("SansSerif", Font.PLAIN, 12));
    chart.addSubtitle(trendLegend);//from   w ww .j a  v  a2 s. com
    chart.addSubtitle(trendLegend2);
    trendLegend.setPosition(RectangleEdge.TOP);
    trendLegend2.setPosition(RectangleEdge.TOP);
    plot = (XYPlot) chart.getPlot();
    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setShadowVisible(false);
    chartPanel = new ChartPanel(chart);
    plot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
}

From source file:grafix.graficos.eixos.EixoHorizontalComLabels.java

public EixoHorizontalComLabels(JanelaGraficos janela) {
    super(janela);
    this.acao = janela.getAcao();
    setTickLabelFont(new Font(Font.DIALOG, Font.PLAIN, 9));
    setAutoTickUnitSelection(true);/*from   ww  w  . j a  v a2  s .c o  m*/
}

From source file:Main.java

/** Set the font property of the given components.  Intended to reduce clutter in GUI code. */
public static void setFont(String name, int size, Component... components) {
    setFont(new Font(name, Font.PLAIN, size), components);
}

From source file:Main.java

@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    FontMetrics fm = g.getFontMetrics(font);
    wordWidth = fm.stringWidth(word);//from   w  w w .j  a  v a2s  .c o  m
    wordHeight = fm.getAscent();

    g.setFont(new Font("impact", Font.PLAIN, 28));
    g.setColor(Color.BLUE);
    g.drawString(word, x, y);
}

From source file:D20140128.ApacheXMLGraphicsTest.EPSColorsExample.java

/**
 * Creates an EPS file. The contents are painted using a Graphics2D
 * implementation that generates an EPS file.
 *
 * @param outputFile the target file/*from w ww.  j  a  v  a2  s.  c om*/
 * @throws IOException In case of an I/O error
 */
public static void generateEPSusingJava2D(File outputFile) throws IOException {
    OutputStream out = new java.io.FileOutputStream(outputFile);
    out = new java.io.BufferedOutputStream(out);
    try {
        //Instantiate the EPSDocumentGraphics2D instance
        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.
        Color colRGB = new Color(255, 204, 0);
        g2d.setColor(colRGB);
        g2d.fillRect(10, 30, 40, 40);

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

        //Try CIELab (not implemented, yet)
        CIELabColorSpace d50 = ColorSpaces.getCIELabColorSpaceD50();
        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)
        float[] c1xyz = d50.toCIEXYZNative(83.25f, 16.45f, 96.89f);
        NamedColorSpace postgelb = new NamedColorSpace("Postgelb", c1xyz);
        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);
    }
}