Skip to content
This repository was archived by the owner on Jun 18, 2026. It is now read-only.

refactor: centralize edge type metadata into EdgeTypeRegistry - #115

Merged
sauravbhattacharya001 merged 1 commit into
masterfrom
refactor/centralize-edge-type-registry
Mar 28, 2026
Merged

sauravbhattacharya001 merged 1 commit into
masterfrom
refactor/centralize-edge-type-registry

Conversation

@sauravbhattacharya001

Copy link
Copy Markdown
Owner

What

Extracts duplicated edge type metadata (names, hex colors, RGB colors) from individual exporters into a new \EdgeTypeRegistry\ utility class.

Why

Before this change, edge type → name/color mappings were copy-pasted across DotExporter, GexfExporter, GraphTimelineExporter, InteractiveHtmlExporter, and CsvReportExporter. Adding a new edge type required updating 5+ files — easy to miss one and end up with inconsistent colors or names.

Changes

  • New: \EdgeTypeRegistry.java\ — single source of truth for edge type codes, display names, hex colors, and RGB colors
  • Refactored: \DotExporter.java\ — removed \DEFAULT_TYPE_COLORS\ static block and \getTypeName()\ switch; now delegates to \EdgeTypeRegistry\
  • Refactored: \GexfExporter.java\ — removed \TYPE_COLORS\ static block; now uses \EdgeTypeRegistry.getRgbColor()\

Future

The remaining exporters (GraphTimelineExporter, InteractiveHtmlExporter) embed type metadata in inline JavaScript strings, which makes Java-side refactoring less clean. Those can be addressed in a follow-up.

Extract duplicated edge type names, hex colors, and RGB colors from
DotExporter and GexfExporter into a single EdgeTypeRegistry utility class.

Before: each exporter maintained its own copy of the type-to-name and
type-to-color mappings. Adding a new edge type required updating 5+ files.

After: single source of truth in EdgeTypeRegistry. Exporters delegate to
it via static methods (getName, getHexColor, getRgbColor).

Refactored:
- DotExporter: removed DEFAULT_TYPE_COLORS static block and getTypeName()
  switch statement, now uses EdgeTypeRegistry
- GexfExporter: removed TYPE_COLORS static block, now uses
  EdgeTypeRegistry.getRgbColor()
@github-actions github-actions Bot added visualization Graph visualization and UI size/m labels Mar 23, 2026
@sauravbhattacharya001
sauravbhattacharya001 merged commit 57aeb77 into master Mar 28, 2026
4 of 8 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size/m visualization Graph visualization and UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant