use of org.swtchart.ISeries in project jbosstools-server by jbosstools.
the class TimelineChart method deleteMonitoredSeries.
/**
* Delete series if not monitored any longer.
*/
private void deleteMonitoredSeries() {
ISeriesSet seriesSet = getSeriesSet();
List<IMonitoredMXBeanAttribute> attributes = attributeGroup.getAttributes();
for (ISeries series : seriesSet.getSeries()) {
String seriesId = series.getId();
boolean found = false;
for (IMonitoredMXBeanAttribute attribute : attributes) {
if (series.getId().equals(getSeriesId(attribute))) {
found = true;
}
}
if (!found) {
seriesSet.deleteSeries(seriesId);
}
}
}
use of org.swtchart.ISeries in project jbosstools-server by jbosstools.
the class Marker method configureHovers.
/**
* Creates the hovers assuming that the time is almost the same among series
*
* @param invertedSeriesIndex
* The inverted series index
*/
private void configureHovers(Integer invertedSeriesIndex) {
ISeries largestSeries = getLargestSeries();
if (largestSeries == null) {
return;
}
// create hover for time
Date[] dates = largestSeries.getXDateSeries();
long time = dates[dates.length - invertedSeriesIndex].getTime();
StringBuffer buffer = new StringBuffer();
buffer.append(Messages.timeLabel).append(' ').append(// $NON-NLS-1$
new SimpleDateFormat("HH:mm:ss").format(time));
texts.put(TIME_KEY, buffer.toString());
int timeInPixel = chart.getAxisSet().getXAxes()[0].getPixelCoordinate(time);
configureHover(hovers.get(TIME_KEY), buffer.toString(), timeInPixel, chart.getPlotArea().getSize().y, true);
// create hover for values
for (ISeries series : chart.getSeriesSet().getSeries()) {
double[] ySeries = series.getYSeries();
int seriesIndex = ySeries.length - invertedSeriesIndex;
if (seriesIndex < 0) {
continue;
}
buffer = new StringBuffer();
// $NON-NLS-1$
buffer.append(series.getId()).append(": ").append(getFormattedValue(ySeries[seriesIndex]));
texts.put(series.getId(), buffer.toString());
int valueInPixel = chart.getAxisSet().getYAxes()[0].getPixelCoordinate(ySeries[seriesIndex]);
configureHover(hovers.get(series.getId()), buffer.toString(), timeInPixel, valueInPixel, false);
}
}
use of org.swtchart.ISeries in project jbosstools-server by jbosstools.
the class Marker method getInvertedSeriesIndex.
/**
* Gets the inverted series index that is the nearest to mouse position.
*
* @param desiredX
* The desired x pixel coordinate
* @return The inverted series index, or <tt>null</tt> if not found
*/
private Integer getInvertedSeriesIndex(int desiredX) {
long desiredTime = (long) chart.getAxisSet().getAxes()[0].getDataCoordinate(desiredX);
// find largest size of series
ISeries largestSeries = getLargestSeries();
if (largestSeries == null) {
return null;
}
// find the time series index
Date[] dates = largestSeries.getXDateSeries();
for (int i = 0; i < dates.length; i++) {
if (dates[i].getTime() < desiredTime && i != dates.length - 1) {
continue;
}
int nearestIndex;
if (i > 0 && dates[i].getTime() - desiredTime > desiredTime - dates[i - 1].getTime()) {
nearestIndex = i - 1;
} else {
nearestIndex = i;
}
return dates.length - nearestIndex;
}
return null;
}
Aggregations