This repository was archived by the owner on Jun 18, 2026. It is now read-only.
Commit c92e223
committed
refactor: extract EdgeType enum to eliminate edge-type if/else chains
Introduces EdgeType.java — a Java enum that centralises the five
relationship categories (Friend, Classmate, Familiar Stranger,
Stranger, Study Group) with their:
- File code strings ('f', 'fs', 'c', 's', 'sg')
- Display labels
- Colours
- Default duration/meeting thresholds
Refactored in Main.java:
- Edge classification in addGraph(): replaced 5-branch if/else
with EdgeType.fromCode() lookup + getEdgeList() helper
- Edge paint transformer: replaced 5-branch color if/else with
EdgeType.colorForCode() single call
- Vertex paint transformer: replaced 5 counter variables + 7-branch
if/else with Set<EdgeType> + iterator().next().getColor()
- getDominantLabel(): replaced 5-branch if/else with EdgeType lookup
- Stats panel & category panel label colours: replaced FRIEND_COLOR
etc. constants with EdgeType.FRIEND.getColor() etc.
- JSlider default values: replaced scattered threshold constants with
EdgeType.getDefaultDurationThreshold()/getDefaultMeetingThreshold()
Removed from Main.java:
- 5 colour constants (FRIEND_COLOR, FS_COLOR, etc.)
- 10 threshold constants (FRIEND_DUR_THRESHOLD, etc.)
- 5 fLabelled/fsLabelled/etc. boolean tracking fields
- Multiple cascading if/else chains (replaced by enum lookups)
New helpers in Main.java:
- getEdgeList(EdgeType): maps enum to the corresponding edge list
- isEdgeTypeVisible(String): maps type code to checkbox state
Net effect: -113 lines from Main.java, all edge-type knowledge
centralised in one enum. Adding a new relationship type now requires
adding one enum constant instead of editing 8+ places.1 parent 66f9110 commit c92e223
2 files changed
Lines changed: 174 additions & 113 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
0 commit comments