Example usage for org.jfree.chart.axis NumberAxis setTickLabelPaint

List of usage examples for org.jfree.chart.axis NumberAxis setTickLabelPaint

Introduction

In this page you can find the example usage for org.jfree.chart.axis NumberAxis setTickLabelPaint.

Prototype

public void setTickLabelPaint(Paint paint) 

Source Link

Document

Sets the paint used to draw tick labels (if they are showing) and sends an AxisChangeEvent to all registered listeners.

Usage

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

public SCHRGraph(ArrayList<Telemetry> telemetry[]) {
    super();//from   w ww  .ja  v  a2 s. c  o  m
    this.telemetry = telemetry;

    final NumberAxis domainAxis = new NumberAxis("Time (h:m:s)");

    domainAxis.setVerticalTickLabels(true);
    domainAxis.setTickLabelPaint(Color.black);
    domainAxis.setAutoRange(true);

    domainAxis.setNumberFormatOverride(new NumberFormat() {
        @Override
        public StringBuffer format(double millis, StringBuffer toAppendTo, FieldPosition pos) {
            if (millis >= 3600000) {
                // hours, minutes and seconds
                return new StringBuffer(

                        String.format("%d:%d:%d", TimeUnit.MILLISECONDS.toHours((long) millis),
                                TimeUnit.MILLISECONDS.toMinutes(
                                        (long) millis - TimeUnit.MILLISECONDS.toHours((long) millis) * 3600000),
                                TimeUnit.MILLISECONDS.toSeconds((long) millis) - TimeUnit.MINUTES
                                        .toSeconds(TimeUnit.MILLISECONDS.toMinutes((long) millis))));
            } else if (millis >= 60000) {
                // minutes and seconds
                return new StringBuffer(String.format("%d:%d", 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", 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;
        }
    });

    // create plot ...
    final XYItemRenderer powerRenderer = new StandardXYItemRenderer() {
        Stroke regularStroke = new BasicStroke(0.7f);
        Color color;

        public void setColor(Color color) {
            this.color = color;
        }

        @Override
        public Stroke getItemStroke(int row, int column) {
            return regularStroke;
        }

        @Override
        public Paint getItemPaint(int row, int column) {
            return orange;
        }
    };
    powerRenderer.setSeriesPaint(0, orange);
    plot = new XYPlot();
    plot.setRenderer(0, powerRenderer);
    plot.setRangeAxis(0, powerAxis);
    plot.setDomainAxis(domainAxis);

    // add a second dataset and renderer...
    final XYItemRenderer cadenceRenderer = new StandardXYItemRenderer() {
        Stroke regularStroke = new BasicStroke(0.7f);
        Color color;

        public void setColor(Color color) {
            this.color = color;
        }

        @Override
        public Stroke getItemStroke(int row, int column) {
            return regularStroke;
        }

        @Override
        public Paint getItemPaint(int row, int column) {
            return cornflower;
        }

        public Shape lookupLegendShape(int series) {
            return new Rectangle(15, 15);
        }
    };

    final ValueAxis cadenceAxis = new NumberAxis(userPrefs.messages.getString("cDrpm"));
    cadenceAxis.setRange(0, 200);

    // arguments of new XYLineAndShapeRenderer are to activate or deactivate
    // the display of points or line. Set first argument to true if you want
    // to draw lines between the points for e.g.
    plot.setRenderer(1, cadenceRenderer);
    plot.setRangeAxis(1, cadenceAxis);
    plot.mapDatasetToRangeAxis(1, 1);
    cadenceRenderer.setSeriesPaint(0, cornflower);

    // add a third dataset and renderer...
    final XYItemRenderer hrRenderer = new StandardXYItemRenderer() {
        Stroke regularStroke = new BasicStroke(0.7f);
        Color color;

        public void setColor(Color color) {
            this.color = color;
        }

        @Override
        public Stroke getItemStroke(int row, int column) {
            return regularStroke;
        }

        @Override
        public Paint getItemPaint(int row, int column) {
            return straw;
        }

    };

    // arguments of new XYLineAndShapeRenderer are to activate or deactivate
    // the display of points or line. Set first argument to true if you want
    // to draw lines between the points for e.g.
    final ValueAxis heartRateAxis = new NumberAxis(userPrefs.messages.getString("hrBpm"));
    heartRateAxis.setRange(0, 200);

    plot.setRenderer(2, hrRenderer);
    hrRenderer.setSeriesPaint(0, straw);

    plot.setRangeAxis(2, heartRateAxis);
    plot.mapDatasetToRangeAxis(2, 2);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    plot.setBackgroundPaint(Color.DARK_GRAY);
    // return a new chart containing the overlaid plot...
    JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    chart.getLegend().setBackgroundPaint(Color.gray);

    chartPanel = new ChartPanel(chart);

    // TODO: maybe remember sizes set by user?
    this.setPreferredSize(new Dimension(1200, 500));
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setBackground(Color.gray);

    setLayout(new BorderLayout());
    add(chartPanel, BorderLayout.CENTER);

    SmoothingPanel smoothingPanel = new SmoothingPanel(this);
    add(smoothingPanel, BorderLayout.SOUTH);

    //infoPanel = new InfoPanel();
    //add(infoPanel, BorderLayout.NORTH);
    setVisible(true);
}

From source file:ec.ui.view.StabilityView.java

private void showDetail(Graphs g) {
    XYPlot plot = detailChart.getXYPlot();

    NumberAxis yAxis = new NumberAxis();
    yAxis.setTickLabelPaint(Color.GRAY);
    plot.setRangeAxis(yAxis);//from  ww w .  ja va2  s  .  com

    NumberAxis xAxis = new NumberAxis();
    xAxis.setTickLabelPaint(Color.GRAY);
    xAxis.setTickUnit(new NumberTickUnit(1));
    xAxis.setRange(-0.5, ((double) g.getMaxElements()) - 0.5);
    plot.setDomainAxis(xAxis);

    plot.setDataset(MEAN_INDEX, new BasicXYDataset(Collections.singletonList(g.S1_)));
    plot.setDataset(POINTS_INDEX, new BasicXYDataset(Collections.singletonList(g.S2_)));
    plot.setDataset(SMOOTH_INDEX, new BasicXYDataset(Collections.singletonList(g.S3_)));

    rescaleAxis((NumberAxis) plot.getRangeAxis());

    detailChart.setTitle(g.label_);
    panel.setChart(detailChart);
    panel.setToolTipText("Right click to show complete data");
    onColorSchemeChange();
}

From source file:ec.ui.view.StabilityView.java

private void configureAxis(XYPlot plot) {
    int nb = graphs_.size();
    List<String> names = new ArrayList<>();
    for (Map.Entry<Bornes, Graphs> entry : graphs_.entrySet()) {
        names.add(entry.getValue().label_);
    }/*  ww w.  j  a v a2  s  .  c  o m*/

    NumberAxis xAxis = new NumberAxis();
    xAxis.setTickLabelPaint(Color.GRAY);
    xAxis.setTickUnit(new StabilityTickUnit(names));
    xAxis.setRange(-0.5, nb - 0.5);
    plot.setDomainAxis(xAxis);
    plot.setDomainGridlinesVisible(false);
    NumberAxis yaxis = new NumberAxis();
    rescaleAxis(yaxis);
    plot.setRangeAxis(yaxis);

    for (int i = 0; i < nb; i++) {
        ValueMarker marker = new ValueMarker(i + 0.5);
        marker.setStroke(MARKER_STROKE);
        marker.setPaint(MARKER_PAINT);
        marker.setAlpha(MARKER_ALPHA);
        plot.addDomainMarker(marker);
    }
}

From source file:org.jls.toolbox.math.chart.XYBlockChart.java

/**
 * Permet de paramtrer le graphique une fois cr.
 *///from   w  w w . jav  a 2s.com
private void setChartStyle() {
    this.plot.setBackgroundAlpha((float) 0.0);
    this.plot.setDomainCrosshairLockedOnData(false);
    this.plot.setRangeCrosshairLockedOnData(false);
    this.plot.setDomainCrosshairVisible(true);
    this.plot.setRangeCrosshairVisible(true);
    this.plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
    this.plot.setDomainGridlinesVisible(true);
    this.plot.setRangeGridlinesVisible(true);
    this.plot.setRangeGridlinePaint(Color.white);

    this.plot.setDomainCrosshairStroke(new BasicStroke(1f));
    this.plot.setRangeCrosshairStroke(new BasicStroke(1f));
    this.chart.setBackgroundPaint(this.CHART_BACKGROUND_COLOR);

    NumberAxis xAxis = (NumberAxis) this.plot.getDomainAxis();
    NumberAxis yAxis = (NumberAxis) this.plot.getRangeAxis();

    xAxis.setAxisLinePaint(this.CHART_FOREGROUND_COLOR);
    xAxis.setLabelPaint(this.CHART_FOREGROUND_COLOR);
    xAxis.setTickLabelPaint(this.CHART_FOREGROUND_COLOR);
    xAxis.setTickMarkPaint(this.CHART_FOREGROUND_COLOR);
    xAxis.setAutoRange(true);
    xAxis.setAutoRangeIncludesZero(false);

    yAxis.setAxisLinePaint(this.CHART_FOREGROUND_COLOR);
    yAxis.setLabelPaint(this.CHART_FOREGROUND_COLOR);
    yAxis.setTickLabelPaint(this.CHART_FOREGROUND_COLOR);
    yAxis.setTickMarkPaint(this.CHART_FOREGROUND_COLOR);
    yAxis.setAutoRange(true);
    yAxis.setAutoRangeIncludesZero(false);

    this.plot.setBackgroundPaint(this.CHART_FOREGROUND_COLOR);
    this.plot.setDomainGridlinePaint(this.CHART_FOREGROUND_COLOR);
    this.plot.setRangeGridlinePaint(this.CHART_FOREGROUND_COLOR);
    this.plot.setDomainCrosshairPaint(this.CROSSHAIR_COLOR);
    this.plot.setRangeCrosshairPaint(this.CROSSHAIR_COLOR);
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.clusterchart.SimpleCluster.java

public JFreeChart createChart(DatasetMap datasets) {

    DefaultXYZDataset dataset = (DefaultXYZDataset) datasets.getDatasets().get("1");

    JFreeChart chart = ChartFactory.createBubbleChart(name, yLabel, xLabel, dataset, PlotOrientation.HORIZONTAL,
            legend, true, false);//w  w w.j  a  v  a2  s .  c o m

    /*Font font = new Font("Tahoma", Font.BOLD, titleDimension);
    TextTitle title = new TextTitle(name, font);
    chart.setTitle(title);*/

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }

    Color colorSubInvisibleTitle = Color.decode("#FFFFFF");
    StyleLabel styleSubSubTitle = new StyleLabel("Arial", 12, colorSubInvisibleTitle);
    TextTitle subsubTitle = setStyleTitle("", styleSubSubTitle);
    chart.addSubtitle(subsubTitle);

    chart.setBackgroundPaint(color);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);
    //plot.setForegroundAlpha(0.50f);
    plot.setForegroundAlpha(0.65f);

    XYItemRenderer renderer = plot.getRenderer();

    //define colors
    int seriesN = dataset.getSeriesCount();
    if (colorMap != null) {
        boolean isSerieSel = true;
        for (int i = 0; i < seriesN; i++) {
            String serieName = (String) dataset.getSeriesKey(i);
            String tmpName = serieName.replaceAll(" ", "");
            tmpName = tmpName.replace('.', ' ').trim();
            if (serie_selected != null && serie_selected.size() > 0) {
                String serieSel = serie_selected.get(tmpName).toString();
                isSerieSel = (serieSel.equalsIgnoreCase("TRUE") || serieSel.equalsIgnoreCase("YES")
                        || serieSel.equalsIgnoreCase("1")) ? true : false;
                serieName = tmpName;
            }

            if (color != null && isSerieSel) {
                Color color = (Color) colorMap.get(serieName);
                renderer.setSeriesPaint(i, color);
            } else {
                Color color = new Color(Integer.decode(defaultColor).intValue());
                renderer.setSeriesPaint(i, color);
            }
        }
    }

    // increase the margins to account for the fact that the auto-range 
    // doesn't take into account the bubble size...
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    //domainAxis.setAutoRange(true);
    domainAxis.setRange(yMin, yMax);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();

    rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis.setLabelPaint(styleXaxesLabels.getColor());
    rangeAxis
            .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor());

    //rangeAxis.setAutoRange(true);
    rangeAxis.setRange(xMin, xMax);

    TickUnits units = null;
    if (decimalXValues == false)
        units = (TickUnits) NumberAxis.createIntegerTickUnits();
    else
        units = (TickUnits) NumberAxis.createStandardTickUnits();
    rangeAxis.setStandardTickUnits(units);

    TickUnits domainUnits = null;
    if (decimalYValues == false)
        domainUnits = (TickUnits) NumberAxis.createIntegerTickUnits();
    else
        domainUnits = (TickUnits) NumberAxis.createStandardTickUnits();
    domainAxis.setStandardTickUnits(domainUnits);

    rangeAxis.setLowerMargin(1.0);
    rangeAxis.setUpperMargin(1.0);

    domainAxis.setLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize()));
    domainAxis.setLabelPaint(styleYaxesLabels.getColor());
    domainAxis
            .setTickLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize()));
    domainAxis.setTickLabelPaint(styleYaxesLabels.getColor());

    domainAxis.setLowerMargin(1.0);
    domainAxis.setUpperMargin(1.0);
    //DecimalFormat format=(new DecimalFormat("0"));
    //rangeAxis.setNumberFormatOverride(format);

    if (legend == true)
        drawLegend(chart);

    return chart;
}

From source file:ec.ui.view.MarginView.java

private JFreeChart createMarginViewChart() {
    JFreeChart result = ChartFactory.createXYLineChart("", "", "", Charts.emptyXYDataset(),
            PlotOrientation.VERTICAL, false, false, false);
    result.setPadding(TsCharts.CHART_PADDING);

    XYPlot plot = result.getXYPlot();//from w w  w .j a  v a2s.co  m
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    LinesThickness linesThickness = LinesThickness.Thin;

    XYLineAndShapeRenderer main = new LineRenderer();
    plot.setRenderer(MAIN_INDEX, main);

    XYDifferenceRenderer difference = new XYDifferenceRenderer();
    difference.setAutoPopulateSeriesPaint(false);
    difference.setAutoPopulateSeriesStroke(false);
    difference.setBaseStroke(TsCharts.getNormalStroke(linesThickness));
    plot.setRenderer(DIFFERENCE_INDEX, difference);

    DateAxis domainAxis = new DateAxis();
    domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    domainAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setDomainAxis(domainAxis);

    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setRangeAxis(rangeAxis);

    return result;
}

From source file:be.nbb.demetra.dfm.output.ConfidenceGraph.java

private JFreeChart createMarginViewChart() {
    final JFreeChart result = ChartFactory.createXYLineChart("", "", "", Charts.emptyXYDataset(),
            PlotOrientation.VERTICAL, false, false, false);
    result.setPadding(TsCharts.CHART_PADDING);

    XYPlot plot = result.getXYPlot();//from  ww w.  j av  a  2  s  . c om
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    XYLineAndShapeRenderer main = new LineRenderer(MAIN_INDEX);
    plot.setRenderer(MAIN_INDEX, main);

    XYLineAndShapeRenderer original = new LineRenderer(ORIGINAL_DATA_INDEX);
    plot.setRenderer(ORIGINAL_DATA_INDEX, original);

    for (int i = 0; i < indexes.length - 1; i++) {
        plot.setRenderer(indexes[i], getDifferenceRenderer());
        for (int j = 1; j < intermediateValues; j++) {
            plot.setRenderer(indexes[i] - j, getDifferenceRenderer());
        }
    }

    plot.setRenderer(CONFIDENCE99_INDEX, getDifferenceRenderer());

    DateAxis domainAxis = new DateAxis();
    domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    domainAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setDomainAxis(domainAxis);

    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setRangeAxis(rangeAxis);

    return result;
}

From source file:org.owasp.benchmark.score.report.Scatter.java

private JFreeChart display(String title, int height, int width, OverallResults or) {
    JFrame f = new JFrame(title);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Note: this is a little weird, since each point is a separate series
    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries series = new XYSeries("Scores");
    for (OverallResult r : or.getResults()) {
        series.add(r.fpr * 100, r.tpr * 100);
    }/*from w  w w .ja  v a2 s.  c o m*/
    dataset.addSeries(series);

    chart = ChartFactory.createScatterPlot(title, "False Positive Rate", "True Positive Rate", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    String fontName = "Arial";
    DecimalFormat pctFormat = new DecimalFormat("0'%'");

    theme = (StandardChartTheme) org.jfree.chart.StandardChartTheme.createJFreeTheme();
    theme.setExtraLargeFont(new Font(fontName, Font.PLAIN, 24)); // title
    theme.setLargeFont(new Font(fontName, Font.PLAIN, 20)); // axis-title
    theme.setRegularFont(new Font(fontName, Font.PLAIN, 16));
    theme.setSmallFont(new Font(fontName, Font.PLAIN, 12));
    theme.setRangeGridlinePaint(Color.decode("#C0C0C0"));
    theme.setPlotBackgroundPaint(Color.white);
    theme.setChartBackgroundPaint(Color.white);
    theme.setGridBandPaint(Color.red);
    theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0));
    theme.setBarPainter(new StandardBarPainter());
    theme.setAxisLabelPaint(Color.decode("#666666"));
    theme.apply(chart);

    XYPlot xyplot = chart.getXYPlot();
    NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis();
    NumberAxis domainAxis = (NumberAxis) xyplot.getDomainAxis();

    xyplot.setOutlineVisible(true);

    rangeAxis.setRange(-9.99, 109.99);
    rangeAxis.setNumberFormatOverride(pctFormat);
    rangeAxis.setTickLabelPaint(Color.decode("#666666"));
    rangeAxis.setMinorTickCount(5);
    rangeAxis.setTickUnit(new NumberTickUnit(10));
    rangeAxis.setAxisLineVisible(true);
    rangeAxis.setMinorTickMarksVisible(true);
    rangeAxis.setTickMarksVisible(true);
    rangeAxis.setLowerMargin(10);
    rangeAxis.setUpperMargin(10);
    xyplot.setRangeGridlineStroke(new BasicStroke());
    xyplot.setRangeGridlinePaint(Color.lightGray);
    xyplot.setRangeMinorGridlinePaint(Color.decode("#DDDDDD"));
    xyplot.setRangeMinorGridlinesVisible(true);

    domainAxis.setRange(-5, 105);
    domainAxis.setNumberFormatOverride(pctFormat);
    domainAxis.setTickLabelPaint(Color.decode("#666666"));
    domainAxis.setMinorTickCount(5);
    domainAxis.setTickUnit(new NumberTickUnit(10));
    domainAxis.setAxisLineVisible(true);
    domainAxis.setTickMarksVisible(true);
    domainAxis.setMinorTickMarksVisible(true);
    domainAxis.setLowerMargin(10);
    domainAxis.setUpperMargin(10);
    xyplot.setDomainGridlineStroke(new BasicStroke());
    xyplot.setDomainGridlinePaint(Color.lightGray);
    xyplot.setDomainMinorGridlinePaint(Color.decode("#DDDDDD"));
    xyplot.setDomainMinorGridlinesVisible(true);

    chart.setTextAntiAlias(true);
    chart.setAntiAlias(true);
    chart.removeLegend();
    chart.setPadding(new RectangleInsets(20, 20, 20, 20));
    xyplot.getRenderer().setSeriesPaint(0, Color.decode("#4572a7"));

    //        // setup item labels
    //        XYItemRenderer renderer = xyplot.getRenderer();
    //        Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 7.0f, 7.0f);
    //        for ( int i = 0; i < dataset.getSeriesCount(); i++ ) {
    //            renderer.setSeriesShape(i, circle);
    //            renderer.setSeriesPaint(i, Color.blue);
    //            String letter = "" + ((String)dataset.getSeries(i).getKey()).charAt(0);
    //            StandardXYItemLabelGenerator generator = new StandardXYItemLabelGenerator(letter); 
    //            renderer.setSeriesItemLabelGenerator(i, generator); 
    //            renderer.setSeriesItemLabelsVisible(i, true);
    //            ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER );
    //            renderer.setSeriesPositiveItemLabelPosition(i, position);
    //        }

    makeDataLabels(or, xyplot);
    makeLegend(or, 57, 48, dataset, xyplot);

    // put legend inside plot
    //        LegendTitle lt = new LegendTitle(xyplot);
    //        lt.setItemFont(theme.getSmallFont());
    //        lt.setPosition(RectangleEdge.RIGHT);
    //        lt.setItemFont(theme.getSmallFont());
    //        XYTitleAnnotation ta = new XYTitleAnnotation(.7, .55, lt, RectangleAnchor.TOP_LEFT);
    //        ta.setMaxWidth(0.48);
    //        xyplot.addAnnotation(ta);

    // draw guessing line
    Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 6, 3 },
            0);
    XYLineAnnotation guessing = new XYLineAnnotation(-5, -5, 105, 105, dashed, Color.red);
    xyplot.addAnnotation(guessing);

    XYPointerAnnotation worse = makePointer(75, 0, "Worse than guessing", TextAnchor.TOP_CENTER, 90);
    xyplot.addAnnotation(worse);

    XYPointerAnnotation better = makePointer(25, 100, "Better than guessing", TextAnchor.BOTTOM_CENTER, 270);
    xyplot.addAnnotation(better);

    XYTextAnnotation time = new XYTextAnnotation("Tool run time: " + or.getTime(), 12, -5.6);
    time.setTextAnchor(TextAnchor.TOP_LEFT);
    time.setFont(theme.getRegularFont());
    time.setPaint(Color.red);
    xyplot.addAnnotation(time);

    XYTextAnnotation stroketext = new XYTextAnnotation("                     Random Guess", 88, 107);
    stroketext.setTextAnchor(TextAnchor.CENTER_RIGHT);
    stroketext.setBackgroundPaint(Color.white);
    stroketext.setPaint(Color.red);
    stroketext.setFont(theme.getRegularFont());
    xyplot.addAnnotation(stroketext);

    XYLineAnnotation strokekey = new XYLineAnnotation(58, 107, 68, 107, dashed, Color.red);
    xyplot.setBackgroundPaint(Color.white);
    xyplot.addAnnotation(strokekey);

    ChartPanel cp = new ChartPanel(chart, height, width, 400, 400, 1200, 1200, false, false, false, false,
            false, false);
    f.add(cp);
    f.pack();
    f.setLocationRelativeTo(null);
    //      f.setVisible(true);
    return chart;
}

From source file:be.nbb.demetra.dfm.output.simulation.RealTimePerspGraphView.java

private void configureAxis(XYPlot plot, int start, int end) {
    int nb = graphs_.size();
    List<String> names = new ArrayList<>();
    for (int i = start; i <= end; i++) {
        names.add(periods.get(i).toString());
    }//from  w w  w.ja  va2  s  . c o m

    NumberAxis xAxis = new NumberAxis();
    xAxis.setTickLabelPaint(Color.GRAY);
    xAxis.setTickUnit(new MyTickUnit(names));
    xAxis.setRange(-0.5, nb - 0.5);
    xAxis.setVerticalTickLabels(true);
    plot.setDomainAxis(xAxis);
    plot.setDomainGridlinesVisible(false);
    NumberAxis yaxis = new NumberAxis();
    rescaleAxis(yaxis);
    yaxis.configure();
    plot.setRangeAxis(yaxis);

    for (int i = 0; i < nb; i++) {
        ValueMarker marker = new ValueMarker(i + 0.5);
        marker.setStroke(MARKER_STROKE);
        marker.setPaint(MARKER_PAINT);
        marker.setAlpha(MARKER_ALPHA);
        plot.addDomainMarker(marker);
    }
}

From source file:be.nbb.demetra.dfm.output.simulation.RealTimePerspGraphView.java

private void showDetail(Graphs g) {
    XYPlot plot = detailChart.getXYPlot();

    NumberAxis yAxis = new NumberAxis();
    yAxis.setTickLabelPaint(Color.GRAY);
    plot.setRangeAxis(yAxis);/*from  ww  w. j  a v a2 s  .  com*/

    NumberAxis xAxis = new NumberAxis();
    xAxis.setTickLabelPaint(Color.GRAY);
    xAxis.setTickUnit(new NumberTickUnit(10));
    xAxis.setRange(horizons.get(0), horizons.get(horizons.size() - 1));
    xAxis.setVerticalTickLabels(true);
    plot.setDomainAxis(xAxis);

    plot.setDataset(TRUE_DATA_INDEX, new BasicXYDataset(Collections.singletonList(g.S1_)));
    plot.setDataset(FCTS_INDEX, new BasicXYDataset(Collections.singletonList(g.S2_)));
    plot.setDataset(ARIMA_DATA_INDEX, new BasicXYDataset(Collections.singletonList(g.S3_)));

    rescaleAxis((NumberAxis) plot.getRangeAxis());

    detailChart.setTitle(g.label_);
    chartPanel.setChart(detailChart);
    chartPanel.setToolTipText("Right click to show complete data");
    chartPanel.setPopupMenu(buildMenu().getPopupMenu());
    onColorSchemeChanged();

    selectedGraph = g;
}