Skip to content

Commit

Permalink
Add documentation for GraphCanvas. Tentatively mark other graph drawi…
Browse files Browse the repository at this point in the history
…ng API-s for removal.
  • Loading branch information
FeldrinH committed Nov 25, 2023
1 parent 9a6cbe6 commit 85905c1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
2. Enne oma rekursiivse meetodi välja kutsumist kutsu välja `Dendrologist.wakeUp()`.
3. Käita programm ja aken rekursioonipuuga avaneb automaatselt.

Näide rekrusiivse Fibonacci arvude arvutamise meetodiga:
Näide rekrusiivse Fibonacci arvude arvutamise meetodiga (vt. [Katsed.java](src/test/java/Katsed.java)):
![image](https://github.com/Scytheface/dendroloj/assets/5256211/fe3ca679-a942-4e39-8611-f4c8536cdca4)

### Kahendpuude joonistamine
Expand All @@ -28,9 +28,19 @@ Näide rekrusiivse Fibonacci arvude arvutamise meetodiga:

(Kui tegemist ei ole kahendpuuga saab kasutada üldisemat meetodit `Dendrologist.drawTree`. Kasutuse kohta leiab lisainfot meetodi Javadoc kommentaarist.)

Näide kasutaja defineeritud Tipp klassiga:
Näide kasutaja defineeritud Tipp klassiga (vt. [TippKatsed.java](src/test/java/TippKatsed.java)):
![image](https://github.com/Scytheface/dendroloj/assets/5256211/04b18c0b-4281-4c06-b3df-2b12a55b8867)

### Graafide joonistamine

Graafide joonistamiseks saab kasutada klassi `GraphCanvas<V>`, kus `V` on joonistatava graafi tippude tüüp.
See klass toimib lõuendina, kuhu saab vastavate meetodite abil joonistada graafi servad ja tipud.
Lõuendi kuvamiseks kutsu välja meetod `Dendrologist.drawGraph(lõuend)`.

Lisainfot leiab `GraphCanvas` klassi ja vastavate meetodite _JavaDoc_ kommentaaridest.

Vaata ka näidet failis [GraafKatsed.java](src/test/java/GraafKatsed.java).

### Graafilise liidese kasutamine

Liigutades riba akna alumises servas saab vaadata väljakutsete puu ajalugu. Iga samm on kas üks meetodi väljakutse või üks tagastus meetodist.
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/ee/ut/dendroloj/Dendrologist.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ public static void drawGraph(GraphCanvas<?> graphCanvas) {
*
* @param adjacencyMatrix graph adjacency matrix; value at [i][j] is treated as the weight of the edge from vertex i to vertex j
* @param labels string labels for vertices; pass null to use vertex indices as labels
* @deprecated THIS API IS EXPERIMENTAL AND MAY EVENTUALLY BE REMOVED
*/
@Deprecated
public static void drawGraph(int[][] adjacencyMatrix, String[] labels) {
if (isHeadless()) {
System.err.println("Dendrologist: Running in headless environment. Ignoring call to drawGraph.");
Expand All @@ -175,7 +177,9 @@ public static void drawGraph(int[][] adjacencyMatrix, String[] labels) {
*
* @param adjacencyMatrix graph adjacency matrix; value at [i][j] is treated as the weight of the edge from vertex i to vertex j
* @param labels string labels for vertices; pass null to use vertex indices as labels
* @deprecated THIS API IS EXPERIMENTAL AND MAY EVENTUALLY BE REMOVED
*/
@Deprecated
public static void drawGraph(double[][] adjacencyMatrix, String[] labels) {
if (isHeadless()) {
System.err.println("Dendrologist: Running in headless environment. Ignoring call to drawGraph.");
Expand All @@ -201,7 +205,9 @@ public static void drawGraph(double[][] adjacencyMatrix, String[] labels) {
*
* @param adjacencyMatrix graph adjacency matrix; value at [i][j] is treated as the weight of the edge from vertex i to vertex j
* @param labels string labels for vertices; pass null to use vertex indices as labels
* @deprecated THIS API IS EXPERIMENTAL AND MAY EVENTUALLY BE REMOVED
*/
@Deprecated
public static void drawGraph(float[][] adjacencyMatrix, String[] labels) {
if (isHeadless()) {
System.err.println("Dendrologist: Running in headless environment. Ignoring call to drawGraph.");
Expand Down
1 change: 1 addition & 0 deletions src/test/java/GraafKatsed.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
public class GraafKatsed {

public static void main(String[] args) {
// Note: The API for drawing directly from an adjacency matrix is experimental and may eventually be removed.
String[] nimed = new String[]{
"A",
"B",
Expand Down

0 comments on commit 85905c1

Please sign in to comment.