MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / getLocation

Method getLocation

ij/src/main/java/ij/Prefs.java:698–722  ·  view source on GitHub ↗

Uses the keyword key to retrieve a location from the preferences file. Returns null if the key is not found or the location is not valid (e.g., offscreen).

(String key)

Source from the content-addressed store, hash-verified

696 from the preferences file. Returns null if the
697 key is not found or the location is not valid (e.g., offscreen). */
698 public static Point getLocation(String key) {
699 String value = ijPrefs.getProperty(KEY_PREFIX+key);
700 if (value==null) return null;
701 int index = value.indexOf(",");
702 if (index==-1) return null;
703 double xloc = Tools.parseDouble(value.substring(0, index));
704 if (Double.isNaN(xloc) || index==value.length()-1) return null;
705 double yloc = Tools.parseDouble(value.substring(index+1));
706 if (Double.isNaN(yloc)) return null;
707 Point p = new Point((int)xloc, (int)yloc);
708 Rectangle bounds = GUI.getScreenBounds(p); // get bounds of screen that contains p
709 if (bounds!=null && p.x+100<=bounds.x+bounds.width && p.y+ 40<=bounds.y+bounds.height) {
710 if (locKeys.get(key)==null) { // first time for this key?
711 locKeys.setProperty(key, "");
712 Rectangle primaryScreen = GUI.getMaxWindowBounds();
713 ImageJ ij = IJ.getInstance();
714 Point ijLoc = ij!=null?ij.getLocation():null;
715 //System.out.println("getLoc: "+key+" "+(ijLoc!=null&&primaryScreen.contains(ijLoc)) + " "+!primaryScreen.contains(p));
716 if ((ijLoc!=null&&primaryScreen.contains(ijLoc)) && !primaryScreen.contains(p))
717 return null; // return null if "ImageJ" window on primary screen and this location is not
718 }
719 return p;
720 } else
721 return null;
722 }
723
724 @AstroImageJ(reason = "Check if location is on the screen")
725 public static boolean isLocationOnScreen(Point loc) {

Callers 15

showDialogMethod · 0.95
arrowToolOptionsMethod · 0.95
CommandsMethod · 0.95
LineWidthAdjusterMethod · 0.95
showWindowMethod · 0.95
runMethod · 0.95
MemoryMonitorMethod · 0.95
ColorPickerMethod · 0.95
ThresholdAdjusterMethod · 0.95
PixelInspectorMethod · 0.95
showDialogMethod · 0.95
showDialogMethod · 0.95

Calls 11

parseDoubleMethod · 0.95
getScreenBoundsMethod · 0.95
getMaxWindowBoundsMethod · 0.95
getInstanceMethod · 0.95
substringMethod · 0.80
lengthMethod · 0.65
getPropertyMethod · 0.45
indexOfMethod · 0.45
getMethod · 0.45
setPropertyMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected