diff --git a/Hello_World_Tutorials/Java_SLL.html b/Hello_World_Tutorials/Java_SLL.html index 3f143ce5a..193180d2b 100644 --- a/Hello_World_Tutorials/Java_SLL.html +++ b/Hello_World_Tutorials/Java_SLL.html @@ -4,10 +4,10 @@
+import bridges.connect.Bridges; import bridges.base.SLelement; -+
Bridges<String, String> bridge = new Bridges<>(1, "YOUR_API_KEY", "YOUR_USER_ID");- Note that you will need to replace the two fields in this call with your BRIDGES credentials.
-
- SLelement<String> e0 = new SLelement<>("Hello", ""); - SLelement<String> e1 = new SLelement<>("World", ""); - SLelement<String> e2 = new SLelement<>("!", ""); -+
Bridges<String, StudentInfo> bridges = new Bridges<>(1, "YOUR_API_KEY", "YOUR_USER_ID");+ In the above call, the parameter 1 is the assignment id (can be any + positive integer), and the remaining two parameters are your BRIDGES + credentials. You will need to replace the two fields in this call + with your own BRIDGES credentials.
+
+SLelementel0 = new SLelement ( "", + new StudentInfo( + "00000000000", + "Gretel Chaney", + "CS", + "g.chaney@generated.com", + "magenta", + "blue", + 9.0, + "https://randomuser.me/api/portraits/med/women/45.jpg" + )); +SLelement el1 = new SLelement ( "", + new StudentInfo( + "00000000001", + "Karol Soderman", + "SIS", + "k.soderman@generated.com", + "magenta", + "red", + 11.0, + "https://randomuser.me/api/portraits/med/women/46.jpg" + )); +SLelement el2 = new SLelement ( "", + new StudentInfo( + "00000000002", + "Lamont Kyler", + "BIO", + "l.kyler@generated.com", + "yellow", + "green", + 12.0, + "https://randomuser.me/api/portraits/med/men/80.jpg" + )); +SLelement el3 = new SLelement ( "", + new StudentInfo( + "00000000003", + "Gladys Serino", + "CS", + "g.serino@generated.com", + "blue", + "magenta", + 9.0, + "https://randomuser.me/api/portraits/med/women/2.jpg" + )); +SLelement el4 = new SLelement ( "", + new StudentInfo( + "00000000004", + "Starr Mcginn", + "CS", + "s.mcginn@generated.com", + "red", + "yellow", + 15.0, + "https://randomuser.me/api/portraits/med/men/87.jpg" + )); +
- e0.setNext(e1); - e1.setNext(e2); --
bridge.setDataStructure(e0);-
bridge.visualize();+
+e0.setNext(e1); +e1.setNext(e2); +e2.setNext(e3); +e3.setNext(e4); ++
+SLelement+currentElement = el0; +while(currentElement != null){ + System.out.println(currentElement.getValue().getFullName()); + + // color the node + currentElement.getVisualizer().setColor(currentElement.getValue().getFavoriteColor()); + + // color the link between two successive element, + // change the link thickness + if(currentElement.getNext() != null){ + currentElement.getLinkVisualizer(currentElement.getNext()) + .setColor(currentElement.getValue().getDislikeColor()); + + currentElement.getLinkVisualizer(currentElement.getNext()) + .setThickness(currentElement.getValue().getStudentCreditHours() * 0.75);//75 percent thinner + } + + // set the label of the element to print student info + currentElement.setLabel( + currentElement.getValue().getFullName() + "\n"+ + "Email: " + currentElement.getValue().getEmail() + "\n" + + "Program: " + currentElement.getValue().getProgram() + "\n" + + "Student ID: " + currentElement.getValue().getStudentID() + "\n" + + "Favorite Color: " + currentElement.getValue().getFavoriteColor() + "\n" + ); + currentElement = currentElement.getNext(); +} +
bridge.setDataStructure(el0);+
bridge.visualize();+ +
+public class StudentInfo { + private String studentID, fullName, program, email, dislikeColor, favoriteColor, avatar; + private double studentCreditHours; + + public StudentInfo(String studentID, String fullName, String program, String email, String dislikeColor, + String favoriteColor, double studentCreditHours, String avatar) { + this.studentID = studentID; + this.fullName = fullName; + this.program = program; + this.email = email; + this.dislikeColor = dislikeColor; + this.favoriteColor = favoriteColor; + this.studentCreditHours = studentCreditHours; + this.avatar = avatar; + } + public String getStudentID() { + return studentID; + } + public void setStudentID(String studentID) { + this.studentID = studentID; + } + public String getFullName() { + return fullName; + } + public void setFullName(String fullName) { + this.fullName = fullName; + } + public String getProgram() { + return program; + } + public void setProgram(String program) { + this.program = program; + } + + public String getEmail() { + return email; + } + public void setEmail(String email) { + this.email = email; + } + public String getFavoriteColor() { + return favoriteColor; + } + public void setFavoriteColor(String favoriteColor) { + this.favoriteColor = favoriteColor; + } + public String getAvatar() { + return avatar; + } + public void setAvatar(String avatar) { + this.avatar = avatar; + } + public String getDislikeColor() { + return dislikeColor; + } + public void setDislikeColor(String dislikeColor) { + this.dislikeColor = dislikeColor; + } + public double getStudentCreditHours() { + return studentCreditHours; + } + public void setStudentCreditHours(double studentCreditHours) { + this.studentCreditHours = studentCreditHours; + } +} +-
- import bridges.connect.Bridges; - import bridges.base.SLelement; - - public class HelloWorld - { - public static void main(String[] args) throws Exception - { - //create the Bridges object - Bridges<String,String> bridge = new Bridges<>(1, "YOUR_API_KEY", "YOUR_USER_ID"); - - //create elements - SLelement<String> e0 = new SLelement<>("Hello", ""); - SLelement<String> e1 = new SLelement<>("World", ""); - SLelement<String> e2 = new SLelement<>("!", ""); - - //link elements - e0.setNext(e1); - e1.setNext(e2); - - //pass first element of data structure - bridge.setDataStructure(e0); - - //visualize data structure - bridge.visualize(); - } - } -