From: Ben Soares Date: Wed, 8 Jul 2020 16:01:32 +0000 (+0100) Subject: JAL-3633 ensure check both http:// or https:// for urls X-Git-Tag: Release_2_11_1_2~6 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=aada6c7d3345363bf8b889f960c6209e7bbe8c06;p=jalview.git JAL-3633 ensure check both or https:// for urls --- diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 1e292ba..eaa5fa8 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -20,28 +20,6 @@ */ package jalview.bin; -import jalview.ext.so.SequenceOntology; -import jalview.gui.AlignFrame; -import jalview.gui.Desktop; -import jalview.gui.PromptUserConfig; -import jalview.io.AppletFormatAdapter; -import jalview.io.BioJsHTMLOutput; -import jalview.io.DataSourceType; -import jalview.io.FileFormat; -import jalview.io.FileFormatException; -import jalview.io.FileFormatI; -import jalview.io.FileFormats; -import jalview.io.FileLoader; -import jalview.io.HtmlSvgOutput; -import jalview.io.IdentifyFile; -import jalview.io.NewickFile; -import jalview.io.gff.SequenceOntologyFactory; -import jalview.schemes.ColourSchemeI; -import jalview.schemes.ColourSchemeProperty; -import jalview.util.MessageManager; -import jalview.util.Platform; -import jalview.ws.jws2.Jws2Discoverer; - import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; @@ -79,6 +57,7 @@ import jalview.io.DataSourceType; import jalview.io.FileFormat; import jalview.io.FileFormatException; import jalview.io.FileFormatI; +import jalview.io.FileFormats; import jalview.io.FileLoader; import jalview.io.HtmlSvgOutput; import jalview.io.IdentifyFile; @@ -451,10 +430,8 @@ public class Jalview } System.out.println("CMD [-open " + file + "] executed successfully!"); - - protocol = AppletFormatAdapter.checkProtocol(file); - + if (protocol == DataSourceType.FILE) { if (!(new File(file)).exists()) @@ -650,11 +627,14 @@ public class Jalview af.createEPS(outputFile); continue; } - FileFormatI outFormat=null; - try { + FileFormatI outFormat = null; + try + { outFormat = FileFormats.getInstance().forName(outputFormat); - } catch (Exception formatP) { - System.out.println("Couldn't parse "+outFormat+" as a valid Jalview format string."); + } catch (Exception formatP) + { + System.out.println("Couldn't parse " + outFormat + + " as a valid Jalview format string."); } if (outFormat != null) { @@ -698,8 +678,8 @@ public class Jalview jalview.bin.Cache.getDefault("www.jalview.org", "https://www.jalview.org") + "/examples/exampleFile_2_7.jvp"); - if (file.equals( - "http://www.jalview.org/examples/exampleFile_2_3.jar") || file.equals( + if (file.equals("http://www.jalview.org/examples/exampleFile_2_3.jar") + || file.equals( "http://www.jalview.org/examples/exampleFile_2_7.jar")) { file.replace("http:", "https:"); diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 4be7d0e..b1efed6 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -138,6 +138,7 @@ import jalview.schemes.ColourSchemeI; import jalview.schemes.ColourSchemes; import jalview.schemes.ResidueColourScheme; import jalview.schemes.TCoffeeColourScheme; +import jalview.util.HttpUtils; import jalview.util.MessageManager; import jalview.util.Platform; import jalview.viewmodel.AlignmentViewport; @@ -1037,7 +1038,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, Desktop.instance.closeAssociatedWindows(); FileLoader loader = new FileLoader(); - DataSourceType protocol = fileName.startsWith("http:") + DataSourceType protocol = HttpUtils.startsWithHttpOrHttps(fileName) ? DataSourceType.URL : DataSourceType.FILE; loader.LoadFile(viewport, fileName, protocol, currentFileFormat); @@ -1047,7 +1048,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, Rectangle bounds = this.getBounds(); FileLoader loader = new FileLoader(); - DataSourceType protocol = fileName.startsWith("http:") + DataSourceType protocol = HttpUtils.startsWithHttpOrHttps(fileName) ? DataSourceType.URL : DataSourceType.FILE; AlignFrame newframe = loader.LoadFileWaitTillLoaded(fileName, @@ -1094,7 +1095,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, public void save_actionPerformed(ActionEvent e) { if (fileName == null || (currentFileFormat == null) - || fileName.startsWith("http")) + || HttpUtils.startsWithHttpOrHttps(fileName)) { saveAs_actionPerformed(null); } @@ -1749,7 +1750,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } /** - * Calls AlignmentI.moveSelectedSequencesByOne with current sequence selection or the sequence under cursor in keyboard mode + * Calls AlignmentI.moveSelectedSequencesByOne with current sequence selection + * or the sequence under cursor in keyboard mode * * @param up * or down (if !up) @@ -1760,23 +1762,25 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, if (sg == null) { - if (viewport.cursorMode) + if (viewport.cursorMode) { sg = new SequenceGroup(); - sg.addSequence(viewport.getAlignment() - .getSequenceAt(alignPanel.getSeqPanel().seqCanvas.cursorY),false); - } else { + sg.addSequence(viewport.getAlignment().getSequenceAt( + alignPanel.getSeqPanel().seqCanvas.cursorY), false); + } + else + { return; } } - + if (sg.getSize() < 1) { - return; + return; } - + // TODO: JAL-3733 - add an event to the undo buffer for this ! - + viewport.getAlignment().moveSelectedSequencesByOne(sg, viewport.getHiddenRepSequences(), up); alignPanel.paintAlignment(true, false); diff --git a/src/jalview/project/Jalview2XML.java b/src/jalview/project/Jalview2XML.java index ca0423b..0e062ac 100644 --- a/src/jalview/project/Jalview2XML.java +++ b/src/jalview/project/Jalview2XML.java @@ -24,6 +24,54 @@ import static jalview.math.RotatableMatrix.Axis.X; import static jalview.math.RotatableMatrix.Axis.Y; import static jalview.math.RotatableMatrix.Axis.Z; +import java.awt.Color; +import java.awt.Font; +import java.awt.Rectangle; +import java.io.BufferedReader; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.lang.reflect.InvocationTargetException; +import java.math.BigInteger; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Enumeration; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.IdentityHashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.Vector; +import java.util.jar.JarEntry; +import java.util.jar.JarInputStream; +import java.util.jar.JarOutputStream; + +import javax.swing.JInternalFrame; +import javax.swing.SwingUtilities; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.Marshaller; +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamReader; + import jalview.analysis.Conservation; import jalview.analysis.PCA; import jalview.analysis.scoremodels.ScoreModels; @@ -85,6 +133,7 @@ import jalview.schemes.UserColourScheme; import jalview.structure.StructureSelectionManager; import jalview.structures.models.AAStructureBindingModel; import jalview.util.Format; +import jalview.util.HttpUtils; import jalview.util.MessageManager; import jalview.util.Platform; import jalview.util.StringUtils; @@ -150,54 +199,6 @@ import jalview.xml.binding.jalview.SequenceSet.SequenceSetProperties; import jalview.xml.binding.jalview.ThresholdType; import jalview.xml.binding.jalview.VAMSAS; -import java.awt.Color; -import java.awt.Font; -import java.awt.Rectangle; -import java.io.BufferedReader; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.lang.reflect.InvocationTargetException; -import java.math.BigInteger; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Enumeration; -import java.util.GregorianCalendar; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.IdentityHashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.Vector; -import java.util.jar.JarEntry; -import java.util.jar.JarInputStream; -import java.util.jar.JarOutputStream; - -import javax.swing.JInternalFrame; -import javax.swing.SwingUtilities; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.Marshaller; -import javax.xml.datatype.DatatypeConfigurationException; -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamReader; - /** * Write out the current jalview desktop state as a Jalview XML stream. * @@ -946,7 +947,7 @@ public class Jalview2XML else { vamsasSeq = createVamsasSequence(id, jds); -// vamsasSet.addSequence(vamsasSeq); + // vamsasSet.addSequence(vamsasSeq); vamsasSet.getSequence().add(vamsasSeq); vamsasSetIds.put(id, vamsasSeq); seqRefIds.put(id, jds); @@ -1339,9 +1340,8 @@ public class Jalview2XML if (colourScheme instanceof jalview.schemes.UserColourScheme) { - jGroup.setColour( - setUserColourScheme(colourScheme, userColours, - object)); + jGroup.setColour(setUserColourScheme(colourScheme, + userColours, object)); } else { @@ -1387,7 +1387,7 @@ public class Jalview2XML } } - //jms.setJGroup(groups); + // jms.setJGroup(groups); Object group; for (JGroup grp : groups) { @@ -1524,11 +1524,13 @@ public class Jalview2XML * save any filter for the feature type */ FeatureMatcherSetI filter = fr.getFeatureFilter(featureType); - if (filter != null) { - Iterator filters = filter.getMatchers().iterator(); + if (filter != null) + { + Iterator filters = filter.getMatchers() + .iterator(); FeatureMatcherI firstFilter = filters.next(); - setting.setMatcherSet(Jalview2XML.marshalFilter( - firstFilter, filters, filter.isAnded())); + setting.setMatcherSet(Jalview2XML.marshalFilter(firstFilter, + filters, filter.isAnded())); } /* @@ -1577,8 +1579,7 @@ public class Jalview2XML setting.setDisplay( av.getFeaturesDisplayed().isVisible(featureType)); - float rorder = fr - .getOrder(featureType); + float rorder = fr.getOrder(featureType); if (rorder > -1) { setting.setOrder(rorder); @@ -1602,7 +1603,7 @@ public class Jalview2XML Group g = new Group(); g.setName(grp); g.setDisplay(((Boolean) fr.checkGroupVisibility(grp, false)) - .booleanValue()); + .booleanValue()); // fs.addGroup(g); fs.getGroup().add(g); groupsAdded.addElement(grp); @@ -2368,7 +2369,8 @@ public class Jalview2XML { if (calcIdParam.getVersion().equals("1.0")) { - final String[] calcIds = calcIdParam.getServiceURL().toArray(new String[0]); + final String[] calcIds = calcIdParam.getServiceURL() + .toArray(new String[0]); Jws2Instance service = Jws2Discoverer.getDiscoverer() .getPreferredServiceFor(calcIds); if (service != null) @@ -2654,12 +2656,12 @@ public class Jalview2XML return id; } - jalview.schemes.UserColourScheme getUserColourScheme( - JalviewModel jm, String id) + jalview.schemes.UserColourScheme getUserColourScheme(JalviewModel jm, + String id) { List uc = jm.getUserColours(); UserColours colours = null; -/* + /* for (int i = 0; i < uc.length; i++) { if (uc[i].getId().equals(id)) @@ -2668,7 +2670,7 @@ public class Jalview2XML break; } } -*/ + */ for (UserColours c : uc) { if (c.getId().equals(id)) @@ -2696,10 +2698,9 @@ public class Jalview2XML newColours = new java.awt.Color[23]; for (int i = 0; i < 23; i++) { - newColours[i] = new java.awt.Color(Integer.parseInt( - colours.getUserColourScheme().getColour().get(i + 24) - .getRGB(), - 16)); + newColours[i] = new java.awt.Color( + Integer.parseInt(colours.getUserColourScheme().getColour() + .get(i + 24).getRGB(), 16)); } ucs.setLowerCaseColours(newColours); } @@ -2778,7 +2779,7 @@ public class Jalview2XML viewportsAdded.clear(); frefedSequence = null; - if (file.startsWith("http://")) + if (HttpUtils.startsWithHttpOrHttps(file)) { url = new URL(file); } @@ -2855,8 +2856,8 @@ public class Jalview2XML XMLStreamReader streamReader = XMLInputFactory.newInstance() .createXMLStreamReader(jin); javax.xml.bind.Unmarshaller um = jc.createUnmarshaller(); - JAXBElement jbe = um - .unmarshal(streamReader, JalviewModel.class); + JAXBElement jbe = um.unmarshal(streamReader, + JalviewModel.class); JalviewModel object = jbe.getValue(); /* @@ -3276,7 +3277,8 @@ public class Jalview2XML AlignFrame loadFromObject(JalviewModel jalviewModel, String file, boolean loadTreesAndStructures, jarInputStreamProvider jprovider) { - SequenceSet vamsasSet = jalviewModel.getVamsasModel().getSequenceSet().get(0); + SequenceSet vamsasSet = jalviewModel.getVamsasModel().getSequenceSet() + .get(0); List vamsasSeqs = vamsasSet.getSequence(); // JalviewModelSequence jms = object.getJalviewModelSequence(); @@ -3335,11 +3337,10 @@ public class Jalview2XML if (tmpSeq.getStart() != jseq.getStart() || tmpSeq.getEnd() != jseq.getEnd()) { - System.err.println( - String.format("Warning JAL-2154 regression: updating start/end for sequence %s from %d/%d to %d/%d", - tmpSeq.getName(), tmpSeq.getStart(), - tmpSeq.getEnd(), jseq.getStart(), - jseq.getEnd())); + System.err.println(String.format( + "Warning JAL-2154 regression: updating start/end for sequence %s from %d/%d to %d/%d", + tmpSeq.getName(), tmpSeq.getStart(), tmpSeq.getEnd(), + jseq.getStart(), jseq.getEnd())); } } else @@ -3622,8 +3623,8 @@ public class Jalview2XML else { // defer to later - frefedSequence.add( - newAlcodMapRef(map.getDnasq(), cf, mapping)); + frefedSequence + .add(newAlcodMapRef(map.getDnasq(), cf, mapping)); } } } @@ -3831,8 +3832,7 @@ public class Jalview2XML jaa.setCalcId(annotation.getCalcId()); if (annotation.getProperty().size() > 0) { - for (Annotation.Property prop : annotation - .getProperty()) + for (Annotation.Property prop : annotation.getProperty()) { jaa.setProperty(prop.getName(), prop.getValue()); } @@ -3913,9 +3913,9 @@ public class Jalview2XML sg.setShowNonconserved(safeBoolean(jGroup.isShowUnconserved())); sg.thresholdTextColour = safeInt(jGroup.getTextColThreshold()); // attributes with a default in the schema are never null - sg.setShowConsensusHistogram(jGroup.isShowConsensusHistogram()); - sg.setshowSequenceLogo(jGroup.isShowSequenceLogo()); - sg.setNormaliseSequenceLogo(jGroup.isNormaliseSequenceLogo()); + sg.setShowConsensusHistogram(jGroup.isShowConsensusHistogram()); + sg.setshowSequenceLogo(jGroup.isShowSequenceLogo()); + sg.setNormaliseSequenceLogo(jGroup.isNormaliseSequenceLogo()); sg.setIgnoreGapsConsensus(jGroup.isIgnoreGapsinConsensus()); if (jGroup.getConsThreshold() != null && jGroup.getConsThreshold().intValue() != 0) @@ -3959,8 +3959,9 @@ public class Jalview2XML if (addAnnotSchemeGroup) { // reconstruct the annotation colourscheme - sg.setColourScheme(constructAnnotationColour( - jGroup.getAnnotationColours(), null, al, jalviewModel, false)); + sg.setColourScheme( + constructAnnotationColour(jGroup.getAnnotationColours(), + null, al, jalviewModel, false)); } } } @@ -4166,8 +4167,8 @@ public class Jalview2XML * @param av * @param ap */ - protected void loadTrees(JalviewModel jm, Viewport view, - AlignFrame af, AlignViewport av, AlignmentPanel ap) + protected void loadTrees(JalviewModel jm, Viewport view, AlignFrame af, + AlignViewport av, AlignmentPanel ap) { // TODO result of automated refactoring - are all these parameters needed? try @@ -4275,8 +4276,8 @@ public class Jalview2XML for (int s = 0; s < structureStateCount; s++) { // check to see if we haven't already created this structure view - final StructureState structureState = pdbid - .getStructureState().get(s); + final StructureState structureState = pdbid.getStructureState() + .get(s); String sviewid = (structureState.getViewId() == null) ? null : structureState.getViewId() + uniqueSetSuffix; jalview.datamodel.PDBEntry jpdb = new jalview.datamodel.PDBEntry(); @@ -4339,8 +4340,8 @@ public class Jalview2XML colourByViewer &= structureState.isColourByJmol(); jmoldat.setColourByViewer(colourByViewer); - if (jmoldat.getStateData().length() < structureState - .getValue()/*Content()*/.length()) + if (jmoldat.getStateData().length() < structureState.getValue() + /*Content()*/.length()) { jmoldat.setStateData(structureState.getValue());// Content()); } @@ -4535,7 +4536,8 @@ public class Jalview2XML String reformatedOldFilename = oldfilenam.replaceAll("/", "\\\\"); filedat = oldFiles.get(new File(reformatedOldFilename)); } - newFileLoc.append(Platform.escapeBackslashes(filedat.getFilePath())); + newFileLoc + .append(Platform.escapeBackslashes(filedat.getFilePath())); pdbfilenames.add(filedat.getFilePath()); pdbids.add(filedat.getPdbId()); seqmaps.add(filedat.getSeqList().toArray(new SequenceI[0])); @@ -4848,9 +4850,9 @@ public class Jalview2XML } AlignFrame loadViewport(String file, List JSEQ, - List hiddenSeqs, AlignmentI al, - JalviewModel jm, Viewport view, String uniqueSeqSetId, - String viewId, List autoAlan) + List hiddenSeqs, AlignmentI al, JalviewModel jm, + Viewport view, String uniqueSeqSetId, String viewId, + List autoAlan) { AlignFrame af = null; af = new AlignFrame(al, safeInt(view.getWidth()), @@ -4931,9 +4933,8 @@ public class Jalview2XML viewport.setColourText(safeBoolean(view.isShowColourText())); - viewport - .setConservationSelected( - safeBoolean(view.isConservationSelected())); + viewport.setConservationSelected( + safeBoolean(view.isConservationSelected())); viewport.setIncrement(safeInt(view.getConsThreshold())); viewport.setShowJVSuffix(safeBoolean(view.isShowFullId())); viewport.setRightAlignIds(safeBoolean(view.isRightAlignIds())); @@ -5009,9 +5010,8 @@ public class Jalview2XML af.changeColour(cs); viewport.setColourAppliesToAllGroups(true); - viewport - .setShowSequenceFeatures( - safeBoolean(view.isShowSequenceFeatures())); + viewport.setShowSequenceFeatures( + safeBoolean(view.isShowSequenceFeatures())); viewport.setCentreColumnLabels(view.isCentreColumnLabels()); viewport.setIgnoreGapsConsensus(view.isIgnoreGapsinConsensus(), null); @@ -5035,13 +5035,13 @@ public class Jalview2XML .getFeatureRenderer(); FeaturesDisplayed fdi; viewport.setFeaturesDisplayed(fdi = new FeaturesDisplayed()); - String[] renderOrder = new String[jm.getFeatureSettings() - .getSetting().size()]; + String[] renderOrder = new String[jm.getFeatureSettings().getSetting() + .size()]; Map featureColours = new Hashtable<>(); Map featureOrder = new Hashtable<>(); - for (int fs = 0; fs < jm.getFeatureSettings() - .getSetting().size(); fs++) + for (int fs = 0; fs < jm.getFeatureSettings().getSetting() + .size(); fs++) { Setting setting = jm.getFeatureSettings().getSetting().get(fs); String featureType = setting.getType(); @@ -5053,8 +5053,8 @@ public class Jalview2XML .getMatcherSet(); if (filters != null) { - FeatureMatcherSetI filter = Jalview2XML - .parseFilter(featureType, filters); + FeatureMatcherSetI filter = Jalview2XML.parseFilter(featureType, + filters); if (!filter.isEmpty()) { fr.setFeatureFilter(featureType, filter); @@ -5086,8 +5086,7 @@ public class Jalview2XML float max = setting.getMax() == null ? 1f : setting.getMax().floatValue(); FeatureColourI gc = new FeatureColour(maxColour, minColour, - maxColour, - noValueColour, min, max); + maxColour, noValueColour, min, max); if (setting.getAttributeName().size() > 0) { gc.setAttributeName(setting.getAttributeName().toArray( @@ -5121,8 +5120,7 @@ public class Jalview2XML } else { - featureColours.put(featureType, - new FeatureColour(maxColour)); + featureColours.put(featureType, new FeatureColour(maxColour)); } renderOrder[fs] = featureType; if (setting.getOrder() != null) @@ -5595,6 +5593,7 @@ public class Jalview2XML } } } + /** * * @param vamsasSeq @@ -6341,8 +6340,8 @@ public class Jalview2XML * @param fcol * @return */ - public static Colour marshalColour( - String featureType, FeatureColourI fcol) + public static Colour marshalColour(String featureType, + FeatureColourI fcol) { Colour col = new Colour(); if (fcol.isSimpleColour()) @@ -6403,7 +6402,7 @@ public class Jalview2XML boolean and) { jalview.xml.binding.jalview.FeatureMatcherSet result = new jalview.xml.binding.jalview.FeatureMatcherSet(); - + if (filters.hasNext()) { /* @@ -6453,7 +6452,7 @@ public class Jalview2XML } result.setMatchCondition(matcherModel); } - + return result; } @@ -6464,8 +6463,7 @@ public class Jalview2XML * @param matcherSetModel * @return */ - public static FeatureMatcherSetI parseFilter( - String featureType, + public static FeatureMatcherSetI parseFilter(String featureType, jalview.xml.binding.jalview.FeatureMatcherSet matcherSetModel) { FeatureMatcherSetI result = new FeatureMatcherSet(); @@ -6480,7 +6478,7 @@ public class Jalview2XML featureType, e.getMessage())); // return as much as was parsed up to the error } - + return result; } @@ -6495,8 +6493,7 @@ public class Jalview2XML * @throws IllegalStateException * if AND and OR conditions are mixed */ - protected static void parseFilterConditions( - FeatureMatcherSetI matcherSet, + protected static void parseFilterConditions(FeatureMatcherSetI matcherSet, jalview.xml.binding.jalview.FeatureMatcherSet matcherSetModel, boolean and) { @@ -6518,7 +6515,7 @@ public class Jalview2XML else if (filterBy == FilterBy.BY_SCORE) { matchCondition = FeatureMatcher.byScore(cond, pattern); - + } else if (filterBy == FilterBy.BY_ATTRIBUTE) { @@ -6528,7 +6525,7 @@ public class Jalview2XML matchCondition = FeatureMatcher.byAttribute(cond, pattern, attNames); } - + /* * note this throws IllegalStateException if AND-ing to a * previously OR-ed compound condition, or vice versa @@ -6571,13 +6568,13 @@ public class Jalview2XML public static FeatureColourI parseColour(Colour colourModel) { FeatureColourI colour = null; - + if (colourModel.getMax() != null) { Color mincol = null; Color maxcol = null; Color noValueColour = null; - + try { mincol = new Color(Integer.parseInt(colourModel.getMinRGB(), 16)); @@ -6586,7 +6583,7 @@ public class Jalview2XML { Cache.log.warn("Couldn't parse out graduated feature color.", e); } - + NoValueColour noCol = colourModel.getNoValueColour(); if (noCol == NoValueColour.MIN) { @@ -6596,7 +6593,7 @@ public class Jalview2XML { noValueColour = maxcol; } - + colour = new FeatureColour(maxcol, mincol, maxcol, noValueColour, safeFloat(colourModel.getMin()), safeFloat(colourModel.getMax())); @@ -6635,7 +6632,7 @@ public class Jalview2XML Color color = new Color(Integer.parseInt(colourModel.getRGB(), 16)); colour = new FeatureColour(color); } - + return colour; } } diff --git a/src/jalview/util/HttpUtils.java b/src/jalview/util/HttpUtils.java index a5a9460..74f77a2 100644 --- a/src/jalview/util/HttpUtils.java +++ b/src/jalview/util/HttpUtils.java @@ -64,4 +64,9 @@ public class HttpUtils return false; } + public static boolean startsWithHttpOrHttps(String file) + { + return file.startsWith("http://") || file.startsWith("https://"); + } + }