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;
}
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;
}
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);
}
}
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;
}
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);
}
Aggregations