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:org.pentaho.plugin.jfreereport.reportcharts.CategoricalChartExpressionTest.java

private static Font createFont() {
    return new Font("Arial", Font.PLAIN, 12);
}

From source file:Chart.java

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

   // compute the minimum and maximum values
   if (values == null) return;
   double minValue = 0;
   double maxValue = 0;
   for (double v : values)
   {/*from  w w  w.  j  ava  2  s  .  co  m*/
      if (minValue > v) minValue = v;
      if (maxValue < v) maxValue = v;
   }
   if (maxValue == minValue) return;

   int panelWidth = getWidth();
   int panelHeight = getHeight();

   Font titleFont = new Font("SansSerif", Font.BOLD, 20);
   Font labelFont = new Font("SansSerif", Font.PLAIN, 10);

   // compute the extent of the title
   FontRenderContext context = g2.getFontRenderContext();
   Rectangle2D titleBounds = titleFont.getStringBounds(title, context);
   double titleWidth = titleBounds.getWidth();
   double top = titleBounds.getHeight();

   // draw the title
   double y = -titleBounds.getY(); // ascent
   double x = (panelWidth - titleWidth) / 2;
   g2.setFont(titleFont);
   g2.drawString(title, (float) x, (float) y);

   // compute the extent of the bar labels
   LineMetrics labelMetrics = labelFont.getLineMetrics("", context);
   double bottom = labelMetrics.getHeight();

   y = panelHeight - labelMetrics.getDescent();
   g2.setFont(labelFont);

   // get the scale factor and width for the bars
   double scale = (panelHeight - top - bottom) / (maxValue - minValue);
   int barWidth = panelWidth / values.length;

   // draw the bars
   for (int i = 0; i < values.length; i++)
   {
      // get the coordinates of the bar rectangle
      double x1 = i * barWidth + 1;
      double y1 = top;
      double height = values[i] * scale;
      if (values[i] >= 0) y1 += (maxValue - values[i]) * scale;
      else
      {
         y1 += maxValue * scale;
         height = -height;
      }

      // fill the bar and draw the bar outline
      Rectangle2D rect = new Rectangle2D.Double(x1, y1, barWidth - 2, height);
      g2.setPaint(Color.RED);
      g2.fill(rect);
      g2.setPaint(Color.BLACK);
      g2.draw(rect);

      // draw the centered label below the bar
      Rectangle2D labelBounds = labelFont.getStringBounds(names[i], context);

      double labelWidth = labelBounds.getWidth();
      x = x1 + (barWidth - labelWidth) / 2;
      g2.drawString(names[i], (float) x, (float) y);
   }
}

From source file:edu.ucla.stat.SOCR.chart.demo.RingChartDemo1.java

/**
 * Creates a chart./*from   ww  w  . jav a 2s .  c  om*/
 * 
 * @param dataset  the dataset.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(PieDataset dataset) {

    JFreeChart chart = ChartFactory.createRingChart(chartTitle, // chart title
            dataset, // data
            !legendPanelOn, // include legend
            true, false);

    RingPlot plot = (RingPlot) chart.getPlot();
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    for (int i = 0; i < pulloutFlag.length; i++) {
        //System.out.println("\""+pulloutFlag[i]+"\"");
        if (isPullout(i)) {
            Comparable key = dataset.getKey(i);
            plot.setExplodePercent(key, 0.30);
        }
    }

    if (rotateOn) {
        Rotator rotator = new Rotator(plot);
        rotator.start();
    }

    setCategorySummary(dataset);
    return chart;

}

From source file:netplot.DialPlotPanel.java

public void addPlot() throws NetPlotException {
    chart.setTitle(plotTitle);/*from   w  w w.  j a  v a 2 s.co  m*/

    DialTextAnnotation annotation = new DialTextAnnotation(plotName);
    annotation.setFont(new Font("Dialog", Font.BOLD, 14));
    if (plotCount == 0) {
        DialValueIndicator dvi = new DialValueIndicator(0);
        dvi.setFont(new Font("Dialog", Font.PLAIN, 10));
        annotation.setRadius(0.7);
        annotation.setPaint(DialPlotPanel.Plot0Color);
        dvi.setRadius(0.60);
        dvi.setAngle(-103.0);
        dvi.setOutlinePaint(DialPlotPanel.Plot0Color);

        StandardDialScale scale = new StandardDialScale(minScaleValue, maxScaleValue, -120, -300,
                yAxisTickCount, yAxisTickCount / 2 - 1);
        scale.setTickRadius(0.88);
        scale.setTickLabelOffset(0.15);
        scale.setTickLabelFont(new Font("Dialog", Font.PLAIN, 14));
        plot.addScale(0, scale);
        plot.mapDatasetToScale(0, 0);

        DialPointer.Pointer p = new DialPointer.Pointer(0);
        p.setFillPaint(DialPlotPanel.Plot0Color);
        plot.addPointer(p);

        plot.addLayer(annotation);
        plot.addLayer(dvi);

    } else if (plotCount == 1) {
        annotation.setRadius(0.8);
        annotation.setPaint(DialPlotPanel.Plot1Color);
        DialValueIndicator dvi = new DialValueIndicator(1);
        dvi.setFont(new Font("Dialog", Font.PLAIN, 10));
        dvi.setRadius(0.60);
        dvi.setAngle(-77.0);
        dvi.setOutlinePaint(DialPlotPanel.Plot1Color);

        StandardDialScale scale2 = new StandardDialScale(minScaleValue, maxScaleValue, -120, -300,
                yAxisTickCount, yAxisTickCount / 2 - 1);
        scale2.setTickRadius(0.50);
        scale2.setTickLabelOffset(0.15);
        scale2.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10));
        scale2.setMajorTickPaint(DialPlotPanel.Plot1Color);
        plot.addScale(1, scale2);
        plot.mapDatasetToScale(1, 1);

        DialPointer.Pointer p = new DialPointer.Pointer(1);
        p.setFillPaint(DialPlotPanel.Plot1Color);
        p.setRadius(0.55);
        plot.addPointer(p);

        plot.addLayer(annotation);
        plot.addLayer(dvi);

    } else {
        throw new NetPlotException(
                "DialPlotPanel.addPlot(). Only two plots available on this plot, this is the third.");
    }

    plotCount++;
}

From source file:com.univocity.app.swing.DataAnalysisWindow.java

private TableSearchField getSearchField() {
    if (searchField == null) {
        searchField = new TableSearchField();
        searchField.addTable(getDataAnalysisPanel().getSourceTable().getDataTable());
        searchField.addTable(getDataAnalysisPanel().getDestinationTable().getDataTable());
        searchField.setFont(new Font("Arial", Font.PLAIN, 10));
    }//from ww w  .ja  va 2s .  c  o m
    return searchField;
}

From source file:ActionExampleSwing.java

public ActionExampleSwing() {
    super("ActionExample Swing");

    setChannel(currentChannel); // enable/disable the Actions as appropriate

    channelLabel.setHorizontalAlignment(JLabel.CENTER);
    channelLabel.setFont(new Font("Serif", Font.PLAIN, 32));

    getContentPane().add(channelLabel, BorderLayout.NORTH);

    JPanel buttonPanel = new JPanel(new GridLayout(2, 2, 16, 6));
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(6, 16, 16, 16));
    getContentPane().add(buttonPanel, BorderLayout.CENTER);
    buttonPanel.add(new JButton(upAction));
    buttonPanel.add(new JButton(gotoFavoriteAction));
    buttonPanel.add(new JButton(downAction));
    buttonPanel.add(new JButton(setFavoriteAction));

    JMenuBar mb = new JMenuBar();
    JMenu menu = new JMenu("Channel");
    menu.add(new JMenuItem(upAction));
    menu.add(new JMenuItem(downAction));
    menu.addSeparator();/*from w  ww .  j  a v  a  2 s.c  o m*/
    menu.add(new JMenuItem(gotoFavoriteAction));
    menu.add(new JMenuItem(setFavoriteAction));
    mb.add(menu);
    setJMenuBar(mb);
}

From source file:org.sakaiproject.evaluation.tool.reporting.EvalLikertChartBuilder.java

@SuppressWarnings("deprecation")
public JFreeChart makeLikertChart() {

    DefaultCategoryDataset likertDataset = new DefaultCategoryDataset();

    for (int i = 0; i < responses.length; i++) {
        likertDataset.addValue(values[i], "Responses", responses[i]);
    }// w  ww.  j  ava  2s.co m

    JFreeChart chart = ChartFactory.createBarChart(null, // "Likert Chart", // Chart title
            null, // "Choices", // domain axis label
            null, // "# of Responses", // range axis label
            likertDataset, PlotOrientation.HORIZONTAL, false, // show legend
            false, // show tooltips
            false // show URLs
    );

    // Set the background colours
    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);

    // Configure the bar colors and display
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setSeriesPaint(0, new Color(244, 252, 212));
    renderer.setDrawBarOutline(true);
    renderer.setOutlinePaint(new Color(34, 35, 237));
    renderer.setOutlineStroke(new BasicStroke(0.5f));
    renderer.setBaseItemLabelsVisible(true);
    if (showPercentages) {
        renderer.setBaseItemLabelGenerator(new LikertPercentageItemLabelGenerator(this.responseCount));
    } else {
        renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    }
    // Turn off the Top Value Axis
    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setVisible(false);
    rangeAxis.setUpperMargin(0.35);
    rangeAxis.resizeRange(1.1f);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setMaximumCategoryLabelWidthRatio(0.4f);
    domainAxis.setMaximumCategoryLabelLines(2);

    // Set the font for the labels
    Font labelFont = new Font("Serif", Font.PLAIN, 6);

    CategoryItemRenderer itemRenderer = plot.getRenderer();
    itemRenderer.setBaseItemLabelFont(labelFont);

    plot.setOutlinePaint(null);

    domainAxis.setLabelFont(labelFont);
    domainAxis.setTickLabelFont(labelFont);
    rangeAxis.setLabelFont(labelFont);
    rangeAxis.setTickLabelFont(labelFont);

    return chart;
}

From source file:logdruid.ui.table.EventRecordingEditorTable.java

/**
 * @wbp.parser.constructor//from w  ww.ja  va 2  s.  c om
 */
@SuppressWarnings("unchecked")
public EventRecordingEditorTable(JTextPane textPane) {
    super(new GridLayout(1, 0));

    model = new MyTableModel(data, header);
    table = new JTable(model);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setFont(new Font("SansSerif", Font.PLAIN, 11));
    // table.setPreferredScrollableViewportSize(new Dimension(500, 200));
    table.setPreferredScrollableViewportSize(table.getPreferredSize());
    table.setFillsViewportHeight(true);

    this.theLine = textPane.getText();
    this.examplePane = textPane;
    // Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    // Set up column sizes.
    initColumnSizes(table);

    // Fiddle with the type and processing column's cell editors/renderers.
    setUpTypeColumn(table, table.getColumnModel().getColumn(2));
    setUpProcessingColumn(table, table.getColumnModel().getColumn(3));

    // Add the scroll pane to this panel.
    add(scrollPane);
    Add();
    FixValues();

}

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)}.
 *//*from   www .j a va2 s.  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;
}

From source file:com.anji.floatingeye.FloatingEyeDisplay.java

private void init(Java2DSurface surface, FloatingEye anEye) {
    eye = anEye;/* ww  w  .  j av  a  2s.c  o  m*/

    // this frame has 3 sections - status, surface canvas, and eye canvas
    addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {
            setVisible(false);
            dispose();
        }
    });
    GridLayout mainLayout = new GridLayout(2, 1);
    mainLayout.setHgap(10);
    mainLayout.setVgap(10);
    getContentPane().setLayout(mainLayout);
    GridLayout topPanelLayout = new GridLayout(2, 1);
    topPanelLayout.setHgap(10);
    topPanelLayout.setVgap(10);
    Panel topPanel = new Panel(topPanelLayout);
    GridLayout bottomPanelLayout = new GridLayout(1, 2);
    bottomPanelLayout.setHgap(10);
    bottomPanelLayout.setVgap(10);
    Panel bottomPanel = new Panel(bottomPanelLayout);

    // 1 - status area
    statusArea = new TextArea("", 1, 1, TextArea.SCROLLBARS_VERTICAL_ONLY);
    statusArea.setEditable(false);
    statusArea.setFont(new Font("Dialog", Font.PLAIN, 10));
    statusArea.setSize(new Dimension(IMG_WIDTH * 2, IMG_HEIGHT / 2));

    // 2 - affinity history chart
    XYSeriesCollection seriesCollection = new XYSeriesCollection(affinitySeries);
    JFreeChart chart = ChartFactory.createXYLineChart("affinity history", "step", "affinity", seriesCollection,
            PlotOrientation.VERTICAL, false, false, false);
    ValueAxis rangeAxis = chart.getXYPlot().getRangeAxis();
    rangeAxis.setAutoRange(false);
    rangeAxis.setRange(0d, 1d);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(IMG_WIDTH * 2, IMG_HEIGHT / 2));

    // 3 - surface canvas
    surfaceCanvas = new SurfaceCanvas(surface, eye, IMG_WIDTH, IMG_HEIGHT);
    surfaceCanvas.setBackground(Color.WHITE);

    // 4 - eye canvas
    eyeCanvas = new EyeCanvas(eye, IMG_WIDTH, IMG_HEIGHT);
    eyeCanvas.setBackground(Color.WHITE);

    topPanel.add(statusArea);
    topPanel.add(chartPanel);
    bottomPanel.add(surfaceCanvas);
    bottomPanel.add(eyeCanvas);
    getContentPane().add(topPanel);
    getContentPane().add(bottomPanel);

    pack();
}