-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rafael Grigorian
committed
Jul 24, 2018
1 parent
c17cfae
commit 033ebca
Showing
9 changed files
with
51 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
* This class stores a 4 by 2 pixel matrix that is eventually translated into a braille character. | ||
* This method abstracts away all the calculations that is needed to transform a matrix into a | ||
* braille character. This class is meant to be used as a sub-matrix. | ||
* @version 1.0.1 | ||
* @version 1.0.2 | ||
* @package io.raffi.drawille | ||
* @author Rafael Grigorian <[email protected]> | ||
* @copyright 2018 Rafael Grigorian — All Rights Reserved | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
package io.raffi.drawille; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.util.Arrays; | ||
|
||
/** | ||
* This class is used to hold all the BrailleMap objects and uses them as sub-matrices. It is an | ||
* abstraction of a pixel screen. Methods to interact with those pixels can be found in this class. | ||
* @version 1.0.1 | ||
* @version 1.0.2 | ||
* @package io.raffi.drawille | ||
* @author Rafael Grigorian <[email protected]> | ||
* @copyright 2018 Rafael Grigorian — All Rights Reserved | ||
|
@@ -145,15 +147,39 @@ public void clear () { | |
/** | ||
* This method traverses through all the BrailleMap objects and renders out the sub-matrices by | ||
* asking for the object's string value with the getString method. It then prints them all out | ||
* to the screen. | ||
* to the screen by using the overloaded cooresponding render method. | ||
* @return void | ||
*/ | ||
public void render () { | ||
ByteArrayOutputStream stream = new ByteArrayOutputStream (); | ||
try { | ||
this.render ( stream ); | ||
} | ||
catch ( IOException e ) { | ||
System.out.print ( e ); | ||
} | ||
System.out.print ( stream.toString () ); | ||
} | ||
|
||
/** | ||
* This method traverses through all the BrailleMap objects and renders out the sub-matrices by | ||
* asking for the object's string value with the getString method. It then writes said output to | ||
* the specified ByteArrayOutputStream. This stream is then returned back to caller for method | ||
* chaining. | ||
* @param ByteArrayOutputStream stream Stream to write to | ||
* @return ByteArrayOutputStream Same stream that was passed in | ||
* @throws IOException ByteArrayOutputStream throws exception | ||
*/ | ||
public ByteArrayOutputStream render ( ByteArrayOutputStream stream ) throws IOException { | ||
for ( int i = 0; i < this.width * this.height; i++ ) { | ||
System.out.print ( this.screen [ i ] ); | ||
String brailleMap = this.screen [ i ].toString (); | ||
byte [] buffer = brailleMap.getBytes (); | ||
stream.write ( buffer ); | ||
if ( i % this.width == this.width - 1 ) { | ||
System.out.println (""); | ||
stream.write ( "\n".toString ().getBytes () ); | ||
} | ||
} | ||
return stream; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* This class inherits from the RuntimeException class. It is meant to be thrown whenever an out of | ||
* range value is passed to the Canvas and BrailleMap class. The message is statically defined in | ||
* this class and the caller only has to pass in the out of bounds (x,y) value pairs. | ||
* @version 1.0.1 | ||
* @version 1.0.2 | ||
* @package io.raffi.drawille | ||
* @author Rafael Grigorian <[email protected]> | ||
* @copyright 2018 Rafael Grigorian — All Rights Reserved | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* This class inherits from the Canvas class and it tries to implement turtle graphics. The methods | ||
* in this class can be abstracted with an idea of a pen and paper. One can move the pen in three | ||
* axis and based on the z axis, when the pen moves it either draws on the paper or not. | ||
* @version 1.0.1 | ||
* @version 1.0.2 | ||
* @package io.raffi.drawille | ||
* @author Rafael Grigorian <[email protected]> | ||
* @copyright 2018 Rafael Grigorian — All Rights Reserved | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters