Skip to content

ohmygodjustload/StarMap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Star Map

CS 220 – Software Design II class project.

Overview

This project implements a Java program that reads astronomical data from text files, renders a 2D star map using Swing graphics, draws constellations by connecting stars, and outputs computed star data in both text and binary formats.

The program visualizes stars based on real catalog data, scales their size according to brightness (magnitude), translates coordinates between astronomical and screen coordinate systems, and overlays constellation line segments using consistent coloring.

Purpose

The purpose of this project is to practice:

  • Object-oriented design using inheritance and composition
  • File I/O (text and binary)
  • Coordinate system translation
  • Basic 2D graphics using Java Swing
  • Managing structured data across multiple classes

Project Structure

project-root/
├── src/
│   ├── Line.java
│   ├── Oval.java
│   └── StarMap.java
├── data/
│   ├── stars.txt
│   └── constellations.txt

Core Classes

Line

A reusable Swing component for drawing straight line segments.

  • Extends JComponent
  • Supports configurable thickness
  • Draws a line between two absolute window coordinates
  • Automatically computes bounding box based on endpoints

Used to render constellation connections between stars.

Oval

A reusable Swing component for drawing filled ovals.

  • Extends JComponent
  • Draws a filled oval within its bounding rectangle
  • Provides simple intersection and point-intersection helpers

Used as the graphical base class for drawing stars.

StarMap

The main application class.

Responsibilities:

  • Creates and configures the application window (JFrame)
  • Reads star catalog data from stars.txt
  • Reads constellation definitions from constellations.txt
  • Displays stars and constellation lines
  • Writes computed star data to output files

The main method and constructor are provided and must not be modified.

Data Files

stars.txt

Each line represents a single star. Fields are space-separated.

Format:

x y z hd magnitude hr [optional names]
  • x, y, z: Star catalog coordinates (range −1.0 to 1.0)
  • hd: Henry Draper number (unique identifier)
  • magnitude: Apparent brightness
  • hr: Harvard Revised number
  • names (optional): Semicolon-separated star names

Only the x, y, magnitude, and identifiers are required for rendering.

constellations.txt

Defines constellations as named groups of line segments.

  • Lines beginning with # indicate the start of a new constellation
  • Each following line lists two star names separated by a comma
  • Each pair defines one line segment to draw between two stars

Each constellation is drawn using a single color. Different constellations use different colors.

Coordinate Systems

Star Catalog Coordinate System

  • Origin (0, 0) at center
  • X and Y range from -1.0 to 1.0

Window Coordinate System

  • Origin (0, 0) at top-left of drawing region
  • X increases to the right
  • Y increases downward

Stars must be translated from catalog coordinates to window coordinates before drawing.

Star Rendering

  • Each star is drawn as a filled circle
  • Star size is determined by magnitude using:
size = 1 + round(10.0 / (magnitude + 2.0))
  • The computed size is used as both width and height
  • The star’s window coordinate represents its center; the oval position must be offset accordingly

Constellation Rendering

  • Each constellation is assigned a distinct color
  • Lines are drawn between stars using the Line component
  • All lines for a constellation share the same color

Output Files

After rendering, the program writes star data to two files:

Text Output (.txt)

  • One line per star
  • Space-separated values

Written attributes (in order):

  1. Original x coordinate
  2. Original y coordinate
  3. Window x coordinate
  4. Window y coordinate
  5. Original magnitude
  6. Display size (diameter)
  7. Henry Draper number

Binary Output (.bin)

The same data as the text file, written in binary form:

  • double: original x
  • double: original y
  • int: window x
  • int: window y
  • double: magnitude
  • int: display size
  • int: Henry Draper number

Stars are written in the same order as they appear in stars.txt.

Notes

  • The drawing region is square and configurable via command-line arguments
  • The program must work with any valid star and constellation data files that follow the documented formats
  • Additional helper classes and methods may be added as needed

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages