Draw in console java

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.

Читайте также:  Fastest server for php

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

    1. BufferReader (br) which is reponsible for taking inputs from the user with readLine function
    2. String (in) which is the input string
    3. PrintWriter (pw) which prints program messages
    4. ScreenManager (sm) which manages and plots the figures of the drawing board
    1. 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.
    2. Erasing: the user can erase any drawn figure.
    3. Centering: the user can center any drawn figure.
    4. Example: there is a robot thread that trigger key board events to show the exmaple usage of this program.
    5. 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:

    1. Create a new canvas
    2. Start drawing on the canvas by issuing various commands
    3. Quit

    Please follow below instructions to get a copy of the project up and running on your local machine for development and testing purposes.

    1. Java/JDK version 1.8 or above should be installed in local machine.
    2. If Porject needs to be cloned from github then Git needs to insatlled in local machine.
    3. To review the Code, any Java development IDE is recommended to installed in local machine.
    4. For running the application code or Test Module via command Line, Mavan needs to installed in you local Machine.
    5. Application and Test module can be executed from development IDE as well
    1. As per Requirements, commands for action should always be given in CAPS
    2. As per Requirements, Diagnol Lines are not allowed to be made.
    3. 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

    1. Clone the project from gitHub repository GitHub Link
    2. Copy/Download the zip Project from Dropbox [DropBox Link] (https://www.dropbox.com/s/2rmqkrffhwybw9e/AnandPratapSingh.zip?dl=0)
    3. 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

    1. TDD Basic development approach was followed.
    2. SpringBoot is used to developer core framework
    3. MVC Design Pattern is followed Controller: DrawingBaseController.java View: DrawingConsoleView.java Model: CanvasModel.java
    4. 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

    Источник

Оцените статью