From cc71444a32e510daaabef9e175e0ecb7a25a4c55 Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 23 Apr 2010 10:51:00 +0000 Subject: [PATCH] 1.1 compatibility and refresh table method --- src/jalview/appletgui/FeatureRenderer.java | 47 +++++++++++----------------- src/jalview/appletgui/FeatureSettings.java | 9 ++++-- 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/src/jalview/appletgui/FeatureRenderer.java b/src/jalview/appletgui/FeatureRenderer.java index c2c2462..2f6fc1b 100755 --- a/src/jalview/appletgui/FeatureRenderer.java +++ b/src/jalview/appletgui/FeatureRenderer.java @@ -155,12 +155,12 @@ public class FeatureRenderer } public void paint(Graphics g) { - int width=getWidth(),height=getHeight(); + Dimension d = getSize(); if (isGcol) { if (isColourByLabel) { g.setColor(Color.white); - g.fillRect(width/2, 0,width/2, height); + g.fillRect(d.width/2, 0,d.width/2, d.height); g.setColor(Color.black); Font f=new Font("Verdana", Font.PLAIN, 10); @@ -170,7 +170,7 @@ public class FeatureRenderer else { g.setColor(maxCol); - g.fillRect(width/2, 0,width/2, height); + g.fillRect(d.width/2, 0,d.width/2, d.height); } } @@ -243,7 +243,7 @@ public class FeatureRenderer ap.seqPanel.seqCanvas.highlightSearchResults(highlight); } - Color col = getColour(name.getText()); + Object col = getFeatureStyle(name.getText()); if (col == null) { col = new jalview.schemes.UserColourScheme() @@ -363,29 +363,19 @@ public class FeatureRenderer colourPanel.updateColor(fcol); dialog.setResizable(true); // TODO: render the graduated color in the box. - if (fcol instanceof Color) - { - colourPanel.addMouseListener(new java.awt.event.MouseAdapter() - { - public void mousePressed(java.awt.event.MouseEvent evt) - { - new UserDefinedColours(fr, ap.alignFrame); - } - }); - - } - else - { - colourPanel.addMouseListener(new java.awt.event.MouseAdapter() + colourPanel.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { - FeatureColourChooser fcc = new FeatureColourChooser(ap.alignFrame, name.getText()); - fcc.setFocusable(true); - dialog.transferFocus(); + if (!colourPanel.isGcol) + { + new UserDefinedColours(fr, ap.alignFrame); + } else { + FeatureColourChooser fcc = new FeatureColourChooser(ap.alignFrame, name.getText()); + dialog.transferFocus(); + } } }); - } dialog.setVisible(true); jalview.io.FeaturesFile ffile = new jalview.io.FeaturesFile(); @@ -412,7 +402,7 @@ public class FeatureRenderer sf.type = lastFeatureAdded; sf.featureGroup = lastFeatureGroupAdded; sf.description = lastDescriptionAdded; - if (fcol instanceof Color) { + if (!colourPanel.isGcol) { // update colour - otherwise its already done. setColour(sf.type, colourPanel.getBackground()); } @@ -474,17 +464,18 @@ public class FeatureRenderer tro[0] = renderOrder[renderOrder.length - 1]; System.arraycopy(renderOrder, 0, tro, 1, renderOrder.length - 1); renderOrder = tro; - - ap.paintAlignment(true); - - return true; } else { + // no update to the alignment return false; } } - + // refresh the alignment and the feature settings dialog + if (av.featureSettings!=null) + { + av.featureSettings.refreshTable(); + } // findAllFeatures(); ap.paintAlignment(true); diff --git a/src/jalview/appletgui/FeatureSettings.java b/src/jalview/appletgui/FeatureSettings.java index 80559bd..7f59de5 100755 --- a/src/jalview/appletgui/FeatureSettings.java +++ b/src/jalview/appletgui/FeatureSettings.java @@ -558,6 +558,9 @@ public class FeatureSettings extends Panel implements ItemListener, public void setUserColour(String feature, Color col) { fr.setColour(feature, col); + refreshTable(); + } + public void refreshTable() { featurePanel.removeAll(); resetTable(false); ap.paintAlignment(true); @@ -687,13 +690,13 @@ public class FeatureSettings extends Panel implements ItemListener, public void paint(Graphics g) { - int width = getWidth(), height = getHeight(); + Dimension d = getSize(); if (gcol != null) { if (gcol.isColourByLabel()) { g.setColor(Color.white); - g.fillRect(width/2, 0,width/2, height); + g.fillRect(d.width/2, 0,d.width/2, d.height); /*g.setColor(Color.black); Font f=g.getFont().deriveFont(9); g.setFont(f); @@ -709,7 +712,7 @@ public class FeatureSettings extends Panel implements ItemListener, { Color maxCol = gcol.getMaxColor(); g.setColor(maxCol); - g.fillRect(width/2, 0,width/2, height); + g.fillRect(d.width/2, 0,d.width/2, d.height); } } -- 1.7.10.2