Merge branch 'Jalview-jJS/JAL-3253-applet-JAL-3436' into Jalview-JS/JAL-3253-applet
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 17 Oct 2019 09:35:09 +0000 (10:35 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 17 Oct 2019 09:35:09 +0000 (10:35 +0100)
56 files changed:
src/jalview/bin/Cache.java
src/jalview/gui/AlignmentPanel.java
src/jalview/gui/ColourMenuHelper.java
src/jalview/gui/Desktop.java
src/jalview/gui/FeatureSettings.java
src/jalview/gui/LineartOptions.java
src/jalview/gui/Preferences.java
src/jalview/io/AppletFormatAdapter.java
src/jalview/renderer/OverviewRenderer.java
src/jalview/renderer/seqfeatures/FeatureColourFinder.java
src/jalview/util/ColorUtils.java
src/jalview/util/Format.java
src/jalview/util/Platform.java
src/jalview/util/StringUtils.java
src/jalview/viewmodel/OverviewDimensions.java
srcjar/fr/README_SWINGJS.txt
srcjar/intervalstore/README_SWINGJS.txt [new file with mode: 0644]
srcjar/net/miginfocom/README_SWINGJS.txt
test/jalview/util/ColorUtilsTest.java
test/jalview/util/FormatTest.java
test/jalview/util/StringUtilsTest.java
unused/json/CDL.java [moved from src/org/json/CDL.java with 100% similarity]
unused/json/Cookie.java [moved from src/org/json/Cookie.java with 100% similarity]
unused/json/CookieList.java [moved from src/org/json/CookieList.java with 100% similarity]
unused/json/HTTP.java [moved from src/org/json/HTTP.java with 100% similarity]
unused/json/HTTPTokener.java [moved from src/org/json/HTTPTokener.java with 100% similarity]
unused/json/JSONArray.java [moved from src/org/json/JSONArray.java with 100% similarity]
unused/json/JSONException.java [moved from src/org/json/JSONException.java with 100% similarity]
unused/json/JSONML.java [moved from src/org/json/JSONML.java with 100% similarity]
unused/json/JSONObject.java [moved from src/org/json/JSONObject.java with 100% similarity]
unused/json/JSONPointer.java [moved from src/org/json/JSONPointer.java with 100% similarity]
unused/json/JSONPointerException.java [moved from src/org/json/JSONPointerException.java with 100% similarity]
unused/json/JSONPropertyIgnore.java [moved from src/org/json/JSONPropertyIgnore.java with 100% similarity]
unused/json/JSONPropertyName.java [moved from src/org/json/JSONPropertyName.java with 100% similarity]
unused/json/JSONString.java [moved from src/org/json/JSONString.java with 100% similarity]
unused/json/JSONStringer.java [moved from src/org/json/JSONStringer.java with 100% similarity]
unused/json/JSONTokener.java [moved from src/org/json/JSONTokener.java with 100% similarity]
unused/json/JSONWriter.java [moved from src/org/json/JSONWriter.java with 100% similarity]
unused/json/LICENSE [moved from src/org/json/LICENSE with 100% similarity]
unused/json/Property.java [moved from src/org/json/Property.java with 100% similarity]
unused/json/README.md [moved from src/org/json/README.md with 100% similarity]
unused/json/XML.java [moved from src/org/json/XML.java with 100% similarity]
unused/json/XMLTokener.java [moved from src/org/json/XMLTokener.java with 100% similarity]
unused/json/simple/ItemList.java [moved from src/org/json/simple/ItemList.java with 100% similarity]
unused/json/simple/JSONArray.java [moved from src/org/json/simple/JSONArray.java with 100% similarity]
unused/json/simple/JSONAware.java [moved from src/org/json/simple/JSONAware.java with 100% similarity]
unused/json/simple/JSONObject.java [moved from src/org/json/simple/JSONObject.java with 100% similarity]
unused/json/simple/JSONStreamAware.java [moved from src/org/json/simple/JSONStreamAware.java with 100% similarity]
unused/json/simple/JSONValue.java [moved from src/org/json/simple/JSONValue.java with 100% similarity]
unused/json/simple/README.txt [moved from src/org/json/simple/README.txt with 100% similarity]
unused/json/simple/parser/ContainerFactory.java [moved from src/org/json/simple/parser/ContainerFactory.java with 100% similarity]
unused/json/simple/parser/ContentHandler.java [moved from src/org/json/simple/parser/ContentHandler.java with 100% similarity]
unused/json/simple/parser/JSONParser.java [moved from src/org/json/simple/parser/JSONParser.java with 100% similarity]
unused/json/simple/parser/ParseException.java [moved from src/org/json/simple/parser/ParseException.java with 100% similarity]
unused/json/simple/parser/Yylex.java [moved from src/org/json/simple/parser/Yylex.java with 100% similarity]
unused/json/simple/parser/Yytoken.java [moved from src/org/json/simple/parser/Yytoken.java with 100% similarity]

index 7128ca4..5aff236 100755 (executable)
@@ -206,8 +206,6 @@ import org.apache.log4j.SimpleLayout;
  * panel in web service preferences</li>
  * </ul>
  * 
- * @author $author$
- * @version $Revision$
  */
 public class Cache implements ApplicationSingletonI
 {
@@ -628,29 +626,36 @@ public class Cache implements ApplicationSingletonI
   }
 
   /**
-   * These methods are used when checking if the saved preference is different
-   * to the default setting
+   * Returns the boolean property value for the given property name. If the
+   * value is absent then the default value is returned instead.
+   * 
+   * @param property
+   * @param def
+   * @return
    */
-
-  public static boolean getDefault(String property, boolean def)
+  public static boolean getDefault(String property, final boolean def)
   {
     String string = getProperty(property);
-    if (string != null)
-    {
-      def = Boolean.valueOf(string).booleanValue();
-    }
-
-    return def;
+    return string == null ? def : Boolean.parseBoolean(string);
   }
 
-  public static int getDefault(String property, int def)
+  /**
+   * Returns the integer property value for the given property name. If the
+   * value is absent, or malformed (not an integer), then the default value is
+   * returned instead.
+   * 
+   * @param property
+   * @param def
+   * @return
+   */
+  public static int getDefault(String property, final int def)
   {
     String string = getProperty(property);
     if (string != null)
     {
       try
       {
-        def = Integer.parseInt(string);
+        return Integer.parseInt(string);
       } catch (NumberFormatException e)
       {
         System.out.println("Error parsing int property '" + property
@@ -696,10 +701,14 @@ public class Cache implements ApplicationSingletonI
   }
 
   /**
-   * Answers the value of the given property, or the supplied default value if
+   * Returns the value of the given property, or the supplied default value if
    * the property is not set
+   * 
+   * @param property
+   * @param def
+   * @return
    */
-  public static String getDefault(String property, String def)
+  public static String getDefault(String property, final String def)
   {
     String value = getProperty(property);
     return value == null ? def : value;
@@ -720,11 +729,27 @@ public class Cache implements ApplicationSingletonI
     return getInstance().setPropertyImpl(key, obj, true);
   }
 
+  /**
+   * Sets a property value for the running application, without saving it to the
+   * properties file
+   * 
+   * @param key
+   * @param obj
+   */
   public static void setPropertyNoSave(String key, String obj)
   {
     getInstance().setPropertyImpl(key, obj, false);
   }
 
+  /**
+   * Sets a property value, and optionally also saves the current properties to
+   * file
+   * 
+   * @param key
+   * @param obj
+   * @param andSave
+   * @return
+   */
   private Object setPropertyImpl(String key, String obj, boolean andSave)
   {
     Object oldValue = null;
@@ -746,7 +771,7 @@ public class Cache implements ApplicationSingletonI
   }
 
   /**
-   * remove the specified property from the jalview properties file
+   * Removes the specified property from the jalview properties file
    * 
    * @param key
    */
@@ -755,11 +780,24 @@ public class Cache implements ApplicationSingletonI
     getInstance().removePropertyImpl(key, true);
   }
 
+  /**
+   * Removes the named property for the running application, without saving the
+   * properties file
+   * 
+   * @param key
+   */
   public static void removePropertyNoSave(String key)
   {
     getInstance().removePropertyImpl(key, false);
   }
 
+  /**
+   * Removes the named property, and optionally saves the current properties to
+   * file
+   * 
+   * @param key
+   * @param andSave
+   */
   private void removePropertyImpl(String key, boolean andSave)
   {
     applicationProperties.remove(key);
@@ -769,6 +807,9 @@ public class Cache implements ApplicationSingletonI
     }
   }
 
+  /**
+   * Saves the current properties to file
+   */
   public static void saveProperties()
   {
     getInstance().savePropertiesImpl();
@@ -1012,18 +1053,24 @@ public class Cache implements ApplicationSingletonI
   }
 
   /**
-   * get the user's default colour if available
+   * Returns the Color value of the given property's value, or the supplied
+   * default colour if no property is found, or it cannot be parsed to a colour.
+   * Colours are normally saved as hex rgb values, though other formats may be
+   * parseable.
    * 
    * @param property
-   * @param defcolour
+   * @param defaultColour
    * @return
+   * @see Cache#setColourPropertyNoSave(String, Color)
+   * @see ColorUtils#parseColourString(String)
    */
-  public static Color getDefaultColour(String property, Color defcolour)
+  public static Color getDefaultColour(String property,
+          final Color defaultColour)
   {
     String colprop = getProperty(property);
     if (colprop == null)
     {
-      return defcolour;
+      return defaultColour;
     }
     Color col = ColorUtils.parseColourString(colprop);
     if (col == null)
@@ -1031,22 +1078,24 @@ public class Cache implements ApplicationSingletonI
       log.warn("Couldn't parse '" + colprop + "' as a colour for "
               + property);
     }
-    return (col == null) ? defcolour : col;
+    return (col == null) ? defaultColour : col;
   }
 
   /**
-   * store a colour as a Jalview user default property
+   * Stores a colour as a Jalview property, converted to hex values for rgb.
+   * Properties are not saved to file.
    * 
    * @param property
    * @param colour
    */
-  public static void setColourProperty(String property, Color colour)
+  public static void setColourPropertyNoSave(String property, Color colour)
   {
-    setProperty(property, jalview.util.Format.getHexString(colour));
+    setPropertyNoSave(property, jalview.util.Format.getHexString(colour));
   }
 
   /**
    * Stores a formatted date in a jalview property, using a fixed locale.
+   * Updated properties are written out to the properties file.
    * 
    * @param propertyName
    * @param date
index 2f5d83b..72a074d 100644 (file)
@@ -842,7 +842,6 @@ public class AlignmentPanel extends GAlignmentPanel implements
     }
     if (updateOverview)
     {
-
       if (overviewPanel != null)
       {
         overviewPanel.updateOverviewImage();
index 5528e75..fbbd1ac 100644 (file)
@@ -314,7 +314,7 @@ public class ColourMenuHelper
     }
     else
     {
-      Cache.removePropertyNoSave(Preferences.USER_DEFINED_COLOURS);
+      Cache.removeProperty(Preferences.USER_DEFINED_COLOURS);
     }
   }
 }
index 1899bd3..8b12ca8 100644 (file)
@@ -1873,7 +1873,7 @@ public class Desktop extends GDesktop
           {
                try 
             {
-              new Jalview2XML().loadJalviewAlign(choice);
+              new Jalview2XML().loadJalviewAlign(selectedFile);
             } catch (OutOfMemoryError oom)
                {
                  new OOMWarning("Whilst loading project from " + choice, oom);
index f81ecce..ddadd6d 100644 (file)
@@ -379,7 +379,7 @@ public class FeatureSettings extends JPanel
                       javax.swing.event.InternalFrameEvent evt)
               {
                 fr.removePropertyChangeListener(change);
-              };
+              }
             });
     frame.setLayer(JLayeredPane.PALETTE_LAYER);
     inConstruction = false;
@@ -1148,26 +1148,38 @@ public class FeatureSettings extends JPanel
 
   }
 
-  public void updateFeatureRenderer(Object[][] data)
+  /**
+   * Update the priority order of features; only repaint if this changed the
+   * order of visible features. Any newly discovered feature types are set to
+   * visible. Returns true if repaint was requested, false if not.
+   * 
+   * @param data
+   * @return
+   */
+  public boolean updateFeatureRenderer(Object[][] data)
   {
-    updateFeatureRenderer(data, true);
+    return updateFeatureRenderer(data, true);
   }
 
   /**
    * Update the priority order of features; only repaint if this changed the
-   * order of visible features
+   * order of visible features. Returns true if repaint was requested, false if
+   * not.
    * 
    * @param data
    * @param visibleNew
+   * @return
    */
-  void updateFeatureRenderer(Object[][] data, boolean visibleNew)
+  boolean updateFeatureRenderer(Object[][] data, boolean visibleNew)
   {
     FeatureSettingsBean[] rowData = getTableAsBeans(data);
 
     if (fr.setFeaturePriority(rowData, visibleNew))
     {
       af.alignPanel.paintAlignment(true, true);
+      return true;
     }
+    return false;
   }
 
   /**
@@ -1272,10 +1284,7 @@ public class FeatureSettings extends JPanel
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        fr.setTransparency(originalTransparency);
-        fr.setFeatureFilters(originalFilters);
-        updateFeatureRenderer(originalData);
-        close();
+        cancel();
       }
     });
 
@@ -1358,6 +1367,27 @@ public class FeatureSettings extends JPanel
   }
 
   /**
+   * On Cancel, restore settings as they were when the dialog was opened (or
+   * possibly with any new features added while the dialog was open)
+   */
+  void cancel()
+  {
+    fr.setTransparency(originalTransparency);
+    fr.setFeatureFilters(originalFilters);
+    boolean repainted = updateFeatureRenderer(originalData);
+
+    /*
+     * ensure alignment (and Overview if visible) are redrawn
+     */
+    if (!repainted)
+    {
+      af.alignPanel.paintAlignment(true, true);
+    }
+
+    close();
+  }
+
+  /**
    * Answers a suitable tooltip to show on the colour cell of the table
    * 
    * @param fcol
index 62bdd35..67b748a 100644 (file)
@@ -188,7 +188,7 @@ public class LineartOptions extends JPanel
     }
     else
     {
-      Cache.removePropertyNoSave(preferencesKey);
+      Cache.removeProperty(preferencesKey);
     }
   }
 
index 777ab48..207fcb8 100755 (executable)
@@ -798,16 +798,17 @@ public class Preferences extends GPreferences
             protColour.getSelectedItem().toString());
     Cache.setPropertyNoSave(DEFAULT_COLOUR_NUC,
             nucColour.getSelectedItem().toString());
-    Cache.setColourProperty(ANNOTATIONCOLOUR_MIN,
+    Cache.setColourPropertyNoSave(ANNOTATIONCOLOUR_MIN,
             minColour.getBackground());
-    Cache.setColourProperty(ANNOTATIONCOLOUR_MAX,
+    Cache.setColourPropertyNoSave(ANNOTATIONCOLOUR_MAX,
             maxColour.getBackground());
 
     /*
      * Save Overview settings
      */
-    Cache.setColourProperty(GAP_COLOUR, gapColour.getBackground());
-    Cache.setColourProperty(HIDDEN_COLOUR, hiddenColour.getBackground());
+    Cache.setColourPropertyNoSave(GAP_COLOUR, gapColour.getBackground());
+    Cache.setColourPropertyNoSave(HIDDEN_COLOUR,
+            hiddenColour.getBackground());
     Cache.setPropertyNoSave(USE_LEGACY_GAP,
             Boolean.toString(useLegacyGap.isSelected()));
     Cache.setPropertyNoSave(SHOW_OV_HIDDEN_AT_START,
@@ -1045,7 +1046,8 @@ public class Preferences extends GPreferences
   }
 
   /**
-   * DOCUMENT ME!
+   * Opens a file browser, and if a file is chosen, sets its path as the text of
+   * the 'startup file' text field
    */
   @Override
   public void startupFileTextfield_mouseClicked()
@@ -1065,8 +1067,10 @@ public class Preferences extends GPreferences
       FileFormatI format = chooser.getSelectedFormat();
       if (format != null)
       {
-        Cache.setPropertyNoSave("DEFAULT_FILE_FORMAT",
-                format.getName());
+        /*
+         * saving properties to file is deferred to the 'OK' action
+         */
+        Cache.setPropertyNoSave("DEFAULT_FILE_FORMAT", format.getName());
       }
       startupFileTextfield
               .setText(chooser.getSelectedFile().getAbsolutePath());
index 8c29078..49d2c6c 100755 (executable)
@@ -158,9 +158,8 @@ public class AppletFormatAdapter
   {
 
     this.selectedFile = selectedFile;
-    // BH 2019.10.06 PDB.getSequenceRecords calling this and then needs string,
-    // below
     inFile = (selectedFile == null ? file : selectedFile.getPath());
+
     try
     {
       if (fileFormat.isStructureFile())
@@ -179,8 +178,6 @@ public class AppletFormatAdapter
         }
         else
         {
-          // BH: This block is executed by PDBSequenceFetcherTest
-
           // todo is mc_view parsing obsolete yet? JAL-2120
           StructureImportSettings.setShowSeqFeatures(true);
           alignFile = new mc_view.PDBfile(annotFromStructure,
index 82e89e5..9f966e2 100644 (file)
@@ -148,8 +148,14 @@ public class OverviewRenderer
 
   private BitSet bscol;
 
+  /*
+   * Overview width in pixels
+   */
   private final int w;
 
+  /*
+   * Overview height in pixels
+   */
   private final int h;
 
   public OverviewRenderer(AlignmentViewPanel panel,
@@ -277,7 +283,7 @@ public class OverviewRenderer
       columnsToShow = calcColumnsToShow();
     }
 
-    Platform.timeCheck(null, Platform.TIME_MARK);
+    // Platform.timeCheck(null, Platform.TIME_MARK);
   }
 
   private void nextRow()
@@ -470,13 +476,13 @@ public class OverviewRenderer
 
   private void done()
   {
-    if (!redraw)
-    {
-      Platform.timeCheck(
-              "overviewrender " + ndone + " pixels row:" + row + " redraw:"
-                      + redraw,
-              Platform.TIME_MARK);
-    }
+    // if (!redraw)
+    // {
+//      Platform.timeCheck(
+//              "overviewrender " + ndone + " pixels row:" + row + " redraw:"
+//                      + redraw,
+//              Platform.TIME_MARK);
+    // }
 
     overlayHiddenRegions();
     if (showProgress)
@@ -625,8 +631,6 @@ public class OverviewRenderer
         // get details of this alignment row
         if (rows.isHidden(alignmentRow))
         {
-          // BH 2019.09.24 fixes JAL-3440 Java+JavaScript off by one row in
-          // height
           g2d.fillRect(0, pixelRow, w, endRow - pixelRow);
         }
         pixelRow = endRow;
index ee40d83..57366b9 100644 (file)
@@ -99,10 +99,16 @@ public class FeatureColourFinder
     if (featureRenderer.getTransparency() != 1f)
     {
       g = goff;
-      if (defaultColour != null)
+      Color c = (defaultColour == null ? Color.white : defaultColour);
+      if (Platform.isJS())
       {
-        offscreenImage.setRGB(0, 0, defaultColour.getRGB());
+        // Clear the HTML5 canvas color.
+        // otherwise we get a smearing.
+        // For whatever reason, this is necessary BH 2019.10.01.
+        g.setColor(c);
+        g.fillRect(0, 0, 1, 1);
       }
+      offscreenImage.setRGB(0, 0, c.getRGB());
     }
 
     Color c = featureRenderer.findFeatureColour(seq, column + 1, g);
index 3eb080b..d465632 100644 (file)
@@ -29,9 +29,13 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Random;
 
+/**
+ * A class with utility methods for manipulating AWT colours/colors
+ */
 public class ColorUtils
 {
   private static final int MAX_CACHE_SIZE = 1729;
+
   /*
    * a cache for colours generated from text strings
    */
@@ -203,8 +207,8 @@ public class ColorUtils
    * Parses a string into a Color, where the accepted formats are
    * <ul>
    * <li>an AWT colour name e.g. white</li>
-   * <li>a hex colour value (without prefix) e.g. ff0000</li>
-   * <li>an rgb triple e.g. 100,50,150</li>
+   * <li>a six digit rgb hex colour value (without prefix) e.g. ff0000</li>
+   * <li>a comma-separated rgb triple e.g. 100,50,150</li>
    * </ul>
    * 
    * @param colour
@@ -219,18 +223,20 @@ public class ColorUtils
     colour = colour.trim();
 
     Color col = null;
-    try
-    {
-      int value = Integer.parseInt(colour, 16);
-      col = new Color(value);
-    } catch (NumberFormatException ex)
+    if (colour.length() == 6 && StringUtils.isHexString(colour))
     {
-      col = Platform.getColorFromName(colour);
+      try
+      {
+        int value = Integer.parseInt(colour, 16);
+        col = new Color(value);
+      } catch (NumberFormatException ex)
+      {
+      }
     }
 
     if (col == null)
     {
-      col = ColorUtils.getAWTColorFromName(colour);
+      col = ColorUtils.getColorFromName(colour);
     }
 
     if (col == null)
@@ -245,7 +251,7 @@ public class ColorUtils
           int b = Integer.parseInt(tokens[2].trim());
           col = new Color(r, g, b);
         }
-      } catch (Exception ex)
+      } catch (IllegalArgumentException ex)
       {
         // non-numeric token or out of 0-255 range
       }
@@ -313,15 +319,49 @@ public class ColorUtils
 
   /**
    * Returns the Color constant for a given colour name e.g. "pink", or null if
-   * the name is not recognised
+   * the name is not recognised. Currently recognises only AWT colour names, but
+   * could be extended to support others e.g. standard html colour names.
    * 
    * @param name
    * @return
    */
-  public static Color getAWTColorFromName(String name)
+  public static Color getColorFromName(String name)
   {
-    return Platform.getColorFromName(name); // BH 2019 -- allows for wide range
-                                            // of JavaScript colors (for
-                                            // JavaScript only)
+    if (name == null)
+    {
+      return null;
+    }
+    // or make a static map; or use reflection on the field name
+    switch (name.toLowerCase())
+    {
+    case "black":
+      return Color.black;
+    case "blue":
+      return Color.blue;
+    case "cyan":
+      return Color.cyan;
+    case "darkgray":
+      return Color.darkGray;
+    case "gray":
+      return Color.gray;
+    case "green":
+      return Color.green;
+    case "lightgray":
+      return Color.lightGray;
+    case "magenta":
+      return Color.magenta;
+    case "orange":
+      return Color.orange;
+    case "pink":
+      return Color.pink;
+    case "red":
+      return Color.red;
+    case "white":
+      return Color.white;
+    case "yellow":
+      return Color.yellow;
+    default:
+      return null;
+    }
   }
 }
index ce7ab6d..0f12eb8 100755 (executable)
@@ -29,10 +29,13 @@ package jalview.util;
 import java.util.Arrays;
 
 /**
- * DOCUMENT ME!
+ * A utility class that provides a variety of formatting methods.
  * 
- * @author $author$
- * @version $Revision$
+ * Principle method {@code format} formats the number following printf
+ * conventions. Main limitation: Can only handle one format parameter at a time
+ * Use multiple Format objects to format more than one number
+ * 
+ * @author unknown
  */
 public class Format
 {
@@ -59,12 +62,59 @@ public class Format
   private final String formatString;
 
   /**
-   * Creates a new Format object.
+   * Creates a new Format object given a format descriptor, which follows printf
+   * conventions The string has a prefix, a format code and a suffix. The prefix
+   * and suffix become part of the formatted output. The format code directs the
+   * formatting of the (single) parameter to be formatted. The code has the
+   * following structure
+   * <ul>
+   * <li>a % (required)
+   * <li>a modifier (optional)
+   * <dl>
+   * <dt>+
+   * <dd>forces display of + for positive numbers
+   * <dt>0
+   * <dd>show leading zeroes
+   * <dt>-
+   * <dd>align left in the field
+   * <dt>space
+   * <dd>prepend a space in front of positive numbers
+   * <dt>#
+   * <dd>use "alternate" format. Add 0 or 0x for octal or hexadecimal numbers.
+   * Don't suppress trailing zeroes in general floating point format.
+   * </dl>
+   * <li>an integer denoting field width (optional)
+   * <li>a period followed by an integer denoting precision (optional)
+   * <li>a format descriptor (required)
+   * <dl>
+   * <dt>f
+   * <dd>floating point number in fixed format
+   * <dt>e, E
+   * <dd>floating point number in exponential notation (scientific format). The
+   * E format results in an uppercase E for the exponent (1.14130E+003), the e
+   * format in a lowercase e.
+   * <dt>g, G
+   * <dd>floating point number in general format (fixed format for small
+   * numbers, exponential format for large numbers). Trailing zeroes are
+   * suppressed. The G format results in an uppercase E for the exponent (if
+   * any), the g format in a lowercase e.
+   * <dt>d, i
+   * <dd>integer in decimal
+   * <dt>x
+   * <dd>integer in hexadecimal
+   * <dt>o
+   * <dd>integer in octal
+   * <dt>s
+   * <dd>string
+   * <dt>c
+   * <dd>character
+   * </dl>
+   * </ul>
    * 
    * @param s
-   *          DOCUMENT ME!
+   *          the format descriptor
    */
-  public Format(String s)
+  public Format(final String s)
   {
     formatString = s;
     width = 0;
@@ -214,63 +264,11 @@ public class Format
   }
 
   /**
-   * Formats the number following printf conventions. Main limitation: Can only
-   * handle one format parameter at a time Use multiple Format objects to format
-   * more than one number
-   * 
-   * @param s
-   *          the format string following printf conventions The string has a
-   *          prefix, a format code and a suffix. The prefix and suffix become
-   *          part of the formatted output. The format code directs the
-   *          formatting of the (single) parameter to be formatted. The code has
-   *          the following structure
-   *          <ul>
-   *          <li>a % (required)
-   *          <li>a modifier (optional)
-   *          <dl>
-   *          <dt>+
-   *          <dd>forces display of + for positive numbers
-   *          <dt>0
-   *          <dd>show leading zeroes
-   *          <dt>-
-   *          <dd>align left in the field
-   *          <dt>space
-   *          <dd>prepend a space in front of positive numbers
-   *          <dt>#
-   *          <dd>use "alternate" format. Add 0 or 0x for octal or hexadecimal
-   *          numbers. Don't suppress trailing zeroes in general floating point
-   *          format.
-   *          </dl>
-   *          <li>an integer denoting field width (optional)
-   *          <li>a period followed by an integer denoting precision (optional)
-   *          <li>a format descriptor (required)
-   *          <dl>
-   *          <dt>f
-   *          <dd>floating point number in fixed format
-   *          <dt>e, E
-   *          <dd>floating point number in exponential notation (scientific
-   *          format). The E format results in an uppercase E for the exponent
-   *          (1.14130E+003), the e format in a lowercase e.
-   *          <dt>g, G
-   *          <dd>floating point number in general format (fixed format for
-   *          small numbers, exponential format for large numbers). Trailing
-   *          zeroes are suppressed. The G format results in an uppercase E for
-   *          the exponent (if any), the g format in a lowercase e.
-   *          <dt>d, i
-   *          <dd>integer in decimal
-   *          <dt>x
-   *          <dd>integer in hexadecimal
-   *          <dt>o
-   *          <dd>integer in octal
-   *          <dt>s
-   *          <dd>string
-   *          <dt>c
-   *          <dd>character
-   *          </dl>
-   *          </ul>
-   * @exception IllegalArgumentException
-   *              if bad format
+   * Returns a 6 character string consisting of the hex values of the colour's
+   * rgb values (left padded with zeroes if necessary)
    * 
+   * @param color
+   * @return
    */
   public static String getHexString(java.awt.Color color)
   {
index 11f7988..121ac1b 100644 (file)
@@ -720,57 +720,6 @@ public class Platform
   }
 
   /**
-   * @param c
-   */
-  public static Color getColorFromName(String name)
-  {
-    if (name == null)
-    {
-      return null;
-    }
-    /**
-     * @j2sNative
-     * 
-     *            return swingjs.JSUtil.getColorFromName$S(name);
-     */
-    {
-      // or make a static map; or use reflection on the field name
-      switch (name.toLowerCase())
-      {
-      case "black":
-        return Color.black;
-      case "blue":
-        return Color.blue;
-      case "cyan":
-        return Color.cyan;
-      case "darkgray":
-        return Color.darkGray;
-      case "gray":
-        return Color.gray;
-      case "green":
-        return Color.green;
-      case "lightgray":
-        return Color.lightGray;
-      case "magenta":
-        return Color.magenta;
-      case "orange":
-        return Color.orange;
-      case "pink":
-        return Color.pink;
-      case "red":
-        return Color.red;
-      case "white":
-        return Color.white;
-      case "yellow":
-        return Color.yellow;
-      default:
-        return null;
-      }
-
-    }
-  }
-
-  /**
    * Initialize Java debug logging. A representative sample -- adapt as desired.
    */
   public static void startJavaLogging()
index 2e8ace8..2cbbfbf 100644 (file)
@@ -146,7 +146,7 @@ public class StringUtils
     {
       return null;
     }
-    List<String> jv = new ArrayList<String>();
+    List<String> jv = new ArrayList<>();
     int cp = 0, pos, escape;
     boolean wasescaped = false, wasquoted = false;
     String lstitem = null;
@@ -444,4 +444,30 @@ public class StringUtils
     }
     return text;
   }
+
+  /**
+   * Answers true if the string is not empty and consists only of digits, or
+   * characters 'a'-'f' or 'A'-'F', else false
+   * 
+   * @param s
+   * @return
+   */
+  public static boolean isHexString(String s)
+  {
+    int j = s.length();
+    if (j == 0)
+    {
+      return false;
+    }
+    for (int i = 0; i < j; i++)
+    {
+      int c = s.charAt(i);
+      if (!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f')
+              && !(c >= 'A' && c <= 'F'))
+      {
+        return false;
+      }
+    }
+    return true;
+  }
 }
index 8dc7dd8..39d0098 100644 (file)
@@ -151,16 +151,31 @@ public abstract class OverviewDimensions
     return boxHeight;
   }
 
+  /**
+   * Returns the width of the Overview in pixels
+   * 
+   * @return
+   */
   public int getWidth()
   {
     return width;
   }
 
+  /**
+   * Returns the height of the Overview in pixels
+   * 
+   * @return
+   */
   public int getHeight()
   {
     return sequencesHeight + graphHeight;
   }
 
+  /**
+   * Returns the height of the sequence alignment in the Overview in pixels
+   * 
+   * @return
+   */
   public int getSequencesHeight()
   {
     return sequencesHeight;
index 95b1753..0cb1348 100644 (file)
@@ -1,3 +1,10 @@
 BH 2019.05.15
 
-Note that this version of VARNA is from VARNA-BH
+Note that this version of VARNA is from https://github.com/BobHanson/VARNA
+
+BH 2019.10.14
+
+Code is from https://github.com/BobHanson/VARNA and DOES have
+changes specific to SwingJS involving dialogs and file loading.
+
+The Varna jar file CANNOT be used directly via decompilation.
diff --git a/srcjar/intervalstore/README_SWINGJS.txt b/srcjar/intervalstore/README_SWINGJS.txt
new file mode 100644 (file)
index 0000000..243ad43
--- /dev/null
@@ -0,0 +1,5 @@
+BH 2019.10.14
+
+This directory contains all source in intervalstore-vx.x.jar.
+No changes are necessary for Jalview (meaning we could use 
+the jar file directly for SwingJS with automated decompilation).
\ No newline at end of file
index cec8076..793363e 100644 (file)
@@ -8,3 +8,9 @@ Status
 7/3/2018
 
 no changes necessary
+
+BH 2019.10.14 note:
+
+This directory contains all source in miglayout-4.0-swing.jar.
+No changes are necessary for Jalview (meaning we could use 
+the jar file directly for SwingJS with automated decompilation).
index fa4091f..08d77b6 100644 (file)
@@ -71,9 +71,6 @@ public class ColorUtilsTest
     assertNull(ColorUtils.brighterThan(null));
   }
 
-  /**
-   * @see http://www.rtapo.com/notes/named_colors.html
-   */
   @Test(groups = { "Functional" })
   public void testToTkCode()
   {
@@ -188,8 +185,9 @@ public class ColorUtilsTest
     // 'hex' prefixes _not_ wanted here
     assertNull(ColorUtils.parseColourString("0x" + hexColour));
     assertNull(ColorUtils.parseColourString("#" + hexColour));
-    // out of range, but Color constructor just or's the rgb value with 0
-    assertEquals(Color.black, ColorUtils.parseColourString("1000000"));
+    // hex values must be 6 hex digits
+    assertNull(ColorUtils.parseColourString("1000000"));
+    assertNull(ColorUtils.parseColourString("0ff00"));
 
     /*
      * by RGB triplet
@@ -206,7 +204,7 @@ public class ColorUtilsTest
      */
     assertNull(ColorUtils.parseColourString(null));
     assertNull(ColorUtils.parseColourString("rubbish"));
-    assertEquals(Color.WHITE, ColorUtils.parseColourString("-1"));
+    assertNull(ColorUtils.parseColourString("-1"));
     assertNull(ColorUtils.parseColourString(String
             .valueOf(Integer.MAX_VALUE)));
     assertNull(ColorUtils.parseColourString("100,200,300")); // out of range
@@ -216,13 +214,13 @@ public class ColorUtilsTest
 
   @Test(groups = "Functional")
   public void testGetAWTColorFromName() {
-    assertEquals(Color.white, ColorUtils.getAWTColorFromName("white"));
-    assertEquals(Color.white, ColorUtils.getAWTColorFromName("White"));
-    assertEquals(Color.white, ColorUtils.getAWTColorFromName("WHITE"));
-    assertEquals(Color.pink, ColorUtils.getAWTColorFromName("pink"));
-    assertNull(ColorUtils.getAWTColorFromName("mauve")); // no such name
-    assertNull(ColorUtils.getAWTColorFromName(""));
-    assertNull(ColorUtils.getAWTColorFromName(null));
+    assertEquals(Color.white, ColorUtils.getColorFromName("white"));
+    assertEquals(Color.white, ColorUtils.getColorFromName("White"));
+    assertEquals(Color.white, ColorUtils.getColorFromName("WHITE"));
+    assertEquals(Color.pink, ColorUtils.getColorFromName("pink"));
+    assertNull(ColorUtils.getColorFromName("mauve")); // no such name
+    assertNull(ColorUtils.getColorFromName(""));
+    assertNull(ColorUtils.getColorFromName(null));
   }
 
   @Test(groups = "Functional")
index 999e456..422132a 100644 (file)
@@ -25,6 +25,8 @@ import static org.testng.Assert.assertTrue;
 
 import jalview.gui.JvOptionPane;
 
+import java.awt.Color;
+
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
@@ -162,4 +164,20 @@ public class FormatTest
             + "ms");
     assertTrue(elapsed2 > elapsed1);
   }
+
+  @Test(groups = "Functional")
+  public void testGetHexString()
+  {
+    /*
+     * r = 13 = d base 16, gets padded to 0d
+     * g = 103 = (16x6) + 7 = 67 base 16
+     * b = 219 = (16x13) + 11 = db base 16
+     */
+    Color c = new Color(13, 103, 219);
+    assertEquals(Format.getHexString(c), "0d67db");
+
+    assertEquals(Format.getHexString(Color.black), "000000");
+
+    assertEquals(Format.getHexString(Color.white), "ffffff");
+  }
 }
index 084219a..0308f72 100644 (file)
 package jalview.util;
 
 import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
 import static org.testng.AssertJUnit.assertNull;
 import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.AssertJUnit.fail;
 
 import jalview.gui.JvOptionPane;
 
@@ -145,7 +147,7 @@ public class StringUtilsTest
   public void testListToDelimitedString()
   {
     assertEquals("", StringUtils.listToDelimitedString(null, ";"));
-    List<String> list = new ArrayList<String>();
+    List<String> list = new ArrayList<>();
     assertEquals("", StringUtils.listToDelimitedString(list, ";"));
     list.add("now");
     assertEquals("now", StringUtils.listToDelimitedString(list, ";"));
@@ -250,4 +252,20 @@ public class StringUtilsTest
     assertEquals("kdHydro &lt; 12.53",
             StringUtils.stripHtmlTags("kdHydro < 12.53"));
   }
+
+  @Test(groups = { "Functional" })
+  public void testIsHexString()
+  {
+    assertFalse(StringUtils.isHexString(""));
+    assertTrue(StringUtils.isHexString("0123456789abcdefABCDEF"));
+    assertFalse(StringUtils.isHexString("g"));
+    try
+    {
+      StringUtils.isHexString(null);
+      fail("expected exception");
+    } catch (NullPointerException e)
+    {
+      // expected
+    }
+  }
 }
similarity index 100%
rename from src/org/json/CDL.java
rename to unused/json/CDL.java
similarity index 100%
rename from src/org/json/HTTP.java
rename to unused/json/HTTP.java
similarity index 100%
rename from src/org/json/LICENSE
rename to unused/json/LICENSE
similarity index 100%
rename from src/org/json/README.md
rename to unused/json/README.md
similarity index 100%
rename from src/org/json/XML.java
rename to unused/json/XML.java