Skip to content
Snippets Groups Projects
Commit f472c2b4 authored by tcarver's avatar tcarver
Browse files

add show average option

parent 70425791
Branches
Tags
No related merge requests found
...@@ -31,7 +31,6 @@ import uk.ac.sanger.artemis.plot.*; ...@@ -31,7 +31,6 @@ import uk.ac.sanger.artemis.plot.*;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.GridLayout; import java.awt.GridLayout;
...@@ -89,6 +88,8 @@ public abstract class Plot extends JPanel ...@@ -89,6 +88,8 @@ public abstract class Plot extends JPanel
**/ **/
protected boolean recalculate_flag = true; protected boolean recalculate_flag = true;
private boolean showAverage = true;
/** /**
* The x position of the last click or -1 if the user hasn't clicked * The x position of the last click or -1 if the user hasn't clicked
* anywhere yet or the user clicked outside the graph. * anywhere yet or the user clicked outside the graph.
...@@ -293,10 +294,9 @@ public abstract class Plot extends JPanel ...@@ -293,10 +294,9 @@ public abstract class Plot extends JPanel
}); });
popup.add(setScale); popup.add(setScale);
final JCheckBoxMenuItem scaling_toggle =
new JCheckBoxMenuItem("Scaling");
scaling_toggle.setState(getAlgorithm().scalingFlag()); final JCheckBoxMenuItem scaling_toggle =
new JCheckBoxMenuItem("Scaling",getAlgorithm().scalingFlag());
scaling_toggle.addItemListener(new ItemListener() scaling_toggle.addItemListener(new ItemListener()
{ {
public void itemStateChanged(ItemEvent _) public void itemStateChanged(ItemEvent _)
...@@ -306,9 +306,18 @@ public abstract class Plot extends JPanel ...@@ -306,9 +306,18 @@ public abstract class Plot extends JPanel
repaint(); repaint();
} }
}); });
popup.add(scaling_toggle); popup.add(scaling_toggle);
final JCheckBoxMenuItem showAverageLn = new JCheckBoxMenuItem("Show average", showAverage);
showAverageLn.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent _)
{
showAverage = showAverageLn.isSelected();
repaint();
}
});
popup.add(showAverageLn);
if(Plot.this instanceof BasePlot) if(Plot.this instanceof BasePlot)
{ {
...@@ -450,8 +459,7 @@ public abstract class Plot extends JPanel ...@@ -450,8 +459,7 @@ public abstract class Plot extends JPanel
{ {
public void actionPerformed(ActionEvent e) public void actionPerformed(ActionEvent e)
{ {
Dimension d = getSize(); rescale((int) (getSize().height * 0.9f));
rescale((int) (d.height * 0.9f));
} }
}); });
...@@ -459,8 +467,7 @@ public abstract class Plot extends JPanel ...@@ -459,8 +467,7 @@ public abstract class Plot extends JPanel
{ {
public void actionPerformed(ActionEvent e) public void actionPerformed(ActionEvent e)
{ {
Dimension d = getSize(); rescale((int) (getSize().height * 1.1f));
rescale((int) (d.height * 1.1f));
} }
}); });
...@@ -478,12 +485,10 @@ public abstract class Plot extends JPanel ...@@ -478,12 +485,10 @@ public abstract class Plot extends JPanel
if(select == 1) if(select == 1)
return; return;
try try
{ {
final int value = Integer rescale(Integer.parseInt(
.parseInt(newGraphHgt.getText().trim()); newGraphHgt.getText().trim()));
rescale(value);
} }
catch(NumberFormatException nfe) catch(NumberFormatException nfe)
{ {
...@@ -953,7 +958,8 @@ public abstract class Plot extends JPanel ...@@ -953,7 +958,8 @@ public abstract class Plot extends JPanel
final float max_value) final float max_value)
{ {
// if a heatmap do not show the average // if a heatmap do not show the average
if(lines != null && lines[0].getPlotType().equals(LineAttributes.PLOT_TYPES[2])) if(!showAverage || (
lines != null && lines[0].getPlotType().equals(LineAttributes.PLOT_TYPES[2])))
return; return;
final Float average = getAlgorithm().getAverage(); final Float average = getAlgorithm().getAverage();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment