Skip to content

Commit 42004a4

Browse files
committed
Merge pull request #502 from ThomasJClark/palette-gui
Add palette categories
2 parents 1e4c484 + 7c5c285 commit 42004a4

24 files changed

+328
-211
lines changed

buildSrc/src/main/java/edu/wpi/gripgenerator/templates/Operation.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,21 @@ private MethodDeclaration getDescriptionMethod() {
126126
return getDescription;
127127
}
128128

129+
private MethodDeclaration getCategoryMethod() {
130+
MethodDeclaration getCategory = new MethodDeclaration(
131+
ModifierSet.PUBLIC,
132+
Collections.singletonList(OVERRIDE_ANNOTATION),
133+
null,
134+
createReferenceType("Category", 0),
135+
"getCategory",
136+
null, 0,
137+
null,
138+
null
139+
);
140+
getCategory.setBody(new BlockStmt(Collections.singletonList(new ReturnStmt(new NameExpr("Category.OPENCV")))));
141+
return getCategory;
142+
}
143+
129144
/**
130145
* Creates the method that returns the input socket of this operation.
131146
*
@@ -280,6 +295,7 @@ private ClassOrInterfaceDeclaration getClassDeclaration() {
280295
.collect(Collectors.toList()));
281296
ASTHelper.addMember(operation, getNameMethod());
282297
ASTHelper.addMember(operation, getDescriptionMethod());
298+
ASTHelper.addMember(operation, getCategoryMethod());
283299
ASTHelper.addMember(operation, getCreateInputSocketsMethod());
284300
ASTHelper.addMember(operation, getCreateOutputSocketsMethod());
285301
ASTHelper.addMember(operation, getPerformMethod());

core/src/main/java/edu/wpi/grip/core/Operation.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
*/
1212
public interface Operation {
1313

14+
enum Category {
15+
IMAGE_PROCESSING,
16+
FEATURE_DETECTION,
17+
NETWORK,
18+
OPENCV,
19+
MISCELLANEOUS,
20+
}
21+
1422
/**
1523
* @return The unique user-facing name of the operation, such as "Gaussian Blur"
1624
*/
@@ -22,6 +30,13 @@ public interface Operation {
2230
*/
2331
String getDescription();
2432

33+
/**
34+
* @return What category the operation falls under. This is used to organize them in the GUI
35+
*/
36+
default Category getCategory() {
37+
return Category.MISCELLANEOUS;
38+
}
39+
2540
/**
2641
* @return An {@link InputStream} of a 128x128 image to show the user as a representation of the operation.
2742
*/

core/src/main/java/edu/wpi/grip/core/operations/Operations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public static void addOperations(EventBus eventBus) {
3333
eventBus.post(new OperationAddedEvent(new FilterLinesOperation()));
3434
eventBus.post(new OperationAddedEvent(new MaskOperation()));
3535
eventBus.post(new OperationAddedEvent(new MinMaxLoc()));
36+
eventBus.post(new OperationAddedEvent(new MatFieldAccessor()));
3637
eventBus.post(new OperationAddedEvent(new NewPointOperation()));
3738
eventBus.post(new OperationAddedEvent(new NewSizeOperation()));
38-
eventBus.post(new OperationAddedEvent(new MatFieldAccessor()));
3939
eventBus.post(new OperationAddedEvent(new NTPublishOperation<>(Number.class, NTNumber.class, NTNumber::new)));
4040
eventBus.post(new OperationAddedEvent(new NTPublishOperation<>(Point.class, NTVector2D.class, NTVector2D::new)));
4141
eventBus.post(new OperationAddedEvent(new NTPublishOperation<>(Size.class, NTVector2D.class, NTVector2D::new)));

core/src/main/java/edu/wpi/grip/core/operations/composite/BlurOperation.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ public String getDescription() {
4646
return "Soften the details of an image to remove noise.";
4747
}
4848

49+
@Override
50+
public Category getCategory() {
51+
return Category.IMAGE_PROCESSING;
52+
}
53+
4954
@Override
5055
public Optional<InputStream> getIcon() {
5156
return Optional.of(getClass().getResourceAsStream("/edu/wpi/grip/ui/icons/blur.png"));

core/src/main/java/edu/wpi/grip/core/operations/composite/ConvexHullsOperation.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ public String getDescription() {
3131
return "Compute the convex hulls of contours.";
3232
}
3333

34+
@Override
35+
public Category getCategory() {
36+
return Category.FEATURE_DETECTION;
37+
}
38+
3439
@Override
3540
public Optional<InputStream> getIcon() {
3641
return Optional.of(getClass().getResourceAsStream("/edu/wpi/grip/ui/icons/convex-hulls.png"));

core/src/main/java/edu/wpi/grip/core/operations/composite/DesaturateOperation.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public String getDescription() {
2727
return "Convert a color image into shades of gray.";
2828
}
2929

30+
@Override
31+
public Category getCategory() {
32+
return Category.IMAGE_PROCESSING;
33+
}
34+
3035
@Override
3136
public Optional<InputStream> getIcon() {
3237
return Optional.of(getClass().getResourceAsStream("/edu/wpi/grip/ui/icons/desaturate.png"));

core/src/main/java/edu/wpi/grip/core/operations/composite/FilterContoursOperation.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public String getDescription() {
5555
return "Find contours matching certain criteria.";
5656
}
5757

58+
@Override
59+
public Category getCategory() {
60+
return Category.FEATURE_DETECTION;
61+
}
62+
5863
@Override
5964
public Optional<InputStream> getIcon() {
6065
return Optional.of(getClass().getResourceAsStream("/edu/wpi/grip/ui/icons/find-contours.png"));

core/src/main/java/edu/wpi/grip/core/operations/composite/FilterLinesOperation.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ public String getDescription() {
3434
return "Filter only lines from a Find Lines operation that fit certain criteria.";
3535
}
3636

37+
@Override
38+
public Category getCategory() {
39+
return Category.FEATURE_DETECTION;
40+
}
41+
3742
@Override
3843
public Optional<InputStream> getIcon() {
3944
return Optional.of(getClass().getResourceAsStream("/edu/wpi/grip/ui/icons/filter-lines.png"));

core/src/main/java/edu/wpi/grip/core/operations/composite/FindBlobsOperation.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ public String getDescription() {
3636
return "Detect groups of pixels in an image.";
3737
}
3838

39+
@Override
40+
public Category getCategory() {
41+
return Category.FEATURE_DETECTION;
42+
}
43+
3944
@Override
4045
public Optional<InputStream> getIcon() {
4146
return Optional.of(getClass().getResourceAsStream("/edu/wpi/grip/ui/icons/find-blobs.png"));

core/src/main/java/edu/wpi/grip/core/operations/composite/FindContoursOperation.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public String getDescription() {
3333
return "Detect contours in a binary image.";
3434
}
3535

36+
@Override
37+
public Category getCategory() {
38+
return Category.FEATURE_DETECTION;
39+
}
40+
3641
@Override
3742
public Optional<InputStream> getIcon() {
3843
return Optional.of(getClass().getResourceAsStream("/edu/wpi/grip/ui/icons/find-contours.png"));

0 commit comments

Comments
 (0)