Example usage for org.jfree.chart JFreeChart DEFAULT_TITLE_FONT

List of usage examples for org.jfree.chart JFreeChart DEFAULT_TITLE_FONT

Introduction

In this page you can find the example usage for org.jfree.chart JFreeChart DEFAULT_TITLE_FONT.

Prototype

Font DEFAULT_TITLE_FONT

To view the source code for org.jfree.chart JFreeChart DEFAULT_TITLE_FONT.

Click Source Link

Document

The default font for titles.

Usage

From source file:playground.yu.utils.charts.TimeLineChart.java

private JFreeChart createChart(String title, String timeAxisLabel, String valueAxisLabel,
        final TimeTableXYDataset dataset) {
    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    timeAxis.setLowerMargin(0.02); // reduce the default margins
    timeAxis.setUpperMargin(0.02);//from   ww  w  .  j av  a2 s .  com
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false); // override default
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);

    XYToolTipGenerator toolTipGenerator = null;
    boolean tooltips = false;
    if (tooltips) {
        toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance();
    }

    XYURLGenerator urlGenerator = null;
    boolean urls = false;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true/* line */, false/* shape */);
    renderer.setBaseToolTipGenerator(toolTipGenerator);
    renderer.setURLGenerator(urlGenerator);
    plot.setRenderer(renderer);

    boolean legend = true;
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    return chart;
}

From source file:org.btrg.df.betterologist.swingui.ProjectJobSchedulingPanel.java

private JFreeChart createChart(Schedule schedule) {
    YIntervalSeriesCollection seriesCollection = new YIntervalSeriesCollection();
    Map<Project, YIntervalSeries> projectSeriesMap = new LinkedHashMap<Project, YIntervalSeries>(
            schedule.getProjectList().size());
    YIntervalRenderer renderer = new YIntervalRenderer();
    int maximumEndDate = 0;
    int seriesIndex = 0;
    for (Project project : schedule.getProjectList()) {
        YIntervalSeries projectSeries = new YIntervalSeries(project.getLabel());
        seriesCollection.addSeries(projectSeries);
        projectSeriesMap.put(project, projectSeries);
        renderer.setSeriesShape(seriesIndex, new Rectangle());
        renderer.setSeriesStroke(seriesIndex, new BasicStroke(3.0f));
        seriesIndex++;/*  w w  w . j a  v  a2  s.com*/
    }
    for (Allocation allocation : schedule.getAllocationList()) {
        int startDate = allocation.getStartDate();
        int endDate = allocation.getEndDate();
        YIntervalSeries projectSeries = projectSeriesMap.get(allocation.getProject());
        projectSeries.add(allocation.getId(), (startDate + endDate) / 2.0, startDate, endDate);
        maximumEndDate = Math.max(maximumEndDate, endDate);
    }
    NumberAxis domainAxis = new NumberAxis("Job");
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    domainAxis.setRange(-0.5, schedule.getAllocationList().size() - 0.5);
    domainAxis.setInverted(true);
    NumberAxis rangeAxis = new NumberAxis("Day (start to end date)");
    rangeAxis.setRange(-0.5, maximumEndDate + 0.5);
    XYPlot plot = new XYPlot(seriesCollection, domainAxis, rangeAxis, renderer);
    plot.setOrientation(PlotOrientation.HORIZONTAL);
    return new JFreeChart("Project Job Scheduling", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
}

From source file:com.bdb.weather.display.stripchart.StripChart.java

/**
 * Constructor./*from   w  ww.  ja va2 s. c  om*/
 * 
 * @param leftAxisType The type of data that is associated with the left axis
 * @param rightAxisType The type of data that is associated with the right axis
 * @param categorySpanHours How many hours that the X axis should initially display
 * @param maxSpanHours The maximum amount of data to keep in the plots dataset
 */
public StripChart(MeasurementType leftAxisType, MeasurementType rightAxisType, int categorySpanHours,
        int maxSpanHours) {
    span = categorySpanHours;
    this.maxSpanHours = maxSpanHours;

    //
    // Set up the Y axes
    //
    setLeftAxis(leftAxisType);
    setRightAxis(leftAxisType);

    //
    // Set up the X axis
    //
    dateAxis = new DateAxis("Time");
    dateAxis.setAutoRange(false);
    dateAxis.setDateFormatOverride(new SimpleDateFormat("h:mm a"));
    dateAxis.setVerticalTickLabels(true);
    dateAxis.setUpperMargin(.10);

    plot.setDomainAxis(dateAxis);
    plot.mapDatasetToRangeAxis(0, 0);
    plot.mapDatasetToRangeAxis(1, 1);
    adjustDateAxis(Calendar.getInstance());

    chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    ChartFactory.getChartTheme().apply(chart);
    chartViewer = new ChartViewer(chart);
    this.setCenter(chartViewer);

    chart.getLegend().setPosition(RectangleEdge.RIGHT);
}

From source file:ch.epfl.leb.sass.ijplugin.SimulatorStatusFrame.java

/** 
 * Creates a new status frame./*  w  w w. j a v  a  2 s.  co m*/
 * 
 * @param groundTruthYLabel The y-axis label for the ground truth signal.
 * @param analyzerYLabel The units output by the analyzer.
 * @param setpointYLabel The units of the controller setpoint.
 * @param outputYLabel The units output by the controller.
 */
public SimulatorStatusFrame(String groundTruthYLabel, String analyzerYLabel, String setpointYLabel,
        String outputYLabel) {
    String seriesLabel = "";
    String yLabel = "";
    CombinedDomainXYPlot combineddomainxyplot = new CombinedDomainXYPlot(new NumberAxis("Simulation Outputs"));
    Font yLabelFont = new Font("Dialog", Font.PLAIN, 10);
    datasets = new XYSeriesCollection[4];
    for (int i = 0; i < SUBPLOT_COUNT; i++) {
        switch (i) {
        case 0:
            seriesLabel = "True density";
            yLabel = groundTruthYLabel;
            break;
        case 1:
            seriesLabel = "Analyzer output";
            yLabel = analyzerYLabel;
            break;
        case 2:
            seriesLabel = "Setpoint";
            yLabel = setpointYLabel;
            break;
        case 3:
            seriesLabel = "Controller output";
            yLabel = outputYLabel;
            break;
        }

        XYSeries timeseries = new XYSeries(seriesLabel);
        datasets[i] = new XYSeriesCollection(timeseries);

        NumberAxis numberaxis = new NumberAxis(yLabel);
        numberaxis.setAutoRangeIncludesZero(false);
        numberaxis.setNumberFormatOverride(new DecimalFormat("###0.00"));
        XYPlot xyplot = new XYPlot(datasets[i], null, numberaxis, new StandardXYItemRenderer());
        xyplot.setBackgroundPaint(Color.lightGray);
        xyplot.setDomainGridlinePaint(Color.white);
        xyplot.setRangeGridlinePaint(Color.white);
        xyplot.getRangeAxis().setLabelFont(yLabelFont);
        combineddomainxyplot.add(xyplot);
    }

    JFreeChart jfreechart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, combineddomainxyplot, true);
    jfreechart.setBorderPaint(Color.black);
    jfreechart.setBorderVisible(true);
    jfreechart.setBackgroundPaint(Color.white);
    combineddomainxyplot.setBackgroundPaint(Color.lightGray);
    combineddomainxyplot.setDomainGridlinePaint(Color.white);
    combineddomainxyplot.setRangeGridlinePaint(Color.white);
    ValueAxis valueaxis = combineddomainxyplot.getDomainAxis();
    valueaxis.setAutoRange(true);
    // Number of frames to display
    valueaxis.setFixedAutoRange(2000D);

    ChartPanel chartpanel = new ChartPanel(jfreechart);

    chartpanel.setPreferredSize(new Dimension(800, 500));
    chartpanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    chartpanel.setVisible(true);

    JPanel jPanel = new JPanel();
    jPanel.setLayout(new BorderLayout());
    jPanel.add(chartpanel, BorderLayout.NORTH);

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    add(jPanel);
    pack();
    setVisible(true);

}

From source file:com.wattzap.view.graphs.MMPGraph.java

public MMPGraph(XYSeries series) {
    super();//from w ww  .j  av a  2s .  c o m

    NumberAxis yAxis = new NumberAxis(userPrefs.messages.getString("poWtt"));
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    double maxY = series.getMaxY();
    yAxis.setRange(0, maxY + 20);
    yAxis.setTickLabelPaint(Color.white);
    yAxis.setLabelPaint(Color.white);

    LogAxis xAxis = new LogAxis(userPrefs.messages.getString("time"));
    xAxis.setTickLabelPaint(Color.white);
    xAxis.setBase(4);
    xAxis.setAutoRange(false);

    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    xAxis.setRange(1, series.getMaxX() + 500);
    xAxis.setNumberFormatOverride(new NumberFormat() {

        @Override
        public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {

            long millis = (long) number * 1000;

            if (millis >= 60000) {
                return new StringBuffer(String.format("%d m %d s",
                        TimeUnit.MILLISECONDS.toMinutes((long) millis),
                        TimeUnit.MILLISECONDS.toSeconds((long) millis)
                                - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes((long) millis))));
            } else {
                return new StringBuffer(String.format("%d s",

                        TimeUnit.MILLISECONDS.toSeconds((long) millis)
                                - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes((long) millis))));
            }
        }

        @Override
        public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) {
            return new StringBuffer(String.format("%s", number));
        }

        @Override
        public Number parse(String source, ParsePosition parsePosition) {
            return null;
        }
    });

    XYPlot plot = new XYPlot(new XYSeriesCollection(series), xAxis, yAxis,
            new XYLineAndShapeRenderer(true, false));

    JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, false);

    chart.setBackgroundPaint(Color.gray);
    plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.darkGray);
    /*plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);*/

    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setTickLabelPaint(Color.white);
    domainAxis.setLabelPaint(Color.white);

    chartPanel = new ChartPanel(chart);
    chartPanel.setSize(100, 800);
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setBackground(Color.gray);

    setLayout(new BorderLayout());
    add(chartPanel, BorderLayout.CENTER);
    setBackground(Color.black);
    chartPanel.revalidate();
    setVisible(true);
}

From source file:org.hxzon.demo.jfreechart.PieDatasetDemo2.java

private static JFreeChart createPieChart(PieDataset dataset) {

    PiePlot plot = new PiePlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }// ww  w .j  a v  a2 s.co  m
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart("Pie Chart Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    plot.setSectionOutlinesVisible(false);
    plot.setNoDataMessage("No data available");

    return chart;

}

From source file:com.jbombardier.console.charts.XYTimeChartPanel.java

public XYTimeChartPanel() {

    DateAxis numberaxis = new DateAxis("Time");

    yAxis = new NumberAxis("Count");
    yAxis.setAutoRangeIncludesZero(true);

    XYSplineRenderer renderer = new XYSplineRenderer();
    // XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    xyplot = new XYPlot(xyseriescollection, numberaxis, yAxis, renderer);
    xyplot.setBackgroundPaint(Color.white);
    xyplot.setDomainGridlinePaint(Color.lightGray);
    xyplot.setRangeGridlinePaint(Color.lightGray);

    // xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D));

    // XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer)
    // xyplot.getRenderer();
    // xylineandshaperenderer.setBaseShapesVisible(false);
    // xylineandshaperenderer.setBaseShapesFilled(false);

    chart = new JFreeChart("Running threads", JFreeChart.DEFAULT_TITLE_FONT, xyplot, true);

    /*//  w ww. j  ava  2 s . co  m
     * ValueMarker valuemarker1 = new ValueMarker(175D);
     * valuemarker1.setLabelOffsetType(LengthAdjustmentType.EXPAND);
     * valuemarker1.setPaint(Color.red); valuemarker1.setLabel("Target Price");
     * valuemarker1.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
     * valuemarker1.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
     * xyplot.addRangeMarker(valuemarker1);
     */

    LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.RIGHT);

    // ChartUtilities.applyCurrentTheme(chart);
    setLayout(new BorderLayout());
    jFreeChartPanel = new ChartPanel(chart);
    jFreeChartPanel.setMinimumDrawHeight(0);
    jFreeChartPanel.setMinimumDrawWidth(0);
    jFreeChartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);
    jFreeChartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);

    add(jFreeChartPanel, BorderLayout.CENTER);

    JPanel controls = new JPanel(new MigLayout("gap 0, ins 0", "[grow,center,fill]", "[grow,center]"));
    final JCheckBox checkbox = new JCheckBox("Auto-scale");
    checkbox.setSelected(true);
    checkbox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            toggleAutoscroll(checkbox.isSelected());
        }
    });
    checkbox.setHorizontalAlignment(SwingConstants.RIGHT);
    controls.add(checkbox, "cell 0 0,alignx center");
    add(controls, BorderLayout.SOUTH);
}

From source file:org.spantus.exp.segment.exec.DrawSegmentComparision.java

/**
 * initialize//w  w  w  .j a  v  a  2  s  . c  o  m
 */
public void init() {
    final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Time"));
    plot.setGap(10.0);
    plot.setOrientation(PlotOrientation.VERTICAL);

    XYSeries[] seriesArr = createSeries(getWavName(), getMarkerName());
    for (XYSeries series : seriesArr) {
        final XYSeriesCollection data1 = new XYSeriesCollection(series);
        final XYItemRenderer renderer1 = new StandardXYItemRenderer();
        final NumberAxis rangeAxis1 = new NumberAxis(series.getDescription());
        final XYPlot subplot = new XYPlot(data1, null, rangeAxis1, renderer1);
        plot.add(subplot, 1);
    }

    final JFreeChart chart = new JFreeChart("Segmentation Result", JFreeChart.DEFAULT_TITLE_FONT, plot, false);

    final ChartPanel chartPanel = new ChartPanel(chart);
    setContentPane(chartPanel);
    chartPanel.setPreferredSize(new Dimension(500, 270));
}

From source file:sernet.gs.ui.rcp.main.bsi.views.chart.RealisierungLineChart.java

private JFreeChart createProgressChart(Object dataset) {
    final double plotGap = 10.0;
    final int axisUpperBoundPadding = 50;
    final int labelFontSize = 10;
    XYDataset data1 = (XYDataset) dataset;
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis(Messages.RealisierungLineChart_1);
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis(Messages.RealisierungLineChart_2));
    plot.setGap(plotGap);/*w w  w  .ja v  a  2 s  .  c o  m*/

    plot.add(subplot1, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);

    CountMassnahmen command = new CountMassnahmen();
    try {
        command = ServiceFactory.lookupCommandService().executeCommand(command);
    } catch (CommandException e) {
        ExceptionUtil.log(e, Messages.RealisierungLineChart_3);
    }
    int totalNum = command.getTotalCount();

    NumberAxis axis = (NumberAxis) subplot1.getRangeAxis();
    axis.setUpperBound(totalNum + axisUpperBoundPadding);

    ValueMarker bst = new ValueMarker(totalNum);
    bst.setPaint(Color.GREEN);
    bst.setLabel(Messages.RealisierungLineChart_4);
    bst.setLabelAnchor(RectangleAnchor.LEFT);
    bst.setLabelFont(new Font("SansSerif", Font.ITALIC + Font.BOLD, labelFontSize)); //$NON-NLS-1$
    bst.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
    subplot1.addRangeMarker(bst, Layer.BACKGROUND);

    // return a new chart containing the overlaid plot...
    JFreeChart chart = new JFreeChart(Messages.RealisierungLineChart_6, JFreeChart.DEFAULT_TITLE_FONT, plot,
            true);
    chart.setBackgroundPaint(Color.white);
    return chart;
}

From source file:playground.dgrether.analysis.charts.DgModalSplitQuantilesChart.java

public JFreeChart createChart() {
    CategoryAxis categoryAxis = this.axisBuilder.createCategoryAxis(xLabel);
    categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    ValueAxis valueAxis = this.axisBuilder.createValueAxis(yLabel);
    valueAxis.setRange(0.0, 102.0);//  ww w . j a  v a2 s .c  om

    DgColorScheme colorScheme = new DgColorScheme();

    CategoryPlot plot = new CategoryPlot();
    plot.setDomainAxis(categoryAxis);
    plot.setRangeAxis(valueAxis);
    plot.setDataset(0, this.dataset);
    BarRenderer carRenderer = new BarRenderer();
    carRenderer.setSeriesPaint(0, colorScheme.COLOR1A);
    carRenderer.setSeriesPaint(1, colorScheme.COLOR3A);

    carRenderer.setItemMargin(0.10);
    plot.setRenderer(0, carRenderer);

    JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    chart.removeLegend();
    return chart;
}