public class FeatureColourChooser extends Panel implements
ActionListener, AdjustmentListener, ItemListener, MouseListener
{
- Frame frame;
+ JVDialog frame;
FeatureRenderer fr;
- FeatureSettings fs;
- AlignmentPanel ap;
+ FeatureSettings fs = null;
+ // AlignmentPanel ap;
GraduatedColor cs;
Object oldcs;
boolean adjusting = false;
private float min,max;
String type=null;
-
+
+ private AlignFrame af=null;
+ public FeatureColourChooser(AlignFrame af, String type)
+ {
+ this.af = af;
+ init(af.getSeqcanvas().getFeatureRenderer(), type);
+ }
public FeatureColourChooser(FeatureSettings fsettings, String type)
{
this.fs = fsettings;
+ init(fsettings.fr, type);
+ // this.ap = fsettings.ap;
+ }
+ private void init(FeatureRenderer frenderer,String type) {
this.type = type;
- fr = fsettings.fr;
- ap = fsettings.ap;
+ fr = frenderer;
float mm[] = ((float[][]) fr.minmax.get(type))[0];
min = mm[0];
max = mm[1];
}
minColour.setBackground(cs.getMinColor());
maxColour.setBackground(cs.getMaxColor());
+ colourFromLabel.setState(cs.isColourByLabel());
adjusting = true;
try
} catch (Exception ex)
{
}
- // To HERE!
+ threshold.select(cs.getThreshType()==AnnotationColourGradient.NO_THRESHOLD ? 0 : cs.getThreshType() == AnnotationColourGradient.ABOVE_THRESHOLD ? 1 : 2);
+
adjusting = false;
changeColour();
+ colourFromLabel.addItemListener(this);
slider.addAdjustmentListener(this);
slider.addMouseListener(this);
- frame = new Frame();
- frame.add(this);
- jalview.bin.JalviewLite.addFrame(frame, "Graduated Feature Colour for "+type, 480,
- 145);
+ Frame owner = (af!=null) ? af : fs.frame;
+ frame = new JVDialog(owner,"Graduated Feature Colour for "+type,true,480,248);
+ frame.setMainPanel(this);
validate();
+ frame.setVisible(true);
+ if (frame.accept) {
+ changeColour();
+ } else {
+ // cancel
+ reset();
+ PaintRefresher.Refresh(this, fr.av.getSequenceSetId());
+ frame.setVisible(false);
+ }
}
public FeatureColourChooser()
maxColour.addActionListener(this);
thresholdIsMin.addItemListener(this);
- ok.setLabel("OK");
- ok.addActionListener(this);
-
- cancel.setLabel("Cancel");
- cancel.addActionListener(this);
-
- this.setLayout(borderLayout1);
- jPanel2.setLayout(flowLayout1);
+ this.setLayout(new GridLayout(4,1));
+ jPanel1.setLayout(new FlowLayout());
+ jPanel2.setLayout(new FlowLayout());
+ jPanel3.setLayout(new GridLayout(1,1));
+ jPanel4.setLayout(new FlowLayout());
jPanel1.setBackground(Color.white);
jPanel2.setBackground(Color.white);
+ jPanel4.setBackground(Color.white);
threshold.addItemListener(this);
threshold.addItem("No Threshold");
threshold.addItem("Above Threshold");
threshold.addItem("Below Threshold");
- jPanel3.setLayout(null);
thresholdValue.addActionListener(this);
-
slider.setBackground(Color.white);
slider.setEnabled(false);
- slider.setBounds(new Rectangle(153, 3, 93, 21));
+ slider.setSize(new Dimension(93, 21));
thresholdValue.setEnabled(false);
- thresholdValue.setBounds(new Rectangle(248, 2, 79, 22));
+ thresholdValue.setSize(new Dimension(79,22)); //setBounds(new Rectangle(248, 2, 79, 22));
thresholdValue.setColumns(5);
jPanel3.setBackground(Color.white);
- //currentColours.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
- //currentColours.setLabel("Use Original Colours");
- //currentColours.addItemListener(this);
-
- threshold.setBounds(new Rectangle(11, 3, 139, 22));
+
+ colourFromLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
+ colourFromLabel.setLabel("Colour by Label");
+ colourFromLabel.setSize(new Dimension(139,22));
+ //threshold.setBounds(new Rectangle(11, 3, 139, 22));
thresholdIsMin.setBackground(Color.white);
thresholdIsMin.setLabel("Threshold is min/max");
- thresholdIsMin.setBounds(new Rectangle(328, 3, 135, 23));
- jPanel1.add(ok);
- jPanel1.add(cancel);
- //jPanel2.add(currentColours);
- jPanel2.add(minColour);
- jPanel2.add(maxColour);
- jPanel3.add(threshold);
+ thresholdIsMin.setSize(new Dimension(135,23));
+ //thresholdIsMin.setBounds(new Rectangle(328, 3, 135, 23));
+ jPanel1.add(minColour);
+ jPanel1.add(maxColour);
+ jPanel1.add(colourFromLabel);
+ jPanel2.add(threshold);
jPanel3.add(slider);
- jPanel3.add(thresholdValue);
- jPanel3.add(thresholdIsMin);
- this.add(jPanel2, java.awt.BorderLayout.NORTH);
- this.add(jPanel3, java.awt.BorderLayout.CENTER);
- this.add(jPanel1, java.awt.BorderLayout.SOUTH);
+ jPanel4.add(thresholdValue);
+ jPanel4.add(thresholdIsMin);
+ this.add(jPanel1);//, java.awt.BorderLayout.NORTH);
+ this.add(jPanel2);//, java.awt.BorderLayout.NORTH);
+ this.add(jPanel3);//, java.awt.BorderLayout.CENTER);
+ this.add(jPanel4);//, java.awt.BorderLayout.CENTER);
}
Button minColour = new Button();
Button maxColour = new Button();
- Button ok = new Button();
-
- Button cancel = new Button();
-
+
Panel jPanel1 = new Panel();
Panel jPanel2 = new Panel();
Choice threshold = new Choice();
- FlowLayout flowLayout1 = new FlowLayout();
-
Panel jPanel3 = new Panel();
+ Panel jPanel4 = new Panel();
Scrollbar slider = new Scrollbar(Scrollbar.HORIZONTAL);
TextField thresholdValue = new TextField(20);
- BorderLayout borderLayout1 = new BorderLayout();
+// BorderLayout borderLayout1 = new BorderLayout();
Checkbox thresholdIsMin = new Checkbox();
+ Checkbox colourFromLabel = new Checkbox();
private GraphLine threshline;
{
maxColour_actionPerformed(null);
}
-
- else if (evt.getSource() == ok)
- {
- changeColour();
- frame.setVisible(false);
- }
- else if (evt.getSource() == cancel)
- {
- reset();
- ap.paintAlignment(true);
- frame.setVisible(false);
- }
-
else
{
changeColour();
public void itemStateChanged(ItemEvent evt)
{
-
+ maxColour.setEnabled(!colourFromLabel.getState());
+ minColour.setEnabled(!colourFromLabel.getState());
changeColour();
}
}
}
protected void valueChanged() {
- changeColour();
threshline.value = (float) slider.getValue() / 1000f;
- ap.paintAlignment(false);
+ cs.setThresh(threshline.value);
+ changeColour();
+ PaintRefresher.Refresh(this, fr.av.getSequenceSetId());
+ // ap.paintAlignment(false);
}
public void minColour_actionPerformed(Color newCol)
{
- if (newCol != null)
+ if (newCol == null)
{
+ UserDefinedColours udc = new UserDefinedColours(this,minColour.getBackground(), frame, "Select Colour for Minimum Value");
+ } else {
minColour.setBackground(newCol);
minColour.repaint();
changeColour();
}
- else
- {
- new UserDefinedColours(this, "Select Colour for Minimum Value", minColour.getBackground());
- }
-
+
}
public void maxColour_actionPerformed(Color newCol)
{
- if (newCol != null)
+ if (newCol == null)
{
+ UserDefinedColours udc = new UserDefinedColours(this,maxColour.getBackground(), frame, "Select Colour for Maximum Value");// this, "Select Colour for Maximum Value", maxColour.getBackground());
+ } else {
maxColour.setBackground(newCol);
maxColour.repaint();
changeColour();
}
- else
- {
- new UserDefinedColours(this, "Select Colour for Maximum Value", maxColour.getBackground());
- }
}
void changeColour()
thresholdValue.setEnabled(true);
GraduatedColor acg = new GraduatedColor(minColour.getBackground(), maxColour.getBackground(), min, max);
+ acg.setColourByLabel(colourFromLabel.getState());
+ maxColour.setEnabled(!colourFromLabel.getState());
+ minColour.setEnabled(!colourFromLabel.getState());
if (aboveThreshold == AnnotationColourGradient.NO_THRESHOLD)
{
slider.setEnabled(false);
fr.featureColours.put(type,acg);
cs = acg;
- ap.paintAlignment(false);
+ PaintRefresher.Refresh(this, fr.av.getSequenceSetId());
+ // ap.paintAlignment(false);
}
void reset()
{
fr.featureColours.put(type, oldcs);
- ap.paintAlignment(true);
+ PaintRefresher.Refresh(this, fr.av.getSequenceSetId());
+ // ap.paintAlignment(true);
}
public void mouseReleased(MouseEvent evt)
{
- ap.paintAlignment(true);
+ PaintRefresher.Refresh(this, fr.av.getSequenceSetId());
+ // ap.paintAlignment(true);
}
public void mouseEntered(MouseEvent evt)