Skip to content

Commit

Permalink
Changes in TreeElement and Icon comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
rgudwin committed Apr 28, 2023
1 parent 41651aa commit 3b2c087
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 96 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = "CST-Desktop"

sourceCompatibility = 1.8
targetCompatibility = 1.8
version = '1.0.5'
version = '1.0.6'

repositories {
flatDir {
Expand Down
99 changes: 4 additions & 95 deletions src/main/java/br/unicamp/cst/util/viewer/MindRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,101 +51,10 @@ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean
DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) value;
DefaultMutableTreeNode objectNode;
TreeElement node = (TreeElement) dmtn.getUserObject();
switch (node.getIcon()) {
case TreeElement.ICON_COMPOSITE:
img = new ImageIcon(this.getClass().getClassLoader().getResource("object.png"));
break;
case TreeElement.ICON_AGGREGATE:
img = new ImageIcon(this.getClass().getClassLoader().getResource("object2.gif"));
break;
case TreeElement.ICON_PROPERTY:
img = new ImageIcon(this.getClass().getClassLoader().getResource("property.png"));
break;
case TreeElement.ICON_QUALITYDIM:
img = new ImageIcon(this.getClass().getClassLoader().getResource("qualityDim.png"));
break;
case TreeElement.ICON_VALUE:
img = new ImageIcon(this.getClass().getClassLoader().getResource("value.png"));
break;
default:
case TreeElement.ICON_MIND:
img = new ImageIcon(this.getClass().getClassLoader().getResource("mind.png"));
break;
case TreeElement.ICON_CODELET:
img = new ImageIcon(this.getClass().getClassLoader().getResource("codelet.png"));
break;
case TreeElement.ICON_CODELETS:
img = new ImageIcon(this.getClass().getClassLoader().getResource("codelets.png"));
break;
case TreeElement.ICON_MEMORY:
img = new ImageIcon(this.getClass().getClassLoader().getResource("memory.png"));
break;
case TreeElement.ICON_MEMORIES:
img = new ImageIcon(this.getClass().getClassLoader().getResource("memories.png"));
break;
case TreeElement.ICON_CONTAINER:
img = new ImageIcon(this.getClass().getClassLoader().getResource("container.png"));
break;
case TreeElement.ICON_MO:
img = new ImageIcon(this.getClass().getClassLoader().getResource("mo.png"));
break;
case TreeElement.ICON_INPUT:
img = new ImageIcon(this.getClass().getClassLoader().getResource("input.png"));
break;
case TreeElement.ICON_OUTPUT:
img = new ImageIcon(this.getClass().getClassLoader().getResource("output.png"));
break;
case TreeElement.ICON_BROADCAST:
img = new ImageIcon(this.getClass().getClassLoader().getResource("broadcast.png"));
break;
case TreeElement.ICON_AFFORDANCE:
img = new ImageIcon(this.getClass().getClassLoader().getResource("codelet2.png"));
break;
case TreeElement.ICON_OBJECT2:
img = new ImageIcon(this.getClass().getClassLoader().getResource("object2.png"));
break;
case TreeElement.ICON_OBJECT3:
img = new ImageIcon(this.getClass().getClassLoader().getResource("object3.png"));
break;
case TreeElement.ICON_CONFIGURATION:
img = new ImageIcon(this.getClass().getClassLoader().getResource("configuration.png"));
break;
case TreeElement.ICON_TIME:
img = new ImageIcon(this.getClass().getClassLoader().getResource("time-machine.png"));
break;
case TreeElement.ICON_PROPERTYCATEGORY:
img = new ImageIcon(this.getClass().getClassLoader().getResource("propertyCategory.png"));
break;
case TreeElement.ICON_OBJECTCATEGORY:
img = new ImageIcon(this.getClass().getClassLoader().getResource("objectCategory.png"));
break;
case TreeElement.ICON_EPISODECATEGORY:
img = new ImageIcon(this.getClass().getClassLoader().getResource("episodeCategory.png"));
break;
case TreeElement.ICON_PROPERTYPOSSIBILITY:
img = new ImageIcon(this.getClass().getClassLoader().getResource("property-p.png"));
break;
case TreeElement.ICON_OBJECTPOSSIBILITY:
img = new ImageIcon(this.getClass().getClassLoader().getResource("object-p.png"));
break;
case TreeElement.ICON_EPISODEPOSSIBILITY:
img = new ImageIcon(this.getClass().getClassLoader().getResource("episode-p.png"));
break;
case TreeElement.ICON_OBJECTEXISTENCE:
img = new ImageIcon(this.getClass().getClassLoader().getResource("object-e.png"));
break;
case TreeElement.ICON_ACTIONPOSSIBILITY:
img = new ImageIcon(this.getClass().getClassLoader().getResource("action-p.png"));
break;
case TreeElement.ICON_ACTIONEXISTENCE:
img = new ImageIcon(this.getClass().getClassLoader().getResource("action-e.png"));
break;
case TreeElement.ICON_ACTIONCATEGORY:
img = new ImageIcon(this.getClass().getClassLoader().getResource("action-l.png"));
break;
case TreeElement.ICON_GOAL:
img = new ImageIcon(this.getClass().getClassLoader().getResource("goal.png"));
break;
img = new ImageIcon(this.getClass().getClassLoader().getResource("mind.png")); // This is the default img if not found anyone else
for (int i=0;i<TreeElement.icon_table.length;i++) {
if (node.getIcon() == (int)TreeElement.icon_table[i][0])
img = new ImageIcon(this.getClass().getClassLoader().getResource((String)TreeElement.icon_table[i][1]));
}
setOpenIcon(img);
setClosedIcon(img);
Expand Down
35 changes: 35 additions & 0 deletions src/main/java/br/unicamp/cst/util/viewer/TreeElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package br.unicamp.cst.util.viewer;

import java.awt.Color;
import javax.swing.ImageIcon;

/**
* @author Suelen Mapa
Expand Down Expand Up @@ -85,6 +86,40 @@ public class TreeElement {
{ICON_ACTIONCATEGORY,0}, // 17 Action - Category
{ICON_GOAL,0}, // 18 Goal
};

public static Object[][] icon_table = {
{ICON_COMPOSITE, "object.png"},
{ICON_AGGREGATE, "object2.gif"},
{ICON_PROPERTY, "property.png"},
{ICON_QUALITYDIM, "qualityDim.png"},
{ICON_VALUE, "value.png"},
{ICON_MIND, "mind.png"},
{ICON_CODELET, "codelet.png"},
{ICON_CODELETS, "codelets.png"},
{ICON_MEMORY, "memory.png"},
{ICON_MEMORIES, "memories.png"},
{ICON_CONTAINER, "container.png"},
{ICON_MO, "mo.png"},
{ICON_INPUT, "input.png"},
{ICON_OUTPUT, "output.png"},
{ICON_BROADCAST, "broadcast.png"},
{ICON_AFFORDANCE, "codelet2.png"},
{ICON_OBJECT2, "object2.png"},
{ICON_OBJECT3, "object3.png"},
{ICON_CONFIGURATION, "configuration.png"},
{ICON_TIME, "time-machine.png"},
{ICON_PROPERTYCATEGORY, "propertyCategory.png"},
{ICON_OBJECTCATEGORY, "objectCategory.png"},
{ICON_EPISODECATEGORY, "episodeCategory.png"},
{ICON_PROPERTYPOSSIBILITY, "property-p.png"},
{ICON_OBJECTPOSSIBILITY, "object-p.png"},
{ICON_EPISODEPOSSIBILITY, "episode-p.png"},
{ICON_OBJECTEXISTENCE, "object-e.png"},
{ICON_ACTIONPOSSIBILITY, "action-p.png"},
{ICON_ACTIONEXISTENCE, "action-e.png"},
{ICON_ACTIONCATEGORY, "action-l.png"},
{ICON_GOAL, "goal.png"}
};

public TreeElement(String name, int node_type, Object element, int typeIcon) {
//this(name,node_type,element,typeIcon,0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,25 @@ public int compare(Object o1, Object o2)
else if(!te1.getName().startsWith("operator") && te2.getName().startsWith("operator")) return(-1);
else if (te1.getIcon() == TreeElement.ICON_GOAL && te2.getIcon() != TreeElement.ICON_GOAL) return(-1);
else if (te1.getIcon() != TreeElement.ICON_GOAL && te2.getIcon() == TreeElement.ICON_GOAL) return(1);
else if (te1.getIcon() == TreeElement.ICON_EPISODEPOSSIBILITY && te2.getIcon() != TreeElement.ICON_EPISODEPOSSIBILITY) return(-1);
else if (te1.getIcon() != TreeElement.ICON_EPISODEPOSSIBILITY && te2.getIcon() == TreeElement.ICON_EPISODEPOSSIBILITY) return(1);
else if (te1.getIcon() == TreeElement.ICON_AFFORDANCE && te2.getIcon() != TreeElement.ICON_AFFORDANCE) return(-1);
else if (te1.getIcon() != TreeElement.ICON_AFFORDANCE && te2.getIcon() == TreeElement.ICON_AFFORDANCE) return(1);
else if (te1.getIcon() == TreeElement.ICON_EPISODECATEGORY && te2.getIcon() != TreeElement.ICON_EPISODECATEGORY) return(-1);
else if (te1.getIcon() != TreeElement.ICON_EPISODECATEGORY && te2.getIcon() == TreeElement.ICON_EPISODECATEGORY) return(1);
else if (te1.getIcon() == TreeElement.ICON_OBJECTPOSSIBILITY && te2.getIcon() != TreeElement.ICON_OBJECTPOSSIBILITY) return(-1);
else if (te1.getIcon() != TreeElement.ICON_OBJECTPOSSIBILITY && te2.getIcon() == TreeElement.ICON_OBJECTPOSSIBILITY) return(1);
else if (te1.getIcon() == TreeElement.ICON_OBJECTEXISTENCE && te2.getIcon() != TreeElement.ICON_OBJECTEXISTENCE) return(-1);
else if (te1.getIcon() != TreeElement.ICON_OBJECTEXISTENCE && te2.getIcon() == TreeElement.ICON_OBJECTEXISTENCE) return(1);
else if (te1.getIcon() == TreeElement.ICON_OBJECTCATEGORY && te2.getIcon() != TreeElement.ICON_OBJECTCATEGORY) return(-1);
else if (te1.getIcon() != TreeElement.ICON_OBJECTCATEGORY && te2.getIcon() == TreeElement.ICON_OBJECTCATEGORY) return(1);
else if (te1.getIcon() == TreeElement.ICON_PROPERTYPOSSIBILITY && te2.getIcon() != TreeElement.ICON_PROPERTYPOSSIBILITY) return(-1);
else if (te1.getIcon() != TreeElement.ICON_PROPERTYPOSSIBILITY && te2.getIcon() == TreeElement.ICON_PROPERTYPOSSIBILITY) return(1);
else if (te1.getIcon() == TreeElement.ICON_PROPERTY && te2.getIcon() != TreeElement.ICON_PROPERTY) return(-1);
else if (te1.getIcon() != TreeElement.ICON_PROPERTY && te2.getIcon() == TreeElement.ICON_PROPERTY) return(1);
else if (te1.getIcon() == TreeElement.ICON_PROPERTYCATEGORY && te2.getIcon() != TreeElement.ICON_PROPERTYCATEGORY) return(-1);
else if (te1.getIcon() != TreeElement.ICON_PROPERTYCATEGORY && te2.getIcon() == TreeElement.ICON_PROPERTYCATEGORY) return(1);

else if (te1.getIcon() == te2.getIcon() ||
te1.getIcon() == TreeElement.ICON_OBJECT && te2.getIcon() == TreeElement.ICON_OBJECT2 ||
te1.getIcon() == TreeElement.ICON_OBJECT2 && te2.getIcon() == TreeElement.ICON_OBJECT) {
Expand Down

0 comments on commit 3b2c087

Please sign in to comment.