/* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ package jalview.appletgui; import jalview.datamodel.*; import java.awt.*; import java.util.*; import java.awt.event.*; public class FeatureSettings extends Panel implements ItemListener, MouseListener, MouseMotionListener { final FeatureRenderer fr; final AlignmentPanel ap; final AlignViewport av; final Frame frame; public FeatureSettings(AlignViewport av, final AlignmentPanel ap) { this.ap = ap; this.av = av; fr = ap.seqPanel.seqCanvas.getFeatureRenderer(); setTableData(); frame = new Frame(); frame.add(this); int height = this.getComponentCount()*50; if (height>400) height = 400; jalview.bin.JalviewLite.addFrame(frame, "Feature Settings", 200, height); } void setTableData() { Vector allFeatures = new Vector(); Vector features; Enumeration e; SequenceFeature sf; for (int i = 0; i < av.alignment.getHeight(); i++) { features = av.alignment.getSequenceAt(i).getSequenceFeatures(); if (features == null) continue; e = features.elements(); while (e.hasMoreElements()) { sf = (SequenceFeature) e.nextElement(); if (!allFeatures.contains(sf.getType())) { allFeatures.addElement(sf.getType()); } } } int fSize = allFeatures.size(); String type; this.setLayout(new GridLayout(fSize, 2, 10,5)); for (int i = 0; i < fSize; i++) { type = allFeatures.elementAt(i).toString(); Color col = fr.getColour(type); boolean displayed = true; if(fr.featuresDisplayed!=null) displayed = fr.featuresDisplayed.contains(type); Checkbox check = new Checkbox(type, displayed); check.addMouseListener(this); check.addMouseMotionListener(this); check.setBackground(col); check.addItemListener(this); add(check); } validate(); } public void itemStateChanged(ItemEvent evt) { Component [] comps = this.getComponents(); int cSize = comps.length; Object [][] data = new Object[cSize][3]; for(int i=0; i this.getSize().height) { comp = this.getComponent(this.getComponentCount()-1); } else if(height < 0) { comp = this.getComponent(0); } else { comp = this.getComponentAt(evt.getX(), evt.getY() + evt.getComponent().getLocation().y); } if(comp!=null && comp instanceof Checkbox) target = (Checkbox)comp; if (selectedCheck != null && target != null && selectedCheck != target) { int targetIndex = -1; for(int i=0; i