*/
package jalview.api;
+import jalview.controller.FeatureSettingsControllerGuiI;
import jalview.datamodel.AlignmentI;
/**
AlignViewControllerGuiI getComplementAlignFrame(
AlignViewControllerGuiI alignFrame);
+ /**
+ * add the given UI to the splitframe's feature settings UI holder
+ *
+ * @param featureSettings
+ * @return
+ */
+ void addFeatureSettingsUI(
+ FeatureSettingsControllerGuiI featureSettings);
+
+ /**
+ * Request to close all feature settings originating from a particular panel
+ *
+ * @param featureSettings
+ */
+ void closeFeatureSettings(FeatureSettingsControllerI featureSettings);
+
}
*/
package jalview.controller;
+import jalview.api.AlignViewControllerGuiI;
+
public interface FeatureSettingsControllerGuiI
{
+ AlignViewControllerGuiI getAlignframe();
+
+ void closeFeatureSettings();
+
}
import jalview.api.AlignViewportI;
import jalview.api.FeatureColourI;
import jalview.api.FeatureSettingsControllerI;
+import jalview.api.SplitContainerI;
import jalview.api.ViewStyleI;
+import jalview.controller.FeatureSettingsControllerGuiI;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceI;
import jalview.datamodel.features.FeatureMatcher;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
+import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridLayout;
import javax.xml.stream.XMLStreamReader;
public class FeatureSettings extends JPanel
- implements FeatureSettingsControllerI
+ implements FeatureSettingsControllerI, FeatureSettingsControllerGuiI
{
private static final String SEQUENCE_FEATURE_COLOURS = MessageManager
.getString("label.sequence_feature_colours");
}
discoverAllFeatureData();
- final PropertyChangeListener change;
final FeatureSettings fs = this;
fr.addPropertyChangeListener(change = new PropertyChangeListener()
{
}
});
-
- frame = new JInternalFrame();
- frame.setContentPane(this);
- if (Platform.isAMac())
+ SplitContainerI splitframe = af.getSplitViewContainer();
+ if (splitframe != null)
{
- Desktop.addInternalFrame(frame,
- MessageManager.getString("label.sequence_feature_settings"),
- 600, 480);
+ frame = null; // keeps eclipse happy
+ splitframe.addFeatureSettingsUI(this);
}
else
{
- Desktop.addInternalFrame(frame,
- MessageManager.getString("label.sequence_feature_settings"),
- 600, 450);
- }
- frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
+ frame = new JInternalFrame();
+ frame.setContentPane(this);
+ if (Platform.isAMac())
+ {
+ Desktop.addInternalFrame(frame,
+ MessageManager.getString("label.sequence_feature_settings"),
+ 600, 480);
+ }
+ else
+ {
+ Desktop.addInternalFrame(frame,
+ MessageManager.getString("label.sequence_feature_settings"),
+ 600, 450);
+ }
+ frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
- frame.addInternalFrameListener(
- new javax.swing.event.InternalFrameAdapter()
- {
- @Override
- public void internalFrameClosed(
- javax.swing.event.InternalFrameEvent evt)
+ frame.addInternalFrameListener(
+ new javax.swing.event.InternalFrameAdapter()
{
- fr.removePropertyChangeListener(change);
- };
- });
- frame.setLayer(JLayeredPane.PALETTE_LAYER);
+ @Override
+ public void internalFrameClosed(
+ javax.swing.event.InternalFrameEvent evt)
+ {
+ closeFeatureSettings();
+ };
+ });
+ frame.setLayer(JLayeredPane.PALETTE_LAYER);
+ }
inConstruction = false;
}
+ PropertyChangeListener change;
+
+ @Override
+ public AlignViewControllerGuiI getAlignframe()
+ {
+ return af;
+ }
+
+ @Override
+ public void closeFeatureSettings()
+ {
+ fr.removePropertyChangeListener(change);
+ change = null;
+ }
+
protected void popupSort(final int rowSelected, final String type,
final Object typeCol, final Map<String, float[][]> minmax, int x,
int y)
{
try
{
- frame.setClosed(true);
+ if (frame != null)
+ {
+ frame.setClosed(true);
+ }
+ else
+ {
+ SplitContainerI sc = af.getSplitViewContainer();
+ sc.closeFeatureSettings(this);
+ af.featureSettings = null;
+ }
} catch (Exception exe)
{
}
refreshDisplay();
}
});
- JButton viewComplementSettings = new JButton(MessageManager
- .formatMessage("label.show_linked_feature_settings",
- nucleotide
- ? MessageManager.getString("label.protein")
- .toLowerCase()
- : "CDS"));
- viewComplementSettings.addActionListener(new ActionListener()
- {
-
- @Override
- public void actionPerformed(ActionEvent e)
- {
- AlignViewControllerGuiI complAf = af.getSplitViewContainer()
- .getComplementAlignFrame(af);
- FeatureSettings complFeatureSettings = (FeatureSettings) complAf
- .getFeatureSettingsUI();
- if (complFeatureSettings != null)
- {
- complFeatureSettings.frame.setVisible(true);
- try
- {
- complFeatureSettings.frame.setSelected(true);
- return;
- } catch (Exception q)
- {
- }
- }
- {
- complAf.showFeatureSettingsUI();
- }
- }
- });
+ // JButton viewComplementSettings = new JButton(MessageManager
+ // .formatMessage("label.show_linked_feature_settings",
+ // nucleotide
+ // ? MessageManager.getString("label.protein")
+ // .toLowerCase()
+ // : "CDS"));
+ // viewComplementSettings.addActionListener(new ActionListener()
+ // {
+ //
+ // @Override
+ // public void actionPerformed(ActionEvent e)
+ // {
+ // AlignViewControllerGuiI complAf = af.getSplitViewContainer()
+ // .getComplementAlignFrame(af);
+ // FeatureSettings complFeatureSettings = (FeatureSettings) complAf
+ // .getFeatureSettingsUI();
+ // if (complFeatureSettings != null)
+ // {
+ // complFeatureSettings.frame.setVisible(true);
+ // try
+ // {
+ // complFeatureSettings.frame.setSelected(true);
+ // return;
+ // } catch (Exception q)
+ // {
+ // }
+ // }
+ // {
+ // complAf.showFeatureSettingsUI();
+ // }
+ // }
+ // });
JPanel lowerPanel = new JPanel(new GridLayout(1, 2));
bigPanel.add(lowerPanel, BorderLayout.SOUTH);
transPanelLeft.add(transparency);
if (hasComplement)
{
- JPanel cp = new JPanel(new GridLayout(3, 2));
+ JPanel cp = new JPanel(new FlowLayout(FlowLayout.LEFT));
cp.add(showComplement);
cp.add(showComplementOnTop);
- cp.add(viewComplementSettings);
transPanelLeft.add(cp);
}
lowerPanel.add(transPanelLeft);
package jalview.gui;
import jalview.api.AlignViewControllerGuiI;
+import jalview.api.FeatureSettingsControllerI;
import jalview.api.SplitContainerI;
+import jalview.controller.FeatureSettingsControllerGuiI;
import jalview.datamodel.AlignmentI;
import jalview.jbgui.GAlignFrame;
import jalview.jbgui.GSplitFrame;
import jalview.structure.StructureSelectionManager;
+import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.viewmodel.AlignmentViewport;
import java.awt.Component;
+import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JComponent;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
+import javax.swing.JLayeredPane;
import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JTabbedPane;
import javax.swing.KeyStroke;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
private static final long serialVersionUID = 1L;
+ /**
+ * geometry for Feature Settings Holder
+ */
+ private static final int FS_MIN_WIDTH = 400;
+
+ private static final int FS_MIN_HEIGHT = 400;
+
public SplitFrame(GAlignFrame top, GAlignFrame bottom)
{
super(top, bottom);
}
super.setSelected(selected);
}
-}
+
+ /**
+ * holds the frame for feature settings, so Protein and DNA tabs can be managed
+ */
+ JInternalFrame featureSettingsUI;
+
+ JTabbedPane featureSettingsPanels;
+
+ @Override
+ public void addFeatureSettingsUI(
+ FeatureSettingsControllerGuiI featureSettings)
+ {
+ boolean showInternalFrame = false;
+ if (featureSettingsUI == null)
+ {
+ showInternalFrame = true;
+ featureSettingsPanels = new JTabbedPane();
+ featureSettingsUI = new JInternalFrame(
+ "Feature Settings for CDS and Protein Views");
+ featureSettingsPanels.setOpaque(true);
+ featureSettingsUI.setContentPane(featureSettingsPanels);
+ JPanel dummyDNA = new JPanel(),dummyProtein=new JPanel();
+ FocusListener fl1 = new FocusListener()
+ {
+
+ @Override
+ public void focusLost(FocusEvent e)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void focusGained(FocusEvent e)
+ {
+ int tab = featureSettingsPanels.getSelectedIndex();
+ getAlignFrames().get(tab).showFeatureSettingsUI();
+ }
+ };
+ dummyDNA.addFocusListener(fl1);
+ dummyProtein.addFocusListener(fl1);
+
+ featureSettingsPanels.addTab("CDS", dummyDNA);
+ featureSettingsPanels.addTab("Protein", dummyProtein);
+ }
+ if (featureSettingsPanels
+ .indexOfTabComponent((Component) featureSettings) > -1)
+ {
+ // just show the feature settings !
+ featureSettingsPanels
+ .setSelectedComponent((Component) featureSettings);
+ return;
+ }
+ // otherwise replace the dummy tab with the given feature settings
+ int pos = getAlignFrames().indexOf(featureSettings.getAlignframe());
+ // if pos==-1 then alignFrame isn't managed by this splitframe
+ if (pos == 0)
+ {
+ featureSettingsPanels.removeTabAt(0);
+ featureSettingsPanels.insertTab("CDS", null,
+ (Component) featureSettings, "Feature Settings for DNA CDS",
+ 0);
+ }
+ if (pos == 1)
+ {
+ featureSettingsPanels.removeTabAt(1);
+ featureSettingsPanels.insertTab("Protein", null,
+ (Component) featureSettings, "Feature Settings for Protein",
+ 1);
+ }
+ featureSettingsPanels.setSelectedComponent((Component) featureSettings);
+ if (showInternalFrame)
+ {
+ if (Platform.isAMac())
+ {
+ Desktop.addInternalFrame(featureSettingsUI,
+ MessageManager.getString(
+ "Feature Settings for CDS and Protein Views"),
+ 600, 480);
+ }
+ else
+ {
+ Desktop.addInternalFrame(featureSettingsUI,
+ MessageManager.getString(
+ "Feature Settings for CDS and Protein Views"),
+ 600, 450);
+ }
+ featureSettingsUI
+ .setMinimumSize(new Dimension(FS_MIN_WIDTH, FS_MIN_HEIGHT));
+
+ featureSettingsUI.addInternalFrameListener(
+ new javax.swing.event.InternalFrameAdapter()
+ {
+ @Override
+ public void internalFrameClosed(
+ javax.swing.event.InternalFrameEvent evt)
+ {
+ for (int tab = 0; tab < featureSettingsPanels
+ .getTabCount();)
+ {
+ FeatureSettingsControllerGuiI fsettings = (FeatureSettingsControllerGuiI) featureSettingsPanels
+ .getTabComponentAt(tab);
+ if (fsettings != null)
+ {
+ featureSettingsPanels.removeTabAt(tab);
+ fsettings.closeFeatureSettings();
+ }
+ else
+ {
+ tab++;
+ }
+ }
+ featureSettingsPanels = null;
+ };
+ });
+ featureSettingsUI.setLayer(JLayeredPane.PALETTE_LAYER);
+ }
+ }
+
+ @Override
+ public void closeFeatureSettings(
+ FeatureSettingsControllerI featureSettings)
+ {
+ if (featureSettingsUI != null)
+ {
+ try
+ {
+ featureSettingsUI.setClosed(true);
+ } catch (Exception x)
+ {
+ }
+ featureSettingsUI = null;
+ }
+ }
+}
\ No newline at end of file