Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jgsteplujr authored and jgsteplujr committed Jun 11, 2017
0 parents commit 0717754
Show file tree
Hide file tree
Showing 8 changed files with 1,096 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Welcome to the Geometric Constructor

You can use this program to model compass-and-straightedge geometric constructions
Read more about it here: https://en.wikipedia.org/wiki/Compass-and-straightedge_construction

The program provides you with two fixed points to start the construction

You can use the following keyboard commands:

Select: Select or deselect entities by clicking on them
Delete: Delete selected entities

0 / H : Hide selected entities or show all
1 / P : Construct a new point on the intersection of two existing geometries
2 / C : Construct a circle on two existing points. First select the center point, then select the radius
3 / L : Construct a line on two existing points by selecting them

+ / - : Zoom in or out of view
Arrows: Pan the view

Made for the ICS3U programming course, June 2017

Source code at https://github.com/yuliu2016/geometryconstructor
43 changes: 43 additions & 0 deletions src/ca/wtcs/ics3u/gc/Const.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package ca.wtcs.ics3u.gc;


/*
* Created by Yu Liu on 2017-06-06
* ICS3U - Culminating Project - A compass-and-straightedge construction tool
*
* More information at https://github.com/yuliu2016/GeometryConstructor
*/


/**
* Contains all the constants used in this application
*
* @author Yu Liu
*/


class Const {

static final int DEFAULT_WIDTH = 600;

static final int DEFAULT_HEIGHT = 450;

static final int MINIMUM_WIDTH = 300;

static final int MINIMUM_HEIGHT = 300;

static final int PAN_RATE = 10;

static final double ZOOM_RATE = 1.05;

static final int FRAME_PERIOD = 15;

static final int POINT_DIAMETER = 10;

static final int POINT_OUTLINE = 14;

static final double MIN_ZOOM_RATIO = 0.2;

static final double MAX_ZOOM_RATIO = 5;

}
89 changes: 89 additions & 0 deletions src/ca/wtcs/ics3u/gc/Geometry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package ca.wtcs.ics3u.gc;


import java.awt.*;


/*
* Created by Yu Liu on 2017-06-06
* ICS3U - Culminating Project - A compass-and-straightedge construction tool
*
* More information at https://github.com/yuliu2016/GeometryConstructor
*/


/**
* <code>Geometry</code> is a top-level interface for
* all geometric entities used in this application. An
* object that implements this interface will be able to
* select/deselect , show/hide, and paint itself, and would
* also be able to add itself into a {@link GraphView}
*
* @author Yu Liu
* @see Geometry1D
*/


public interface Geometry {


/**
* Paints the geometry entity
* @param g the graphic context to be drawn on
* @param viewPort the viewport context to determine position
*/

void paint (Graphics g, ViewPort viewPort);


/**
* Determines if a mouse position is hovering over the geometry
* @param mouseX the X position of the mouse
* @param mouseY the Y position of the mouse
* @param viewPort the viewport context to determine position
* @return if the mouse is over geometry
*/

boolean isMouseOver(int mouseX, int mouseY, ViewPort viewPort);


/**
* Determines if the geometry is selected
* @return if the geometry is selected
*/

boolean isSelected();


/**
* Determines if the geometry is hidden
* @return if the geometry is hidden
*/

boolean isHidden();


/**
* Sets the hovered state of geometry
* @param hovered the hovered state of geometry
*/

void setHovered(boolean hovered);


/**
* Sets the selected state of geometry
* @param selected the selected state of geometry
*/

void setSelected(boolean selected);


/**
* Sets the hidden state of geometry
* @param hidden the hidden state of geometry
*/

void setHidden(boolean hidden);

}
23 changes: 23 additions & 0 deletions src/ca/wtcs/ics3u/gc/Geometry1D.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package ca.wtcs.ics3u.gc;


/*
* Created by Yu Liu on 2017-06-06
* ICS3U - Culminating Project - A compass-and-straightedge construction tool
*
* More information at https://github.com/yuliu2016/GeometryConstructor
*/


/**
* <code>Geometry1D</code> is a currently empty interface that represent
* a 1 dimensional object. Useful later when a geometry can only be a point
*
* @author Yu Liu
* @see Geometry
*/

interface Geometry1D
extends Geometry {

}
28 changes: 28 additions & 0 deletions src/ca/wtcs/ics3u/gc/GeometryConstructor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package ca.wtcs.ics3u.gc;


/*
* Created by Yu Liu on 2017-06-06
* ICS3U - Culminating Project - A compass-and-straightedge construction tool
*
* More information at https://github.com/yuliu2016/GeometryConstructor
*/


/**
* Contains the wrapper main method to initiate a GraphView
*
* @author Yu Liu
* @see GraphView
*/


public class GeometryConstructor {

public static void main(String[] args) {

new GraphView();

}

}
Loading

0 comments on commit 0717754

Please sign in to comment.