2828import com .brunomnsilva .smartgraph .graphview .SmartRadiusSource ;
2929import 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 ) {
0 commit comments