From 22b9e04a8351aef1cb23a66d898502601499b673 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Thu, 16 Feb 2006 15:49:43 +0000 Subject: [PATCH] FeatureGroups added --- src/jalview/gui/FeatureRenderer.java | 15 +++++++++++- src/jalview/gui/FeatureSettings.java | 45 +++++++++++++++++++++++++++++++--- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/src/jalview/gui/FeatureRenderer.java b/src/jalview/gui/FeatureRenderer.java index 69ecf14..22789a1 100755 --- a/src/jalview/gui/FeatureRenderer.java +++ b/src/jalview/gui/FeatureRenderer.java @@ -46,6 +46,11 @@ public class FeatureRenderer // to be added, in the correct order or rendering Vector featuresDisplayed = null; + // A higher level for grouping features of a + // particular type + Hashtable featureGroups = null; + + /** * Creates a new FeatureRenderer object. * @@ -98,7 +103,7 @@ public class FeatureRenderer int start, int end, int x1, int y1, int width, int height) { -//System.out.println(start+" "+end+" "+x1+" "+y1); + //System.out.println(start+" "+end+" "+x1+" "+y1); if (seq.getDatasetSequence().getSequenceFeatures() == null || seq.getDatasetSequence().getSequenceFeatures().size()==0) return; @@ -135,6 +140,14 @@ public class FeatureRenderer if (!type.equals(sf.getType())) continue; + if(featureGroups!=null + && sf.getFeatureGroup()!=null + && featureGroups.containsKey(sf.getFeatureGroup()) + && !((Boolean)featureGroups.get(sf.getFeatureGroup())).booleanValue()) + { + continue; + } + if (sf.getBegin() > seq.getEnd()) continue; diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index 47cedd3..eb74454 100755 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -39,6 +39,7 @@ public class FeatureSettings extends JPanel final JInternalFrame frame; JScrollPane scrollPane = new JScrollPane(); JTable table; + JPanel groupPanel; public FeatureSettings(AlignViewport av, final AlignmentPanel ap) { @@ -122,6 +123,8 @@ public class FeatureSettings extends JPanel JPanel bigPanel = new JPanel(new BorderLayout()); bigPanel.add(transPanel, BorderLayout.SOUTH); bigPanel.add(scrollPane, BorderLayout.CENTER); + if(groupPanel!=null) + bigPanel.add(groupPanel, BorderLayout.NORTH); add(bigPanel, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); @@ -131,6 +134,11 @@ public class FeatureSettings extends JPanel void setTableData() { + if (fr.featureGroups == null) + fr.featureGroups = new Hashtable(); + else + fr.featureGroups.clear(); + Vector allFeatures = new Vector(); Vector features; Enumeration e; @@ -147,6 +155,32 @@ public class FeatureSettings extends JPanel while (e.hasMoreElements()) { sf = (SequenceFeature) e.nextElement(); + if(sf.getFeatureGroup()!=null + && !fr.featureGroups.containsKey(sf.getFeatureGroup())) + { + fr.featureGroups.put(sf.getFeatureGroup(), new Boolean(true)); + if(groupPanel==null) + groupPanel = new JPanel(); + + final JCheckBox check = new JCheckBox(sf.getFeatureGroup(), true); + check.setFont(new Font("Serif", Font.BOLD, 12)); + check.addItemListener(new ItemListener() + { + public void itemStateChanged(ItemEvent evt) + { + if (fr.featureGroups.containsKey(check.getText())) + { + fr.featureGroups.put(check.getText(), + new Boolean(check.isSelected())); + ap.seqPanel.seqCanvas.repaint(); + if (ap.overviewPanel != null) + ap.overviewPanel.updateOverviewImage(); + } + + } + }); + groupPanel.add(check); + } if (!allFeatures.contains(sf.getType())) { allFeatures.addElement(sf.getType()); @@ -155,9 +189,14 @@ public class FeatureSettings extends JPanel } if(allFeatures.size()<1) { - try{ - frame.setClosed(true); - }catch(Exception ex){} + try + { frame.setClosed(true); } + catch (Exception ex){} + + JOptionPane.showInternalMessageDialog( + Desktop.desktop, "No features have been added to this alignment!", + "No Sequence Features", JOptionPane.WARNING_MESSAGE); + return; } -- 1.7.10.2