-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding(still) files used to all tutorials.
- Loading branch information
Showing
8 changed files
with
579 additions
and
424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,318 +80,20 @@ <h3>Here's the final code:</h3> | |
<div class="panel-body"> | ||
<div class="tab-content"> | ||
<div class="tab-pane fade in active" id="tab1"> | ||
<pre class="prettyprint"> | ||
package cdllist; | ||
/** | ||
* Created by Lucas Estrella on 1/31/2017. | ||
* [email protected] | ||
*/ | ||
import bridges.base.CircDLelement; | ||
import bridges.connect.Bridges; | ||
import model.Student; | ||
import provider.StudentProvider; | ||
|
||
public class Main { | ||
|
||
public static void main(String[] args) throws , ParseException { | ||
|
||
Bridges<String, Student> bridge = new Bridges<String, Student>(4, "YOUR_API_KEY", "YOUR_USER_ID"); | ||
|
||
/** | ||
* new CircDLelement<>(label, genericData) | ||
*/ | ||
//initializing all elements with empty labels, and with the student data. See Object model.Student.java | ||
CircDLelement<Student> el0 = null; | ||
for(int i = 0; i < StudentProvider.getStudents().length; i++) { | ||
if(i > 0) { | ||
el0 = insertFront(el0, new CircDLelement("",StudentProvider.getStudentAt(i))); | ||
}else{ | ||
el0 = new CircDLelement("",StudentProvider.getStudentAt(i)); | ||
} | ||
} | ||
|
||
CircDLelement<Student> current = el0; | ||
do{ | ||
current.setLabel(current.getValue().getStudentLabel()); | ||
current.getVisualizer().setColor(current.getValue().getFavoriteColor()); | ||
|
||
current.getLinkVisualizer(current.getNext()).setColor(current.getValue().getDislikeColor()); | ||
current.getLinkVisualizer(current.getNext()).setThickness(current.getValue().getStudentCreditHours()*.75); | ||
|
||
current.getLinkVisualizer(current.getPrev()).setColor(current.getValue().getDislikeColor()); | ||
current.getLinkVisualizer(current.getPrev()).setThickness(current.getValue().getStudentCreditHours()*.75); | ||
|
||
current = current.getNext(); | ||
}while(current.getIdentifier() != el0.getIdentifier()); | ||
|
||
bridge.setDataStructure(el0); | ||
bridge.visualize(); | ||
|
||
|
||
} | ||
|
||
|
||
public static CircDLelement insertFront(CircDLelement tailElement, | ||
CircDLelement newElement){ | ||
CircDLelement tailNextElement = tailElement.getNext(); | ||
|
||
newElement.setNext(tailNextElement); | ||
newElement.setPrev(tailElement); | ||
|
||
tailNextElement.setPrev(newElement); | ||
tailElement.setNext(newElement); | ||
return tailElement; | ||
} | ||
} | ||
</pre> | ||
<pre w3-include-html="tutorial-source-code/cdllist.java" class="prettyprint"></pre> | ||
</div> | ||
<div class="tab-pane fade" id="tab2"> | ||
<pre class="prettyprint"> | ||
package model; | ||
|
||
/** | ||
* Created by Lucas Estrella on 1/31/2017. | ||
*/ | ||
public class Student { | ||
private String studentID, | ||
fullName, | ||
program, | ||
email, | ||
dislikeColor, | ||
favoriteColor, | ||
avatar; | ||
|
||
private boolean visited; | ||
|
||
public boolean isVisited() { | ||
return visited; | ||
} | ||
|
||
public void setVisited(boolean visited) { | ||
this.visited = visited; | ||
} | ||
|
||
private double studentCreditHours; | ||
|
||
/** | ||
* @param studentID | ||
* @param fullName | ||
* @param program | ||
* @param email | ||
*/ | ||
public Student(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; | ||
} | ||
|
||
/** | ||
* @return studentID | ||
*/ | ||
public String getStudentID() { | ||
return studentID; | ||
} | ||
|
||
/** | ||
* @param studentID | ||
*/ | ||
public void setStudentID(String studentID) { | ||
this.studentID = studentID; | ||
} | ||
|
||
/** | ||
* @return fullName | ||
*/ | ||
public String getFullName() { | ||
return fullName; | ||
} | ||
|
||
/** | ||
* @param fullName | ||
*/ | ||
public void setFullName(String fullName) { | ||
this.fullName = fullName; | ||
} | ||
|
||
/** | ||
* @return program | ||
*/ | ||
public String getProgram() { | ||
return program; | ||
} | ||
|
||
/** | ||
* @param program | ||
*/ | ||
public void setProgram(String program) { | ||
this.program = program; | ||
} | ||
|
||
/** | ||
* @return email | ||
*/ | ||
public String getEmail() { | ||
return email; | ||
} | ||
|
||
/** | ||
* @param email | ||
*/ | ||
public void setEmail(String email) { | ||
this.email = email; | ||
} | ||
|
||
|
||
/** | ||
* @return favoriteColor | ||
*/ | ||
public String getFavoriteColor() { | ||
return favoriteColor; | ||
} | ||
|
||
/** | ||
* @param 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; | ||
} | ||
|
||
public String getStudentLabel() { | ||
String $label = | ||
fullName + "\n" + | ||
"Email: " + email + "\n" + | ||
"Program: " + program + "\n" + | ||
"Student ID: " + studentID + "\n" + | ||
"Favorite Color: " + favoriteColor + "\n"; | ||
|
||
if(avatar != null) | ||
$label += "<img width='100' src='" + avatar + "'/>"; | ||
|
||
|
||
return $label; | ||
} | ||
} | ||
|
||
</pre> | ||
<div class="tab-pane fade" id="tab2"> | ||
<pre w3-include-html="tutorial-source-code/Student.java" class="prettyprint"></pre> | ||
</div> | ||
<div class="tab-pane fade" id="tab3"> | ||
<pre class="prettyprint"> | ||
package provider; | ||
|
||
import model.Student; | ||
|
||
/** | ||
* Created by Lucas Estrella on 2/2/2017. | ||
*/ | ||
public class StudentProvider { | ||
|
||
/** | ||
* @param index | ||
* @return student at index | ||
*/ | ||
public static Student getStudentAt(int index){ | ||
if(index >= students.length){ | ||
throw new NullPointerException(); | ||
} | ||
return students[index]; | ||
} | ||
|
||
/** | ||
* @return all students | ||
*/ | ||
public static Student[] getStudents(){ | ||
return students; | ||
} | ||
|
||
private static Student[] students = { | ||
new Student( | ||
"00000000000", | ||
"Gretel Chaney", | ||
"CS", | ||
"[email protected]", | ||
"magenta", | ||
"blue", | ||
9.0, | ||
"https://randomuser.me/api/portraits/med/women/45.jpg" | ||
), | ||
new Student( | ||
"00000000001", | ||
"Karol Soderman", | ||
"SIS", | ||
"[email protected]", | ||
"magenta", | ||
"red", | ||
11.0, | ||
"https://randomuser.me/api/portraits/med/women/46.jpg" | ||
), | ||
new Student( | ||
"00000000002", | ||
"Lamont Kyler", | ||
"BIO", | ||
"[email protected]", | ||
"yellow", | ||
"green", | ||
12.0, | ||
"https://randomuser.me/api/portraits/med/men/80.jpg" | ||
), | ||
new Student( | ||
"00000000003", | ||
"Gladys Serino", | ||
"CS","[email protected]", | ||
"blue", | ||
"magenta", | ||
9.0, | ||
"https://randomuser.me/api/portraits/med/women/2.jpg" | ||
), | ||
new Student("00000000004", | ||
"Starr Mcginn", | ||
"CS", | ||
"[email protected]", | ||
"red", | ||
"yellow", | ||
15.0, | ||
"https://randomuser.me/api/portraits/med/men/87.jpg") | ||
}; | ||
} | ||
|
||
</pre> | ||
<div class="tab-pane fade" id="tab3"> | ||
<pre w3-include-html="tutorial-source-code/StudentProvider.java" class="prettyprint"></pre> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
<script> | ||
w3IncludeHTML(); | ||
</script> |
Oops, something went wrong.