happyjack27 / autoredistrict

Programmatically makes a fair congressional district map (prevents gerrymandering)
GNU General Public License v3.0
89 stars 14 forks source link

major refactoring, + add class heirarchy doc #107

Open happyjack27 opened 8 years ago

happyjack27 commented 8 years ago

PROPOSED NEW ARCHITECTURE

Applet |-static MainFrame mainframe; |-static InstructionProcessor ip; |-static FeatureCollection featureCollection; |-static Ecology ecology; |-static LoadShapefile; <-- load shapefile threads |-static ThreadFactory; <-- other threads -static Core; <-- everything else from mainframe that's not ui-related

merge Feature and VTD classes into one.

move vertex and edge into geography package

remove JSonobject extension from edges and vertexes - just a memory waste

loading

load to hash hash to vector

getMinMaxXY featureCollection.initWards:

create vtd's and add to vtd vector
attempt set population
collect vertexes
collect edges
set feature.vtd.feature = feature
f.vtd.collectNieghbors
f.vtd.suncneighbors
f.vtd.collectneighbotlengths
f.calcarea
f.geometry.makePolysFull
if no neighbors, add nearest neighbor
find islands and link
unlock all wards

resetZoom() featureCollection.initEcology <--- merge into initWards ecology.wards = vtds; locked_wards = new boolean[vtds.size()]; for( int i = 0; i < locked_wards.length; i++) { locked_wards[i] = false; } addEcologyListeners(); <-- this should be on a constructor, probably mainframe's.

fillComboBoxes(); mapPanel.invalidate(); mapPanel.repaint();

setDistrictColumn(project.district_column); setEnableds(); project.demographic_columns.clear(); setDemographicColumns(); project.election_columns.clear(); setElectionColumns(); project.election_columns_2.clear(); setElectionColumns2(); project.election_columns_3.clear(); setElectionColumns3(); project.substitute_columns.clear(); setSubstituteColumns();

OBSOLETE (REMOVE)

initFeatures (and calling function)

CLASS HEIRARCHY

ui

Applet -MainFrame mainFrame -static MainFrame mainframe; -Project project = new Project(); -FeatureCollection featureCollection = new FeatureCollection();
-InstructionProcessor ip = new InstructionProcessor();
-MainFrame mainFrame;
-Vector instructions = new Vector();
-Vector instruction_history = new Vector();
-MapPanel mapPanel = new MapPanel();
-PanelSeats seatsPanel = new PanelSeats();
-FrameSeatsVotesChart frameSeatsVotesChart = new FrameSeatsVotesChart();
-DialogShowProperties df = new DialogShowProperties();
-JFrame frameGraph = new JFrame();
-PanelGraph panelGraph = new PanelGraph();
-JFrame frameStats = new JFrame();
-PanelStats panelStats = new PanelStats();

-DialogManageLocks manageLocks = new DialogManageLocks();

Threads in ui.MainFrame

FileThread

OpenShapeFileThread; OpenProjectFileThread (deprecated?) OpenGeoJsonFileThread

MergeInDemoAndElection(); (deprecated?) ImportCensus2Thread; ImportTranslations ImportCountyLevel ImportDemographics ImportVTDLevel ThreadFinishImport

ImportAggregateCustom

ExportCustomThread ExportToBlockLevelThread

LoadCensusFileThread (deprecated?) ImportGazzeterThread (deprecated)

OpenWKTFileThread WKTFileToCoordsThread (deprecated?)

CycleThread (deprecated)

FeatureCollection - Simple

FeatureCollection |-Features | |-Properties | |-Geometry | -VTD | |-Edge | -VTD (neighbors) -Ecology -DistrictMap -District -VTD

FeatureCollection - Detailed

FeatureCollection extends ReflectionJSONObject |-Vector features |-Vector vtds |-Ecology ecology |-HashMap<String,Quadruplet<String,Integer,Integer,Byte>> header_data -Vector locked_counties

Feature extends ReflectionJSONObject implements Comparable |-Properties properties |-Geometry geometry |-VTD vtd -Vector<double[]> points

Properties extends ReflectionJSONObject

Geometry extends ReflectionJSONObject |-String type; |-double[][][] coordinates; |-int[] xpolys; |-int[] ypolys; |-Polygon[] polygons; |-Polygon[] polygons_full; |-Color outlineColor = Color.BLACK; |-Color fillColor = FeatureCollection.DEFAULT_COLOR; |-boolean isDistrict = true; -double[] full_centroid;

VTD extends ReflectionJSONObject |-Feature feature |-Vector edges |-Vector neighbors |-Vector<Vector> -double[] demographics

Edge extends ReflectionJSONObject |-VTD ward1 = null; |-VTD ward2 = null; |-Vertex vertex1; |-Vertex vertex2; |-int id = -1; |-int ward1_id = -1; |-int ward2_id = -1; |-int vertex1_id = -1; |-int vertex2_id = -1; -double length;

Vertex extends ReflectionJSONObject |-int id; |-double x; -double y;

Ecology extends ReflectionJSONObject |-Vector population |-Vector swap_population |-HashMap<Integer,VTD> wards_by_id; |-Vector wards = new Vector(); |-Vector edges = new Vector(); -Vector vertexes = new Vector();

DistrictMap implements iEvolvable, Comparable |-Vector vtds = new Vector(); -Vector districts = new Vector();

District extends JSONObject -Vector vtds = new Vector();

jdbf

DBFReader / DBFWRiter |-JDBField -JDBFException

serialization

ReflectionJSONObject -JSONObject -iJSONObject

happyjack27 commented 8 years ago

finsished:

merge Feature and VTD classes into one.

move vertex and edge into geography package

remove JSonobject extension from edges and vertexes - just a memory waste

now just need to move things out of mainframe and into applet.