If 'urlOrName' is a URL, opens the image at that URL. If it is a file name, opens the image with that name from the 'images.location' URL in IJ_Props.txt. If it is blank, prompts for an image URL and open the specified image.
(String urlOrName)
| 40 | URL and open the specified image. |
| 41 | */ |
| 42 | public void run(String urlOrName) { |
| 43 | if (IJ.debugMode) IJ.log("URLOpener.run: "+urlOrName); |
| 44 | if (!urlOrName.equals("")) { |
| 45 | if (urlOrName.equals("cache")) |
| 46 | cacheSampleImages(); |
| 47 | else if (urlOrName.endsWith("StartupMacros.txt")) |
| 48 | openTextFile(urlOrName, true); |
| 49 | else { |
| 50 | double startTime = System.currentTimeMillis(); |
| 51 | String url = imageURL(urlOrName); |
| 52 | ImagePlus imp = new ImagePlus(url); |
| 53 | if (IJ.recording()) |
| 54 | Recorder.recordCall("imp = IJ.openImage(\""+url+"\");"); |
| 55 | if (imp.getType()==ImagePlus.COLOR_RGB) |
| 56 | Opener.convertGrayJpegTo8Bits(imp); |
| 57 | WindowManager.checkForDuplicateName = true; |
| 58 | FileInfo fi = imp.getOriginalFileInfo(); |
| 59 | if (fi!=null && fi.fileType==FileInfo.RGB48) |
| 60 | imp = new CompositeImage(imp, IJ.COMPOSITE); |
| 61 | else if (imp.getNChannels()>1 && fi!=null && fi.description!=null && fi.description.indexOf("mode=")!=-1) { |
| 62 | int mode = IJ.COLOR; |
| 63 | if (fi.description.indexOf("mode=composite")!=-1) |
| 64 | mode = IJ.COMPOSITE; |
| 65 | else if (fi.description.indexOf("mode=gray")!=-1) |
| 66 | mode = IJ.GRAYSCALE; |
| 67 | imp = new CompositeImage(imp, mode); |
| 68 | } |
| 69 | if (fi!=null && (fi.url==null || fi.url.length()==0)) { |
| 70 | fi.url = url; |
| 71 | imp.setFileInfo(fi); |
| 72 | } |
| 73 | imp.show(Opener.getLoadRate(startTime,imp)); |
| 74 | String title = imp.getTitle(); |
| 75 | if (title!=null && (title.startsWith("flybrain") || title.startsWith("t1-head"))) |
| 76 | imp.setSlice(imp.getStackSize()/2); |
| 77 | } |
| 78 | return; |
| 79 | } |
| 80 | |
| 81 | GenericDialog gd = new GenericDialog("Enter a URL"); |
| 82 | gd.setInsets(10, 32, 0); |
| 83 | gd.addMessage("Enter URL of an image, macro or web page", null, Color.darkGray); |
| 84 | gd.addStringField("URL:", url, 45); |
| 85 | gd.showDialog(); |
| 86 | if (gd.wasCanceled()) |
| 87 | return; |
| 88 | url = gd.getNextString(); |
| 89 | url = url.trim(); |
| 90 | if (url.indexOf("://")==-1) |
| 91 | url = "http://" + url; |
| 92 | if (url.endsWith("/")) |
| 93 | IJ.runPlugIn("ij.plugin.BrowserLauncher", url.substring(0, url.length()-1)); |
| 94 | else if (url.endsWith(".html") || url.endsWith(".htm") || url.endsWith(".pdf") || url.indexOf(".html#")>0 || noExtension(url)) |
| 95 | IJ.runPlugIn("ij.plugin.BrowserLauncher", url); |
| 96 | else if (url.endsWith(".txt")||url.endsWith(".ijm")||url.endsWith(".js")||url.endsWith(".java")) |
| 97 | openTextFile(url, false); |
| 98 | else if (url.endsWith(".jar")||url.endsWith(".class")) |
| 99 | IJ.open(url); |
nothing calls this directly
no test coverage detected