From: hansonr Date: Fri, 12 Jul 2019 07:02:25 +0000 (+0100) Subject: JAL-3366 JAL-3253-applet X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=b99e07953b993df11db59d578886db7cc0add719 JAL-3366 JAL-3253-applet adds RendererPanel default inner size. --- diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 36ade0b..ebbbeeb 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -263,6 +263,7 @@ label.use_rnaview = Use RNAView for secondary structure label.autoadd_secstr = Add secondary structure annotation to alignment label.autoadd_temp = Add Temperature Factor annotation to alignment label.structure_viewer = Default structure viewer +label.structure_dimensions = Default dimensions label.double_click_to_browse = Double-click to browse for file label.chimera_path = Path to Chimera program label.chimera_path_tip = Jalview will first try any path entered here, else standard installation locations.
Double-click to browse for file. diff --git a/resources/lang/Messages_es.properties b/resources/lang/Messages_es.properties index 8bd22a0..baeb5af 100644 --- a/resources/lang/Messages_es.properties +++ b/resources/lang/Messages_es.properties @@ -1202,6 +1202,7 @@ label.alpha_helix=H label.chimera_help=Ayuda para Chimera label.find_tip=Buscar alineamiento, selección o IDs de secuencia para una subsecuencia (sin huecos) label.structure_viewer=Visualizador por defecto +label.structure_dimensions=Dimensiones por defecto label.embbed_biojson=Incrustar BioJSON al exportar HTML label.transparency_tip=Ajustar la transparencia a "ver a través" los colores de las características. label.choose_annotations=Escoja anotaciones diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 4dac4df..b15c317 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -33,6 +33,7 @@ import jalview.util.Platform; import jalview.ws.sifts.SiftsSettings; import java.awt.Color; +import java.awt.Dimension; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -661,6 +662,40 @@ public class Cache implements ApplicationSingletonI } /** + * retrieve a dimension, such as for Jmol + * + * @param property + * @param def + * @return + */ + public static Dimension getDefaultDim(String property, Dimension def) + { + String s = getProperty(property); + if (s != null) + { + if (s.indexOf(',') < 0) + { + s = s.trim().replace(' ', ','); + if (s.indexOf(',') < 0) + { + s += "," + s; + } + } + try + { + int pt = s.indexOf(","); + return new Dimension(Integer.parseInt(s.substring(0, pt)), + Integer.parseInt(s.substring(pt + 1))); + } catch (NumberFormatException e) + { + System.out.println("Error parsing Dimension property '" + property + + "' with value '" + s + "'"); + } + } + return def; + } + + /** * Answers the value of the given property, or the supplied default value if * the property is not set */ diff --git a/src/jalview/gui/AppJmol.java b/src/jalview/gui/AppJmol.java index b88ac35..5687219 100644 --- a/src/jalview/gui/AppJmol.java +++ b/src/jalview/gui/AppJmol.java @@ -238,6 +238,8 @@ public class AppJmol extends StructureViewerBase // TODO: consider waiting until the structure/view is fully loaded before // displaying this.getContentPane().add(renderPanel, java.awt.BorderLayout.CENTER); + this.invalidate(); + this.pack(); jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle(), getBounds().width, getBounds().height); if (scriptWindow == null) @@ -563,6 +565,7 @@ public class AppJmol extends StructureViewerBase * * @param type */ + @Override public void makePDBImage(ImageMaker.TYPE type) { int width = getWidth(); @@ -626,15 +629,25 @@ public class AppJmol extends StructureViewerBase validate(); } + @SuppressWarnings("serial") class RenderPanel extends JPanel { final Dimension currentSize = new Dimension(); + public RenderPanel() + { + setPreferredSize( + Cache.getDefaultDim(Preferences.STRUCTURE_DIMENSIONS, + Preferences.DEFAULT_STRUCTURE_DIMENSIONS)); + // BH 2019.07.12 suggesting 600,600; current is something like 347 x 323 + } + @Override public void paintComponent(Graphics g) { getSize(currentSize); - + // BH: Note that this size could be slightly different from the size set + // prior to packing. if (jmb != null && jmb.hasFileLoadingError()) { g.setColor(Color.black); diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index dbb5aec..b1206a2 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -84,67 +84,6 @@ import ext.edu.ucsf.rbvi.strucviz2.StructureManager; @SuppressWarnings("serial") public class Preferences extends GPreferences { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public static final String ADD_SS_ANN = "ADD_SS_ANN"; public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN"; @@ -261,6 +200,8 @@ public class Preferences extends GPreferences public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY"; + public static final String STRUCTURE_DIMENSIONS = "STRUCTURE_DIMENSIONS"; + public static final String UNIPROT_DOMAIN = "UNIPROT_DOMAIN"; public static final String USE_FULL_SO = "USE_FULL_SO"; @@ -302,6 +243,8 @@ public class Preferences extends GPreferences public static final String SHOW_FULLSCREEN = "SHOW_FULLSCREEN"; + public static final Dimension DEFAULT_STRUCTURE_DIMENSIONS = new Dimension( + 600, 600); static { @@ -363,11 +306,13 @@ public class Preferences extends GPreferences wsPrefs = new WsPreferences(); wsTab.add(wsPrefs, BorderLayout.CENTER); } - int width = 500, height = 450; + int width = 500, height = 510; // BH 2019.07.12 added 60 to height + // (structure panel was too small anyway, and I added a default dimension + // for Jmol if (Platform.isAMacAndNotJS()) { width = 570; - height = 480; + height = 540; // BH 2019.07.12 added 30 } Desktop.addInternalFrame(frame, @@ -512,6 +457,10 @@ public class Preferences extends GPreferences addTempFactor.setEnabled(structSelected); structViewer.setSelectedItem( Cache.getDefault(STRUCTURE_DISPLAY, ViewerType.JMOL.name())); + Dimension d = Cache.getDefaultDim(STRUCTURE_DIMENSIONS, + DEFAULT_STRUCTURE_DIMENSIONS); + String s = d.width + "," + d.height; + structureDimensions.setText(s); chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, "")); chimeraPath.addActionListener(new ActionListener() { @@ -872,6 +821,8 @@ public class Preferences extends GPreferences Boolean.toString(structFromPdb.isSelected())); Cache.setPropertyNoSave(STRUCTURE_DISPLAY, structViewer.getSelectedItem().toString()); + Cache.setPropertyNoSave(STRUCTURE_DIMENSIONS, + structureDimensions.getText()); // BH 2019.07.12 Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText()); Cache.setPropertyNoSave(MAP_WITH_SIFTS, Boolean.toString(siftsMapping.isSelected())); diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index c8052bc..7784cf4 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -180,6 +180,8 @@ public class GPreferences extends JPanel protected JComboBox structViewer = new JComboBox<>(); + protected JTextField structureDimensions = new JTextField(); + protected JTextField chimeraPath = new JTextField(); protected ButtonGroup mappingMethod = new ButtonGroup(); @@ -1281,6 +1283,7 @@ public class GPreferences extends JPanel structViewer.addItem(ViewerType.JMOL.name()); structViewer.addItem(ViewerType.CHIMERA.name()); structViewer.addActionListener(new ActionListener() + { @Override public void actionPerformed(ActionEvent e) @@ -1291,6 +1294,20 @@ public class GPreferences extends JPanel }); structureTab.add(structViewer); + // BH 2019.07.12 + ypos += lineSpacing; + JLabel dimLabel = new JLabel(); + dimLabel.setFont(new java.awt.Font("SansSerif", 0, 11)); + dimLabel.setHorizontalAlignment(SwingConstants.LEFT); + dimLabel.setText( + MessageManager.getString("label.structure_dimensions")); + dimLabel.setBounds(new Rectangle(10, ypos, 140, height)); + structureTab.add(dimLabel); + + structureDimensions.setFont(LABEL_FONT); + structureDimensions.setBounds(new Rectangle(160, ypos, 120, height)); + structureTab.add(structureDimensions); + ypos += lineSpacing; JLabel pathLabel = new JLabel(); pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11)); @@ -2747,6 +2764,7 @@ public class GPreferences extends JPanel button.setHorizontalAlignment(SwingConstants.CENTER); this.button.addActionListener(new ActionListener() { + @SuppressWarnings("synthetic-access") @Override public void actionPerformed(ActionEvent e) { @@ -2835,7 +2853,7 @@ class BackupFilesPresetsComboBoxRenderer extends DefaultListCellRenderer private static final long serialVersionUID = 88L; @Override - public Component getListCellRendererComponent(JList list, Object value, + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);