- int original1 = viewport.textColour.getRGB();
- int original2 = viewport.textColour2.getRGB();
- int thresh = viewport.thresholdTextColour;
- final JSlider slider = new JSlider(0, 750, viewport.thresholdTextColour);
- final JButton col1 = new JButton("DARK");
- col1.setBackground(viewport.textColour);
- col1.setForeground(viewport.textColour);
- final JButton col2 = new JButton("LIGHT");
- col2.setBackground(viewport.textColour2);
- col2.setForeground(viewport.textColour2);
- final JPanel bigpanel = new JPanel(new BorderLayout());
- JPanel panel = new JPanel();
- bigpanel.add(panel, BorderLayout.CENTER);
- bigpanel.add(new JLabel(
- "<html><i>Select a dark and light text colour, then set the threshold to"
- +"<br>switch between colours, based on background colour</i></html>"),
- BorderLayout.NORTH);
- panel.add(col1);
- panel.add(slider);
- panel.add(col2);
-
- col1.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- Color col = JColorChooser.showDialog(bigpanel,
- "Select Colour for Text",
- viewport.textColour);
- if (col != null)
- {
- viewport.textColour = col;
- col1.setBackground(col);
- col1.setForeground(col);
- if(viewport.colourAppliesToAllGroups)
- setGroupTextColour();
- }
- alignPanel.repaint();
- }
- });
-
- col2.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- Color col = JColorChooser.showDialog(bigpanel,
- "Select Colour for Text",
- viewport.textColour);
- if (col != null)
- {
- viewport.textColour2 = col;
- col2.setBackground(col);
- col2.setForeground(col);
- if(viewport.colourAppliesToAllGroups)
- setGroupTextColour();
- }
- alignPanel.repaint();
- }
- });
-
-
- slider.addChangeListener(new ChangeListener()
- {
- public void stateChanged(ChangeEvent evt)
- {
- viewport.thresholdTextColour = slider.getValue();
- if(viewport.colourAppliesToAllGroups)
- setGroupTextColour();
- alignPanel.repaint();
- }
- });
-
- int reply = JOptionPane.showInternalOptionDialog(this,
- bigpanel,
- "Adjust Foreground Text Colour Threshold",
- JOptionPane.OK_CANCEL_OPTION,
- JOptionPane.QUESTION_MESSAGE,
- null,
- null, null);
-
- if(reply==JOptionPane.CANCEL_OPTION)
- {
- viewport.textColour = new Color(original1);
- viewport.textColour2 = new Color(original2);
- viewport.thresholdTextColour = thresh;
- }
- }
-
- void setGroupTextColour()
- {
- if(viewport.alignment.getGroups()==null)
- return;
-
- Vector groups = viewport.alignment.getGroups();
-
- for(int i=0; i<groups.size(); i++)
- {
- SequenceGroup sg = (SequenceGroup)groups.elementAt(i);
- sg.textColour = viewport.textColour;
- sg.textColour2 = viewport.textColour2;
- sg.thresholdTextColour = viewport.thresholdTextColour;
- }
-
-