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:ui.Graph.java

/**
 * Creates a chart.//from w w  w.j av  a 2  s . c om
 *
 * @param dataset
 *            the data for the chart.
 *
 * @return a chart.
 */
private JFreeChart createChart(ArrayList<Setpoint> setpoints, ArrayList<Setpoint> traj) {
    trajectory = traj;

    XYSeries posSeries = new XYSeries("Position");
    XYSeries trajSeries = new XYSeries("Trajectory");
    XYSeries velSeries = new XYSeries("Velocity");
    for (int i = 0; i < setpoints.size(); i++) {

        Setpoint p = setpoints.get(i);
        posSeries.add(p.time, p.position);
        velSeries.add(p.time, p.velocity);
    }

    for (int i = 0; i < trajectory.size(); i++) {

        Setpoint p = trajectory.get(i);
        trajSeries.add(p.time, p.position);

    }

    XYSeriesCollection posDataset = new XYSeriesCollection();
    XYSeriesCollection trajDataset = new XYSeriesCollection();
    XYSeriesCollection velDataset = new XYSeriesCollection();

    posDataset.addSeries(posSeries);
    velDataset.addSeries(velSeries);
    trajDataset.addSeries(trajSeries);
    // create the chart...
    final JFreeChart chart = ChartFactory.createScatterPlot("System output", // chart title
            "X", // x axis label
            "Y", // y axis label
            posDataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);

    // final StandardLegend legend = (StandardLegend) chart.getLegend();
    // legend.setDisplaySeriesShapes(true);
    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();

    plot.setDataset(0, posDataset);
    plot.setDataset(1, trajDataset);
    plot.setDataset(2, velDataset);
    plot.setBackgroundPaint(Color.white);
    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    XYLineAndShapeRenderer posRenderer = new XYLineAndShapeRenderer();
    // renderer.setSeriesShape(0, new Ellipse2D.Float(1.0f, 1.0f, 1.0f,
    // 1.0f));
    posRenderer.setSeriesPaint(0, Color.BLUE);
    posRenderer.setSeriesLinesVisible(0, true);
    posRenderer.setSeriesShapesVisible(0, false);
    XYStepRenderer trajRenderer = new XYStepRenderer();
    trajRenderer.setSeriesPaint(1, Color.RED);
    trajRenderer.setSeriesStroke(1, new BasicStroke(10));
    trajRenderer.setSeriesLinesVisible(1, true);
    trajRenderer.setSeriesShapesVisible(1, false);

    XYLineAndShapeRenderer velRenderer = new XYLineAndShapeRenderer();
    velRenderer.setSeriesPaint(0, Color.MAGENTA);
    velRenderer.setSeriesLinesVisible(0, true);
    velRenderer.setSeriesShapesVisible(0, false);
    // renderer.setSeriesStroke(1, new BasicStroke(0.01f));
    plot.setRenderer(0, posRenderer);
    plot.setRenderer(1, trajRenderer);
    plot.setRenderer(2, velRenderer);

    for (Setpoint s : trajectory) {
        Marker marker = new ValueMarker(s.time);
        marker.setPaint(Color.DARK_GRAY);
        marker.setLabel(Float.toString((float) s.position));
        marker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
        marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
        plot.addDomainMarker(marker);
    }

    XYTextAnnotation p = new XYTextAnnotation("kP = " + gains.kP, plot.getDomainAxis().getUpperBound() * 0.125,
            plot.getRangeAxis().getUpperBound() * .75);
    p.setFont(new Font("Dialog", Font.PLAIN, 12));
    plot.addAnnotation(p);
    XYTextAnnotation i = new XYTextAnnotation("kI = " + gains.kI, plot.getDomainAxis().getUpperBound() * 0.125,
            plot.getRangeAxis().getUpperBound() * .7);
    i.setFont(new Font("Dialog", Font.PLAIN, 12));
    plot.addAnnotation(i);
    XYTextAnnotation d = new XYTextAnnotation("kD = " + gains.kD, plot.getDomainAxis().getUpperBound() * 0.125,
            plot.getRangeAxis().getUpperBound() * .65);
    d.setFont(new Font("Dialog", Font.PLAIN, 12));
    plot.addAnnotation(d);

    // change the auto tick unit selection to integer units only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRange(true);
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:org.jfree.chart.demo.SurveyResultsDemo3.java

/**
 * Creates a chart.//from w ww.jav a 2s .co m
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createBarChart(null, // chart title
            null, // domain axis label
            null, // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, // orientation
            false, // include legend
            true, false);

    chart.setBackgroundPaint(Color.white);
    chart.getPlot().setOutlinePaint(null);
    final TextTitle title = new TextTitle("Figure 6 | Overall SEO Rating");
    title.setHorizontalAlignment(HorizontalAlignment.LEFT);
    title.setBackgroundPaint(Color.red);
    title.setPaint(Color.white);

    chart.setTitle(title);
    final CategoryPlot plot = chart.getCategoryPlot();

    final ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setRange(0.0, 4.0);
    rangeAxis.setVisible(false);

    final ExtendedCategoryAxis domainAxis = new ExtendedCategoryAxis(null);
    domainAxis.setTickLabelFont(new Font("SansSerif", Font.BOLD, 12));
    domainAxis.setCategoryMargin(0.30);
    domainAxis.addSubLabel("Sm.", "(10)");
    domainAxis.addSubLabel("Med.", "(10)");
    domainAxis.addSubLabel("Lg.", "(10)");
    domainAxis.addSubLabel("All", "(10)");
    final CategoryLabelPositions p = domainAxis.getCategoryLabelPositions();
    final CategoryLabelPosition left = new CategoryLabelPosition(RectangleAnchor.LEFT,
            TextBlockAnchor.CENTER_LEFT);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.replaceLeftPosition(p, left));
    plot.setDomainAxis(domainAxis);

    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setSeriesPaint(0, new Color(0x9C, 0xA4, 0x4A));
    renderer.setBaseOutlineStroke(null);

    //        final StandardCategoryLabelGenerator generator = new StandardCategoryLabelGenerator(
    //          "{2}", new DecimalFormat("0.00")
    //    );
    //  renderer.setLabelGenerator(generator);
    renderer.setItemLabelsVisible(true);
    renderer.setItemLabelFont(new Font("SansSerif", Font.PLAIN, 18));
    final ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT);
    renderer.setPositiveItemLabelPosition(position);
    renderer.setPositiveItemLabelPositionFallback(new ItemLabelPosition());

    return chart;

}

From source file:org.jfree.eastwood.ChartEngine.java

/**
 * Creates and returns a new <code>JFreeChart</code> instance that
 * reflects the specified parameters (which should be equivalent to
 * a parameter map returned by HttpServletRequest.getParameterMap() for
 * a valid URI for the Google Chart API.
 *
 * @param params  the parameters (<code>null</code> not permitted).
 *
 * @return A chart corresponding to the specification in the supplied
 *         parameters.//from   w w  w.  j  a va2 s  . c om
 */
public static JFreeChart buildChart(Map params) {
    return buildChart(params, new Font("Dialog", Font.PLAIN, 12));
}

From source file:com.willwinder.universalgcodesender.uielements.panels.MachineStatusPanel.java

private void applyFont() {
    String fontPath = "/resources/";
    String fontName = "LED.ttf";
    InputStream is = getClass().getResourceAsStream(fontPath + fontName);
    Font font;/*from  w w w  .j a  v a  2 s. c  om*/
    Font big, small;

    try {
        font = Font.createFont(Font.TRUETYPE_FONT, is);
        big = font.deriveFont(Font.PLAIN, 30);
        small = font.deriveFont(Font.PLAIN, 18);
    } catch (Exception ex) {
        ex.printStackTrace();
        System.err.println(fontName + " not loaded.  Using serif font.");
        big = new Font("serif", Font.PLAIN, 24);
        small = new Font("serif", Font.PLAIN, 17);
    }

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    ge.registerFont(big);
    ge.registerFont(small);

    this.machinePositionXValue.setFont(small);
    this.machinePositionXValue.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
    this.machinePositionYValue.setFont(small);
    this.machinePositionYValue.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
    this.machinePositionZValue.setFont(small);
    this.machinePositionZValue.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);

    this.workPositionXValue.setFont(big);
    this.workPositionXValue.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
    this.workPositionYValue.setFont(big);
    this.workPositionYValue.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
    this.workPositionZValue.setFont(big);
    this.workPositionZValue.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
}

From source file:org.bench4Q.console.ui.section.S_SummarizeSection.java

/**
 * @return/*from ww  w . j  a  va2 s .  com*/
 * @throws IOException
 */
public JPanel drawSessionPic() throws IOException {

    CategoryDataset dataset = getDataSet();
    JFreeChart chart = ChartFactory.createBarChart3D("Session", "Session type", "Session number", dataset,
            PlotOrientation.VERTICAL, true, true, true);
    CategoryPlot plot = chart.getCategoryPlot();
    org.jfree.chart.axis.CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setLowerMargin(0.1);
    domainAxis.setUpperMargin(0.1);
    domainAxis.setCategoryLabelPositionOffset(10);
    domainAxis.setCategoryMargin(0.2);

    org.jfree.chart.axis.ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setUpperMargin(0.1);

    org.jfree.chart.renderer.category.BarRenderer3D renderer;
    renderer = new org.jfree.chart.renderer.category.BarRenderer3D();
    renderer.setBaseOutlinePaint(Color.red);
    renderer.setSeriesPaint(0, new Color(0, 255, 255));
    renderer.setSeriesOutlinePaint(0, Color.BLACK);
    renderer.setSeriesPaint(1, new Color(0, 255, 0));
    renderer.setSeriesOutlinePaint(1, Color.red);
    renderer.setItemMargin(0.1);

    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setItemLabelFont(new Font("", Font.PLAIN, 12));
    renderer.setItemLabelPaint(Color.black);
    renderer.setItemLabelsVisible(true);
    plot.setRenderer(renderer);

    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.setBackgroundPaint(Color.WHITE);

    return new ChartPanel(chart);
}

From source file:domainhealth.frontend.graphics.JFreeChartGraphImpl.java

/**
 * Check to see if current graph has empty chart lines (ie. no data-series
 * in any lines), and if so, write the text 'NO DATA' in large letters 
 * across the front of the graph/*from   ww w  .  j  a  va  2  s .  c o m*/
 * 
 * @param graphImage The current image representation of the generated graph
 */
@SuppressWarnings("unchecked")
private void addNoDataLogoIfEmpty(BufferedImage graphImage) {
    int maxStatCount = 0;
    List<XYSeries> seriesList = xySeriesCollection.getSeries();

    for (XYSeries series : seriesList) {
        maxStatCount = Math.max(maxStatCount, series.getItemCount());
    }

    if (maxStatCount <= 0) {
        Graphics2D graphics2D = get2DGraphics(graphImage);
        graphics2D.setFont(new Font(GRAPH_TEXT_FONT, Font.PLAIN, 36));
        graphics2D.drawString(NO_DATA_TEXT, 200, 210);
        graphics2D.dispose();
    } else if (maxStatCount <= 1) {
        Graphics2D graphics2D = get2DGraphics(graphImage);
        graphics2D.setFont(new Font(GRAPH_TEXT_FONT, Font.PLAIN, 22));
        graphics2D.drawString(WAITING_FOR_DATA_TEXT_LN1, 152, 205);
        graphics2D.dispose();
        graphics2D = get2DGraphics(graphImage);
        graphics2D.setFont(new Font(GRAPH_TEXT_FONT, Font.PLAIN, 15));
        graphics2D.drawString(WAITING_FOR_DATA_TEXT_LN2, 81, 225);
        graphics2D.dispose();
    }
}

From source file:ec.nbdemetra.benchmarking.calendarization.CalendarizationChartView.java

/**
 * Sets data to display on the graph. This method is used to add smoothed
 * and given periods data to the graph.//from   w ww. ja  v a  2 s .  c o  m
 *
 * @param days All the given periods
 * @param smooth Serie of calculated smoothed daily data
 * @param smoothDevs 2 smoothed data series : 1) smoothed data lowered by
 * the standard deviation and 2) smoothed data increased by the standard
 * deviation
 */
public void setData(TimeSeriesCollection days, TimeSeries smooth, TimeSeriesCollection smoothDevs) {
    XYPlot plot = chartPanel.getChart().getXYPlot();
    chartPanel.getChart().setTitle(new TextTitle("Smoothed Data", new Font("SansSerif", Font.PLAIN, 12)));

    plot.setDataset(DAILY_INDEX, days);
    plot.setDataset(SMOOTH_INDEX, new TimeSeriesCollection(smooth));
    plot.setDataset(DIFF_INDEX, smoothDevs);

    onDataFormatChange();
    onColorSchemeChange();
}

From source file:io.github.tavernaextras.biocatalogue.ui.search_results.ServiceListCellRenderer.java

/**
 * /*ww  w .j  a  v  a  2  s  .c  om*/
 * @param itemToRender
 * @param expandedView <code>true</code> to indicate that this method generates the top
 *                     fragment of the expanded list entry for this SOAP operation / REST method.
 * @return
 */
protected GridBagConstraints prepareLoadedEntry(Object itemToRender, boolean selected) {
    TYPE resourceType = determineResourceType(itemToRender);
    Service service = (Service) itemToRender;
    ;

    // service type
    if (service.getServiceTechnologyTypes() != null
            && service.getServiceTechnologyTypes().getTypeList().size() > 0) {
        if (service.getServiceTechnologyTypes().getTypeList().size() > 1
                && !(service.getServiceTechnologyTypes().getTypeList().get(0).toString()
                        .equalsIgnoreCase("SOAP"))
                && service.getServiceTechnologyTypes().getTypeList().get(1).toString()
                        .equalsIgnoreCase("SOAPLAB")) {
            jlTypeIcon = new JLabel(ResourceManager.getImageIcon(ResourceManager.SERVICE_TYPE_MULTITYPE_ICON));
        } else if (service.getServiceTechnologyTypes().getTypeArray(0).toString().equalsIgnoreCase("SOAP")) {
            jlTypeIcon = new JLabel(ResourceManager.getImageIcon(ResourceManager.SERVICE_TYPE_SOAP_ICON));
        } else if (service.getServiceTechnologyTypes().getTypeArray(0).toString().equalsIgnoreCase("REST")) {
            jlTypeIcon = new JLabel(ResourceManager.getImageIcon(ResourceManager.SERVICE_TYPE_REST_ICON));
        }
    } else {
        // can't tell the type - just show as a service of no particular type
        jlTypeIcon = new JLabel(resourceType.getIcon());
    }

    // service status
    jlItemStatus = new JLabel(ServiceMonitoringStatusInterpreter.getStatusIcon(service, true));

    jlItemTitle = new JLabel(Resource.getDisplayNameForResource(service), JLabel.LEFT);
    jlItemTitle.setForeground(Color.decode("#AD0000")); // very dark red
    jlItemTitle.setFont(jlItemTitle.getFont().deriveFont(Font.PLAIN, jlItemTitle.getFont().getSize() + 2));

    int descriptionMaxLength = DESCRIPTION_MAX_LENGTH_EXPANDED;
    String strDescription = Util.stripAllHTML(service.getDescription());
    strDescription = (strDescription == null || strDescription.length() == 0
            ? "<font color=\"gray\">no description</font>"
            : StringEscapeUtils
                    .escapeHtml(Util.ensureLineLengthWithinString(strDescription, LINE_LENGTH, false)));

    if (strDescription.length() > descriptionMaxLength) {
        strDescription = strDescription.substring(0, descriptionMaxLength)
                + "<font color=\"gray\">(...)</font>";
    }
    strDescription = "<html><b>Description: </b>" + strDescription + "</html>";
    jlDescription = new JLabel(strDescription);

    return (arrangeLayout(true));
}

From source file:Bouncer.java

protected void setClip(Graphics2D g2) {
    if (mClip == false)
        return;//w  ww .j a v a  2 s. co  m
    if (mClipShape == null) {
        Dimension d = getSize();
        FontRenderContext frc = g2.getFontRenderContext();
        Font font = new Font("Serif", Font.PLAIN, 144);
        String s = "Java Source and Support!";
        GlyphVector gv = font.createGlyphVector(frc, s);
        Rectangle2D bounds = font.getStringBounds(s, frc);
        mClipShape = gv.getOutline((d.width - (float) bounds.getWidth()) / 2,
                (d.height + (float) bounds.getHeight()) / 2);
    }
    g2.clip(mClipShape);
}

From source file:daylightchart.sunchart.chart.SunChart.java

@SuppressWarnings("unchecked")
private void createTitles(final ChartOptions chartOptions, final Font titleFont) {

    // Clear all titles and subtitles
    setTitle((TextTitle) null);/*from   w  w w .  j av a  2s. com*/
    for (final Title subtitle : (List<Title>) getSubtitles()) {
        if (subtitle instanceof TextTitle) {
            removeSubtitle(subtitle);
        }
    }

    // Build new titles and legend
    final Location location = sunChartData.getLocation();
    final boolean showTitle = chartOptions.getTitleOptions().getShowTitle();
    if (location != null && showTitle) {
        final TextTitle title = new TextTitle(location.toString(), titleFont);
        setTitle(title);

        final Font subtitleFont = titleFont.deriveFont(Font.PLAIN);
        final TextTitle subtitle = new TextTitle(location.getDetails(), subtitleFont);
        subtitle.setPaint(title.getPaint());
        addSubtitle(subtitle);
    }
}