use of org.jfree.data.time.TimeSeries in project cubrid-manager by CUBRID.
the class ChartCompositePart method updateSettingChart.
/**
* Update setting chart
*
* @param item the selected item
* @param checked whether show in the table
* @param seriesRgb the background color of the selected item
* @param width the width of the selected item
*/
@SuppressWarnings("unchecked")
private void updateSettingChart(String item, boolean checked, RGB seriesRgb, float width) {
Color color = new Color(seriesRgb.red, seriesRgb.green, seriesRgb.blue);
if (checked) {
if (timeseriescollection.getSeries(item) == null) {
timeseriescollection.addSeries(seriesMap.get(item));
}
List<TimeSeries> list = timeseriescollection.getSeries();
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getKey().equals(item)) {
xylineandshaperenderer.setSeriesPaint(i, color);
xylineandshaperenderer.setSeriesStroke(i, new BasicStroke(width, 0, 2));
break;
}
}
} else {
if (timeseriescollection.getSeries(item) != null) {
timeseriescollection.removeSeries(seriesMap.get(item));
}
}
}
use of org.jfree.data.time.TimeSeries in project cubrid-manager by CUBRID.
the class MonitorStatisticChart method buildInvalidData.
/**
* Build TimeSeries for StatisticData which has no data. After build, each
* TimeSeries accompany with the StatisticData will have the same time
* series with ordinary TimeSeries, but all the values will be -1.
*
* @param dataset
* @param timeType
* @param dataItemWithoutDataList
* @param current
* @param interalMillisecs
*/
private void buildInvalidData(TimeSeriesCollection dataset, TimeType timeType, List<StatisticData> dataItemWithoutDataList, Date current, long interalMillisecs) {
for (StatisticData statisticData : dataItemWithoutDataList) {
TimeSeries series = null;
if (isDetailView) {
series = new TimeSeries(statisticData.getDescription(isMultiHost));
} else {
series = new TimeSeries(statisticData.getSimpleDescription(isMultiHost));
}
Date point = (Date) current.clone();
long curMillisecs = current.getTime();
for (int i = 0; i < dataSize; i++) {
point.setTime(curMillisecs - (dataSize - i) * interalMillisecs);
switch(timeType) {
case DAILY:
series.add(new Second(point), -1);
break;
case WEEKLY:
series.add(new Hour(point), -1);
break;
case MONTHLY:
series.add(new Hour(point), -1);
break;
case YEARLY:
series.add(new Day(point), -1);
break;
default:
break;
}
}
maxValueMap.put(statisticData, -1d);
minValueMap.put(statisticData, -1d);
dataset.addSeries(series);
}
}
use of org.jfree.data.time.TimeSeries in project pentaho-platform by pentaho.
the class TimeSeriesCollectionChartDefinition method setDataByColumn.
private void setDataByColumn(final IPentahoResultSet data) {
// TODO Make this routine MDX friendly
if (data == null) {
// $NON-NLS-1$
noDataMessage = Messages.getInstance().getString("CHART.USER_NO_DATA_AVAILABLE");
// No data so we've got nothing to set
return;
// TODO come up with some sort of error strategy here.
}
boolean firstPass = true;
// $NON-NLS-1$
String lastSeries = "";
// $NON-NLS-1$
String seriesName = "";
Class timePeriodClass = TimeSeriesCollectionChartDefinition.getTimePeriodClass(getDomainPeriodType());
Object[] rowData = data.next();
TimeSeries wrkSeries = null;
while (rowData != null) {
seriesName = (String) rowData[0];
if (firstPass || !seriesName.equalsIgnoreCase(lastSeries)) {
if (!firstPass) {
addSeries(wrkSeries);
}
wrkSeries = new TimeSeries(seriesName, timePeriodClass);
lastSeries = seriesName;
firstPass = false;
}
Date keyDate = getValidDate(rowData[1]);
RegularTimePeriod regularTimePeriod = RegularTimePeriod.createInstance(timePeriodClass, keyDate, RegularTimePeriod.DEFAULT_TIME_ZONE);
TimeSeriesDataItem timeSeriesDataItem = new TimeSeriesDataItem(regularTimePeriod, ((Number) rowData[2]).doubleValue());
if (wrkSeries != null) {
wrkSeries.add(timeSeriesDataItem);
}
rowData = data.next();
}
if (!firstPass) {
addSeries(wrkSeries);
}
if ((data.getRowCount() > 0) && (this.getSeriesCount() <= 0)) {
// $NON-NLS-1$
noDataMessage = Messages.getInstance().getString("CHART.USER_INCORRECT_DATA_FORMAT");
}
}
use of org.jfree.data.time.TimeSeries in project spf4j by zolyfarkas.
the class Charts method createTimeSeriesCollection.
private static TimeSeriesCollection createTimeSeriesCollection(final String[] measurementNames, final long[] timestamps, final double[][] measurements) {
TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
for (int i = 0; i < measurementNames.length; i++) {
TimeSeries tseries = new TimeSeries(measurementNames[i]);
for (int j = 0; j < timestamps.length; j++) {
FixedMillisecond ts = new FixedMillisecond(timestamps[j]);
tseries.add(ts, measurements[i][j]);
}
timeseriescollection.addSeries(tseries);
}
return timeseriescollection;
}
use of org.jfree.data.time.TimeSeries in project spf4j by zolyfarkas.
the class Charts method createTimeSeriesCollection.
private static TimeSeriesCollection createTimeSeriesCollection(final String[] measurementNames, final long[][] timestamps, final double[][] measurements) {
TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
for (int i = 0; i < measurementNames.length; i++) {
TimeSeries tseries = new TimeSeries(measurementNames[i]);
for (int j = 0; j < timestamps[i].length; j++) {
FixedMillisecond ts = new FixedMillisecond(timestamps[i][j]);
tseries.add(ts, measurements[i][j]);
}
timeseriescollection.addSeries(tseries);
}
return timeseriescollection;
}
Aggregations