Search in sources :

Example 6 with DateData

use of net.sourceforge.processdash.data.DateData in project processdash by dtuma.

the class XYChart method createChart.

/** Create a scatter plot. */
@Override
public JFreeChart createChart() {
    JFreeChart chart;
    String xLabel = null, yLabel = null;
    if (!chromeless) {
        xLabel = Translator.translate(data.getColName(1));
        yLabel = getSetting("yLabel");
        if (yLabel == null && data.numCols() == 2)
            yLabel = data.getColName(2);
        if (yLabel == null)
            yLabel = getSetting("units");
        if (yLabel == null)
            yLabel = "Value";
        yLabel = Translator.translate(yLabel);
    }
    Object autoZero = parameters.get("autoZero");
    boolean firstColumnContainsDate = data.numRows() > 0 && data.numCols() > 0 && data.getData(1, 1) instanceof DateData;
    if (firstColumnContainsDate || parameters.get("xDate") != null) {
        chart = ChartFactory.createTimeSeriesChart(null, xLabel, yLabel, data.xyDataSource(), true, true, false);
        if (firstColumnContainsDate && ((DateData) data.getData(1, 1)).isFormatAsDateOnly())
            chart.getXYPlot().getRenderer().setBaseToolTipGenerator(new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, DateFormat.getDateInstance(DateFormat.SHORT), NumberFormat.getInstance()));
    } else {
        XYDataset src = data.xyDataSource();
        chart = ChartFactory.createScatterPlot(null, xLabel, yLabel, src, PlotOrientation.VERTICAL, true, true, false);
        if (src instanceof XYToolTipGenerator) {
            chart.getXYPlot().getRenderer().setBaseToolTipGenerator((XYToolTipGenerator) src);
        }
        String trendLine = getParameter("trend");
        if ("none".equalsIgnoreCase(trendLine))
            ;
        else if ("average".equalsIgnoreCase(trendLine))
            addTrendLine(chart, XYDataSourceTrendLine.getAverageLine(src, 0, autoZero != null && !autoZero.equals("y")));
        else
            addTrendLine(chart, XYDataSourceTrendLine.getRegressionLine(src, 0, autoZero != null && !autoZero.equals("y")));
    }
    if (autoZero != null) {
        if (!"x".equals(autoZero))
            ((NumberAxis) chart.getXYPlot().getRangeAxis()).setAutoRangeIncludesZero(true);
        if (!"y".equals(autoZero))
            ((NumberAxis) chart.getXYPlot().getDomainAxis()).setAutoRangeIncludesZero(true);
    }
    if (data.numCols() == 2)
        chart.removeLegend();
    return chart;
}
Also used : StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) DateData(net.sourceforge.processdash.data.DateData) XYDataset(org.jfree.data.xy.XYDataset) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator) JFreeChart(org.jfree.chart.JFreeChart)

Example 7 with DateData

use of net.sourceforge.processdash.data.DateData in project processdash by dtuma.

the class StudentProfileValidator method checkValues.

private boolean checkValues() {
    String owner = getOwner();
    if (owner == null || owner.trim().length() == 0)
        return false;
    DataContext c = getDataContext();
    for (String name : NAMES_TO_CHECK) {
        SimpleData sd = c.getSimpleValue(name);
        if (sd == null || !sd.test() || sd.format().trim().length() == 0)
            return false;
    }
    c.putValue("../Student_Profile_Complete", ImmutableDoubleData.TRUE);
    if (c.getSimpleValue("Completed") == null)
        c.putValue("Completed", new DateData());
    return true;
}
Also used : DataContext(net.sourceforge.processdash.data.DataContext) DateData(net.sourceforge.processdash.data.DateData) SimpleData(net.sourceforge.processdash.data.SimpleData)

Example 8 with DateData

use of net.sourceforge.processdash.data.DateData in project processdash by dtuma.

the class McfSizeMetricApiHandler method maybeShowNotification.

/**
     * Register a user notification if requested by the client.
     */
private void maybeShowNotification(SizeMetricApiRequestData request, String dataPrefix) {
    if ("true".equals(request.params.get("notify"))) {
        DateData timestamp = new DateData();
        writeHighlightFlags(request, dataPrefix, timestamp);
        addNotification(request, timestamp);
    }
}
Also used : DateData(net.sourceforge.processdash.data.DateData)

Example 9 with DateData

use of net.sourceforge.processdash.data.DateData in project processdash by dtuma.

the class TinyCGIBase method getPostToken.

/**
     * Retrieve the token that was previously generated by
     * {@link #generatePostToken(String)}
     *
     * @param dataNameSuffix the suffix that was used to generate the token
     * @since 1.14.0.1
     */
protected String getPostToken(String dataNameSuffix) {
    String dataName = getPostTokenDataName(dataNameSuffix);
    SimpleData storedToken = getDataRepository().getSimpleValue(dataName);
    SimpleData storedDate = getDataRepository().getSimpleValue(dataName + "/TS");
    if (storedToken != null && storedDate instanceof DateData) {
        DateData date = (DateData) storedDate;
        long age = System.currentTimeMillis() - date.getValue().getTime();
        if (age > 0 && age < getPostTokenAgeTimeout())
            return storedToken.format();
    }
    return null;
}
Also used : DateData(net.sourceforge.processdash.data.DateData) SimpleData(net.sourceforge.processdash.data.SimpleData)

Example 10 with DateData

use of net.sourceforge.processdash.data.DateData in project processdash by dtuma.

the class TaskStatusApi method storeCompletionDate.

private void storeCompletionDate(String path, String newDateParam) {
    DateData newDate = null;
    if (!"".equals(newDateParam) && !"null".equals(newDateParam)) {
        try {
            Date d;
            if ("now".equals(newDateParam))
                d = new Date();
            else
                d = WebApiUtils.DATE_FMT.parse(newDateParam);
            newDate = new DateData(d, true);
        } catch (ParseException e) {
            throw new WebApiException("parameter-invalid", 400, "The 'completionDate' parameter value '" + newDateParam + "' is not a valid date.").causedBy(e).putAttr("param", "completionDate");
        }
    }
    String dataName = path + "/Completed";
    SaveableData currentDate = getDataContext().getValue(dataName);
    if (currentDate != null && !(currentDate instanceof DateData))
        throw new WebApiException("date-not-editable", 400, "The completion date is not editable for task '" + path + "'.");
    getDataContext().putValue(dataName, newDate);
}
Also used : DateData(net.sourceforge.processdash.data.DateData) ParseException(java.text.ParseException) SaveableData(net.sourceforge.processdash.data.SaveableData) Date(java.util.Date)

Aggregations

DateData (net.sourceforge.processdash.data.DateData)31 SimpleData (net.sourceforge.processdash.data.SimpleData)10 Date (java.util.Date)6 Iterator (java.util.Iterator)3 SaveableData (net.sourceforge.processdash.data.SaveableData)3 DataContext (net.sourceforge.processdash.data.DataContext)2 DoubleData (net.sourceforge.processdash.data.DoubleData)2 ListData (net.sourceforge.processdash.data.ListData)2 EscapeString (net.sourceforge.processdash.util.EscapeString)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 ConcurrentModificationException (java.util.ConcurrentModificationException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 UUID (java.util.UUID)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 MalformedData (net.sourceforge.processdash.data.MalformedData)1 MalformedValueException (net.sourceforge.processdash.data.MalformedValueException)1