Skip to content

Commit a0b3a19

Browse files
committed
Javadoc fix and refactoring.
1 parent 00d41d4 commit a0b3a19

2 files changed

Lines changed: 47 additions & 9 deletions

File tree

src/main/java/com/brunomnsilva/smartgraph/example/City.java

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import com.brunomnsilva.smartgraph.graphview.SmartRadiusSource;
2929
import com.brunomnsilva.smartgraph.graphview.SmartShapeTypeSource;
3030

31+
import java.util.Objects;
32+
3133
/**
3234
* A simple class to represent a city in an example usage of the library.
3335
* @author brunomnsilva
@@ -37,7 +39,7 @@ public class City {
3739
private float population;
3840

3941
/**
40-
* City constructor
42+
* Constructor for City instances.
4143
* @param name name of the city
4244
* @param population population (in millions)
4345
*/
@@ -46,19 +48,35 @@ public City(String name, float population) {
4648
this.population = population;
4749
}
4850

51+
/**
52+
* Returns the name of the city.
53+
* @return the name of the city
54+
*/
4955
@SmartLabelSource
5056
public String getName() {
5157
return name;
5258
}
5359

60+
/**
61+
* Setter for the name of the city.
62+
* @param name the name of the city
63+
*/
5464
public void setName(String name) {
5565
this.name = name;
5666
}
5767

68+
/**
69+
* Returns the population of the city.
70+
* @return the population of the city
71+
*/
5872
public float getPopulation() {
5973
return population;
6074
}
6175

76+
/**
77+
* Setter for the population of the city.
78+
* @param population the population of the city
79+
*/
6280
public void setPopulation(float population) {
6381
this.population = population;
6482
}
@@ -67,19 +85,27 @@ public void setPopulation(float population) {
6785
public String toString() {
6886
return "City{" + "name=" + name + ", population=" + population + '}';
6987
}
70-
88+
89+
/**
90+
* Establishes the shape of the vertex to use when representing this city.
91+
* @return the name of the shape, see {@link com.brunomnsilva.smartgraph.graphview.ShapeFactory}
92+
*/
7193
@SmartShapeTypeSource
7294
public String modelShape() {
73-
if(this.name == "Tokyo") {
95+
if(Objects.equals(this.name, "Tokyo")) {
7496
return "star";
7597
}
7698

7799
return "circle";
78100
}
79101

102+
/**
103+
* Returns the radius of the vertex when representing this city.
104+
* @return the radius of the vertex
105+
*/
80106
@SmartRadiusSource
81107
public Double modelRadius() {
82-
return convertToLogScale(Double.valueOf(String.valueOf(this.population)));
108+
return convertToLogScale(Double.parseDouble(String.valueOf(this.population)));
83109
}
84110

85111
private static double convertToLogScale(double value) {

src/main/java/com/brunomnsilva/smartgraph/example/Distance.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,34 @@
3333
public class Distance {
3434
private int distance;
3535

36+
/**
37+
* Constructor for Distance instances.
38+
* @param distance the distance
39+
*/
3640
public Distance(int distance) {
3741
this.distance = distance;
3842
}
3943

44+
/**
45+
* Returns the distance.
46+
* @return the distance
47+
*/
4048
public int getDistance() {
4149
return distance;
4250
}
4351

52+
/**
53+
* Setter for the distance.
54+
* @param distance the distance.
55+
*/
4456
public void setDistance(int distance) {
4557
this.distance = distance;
4658
}
47-
59+
60+
/**
61+
* Establishes the text representation in the graph.
62+
* @return the text representation of the distance
63+
*/
4864
@SmartLabelSource
4965
public String getDisplayDistance() {
5066
/* If the above annotation is not present, the toString()
@@ -58,8 +74,4 @@ public String toString() {
5874
return "Distance{" + "distance=" + distance + '}';
5975
}
6076

61-
62-
63-
64-
6577
}

0 commit comments

Comments
 (0)