Skip to content
Snippets Groups Projects
Commit c48110d6 authored by Raphael GIRARDOT's avatar Raphael GIRARDOT
Browse files

restore X autoscale when there is some data on X (TANGOARCH-938)

parent ae9dcbd7
No related branches found
No related tags found
No related merge requests found
......@@ -29,7 +29,9 @@ import fr.soleil.archiving.hdbtdb.api.tools.SamplingType;
import fr.soleil.comete.definition.event.ChartViewerEvent;
import fr.soleil.comete.definition.listener.IChartViewerListener;
import fr.soleil.comete.definition.widget.IChartViewer;
import fr.soleil.comete.definition.widget.properties.AxisProperties;
import fr.soleil.comete.definition.widget.properties.ChartProperties;
import fr.soleil.comete.definition.widget.properties.PlotProperties;
import fr.soleil.comete.swing.Chart;
import fr.soleil.comete.tango.data.service.helper.TangoExceptionHelper;
import fr.soleil.lib.project.ObjectUtils;
......@@ -249,11 +251,63 @@ public class ViewConfiguration implements IConfiguration {
}
}
protected boolean isOnX(PlotProperties properties) {
return (properties != null && properties.getAxisChoice() == IChartViewer.X);
}
protected boolean isOnX(ViewConfigurationAttributeProperties attrProperties) {
boolean hasX = false;
if (attrProperties != null) {
hasX = isOnX(attrProperties.getPlotProperties());
}
return hasX;
}
public void configureChart(Chart chart) {
if (chart != null) {
cleanChart(chart);
data.configureChart(chart);
chart.setDataDirectory(Mambo.getPathToResources());
// Chart is configured.
// Now check whether there is some data on X (TANGOARCH-938).
ViewConfigurationAttributes attributes = this.attributes;
Map<String, ExpressionAttribute> expressions = this.expressions;
boolean hasX = false;
if (attributes != null) {
Collection<ViewConfigurationAttribute> vcAttributes = attributes.getAttributeList();
if (vcAttributes != null) {
for (ViewConfigurationAttribute attribute : vcAttributes) {
if (attribute != null) {
hasX = isOnX(attribute.getProperties());
if (hasX) {
break;
}
}
}
}
}
if ((!hasX) && (expressions != null)) {
for (ExpressionAttribute expr : expressions.values()) {
if (expr != null) {
hasX = isOnX(expr.getProperties());
if (hasX) {
break;
}
}
}
}
// If there is some data on X, restore X autoscale (TANGOARCH-938).
if (hasX) {
ChartProperties chartProperties = data.getChartProperties();
if (chartProperties != null) {
AxisProperties xProperties = chartProperties.getXAxisProperties();
if (xProperties != null && xProperties.isAutoScale()) {
if (!chart.isAutoScale(IChartViewer.X)) {
chart.setAutoScale(true, IChartViewer.X);
}
}
}
}
chart.addChartViewerListener(chartListener);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment