/*
- * Jalview - A Sequence Alignment Editor and Viewer
- * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
- *
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
+ * Copyright (C) 2008 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
import jalview.datamodel.*;
-public class FeatureSettings
- extends Panel implements ItemListener,
- MouseListener, MouseMotionListener, ActionListener, AdjustmentListener
+public class FeatureSettings extends Panel implements ItemListener,
+ MouseListener, MouseMotionListener, ActionListener,
+ AdjustmentListener
{
FeatureRenderer fr;
+
AlignmentPanel ap;
+
AlignViewport av;
+
Frame frame;
+
Panel groupPanel;
+
Panel featurePanel = new Panel();
+
ScrollPane scrollPane;
+
boolean alignmentHasFeatures = false;
+
Image linkImage;
+
Scrollbar transparency;
public FeatureSettings(final AlignmentPanel ap)
fr = ap.seqPanel.seqCanvas.getFeatureRenderer();
transparency = new Scrollbar(Scrollbar.HORIZONTAL,
- 100 - (int) (fr.transparency * 100), 1, 1, 100);
+ 100 - (int) (fr.transparency * 100), 1, 1, 100);
if (fr.transparencySetter != null)
{
}
else
{
- tPanel.add(new Label("Transparency not available in this web browser"),
- BorderLayout.CENTER);
+ tPanel.add(
+ new Label("Transparency not available in this web browser"),
+ BorderLayout.CENTER);
}
lowerPanel.add(tPanel, BorderLayout.SOUTH);
if (groupPanel != null)
{
- groupPanel.setLayout(
- new GridLayout(fr.featureGroups.size() / 4 + 1, 4));
+ groupPanel.setLayout(new GridLayout(fr.featureGroups.size() / 4 + 1,
+ 4));
groupPanel.validate();
add(groupPanel, BorderLayout.NORTH);
{
public void windowClosing(WindowEvent e)
{
- if (me.av.featureSettings==me)
+ if (me.av.featureSettings == me)
{
me.av.featureSettings = null;
me.ap = null;
me.av = null;
}
}
- }
- );
+ });
int height = featurePanel.getComponentCount() * 50 + 60;
height = Math.max(200, height);
height = Math.min(400, height);
int width = 300;
jalview.bin.JalviewLite.addFrame(frame, "Feature Settings", width,
- height);
+ height);
}
public void paint(Graphics g)
if (alignmentHasFeatures)
{
rebuildGroups();
-
+
}
resetTable(false);
}
+
/**
* rebuilds the group panel
*/
if (groupPanel == null)
{
groupPanel = new Panel();
- } else {
+ }
+ else
+ {
rdrw = true;
groupPanel.removeAll();
}
-
+
Enumeration gps = fr.featureGroups.keys();
while (gps.hasMoreElements())
{
String group = (String) gps.nextElement();
Boolean vis = (Boolean) fr.featureGroups.get(group);
- Checkbox check = new MyCheckbox(
- group,
- vis.booleanValue(),
- (fr.featureLinks != null && fr.featureLinks.containsKey(group))
- );
+ Checkbox check = new MyCheckbox(group, vis.booleanValue(),
+ (fr.featureLinks != null && fr.featureLinks
+ .containsKey(group)));
check.addMouseListener(this);
check.setFont(new Font("Serif", Font.BOLD, 12));
check.addItemListener(this);
}
}
- //This routine adds and removes checkboxes depending on
- //Group selection states
+ // This routine adds and removes checkboxes depending on
+ // Group selection states
void resetTable(boolean groupsChanged)
{
SequenceFeature[] tmpfeatures;
{
group = tmpfeatures[index].featureGroup;
- if (group == null || fr.featureGroups.get(group) == null ||
- ( (Boolean) fr.featureGroups.get(group)).booleanValue())
+ if (group == null || fr.featureGroups.get(group) == null
+ || ((Boolean) fr.featureGroups.get(group)).booleanValue())
{
type = tmpfeatures[index].getType();
if (!visibleChecks.contains(type))
Component[] comps;
int cSize = featurePanel.getComponentCount();
Checkbox check;
- //This will remove any checkboxes which shouldn't be
- //visible
+ // This will remove any checkboxes which shouldn't be
+ // visible
for (int i = 0; i < cSize; i++)
{
comps = featurePanel.getComponents();
if (fr.renderOrder != null)
{
- //First add the checks in the previous render order,
- //in case the window has been closed and reopened
+ // First add the checks in the previous render order,
+ // in case the window has been closed and reopened
for (int ro = fr.renderOrder.length - 1; ro > -1; ro--)
{
String item = fr.renderOrder[ro];
addCheck(groupsChanged, en.nextElement().toString());
}
- featurePanel.setLayout(new GridLayout(featurePanel.getComponentCount(), 1,
- 10, 5));
+ featurePanel.setLayout(new GridLayout(featurePanel.getComponentCount(),
+ 1, 10, 5));
featurePanel.validate();
if (scrollPane != null)
itemStateChanged(null);
}
+
/**
* update the checklist of feature types with the given type
- * @param groupsChanged true means if the type is not in the display list then it will be added and displayed
- * @param type feature type to be checked for in the list.
+ *
+ * @param groupsChanged
+ * true means if the type is not in the display list then it
+ * will be added and displayed
+ * @param type
+ * feature type to be checked for in the list.
*/
void addCheck(boolean groupsChanged, String type)
{
selected = true;
}
- check = new MyCheckbox(type,
- selected,
- (fr.featureLinks != null &&
- fr.featureLinks.containsKey(type))
- );
+ check = new MyCheckbox(
+ type,
+ selected,
+ (fr.featureLinks != null && fr.featureLinks.containsKey(type)));
check.addMouseListener(this);
check.addMouseMotionListener(this);
{
if (evt != null)
{
- //Is the source a top level featureGroup?
+ // Is the source a top level featureGroup?
Checkbox source = (Checkbox) evt.getSource();
if (fr.featureGroups.containsKey(source.getLabel()))
{
- fr.featureGroups.put(source.getLabel(), new Boolean(source.getState()));
+ fr.featureGroups.put(source.getLabel(), new Boolean(source
+ .getState()));
ap.seqPanel.seqCanvas.repaint();
if (ap.overviewPanel != null)
{
}
MyCheckbox selectedCheck;
+
boolean dragging = false;
public void mousePressed(MouseEvent evt)
selectedCheck = (MyCheckbox) evt.getSource();
if (fr.featureLinks != null
- && fr.featureLinks.containsKey(selectedCheck.getLabel())
- )
+ && fr.featureLinks.containsKey(selectedCheck.getLabel()))
{
if (evt.getX() > selectedCheck.stringWidth + 20)
{
public void mouseDragged(MouseEvent evt)
{
- if ( ( (Component) evt.getSource()).getParent() != featurePanel)
+ if (((Component) evt.getSource()).getParent() != featurePanel)
{
return;
}
public void mouseReleased(MouseEvent evt)
{
- if ( ( (Component) evt.getSource()).getParent() != featurePanel)
+ if (((Component) evt.getSource()).getParent() != featurePanel)
{
return;
}
if (height > featurePanel.getSize().height)
{
- comp = featurePanel.getComponent(featurePanel.getComponentCount() - 1);
+ comp = featurePanel
+ .getComponent(featurePanel.getComponentCount() - 1);
}
else if (height < 0)
{
}
else
{
- comp = featurePanel.getComponentAt(evt.getX(),
- evt.getY() +
- evt.getComponent().getLocation().y);
+ comp = featurePanel.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)
+ if (selectedCheck != null && target != null && selectedCheck != target)
{
int targetIndex = -1;
for (int i = 0; i < featurePanel.getComponentCount(); i++)
}
public void mouseEntered(MouseEvent evt)
- {}
+ {
+ }
public void mouseExited(MouseEvent evt)
- {}
+ {
+ }
public void mouseClicked(MouseEvent evt)
{
MyCheckbox check = (MyCheckbox) evt.getSource();
if (fr.featureLinks != null
- && fr.featureLinks.containsKey(check.getLabel()))
+ && fr.featureLinks.containsKey(check.getLabel()))
{
if (evt.getX() > check.stringWidth + 20)
{
evt.consume();
String link = fr.featureLinks.get(check.getLabel()).toString();
- ap.alignFrame.showURL(link.substring(link.indexOf("|") + 1),
- link.substring(0, link.indexOf("|")));
+ ap.alignFrame.showURL(link.substring(link.indexOf("|") + 1), link
+ .substring(0, link.indexOf("|")));
}
}
if (evt.getClickCount() > 1)
{
- new UserDefinedColours(this, check.getLabel(),
- fr.getColour(check.getLabel()));
+ new UserDefinedColours(this, check.getLabel(), fr.getColour(check
+ .getLabel()));
}
}
public void mouseMoved(MouseEvent evt)
- {}
+ {
+ }
public void adjustmentValueChanged(AdjustmentEvent evt)
{
- fr.transparency = ( (float) (100 - transparency.getValue()) / 100f);
+ fr.transparency = ((float) (100 - transparency.getValue()) / 100f);
ap.seqPanel.seqCanvas.repaint();
}
- class MyCheckbox
- extends Checkbox
+ class MyCheckbox extends Checkbox
{
public int stringWidth;
+
boolean hasLink;
+
public MyCheckbox(String label, boolean checked, boolean haslink)
{
super(label, checked);
{
if (hasLink)
{
- g.drawImage(linkImage, stringWidth + 25, (
- getSize().height - linkImage.getHeight(this)) / 2,
- this);
+ g.drawImage(linkImage, stringWidth + 25,
+ (getSize().height - linkImage.getHeight(this)) / 2, this);
}
}
}