public void run() {
    _running = true;
    initialFound = true;

    // Looking for the target for the first time
    Debug.log("[Tracker] Looking for the target for the first time");

    match = null;
    while (_running && (match == null)) {
      try {
        match = _screen.exists(_pattern, 0.5);
      } catch (Exception ex) {
      }
    }

    // this means the tracker has been stopped before the pattern is found
    if (match == null) return;

    Debug.log("[Tracker] Pattern is found for the first time");

    anchor.setLocation(match.x, match.y);
    anchor.setSize(match.w, match.h);
    SklAnimationFactory.createFadeinAnimation(anchor).start();

    try {
      _screen.click(match, 0);
    } catch (FindFailed e) {
    }

    if (transitionListener != null) transitionListener.transitionOccurred(this);
  }
Exemple #2
0
  @Override
  public void setLocationRelativeToRegion(Region region, Layout side) {
    setBoundsRelativeToComponent(source);
    Debug.info("[Shadow] UDPATED: " + this);

    super.setLocationRelativeToRegion(region, side);
  }
  private void loadPrefs() {
    SikuliIDE ide = SikuliIDE.getInstance();
    double delay = pref.getCaptureDelay();
    _spnDelay.setValue(delay);
    _old_cap_hkey = _cap_hkey = pref.getCaptureHotkey();
    _old_cap_mod = _cap_mod = pref.getCaptureHotkeyModifiers();
    setTxtHotkey(_cap_hkey, _cap_mod);
    switch (pref.getAutoNamingMethod()) {
      case UserPreferences.AUTO_NAMING_TIMESTAMP:
        _radTimestamp.setSelected(true);
        break;
      case UserPreferences.AUTO_NAMING_OCR:
        _radOCR.setSelected(true);
        break;
      case UserPreferences.AUTO_NAMING_OFF:
        _radOff.setSelected(true);
        break;
      default:
        Debug.error("Error in reading auto naming method preferences");
    }
    _chkAutoUpdate.setSelected(pref.getCheckUpdate());

    _chkExpandTab.setSelected(pref.getExpandTab());
    _spnTabWidth.setValue(pref.getTabWidth());
    initFontPrefs();
    initLangPrefs();
  }
 private void txtHotkeyKeyPressed(KeyEvent e) {
   int code = e.getKeyCode();
   int mod = e.getModifiers();
   Debug.log(7, "" + code + " " + mod);
   setTxtHotkey(code, mod);
   _txtHotkey.setEditable(false);
 }
Exemple #5
0
  public BufferedImage createShadowImage() {

    BufferedImage image =
        new BufferedImage(
            source.getWidth() + shadowSize * 2,
            source.getHeight() + shadowSize * 2,
            BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = image.createGraphics();
    g2.translate(shadowSize, shadowSize);
    source.paint(g2);

    shadowImage =
        new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
    getBlurOp(shadowSize).filter(createShadowMask(image), shadowImage);

    Debug.info("[Shadow] shadowImage: " + shadowImage);
    Debug.info("[Shadow] bounds: " + getBounds());

    return shadowImage;
  }
 public void testEnded(String testName) {
   Debug.log(8, "test ended: " + testName);
   synchUI();
   SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           if (fTestResult != null) {
             fCounterPanel.setRunValue(fTestResult.runCount());
             fProgressIndicator.step(fTestResult.runCount(), fTestResult.wasSuccessful());
           }
         }
       });
 }
Exemple #7
0
  public void drawPathTo(SikuliGuide guide, String search_string) {

    Enumeration<GUINode> e = ((GUINode) getRoot()).breadthFirstEnumeration();

    e.nextElement(); // pop the root

    GUINode matched_node = null;
    while (e.hasMoreElements()) {
      GUINode node = (GUINode) e.nextElement();

      // fuzzy matching hack
      String s1 = removeSpaces(node.name.toLowerCase());
      String s2 = removeSpaces(search_string.toLowerCase());

      if (Math.abs(s1.length() - s2.length()) < 3 && Distance.LD(s1, s2) < 3) {
        matched_node = node;
        break;
      }
    }

    Debug.info("matched_node: " + matched_node);

    if (matched_node != null) {

      Match m = matched_node.findOnScreen();
      if (m != null) {

        guide.addToFront(new SikuliGuideRectangle(m));

      } else {

        GUINode ancestor = matched_node.findAncestorOnScreen();

        if (ancestor != null) {

          matched_node.drawPathFromAncestor(guide, ancestor);
        }
      }
    }
  }
 public void testStarted(String testName) {
   Debug.log(8, "test started: " + testName);
 }