Example usage for org.jfree.chart.plot XYPlot setDomainGridlinePaint

List of usage examples for org.jfree.chart.plot XYPlot setDomainGridlinePaint

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot setDomainGridlinePaint.

Prototype

public void setDomainGridlinePaint(Paint paint) 

Source Link

Document

Sets the paint for the grid lines plotted against the domain axis, and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:adams.flow.sink.JFreeChartPlot.java

/**
 * Creates a new display panel for the token.
 *
 * @param token   the token to display in a new panel, can be null
 * @return      the generated panel/*w  w w  . j  av a2  s  . co  m*/
 */
@Override
public DisplayPanel createDisplayPanel(Token token) {
    AbstractDisplayPanel result;

    result = new AbstractComponentDisplayPanel(getClass().getSimpleName()) {
        private static final long serialVersionUID = -3785685146120118884L;
        protected JFreeChart m_JFreeChart;
        protected ChartPanel m_PlotPanel;

        @Override
        protected void initGUI() {
            super.initGUI();
            setLayout(new BorderLayout());
        }

        @Override
        public void display(Token token) {
            SpreadSheet sheet = (SpreadSheet) token.getPayload();
            Dataset dataset = m_Dataset.generate(sheet);
            m_JFreeChart = m_Chart.generate(dataset);
            if (m_JFreeChart.getPlot() instanceof XYPlot) {
                XYPlot plot = (XYPlot) m_JFreeChart.getPlot();
                plot.setDomainGridlinesVisible(true);
                plot.setDomainGridlinePaint(Color.GRAY);
                plot.setRangeGridlinesVisible(true);
                plot.setRangeGridlinePaint(Color.GRAY);
                plot.getRenderer().setSeriesPaint(0, m_PlotColor);
                if (plot.getSeriesCount() > 1)
                    plot.getRenderer().setSeriesPaint(1, m_DiagonalColor);
                Shape shape = m_Shape.generate();
                if (shape != null)
                    plot.getRenderer().setSeriesShape(0, shape);
            }
            m_PlotPanel = new ChartPanel(m_JFreeChart);
            removeAll();
            add(m_PlotPanel, BorderLayout.CENTER);
        }

        @Override
        public void clearPanel() {
            removeAll();
            m_JFreeChart = null;
        }

        @Override
        public void cleanUp() {
            removeAll();
            m_JFreeChart = null;
        }

        @Override
        public JComponent supplyComponent() {
            return m_PlotPanel;
        }
    };

    if (token != null)
        result.display(token);

    return result;
}

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

/**
 * Creates a chart./* ww  w  . ja v a 2s. c o  m*/
 * 
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(XYDataset dataset) {
    chartTitle = "Power Transform Chart";
    //   create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, //"Power Transform Chart",      // chart title
            domainLabel, // x axis label 
            rangeLabel, // y axis label  
            dataset, // data
            PlotOrientation.VERTICAL, !legendPanelOn, // include legend
            true, // tooltips 
            false // urls
    );
    toolBar.setLayout(new FlowLayout(FlowLayout.LEFT));

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

    // get a reference to the plot for further customisation...
    XYPlot plot = (XYPlot) chart.getPlot();

    plot.setBackgroundPaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    //  renderer.setSeriesShape(0, java.awt.Shape.round);
    renderer.setBaseShapesVisible(false);
    renderer.setBaseShapesFilled(false);
    renderer.setBaseLinesVisible(true);

    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    //change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setUpperMargin(0.05);
    rangeAxis.setLowerMargin(0.05);

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    domainAxis.setAutoRangeIncludesZero(false);
    //  domainAxis.setTickLabelsVisible(false);
    // domainAxis.setTickMarksVisible(false);      
    domainAxis.setUpperMargin(0.05);
    domainAxis.setLowerMargin(0.05);

    // OPTIONAL CUSTOMISATION COMPLETED.
    setYSummary(dataset);

    return chart;
}

From source file:edu.unibonn.kmeans.mapreduce.plotting.TimeSeriesPlotter_KMeans.java

/**
  * Creates a chart./* ww w.  j  av  a  2 s.  c om*/
  * 
  * @param dataset  a dataset.
 * @param clusters 
  * 
  * @return A chart.
  */
//    private JFreeChart createChart(final XYDataset dataset, ArrayList<Cluster_DBScan> clusters) {
//
//        final JFreeChart chart = ChartFactory.createTimeSeriesChart(
//            "Sensors",
//            "Time", "Erlang",
//            dataset,
//            false, //t
//            true, //t
//            false //f
//        );
//
//        ChartUtilities.applyCurrentTheme(chart);
//        
//        //chart.setBackgroundPaint(Color.white);
//
////        final StandardLegend sl = (StandardLegend) chart.getLegend();
////        sl.setDisplaySeriesShapes(true);
//
//        final XYPlot plot = chart.getXYPlot();
//        plot.setBackgroundPaint(Color.WHITE);
//        plot.setDomainGridlinePaint(Color.white);
//        plot.setRangeGridlinePaint(Color.white);
////        plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
//        plot.setDomainCrosshairVisible(true);
//        plot.setRangeCrosshairVisible(true);
//        
//        final XYItemRenderer renderer = plot.getRenderer();
//        
//        if (renderer instanceof StandardXYItemRenderer) 
//        {
//            final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer;
//            //rr.setPlotShapes(true);
//            rr.setShapesFilled(true);
//            rr.setItemLabelsVisible(true);
//        }
//
//        int temp_count = 0;
//        
//        //for (int i = 0; i < clusters.size(); i++)
//        for (int i = 0; (i < 11) && (i < clusters.size()); i++)
//      {
//         Cluster_DBScan current_cluster = clusters.get(i);   
//         ArrayList<Day_24d> member_time_series = current_cluster.getMembership();
//         
//         for (int j = 0; j < member_time_series.size(); j++)
//         {
//            renderer.setSeriesPaint(j+temp_count, getColor(i));
//         }
//         temp_count = temp_count + member_time_series.size();
//      }
//        
//        final DateAxis axis = (DateAxis) plot.getDomainAxis();    
//        axis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));
//        
//        final ValueAxis axis_y = plot.getRangeAxis();
//        axis_y.setRange(0, 100);
//        
//        return chart;
//
//    }

private JFreeChart createChart(final XYDataset dataset, final XYDataset dataset_centroids,
        ArrayList<Cluster_KMeans> clusters) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("Sensors", "Time", "Erlang", dataset, false, //t
            true, //t
            false //f
    );

    ChartUtilities.applyCurrentTheme(chart);

    //chart.setBackgroundPaint(Color.white);

    //        final StandardLegend sl = (StandardLegend) chart.getLegend();
    //        sl.setDisplaySeriesShapes(true);

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    //        plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    final XYItemRenderer renderer = plot.getRenderer();

    if (renderer instanceof StandardXYItemRenderer) {
        final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer;
        //rr.setPlotShapes(true);
        rr.setShapesFilled(true);
        rr.setItemLabelsVisible(true);
    }

    int temp_count = 0;

    //for (int i = 0; i < clusters.size(); i++)
    for (int i = 0; (i < 11) && (i < clusters.size()); i++) {
        Cluster_KMeans current_cluster = clusters.get(i);
        ArrayList<Day_24d> member_time_series = current_cluster.getMembership();

        for (int j = 0; j < member_time_series.size(); j++) {
            renderer.setSeriesPaint(j + temp_count, getColor(i));
        }
        temp_count = temp_count + member_time_series.size();
    }

    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));

    //final ValueAxis axis_y = plot.getRangeAxis();
    //axis_y.setRange(0, 20);

    plot.setDataset(1, dataset_centroids);
    plot.setRenderer(1, new StandardXYItemRenderer());

    for (int i = 0; (i < clusters.size()); i++) {
        //plot.getRenderer(1).setSeriesPaint(i, getColor(i));
        plot.getRenderer(1).setSeriesPaint(i, Color.BLACK);
        plot.getRenderer(1).setSeriesStroke(i, new BasicStroke(3.0f, BasicStroke.CAP_ROUND,
                BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10.0f, 6.0f }, 0.0f));
    }

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    return chart;
}

From source file:com.rapidminer.gui.plotter.charts.DistributionPlotter.java

@Override
public void updatePlotter() {

    JFreeChart chart = null;//from   w  w  w. j  a v  a2 s .  c o m
    Attribute attr = null;
    if (plotColumn != -1 && createFromModel) {
        attr = model.getTrainingHeader().getAttributes().get(model.getAttributeNames()[plotColumn]);
    }
    if (attr != null && attr.isNominal()
            && attr.getMapping().getValues().size() > MAX_NUMBER_OF_DIFFERENT_NOMINAL_VALUES) {
        // showing no chart because of too many different values
        chart = new JFreeChart(new Plot() {

            private static final long serialVersionUID = 1L;

            @Override
            public String getPlotType() {
                return "empty";
            }

            @Override
            public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState,
                    PlotRenderingInfo info) {
                String msg = I18N.getGUILabel("plotter_panel.too_many_nominals", "Distribution Plotter",
                        DistributionPlotter.MAX_NUMBER_OF_DIFFERENT_NOMINAL_VALUES);
                g2.setColor(Color.BLACK);
                g2.setFont(g2.getFont().deriveFont(g2.getFont().getSize() * 1.35f));
                g2.drawChars(msg.toCharArray(), 0, msg.length(), 50, (int) (area.getHeight() / 2 + 0.5d));
            }
        });
        AbstractChartPanel panel = getPlotterPanel();
        // Chart Panel Settings
        if (panel == null) {
            panel = createPanel(chart);
        } else {
            panel.setChart(chart);
        }
        // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
        panel.getChartRenderingInfo().setEntityCollection(null);
    } else {
        preparePlots();

        if (!createFromModel && (groupColumn < 0 || plotColumn < 0)) {
            CategoryDataset dataset = new DefaultCategoryDataset();
            chart = ChartFactory.createBarChart(null, // chart title
                    "Not defined", // x axis label
                    RANGE_AXIS_NAME, // y axis label
                    dataset, // data
                    PlotOrientation.VERTICAL, true, // include legend
                    true, // tooltips
                    false // urls
            );
        } else {
            try {
                if (model.isDiscrete(translateToModelColumn(plotColumn))) {
                    chart = createNominalChart();
                } else {
                    chart = createNumericalChart();
                }
            } catch (Exception e) {
                // do nothing - just do not draw the chart
            }
        }

        if (chart != null) {
            chart.setBackgroundPaint(Color.white);

            // get a reference to the plot for further customization...
            Plot commonPlot = chart.getPlot();
            commonPlot.setBackgroundPaint(Color.WHITE);
            if (commonPlot instanceof XYPlot) {
                XYPlot plot = (XYPlot) commonPlot;

                plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
                plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

                // domain axis
                if (dataTable != null) {
                    if (dataTable.isDate(plotColumn) || dataTable.isDateTime(plotColumn)) {
                        DateAxis domainAxis = new DateAxis(dataTable.getColumnName(plotColumn));
                        domainAxis.setTimeZone(com.rapidminer.tools.Tools.getPreferredTimeZone());
                        plot.setDomainAxis(domainAxis);
                    } else {
                        NumberAxis numberAxis = new NumberAxis(dataTable.getColumnName(plotColumn));
                        plot.setDomainAxis(numberAxis);
                    }
                }

                plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD);
                plot.getDomainAxis().setTickLabelFont(LABEL_FONT);

                plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD);
                plot.getRangeAxis().setTickLabelFont(LABEL_FONT);

                // ranging
                if (dataTable != null) {
                    Range range = getRangeForDimension(plotColumn);
                    if (range != null) {
                        plot.getDomainAxis().setRange(range, true, false);
                    }

                    range = getRangeForName(RANGE_AXIS_NAME);
                    if (range != null) {
                        plot.getRangeAxis().setRange(range, true, false);
                    }
                }

                // rotate labels
                if (isLabelRotating()) {
                    plot.getDomainAxis().setTickLabelsVisible(true);
                    plot.getDomainAxis().setVerticalTickLabels(true);
                }

            } else if (commonPlot instanceof CategoryPlot) {
                CategoryPlot plot = (CategoryPlot) commonPlot;

                plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
                plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

                plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD);
                plot.getRangeAxis().setTickLabelFont(LABEL_FONT);

                plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD);
                plot.getDomainAxis().setTickLabelFont(LABEL_FONT);
            }

            // legend settings
            LegendTitle legend = chart.getLegend();
            if (legend != null) {
                legend.setPosition(RectangleEdge.TOP);
                legend.setFrame(BlockBorder.NONE);
                legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
                legend.setItemFont(LABEL_FONT);
            }

            AbstractChartPanel panel = getPlotterPanel();
            // Chart Panel Settings
            if (panel == null) {
                panel = createPanel(chart);
            } else {
                panel.setChart(chart);
            }

            // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
            panel.getChartRenderingInfo().setEntityCollection(null);
        }
    }
}

From source file:org.knime.knip.core.ui.imgviewer.panels.HistogramBC.java

private final void setBackgroundDefault(final JFreeChart chart) {
    final BasicStroke gridStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 2.0f, 1.0f }, 0.0f);
    final XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRangeGridlineStroke(gridStroke);
    plot.setDomainGridlineStroke(gridStroke);
    // Background of Histogram inside border
    //plot.setBackgroundPaint(new Color(235,235,235));
    plot.setBackgroundPaint(Color.white);
    // change from white to gray
    plot.setRangeGridlinePaint(Color.gray);
    plot.setDomainGridlinePaint(Color.gray);
    // set lines invisible
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setOutlineVisible(true);/*from   w w  w .  j a va2 s  .  c  o m*/
    plot.getDomainAxis().setAxisLineVisible(false);
    plot.getRangeAxis().setAxisLineVisible(false);
    plot.getDomainAxis().setLabelPaint(Color.gray);
    plot.getRangeAxis().setLabelPaint(Color.gray);
    plot.getDomainAxis().setTickLabelPaint(Color.gray);
    plot.getRangeAxis().setTickLabelPaint(Color.gray);
    final TextTitle title = chart.getTitle();
    if (title != null) {
        title.setPaint(Color.black);
    }
}

From source file:com.mothsoft.alexis.web.ChartServlet.java

private void doLineGraph(final HttpServletRequest request, final HttpServletResponse response,
        final String title, final String[] dataSetIds, final Integer width, final Integer height,
        final Integer numberOfSamples) throws ServletException, IOException {

    final DataSetService dataSetService = WebApplicationContextUtils
            .getWebApplicationContext(this.getServletContext()).getBean(DataSetService.class);

    final OutputStream out = response.getOutputStream();
    response.setContentType("image/png");
    response.setHeader("Cache-Control", "max-age: 5; must-revalidate");

    final XYSeriesCollection seriesCollection = new XYSeriesCollection();

    final DateAxis dateAxis = new DateAxis(title != null ? title : "Time");
    final DateTickUnit unit = new DateTickUnit(DateTickUnit.HOUR, 1);
    final DateFormat chartFormatter = new SimpleDateFormat("ha");
    dateAxis.setDateFormatOverride(chartFormatter);
    dateAxis.setTickUnit(unit);/*from www  .  j av a  2 s.c  o m*/
    dateAxis.setLabelFont(DEFAULT_FONT);
    dateAxis.setTickLabelFont(DEFAULT_FONT);

    if (numberOfSamples > 12) {
        dateAxis.setTickLabelFont(
                new Font(DEFAULT_FONT.getFamily(), Font.PLAIN, (int) (DEFAULT_FONT.getSize() * .8)));
    }

    final NumberAxis yAxis = new NumberAxis("Activity");

    final StandardXYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES);

    int colorCounter = 0;

    if (dataSetIds != null) {
        for (final String dataSetIdString : dataSetIds) {
            final Long dataSetId = Long.valueOf(dataSetIdString);
            final DataSet dataSet = dataSetService.get(dataSetId);

            // go back for numberOfSamples, but include current hour
            final Calendar calendar = new GregorianCalendar();
            calendar.add(Calendar.HOUR_OF_DAY, -1 * (numberOfSamples - 1));
            calendar.set(Calendar.MINUTE, 0);
            calendar.set(Calendar.SECOND, 0);
            calendar.set(Calendar.MILLISECOND, 0);
            final Timestamp startDate = new Timestamp(calendar.getTimeInMillis());

            calendar.add(Calendar.HOUR_OF_DAY, numberOfSamples);
            calendar.set(Calendar.MINUTE, 59);
            calendar.set(Calendar.SECOND, 59);
            calendar.set(Calendar.MILLISECOND, 999);
            final Timestamp endDate = new Timestamp(calendar.getTimeInMillis());

            logger.debug(String.format("Generating chart for period: %s to %s", startDate.toString(),
                    endDate.toString()));

            final List<DataSetPoint> dataSetPoints = dataSetService
                    .findAndAggregatePointsGroupedByUnit(dataSetId, startDate, endDate, TimeUnits.HOUR);

            final boolean hasData = addSeries(seriesCollection, dataSet.getName(), dataSetPoints, startDate,
                    numberOfSamples, renderer);

            if (dataSet.isAggregate()) {
                renderer.setSeriesPaint(seriesCollection.getSeriesCount() - 1, Color.BLACK);
            } else if (hasData) {
                renderer.setSeriesPaint(seriesCollection.getSeriesCount() - 1,
                        PAINTS[colorCounter++ % PAINTS.length]);
            } else {
                renderer.setSeriesPaint(seriesCollection.getSeriesCount() - 1, Color.LIGHT_GRAY);
            }
        }
    }

    final XYPlot plot = new XYPlot(seriesCollection, dateAxis, yAxis, renderer);

    // create the chart...
    final JFreeChart chart = new JFreeChart(plot);

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    plot.setBackgroundPaint(new Color(253, 253, 253));
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setLabelFont(DEFAULT_FONT);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLowerBound(0.00d);

    ChartUtilities.writeChartAsPNG(out, chart, width, height);
}

From source file:GeMSE.GS.Analysis.Stats.OneSamplePCAPanel.java

private void Plot() {
    double[][] data = _principalComponents.getData();
    if (data[0].length < 2) {
        JOptionPane.showMessageDialog(this,
                "An error occured when computing principal components.     "
                        + "\nRequire at least two principal components, but calculated "
                        + String.valueOf(data[0].length) + "\n",
                "Not enough data", JOptionPane.ERROR_MESSAGE);
        return;/*from  ww w  . j a v  a  2s .  com*/
    }

    float[] yAxisColor = new float[3];
    Color.RGBtoHSB(255, 255, 255, yAxisColor);

    float[] hsbValues = new float[3];
    Color.RGBtoHSB(16, 23, 67, hsbValues);

    float[] pcColor = new float[3];
    Color.RGBtoHSB(255, 255, 0, pcColor);

    XYSeriesCollection dataset = new XYSeriesCollection();

    XYSeries series = new XYSeries("PC");
    for (double[] d : data)
        series.add(d[0], d[1]);
    dataset.addSeries(series);

    JFreeChart chart = ChartFactory.createScatterPlot(null, "Principal component 1", "Principal component 2",
            (XYDataset) dataset);
    chart.setBackgroundPaint(Color.getHSBColor(hsbValues[0], hsbValues[1], hsbValues[2]));
    chart.removeLegend();

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.getHSBColor(hsbValues[0], hsbValues[1], hsbValues[2]));

    Font axisLabelFont = new Font("Dialog", Font.PLAIN, 14);
    Font axisTickLabelFont = new Font("Dialog", Font.PLAIN, 12);

    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);

    plot.getDomainAxis().setTickLabelPaint(Color.white);
    plot.getDomainAxis().setLabelPaint(Color.white);
    plot.getDomainAxis().setLabelFont(axisLabelFont);
    plot.getDomainAxis().setTickLabelFont(axisTickLabelFont);

    plot.getRangeAxis().setTickLabelPaint(Color.getHSBColor(yAxisColor[0], yAxisColor[1], yAxisColor[2]));
    plot.getRangeAxis().setLabelPaint(Color.getHSBColor(yAxisColor[0], yAxisColor[1], yAxisColor[2]));
    plot.getRangeAxis().setLabelFont(axisLabelFont);
    plot.getRangeAxis().setTickLabelFont(axisTickLabelFont);

    Shape shape = ShapeUtilities.createDiagonalCross(4, 0.5f);
    XYItemRenderer renderer = chart.getXYPlot().getRenderer();
    renderer.setSeriesShape(0, shape);
    renderer.setSeriesPaint(0, Color.getHSBColor(pcColor[0], pcColor[1], pcColor[2]));

    ChartPanel panel = new ChartPanel(chart);
    Dimension plotDim = plotPanel.getSize();
    plotDim.height -= (plotDim.height * 10) / 100;
    plotDim.width -= (plotDim.width * 10) / 100;
    panel.setPreferredSize(plotDim);
    plotPanel.setViewportView(panel);

    revalidate();
    repaint();
}

From source file:ecg.ecgshow.ECGShowUI.java

private void createECGData(long timeZone) {
    ECGData = new JPanel(new GridLayout(LEAD_COUNT, 1));
    dateAxises = new DateAxis[LEAD_COUNT];
    ECGSeries = new TimeSeries[LEAD_COUNT * 2];
    for (int i = 0; i < LEAD_COUNT; i++) {
        TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); //XYDataset  TimeSeriesCollection
        ECGSeries[i] = new TimeSeries("?" + (i + 1));
        ECGSeries[i].setMaximumItemCount(500);
        ECGSeries[i + LEAD_COUNT] = new TimeSeries("");
        ECGSeries[i + LEAD_COUNT].setMaximumItemAge(timeZone);
        ECGSeries[i + LEAD_COUNT].setMaximumItemCount(2);

        timeseriescollection.addSeries(ECGSeries[i]);
        timeseriescollection.addSeries(ECGSeries[i + LEAD_COUNT]);

        //DateAxis dateaxis = new DateAxis("Time");
        dateAxises[i] = new DateAxis("");
        dateAxises[i].setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016)));
        dateAxises[i].setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018)));
        dateAxises[i].setTickLabelsVisible(true);
        dateAxises[i].setVisible(false);

        //NumberAxis numberaxis = new NumberAxis("ecg");
        NumberAxis numberaxis = new NumberAxis("ecg");
        numberaxis.setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016)));
        numberaxis.setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018)));
        numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        numberaxis.setVisible(false);/* www. j a  v  a2 s . c  om*/
        numberaxis.setLowerBound(1500D);
        numberaxis.setUpperBound(3000D);

        XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
        xylineandshaperenderer.setSeriesPaint(0, Color.GREEN); //
        xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(2));
        xylineandshaperenderer.setSeriesPaint(1, Color.LIGHT_GRAY); //
        xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(5));

        XYPlot xyplot = new XYPlot(timeseriescollection, dateAxises[i], numberaxis, xylineandshaperenderer);
        xyplot.setBackgroundPaint(Color.LIGHT_GRAY);
        xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY);
        xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY);
        xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
        xyplot.setBackgroundPaint(Color.BLACK);

        JFreeChart jfreechart = new JFreeChart(xyplot);
        jfreechart.setBackgroundPaint(new Color(237, 237, 237));//?
        jfreechart.getLegend().setVisible(false);

        ChartPanel chartpanel = new ChartPanel(jfreechart, (int) (WIDTH * 46 / 100), (int) (HEIGHT * 17 / 100),
                0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, true, false, false);

        chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0) //??0
                , BorderFactory.createEmptyBorder() //????
        ));
        chartpanel.setMouseZoomable(false); //?
        ECGData.add(chartpanel);
    }
}

From source file:edu.illinois.ncsa.datawolf.service.ExecutionsResource.java

private JFreeChart createChart(String xVariable, String yVariable, XYDataset dataset) {
    final JFreeChart chart = ChartFactory.createXYLineChart("Convergence Graph", xVariable, yVariable, dataset,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.WHITE);
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.WHITE);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    return chart;
}

From source file:gui.QTLResultsPanel.java

private JPanel getChart(Trait trait) {
    JFreeChart chart = ChartFactory.createXYLineChart(null, "Position (cM)", "LOD Score", null,
            PlotOrientation.VERTICAL, true, true, false);

    setChartData(chart, trait);//w ww  .  jav a2  s  .  c  o  m

    RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    chart.setRenderingHints(rh);
    chart.removeLegend();

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(new Color(255, 255, 220));
    plot.setDomainGridlinePaint(new Color(128, 128, 128));
    plot.setRangeGridlinePaint(new Color(128, 128, 128));

    ValueAxis axis = plot.getRangeAxis();
    if (trait.maxLOD <= 3) {
        axis.setUpperBound(3);
    }

    PermResult result = trait.getPermResult();
    if (result != null) {
        float[] dashPattern = { 5, 5 };
        BasicStroke s1 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10, dashPattern, 0);

        ValueMarker m1 = new ValueMarker(result.getSig90(), new Color(0, 0, 60), s1, null, null, 1.0f);
        ValueMarker m2 = new ValueMarker(result.getSig95(), new Color(0, 0, 60), s1, null, null, 1.0f);

        plot.addRangeMarker(m1);
        plot.addRangeMarker(m2);

        if (result.getSig95() > trait.maxLOD && result.getSig95() >= 3) {
            axis.setUpperBound(result.getSig95() * (1.05));
        }
    }

    chartPanel = new ChartPanel(chart);
    chartPanel.setPopupMenu(null);
    return chartPanel;
}