Skip to content

Commit d5a3128

Browse files
committed
javadocs
1 parent 2a94278 commit d5a3128

File tree

2 files changed

+45
-44
lines changed

2 files changed

+45
-44
lines changed

API/src/main/java/org/sikuli/script/Pixels.java

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@
99
import java.util.Iterator;
1010
import java.util.List;
1111

12+
/**
13+
* INTERNAL: An abstract super-class for {@link Region} and {@link Image}.
14+
* <br>
15+
* <p>BE AWARE: This class cannot be used as such (cannot be instantiated)
16+
* <br>... instead use the classes Region or Image as needed</p>
17+
* NOTES:
18+
* <br>- the classname might change in the future without notice
19+
* <br>- the intention is, to have only one implementation for features, that are the same for Region and Image
20+
* <br>- the implementation here is ongoing beginning with version 2.0.2 and hence not complete yet
21+
* <br>- you might get <b>not-implemented exceptions</b> until complete
22+
*/
1223
public abstract class Pixels {
1324

1425
protected static final int logLevel = 3;
@@ -31,7 +42,7 @@ public int getX() {
3142
}
3243

3344
/**
34-
* X-coordinate of the Region
45+
* X-coordinate of the Region (ignored for Image)
3546
*/
3647
public int x = 0;
3748

@@ -43,31 +54,31 @@ public int getY() {
4354
}
4455

4556
/**
46-
* Y-coordinate of the Region
57+
* Y-coordinate of the Region (ignored for Image)
4758
*/
4859
public int y = 0;
4960

5061
/**
51-
* @return width of region
62+
* @return width of region/image
5263
*/
5364
public int getW() {
5465
return w;
5566
}
5667

5768
/**
58-
* Width of the Region
69+
* Width of the Region/Image
5970
*/
6071
public int w = 0;
6172

6273
/**
63-
* @return height of region
74+
* @return height of region/image
6475
*/
6576
public int getH() {
6677
return h;
6778
}
6879

6980
/**
70-
* Height of the Region
81+
* Height of the Region/Image
7182
*/
7283
public int h = 0;
7384

@@ -107,7 +118,7 @@ protected void setImageMissingHandler(Object handler) {
107118
* finds the given Pattern, String or Image in the region and returns the best match.
108119
*
109120
* @param <PSI> Pattern, String or Image
110-
* @param target
121+
* @param target what (PSI) to find in this Region
111122
* @return If found, the element. null otherwise
112123
* @throws FindFailed if the Find operation failed
113124
*/
@@ -214,7 +225,7 @@ public List<Match> findWords() {
214225
/**
215226
* Find the first word as text (top left to bottom right) containing the given text
216227
*
217-
* @param word
228+
* @param word to be searched
218229
* @return a text match or null if not found
219230
*/
220231
public Match findWord(String word) {
@@ -231,7 +242,7 @@ public Match findWord(String word) {
231242
/**
232243
* Find all words as text (top left to bottom right) containing the given text
233244
*
234-
* @param word
245+
* @param word to be searched
235246
* @return a list of text matches
236247
*/
237248
public List<Match> findWords(String word) {
@@ -245,7 +256,7 @@ public List<Match> findWords(String word) {
245256
/**
246257
* Find the first line as text (top left to bottom right) containing the given text
247258
*
248-
* @param text
259+
* @param text the line should contain
249260
* @return a text match or null if not found
250261
*/
251262
public Match findLine(String text) {
@@ -262,7 +273,7 @@ public Match findLine(String text) {
262273
/**
263274
* Find all lines as text (top left to bottom right) containing the given text
264275
*
265-
* @param text
276+
* @param text the lines should contain
266277
* @return a list of text matches or empty list if not found
267278
*/
268279
public List<Match> findLines(String text) {
@@ -322,6 +333,10 @@ public Match existsText(String text) {
322333
//return match;
323334
}
324335

336+
public Match existsT(String text) {
337+
return existsText(text);
338+
}
339+
325340
public boolean hasText(String text) {
326341
return null != existsText(text);
327342
}
@@ -344,8 +359,8 @@ public List<Match> findAllT(String text) {
344359
//<editor-fold desc="20 helper">
345360
/**
346361
* INTERNAL: get Image from target
347-
* @param target Pattern, Filename, Image, ScreenImage
348-
* @param <PSI>
362+
* @param <PSI> Pattern, Filename, Image, ScreenImage
363+
* @param target what(PSI) to search
349364
* @return Image object
350365
*/
351366
public static <PSI> Image getImageFromTarget(PSI target) {
@@ -369,8 +384,7 @@ protected static <SFIRBS> BufferedImage getBufferedImage(SFIRBS whatEver) {
369384
} else if (whatEver instanceof File) {
370385
return Image.create((File) whatEver).get();
371386
} else if (whatEver instanceof Region) {
372-
Region reg = (Region) whatEver;
373-
return reg.getScreen().capture(reg).getImage();
387+
return ((Region) whatEver).getImage().get();
374388
} else if (whatEver instanceof Image) {
375389
return ((Image) whatEver).get();
376390
} else if (whatEver instanceof ScreenImage) {
@@ -409,9 +423,10 @@ protected Match relocate(Match match) {
409423
protected long lastSearchTimeRepeat = -1;
410424

411425
/**
412-
* a find operation saves its match on success in the used region object<br>unchanged if not successful
426+
* a find operation saves its match on success in this region/image.
427+
* <br>... unchanged if not successful
413428
*
414-
* @return the Match object from last successful find in this region
429+
* @return the Match object from last successful find
415430
*/
416431
public Match getLastMatch() {
417432
return lastMatch;
@@ -420,9 +435,10 @@ public Match getLastMatch() {
420435
// ************************************************
421436

422437
/**
423-
* a searchAll operation saves its matches on success in the used region object<br>unchanged if not successful
438+
* a searchAll operation saves its matches on success in this region/image
439+
* <br>... unchanged if not successful
424440
*
425-
* @return a Match-Iterator of matches from last successful searchAll in this region
441+
* @return a Match-Iterator of matches from last successful searchAll
426442
*/
427443
public Iterator<Match> getLastMatches() {
428444
return lastMatches;
@@ -431,7 +447,7 @@ public Iterator<Match> getLastMatches() {
431447

432448
//<editor-fold desc="99 obsolete">
433449
/**
434-
* @return
450+
* @return a list of matches
435451
* @deprecated use findLines() instead
436452
* @see #findLines()
437453
*/
@@ -440,7 +456,7 @@ public List<Match> collectLines() {
440456
}
441457

442458
/**
443-
* @return
459+
* @return a list of lines as strings
444460
* @deprecated use textLines() instead
445461
* @see #textLines()
446462
*/
@@ -450,7 +466,7 @@ public List<String> collectLinesText() {
450466
}
451467

452468
/**
453-
* @return
469+
* @return a list of matches
454470
* @deprecated use findWords() instead
455471
* @see #findWords()
456472
*/
@@ -460,7 +476,7 @@ public List<Match> collectWords() {
460476
}
461477

462478
/**
463-
* @return
479+
* @return a list of words sa strings
464480
* @deprecated use textWords() instead
465481
* @see #textWords()
466482
*/

API/src/main/java/org/sikuli/script/Region.java

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@
1818
import java.util.*;
1919

2020
/**
21-
* A Region is a rectengular area and lies always completely inside its parent screen
21+
* A Region is a rectengular area on a screen.
22+
* <br>
23+
* <p>completely contained in that screen (no screen overlapping)</p>
24+
* NOTES:
25+
* <br>- when needed (find ops), the pixel content is captured from the screen
26+
* <br>- if nothing else is said, the center pixel is the target for mouse actions
2227
*/
2328
public class Region extends Pixels {
2429

@@ -2636,10 +2641,6 @@ public Match findText(String text) throws FindFailed {
26362641
return waitText(text, 0);
26372642
}
26382643

2639-
// public Match findT(String text) throws FindFailed {
2640-
// return findText(text);
2641-
// }
2642-
26432644
public Match existsText(String text, double timeout) {
26442645
Match match = null;
26452646
try {
@@ -2653,22 +2654,10 @@ public Match existsText(String text) {
26532654
return existsText(text, autoWaitTimeout);
26542655
}
26552656

2656-
// public Match existsT(String text, double timeout) {
2657-
// return existsText(text, timeout);
2658-
// }
2659-
//
2660-
// public Match existsT(String text) {
2661-
// return existsT(text, autoWaitTimeout);
2662-
// }
2663-
26642657
public boolean hasText(String text) {
26652658
return null != existsText(text, 0);
26662659
}
26672660

2668-
// public boolean hasT(String text) {
2669-
// return hasText(text);
2670-
// }
2671-
26722661
public List<Match> findAllText(String text) {
26732662
List<Match> matches = new ArrayList<>();
26742663
try {
@@ -2678,10 +2667,6 @@ public List<Match> findAllText(String text) {
26782667
return matches;
26792668
}
26802669

2681-
public List<Match> findAllT(String text) {
2682-
return findAllText(text);
2683-
}
2684-
26852670
protected List<Match> relocate(List<Match> matches) {
26862671
for (Match match : matches) {
26872672
match.x += this.x;

0 commit comments

Comments
 (0)