From fd78187d73394a2a6358ba8666ba409ee51b59d5 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Fri, 10 Jul 2015 06:16:36 +0100 Subject: [PATCH] JAL-1807 explicit imports (jalview.util) --- src/jalview/util/BrowserLauncher.java | 12 +++++++++--- src/jalview/util/DBRefUtils.java | 2 +- src/jalview/util/GroupUrlLink.java | 15 +++++++++------ src/jalview/util/ImageMaker.java | 22 ++++++++++++---------- src/jalview/util/UrlLink.java | 18 +++++++++--------- 5 files changed, 40 insertions(+), 29 deletions(-) diff --git a/src/jalview/util/BrowserLauncher.java b/src/jalview/util/BrowserLauncher.java index cd9c969..55343c1 100755 --- a/src/jalview/util/BrowserLauncher.java +++ b/src/jalview/util/BrowserLauncher.java @@ -20,8 +20,14 @@ */ package jalview.util; -import java.io.*; -import java.lang.reflect.*; +import jalview.bin.Cache; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; /** * BrowserLauncher is a class that provides one static method, openURL, which @@ -673,7 +679,7 @@ public class BrowserLauncher case OTHER: default: - browser = jalview.bin.Cache.getDefault("DEFAULT_BROWSER", "firefox"); + browser = Cache.getDefault("DEFAULT_BROWSER", "firefox"); break; } diff --git a/src/jalview/util/DBRefUtils.java b/src/jalview/util/DBRefUtils.java index 123a4e1..0349ff2 100755 --- a/src/jalview/util/DBRefUtils.java +++ b/src/jalview/util/DBRefUtils.java @@ -430,7 +430,7 @@ public class DBRefUtils * Check for PFAM style stockhom PDB accession id citation e.g. * "1WRI A; 7-80;" */ - Regex r = new com.stevesoft.pat.Regex( + Regex r = new Regex( "([0-9][0-9A-Za-z]{3})\\s*(.?)\\s*;\\s*([0-9]+)-([0-9]+)"); if (r.search(acn.trim())) { diff --git a/src/jalview/util/GroupUrlLink.java b/src/jalview/util/GroupUrlLink.java index 6665f51..026e289 100644 --- a/src/jalview/util/GroupUrlLink.java +++ b/src/jalview/util/GroupUrlLink.java @@ -24,7 +24,8 @@ import jalview.datamodel.Sequence; import jalview.datamodel.SequenceI; import java.util.Hashtable; -import java.util.Vector; + +import com.stevesoft.pat.Regex; public class GroupUrlLink { @@ -150,7 +151,7 @@ public class GroupUrlLink } ptok[ntoks] = link.length(); tmtch[ntoks] = "$$$$$$$$$"; - jalview.util.QuickSort.sortInt(ptok, tmtch); + QuickSort.sortInt(ptok, tmtch); for (int i = 0; i < ntoks; i++) { mtch[i] = tmtch[i]; // TODO: check order is ascending @@ -217,7 +218,7 @@ public class GroupUrlLink regexReplace[pass] = link.substring(ptok[pass] + mlength, p); try { - com.stevesoft.pat.Regex rg = com.stevesoft.pat.Regex.perlCode("/" + Regex rg = Regex.perlCode("/" + regexReplace[pass] + "/"); if (rg == null) { @@ -320,10 +321,12 @@ public class GroupUrlLink private String _replaceFor(String token) { for (int i = 0; i < mtch.length; i++) + { if (segs[i] > -1 && mtch[i].equals(token)) { return regexReplace[i]; } + } return null; } @@ -499,13 +502,13 @@ public class GroupUrlLink // iterate through input, collating segments to be inserted into url StringBuffer matched[] = new StringBuffer[idseq.length]; // and precompile regexes - com.stevesoft.pat.Regex[] rgxs = new com.stevesoft.pat.Regex[matched.length]; + Regex[] rgxs = new Regex[matched.length]; for (pass = 0; pass < matched.length; pass++) { matched[pass] = new StringBuffer(); if (regexReplace[pass] != null) { - rgxs[pass] = com.stevesoft.pat.Regex.perlCode("/" + rgxs[pass] = Regex.perlCode("/" + regexReplace[pass] + "/"); } else @@ -544,7 +547,7 @@ public class GroupUrlLink } if (rgxs[pass] != null) { - com.stevesoft.pat.Regex rg = rgxs[pass]; + Regex rg = rgxs[pass]; int rematchat = 0; // concatenate all matches of re in the given string! while (rg.searchFrom(idseq[pass][sq], rematchat)) diff --git a/src/jalview/util/ImageMaker.java b/src/jalview/util/ImageMaker.java index 8abe965..e32dfee 100755 --- a/src/jalview/util/ImageMaker.java +++ b/src/jalview/util/ImageMaker.java @@ -20,10 +20,12 @@ */ package jalview.util; +import jalview.bin.Cache; import jalview.bin.Jalview; import jalview.gui.EPSOptions; import jalview.gui.SVGOptions; import jalview.io.JalviewFileChooser; +import jalview.io.JalviewFileView; import java.awt.Component; import java.awt.Graphics; @@ -99,14 +101,14 @@ public class ImageMaker { JalviewFileChooser chooser; chooser = type.getChooser(); - chooser.setFileView(new jalview.io.JalviewFileView()); + chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle(title); chooser.setToolTipText(MessageManager.getString("action.save")); int value = chooser.showSaveDialog(parent); - if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION) + if (value == JalviewFileChooser.APPROVE_OPTION) { - jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser + Cache.setProperty("LAST_DIRECTORY", chooser .getSelectedFile().getParent()); file = chooser.getSelectedFile(); } @@ -177,7 +179,7 @@ public class ImageMaker { boolean accurateText = true; - String renderStyle = jalview.bin.Cache.getDefault("EPS_RENDERING", + String renderStyle = Cache.getDefault("EPS_RENDERING", "Prompt each time"); // If we need to prompt, and if the GUI is visible then @@ -231,7 +233,7 @@ public class ImageMaker g2 = new SVGGraphics2D(width, height); Graphics2D ig2 = g2; - String renderStyle = jalview.bin.Cache.getDefault("SVG_RENDERING", + String renderStyle = Cache.getDefault("SVG_RENDERING", "Prompt each time"); // If we need to prompt, and if the GUI is visible then @@ -265,7 +267,7 @@ public class ImageMaker return null; } return new jalview.io.JalviewFileChooser( - jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] + Cache.getProperty("LAST_DIRECTORY"), new String[] { "png" }, new String[] { "Portable network graphics" }, "Portable network graphics"); } @@ -276,8 +278,8 @@ public class ImageMaker { return null; } - return new jalview.io.JalviewFileChooser( - jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] + return new JalviewFileChooser( + Cache.getProperty("LAST_DIRECTORY"), new String[] { "eps" }, new String[] { "Encapsulated Postscript" }, "Encapsulated Postscript"); } @@ -288,8 +290,8 @@ public class ImageMaker { return null; } - return new jalview.io.JalviewFileChooser( - jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] + return new JalviewFileChooser( + Cache.getProperty("LAST_DIRECTORY"), new String[] { "svg" }, new String[] { "Scalable Vector Graphics" }, "Scalable Vector Graphics"); } diff --git a/src/jalview/util/UrlLink.java b/src/jalview/util/UrlLink.java index 3f72ab4..c0cf821 100644 --- a/src/jalview/util/UrlLink.java +++ b/src/jalview/util/UrlLink.java @@ -22,16 +22,17 @@ package jalview.util; import java.util.Vector; +import com.stevesoft.pat.Regex; + public class UrlLink { /** * helper class to parse URL Link strings taken from applet parameters or - * jalview properties file using the com.stevesoft.pat.Regex implementation. - * Jalview 2.4 extension allows regular expressions to be used to parse ID - * strings and replace the result in the URL. Regex's operate on the whole ID - * string given to the matchURL method, if no regex is supplied, then only - * text following the first pipe symbol will be susbstituted. Usage - * documentation todo. + * jalview properties file using the Regex implementation. Jalview 2.4 + * extension allows regular expressions to be used to parse ID strings and + * replace the result in the URL. Regex's operate on the whole ID string given + * to the matchURL method, if no regex is supplied, then only text following + * the first pipe symbol will be susbstituted. Usage documentation todo. */ private String url_suffix, url_prefix, target, label, regexReplace; @@ -85,7 +86,7 @@ public class UrlLink regexReplace = link.substring(psqid + 14, p); try { - com.stevesoft.pat.Regex rg = com.stevesoft.pat.Regex.perlCode("/" + Regex rg = Regex.perlCode("/" + regexReplace + "/"); if (rg == null) { @@ -200,8 +201,7 @@ public class UrlLink { if (regexReplace != null) { - com.stevesoft.pat.Regex rg = com.stevesoft.pat.Regex.perlCode("/" - + regexReplace + "/"); + Regex rg = Regex.perlCode("/" + regexReplace + "/"); if (rg.search(idstring)) { int ns = rg.numSubs(); -- 1.7.10.2