ColourSchemeI oldColourScheme;\r
JInternalFrame frame;\r
MCview.PDBCanvas pdbcanvas;\r
+ Vector upperCaseButtons;\r
+ Vector lowerCaseButtons;\r
+\r
\r
/**\r
* Creates a new UserDefinedColours object.\r
public UserDefinedColours(AlignmentPanel ap, SequenceGroup sg)\r
{\r
super();\r
- frame = new JInternalFrame();\r
- frame.setContentPane(this);\r
- Desktop.addInternalFrame(frame, "User Defined Colours", 720, 370, true);\r
-\r
- if (System.getProperty("os.name").startsWith("Mac"))\r
- {\r
- frame.setSize(760, 370);\r
- }\r
-\r
- if (sg != null)\r
- {\r
- frame.setTitle(frame.getTitle() + " (" + sg.getName() + ")");\r
- }\r
-\r
- colorChooser.getSelectionModel().addChangeListener(this);\r
+ lcaseColour.setEnabled(false);\r
\r
this.ap = ap;\r
seqGroup = sg;\r
\r
if (seqGroup != null)\r
- {\r
oldColourScheme = seqGroup.cs;\r
- }\r
else\r
- {\r
oldColourScheme = ap.av.getGlobalColourScheme();\r
- }\r
\r
if (oldColourScheme instanceof UserColourScheme)\r
{\r
- schemeName.setText( ( (UserColourScheme) oldColourScheme).getName());\r
- }\r
- for (int i = 0; i < 20; i++)\r
- {\r
- makeButton(ResidueProperties.aa2Triplet.get(ResidueProperties.aa[i]) +\r
- "", ResidueProperties.aa[i]);\r
+ schemeName.setText( ( (UserColourScheme) oldColourScheme).getName());\r
+ if(( (UserColourScheme) oldColourScheme).getLowerCaseColours()!=null)\r
+ {\r
+ caseSensitive.setSelected(true);\r
+ lcaseColour.setEnabled(true);\r
+ resetButtonPanel(true);\r
+ }\r
+ else\r
+ resetButtonPanel(false);\r
}\r
+ else\r
+ resetButtonPanel(false);\r
\r
- makeButton("B", "B");\r
- makeButton("Z", "Z");\r
- makeButton("X", "X");\r
- makeButton("Gap", "-");\r
+ showFrame();\r
}\r
\r
public UserDefinedColours(MCview.PDBCanvas pdb, ColourSchemeI oldcs)\r
{\r
super();\r
- frame = new JInternalFrame();\r
- frame.setContentPane(this);\r
- Desktop.addInternalFrame(frame, "User Defined Colours", 720, 370, true);\r
pdbcanvas = pdb;\r
\r
- if (System.getProperty("os.name").startsWith("Mac"))\r
- {\r
- frame.setSize(760, 370);\r
- }\r
-\r
colorChooser.getSelectionModel().addChangeListener(this);\r
\r
oldColourScheme = oldcs;\r
{\r
schemeName.setText( ( (UserColourScheme) oldColourScheme).getName());\r
}\r
- for (int i = 0; i < 20; i++)\r
- {\r
- makeButton(ResidueProperties.aa2Triplet.get(ResidueProperties.aa[i]) +\r
- "", ResidueProperties.aa[i]);\r
- }\r
\r
- makeButton("B", "B");\r
- makeButton("Z", "Z");\r
- makeButton("X", "X");\r
- makeButton("Gap", "-");\r
+ resetButtonPanel(false);\r
+\r
+ showFrame();\r
+\r
+ }\r
+\r
+ void showFrame()\r
+ {\r
+ colorChooser.getSelectionModel().addChangeListener(this);\r
+ frame = new JInternalFrame();\r
+ frame.setContentPane(this);\r
+ Desktop.addInternalFrame(frame, "User Defined Colours", 720, 370, true);\r
+\r
+ if (seqGroup != null)\r
+ frame.setTitle(frame.getTitle() + " (" + seqGroup.getName() + ")");\r
+\r
+ if (System.getProperty("os.name").startsWith("Mac"))\r
+ {\r
+ frame.setSize(760, 370);\r
+ }\r
+ }\r
+\r
+ void resetButtonPanel(boolean caseSensitive)\r
+ {\r
+ buttonPanel.removeAll();\r
+\r
+\r
+ if(upperCaseButtons==null)\r
+ upperCaseButtons = new Vector();\r
+\r
+ JButton button;\r
+ String label;\r
+ for (int i = 0; i < 20; i++)\r
+ {\r
+ if(caseSensitive)\r
+ label = ResidueProperties.aa[i];\r
+ else\r
+ label = ResidueProperties.aa2Triplet.get\r
+ (ResidueProperties.aa[i]).toString();\r
+\r
+ button = makeButton(label,\r
+ ResidueProperties.aa[i],\r
+ upperCaseButtons, i);\r
+\r
+ buttonPanel.add(button);\r
+ }\r
+\r
+ buttonPanel.add(makeButton("B", "B", upperCaseButtons, 20));\r
+ buttonPanel.add(makeButton("Z", "Z", upperCaseButtons, 21));\r
+ buttonPanel.add(makeButton("X", "X", upperCaseButtons, 22));\r
+ buttonPanel.add(makeButton("Gap", "-", upperCaseButtons, 23));\r
+\r
+ if(!caseSensitive)\r
+ {\r
+ gridLayout.setRows(6);\r
+ gridLayout.setColumns(4);\r
+ }\r
+ else\r
+ {\r
+ gridLayout.setRows(7);\r
+ int cols = 7;\r
+ gridLayout.setColumns(cols+1);\r
+\r
+ if(lowerCaseButtons==null)\r
+ lowerCaseButtons = new Vector();\r
+\r
+\r
+ for (int i = 0; i < 20; i++)\r
+ {\r
+ int row = i / cols + 1;\r
+ int index = (row * cols) + i;\r
+ button = makeButton(\r
+ ResidueProperties.aa[i].toLowerCase(),\r
+ ResidueProperties.aa[i].toLowerCase(),\r
+ lowerCaseButtons,\r
+ i);\r
+\r
+ buttonPanel.add(button, index);\r
+ }\r
+ }\r
+\r
+\r
+ if(caseSensitive)\r
+ {\r
+ buttonPanel.add(makeButton("b", "b", lowerCaseButtons, 20));\r
+ buttonPanel.add(makeButton("z", "z", lowerCaseButtons, 21));\r
+ buttonPanel.add(makeButton("x", "x", lowerCaseButtons, 22));\r
+ }\r
+\r
+ buttonPanel.validate();\r
+ validate();\r
}\r
\r
\r
{\r
if (selectedButtons != null)\r
{\r
- JButton button;\r
+ JButton button=null;\r
for(int i=0; i<selectedButtons.size(); i++)\r
{\r
button = (JButton)selectedButtons.elementAt(i);\r
button.setBackground(colorChooser.getColor());\r
button.setForeground( button.getBackground().brighter().brighter().brighter());\r
}\r
+ if(button==lcaseColour)\r
+ {\r
+ for(int i=0; i<lowerCaseButtons.size(); i++)\r
+ {\r
+ button = (JButton)lowerCaseButtons.elementAt(i);\r
+ button.setBackground(colorChooser.getColor());\r
+ button.setForeground( button.getBackground().brighter().brighter().brighter());\r
+ }\r
+ }\r
}\r
}\r
\r
* @param label DOCUMENT ME!\r
* @param aa DOCUMENT ME!\r
*/\r
- void makeButton(String label, String aa)\r
+ JButton makeButton(String label,\r
+ String aa,\r
+ Vector caseSensitiveButtons,\r
+ int buttonIndex)\r
{\r
- final JButton button = new JButton();\r
- Color col = Color.white;\r
+ final JButton button;\r
+ Color col;\r
\r
- try\r
+ if(buttonIndex<caseSensitiveButtons.size())\r
{\r
- col = oldColourScheme.findColour(aa, -1);\r
+ button = (JButton) caseSensitiveButtons.elementAt(buttonIndex);\r
+ col = button.getBackground();\r
}\r
- catch (Exception ex)\r
+ else\r
{\r
- // ex.printStackTrace();\r
+ button = new JButton();\r
+ button.addMouseListener(new java.awt.event.MouseAdapter()\r
+ {\r
+ public void mouseClicked(MouseEvent e)\r
+ {\r
+ colourButtonPressed(e);\r
+ }\r
+ });\r
+\r
+ caseSensitiveButtons.addElement(button);\r
+\r
+ col = Color.white;\r
+\r
+ try\r
+ {\r
+ col = oldColourScheme.findColour(aa, -1);\r
+ }\r
+ catch (Exception ex)\r
+ { }\r
}\r
\r
+ if(caseSensitive.isSelected())\r
+ button.setMargin(new java.awt.Insets(2,2,2,2));\r
+ else\r
+ button.setMargin(new java.awt.Insets(2,14,2,14));\r
+\r
button.setBackground(col);\r
button.setText(label);\r
button.setForeground(col.darker().darker().darker());\r
- button.setFont(new java.awt.Font("Verdana", 1, 10));\r
- button.addMouseListener(new java.awt.event.MouseAdapter()\r
- {\r
- public void mouseClicked(MouseEvent e)\r
- {\r
- colourButtonPressed(e);\r
- }\r
- });\r
+ button.setFont(new java.awt.Font("Verdana", Font.BOLD, 10));\r
\r
- buttonPanel.add(button, null);\r
+ return button;\r
}\r
\r
/**\r
*/\r
protected void applyButton_actionPerformed(ActionEvent e)\r
{\r
- UserColourScheme ucs = getSchemeFromGUI();\r
+ UserColourScheme ucs = getSchemeFromButtons();\r
ucs.setName(schemeName.getText());\r
\r
if (seqGroup != null)\r
}\r
}\r
\r
- UserColourScheme getSchemeFromGUI()\r
+ UserColourScheme getSchemeFromButtons()\r
{\r
+\r
Color[] newColours = new Color[24];\r
\r
for (int i = 0; i < 24; i++)\r
{\r
- JButton button = (JButton) buttonPanel.getComponent(i);\r
+ JButton button = (JButton) upperCaseButtons.elementAt(i);\r
newColours[i] = button.getBackground();\r
}\r
\r
UserColourScheme ucs = new UserColourScheme(newColours);\r
+\r
+\r
+ if(caseSensitive.isSelected())\r
+ {\r
+ newColours = new Color[23];\r
+ for (int i = 0; i < 23; i++)\r
+ {\r
+ JButton button = (JButton) lowerCaseButtons.elementAt(i);\r
+ newColours[i] = button.getBackground();\r
+ }\r
+ ucs.setLowerCaseColours(newColours);\r
+ }\r
+\r
if(ap!=null)\r
ucs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
\r
*/\r
protected void loadbutton_actionPerformed(ActionEvent e)\r
{\r
+ upperCaseButtons = new Vector();\r
+ lowerCaseButtons = new Vector();\r
+\r
JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty(\r
"LAST_DIRECTORY"), new String[] { "jc" },\r
new String[] { "Jalview User Colours" }, "Jalview User Colours");\r
Color[] colors = ucs.getColours();\r
schemeName.setText(ucs.getName());\r
\r
- for (int i = 0; i < colors.length; i++)\r
+ if(ucs.getLowerCaseColours()!=null)\r
+ {\r
+ caseSensitive.setSelected(true);\r
+ lcaseColour.setEnabled(true);\r
+ resetButtonPanel(true);\r
+ for (int i = 0; i < lowerCaseButtons.size(); i++)\r
+ {\r
+ JButton button = (JButton) lowerCaseButtons.elementAt(i);\r
+ button.setBackground(ucs.getLowerCaseColours()[i]);\r
+ }\r
+\r
+ }\r
+ else\r
+ {\r
+ caseSensitive.setSelected(false);\r
+ lcaseColour.setEnabled(false);\r
+ resetButtonPanel(false);\r
+ }\r
+\r
+ for (int i = 0; i < upperCaseButtons.size(); i++)\r
{\r
- JButton button = (JButton) buttonPanel.getComponent(i);\r
+ JButton button = (JButton) upperCaseButtons.elementAt(i);\r
button.setBackground(colors[i]);\r
}\r
+\r
}\r
}\r
\r
{\r
UserColourScheme ucs = null;\r
Color[] newColours = null;\r
-\r
try\r
{\r
InputStreamReader in = new InputStreamReader(new FileInputStream(\r
= new org.exolab.castor.xml.Unmarshaller(jucs);\r
jucs = (jalview.schemabinding.version2.JalviewUserColours) unmar.unmarshal( in );\r
\r
- newColours = new Color[jucs.getColourCount()];\r
+ newColours = new Color[24];\r
+\r
+ Color [] lowerCase = null;\r
+ boolean caseSensitive = false;\r
+\r
\r
- for (int i = 0; i < 24; i++)\r
+ String name;\r
+ int index;\r
+ for (int i = 0; i < jucs.getColourCount(); i++)\r
{\r
- newColours[i] = new Color(Integer.parseInt(\r
+ name = jucs.getColour(i).getName();\r
+ if(ResidueProperties.aa3Hash.containsKey(name))\r
+ {\r
+ index = ((Integer)ResidueProperties.aa3Hash.get(name)).intValue();\r
+ }\r
+ else\r
+ {\r
+ index = ((Integer)ResidueProperties.aaHash.get(name)).intValue();\r
+ }\r
+ if(index == -1)\r
+ continue;\r
+\r
+ if(name.toLowerCase().equals(name))\r
+ {\r
+ if(lowerCase==null)\r
+ lowerCase = new Color[23];\r
+ caseSensitive = true;\r
+ lowerCase[index] = new Color(Integer.parseInt(\r
jucs.getColour(i).getRGB(), 16));\r
+ }\r
+ else\r
+ {\r
+ newColours[index] = new Color(Integer.parseInt(\r
+ jucs.getColour(i).getRGB(), 16));\r
+ }\r
}\r
+\r
if (newColours != null)\r
{\r
ucs = new UserColourScheme(newColours);\r
ucs.setName( jucs.getSchemeName() );\r
+ if(caseSensitive)\r
+ {\r
+ ucs.setLowerCaseColours(lowerCase);\r
+ }\r
}\r
\r
}\r
defaultColours = defaultColours.concat(choice);\r
}\r
\r
- userColourSchemes.put(schemeName.getText(), getSchemeFromGUI());\r
+ userColourSchemes.put(schemeName.getText(), getSchemeFromButtons());\r
\r
ap.alignFrame.updateUserColourMenu();\r
\r
jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", defaultColours);\r
\r
- jalview.binding.JalviewUserColours ucs = new jalview.binding.JalviewUserColours();\r
+ jalview.schemabinding.version2.JalviewUserColours ucs\r
+ = new jalview.schemabinding.version2.JalviewUserColours();\r
+\r
ucs.setSchemeName(schemeName.getText());\r
try\r
{\r
PrintWriter out = new PrintWriter(new OutputStreamWriter(\r
new FileOutputStream(choice), "UTF-8"));\r
\r
- for (int i = 0; i < 24; i++)\r
+ for (int i = 0; i < buttonPanel.getComponentCount(); i++)\r
{\r
JButton button = (JButton) buttonPanel.getComponent(i);\r
- jalview.binding.Colour col = new jalview.binding.Colour();\r
+ jalview.schemabinding.version2.Colour col\r
+ = new jalview.schemabinding.version2.Colour();\r
col.setName(button.getText());\r
col.setRGB(jalview.util.Format.getHexString(\r
button.getBackground()));\r
jalview.bin.Cache.applicationProperties.remove("USER_DEFINED_COLOURS");\r
\r
}\r
+\r
+ public void caseSensitive_actionPerformed(ActionEvent e)\r
+ {\r
+ resetButtonPanel(caseSensitive.isSelected());\r
+ lcaseColour.setEnabled(caseSensitive.isSelected());\r
+ }\r
+\r
+ public void lcaseColour_actionPerformed(ActionEvent e)\r
+ {\r
+ if(selectedButtons==null)\r
+ selectedButtons = new Vector();\r
+ else\r
+ selectedButtons.clear();\r
+ selectedButtons.add(lcaseColour);\r
+ }\r
+\r
}\r
import java.awt.event.*;\r
\r
import javax.swing.*;\r
-\r
+import java.awt.Dimension;\r
\r
/**\r
* DOCUMENT ME!\r
protected JColorChooser colorChooser = new JColorChooser();\r
protected JPanel buttonPanel = new JPanel();\r
protected GridLayout gridLayout = new GridLayout();\r
- JPanel jPanel2 = new JPanel();\r
+ JPanel lowerPanel = new JPanel();\r
protected JButton okButton = new JButton();\r
protected JButton applyButton = new JButton();\r
protected JButton loadbutton = new JButton();\r
protected JTextField schemeName = new JTextField();\r
BorderLayout borderLayout1 = new BorderLayout();\r
JPanel panel1 = new JPanel();\r
- JPanel jPanel1 = new JPanel();\r
- JPanel jPanel3 = new JPanel();\r
+ JPanel okCancelPanel = new JPanel();\r
+ JPanel saveLoadPanel = new JPanel();\r
BorderLayout borderLayout3 = new BorderLayout();\r
GridBagLayout gridBagLayout1 = new GridBagLayout();\r
BorderLayout borderLayout2 = new BorderLayout();\r
BorderLayout borderLayout4 = new BorderLayout();\r
JPanel jPanel4 = new JPanel();\r
BorderLayout borderLayout5 = new BorderLayout();\r
- JPanel jPanel6 = new JPanel();\r
JLabel label = new JLabel();\r
+ JPanel casePanel = new JPanel();\r
+ protected JCheckBox caseSensitive = new JCheckBox();\r
+ protected JButton lcaseColour = new JButton();\r
/**\r
* Creates a new GUserDefinedColours object.\r
*/\r
this.setLayout(borderLayout4);\r
buttonPanel.setLayout(gridLayout);\r
gridLayout.setColumns(4);\r
- gridLayout.setRows(6);\r
+ gridLayout.setRows(5);\r
okButton.setFont(new java.awt.Font("Verdana", 0, 11));\r
okButton.setText("OK");\r
okButton.addActionListener(new java.awt.event.ActionListener()\r
}\r
});\r
this.setBackground(new Color(212, 208, 223));\r
- jPanel2.setOpaque(false);\r
- jPanel2.setLayout(borderLayout3);\r
+ lowerPanel.setOpaque(false);\r
+ lowerPanel.setLayout(borderLayout3);\r
colorChooser.setOpaque(false);\r
jLabel1.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
jLabel1.setText("Name");\r
schemeName.setHorizontalAlignment(SwingConstants.CENTER);\r
panel1.setLayout(flowLayout1);\r
panel1.setOpaque(false);\r
- jPanel1.setOpaque(false);\r
- jPanel3.setOpaque(false);\r
+ okCancelPanel.setOpaque(false);\r
+ saveLoadPanel.setOpaque(false);\r
jPanel4.setLayout(borderLayout5);\r
- jPanel6.setBackground(Color.pink);\r
- jPanel6.setMinimumSize(new Dimension(10, 70));\r
- jPanel6.setOpaque(false);\r
- jPanel6.setPreferredSize(new Dimension(10, 45));\r
- jPanel6.setLayout(null);\r
label.setFont(new java.awt.Font("Verdana", Font.ITALIC, 10));\r
label.setOpaque(false);\r
label.setPreferredSize(new Dimension(260, 34));\r
label.setText(\r
"<html>Save your colour scheme with a unique name and it will be added " +\r
"to the Colour menu.</html>");\r
+ caseSensitive.setText("Case Sensitive");\r
+ caseSensitive.addActionListener(new ActionListener()\r
+ {\r
+ public void actionPerformed(ActionEvent e)\r
+ {\r
+ caseSensitive_actionPerformed(e);\r
+ }\r
+ });\r
+ lcaseColour.setText("Lower Case Colour");\r
+ lcaseColour.addActionListener(new ActionListener()\r
+ {\r
+ public void actionPerformed(ActionEvent e)\r
+ {\r
+ lcaseColour_actionPerformed(e);\r
+ }\r
+ });\r
\r
- jPanel3.add(savebutton);\r
- jPanel3.add(loadbutton);\r
- jPanel1.add(applyButton);\r
- jPanel1.add(okButton);\r
- jPanel1.add(cancelButton);\r
- jPanel2.add(jPanel3, java.awt.BorderLayout.NORTH);\r
- jPanel2.add(jPanel1, java.awt.BorderLayout.SOUTH);\r
+ saveLoadPanel.add(savebutton);\r
+ saveLoadPanel.add(loadbutton);\r
+ okCancelPanel.add(applyButton);\r
+ okCancelPanel.add(okButton);\r
+ okCancelPanel.add(cancelButton);\r
+ lowerPanel.add(saveLoadPanel, java.awt.BorderLayout.NORTH);\r
+ lowerPanel.add(okCancelPanel, java.awt.BorderLayout.SOUTH);\r
\r
namePanel.add(schemeName, java.awt.BorderLayout.CENTER);\r
namePanel.add(jLabel1, java.awt.BorderLayout.WEST);\r
panel1.add(namePanel, null);\r
panel1.add(buttonPanel, null);\r
- panel1.add(jPanel2, null);\r
+ panel1.add(casePanel);\r
+ casePanel.add(caseSensitive);\r
+ casePanel.add(lcaseColour);\r
+ panel1.add(lowerPanel, null);\r
panel1.add(label);\r
\r
jPanel4.add(panel1, java.awt.BorderLayout.CENTER);\r
- jPanel4.add(jPanel6, java.awt.BorderLayout.NORTH);\r
this.add(jPanel4, java.awt.BorderLayout.CENTER);\r
this.add(colorChooser, java.awt.BorderLayout.EAST);\r
}\r
protected void cancelButton_actionPerformed(ActionEvent e)\r
{\r
}\r
+\r
+ public void caseSensitive_actionPerformed(ActionEvent e)\r
+ {\r
+\r
+ }\r
+\r
+ public void lcaseColour_actionPerformed(ActionEvent e)\r
+ {\r
+\r
+ }\r
}\r