Example usage for org.jfree.chart.renderer.category LineAndShapeRenderer setBaseShapesFilled

List of usage examples for org.jfree.chart.renderer.category LineAndShapeRenderer setBaseShapesFilled

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.category LineAndShapeRenderer setBaseShapesFilled.

Prototype

public void setBaseShapesFilled(boolean flag) 

Source Link

Document

Sets the base 'shapes filled' flag and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:service.chart.FitnessChart.java

/**
 * Utworz wykres funkcji fitness dla najlepszego osobnika w danej iteracji algorytmu genetycznego 
 * na podstawie zestawu danych/*from   w ww  .  ja  v  a2 s .  c  o m*/
 * 
 * @param categoryDataset Zestaw danych
 * @return Wykres funkcji fitness
 */
private static JFreeChart createChart(CategoryDataset categoryDataset) {

    JFreeChart chart = ChartFactory.createLineChart("Best fitness function value", // title
            "Iteration", // x-axis label
            "Fitness", // y-axis label
            categoryDataset, // data
            PlotOrientation.VERTICAL, true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    CategoryItemRenderer r = plot.getRenderer();
    if (r instanceof LineAndShapeRenderer) {
        LineAndShapeRenderer renderer = (LineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(false);
        renderer.setBaseShapesFilled(true);
    }

    return chart;
}

From source file:org.pentaho.plugin.jfreereport.reportcharts.LineChartExpression.java

protected void configureChart(final JFreeChart chart) {
    super.configureChart(chart);

    final CategoryPlot cpl = chart.getCategoryPlot();
    final CategoryItemRenderer renderer = cpl.getRenderer();
    renderer.setStroke(translateLineStyle(lineWidth, lineStyle));
    if (renderer instanceof LineAndShapeRenderer) {
        final LineAndShapeRenderer shapeRenderer = (LineAndShapeRenderer) renderer;
        shapeRenderer.setShapesVisible(isMarkersVisible());
        shapeRenderer.setBaseShapesFilled(isMarkersVisible());
    }//www.  ja v a2  s . com

}

From source file:peakmlviewer.dialog.peakinformation.Graph.java

public Graph(Composite parent) {
    super(parent, SWT.EMBEDDED);

    setLayout(new FillLayout());

    // create the chart
    linechart = ChartFactory.createLineChart(null, "", "Abundance", dataset_intensity, PlotOrientation.VERTICAL,
            false, // legend
            false, // tooltips
            false // urls
    );//from   ww w .j  a v  a  2 s  . c o m

    CategoryPlot plot = (CategoryPlot) linechart.getPlot();

    // make the labels for the xaxis 45 degrees
    CategoryAxis xaxis = (CategoryAxis) plot.getDomainAxis();
    xaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    // add the mass accuracy yaxis
    NumberAxis yaxis_massacc = new NumberAxis("Mass accuracy (ppm)");
    plot.setRangeAxis(1, yaxis_massacc);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);

    // create the mass accuracy dataset
    dataset_ppm = new DefaultCategoryDataset();
    plot.setDataset(1, dataset_ppm);
    plot.mapDatasetToRangeAxis(1, 1);

    // create the renderer for the mass accuracy dataset
    LineAndShapeRenderer renderer_ppm = new LineAndShapeRenderer();
    renderer_ppm.setBaseShapesFilled(true);
    renderer_ppm.setBaseShapesVisible(true);
    renderer_ppm.setBaseStroke(
            new BasicStroke(1, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 1, new float[] { 5, 5 }, 0));
    plot.setRenderer(1, renderer_ppm);

    // setup the renderer for the intensity dataset
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesFilled(true);
    renderer.setBaseShapesVisible(true);

    // general properties
    linechart.setBackgroundPaint(Color.WHITE);
    linechart.setBorderVisible(false);
    linechart.setAntiAlias(true);

    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinesVisible(true);

    // add the components
    // --------------------------------------------------------------------------------
    // This uses the SWT-trick for embedding awt-controls in an SWT-Composit.
    try {
        System.setProperty("sun.awt.noerasebackground", "true");
    } catch (NoSuchMethodError error) {
        ;
    }

    java.awt.Frame frame = org.eclipse.swt.awt.SWT_AWT.new_Frame(this);

    // create a new ChartPanel, without the popup-menu (5x false)
    frame.add(new ChartPanel(linechart, false, false, false, false, false));
    // --------------------------------------------------------------------------------
}

From source file:org.cerberus.refactor.LineChart.java

public BufferedImage bi(CategoryDataset categorydataset, String name, int count) {

    BufferedImage bi = null;/*from   w  ww  .  j av  a  2s.co  m*/

    JFreeChart jfreechart = ChartFactory.createLineChart(name, "Category", "Count", categorydataset,
            PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    Shape point = ShapeUtilities.createDiagonalCross(1, 1);
    //TODO check this - seriesColors never used
    //        String[] seriesColors = {"#FF0000", "#D7D6F6", "#0F07F3", "#EEFFBD", "#75C53E", "#FED7BA", "#FE6F01"};
    //        String[] seriesColors2 = {"#D7D6F6", "#0F07F3", "#EEFFBD", "#75C53E", "#FED7BA", "#FE6F01"};

    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setBaseShapesVisible(true);
    lineandshaperenderer.setBaseShapesFilled(true);
    for (int a = 0; a < count; a++) {
        lineandshaperenderer.setSeriesShapesVisible(a, true);
        lineandshaperenderer.setSeriesLinesVisible(a, true);
        lineandshaperenderer.setSeriesStroke(a, new BasicStroke(1.0F));
        lineandshaperenderer.setSeriesShape(a, point);
    }

    lineandshaperenderer.setDrawOutlines(true);
    lineandshaperenderer.setUseFillPaint(true);
    lineandshaperenderer.setBaseFillPaint(Color.white);

    //DateAxis dateaxis = (DateAxis)xyplot.getDomainAxis();
    //dateaxis.setDateFormatOverride(new SimpleDateFormat("hh:mm"));

    bi = jfreechart.createBufferedImage(500, 270);

    return bi;

}

From source file:org.openmrs.module.vcttrac.web.view.chart.EvolutionOfClientRegisteredPerDay.java

/**
 * @see org.openmrs.module.vcttrac.web.view.chart.AbstractChartView#createChart(java.util.Map,
 *      javax.servlet.http.HttpServletRequest)
 *//*from w w w  .ja  va2s . c  om*/
@Override
protected JFreeChart createChart(Map<String, Object> model, HttpServletRequest request) {

    String categoryAxisLabel = VCTTracUtil.getMessage("vcttrac.graph.evolution.yAxis.days", null);
    String valueAxisLabel = VCTTracUtil.getMessage("vcttrac.graph.evolution.xAxis.numberofclient", null);

    int numberOfDays = 7, dayFormat = 1;

    if (request.getParameter("graphCategory") != null) {
        if (request.getParameter("graphCategory").trim().compareTo("2") == 0) {
            Date d = new Date();
            d.setDate(1);
            d.setMonth((new Date()).getMonth());
            d.setYear((new Date()).getYear());

            numberOfDays = (int) (((new Date()).getTime() - d.getTime())
                    / VCTTracConstant.ONE_DAY_IN_MILLISECONDS);

            categoryAxisLabel = VCTTracUtil.getMessage("vcttrac.month." + ((new Date()).getMonth() + 1), null);
            dayFormat = 2;

        }
    }

    String title = "";
    title = VCTTracUtil.getMessage("vcttrac.graph.evolution.client.received", null);

    JFreeChart chart = ChartFactory.createLineChart(title, categoryAxisLabel, valueAxisLabel,
            createDataset(numberOfDays, dayFormat), // data
            PlotOrientation.VERTICAL, true, false, false);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    // customise the range axis...   
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setUpperMargin(0.15);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // customise the renderer...   
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setItemLabelsVisible(true);

    return chart;
}

From source file:sanger.team16.gui.genevar.eqtl.query.SNPGeneAssocPlot.java

private JFreeChart createChart(String populationName, CategoryDataset categoryDataset, double max, double min) {
    CategoryAxis categoryaxis = new CategoryAxis();
    categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD);
    //categoryaxis.setMaximumCategoryLabelWidthRatio(5F);
    //categoryaxis.setMaximumCategoryLabelLines(141);
    //categoryaxis.setCategoryMargin(450);

    LineAndShapeRenderer lineandshaperenderer = new LineAndShapeRenderer();
    lineandshaperenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    lineandshaperenderer.setBaseShapesFilled(false);
    lineandshaperenderer.setBaseShape(ShapeUtilities.createDiamond((float) 3));
    lineandshaperenderer.setBaseSeriesVisibleInLegend(false);
    //lineandshaperenderer.setBaseLinesVisible(false);
    lineandshaperenderer.setAutoPopulateSeriesShape(false);
    lineandshaperenderer.setAutoPopulateSeriesPaint(false);
    //lineandshaperenderer.findRangeBounds(categoryDataset);

    NumberAxis numberaxis = new NumberAxis("Expression");
    numberaxis.setAutoRangeIncludesZero(false);
    //numberaxis.setRangeWithMargins(min, max);

    CategoryPlot categoryplot = new CategoryPlot(categoryDataset, categoryaxis, numberaxis,
            lineandshaperenderer);/*  w  w w.  j av  a  2 s . co m*/
    categoryplot.setDomainGridlinesVisible(false);
    categoryplot.setOrientation(PlotOrientation.VERTICAL);

    JFreeChart jfreechart = new JFreeChart(populationName, new Font("SansSerif", 1, 14), categoryplot, true);
    return jfreechart;
}

From source file:Demo.LineGraph.java

private void InitChart() {
    JFreeChart chart = ChartFactory.createLineChart("Yield", "sample NB", "Probability", dataSet,
            PlotOrientation.VERTICAL, false, false, false);

    CategoryPlot plot = chart.getCategoryPlot();

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    plot.setDomainGridlinesVisible(true);
    plot.setNoDataMessage("no data");

    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();

    renderer.setBaseItemLabelsVisible(true);
    renderer.setSeriesPaint(0, Color.BLUE);

    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);

    renderer.setBaseItemLabelsVisible(true);
    renderer.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseItemLabelFont(new Font("Times New Romain", 0, 10));
    plot.setRenderer(renderer);//from  w w w . j av a 2s .c  o m

    CategoryAxis axis = plot.getDomainAxis();
    axis.setCategoryLabelPositions(CategoryLabelPositions.createDownRotationLabelPositions(Math.PI / 6.0));

    chartPane = new ChartPanel(chart);
}

From source file:org.openmrs.module.laboratorymanagement.web.chart.EvolutionOfClientRegisteredPerDay.java

/**
 * @see org.openmrs.module.vcttrac.web.view.chart.AbstractChartView#createChart(java.util.Map,
 *      javax.servlet.http.HttpServletRequest)
 *///from www  .j a  va2 s.  c o m
@Override
protected JFreeChart createChart(Map<String, Object> model, HttpServletRequest request, String patientIdstr,
        String locationIdstr, int conceptId, Date startDate, Date endDate) {

    String categoryAxisLabel = " Year";
    String valueAxisLabel = "Number of Lab tests";

    String title = "EVolution of labotory test:"
            + Context.getConceptService().getConcept(conceptId).getDisplayString();

    JFreeChart chart = ChartFactory.createLineChart(title, categoryAxisLabel, valueAxisLabel,
            createDataset(patientIdstr, locationIdstr, conceptId, startDate, endDate), // data
            PlotOrientation.VERTICAL, true, false, false);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    // customise the range axis...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setUpperMargin(0.15);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // customise the renderer...
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setItemLabelsVisible(true);

    return chart;
}

From source file:org.angnysa.yaba.swing.BudgetFrame.java

private void buildSimulationPanel() {

    simulationPanel = new JPanel();
    SpringLayout springLayout = new SpringLayout();
    simulationPanel.setLayout(springLayout);

    // chart data
    simulationDataset = new SimulationDataset(service);
    simulationDataset.setInitial(0D);//from   ww  w  . j a  v a  2  s.  c  o  m
    simulationDataset.setStart(new LocalDate());
    simulationDataset.setEnd(new LocalDate().plus(Years.ONE));
    simulationDataset.setPeriod(Period.months(1));
    simulationDataset.updateDataset();
    transactionModel.addTableModelListener(new TableModelListener() {

        @Override
        public void tableChanged(TableModelEvent e) {
            simulationDataset.updateDataset();
        }
    });
    reconciliationModel.addTableModelListener(new TableModelListener() {

        @Override
        public void tableChanged(TableModelEvent e) {
            simulationDataset.updateDataset();
        }
    });

    // initial amount label
    JLabel amountLbl = new JLabel(Messages.getString("simulation.field.initial-amount")); //$NON-NLS-1$
    springLayout.putConstraint(SpringLayout.WEST, amountLbl, 10, SpringLayout.WEST, simulationPanel);
    simulationPanel.add(amountLbl);

    // initial amount field
    amountFld = new JFormattedTextField(
            new DefaultFormatterFactory(new NumberFormatter(NumberFormat.getNumberInstance()),
                    new NumberFormatter(NumberFormat.getCurrencyInstance())));
    amountFld.setColumns(8);
    amountFld.setValue(simulationDataset.getInitial());
    amountFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            simulationDataset.setInitial(((Number) amountFld.getValue()).doubleValue());
            simulationDataset.updateDataset();
        }
    });
    springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, amountLbl, 0, SpringLayout.VERTICAL_CENTER,
            amountFld);
    springLayout.putConstraint(SpringLayout.WEST, amountFld, 0, SpringLayout.EAST, amountLbl);
    springLayout.putConstraint(SpringLayout.NORTH, amountFld, 10, SpringLayout.NORTH, simulationPanel);
    simulationPanel.add(amountFld);

    // start date label
    JLabel fromLbl = new JLabel(Messages.getString("simulation.field.start-date")); //$NON-NLS-1$
    springLayout.putConstraint(SpringLayout.WEST, fromLbl, 10, SpringLayout.EAST, amountFld);
    simulationPanel.add(fromLbl);

    // start date field
    fromFld = new JFormattedTextField(new JodaLocalDateFormat());
    fromFld.setColumns(8);
    fromFld.setValue(simulationDataset.getStart());
    fromFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            simulationDataset.setStart((LocalDate) fromFld.getValue());
            simulationDataset.updateDataset();
        }
    });
    springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, fromLbl, 0, SpringLayout.VERTICAL_CENTER, fromFld);
    springLayout.putConstraint(SpringLayout.WEST, fromFld, 0, SpringLayout.EAST, fromLbl);
    springLayout.putConstraint(SpringLayout.NORTH, fromFld, 10, SpringLayout.NORTH, simulationPanel);
    simulationPanel.add(fromFld);

    // end date label
    JLabel toLbl = new JLabel(Messages.getString("simulation.field.end-date")); //$NON-NLS-1$
    springLayout.putConstraint(SpringLayout.WEST, toLbl, 10, SpringLayout.EAST, fromFld);
    simulationPanel.add(toLbl);

    // end date field
    toFld = new JFormattedTextField(new JodaLocalDateFormat());
    toFld.setColumns(8);
    toFld.setValue(simulationDataset.getEnd());
    toFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            simulationDataset.setEnd((LocalDate) toFld.getValue());
            simulationDataset.updateDataset();
        }
    });
    springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, toLbl, 0, SpringLayout.VERTICAL_CENTER, toFld);
    springLayout.putConstraint(SpringLayout.WEST, toFld, 0, SpringLayout.EAST, toLbl);
    springLayout.putConstraint(SpringLayout.NORTH, toFld, 10, SpringLayout.NORTH, simulationPanel);
    simulationPanel.add(toFld);

    // period label
    JLabel periodLbl = new JLabel(Messages.getString("simulation.field.period")); //$NON-NLS-1$
    springLayout.putConstraint(SpringLayout.WEST, periodLbl, 10, SpringLayout.EAST, toFld);
    simulationPanel.add(periodLbl);

    // period field
    periodFld = new JFormattedTextField(new JodaPeriodFormat());
    periodFld.setColumns(5);
    periodFld.setValue(simulationDataset.getPeriod());
    periodFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            simulationDataset.setPeriod((ReadablePeriod) periodFld.getValue());
            simulationDataset.updateDataset();
        }
    });
    springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, periodLbl, 0, SpringLayout.VERTICAL_CENTER,
            periodFld);
    springLayout.putConstraint(SpringLayout.WEST, periodFld, 0, SpringLayout.EAST, periodLbl);
    springLayout.putConstraint(SpringLayout.NORTH, periodFld, 10, SpringLayout.NORTH, simulationPanel);
    simulationPanel.add(periodFld);

    // chart panel
    JFreeChart chart = ChartFactory.createLineChart("", Messages.getString("simulation.chart.date-axis-label"), //$NON-NLS-1$//$NON-NLS-2$
            Messages.getString("simulation.chart.amount-axis-label"), simulationDataset, //$NON-NLS-1$
            PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesFilled(true);
    renderer.setBaseShapesVisible(true);
    renderer.setBaseToolTipGenerator(new SimulationTooltipGenerator(service));
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setDismissDelay(3600000);
    chartPanel.setInitialDelay(0);
    springLayout.putConstraint(SpringLayout.NORTH, chartPanel, 15, SpringLayout.SOUTH, periodFld);
    springLayout.putConstraint(SpringLayout.WEST, chartPanel, 10, SpringLayout.WEST, simulationPanel);
    springLayout.putConstraint(SpringLayout.SOUTH, chartPanel, -10, SpringLayout.SOUTH, simulationPanel);
    springLayout.putConstraint(SpringLayout.EAST, chartPanel, -10, SpringLayout.EAST, simulationPanel);
    simulationPanel.add(chartPanel);
}

From source file:org.operamasks.faces.render.graph.LineChartRenderer.java

private void setLineStyles(LineAndShapeRenderer renderer, UIChart comp) {
    Boolean drawLines = comp.getDrawLines();
    if (drawLines != null) {
        renderer.setBaseLinesVisible(drawLines);
    }//  ww  w .ja  v a  2s .c o  m

    Boolean drawMarkers = comp.getDrawMarkers();
    if (drawMarkers != null) {
        renderer.setBaseShapesVisible(drawMarkers);
    }

    Boolean fillMarkers = comp.getFillMarkers();
    if (fillMarkers != null) {
        renderer.setBaseShapesFilled(fillMarkers);
    }
    renderer.setUseFillPaint(true);

    Boolean drawOutline = comp.getDrawOutline();
    if (drawOutline != null) {
        renderer.setDrawOutlines(drawOutline);
    } else if (renderer instanceof LineRenderer3D) {
        renderer.setDrawOutlines(false);
    }
    renderer.setUseOutlinePaint(true);
}