// "StartupMacros"
// The macros and macro tools in this file ("StartupMacros.txt") are 
// automatically installed in the Plugins>Macros submenu and
//  in the tool bar when ImageJ starts up.

//  About the drawing tools.
//
//  This is a set of drawing tools similar to the pencil, paintbrush, 
//  eraser and flood fill (paint bucket) tools in NIH Image. The 
//  pencil and paintbrush draw in the current foreground color 
//  and the eraser draws in the current background color. The
//  flood fill tool fills the selected area using the foreground color.
//  Hold down the alt key to have the pencil and paintbrush draw 
//  using the background color or to have the flood fill tool fill 
//  using the background color. Set the foreground and background 
//  colors by double-clicking on the flood fill tool or on the eye  
//  dropper tool.  Double-click on the pencil, paintbrush or eraser 
//  tool  to set the drawing width for that tool.
//
// Icons contributed by Tony Collins.

   // Global variables
   var pencilWidth=1,  eraserWidth=10, leftClick=16, alt=8;
   var brushWidth = 10; //call("ij.Prefs.get", "startup.brush", "10");
   var floodType =  "8-connected"; //call("ij.Prefs.get", "startup.flood", "8-connected");

   // The macro named "AutoRun" runs when ImageJ starts.
   // macro "AutoRun" {print("AutoRun");}

   // The macro named "AutoRunAndHide" runs when ImageJ starts
   // and the file containing it is not displayed when ImageJ opens it.
   // macro "AutoRunAndHide" {}

   macro "AutoRun"
      {
      wait(10);
      setTool(10);
 //     wait(10);
      run("Astronomy Listener");
      }


  //macro "Unused Tool -" {}

  var pmCmds = newMenu("Popup Menu",
       newArray("Help...", "Rename...", "Duplicate...", "Original Scale", 
       "Paste Control...", "-", "Record...", "Capture Screen ", "Monitor Memory...", 
       "List Commands...", "Control Panel...", "Startup Macros...", "Search..."));

  macro "Popup Menu" {
      cmd = getArgument();
      if (cmd=="Help...")
           showMessage("About Popup Menu",
               "To customize this menu, edit the line that starts with\n\"var pmCmds\" in ImageJ/macros/StartupMacros.txt.");
      else
          run(cmd);
  }

 // macro "Abort Macro or Plugin (or press Esc key) Action Tool - CbooP51b1f5fbbf5f1b15510T5c10X" {
 //     setKeyDown("Esc");
 // }
 

// Runs when the "Astronomy Tool" icon is clicked.

macro 'Astronomy_Tool Tool- C000F00ffCf77o3422Cfffo9922CfffD55D27D78D2aD52D6dD93D85D4cDa3Db5Dc8DabDdd' {
//macro 'Astronomy_Tool Tool- Cccfo22bbC88fo4477C44fo5544Cf00L707fL07f7' {
	run ("Astronomy Tool");
}
// macro 'Astrometry Tool Options...' {
// 	run ("Set World Coordinates");
// }


// Runs when the "Aperture Photometry Tool" icon is clicked.

var rStar = 15;
var rSky  = 20;

macro 'Aperture Photometry Tool - Cf00O00ffCccfo22bbC88fo4477C44fo5544' {
	getCursorLoc (x,y,z,flags);
	makeOval (x-rSky, y-rSky, rSky*2, rSky*2);
	makeOval (x-rStar, y-rStar, rStar*2, rStar*2);
	run ("Aperture ");
}
macro 'Aperture Photometry Tool Options...' {
	run ("Set Aperture");
}

// Runs when the "Multiple-Aperture Tool" icon is clicked.
// 
 macro 'Multiple Aperture Action Tool - Cf00O0099O8899Cccfo2255oaa55C00fo3333obb33' {
 	run ("MultiAperture ");
}
// macro 'Multiple Aperture Tool Options...' {
// 	run ("MultiAperture ");
// }

// Runs when the "Clear Overlay Tool" icon is clicked.

macro 'Clear Overlay Action Tool - Cda1L0b75L2c86L4d97L6ea8L8fb9L74b3Lc7b3Cf00L75b7C431Lc3e0DbeDefDed' {
//	getCursorLoc (x,y,z,flags);
//	makeOval (x-3,y-3,7,7);
	run ("Clear Overlay","nix");
}
// macro 'Clear Overlay Tool Options...' {
// 	getCursorLoc (x,y,z,flags);
// 	makeOval (x-3,y-3,7,7);
// 	run ("Clear Overlay","nix");
// }

// Runs when the "Multi-Plot Tool" icon is clicked.

macro 'MultiPlot Action Tool -  ' {

	run("MultiPlot ");
}

// Runs when the "Read MeasurementTable" icon is clicked.

macro 'Read MeasurementTable Action Tool - C037B00R00ffL01f1L02f2L303fL707fLb0bf' {

	run("Read MeasurementTable");
}

macro "CCD Data Processor Action Tool - C03cT0e14DCf00T9e14P" {
	run("Data Processor");
}


macro "Coordinate Converter Action Tool -  "{
run("Coordinate Converter");
}


//macro "Adjust Brightness and Contrast Action Tool - //C037D04D05D06D07D08D09D0aD0bD0cD14D18D1cD24D28D2cD34D38D3cD45D46D47D49D4aD4bD6bD6cD76D77D78D79D7aD84D85Da6Da7Da8Da9DaaDb5//DbbDc4DccDd4DdcDe5DebDf6Dfa" {
//	run("Coordinate Converter");
//}
// macro "Adjust Brightness and Contrast Tool Options..." {
// 	run("Brightness/Contrast...");
// }






  macro "Set Drawing Color..."{ 
      run("Color Picker..."); 
  }

  macro "-" {} //menu divider

  macro "About Startup Macros..." {
      path = getDirectory("macros")+"/About Startup Macros";
      if (!File.exists(path))
          exit("\"About Startup Macros\" not found in ImageJ/macros/.");
      open(path);
  }

  macro "Save As JPEG... [j]" {
     quality = call("ij.plugin.JpegWriter.getQuality");
     quality = getNumber("JPEG quality (0-100):", quality);
     run("Input/Output...", "jpeg="+quality);
     saveAs("Jpeg");
  }



