From: gmungoc Date: Thu, 23 Apr 2015 09:47:30 +0000 (+0100) Subject: JAL-1706 distinguish between 'font too small' and 'font does not have X-Git-Tag: Jalview_2_9~52 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=ec48924dda6dc02a967e413eea0a5fc6609c2ae3;hp=5351b9fbb6e8a15f4c3cc83d8cc58cec4e1c016a;p=jalview.git JAL-1706 distinguish between 'font too small' and 'font does not have letters' --- diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 3d572f5..42dfca9 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -1142,6 +1142,7 @@ status.das_feature_fetching_cancelled = DAS Feature Fetching Cancelled 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. diff --git a/resources/lang/Messages_es.properties b/resources/lang/Messages_es.properties index 241fff2..6db40cf 100644 --- a/resources/lang/Messages_es.properties +++ b/resources/lang/Messages_es.properties @@ -1097,6 +1097,7 @@ status.das_feature_fetching_cancelled = Recuperaci 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. diff --git a/src/jalview/gui/FontChooser.java b/src/jalview/gui/FontChooser.java index 92d2b2b..2ffb166 100755 --- a/src/jalview/gui/FontChooser.java +++ b/src/jalview/gui/FontChooser.java @@ -23,6 +23,7 @@ package jalview.gui; 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; @@ -241,14 +242,17 @@ public class FontChooser extends GFontChooser 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 the changed value - note this will reinvoke this method via the