summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CSVReader.java5
-rw-r--r--src/ComparisonView.java6
-rw-r--r--src/FontFamily.java55
-rw-r--r--src/JSONReader.java25
-rw-r--r--src/LineGraph.java10
-rw-r--r--src/Reader.java2
6 files changed, 84 insertions, 19 deletions
diff --git a/src/CSVReader.java b/src/CSVReader.java
index e4af4df..3e1cd8f 100644
--- a/src/CSVReader.java
+++ b/src/CSVReader.java
@@ -10,7 +10,7 @@ import java.util.Arrays;
* References:
*
* Date:
- * 2024-04-28
+ * 2024-05-08
*
* Purpose of class:
* Read from and interpret CSV files.
@@ -28,6 +28,9 @@ public class CSVReader extends Reader {
parse();
}
+ /*
+ * Parse CSV file.
+ */
public void parse() {
String[] lines = this.getContents().split("\n");
this.header = lines[0].split(",");
diff --git a/src/ComparisonView.java b/src/ComparisonView.java
index 631c718..1075abd 100644
--- a/src/ComparisonView.java
+++ b/src/ComparisonView.java
@@ -12,7 +12,7 @@ import java.awt.*;
* https://stackoverflow.com/questions/4871051/how-to-get-the-current-working-directory-in-java
*
* Date:
- * 2024-04-28
+ * 2024-05-08
*
* Purpose of class:
* Provide a view for comparing font families.
@@ -76,10 +76,12 @@ public class ComparisonView extends JFrame {
for (File file : metadataList) {
System.out.println(file.getPath());
}
+
+ new CSVReader(new File("families.csv"));
+ new JSONReader(new File("popularity.json"));
}
public static void main(String[] argv) {
new ComparisonView();
- new CSVReader(new File("families.csv"));
}
}
diff --git a/src/FontFamily.java b/src/FontFamily.java
index 54e174f..8e32f05 100644
--- a/src/FontFamily.java
+++ b/src/FontFamily.java
@@ -8,28 +8,63 @@ import java.util.HashMap;
* References:
*
* Date:
- * 2024-04-28
+ * 2024-05-08
*
* Purpose of class:
* Store and operate on font family metadata.
*/
public class FontFamily {
- /* The directory containing the associated METADATA.pb */
- private String directoryName;
+ /* JSONReader from which metadata is pulled. */
+ private JSONReader metadata;
/* Taken from first line of METADATA.pb */
private String familyName;
/* Taken from fonts/tags/all/families.csv */
- private ArrayList<String> styles;
+ private HashMap<String,Integer> styles;
/* Taken from top level of METADATA.pb */
private String dateAdded;
- /* Average glyph count of every font file specified in METADATA.pb */
- private int glyphCount;
- /* Average file size of every font file specified in METADATA.pb */
- private int fileSize;
- /* Author from METADATA.pb */
- private String author;
+ /* Languages supported. */
+ private String[] languages;
+ private String designer;
/* total views, 7day views, 30day views, 90day views, year views.
Taken from popularity.json. */
private HashMap<String,Long> views;
+ private String license;
+ private String category;
+ /* popularity.json and families.csv are shared among all families.
+ Have their associated objects passed from outside. */
+
+ /*
+ * Constructor.
+ */
+ public FontFamily(JSONReader metadata, JSONReader popularity, CSVReader styles) {
+ this.metadata = metadata;
+ parseMetadata(metadata);
+ parsePopularity(popularity);
+ parseStyles(styles);
+ }
+
+ /*
+ * Parse metadata.
+ */
+ private void parseMetadata(JSONReader metadata) {
+ familyName = metadata.get("name");
+ dateAdded = metadata.get("date_added");
+ languages = metadata.getAll("languages");
+ designer = metadata.get("designer");
+ license = metadata.get("license");
+ category = metadata.get("category");
+ }
+
+ /*
+ * Parse popularity.
+ */
+ private void parsePopularity(JSONReader popularity) {
+ }
+
+ /*
+ * Parse styles.
+ */
+ private void parseStyles(CSVReader styles) {
+ }
}
diff --git a/src/JSONReader.java b/src/JSONReader.java
index 52edf3a..786b2a1 100644
--- a/src/JSONReader.java
+++ b/src/JSONReader.java
@@ -1,3 +1,4 @@
+import java.util.HashMap;
import java.io.*;
/*
@@ -5,10 +6,9 @@ import java.io.*;
* Kian Agheli
*
* References:
- * https://jqlang.github.io/jq/manual/
*
* Date:
- * 2024-04-28
+ * 2024-05-08
*
* Purpose of class:
* Read from and interpret JSON files.
@@ -19,8 +19,25 @@ public class JSONReader extends Reader {
super(file);
}
- /* Something akin to jq's field selection. */
- public String getField(String field) {
+ /*
+ * Search for and return the first
+ * match.
+ */
+ public String get(String field) {
+ return null;
+ }
+
+ /*
+ * Search for and return all matches.
+ */
+ public String[] getAll(String field) {
+ return null;
+ }
+
+ /*
+ * Search for and return a table of fields.
+ */
+ public String getTable(HashMap<String,String> name) {
return null;
}
}
diff --git a/src/LineGraph.java b/src/LineGraph.java
index b9642fb..b698462 100644
--- a/src/LineGraph.java
+++ b/src/LineGraph.java
@@ -7,7 +7,7 @@ import javax.swing.*;
* References:
*
* Date:
- * 2024-04-28
+ * 2024-05-08
*
* Purpose of class:
* Draw a line graph.
@@ -15,10 +15,18 @@ import javax.swing.*;
public class LineGraph {
int[][] coordinates; // A line graph has-a set of coordinates
+
+ /*
+ * Constructor.
+ */
public LineGraph() {
coordinates = null;
}
+
+ /*
+ * Set a point at a pair of coordinates.
+ */
void setCoordinates(int y, int x) {
}
}
diff --git a/src/Reader.java b/src/Reader.java
index 80e795d..8c3caf8 100644
--- a/src/Reader.java
+++ b/src/Reader.java
@@ -8,7 +8,7 @@ import java.util.Scanner;
* References:
*
* Date:
- * 2024-04-28
+ * 2024-05-08
*
* Purpose of class:
* Read from a file.