use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute in project tdi-studio-se by Talend.
the class ConfigureChartAction method performConfiguration.
/**
* Performs the configuration.
*
* @param chartTitle The chart title
* @param axisUnit The axis unit
* @param attributes The attributes
* @param removedAttributes The removed attributes
*/
private void performConfiguration(String chartTitle, AxisUnit axisUnit, List<MBeanAttribute> attributes, List<MBeanAttribute> removedAttributes) {
IMonitoredMXBeanGroup group = chart.getAttributeGroup();
group.setName(chartTitle);
group.setAxisUnit(axisUnit);
for (MBeanAttribute attribute : attributes) {
ObjectName objectName = attribute.getObjectName();
String attributeName = attribute.getAttributeName();
IMonitoredMXBeanAttribute monitoredAttribute = group.getAttribute(objectName, attributeName);
RGB rgb = attribute.getRgb();
if (monitoredAttribute == null) {
try {
group.addAttribute(objectName.getCanonicalName(), attributeName, new int[] { rgb.red, rgb.green, rgb.blue });
} catch (JvmCoreException e) {
Activator.log(Messages.addAttributeFailedMsg, e);
}
} else {
monitoredAttribute.setRGB(rgb.red, rgb.green, rgb.blue);
}
}
for (MBeanAttribute removedAttribute : removedAttributes) {
group.removeAttribute(removedAttribute.getObjectName().getCanonicalName(), removedAttribute.getAttributeName());
}
chart.refresh();
}
use of org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanAttribute in project tdi-studio-se by Talend.
the class TimelineChart method refreshChartWidget.
/**
* Refreshes the chart widget.
*/
void refreshChartWidget() {
if (isDisposed()) {
return;
}
deleteMonitoredSeries();
for (IMonitoredMXBeanAttribute attribute : attributeGroup.getAttributes()) {
String seriesId = getSeriesId(attribute);
ISeries series = getSeriesSet().getSeries(seriesId);
if (series == null) {
boolean enableArea = true;
series = addMonitoredSeries(attribute, enableArea);
if (series == null) {
return;
}
}
series.setXDateSeries(attribute.getDates().toArray(new Date[0]));
series.setYSeries(getYSeries(attribute));
setColor((ILineSeries) series, attribute.getRGB());
}
AxisUnit axisUnit = attributeGroup.getAxisUnit();
if (axisUnit == AxisUnit.MBytes) {
//$NON-NLS-1$
getAxisSet().getYAxis(0).getTick().setFormat(new DecimalFormat("#####.#M"));
getAxisSet().adjustRange();
} else if (axisUnit == AxisUnit.Percent) {
//$NON-NLS-1$
getAxisSet().getYAxis(0).getTick().setFormat(new DecimalFormat("###%"));
getAxisSet().getXAxis(0).adjustRange();
int y = getSize().y;
if (y > 0) {
getAxisSet().getYAxis(0).setRange(new Range(0, (y + 10) / (double) y));
}
} else if (axisUnit == AxisUnit.Count) {
getAxisSet().getYAxis(0).getTick().setFormat(NumberFormat.getIntegerInstance());
getAxisSet().adjustRange();
} else {
getAxisSet().adjustRange();
}
section.setText(attributeGroup.getName());
section.layout();
marker.redraw();
redraw();
}
Aggregations