Skip to content

Commit

Permalink
coverage now 48%
Browse files Browse the repository at this point in the history
  • Loading branch information
i-make-robots committed Jan 30, 2024
1 parent 9d21849 commit 28f8d70
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 6 deletions.
50 changes: 46 additions & 4 deletions src/main/java/com/marginallyclever/ro3/AllPanels.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import javax.swing.*;
Expand Down Expand Up @@ -57,10 +58,12 @@ public JPanel buildSet() {
// create one of every panel that extends JPanel
private void collectAllJPanels(Reflections reflections, JPanel cardPanel, List<String> names, List<Class<?>> exceptions) {
Set<Class<? extends JPanel>> allClasses = reflections.getSubTypesOf(JPanel.class);
if(allClasses.isEmpty()) {
allClasses.addAll(getHandmadeList());
}
for(var panelClass : allClasses) {
logger.debug("Panel "+panelClass.getName());
try {
if(exceptions.contains(panelClass)) continue; // skip, no default constructor
if(exceptions.contains(panelClass)) continue; // skip
JPanel panelInstance = panelClass.getDeclaredConstructor().newInstance();
logger.debug("Adding "+panelClass.getName());
cardPanel.add(panelInstance, panelClass.getName());
Expand All @@ -71,6 +74,45 @@ private void collectAllJPanels(Reflections reflections, JPanel cardPanel, List<S
}
}

private Collection<Class<? extends JPanel>> getHandmadeList() {
return new ArrayList<>(List.of(
com.marginallyclever.ro3.apps.about.AboutPanel.class,
com.marginallyclever.ro3.apps.editorpanel.EditorPanel.class,
com.marginallyclever.ro3.apps.logpanel.LogPanel.class,
com.marginallyclever.ro3.apps.nodedetailview.NodeDetailView.class,
com.marginallyclever.ro3.apps.nodeselector.NodeSelectionDialog.class,
com.marginallyclever.ro3.apps.nodeselector.NodeSelector.class,
com.marginallyclever.ro3.apps.nodetreeview.NodeTreeView.class,
com.marginallyclever.ro3.apps.shared.SearchBar.class,
com.marginallyclever.ro3.apps.viewport.OpenGLPanel.class,
com.marginallyclever.ro3.apps.viewport.Viewport.class,
com.marginallyclever.ro3.apps.viewport.ViewportSettingsPanel.class,
com.marginallyclever.ro3.apps.webcampanel.WebCamPanel.class,
com.marginallyclever.ro3.mesh.MeshChooserDialog.class,
com.marginallyclever.ro3.node.NodePanel.class,
com.marginallyclever.ro3.node.nodefactory.NodeFactoryPanel.class,
com.marginallyclever.ro3.node.nodes.DHParameterPanel.class,
com.marginallyclever.ro3.node.nodes.HingeJointPanel.class,
com.marginallyclever.ro3.node.nodes.LinearJointPanel.class,
com.marginallyclever.ro3.node.nodes.MaterialPanel.class,
com.marginallyclever.ro3.node.nodes.MotorPanel.class,
com.marginallyclever.ro3.node.nodes.RigidBody3DPanel.class,
com.marginallyclever.ro3.node.nodes.behavior.BehaviorTreeRunnerPanel.class,
com.marginallyclever.ro3.node.nodes.behavior.actions.LimbMoveToTargetPanel.class,
com.marginallyclever.ro3.node.nodes.behavior.decorators.RepeatPanel.class,
com.marginallyclever.ro3.node.nodes.limbplanner.LimbPlannerPanel.class,
com.marginallyclever.ro3.node.nodes.limbsolver.LimbSolverPanel.class,
com.marginallyclever.ro3.node.nodes.marlinrobotarm.MarlinRobotArmPanel.class,
com.marginallyclever.ro3.node.nodes.pose.PosePanel.class,
com.marginallyclever.ro3.node.nodes.pose.poses.AttachmentPointPanel.class,
com.marginallyclever.ro3.node.nodes.pose.poses.CameraPanel.class,
com.marginallyclever.ro3.node.nodes.pose.poses.LimbPanel.class,
com.marginallyclever.ro3.node.nodes.pose.poses.LookAtPanel.class,
com.marginallyclever.ro3.node.nodes.pose.poses.MeshInstancePanel.class,
com.marginallyclever.ro3.texture.TextureChooserDialog.class
));
}

// create and display a frame containing all the panels
public JFrame buildFrame() {
javax.swing.JFrame frame = new javax.swing.JFrame("All Panels");
Expand All @@ -85,13 +127,13 @@ public JFrame buildFrame() {

public static void main(String[] args) {
Registry.start();

/*
// print the classpath
System.out.println("Classpath:");
for(var path : ClasspathHelper.forJavaClassPath()) {
System.out.println(" "+path);
}

*/
try {
UIManager.setLookAndFeel(new FlatLightLaf());
} catch (Exception ignored) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,17 @@ public Supplier<Node> getSupplier() {
private final Category root = new Category("Node",Node::new);

public NodeFactory() {
scan();
super();
//scan();
}

public Category getRoot() {
return root;
}

public Supplier<Node> getSupplierFor(String path) {
List<Category> toCheck = new ArrayList<>(root.children);
List<Category> toCheck = new ArrayList<>();
toCheck.add(root);
while(!toCheck.isEmpty()) {
Category current = toCheck.remove(0);
toCheck.addAll(current.children);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import java.awt.*;

public class RepeatPanel extends JPanel {
public RepeatPanel() {
this(new Repeat());
}

public RepeatPanel(Repeat repeat) {
super(new GridLayout(0,2));

Expand Down
7 changes: 7 additions & 0 deletions src/test/java/com/marginallyclever/ro3/node/NodeTest.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.marginallyclever.ro3.node;

import com.marginallyclever.ro3.Registry;
import com.marginallyclever.ro3.node.nodes.pose.poses.Camera;
import com.marginallyclever.ro3.node.nodes.pose.Pose;
import org.json.JSONObject;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand All @@ -14,6 +16,11 @@ public class NodeTest {
private Node parentNode;
private Node childNode;

@BeforeAll
public static void beforeAll() {
Registry.start();
}

@BeforeEach
public void setup() {
parentNode = new Node("Parent");
Expand Down

0 comments on commit 28f8d70

Please sign in to comment.