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

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

Introduction

In this page you can find the example usage for org.jfree.chart.axis ValueAxis 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:eu.kprod.gui.chart.MwChartFactory.java

public static MwChartPanel createChart(MwConfiguration conf, final XYDataset xyDataset) {
    final JFreeChart chart;

    chart = ChartFactory.createTimeSeriesChart(null, null, null, xyDataset, false, true, true);

    chart.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR));
    chart.setBorderVisible(false);/* w ww. j  a v  a  2s .c  om*/
    final XYPlot plot = chart.getXYPlot();

    plot.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR));

    plot.setDomainGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR));
    plot.setRangeGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR));
    plot.setDomainGridlinesVisible(false);
    plot.setDomainCrosshairPaint(conf.color.getColor(MwColor.FORGROUND_COLOR));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    // axis.setDateFormatOverride(new SimpleDateFormat("mm''ss''''SSS"));
    axis.setAxisLineVisible(false);
    axis.setTickLabelsVisible(false);
    axis.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR));

    // force integer display
    final ValueAxis va = plot.getRangeAxis();
    va.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    va.setLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR));
    va.setAxisLinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR));
    va.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR));

    //        va.setRange(-280,280);
    //        va.setFixedAutoRange(560);
    //        va.setLowerBound(-280);
    //        va.setUpperBound(280);
    //        va.setAutoRange(false);
    va.setRangeWithMargins(-280, 280);

    final MwChartPanel chartPanel = new MwChartPanel(chart, conf);
    chartPanel.setMouseWheelEnabled(false);
    chartPanel.setDomainZoomable(false);
    chartPanel.setRangeZoomable(false);

    return chartPanel;

}

From source file:org.multiwii.swingui.gui.chart.MwChartFactory.java

public static MwChartPanel createChart(MwConfiguration conf, final XYDataset xyDataset) {
    final JFreeChart chart;

    chart = ChartFactory.createTimeSeriesChart(null, null, null, xyDataset, false, true, true);

    chart.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR));
    chart.setBorderVisible(false);//from   w w w  . j  av  a 2 s.  c  o m
    final XYPlot plot = chart.getXYPlot();

    plot.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR));

    plot.setDomainGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR));
    plot.setRangeGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR));
    plot.setDomainGridlinesVisible(false);
    plot.setDomainCrosshairPaint(conf.color.getColor(MwColor.FORGROUND_COLOR));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    // axis.setDateFormatOverride(new SimpleDateFormat("mm''ss''''SSS"));
    axis.setAxisLineVisible(false);
    axis.setTickLabelsVisible(false);
    axis.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR));

    // force integer display
    final ValueAxis va = plot.getRangeAxis();
    va.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    va.setLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR));
    va.setAxisLinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR));
    va.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR));

    // va.setRange(-280,280);
    // va.setFixedAutoRange(560);
    // va.setLowerBound(-280);
    // va.setUpperBound(280);
    // va.setAutoRange(false);
    va.setRangeWithMargins(-280, 280);

    final MwChartPanel chartPanel = new MwChartPanel(chart, conf);
    chartPanel.setMouseWheelEnabled(false);
    chartPanel.setDomainZoomable(false);
    chartPanel.setRangeZoomable(false);

    return chartPanel;

}

From source file:msec.org.Tools.java

public static String generateFullDayChart(String filename, OneDayValue[] data, String title) {
    if (data[0].getValues().length != 1440) {
        return "data size invalid";
    }/* w w  w . ja v  a 2  s.  c  o  m*/
    if (data.length > 1) {
        if (data[1].getValues() == null || data[1].getValues().length != 1440) {
            return "data 1 invalid";
        }
    }

    XYDataset xydataset = createDataset(data);
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(title, "time", "", xydataset, true, true, true);

    try {
        XYPlot xyplot = (XYPlot) jfreechart.getPlot();

        //
        DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
        dateaxis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));
        dateaxis.setLabelFont(new Font("", Font.PLAIN, 16)); //
        dateaxis.setLabelPaint(ChartColor.gray);
        dateaxis.setTickLabelFont(new Font("", Font.PLAIN, 16));
        dateaxis.setTickLabelPaint(ChartColor.GRAY);

        GregorianCalendar endgc = (GregorianCalendar) gc.clone();
        endgc.add(GregorianCalendar.DATE, 1);
        dateaxis.setMaximumDate(endgc.getTime());

        dateaxis.setTickMarksVisible(true);
        dateaxis.setTickMarkInsideLength(5);
        dateaxis.setTickUnit(new DateTickUnit(DateTickUnitType.HOUR, 2));
        dateaxis.setVerticalTickLabels(true);
        dateaxis.setLabel("");

        //
        ValueAxis rangeAxis = xyplot.getRangeAxis();//?
        rangeAxis.setLabelFont(new Font("", Font.PLAIN, 16));
        rangeAxis.setLabelPaint(ChartColor.gray);
        rangeAxis.setTickLabelFont(new Font("", Font.PLAIN, 16));
        rangeAxis.setTickLabelPaint(ChartColor.gray);
        rangeAxis.setLowerBound(0);

        //
        jfreechart.getLegend().setItemFont(new Font("", Font.PLAIN, 12));
        jfreechart.getLegend().setItemPaint(ChartColor.gray);
        jfreechart.getLegend().setBorder(0, 0, 0, 0);//

        //
        jfreechart.getTitle().setFont(new Font("", Font.PLAIN, 18));//
        jfreechart.getTitle().setPaint(ChartColor.gray);

        //?
        xyplot.setRangeGridlinePaint(ChartColor.GRAY);
        xyplot.setBackgroundPaint(ChartColor.WHITE);
        xyplot.setOutlinePaint(null);//

        int w = 500;
        int h = 300;

        // ChartUtilities.saveChartAsPNG(new File(filename), jfreechart, w, h);
        ChartUtilities.saveChartAsJPEG(new File(filename), 0.8f, jfreechart, w, h);

        return "success";

    } catch (Exception e) {
        e.printStackTrace();
        return e.getMessage();
    }
}

From source file:msec.org.Tools.java

public static String generateDaysChart(String filename, ArrayList<OneDayValue> data, OneAttrDaysChart chart,
        String title, int duration) {
    if (data.size() == 0) {
        return "data size invalid";
    }//from  w ww.ja  va2s .  c  o m

    int date = Integer.parseInt(data.get(0).getDate());
    GregorianCalendar startgc = new GregorianCalendar(date / 10000, date % 10000 / 100 - 1, date % 100);

    XYDataset xydataset = createDaysDataset(data, startgc, chart);
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(title, "time", "", xydataset, true, true, true);

    try {
        XYPlot xyplot = (XYPlot) jfreechart.getPlot();

        //
        DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
        dateaxis.setDateFormatOverride(new SimpleDateFormat("MM/dd"));
        dateaxis.setLabelFont(new Font("", Font.PLAIN, 16)); //
        dateaxis.setLabelPaint(ChartColor.gray);
        dateaxis.setTickLabelFont(new Font("", Font.PLAIN, 16));
        dateaxis.setTickLabelPaint(ChartColor.GRAY);

        dateaxis.setMinimumDate(startgc.getTime());
        GregorianCalendar endgc = (GregorianCalendar) startgc.clone();
        endgc.add(GregorianCalendar.DATE, duration);
        dateaxis.setMaximumDate(endgc.getTime());

        dateaxis.setTickMarksVisible(true);
        dateaxis.setTickMarkInsideLength(5);
        dateaxis.setTickUnit(new DateTickUnit(DateTickUnitType.DAY, 1));
        dateaxis.setVerticalTickLabels(true);
        dateaxis.setLabel("");

        //
        ValueAxis rangeAxis = xyplot.getRangeAxis();//?
        rangeAxis.setLabelFont(new Font("", Font.PLAIN, 16));
        rangeAxis.setLabelPaint(ChartColor.gray);
        rangeAxis.setTickLabelFont(new Font("", Font.PLAIN, 16));
        rangeAxis.setTickLabelPaint(ChartColor.gray);
        rangeAxis.setLowerBound(0);

        //
        jfreechart.getLegend().setItemFont(new Font("", Font.PLAIN, 12));
        jfreechart.getLegend().setItemPaint(ChartColor.gray);
        jfreechart.getLegend().setBorder(0, 0, 0, 0);//

        //
        jfreechart.getTitle().setFont(new Font("", Font.PLAIN, 18));//
        jfreechart.getTitle().setPaint(ChartColor.gray);

        //?
        xyplot.setRangeGridlinePaint(ChartColor.GRAY);
        xyplot.setBackgroundPaint(ChartColor.WHITE);
        xyplot.setOutlinePaint(null);//

        int w = 500;
        int h = 300;

        // ChartUtilities.saveChartAsPNG(new File(filename), jfreechart, w, h);
        ChartUtilities.saveChartAsJPEG(new File(filename), 0.8f, jfreechart, w, h);

        return "success";

    } catch (Exception e) {
        e.printStackTrace();
        return e.getMessage();
    }
}

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

public GenericScatterGraph(XYSeries series, String xAxis, String yAxis) {
    super();/*from   w  w w  . j a va  2s.  c o  m*/

    XYDataset xyDataset = new XYSeriesCollection(series);

    JFreeChart chart = ChartFactory.createScatterPlot("", // chart title
            xAxis, // x axis label
            yAxis, // y axis label
            null, PlotOrientation.VERTICAL, false, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.darkGray);
    plot = chart.getXYPlot();
    plot.setDataset(0, xyDataset);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    // Shape cross = ShapeUtilities.createDiamond(0.5f);
    Shape cross = ShapeUtilities.createDiagonalCross(0.5f, 0.5f);
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, new Color(252, 141, 89));
    renderer.setSeriesShape(0, cross);

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

    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setTickLabelPaint(Color.white);
    rangeAxis.setLabelPaint(Color.white);

    chartPanel = new ChartPanel(chart);
    chartPanel.setSize(100, 800);

    setLayout(new BorderLayout());
    add(chartPanel, BorderLayout.CENTER);
    setBackground(Color.black);

    chartPanel.revalidate();
    setVisible(true);
}

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

public MMPGraph(XYSeries series) {
    super();/*from  ww  w. j av a2s  .  com*/

    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:oscar.oscarEncounter.oscarMeasurements.pageUtil.MeasurementGraphAction2.java

private static XYItemRenderer setAxisAndDataSet(int i, XYPlot plot, ValueAxis axis, XYDataset dataset, Paint p,
        XYItemRenderer renderer) {//from  ww  w .  j  ava 2s. co m
    plot.setRangeAxis(i, axis);
    plot.setDataset(i, dataset);
    plot.mapDatasetToRangeAxis(i, i);

    renderer.setSeriesPaint(0, p);
    axis.setLabelPaint(p);
    axis.setTickLabelPaint(p);
    return renderer;
}

From source file:oscar.oscarEncounter.oscarMeasurements.pageUtil.MeasurementGraphAction2.java

private static XYItemRenderer setAxisAndDataSet(int i, XYPlot plot, ValueAxis axis, XYDataset dataset,
        Paint p) {// w  ww.  ja  v a2  s. c  om
    plot.setRangeAxis(i, axis);
    plot.setDataset(i, dataset);
    plot.mapDatasetToRangeAxis(i, i);

    XYItemRenderer renderer = new StandardXYItemRenderer();
    renderer.setSeriesPaint(0, p);
    axis.setLabelPaint(p);
    axis.setTickLabelPaint(p);
    return renderer;
}

From source file:com.xilinx.ultrascale.gui.BarChartsEth.java

License:asdf

private void makeChart(String name) {
    dataset = new DefaultCategoryDataset();
    //        chart = ChartFactory.createLineChart("", "", name, dataset, PlotOrientation.VERTICAL, true, true, false);
    //        chart = ChartFactory.createBarChart("asd", "asd", "asdffa", dataset, PlotOrientation.HORIZONTAL, true, true, false);

    chart = ChartFactory.createBarChart("power", "Time Interval", "Throughput (Gbps)", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    chart.setBackgroundPaint(bg);// w  w w .  j  a  v  a2 s.  c o  m

    TextTitle ttitle = new TextTitle(title, new Font(title, Font.BOLD, 15));
    ttitle.setPaint(Color.BLACK);
    chart.setTitle(ttitle);

    CategoryPlot plot = chart.getCategoryPlot();
    //        BarRenderer renderer = (BarRenderer)plot.getRenderer();
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    ValueAxis axis = plot.getRangeAxis();
    upperBounds(65);

    axis.setTickLabelPaint(new Color(0, 0, 0));//(185, 185, 185)
    axis.setLabelPaint(new Color(0, 0, 0));

    CategoryAxis caxis = plot.getDomainAxis();
    caxis.setTickLabelPaint(new Color(0, 0, 0));
    caxis.setLabelPaint(new Color(0, 0, 0));

    renderer.setItemMargin(0);
    renderer.setSeriesPaint(0, new Color(0x2e, 0x90, 0x18));//(0x17, 0x7b, 0x7c));
    renderer.setSeriesPaint(1, new Color(0x12, 0x45, 0x73));//(0xa2, 0x45, 0x73)
    renderer.setSeriesPaint(3, new Color(0xff, 0x80, 0x40));
    renderer.setSeriesPaint(2, new Color(0x6f, 0x2c, 0x85));
    //        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator("{0}:{2}", new DecimalFormat("0.000")));
    //renderer.setMaximumBarWidth(0.05);
    addDummy();
}

From source file:com.wattzap.view.Profile.java

@Override
public void callback(Messages message, Object o) {
    double distance = 0.0;
    switch (message) {
    case SPEED://from  w  ww .  j a v  a 2 s .c  o m
        Telemetry t = (Telemetry) o;
        distance = t.getDistanceKM();
        break;
    case STARTPOS:
        distance = (Double) o;
        break;
    case CLOSE:
        if (this.isVisible()) {
            remove(chartPanel);
            setVisible(false);
            revalidate();
        }

        return;
    case GPXLOAD:
        // Note if we are loading a Power Profile there is no GPX data so we don't show the chart panel
        RouteReader routeData = (RouteReader) o;

        if (chartPanel != null) {
            remove(chartPanel);
            if (routeData.routeType() == RouteReader.POWER) {
                setVisible(false);
                chartPanel.revalidate();
                return;
            }
        } else if (routeData.routeType() == RouteReader.POWER) {
            return;
        }

        logger.debug("Load " + routeData.getFilename());
        XYDataset xyDataset = new XYSeriesCollection(routeData.getSeries());

        // create the chart...
        final JFreeChart chart = ChartFactory.createXYAreaChart(routeData.getName(), // chart
                // title
                userPrefs.messages.getString("distancekm"), // domain axis label
                userPrefs.messages.getString("heightMeters"), // range axis label
                xyDataset, // data
                PlotOrientation.VERTICAL, // orientation
                false, // include legend
                false, // tooltips
                false // urls
        );

        chart.setBackgroundPaint(Color.darkGray);

        plot = chart.getXYPlot();
        // plot.setForegroundAlpha(0.85f);

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

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

        double minY = routeData.getSeries().getMinY();
        double maxY = routeData.getSeries().getMaxY();
        rangeAxis.setRange(minY - 100.0, maxY + 100.0);

        chartPanel = new ChartPanel(chart);

        chartPanel.setSize(100, 800);

        setLayout(new BorderLayout());
        add(chartPanel, BorderLayout.CENTER);
        setBackground(Color.black);
        chartPanel.revalidate();
        setVisible(true);
        break;
    }// switch
    if (plot == null) {
        return;
    }

    if (marker != null) {
        plot.removeDomainMarker(marker);
    }
    marker = new ValueMarker(distance);

    marker.setPaint(Color.blue);
    BasicStroke stroke = new BasicStroke(2);
    marker.setStroke(stroke);
    plot.addDomainMarker(marker);

}