当前位置: 首页>>代码示例>>Java>>正文


Java Pattern类代码示例

本文整理汇总了Java中org.sikuli.script.Pattern的典型用法代码示例。如果您正苦于以下问题:Java Pattern类的具体用法?Java Pattern怎么用?Java Pattern使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Pattern类属于org.sikuli.script包,在下文中一共展示了Pattern类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setImageIfUrlsIsSet

import org.sikuli.script.Pattern; //导入依赖的package包/类
private void setImageIfUrlsIsSet(SikuliElement sikuliElement, int timeoutInSeconds) {
	if (sikuliElement.getImages().length > 1) {
		boolean imageFound = false;
		long timeoutExpiredMs = System.currentTimeMillis() + timeoutInSeconds * 1000;
		while (!imageFound) {
			for (int i = 0; i < sikuliElement.getImages().length; i++) {
				imageFound = sikuli.exists(new Pattern(sikuliElement.getImages()[i]).similar(sikuliElement.getSimilarity0to100()/100), 0) != null;
				if (imageFound) {
					sikuliElement.setImage(sikuliElement.getImages()[i]);
					return;
				}
			}
			long waitMs = timeoutExpiredMs - System.currentTimeMillis();
		    if (waitMs <= 0) {
		        break;
		     }
		}
		if (!imageFound) {
			throw new RuntimeException(new FindFailed("Images not found: " + Arrays.toString(sikuliElement.getImages())));
		}
	}
}
 
开发者ID:marcoslimaqa,项目名称:sikuli-factory,代码行数:23,代码来源:SikuliElement.java

示例2: clickItem

import org.sikuli.script.Pattern; //导入依赖的package包/类
public void clickItem(String imageNameOrText, Locator locator) {
	SikuliLogger.logDebug("Clicking item at Server class");
	imageNameOrText = locator.updateLocatorTarget(imageNameOrText);
	try {
		SikuliLogger.logDebug("Clicking item: " + imageNameOrText);
		if (locator.isImage()) {
			Helper.getRegion().click(new Pattern(imageNameOrText).similar(locator.getSimilarityasFloat())
					.targetOffset(locator.getxOffset(), locator.getyOffset()));
		} else if (locator.isText()) {
			Location location = new TextRecognizer().findText(imageNameOrText);
			Helper.getRegion().click(new Location(location.x + (double)locator.getxOffset(), 
									              location.y + (double)locator.getyOffset()));
		}
	} catch (FindFailed e) {
		this.handleFindFailed(locator.isRemote(), e);
	}
}
 
开发者ID:Hi-Fi,项目名称:remotesikulilibrary,代码行数:18,代码来源:Server.java

示例3: doubleClickItem

import org.sikuli.script.Pattern; //导入依赖的package包/类
public void doubleClickItem(String imageNameOrText, Locator locator) {
	SikuliLogger.logDebug("Clicking item at Server class");
	imageNameOrText = locator.updateLocatorTarget(imageNameOrText);
	try {
		SikuliLogger.logDebug("Clicking item: " + imageNameOrText);
		if (locator.isImage()) {
			Helper.getRegion().doubleClick(new Pattern(imageNameOrText).similar(locator.getSimilarityasFloat())
					.targetOffset(locator.getxOffset(), locator.getyOffset()));
		} else if (locator.isText()) {
			Location location = new TextRecognizer().findText(imageNameOrText);
			Helper.getRegion().doubleClick(new Location(location.x + (double)locator.getxOffset(), 
												        location.y + (double)locator.getyOffset()));
		}
	} catch (FindFailed e) {
		this.handleFindFailed(locator.isRemote(), e);
	}
}
 
开发者ID:Hi-Fi,项目名称:remotesikulilibrary,代码行数:18,代码来源:Server.java

示例4: rightClickItem

import org.sikuli.script.Pattern; //导入依赖的package包/类
public void rightClickItem(String imageNameOrText, Locator locator) {
	SikuliLogger.logDebug("Clicking item at Server class");
	imageNameOrText = locator.updateLocatorTarget(imageNameOrText);
	try {
		SikuliLogger.logDebug("Clicking item: " + imageNameOrText);
		if (locator.isImage()) {
			Helper.getRegion().rightClick(new Pattern(imageNameOrText).similar(locator.getSimilarityasFloat())
					.targetOffset(locator.getxOffset(), locator.getyOffset()));
		} else if (locator.isText()) {
			Location location = new TextRecognizer().findText(imageNameOrText);
			Helper.getRegion().rightClick(new Location(location.x + (double)locator.getxOffset(), 
												       location.y + (double)locator.getyOffset()));
		}
	} catch (FindFailed e) {
		this.handleFindFailed(locator.isRemote(), e);
	}
}
 
开发者ID:Hi-Fi,项目名称:remotesikulilibrary,代码行数:18,代码来源:Server.java

示例5: inputTextToField

import org.sikuli.script.Pattern; //导入依赖的package包/类
public void inputTextToField(String text, String imageNameOrText, Locator locator) {
	imageNameOrText = locator.updateLocatorTarget(imageNameOrText);
	if (imageNameOrText != null) {
		try {
			SikuliLogger.logDebug("Clicking item: " + imageNameOrText);
			if (locator.isImage()) {
				Helper.getRegion().click(new Pattern(imageNameOrText).similar(locator.getSimilarityasFloat())
						.targetOffset(locator.getxOffset(), locator.getyOffset()));
			} else if (locator.isText()) {
				Location location = new TextRecognizer().findText(imageNameOrText);
				Helper.getRegion().click(new Location(location.x + (double)locator.getxOffset(), 
													  location.y + (double)locator.getyOffset()));
			}
		} catch (FindFailed e) {
			this.handleFindFailed(locator.isRemote(), e);
		}
	}

	this.pasteText(text);
}
 
开发者ID:Hi-Fi,项目名称:remotesikulilibrary,代码行数:21,代码来源:Server.java

示例6: getNewPattern

import org.sikuli.script.Pattern; //导入依赖的package包/类
private static Pattern getNewPattern(Field field) {
    try {
        Pattern pattern = null;
        if (group != null) {
            JLocation jLocation = field.getAnnotation(JLocation.class);
            JOffset jOffset = field.getAnnotation(JOffset.class);
            if (jLocation != null && group.equals(jLocation.group()))
                pattern = GuiAnnotationsUtil.getPattern(jLocation, jOffset);
        }
        return (pattern != null)
                ? pattern
                : GuiAnnotationsUtil.getPattern(field.getAnnotation(JLocation.class),
                field.getAnnotation(JOffset.class));
    } catch (Exception ex) {
        throw exception("Error in get patter for type '%s'", field.getType().getName()
                + LINE_BREAK + ex.getMessage());
    }
}
 
开发者ID:epam,项目名称:JDI,代码行数:19,代码来源:PatternCreator.java

示例7: getPattern

import org.sikuli.script.Pattern; //导入依赖的package包/类
public static Pattern getPattern(JLocation locator, JOffset offset) {
    if (locator == null) return null;
    Pattern pattern = new Pattern(GuiSettings.imageRoot + locator.filePath());
    pattern = pattern.similar((float) locator.similarity());
    if (offset != null)
        switch (offset.offsetUnit()) {
            case PIXELS:
                pattern.targetOffset(offset.xOffset(), offset.yOffset());
                break;
            case PERCENTAGE:
                int x = (int) pattern.getImage().getSize().getWidth() * offset.xOffset() / 100;
                int y = (int) pattern.getImage().getSize().getHeight() * offset.yOffset() / 100;
                pattern.targetOffset(x, y);
                break;
        }
    return pattern;
}
 
开发者ID:epam,项目名称:JDI,代码行数:18,代码来源:GuiAnnotationsUtil.java

示例8: specificAction

import org.sikuli.script.Pattern; //导入依赖的package包/类
protected IBaseElement specificAction(IBaseElement instance, Field field, Object parent, Class<?> type) {
    BaseElement element = (BaseElement) instance;
    if (type != null) {
        Pattern frameBy = GuiAnnotationsUtil.getPattern(type.getDeclaredAnnotation(JLocation.class),
                type.getDeclaredAnnotation(JOffset.class));
        if (frameBy != null)
            element.avatar.context.add(ContextType.Frame, frameBy);
    }

    element.avatar.setSimilarity(GuiAnnotationsUtil.getSimilarity(field.getAnnotation(JLocation.class)));
    if (field.getAnnotation(JRegion.class) != null) {
        element.avatar.setRectangle(GuiAnnotationsUtil.getRectangle(field.getAnnotation(JRegion.class)));
        element.avatar.setX(GuiAnnotationsUtil.getX(field.getAnnotation(JRegion.class)));
        element.avatar.setY(GuiAnnotationsUtil.getY(field.getAnnotation(JRegion.class)));
        element.avatar.setW(GuiAnnotationsUtil.getWight(field.getAnnotation(JRegion.class)));
        element.avatar.setH(GuiAnnotationsUtil.getHeight(field.getAnnotation(JRegion.class)));
    }
    return element;
}
 
开发者ID:epam,项目名称:JDI,代码行数:20,代码来源:GUICascadeInit.java

示例9: updatePageData

import org.sikuli.script.Pattern; //导入依赖的package包/类
public void updatePageData(String fileLogoPath, CheckPageTypes checkPage,
                           Rectangle rectangle, int X, int Y, int W, int H, double similarity) {
    if (this.filePath == null)
        this.filePath = fileLogoPath;
    if (this.rectangle == null)
        this.rectangle = rectangle;
    if (this.x == 0)
        this.x = X;
    if (this.y == 0)
        this.y = Y;
    if (this.w == 0)
        this.w = W;
    if (this.h == 0)
        this.h = H;
    if (this.similarity == 0)
        this.similarity = similarity;
    if (this.filePath != null && this.similarity != 0.0)
        this.pattern = new Pattern(fileLogoPath).similar((float) this.similarity);
    this.checkPage = checkPage;
}
 
开发者ID:epam,项目名称:JDI,代码行数:21,代码来源:Page.java

示例10: findBestMatchIndexMultithreaded

import org.sikuli.script.Pattern; //导入依赖的package包/类
/**
 * Finds the best match among matches that satisfy minimum acceptable similarity and returns
 * index of it according to the provided array of Patterns.
 *
 * @param screenImage
 *            The captured image.
 * @param targetList
 *            The array with targets (Patterns) with specified minimum similarity.
 * @return The target index in array with the best score, -1 if there are no matches.
 */
private int findBestMatchIndexMultithreaded(ScreenImage screenImage, Pattern[] targetList) {
	int bestIndex = -1;
	double bestScore = 0.0;
	Match[] matches = getMatchesMultithreaded(screenImage, targetList);
	if (matches == null) {
		return -1;
	}
	int i = 0;
	for (Match match: matches) {
		if (match != null) { // Pattern found.
			double score = match.getScore();
			if (bestScore < score) {
				bestScore = score;
				bestIndex = i;
			}
		}
		i++;
	}
	return bestIndex;
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:31,代码来源:RegionSwitchAction.java

示例11: init

import org.sikuli.script.Pattern; //导入依赖的package包/类
@Override
public void init() {
	super.init();
	coords.get().initRegion(elementInfo);
	if (elementInfo.isBroken()) {
		// already broken by coords.get().initRegion();
		return;
	}
	if (similarity.get() > 1 || similarity.get() <= 0) {
		elementInfo.setAsBroken("Similarity parameter must be from 0 to 1.00");
		return;
	}
	fileLister.get().initTemporaryFileList(elementInfo, "Target image files", null);
	if (elementInfo.isBroken()) {
		// already broken by fileLister.get().initTemporaryFileList() or null extension
		return;
	}
	ReadOnlyListProperty<File> targetsList = fileLister.get().getTemporarySourceFileList();
	targets = new ArrayList<Pattern>(targetsList.size());
	for (File f : targetsList) {
		Image.unCacheBundledImage(f.getAbsolutePath());
		targets.add(new Pattern(f.toString()).similar(similarity.get()));
	}
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:25,代码来源:MultiTargetRegionChecker.java

示例12: ImageLibObject

import org.sikuli.script.Pattern; //导入依赖的package包/类
public ImageLibObject(Path imageFile) throws SakuliException {
    this.imageFile = imageFile;

    if (Files.exists(imageFile)) {
        String name = imageFile.toFile().getName();

        if (isValidInputImageFileEnding(name)) {
            pattern = new Pattern(imageFile.toFile().getAbsolutePath());

            id = name.substring(0, name.lastIndexOf('.'));

            logger.info("loaded image " + this.toString());
        }
        // for .js files do nothing
        else if (name.endsWith(".js")) {
            logger.debug("internal image library: Ignore javascript file " + name);
        }
        // for all other files log a warning
        else {
            logger.info("internal image library: '" + imageFile.toFile().getAbsolutePath() + "' is no .png picture");
        }
    } else {
        throw new SakuliException("Image-File '" + imageFile.toFile().getAbsolutePath() + "' does not exists!");
    }
}
 
开发者ID:ConSol,项目名称:sakuli,代码行数:26,代码来源:ImageLibObject.java

示例13: CheckBox

import org.sikuli.script.Pattern; //导入依赖的package包/类
public CheckBox(String checkedImage, String uncheckedImage) {
    this.checkedImage = checkedImage;
    this.uncheckedImage = uncheckedImage;

    this.patternCheck = new Pattern(checkedImage);
    this.patternUncheck = new Pattern(uncheckedImage);

}
 
开发者ID:ggasoftware,项目名称:gga-selenium-framework,代码行数:9,代码来源:CheckBox.java

示例14: getElementInstance

import org.sikuli.script.Pattern; //导入依赖的package包/类
private static BaseElement getElementInstance(Class<?> type, String fieldName, Pattern newPattern, String driverName, Field field) {
    try {
        if (!type.isInterface()) {
            BaseElement instance;
            if (MapClassToAnnotation.mapForConstructor.get(type) != null)
                instance = MapClassToAnnotation.getMapForConstructor().get(type).value.apply(field);
            else
                instance = (BaseElement) type.newInstance();
            instance.avatar.pattern = newPattern;
            instance.avatar.setDriverName(driverName);
            return instance;
        }
        throw exception("Unknown interface: " + type +
                ". Add relation interface -> class in VIElement.InterfaceTypeMap");
    } catch (Exception ex) {
        throw exception("Error in getElementInstance for field '%s' with type '%s'", fieldName, type.getSimpleName() +
                LINE_BREAK + ex.getMessage());
    }
}
 
开发者ID:ggasoftware,项目名称:gga-selenium-framework,代码行数:20,代码来源:CascadeInit.java

示例15: getNewPattern

import org.sikuli.script.Pattern; //导入依赖的package包/类
private static Pattern getNewPattern(Field field) {
    try {
        Pattern pattern = null;
        String locatorGroup = APP_VERSION;
        if (locatorGroup != null) {
            JLocation jLocation = field.getAnnotation(JLocation.class);
            JOffset jOffset = field.getAnnotation(JOffset.class);
            if (jLocation != null && locatorGroup.equals(jLocation.group()))
                pattern = GuiAnnotationsUtil.getPattern(jLocation, jOffset);
        }
        return (pattern != null)
                ? pattern
                : GuiAnnotationsUtil.getPattern(field.getAnnotation(JLocation.class),
                field.getAnnotation(JOffset.class));
    } catch (Exception ex) {
        throw exception("Error in get patter for type '%s'", field.getType().getName() +
                LINE_BREAK + ex.getMessage());
    }
}
 
开发者ID:ggasoftware,项目名称:gga-selenium-framework,代码行数:20,代码来源:CascadeInit.java


注:本文中的org.sikuli.script.Pattern类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。