Java Code Examples for org.sikuli.script.Pattern#getBImage()

The following examples show how to use org.sikuli.script.Pattern#getBImage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Guide.java    From SikuliX1 with MIT License 6 votes vote down vote up
public void addTracker(Pattern pattern, SxAnchor anchor) {
  Tracker tracker = null;

  //      // find a tracker already assigned to this pattern
  //      for (Tracker t : trackers){
  //         if (t.isAlreadyTracking(pattern,r)){
  //            tracker = t;
  //            break;
  //         }
  //      }

  //      if (tracker == null){
  tracker = new Tracker(this, pattern, null);
  trackers.add(tracker);
  //      }
  BufferedImage img;
  try {
    img = pattern.getBImage();
    anchor.setActualSize(img.getWidth(), img.getHeight());
    tracker.setAnchor(anchor);
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
Example 2
Source File: Tracker.java    From SikuliX1 with MIT License 6 votes vote down vote up
public Tracker(Guide guide, Pattern pattern, Region match){
   this.guide = guide;
   //this.match = match;
   screen = new Screen();
   BufferedImage image;
   BufferedImage center;
   this.pattern = pattern;
   try {
      image = pattern.getBImage();
      int w = image.getWidth();
      int h = image.getHeight();
      center = image.getSubimage(w/4,h/4,w/2,h/2);
      centerPattern = new Pattern(center);
   } catch (Exception e) {
      e.printStackTrace();
   }
}
 
Example 3
Source File: SxAnchor.java    From SikuliX1 with MIT License 5 votes vote down vote up
public void setTracker(Pattern pattern) {
  setOpacity(0f);
  tracker = new Tracker(pattern);
  BufferedImage img;
  try {
    img = pattern.getBImage();
    setActualSize(img.getWidth(), img.getHeight());
    tracker.setAnchor(this);
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
Example 4
Source File: Tracker.java    From SikuliX1 with MIT License 5 votes vote down vote up
public boolean isAlreadyTracking(Pattern pattern, Region match) {
   try {
      boolean sameMatch = this.match == match;
      boolean sameBufferedImage = this.pattern.getBImage() == pattern.getBImage();
      boolean sameFilename = (this.pattern.getFilename() != null &&
            (this.pattern.getFilename().compareTo(pattern.getFilename()) == 0));
      return sameMatch || sameBufferedImage || sameFilename;
   } catch (Exception e) {
      return false;
   }
}
 
Example 5
Source File: SxMagnet.java    From SikuliX1 with MIT License 4 votes vote down vote up
void attractTarget(SxAnchor a, Point targetLocation) {

    try {
      Pattern pattern = a.getPattern();
      SxImage img = new SxImage(pattern.getBImage());

      SxClickable clickable = new SxClickable();
      clickable.setLocationRelativeToComponent(img, Layout.OVER);
      guide.addToFront(clickable);

      clickable.clickPoint = a.getCenter();

      Link link = new Link();
      link.image = img;
      link.anchor = a;
      links.add(link);

      img.setShadowDefault();
      img.setActualLocation(a.getActualLocation());

      Dimension currentSize = a.getActualSize();
      Dimension targetSize = new Dimension(currentSize);
      targetSize.width *= 1.5;
      targetSize.height *= 1.5;

      img.addResizeAnimation(currentSize, targetSize);

      Point currentLocation = new Point(a.getActualLocation());

      targetLocation.x -= targetSize.width / 2;
      targetLocation.y -= targetSize.height / 2;

      img.addMoveAnimation(currentLocation, targetLocation);
      guide.addToFront(img);
      img.startAnimation();

      guide.repaint();

    } catch (Exception e) {
      e.printStackTrace();
    }

  }