- Saved searches
- Use saved searches to filter your results more quickly
- kamit28/ASCIIDraw
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- Saved searches
- Use saved searches to filter your results more quickly
- bobbui/console-drawing
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- Console Drawing Board
- Prerequisite
- Program Structure
- Demonstration
- Conclusion
- History
- Reference
- Saved searches
- Use saved searches to filter your results more quickly
- scorpionaps/ConsoleDrawing
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
A simple console drawing program
kamit28/ASCIIDraw
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Description
This is a simple console drawing program in Java.
The program works as follows:
Below is a sample run of the program. User input is prefixed with enter command:
enter command: C 20 4 -------------------- | | | | | | | | -------------------- enter command: L 1 2 6 2 -------------------- | | |xxxxxx | | | | | -------------------- enter command: L 6 3 6 4 -------------------- | | |xxxxxx | | x | | x | -------------------- enter command: R 14 1 18 3 -------------------- | xxxxx| |xxxxxx x x| | x xxxxx| | x | -------------------- enter command: B 10 3 o -------------------- |oooooooooooooxxxxx| |xxxxxxooooooox x| | xoooooooxxxxx| | xoooooooooooo| -------------------- enter command: L 6 4 13 4 -------------------- |oooooooooooooxxxxx| |xxxxxxooooooox x| | xoooooooxxxxx| | xxxxxxxxooooo| -------------------- enter command: B 1 2 . -------------------- |oooooooooooooxxxxx| |. ooooooox x| | .oooooooxxxxx| | . ooooo| -------------------- enter command: Q
Build To build the executable Jar, run the following maven command in the project root directory: $ mvn clean package
It will create a jar ASCIIDraw.jar in /target directory.
Run To run the program: $ java -jar ASCIIDraw.jar
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
A simple, fun program to draw on console.
bobbui/console-drawing
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
A simple, fun program to draw on console.
The program was built using Java 8 and Maven
Command Description C w h Create a new canvas of width w and height h. L x1 y1 x2 y2 Create a new line of 'x' from (x1,y1) to (x2,y2). Only support horizontal or vertical lines. R x1 y1 x2 y2 Create a new rectangle, (x1,y1) is upper left corner & (x2,y2) is lower right corner. B x y c Fill the entire area around (x,y) with "colour" c. Same as that of the "bucket fill" tool in paint programs. Q Quit.
enter command: C 20 4 ---------------------- | | | | | | | | ---------------------- enter command: L 1 2 6 2 ---------------------- | | |xxxxxx | | | | | ---------------------- enter command: L 6 3 6 4 ---------------------- | | |xxxxxx | | x | | x | ---------------------- enter command: R 14 1 18 3 ---------------------- | xxxxx | |xxxxxx x x | | x xxxxx | | x | ---------------------- enter command: B 10 3 o ---------------------- |oooooooooooooxxxxxoo| |xxxxxxooooooox xoo| | xoooooooxxxxxoo| | xoooooooooooooo| ----------------------
- From prebuilt JAR: java -jar console-drawing-1.0.jar
- From source:
- Run program: mvn exec:java
- Test: mvn test
- Create JAR: mvn package
Console Drawing Board
A drawing board is a kind of desk which can be used for any kind of drawing, writing or sketching on a sheet of paper. This program, console drawing board, is a Java program that provide a console interface and enable you to draw several figures, including rectangles and triangles.
Prerequisite
Program Structure
- BufferReader (br) which is reponsible for taking inputs from the user with readLine function
- String (in) which is the input string
- PrintWriter (pw) which prints program messages
- ScreenManager (sm) which manages and plots the figures of the drawing board
- Drawing: the user can draw a rectangle by specifying the width, height, the center of x, and the center of y or a triangle by providing the three vertices.
- Erasing: the user can erase any drawn figure.
- Centering: the user can center any drawn figure.
- Example: there is a robot thread that trigger key board events to show the exmaple usage of this program.
- Exit: exit this program
sm.printScreen(); while (true) pw.printf("Welcome to the drawing board !\n1.draw\n2.erase\n3.center\n4.example\n5.exit : "); try in = br.readLine(); if (in.equals("5")) break; > catch (IOException e) e.printStackTrace(); continue; > switch (in) case "1": draw(); break; case "2": erase(); break; case "3": center(); break; case "4": example(); break; default: pw.printf("Wrong entry number : %s\n", in); break; > >
ScreenManager keeps the information of the drawn Figure in an ArrayList fgs on the drawing board and the information of the grid in an array db with the size of 50 * 50.
public class ScreenManager public ScreenManager() pw = new PrintWriter(System.out, true); db = new int[2500]; fgs = new ArrayListFigure>(); > public void draw(int x,int y) db[x+50*y]++; > public void erase(int x,int y) db[x+50*y]--; > public void addFig(Figure fg) fgs.add(fg); fg.draw(this); > public void delFig(Figure fg) fgs.remove(fg); fg.erase(this); > public ArrayListFigure> getFigList() return fgs; > public void printScreen() pw.print('+'); for (int i = 0;i50;i++)pw.print((char)('-'+65248)); pw.println('+'); for (int i = 0; i db.length; i++) if(i%50==0)pw.print('|'); if(db[i]>0)pw.print((char)('*'+65248)); else pw.print((char)12288); if ((i+1)%50==0) pw.println('|'); > pw.print('+'); for (int i = 0;i50;i++)pw.print((char)('-'+65248)); pw.println('+'); > protected ArrayListFigure> fgs; protected PrintWriter pw; protected int[] db; >
public abstract class Figure extends Component public Figure() centerPoint = new Point( 0, 0); name = "None"; > public Figure(String n,Point p) centerPoint = new Point(p); name = new String(n); > abstract public void draw(ScreenManager sm); abstract public void erase(ScreenManager sm); abstract public void center(ScreenManager sm); abstract public void showDetail(PrintWriter pw); public String getName() return name; > protected Point centerPoint; protected String name; /** * */ private static final long serialVersionUID = 1L; >
Demonstration
Conclusion
This simple console board drawing program can provide a basic template for more sophisticated console plotting program.
History
Reference
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Console Drawing in Java, SpringBoot
scorpionaps/ConsoleDrawing
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Console Drawing Java Application
This is Shape Drawing Application for Console, developed in java and SpringBoot Framework. It is developed with MVC design pattern At this time, the functionality of the program is quite limited but this might change in the future. In a nutshell, the program should work as follows:
- Create a new canvas
- Start drawing on the canvas by issuing various commands
- Quit
Please follow below instructions to get a copy of the project up and running on your local machine for development and testing purposes.
- Java/JDK version 1.8 or above should be installed in local machine.
- If Porject needs to be cloned from github then Git needs to insatlled in local machine.
- To review the Code, any Java development IDE is recommended to installed in local machine.
- For running the application code or Test Module via command Line, Mavan needs to installed in you local Machine.
- Application and Test module can be executed from development IDE as well
- As per Requirements, commands for action should always be given in CAPS
- As per Requirements, Diagnol Lines are not allowed to be made.
- Bucket Fill for already painted shape is not considered.
A step by step series of examples that tell you how to get a development env running
- Clone the project from gitHub repository GitHub Link
- Copy/Download the zip Project from Dropbox [DropBox Link] (https://www.dropbox.com/s/2rmqkrffhwybw9e/AnandPratapSingh.zip?dl=0)
- Open Developemt IDE for Code Review and Run, Import «Exisitng Maven Project» into your local workspace.
1. From Command Line: Go to Project root folder--> Run "mvn test" 2. From IDE: Select Mavan Build/Run config, select Project root as Base Directory. Set goal as "test". Click on Run(Assumption, JRE is configured correctly) 3. From IDE: Select "/consoleDrawing/src/test/java" and run as Junit Test.
1. From Command Line: Go to Project /consoleDrawing/target folder--> Run java -jar consoleDrawing-1.0.jar 2. From IDE: Select Mavan Build/Run config, select Project root as Base Directory. Set goal as "exec:java". Click on Run(Assumption, JRE is configured correctly) 3. From IDE: Select "/consoleDrawing/" and run as Java application.
Below is a sample run of the program. User input is prefixed with enter command: Choose Options: C L R B Q C 20 4 ---------------------- | | | | | | | | ---------------------- L 1 2 6 2 ---------------------- | | |xxxxxx | | | | | ---------------------- L 6 3 6 4 ---------------------- | | |xxxxxx | | x | | x | ---------------------- R 14 1 18 3 ---------------------- | xxxxx | |xxxxxx x x | | x xxxxx | | x | ---------------------- B 10 3 o ---------------------- |oooooooooooooxxxxxoo| |xxxxxxooooooox xoo| | xoooooooxxxxxoo| | xoooooooooooooo| ---------------------- Q Thank You For Using Drawing Console
Development Style and Design Pattern Used
- TDD Basic development approach was followed.
- SpringBoot is used to developer core framework
- MVC Design Pattern is followed Controller: DrawingBaseController.java View: DrawingConsoleView.java Model: CanvasModel.java
- To Loose coupling and high cohesion, Factory pattern is used to generate Service based on Command selected. DrawingService.java -> Interface ShapeBuilderServiceFactory.java —> Service Factory DrawBlankCanvasServiceImpl.java,DrawLineServiceImpl.java,DrawRectangleServiceImpl.java,FillBucketServiceImpl.java —> Implemenation