Example usage for org.jfree.chart.axis DateTickMarkPosition START

List of usage examples for org.jfree.chart.axis DateTickMarkPosition START

Introduction

In this page you can find the example usage for org.jfree.chart.axis DateTickMarkPosition START.

Prototype

DateTickMarkPosition START

To view the source code for org.jfree.chart.axis DateTickMarkPosition START.

Click Source Link

Document

Start of period.

Usage

From source file:com.xpn.xwiki.plugin.charts.params.DateTickMarkPositionChartParam.java

@Override
protected void init() {
    addChoice("start", DateTickMarkPosition.START);
    addChoice("middle", DateTickMarkPosition.MIDDLE);
    addChoice("end", DateTickMarkPosition.END);
}

From source file:de.stefanwndelmann.zy1270logger.Test.TestJFreeChart.java

private void initJFreeChart() {
    voltageSeries = new TimeSeries("Voltage");
    ampSeries = new TimeSeries("Amps");
    dataset = new TimeSeriesCollection(voltageSeries);
    dataset.addSeries(ampSeries);//from ww w.  j  a  v a 2  s .co  m
    chart = ChartFactory.createTimeSeriesChart("Test Chart", "Time (seconds)", "U/I", dataset);
    DateAxis axis = (DateAxis) chart.getXYPlot().getDomainAxis();
    //        axis.setTickUnit(new DateTickUnit(DateTickUnitType.MILLISECOND, 1));
    axis.setTickMarkPosition(DateTickMarkPosition.START);
    axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss.SSS"));
    chart.setAntiAlias(true);
    chart.setTextAntiAlias(true);
    this.add(new ChartPanel(chart), BorderLayout.CENTER);
}

From source file:de.stefanwndelmann.zy1270logger.ZY1270LoggerMain.java

private void initJFreeChart() {
    voltageSeries = new TimeSeries("Voltage");
    ampSeries = new TimeSeries("Amps");
    wattSeries = new TimeSeries("Watt");
    dataset = new TimeSeriesCollection(voltageSeries);
    dataset.addSeries(ampSeries);/*  w  w  w  . j  av a 2s .c o  m*/
    dataset.addSeries(wattSeries);
    chart = ChartFactory.createTimeSeriesChart("Live Data", "Time", "U/I/P", dataset);
    DateAxis axis = (DateAxis) chart.getXYPlot().getDomainAxis();
    axis.setTickMarkPosition(DateTickMarkPosition.START);
    axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss.SSS"));
    chart.setAntiAlias(true);
    chart.setTextAntiAlias(true);
    chartPanel = new ChartPanel(chart);
    jFreeChartPanel.add(chartPanel, BorderLayout.CENTER);
}

From source file:ec.nbdemetra.benchmarking.calendarization.CalendarizationChartView.java

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

    result.setTitle(new TextTitle(title, new Font("SansSerif", Font.PLAIN, 12)));

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

    LinesThickness linesThickness = LinesThickness.Thin;

    XYLineAndShapeRenderer daily = new XYLineAndShapeRenderer(true, false);
    daily.setAutoPopulateSeriesPaint(false);

    daily.setAutoPopulateSeriesStroke(false);
    daily.setBaseStroke(TsCharts.getStrongStroke(linesThickness));
    plot.setRenderer(DAILY_INDEX, daily);

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

    XYLineAndShapeRenderer smooth = new XYLineAndShapeRenderer(true, false);
    smooth.setAutoPopulateSeriesPaint(false);
    smooth.setAutoPopulateSeriesStroke(false);
    smooth.setBaseStroke(TsCharts.getStrongStroke(linesThickness));
    plot.setRenderer(SMOOTH_INDEX, smooth);

    DateAxis domainAxis = new DateAxis();
    domainAxis.setTickMarkPosition(DateTickMarkPosition.START);
    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.infoglue.deliver.util.charts.TimeSeriesDiagram.java

/**
 * Creates a chart./*from  w  w w.j  a  v  a 2s .co m*/
 * 
 * @param dataset  a dataset.
 * 
 * @return A chart.
 */

private JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart(header, axisXHeader, axisYHeader, dataset, true, true,
            false);

    chart.setBackgroundPaint(Color.white);

    LegendTitle legend = chart.getLegend();
    //legend.set .setDisplaySeriesShapes(true);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(UnitType.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    XYItemRenderer renderer = plot.getRenderer();
    if (renderer instanceof StandardXYItemRenderer) {
        StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer;
        //rr.setPlotShapes(true);
        rr.setShapesFilled(true);
    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();

    if (this.timeGranulariry.equalsIgnoreCase("Week")) {
        DateTickUnit unit = new DateTickUnit(DateTickUnit.DAY, 7, new SimpleDateFormat(this.dateFormat));
        axis.setTickUnit(unit);
        axis.setTickMarkPosition(DateTickMarkPosition.START);

        axis.setDateFormatOverride(new SimpleDateFormat(this.dateFormat));
    } else {
        axis.setDateFormatOverride(new SimpleDateFormat(this.dateFormat));
    }
    /*
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat(this.dateFormat));
      */
    return chart;

}

From source file:org.jstockchart.plot.TimeseriesPlot.java

private CombinedDomainXYPlot createCombinedXYPlot() {
    Font axisFont = new Font("Arial", 0, 12);
    Stroke stroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f,
            new float[] { 1.0f, 1.0f }, 1.0f);
    LogicDateAxis logicDateAxis = timeseriesArea.getlogicDateAxis();
    TimeseriesDateAxis dateAxis = new TimeseriesDateAxis(logicDateAxis.getLogicTicks());
    if (timeline != null) {
        dateAxis.setTimeline(timeline);/*ww  w . j  av a2 s. co m*/
    }
    dateAxis.setTickLabelFont(axisFont);
    dateAxis.setTickMarkStroke(stroke);
    List<String> hideTick = new ArrayList<String>();
    hideTick.add("10:00");
    hideTick.add("11:00");
    hideTick.add("13:30");
    //hideTick.add("14:30");
    hideTick.add("14:30");
    dateAxis.setHideTickLabel(hideTick);
    dateAxis.setTickMarkPosition(DateTickMarkPosition.START);
    dateAxis.setTickMarksVisible(false);
    Date startTime = DateUtils.createDate(2008, 1, 1, 9, 30, 0);
    Date endTime = DateUtils.createDate(2008, 1, 1, 15, 0, 0);
    dateAxis.setRange(timeseriesArea.getStartDate(), timeseriesArea.getEndDate());
    dateAxis.setAxisLineVisible(false);
    CFXCombinedPlot combinedDomainXYPlot = new CFXCombinedPlot(dateAxis);
    combinedDomainXYPlot.setInsets(new RectangleInsets(5, 2, 4, 2));

    AxisSpace axisSpace = new AxisSpace();
    axisSpace.setBottom(22);
    axisSpace.setLeft(0);
    axisSpace.setRight(0);
    axisSpace.setTop(0);
    combinedDomainXYPlot.setFixedDomainAxisSpace(axisSpace);
    combinedDomainXYPlot.setGap(0);
    combinedDomainXYPlot.setOrientation(timeseriesArea.getOrientation());
    combinedDomainXYPlot.setDomainAxis(dateAxis);
    combinedDomainXYPlot.setDomainAxisLocation(timeseriesArea.getDateAxisLocation());

    if (timeseriesArea.getPriceWeight() <= 0 && timeseriesArea.getVolumeWeight() <= 0) {
        throw new IllegalArgumentException("Illegal weight value: priceWeight="
                + timeseriesArea.getPriceWeight() + ", volumeWeight=" + timeseriesArea.getVolumeWeight());
    }

    if (timeseriesArea.getPriceWeight() > 0) {
        XYPlot pricePlot = createPricePlot();
        combinedDomainXYPlot.add(pricePlot, timeseriesArea.getPriceWeight());
    }

    if (timeseriesArea.getVolumeWeight() > 0) {
        XYPlot volumePlot = createVolumePlot();
        combinedDomainXYPlot.add(volumePlot, timeseriesArea.getVolumeWeight());
    }

    return combinedDomainXYPlot;
}

From source file:com.bdb.weather.display.summary.HighLowPanel.java

@SuppressWarnings("LeakingThisInConstructor")
public HighLowPanel(String title, SummaryInterval interval, ViewLauncher launcher, SummarySupporter supporter,
        ValueAxis rangeAxis, String domainAxisLabel, SeriesInfo<T>[] seriesList, NumberFormat format) {
    this.setPrefSize(500, 300);
    this.interval = interval;
    this.launcher = launcher;
    this.supporter = supporter;

    chart = ChartFactory.createHighLowChart(title, domainAxisLabel, "", seriesCollection, true);
    chart.getLegend().setPosition(RectangleEdge.RIGHT);

    plot = (XYPlot) chart.getPlot();//www . j  a  v  a 2s  .  com
    renderer = (HighLowRenderer) plot.getRenderer();
    renderer.setDrawCloseTicks(false);

    plot.setRangeAxis(rangeAxis);

    dateAxis = (DateAxis) plot.getDomainAxis();
    dateAxis.setDateFormatOverride(interval.getLegacyFormat());
    dateAxis.setVerticalTickLabels(true);
    dateAxis.setTickMarkPosition(DateTickMarkPosition.START);
    //dateAxis.setTickUnit(interval.getDateTickUnit());
    //dateAxis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH, 2));

    ChartViewer chartViewer = new ChartViewer(chart);
    chartViewer.addChartMouseListener(this);
    chartViewer.setPrefSize(500, 300);

    series = new OHLCSeries[seriesList.length];

    for (int i = 0; i < seriesList.length; i++) {
        series[i] = new OHLCSeries(seriesList[i].getSeriesName());
        seriesCollection.addSeries(series[i]);
    }

    seriesInfo = Arrays.copyOf(seriesList, seriesList.length);

    TableColumn<SummaryRecord, String> column = new TableColumn<>("Date");
    column.setCellValueFactory(
            (rec) -> new ReadOnlyStringWrapper(DisplayConstants.formatDate(rec.getValue().getDate())));

    dataTable.getColumns().add(column);

    String headingPrefix[] = { HIGH_COL_HEADING, LOW_COL_HEADING, AVG_COL_HEADING };

    for (SeriesInfo<T> seriesColumn : seriesList) {
        for (String heading : headingPrefix) {
            column = new TableColumn<>(heading + " - " + seriesColumn.getSeriesName());
            column.setCellValueFactory(seriesColumn);
            column.setUserData(heading);
            dataTable.getColumns().add(column);
        }
    }

    this.setTabContents(chartViewer, dataTable);

    HighLowItemLabelGenerator ttg = new HiLoItemLabelGenerator(interval.getLegacyFormat(), format);
    plot.getRenderer().setBaseToolTipGenerator(ttg);
}

From source file:figs.treeVisualization.gui.PhyloDateAxis.java

/**
 * Returns the previous "standard" date, for a given date and tick unit.
 *
 * @param date  the reference date.//from  w w w  .  j ava2 s .  co  m
 * @param unit  the tick unit.
 *
 * @return The previous "standard" date.
 */
@Override
protected Date previousStandardDate(Date date, DateTickUnit unit) {

    int hours;
    int days;
    int months;
    int years;

    Calendar calendar = Calendar.getInstance(TimeZone.getDefault());
    calendar.setTime(getMinimumDate());
    int current = calendar.get(unit.getCalendarField());

    // We only care about DAY, MONTH, YEAR
    DateTickMarkPosition tickMarkPosition = this.getTickMarkPosition();
    switch (unit.getUnit()) {
    case (DateTickUnit.DAY):
        years = calendar.get(Calendar.YEAR);
        months = calendar.get(Calendar.MONTH);

        if (tickMarkPosition == DateTickMarkPosition.START) {
            hours = 0;
        } else if (tickMarkPosition == DateTickMarkPosition.MIDDLE) {
            hours = 12;
        } else {
            hours = 23;
        }
        calendar.clear(Calendar.MILLISECOND);
        calendar.set(years, months, current, hours, 0, 0);

        long result = calendar.getTime().getTime();
        if (result > date.getTime()) {
            // move it back a day
            calendar.set(years, months, current - 1, hours, 0, 0);
        }
        return calendar.getTime();
    case (DateTickUnit.MONTH):
        years = calendar.get(Calendar.YEAR);
        calendar.clear(Calendar.MILLISECOND);
        calendar.set(years, current, 1, 0, 0, 0);
        // TODO:
        /*
        Month month = new Month(calendar.getTime());
        Date standardDate = calculateDateForPosition(
            month, tickMarkPosition
        );
        long millis = standardDate.getTime();
        if (millis > date.getTime()) {
            month = (Month) month.previous();
            standardDate = calculateDateForPosition(
                month, tickMarkPosition
            );
        }
        return standardDate;
        */
        return calendar.getTime();
    case (DateTickUnit.YEAR):
        if (tickMarkPosition == DateTickMarkPosition.START) {
            months = 0;
            days = 1;
        } else if (tickMarkPosition == DateTickMarkPosition.MIDDLE) {
            months = 6;
            days = 1;
        } else {
            months = 11;
            days = 31;
        }
        calendar.clear(Calendar.MILLISECOND);
        calendar.set(current, months, days, 0, 0, 0);
        return calendar.getTime();
    default:
        return calendar.getTime();
    }

}

From source file:eu.cassandra.platform.gui.GUI.java

public JFreeChart createChart(String title, final XYDataset dataset) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart(title, "Time", "Consumption (W)", dataset,
            false, true, true);//from   w  w w  .  ja va2s  .  c o m

    DateAxis axis = (DateAxis) chart.getXYPlot().getDomainAxis();
    axis.setTickUnit(new DateTickUnit(DateTickUnitType.DAY, 1));
    axis.setTickMarkPosition(DateTickMarkPosition.START);
    axis.setDateFormatOverride(new SimpleDateFormat("dd"));

    //      XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    //      BasicStroke basicStroke = new BasicStroke(1f);
    //      renderer.setSeriesStroke(0, basicStroke);
    //      chart.getXYPlot().setRenderer(renderer);

    chart.setAntiAlias(true);
    chart.setTextAntiAlias(true);

    return chart;
}

From source file:org.n52.oxf.render.sos.TimeSeriesMapChartRenderer.java

/**
 * The resulting chart consists a TimeSeries for each FeatureOfInterest contained in the
 * observationCollection.//from  w w  w. j a v a2 s  .  c  o m
 * 
 * @param foiIdArray
 *        the IDs of the FeaturesOfInterest whose Observations shall be rendered
 * @param observationCollection
 * @return
 */
protected XYPlot drawChart4FOI(String foiID, Map<ITimePosition, ObservedValueTuple> timeMap) {

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    TimeSeries timeSeries = new TimeSeries(foiID, Second.class);

    for (ITimePosition timePos : timeMap.keySet()) {
        Number value = (Number) timeMap.get(timePos).getValue(0);
        timeSeries.add(
                new Second(new Float(timePos.getSecond()).intValue(), timePos.getMinute(), timePos.getHour(),
                        timePos.getDay(), timePos.getMonth(), new Long(timePos.getYear()).intValue()),
                value);
    }

    dataset.addSeries(timeSeries);
    dataset.setDomainIsPointsInTime(true);

    //
    // create Plot:
    //

    XYPlot plot = new XYPlot();

    plot.setDataset(dataset);
    plot.setBackgroundPaint(Color.white);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setBaseShapesVisible(false);
    plot.setRenderer(renderer);

    DateAxis dateAxis = new DateAxis();
    dateAxis.setTickMarkPosition(DateTickMarkPosition.START);
    dateAxis.setTickMarksVisible(true);
    dateAxis.setVerticalTickLabels(true);
    dateAxis.setDateFormatOverride(new SimpleDateFormat("dd'.'MM'.'"));
    plot.setDomainAxis(dateAxis);

    plot.setRangeAxis(new NumberAxis());

    return plot;
}