วันพฤหัสบดีที่ 27 เมษายน พ.ศ. 2560

การสร้าง Text Window ในโปรแกรม ImageJ

Text Window…

เปิดหน้าต่างข้อความเพื่อกำหนดขนาดของมาโคร ดังตัวอย่าง

https://imagej.nih.gov/ij/macros/PrintToTextWindow.txt

// Print to Text Window
  s1 = "This macro demonstrates how to display text in a text window.\n"
  s2 = "It uses the Plugins>New>Text Window commad to open the window\n"
  s3 = "if it is not already open. Note that newline characters (backslash-n) \n"
  s4 = "are not automatically added by the print() function.\n"
  requires("1.38m");
  title1 = "Text Window";
  title2 = "["+title1+"]";
  f = title2;
  if (isOpen(title1))
     print(f, "\\Update:"); // clears the window
  else
     run("Text Window...", "name="+title2+" width=72 height=8 menu");
  print(f, s1);
  print(f, s2);
  print(f, s3+s4);
https://imagej.nih.gov/ij/macros/Clock.txt

// Clock
//
// This macro demonstrates how to display a
// digital clock in a text window. It uses the
// Plugins>New>Text Window command to
// open a text window without a menu bar.
  title = "[Clock]";
  run("Text Window...", "name="+ title +" width=10 height=1");
  getDateAndTime(year, month, week, day, hour, min, sec, msec);
  start = getTime;
  while (true) {
      getDateAndTime(year, month, week, day, hour, min, sec, msec);
      print(title, "\\Update:"+pad(hour)+":"+pad(min)+":"+pad(sec));
      wait(1000);
  }
  function pad(n) {
      n = toString(n);
      if (lengthOf(n)==1) n = "0"+n;
      return n;
  }
https://imagej.nih.gov/ij/macros/ProgressBar.txt
// Progress Bar
//
// This macro demonstrates how to display status
// information and a progress bar in a text window.
// It uses the Plugins>New>Text Window command
// to open a text window without a menu bar.
  title = "[Progress]";
  run("Text Window...", "name="+ title +" width=25 height=2 monospaced");
  for (i=0; i<100; i++) {
     print(title, "\\Update:"+i+"/"+100+" ("+(i*100)/100+"%)\n"+getBar(i, 100));
     wait(200);
  }
  print(title, "\\Close");
  function getBar(p1, p2) {
        n = 20;
        bar1 = "--------------------";
        bar2 = "********************";
        index = round(n*(p1/p2));
        if (index<1) index = 1;
        if (index>n-1) index = n-1;
        return substring(bar2, 0, index) + substring(bar1, index+1, n);
  }

ไม่มีความคิดเห็น:

แสดงความคิดเห็น