From d8c50265e5b07fe9a5565f6079f716cae81afe01 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Tue, 21 Nov 2006 12:18:01 +0000 Subject: [PATCH] Use textColourChooser --- src/jalview/gui/AlignFrame.java | 105 +-------------------------------------- src/jalview/gui/PopupMenu.java | 84 ++----------------------------- 2 files changed, 4 insertions(+), 185 deletions(-) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 6899626..8fafb34 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -1959,112 +1959,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener public void textColour_actionPerformed(ActionEvent e) { - 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( - "Select a dark and light text colour, then set the threshold to" - +"
switch between colours, based on background colour
"), - 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; - } + new TextColourChooser().chooseColour(alignPanel, null); } - void setGroupTextColour() - { - if(viewport.alignment.getGroups()==null) - return; - - Vector groups = viewport.alignment.getGroups(); - - for(int i=0; iSelect a dark and light text colour, then set the threshold to" - +"
switch between colours, based on background colour
"), - 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", - sg.textColour); - if (col != null) - { - sg.textColour = col; - col1.setBackground(col); - col1.setForeground(col); - } - ap.repaint(); - } - }); - - col2.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - Color col = JColorChooser.showDialog(bigpanel, - "Select Colour for Text", - sg.textColour); - if (col != null) - { - sg.textColour2 = col; - col2.setBackground(col); - col2.setForeground(col); - } - ap.repaint(); - } - }); - - - slider.addChangeListener(new ChangeListener() - { - public void stateChanged(ChangeEvent evt) - { - sg.thresholdTextColour = slider.getValue(); - ap.repaint(); - } - }); - - int reply = JOptionPane.showInternalOptionDialog(Desktop.desktop, - bigpanel, - "Adjust Foreground Text Colour Threshold", - JOptionPane.OK_CANCEL_OPTION, - JOptionPane.QUESTION_MESSAGE, - null, - null, null); - - if(reply==JOptionPane.CANCEL_OPTION) - { - sg.textColour = new Color(original1); - sg.textColour2 = new Color(original2); - sg.thresholdTextColour = thresh; - } + SequenceGroup sg = getGroup(); + if (sg != null) + new TextColourChooser().chooseColour(ap, sg); } } -- 1.7.10.2