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

optimizations with better legend placement (CONTROLGUI-403)

parent bd61f1b1
No related branches found
No related tags found
No related merge requests found
package fr.soleil.comete.bean.trend.view;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Window;
import java.io.File;
import java.util.Collection;
......@@ -281,6 +282,8 @@ public class ChartPanel extends JPanel implements ITrendFileListener, IChartView
public TrendChart() {
super();
// Don't update data map on data file loading (CONTROLGUI-403)
setUpdateDataMapWithFileLoading(false);
}
public String getSettingsDirectory() {
......@@ -294,7 +297,7 @@ public class ChartPanel extends JPanel implements ITrendFileListener, IChartView
}
public boolean hasData(String id) {
return (id != null) && data.containsKey(id);
return (id != null) && (getDataView(id, false) != null);
}
public boolean isSamplingEnabled() {
......@@ -314,6 +317,10 @@ public class ChartPanel extends JPanel implements ITrendFileListener, IChartView
protected void doApplyConfiguration(CfFileReader f) {
super.applyConfiguration(f);
SwingUtilities.invokeLater(() -> {
refresh(false);
repaint();
});
}
@Override
......@@ -356,6 +363,37 @@ public class ChartPanel extends JPanel implements ITrendFileListener, IChartView
doApplyConfiguration(configurationReader);
configurationReader = null;
}
if (isLegendVisible() && (chartLegend != null) && (chartSplitPane != null)) {
// Update legend placement (CONTROLGUI-403)
final int placement = getLabelPlacement(), width = getWidth(), height = getHeight();
final int div = chartSplitPane.getDividerSize();
final int minViewSize = 100, margin = 5;
final Dimension size = chartLegend.getPreferredSize();
switch (placement) {
case LABEL_LEFT:
if (width >= size.width + margin + div + minViewSize) {
chartSplitPane.setDividerLocation(size.width + margin);
repaint();
}
break;
case LABEL_RIGHT:
if (width >= size.width + margin + div + minViewSize) {
chartSplitPane.setDividerLocation(width - (size.width + margin + div));
repaint();
}
break;
case LABEL_UP:
if (height >= size.height + margin + div + minViewSize) {
chartSplitPane.setDividerLocation(size.height + margin);
}
break;
default:
if (height >= size.height + margin + div + minViewSize) {
chartSplitPane.setDividerLocation(height - (size.height + margin + div));
}
break;
}
}
});
super.finalActionOnceDataLoaded();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment