status.das_feature_fetching_complete = DAS Feature Fetching Complete
status.fetching_db_refs = Fetching db refs
label.font_doesnt_have_letters_defined = Font doesn't have letters defined\nso cannot be used\nwith alignment data
+label.font_too_small = Font size is too small
label.error_loading_file_params = Error loading file {0}
label.error_loading_jalview_file = Error loading Jalview file
warn.out_of_memory_when_action = Out of memory when {0}\!\!\nSee help files for increasing Java Virtual Machine memory.
status.das_feature_fetching_complete = Recuperación de características DAS completada
status.fetching_db_refs = Recuperando db refs
label.font_doesnt_have_letters_defined = La fuente no tiene letras definidas\npor lo que no puede emplease\ncon datos de alineamientos
+label.font_too_small = Tamaño de la letra es demasiado pequeña
label.error_loading_file_params = Error cargando el fichero {0}
label.error_loading_jalview_file = Error cargando el fichero Jalview
warn.out_of_memory_when_action = Sin memoria al {0}\!\!\nConsulte los ficheros de ayuda para ajustar la memoria de la m\u00E1quina virtual de Java.
final boolean openInNewWindow = (response == 2);
/*
- * Create the AlignFrame first (which creates the new alignment's datasets),
- * before attempting sequence mapping.
- */
- AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
- AlignFrame.DEFAULT_HEIGHT);
- newAlignFrame.setTitle(title);
-
- /*
* Identify protein and dna alignments. Make a copy of this one if opening
* in a new split pane.
*/
AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
+ /*
+ * Map sequences. At least one should get mapped as we have already passed
+ * the test for 'mappability'. Any mappings made will be added to the
+ * protein alignment. Note creating dataset sequences on the new alignment
+ * is a pre-requisite for building mappings.
+ */
+ al.setDataset(null);
+ AlignmentUtils.mapProteinToCdna(protein, cdna);
+
+ /*
+ * Create the AlignFrame for the added alignment. Note this will include the
+ * cDNA consensus annotation if it is protein (because the alignment holds
+ * mappings to nucleotide)
+ */
+ AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
+ AlignFrame.DEFAULT_HEIGHT);
+ newAlignFrame.setTitle(title);
newAlignFrame.statusBar.setText(MessageManager.formatMessage(
"label.successfully_loaded_file", new Object[]
{ title }));
AlignFrame.DEFAULT_HEIGHT);
}
- /*
- * Map sequences. At least one should get mapped as we have already passed
- * the test for 'mappability'. Any mappings made will be added to the
- * protein alignment.
- */
- AlignmentUtils.mapProteinToCdna(protein, cdna);
-
try
{
newAlignFrame.setMaximum(jalview.bin.Cache.getDefault(
AlignmentI complement, Set<AlignedCodonFrame> mappings)
{
/*
- * Open in split pane. DNA sequence above, protein below.
+ * Make a new frame with a copy of the alignment we are adding to. If this
+ * is protein, the new frame will have a cDNA consensus annotation row
+ * added.
*/
AlignFrame copyMe = new AlignFrame(complement,
AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
proteinFrame.setVisible(true);
String linkedTitle = MessageManager
.getString("label.linked_view_title");
+
+ /*
+ * Open in split pane. DNA sequence above, protein below.
+ */
JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.event.ActionEvent;
+import java.awt.geom.Rectangle2D;
import javax.swing.JInternalFrame;
import javax.swing.JLayeredPane;
TreePanel tp;
+ /*
+ * The font on opening the dialog (to be restored on Cancel)
+ */
Font oldFont;
boolean oldProteinScale;
JInternalFrame frame;
+ /*
+ * The last font settings selected in the dialog
+ */
+ private Font lastSelected = null;
+
+ private boolean lastSelMono = false;
+
/**
* Creates a new FontChooser object.
*
}
}
- private Font lastSelected = null;
-
- private int lastSelStyle = 0;
-
- private int lastSelSize = 0;
-
- private boolean lastSelMono = false;
-
/**
* DOCUMENT ME!
*/
{
// initialise with original font
lastSelected = oldFont;
- lastSelSize = oldFont.getSize();
- lastSelStyle = oldFont.getStyle();
FontMetrics fm = getGraphics().getFontMetrics(oldFont);
- double mw = fm.getStringBounds("M", getGraphics()).getWidth(), iw = fm
- .getStringBounds("I", getGraphics()).getWidth();
- lastSelMono = mw == iw;
+ double mw = fm.getStringBounds("M", getGraphics()).getWidth();
+ double iw = fm.getStringBounds("I", getGraphics()).getWidth();
+ lastSelMono = (mw == iw); // == on double - flaky?
}
Font newFont = new Font(fontName.getSelectedItem().toString(),
fontStyle.getSelectedIndex(),
(Integer) fontSize.getSelectedItem());
FontMetrics fm = getGraphics().getFontMetrics(newFont);
- double mw = fm.getStringBounds("M", getGraphics()).getWidth(), iw = fm
- .getStringBounds("I", getGraphics()).getWidth();
+ double mw = fm.getStringBounds("M", getGraphics()).getWidth();
+ final Rectangle2D iBounds = fm.getStringBounds("I", getGraphics());
+ double iw = iBounds.getWidth();
if (mw < 1 || iw < 1)
{
+ final String messageKey = iBounds.getHeight() < 1 ? "label.font_doesnt_have_letters_defined"
+ : "label.font_too_small";
JOptionPane
.showInternalMessageDialog(
this,
- MessageManager.getString("label.font_doesnt_have_letters_defined"),
+ MessageManager.getString(messageKey),
MessageManager.getString("label.invalid_font"), JOptionPane.WARNING_MESSAGE);
/*
- * Restore previous values - size first to avoid recursive calls to this
- * point!
+ * Restore the changed value - note this will reinvoke this method via the
+ * ActionListener, but now validation should pass
*/
- fontSize.setSelectedItem(lastSelSize);
- fontName.setSelectedItem(lastSelected.getName());
- fontStyle.setSelectedIndex(lastSelStyle);
- monospaced.setSelected(lastSelMono);
+ if (lastSelected.getSize() != (Integer) fontSize.getSelectedItem()) // autoboxing
+ {
+ fontSize.setSelectedItem(lastSelected.getSize());
+ }
+ if (!lastSelected.getName().equals(
+ fontName.getSelectedItem().toString()))
+ {
+ fontName.setSelectedItem(lastSelected.getName());
+ }
+ if (lastSelected.getStyle() != fontStyle.getSelectedIndex())
+ {
+ fontStyle.setSelectedIndex(lastSelected.getStyle());
+ }
+ if (lastSelMono != monospaced.isSelected())
+ {
+ monospaced.setSelected(lastSelMono);
+ }
return;
}
if (tp != null)
}
monospaced.setSelected(mw == iw);
- // remember last selected
+
+ /*
+ * Remember latest valid selection, so it can be restored if followed by an
+ * invalid one
+ */
lastSelected = newFont;
}
*/
package jalview.gui;
-import jalview.api.structures.JalviewStructureDisplayI;
-import jalview.datamodel.SequenceGroup;
-import jalview.io.JalviewFileChooser;
-import jalview.jbgui.GUserDefinedColours;
-import jalview.schemes.ColourSchemeI;
-import jalview.schemes.ResidueProperties;
-import jalview.schemes.UserColourScheme;
-import jalview.util.ColorUtils;
-import jalview.util.MessageManager;
-
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import jalview.api.structures.JalviewStructureDisplayI;
+import jalview.datamodel.SequenceGroup;
+import jalview.io.JalviewFileChooser;
+import jalview.jbgui.GUserDefinedColours;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.ResidueProperties;
+import jalview.schemes.UserColourScheme;
+import jalview.util.ColorUtils;
+import jalview.util.MessageManager;
+
/**
* This panel allows the user to assign colours to Amino Acid residue codes, and
* save the colour scheme.
@Override
protected void okButton_actionPerformed(ActionEvent e)
{
- //Check if the user have done any selection
- boolean showWarning = (upperCaseButtons==null) ||
- ((upperCaseButtons!=null) && (upperCaseButtons.size()==0)) ||
- (lowerCaseButtons==null) ||
- ((lowerCaseButtons!=null) && (lowerCaseButtons.size()==0));
- if (showWarning){
- JOptionPane.showMessageDialog(Desktop.desktop,
- MessageManager.getString("label.no_colour_selection_in_scheme"),MessageManager.getString("label.no_colour_selection_warn"),
- JOptionPane.WARNING_MESSAGE);
-
- }else{
- applyButton_actionPerformed(null);
-
- try
- {
- frame.setClosed(true);
- } catch (Exception ex)
- {
- }
- }
+ if (isNoSelectionMade())
+ {
+ JOptionPane.showMessageDialog(Desktop.desktop, MessageManager
+ .getString("label.no_colour_selection_in_scheme"),
+ MessageManager.getString("label.no_colour_selection_warn"),
+ JOptionPane.WARNING_MESSAGE);
+ }
+ else
+ {
+ applyButton_actionPerformed(null);
+
+ try
+ {
+ frame.setClosed(true);
+ } catch (Exception ex)
+ {
+ }
+ }
+ }
+
+ /**
+ * Returns true if the user has not made any colour selection (including if
+ * 'case-sensitive' selected and no lower-case colour chosen).
+ *
+ * @return
+ */
+ protected boolean isNoSelectionMade()
+ {
+ final boolean noUpperCaseSelected = upperCaseButtons == null
+ || upperCaseButtons.isEmpty();
+ final boolean noLowerCaseSelected = caseSensitive.isSelected()
+ && (lowerCaseButtons == null || lowerCaseButtons.isEmpty());
+ final boolean noSelectionMade = noUpperCaseSelected || noLowerCaseSelected;
+ return noSelectionMade;
}
/**
@Override
protected void applyButton_actionPerformed(ActionEvent e)
{
- //Check if the user have done any selection
- boolean showWarning = (upperCaseButtons==null) ||
- ((upperCaseButtons!=null) && (upperCaseButtons.size()==0)) ||
- (lowerCaseButtons==null) ||
- ((lowerCaseButtons!=null) && (lowerCaseButtons.size()==0));
- if (showWarning){
+ if (isNoSelectionMade())
+ {
JOptionPane.showMessageDialog(Desktop.desktop,
MessageManager.getString("label.no_colour_selection_in_scheme"),MessageManager.getString("label.no_colour_selection_warn"),
JOptionPane.WARNING_MESSAGE);
name = jucs.getColour(i).getName();
if (ResidueProperties.aa3Hash.containsKey(name))
{
- index = ((Integer) ResidueProperties.aa3Hash.get(name))
+ index = ResidueProperties.aa3Hash.get(name)
.intValue();
}
else
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topFrame,
bottomFrame);
splitPane.setVisible(true);
- final double ratio = topFrame.getHeight()
+ final double ratio = bottomFrame.getHeight() == 0 ? 0.5d : topFrame
+ .getHeight()
/ (double) (topFrame.getHeight() + bottomFrame.getHeight());
splitPane.setDividerLocation(ratio);
splitPane.setResizeWeight(ratio);
SequenceI[] sortOrder = command.getSequenceOrder(undo);
List<SequenceI> mappedOrder = new ArrayList<SequenceI>();
int j = 0;
+
+ /*
+ * Assumption: we are only interested in a cDNA/protein mapping; refactor in
+ * future if we want to support sorting (c)dna as (c)dna or protein as
+ * protein
+ */
+ boolean mappingToNucleotide = mapTo.isNucleotide();
for (SequenceI seq : sortOrder)
{
for (AlignedCodonFrame acf : mappings)
{
- /*
- * Try protein-to-Dna, failing that try dna-to-protein
- */
- SequenceI mappedSeq = acf.getDnaForAaSeq(seq);
- if (mappedSeq == null)
- {
- mappedSeq = acf.getAaForDnaSeq(seq);
- }
+ SequenceI mappedSeq = mappingToNucleotide ? acf.getDnaForAaSeq(seq) : acf.getAaForDnaSeq(seq);
if (mappedSeq != null)
{
for (SequenceI seq2 : mapTo.getSequences())
{
String[] fonts = java.awt.GraphicsEnvironment
.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
+ final Canvas canvas = new Canvas();
for (int pointSize = 1;; pointSize++)
{
System.out.println(System.lineSeparator()
- + "Fonts with insufficient width at " + pointSize + "pt:");
+ + "Plain fonts with sub-pixel width at " + pointSize + "pt:");
if (pointSize == 1)
{
System.out.println("All except:");
for (String fontname : fonts)
{
Font newFont = new Font(fontname, Font.PLAIN, pointSize);
- FontMetrics fontm = new Canvas().getFontMetrics(newFont);
+ FontMetrics fontm = canvas.getFontMetrics(newFont);
double iw = fontm.getStringBounds("I", null).getWidth();
final boolean tooSmall = iw < 1d;
if (tooSmall)