mirror of
https://github.com/braillerap/BrailleRap.git
synced 2025-06-08 01:49:59 +02:00
typo
This commit is contained in:
parent
b10740ca2f
commit
2ef9ac3b4b
@ -70,7 +70,9 @@ public class Braille2GcodeEncoder {
|
||||
this.encoder = encoder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Start a new page
|
||||
*/
|
||||
public void startPage ()
|
||||
{
|
||||
pagedot = new ArrayList <Point2D.Float> ();
|
||||
|
263
NatBrailleTools/BrailleLogger/src/Braille2GcodeEncoder.java.bak
Normal file
263
NatBrailleTools/BrailleLogger/src/Braille2GcodeEncoder.java.bak
Normal file
@ -0,0 +1,263 @@
|
||||
import java.awt.Point;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Braille encoder class
|
||||
*
|
||||
* @author crocsg
|
||||
*
|
||||
*/
|
||||
public class Braille2GcodeEncoder {
|
||||
|
||||
private GCodeGenerator generator = new GCodeGenerator ();
|
||||
private int page_num= 0;
|
||||
private int char_cnt_line = 0;
|
||||
|
||||
private BrailleGcodeEncoding encoder;
|
||||
|
||||
private float position_x;
|
||||
private float position_y;
|
||||
|
||||
private ArrayList <Point2D.Float> pagedot;
|
||||
private ArrayList<ArrayList<Point2D.Float>> linedot;
|
||||
private String bufline = "";
|
||||
private String pagegcode = "";
|
||||
|
||||
private final float Braille_cell_width = 2.3f;
|
||||
private final float Braille_cell_height = 2.3f;
|
||||
private final float Braille_cell_padding = 6.1f;
|
||||
private final float Braille_line_padding = 10f;
|
||||
private boolean pageAvailable = false;
|
||||
private boolean newpage=true;
|
||||
|
||||
/**
|
||||
* @return the pageAvailable
|
||||
*/
|
||||
public boolean isPageAvailable() {
|
||||
return pageAvailable;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the pagegcode
|
||||
*/
|
||||
public String getPagegcode() {
|
||||
return pagegcode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
private Braille2GcodeEncoder() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param encoder Braille Encoding
|
||||
*/
|
||||
public Braille2GcodeEncoder(BrailleGcodeEncoding encoder) {
|
||||
this.encoder = encoder;
|
||||
}
|
||||
|
||||
|
||||
public void startPage ()
|
||||
{
|
||||
pagedot = new ArrayList <Point2D.Float> ();
|
||||
position_y = 2;//TODO avoid magic
|
||||
pageAvailable = false;
|
||||
newpage = false;
|
||||
pagegcode = "";
|
||||
startLine ();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete GCode encoding for the current page
|
||||
*/
|
||||
public void endPage ()
|
||||
{
|
||||
if ( ! pagedot.isEmpty())
|
||||
{
|
||||
pagegcode = generator.Header();
|
||||
|
||||
for (Point2D.Float p: pagedot)
|
||||
{
|
||||
pagegcode += generator.moveTo(p.getX(),p.getY());
|
||||
pagegcode += generator.printDot();
|
||||
}
|
||||
pagegcode += generator.Footer();
|
||||
|
||||
|
||||
pageAvailable = true;
|
||||
|
||||
int n = JOptionPane.showConfirmDialog(
|
||||
null,
|
||||
"Page " + (page_num+1) + " chargez le papier quand l'embosseuse est disponible",
|
||||
"BrailleRapSP Embosseuse Braille",
|
||||
JOptionPane.OK_CANCEL_OPTION);
|
||||
if (n == JOptionPane.CANCEL_OPTION)
|
||||
{
|
||||
// cancel print
|
||||
System.exit(0);
|
||||
|
||||
}
|
||||
|
||||
page_num++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Start a new line
|
||||
*/
|
||||
public void startLine ()
|
||||
{
|
||||
linedot = new ArrayList <ArrayList <Point2D.Float>> ();
|
||||
for (int i =0; i < encoder.getNline(); i++ )
|
||||
{
|
||||
linedot.add(new ArrayList<Point2D.Float>());
|
||||
}
|
||||
|
||||
position_x = 0; //TODO avoid magic
|
||||
bufline = "";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param p Dot position in Braille character
|
||||
* @return Absolute position on page
|
||||
*/
|
||||
private Point2D.Float getDotAbsolutePosition(Point p)
|
||||
{
|
||||
Point2D.Float absolute = new Point2D.Float();
|
||||
absolute.x = position_x + (float) p.x * Braille_cell_width;
|
||||
absolute.y = position_y + (float) p.y * Braille_cell_height;
|
||||
|
||||
return absolute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update fields for next Braille character
|
||||
*/
|
||||
private void nextCellPosition ()
|
||||
{
|
||||
this.position_x += Braille_cell_padding;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update fields for next line of Braille characters
|
||||
*/
|
||||
private void nextLinePosition ()
|
||||
{
|
||||
this.position_y += Braille_line_padding;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* End Braille characters line
|
||||
*/
|
||||
private void endLine ()
|
||||
{
|
||||
ArrayList<Point> dots;
|
||||
|
||||
// compute braille dots on line
|
||||
for (int i =0; i < bufline.length(); i++)
|
||||
{
|
||||
dots = encoder.GetCharacterDots(bufline.charAt(i));
|
||||
if (dots != null)
|
||||
{
|
||||
for (int d= 0; d < dots.size (); d++)
|
||||
{
|
||||
int x = dots.get(d).x;
|
||||
int y = dots.get(d).y;
|
||||
|
||||
linedot.get(y).add(getDotAbsolutePosition(dots.get(d)));
|
||||
}
|
||||
|
||||
nextCellPosition ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// store braille absolute dot on page
|
||||
for (int l = 0; l < linedot.size(); l++)
|
||||
{
|
||||
pagedot.addAll(linedot.get(l));
|
||||
}
|
||||
|
||||
nextLinePosition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a character in page buffer to encode in Braille
|
||||
* @param a character to add
|
||||
*/
|
||||
private void addCharToBuffer (char a)
|
||||
{
|
||||
bufline += a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Braille encoder
|
||||
*/
|
||||
public void Open ()
|
||||
{
|
||||
startPage ();
|
||||
}
|
||||
|
||||
/*
|
||||
* Process a character
|
||||
* @param a character to process
|
||||
*/
|
||||
public void processChar (char a)
|
||||
{
|
||||
if (a == '\n')
|
||||
{
|
||||
endLine ();
|
||||
startLine ();
|
||||
}
|
||||
else if (a == 0x0c)
|
||||
endPage ();
|
||||
|
||||
else
|
||||
{
|
||||
if (newpage)
|
||||
startPage();
|
||||
addCharToBuffer (a);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* CloseBraille encoder
|
||||
*/
|
||||
public void Close ()
|
||||
{
|
||||
endLine ();
|
||||
endPage ();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Request a new page
|
||||
*/
|
||||
public void requestNewPage() {
|
||||
newpage = true;
|
||||
pageAvailable = false;
|
||||
startPage ();
|
||||
}
|
||||
|
||||
}
|
@ -19,7 +19,7 @@ public class BrailleLogger {
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
System.out.println ("; BrailleRapSP GCODE generator");
|
||||
int arg = 0;
|
||||
@ -57,7 +57,9 @@ public class BrailleLogger {
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
System.out.println("File not found:" + args[0]);
|
||||
System.out.println(e.getMessage());
|
||||
//e.printStackTrace();
|
||||
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
|
71
NatBrailleTools/BrailleLogger/src/BrailleLogger.java.bak
Normal file
71
NatBrailleTools/BrailleLogger/src/BrailleLogger.java.bak
Normal file
@ -0,0 +1,71 @@
|
||||
import java.awt.geom.Point2D;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Main program
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author lenovo
|
||||
*
|
||||
*/
|
||||
public class BrailleLogger {
|
||||
|
||||
|
||||
ArrayList <Point2D.Float> braillepoints = new ArrayList <Point2D.Float>();
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
System.out.println ("; BrailleRapSP GCODE generator");
|
||||
int arg = 0;
|
||||
for (String s: args)
|
||||
{
|
||||
System.out.println(";" + arg);
|
||||
System.out.println(";" + s);
|
||||
}
|
||||
|
||||
if (args.length > 0)
|
||||
{
|
||||
FileReader fr;
|
||||
Braille2GcodeEncoder encoder = new Braille2GcodeEncoder(new Braille6GcodeEncoding());
|
||||
try {
|
||||
fr = new FileReader(args[0]);
|
||||
|
||||
int i;
|
||||
while ((i=fr.read()) != -1)
|
||||
{
|
||||
encoder.processChar((char) i);
|
||||
if (encoder.isPageAvailable())
|
||||
{
|
||||
System.out.println(encoder.getPagegcode());
|
||||
encoder.requestNewPage ();
|
||||
}
|
||||
}
|
||||
|
||||
encoder.Close ();
|
||||
if (encoder.isPageAvailable())
|
||||
{
|
||||
System.out.println(encoder.getPagegcode());
|
||||
|
||||
}
|
||||
fr.close();
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user