[FOray-commit] SF.net SVN: foray: [8012] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2006-09-09 18:59:45
|
Revision: 8012
http://svn.sourceforge.net/foray/?rev=8012&view=rev
Author: victormote
Date: 2006-09-09 11:59:26 -0700 (Sat, 09 Sep 2006)
Log Message:
-----------
Remove magic numbers.
Modified Paths:
--------------
trunk/foray/foray-mif/src/java/org/foray/mif/MIFDocument.java
trunk/foray/scripts/checkstyle-suppressions.xml
Modified: trunk/foray/foray-mif/src/java/org/foray/mif/MIFDocument.java
===================================================================
--- trunk/foray/foray-mif/src/java/org/foray/mif/MIFDocument.java 2006-09-09 18:29:56 UTC (rev 8011)
+++ trunk/foray/foray-mif/src/java/org/foray/mif/MIFDocument.java 2006-09-09 18:59:26 UTC (rev 8012)
@@ -44,6 +44,8 @@
*/
public class MIFDocument {
+ public static final float MILLIPOINT_CONVERSION = 1000f;
+
private static final String EOL = "\n";
private static final String TAB = "\t";
@@ -157,8 +159,11 @@
public void output(final OutputStream stream) throws IOException {
- final String mif = "\n<Document " + "\n<DPageSize " + width / 1000f
- + " " + height / 1000f + " >\n>";
+ final String mif = EOL
+ + "<Document " + EOL
+ + "<DPageSize " + width / MILLIPOINT_CONVERSION
+ + " " + height / MILLIPOINT_CONVERSION + " >" + EOL
+ + ">";
final byte buf[] = mif.getBytes();
stream.write(buf);
@@ -203,7 +208,7 @@
String path = this.url;
// Strip 'file:'
- path = path.substring(5);
+ path = path.substring("file:".length());
String result = "";
int i;
do { // replace all matching '/'
@@ -218,19 +223,20 @@
} while (i != -1);
- String mif = "\n<ImportObject" + "\n<ImportObFixedSize Yes>";
- mif += "\n\t<ImportObFileDI " + "`<c\\>" + path + "'" + " >";
- mif += "\n\t<ShapeRect " + this.x / 1000f + " " + this.y / 1000f
- + " " + this.w / 1000f + " " + this.h / 1000f + " >";
-
- mif += "\n> #End ImportObj";
+ String mif = EOL
+ + "<ImportObject" + EOL
+ + "<ImportObFixedSize Yes>" + EOL;
+ mif += TAB + "<ImportObFileDI " + "`<c\\>" + path + "'" + " >"
+ + EOL;
+ mif += TAB + "<ShapeRect " + this.x / MILLIPOINT_CONVERSION + " "
+ + this.y / MILLIPOINT_CONVERSION + " "
+ + this.w / MILLIPOINT_CONVERSION + " "
+ + this.h / MILLIPOINT_CONVERSION + " >" + EOL;
+ mif += "> #End ImportObj";
stream.write(mif.getBytes());
-
}
-
}
-
/**
* A MIF Frame.
*/
@@ -256,7 +262,9 @@
}
public void output(final OutputStream stream) throws IOException {
- String mif = "\n<Frame" + "\n\t<ID " + this.id + " >";
+ String mif = EOL
+ + "<Frame" + EOL
+ + TAB + "<ID " + this.id + " >";
mif += EOL
+ TAB + "<Pen 15>" + EOL
+ TAB + "<Fill 7>" + EOL
@@ -276,26 +284,24 @@
+ TAB + "<BLOffset 0>" + EOL
+ TAB + "<Cropped No>" + EOL
+ TAB + "<FrameType Below>" + EOL
- + TAB + "<AnchorAlign Center>";
+ + TAB + "<AnchorAlign Center>" + EOL;
- mif += "\n\t<ShapeRect " + this.x / 1000f + " " + this.y / 1000f
- + " " + this.w / 1000f + " " + this.h / 1000f + " >";
+ mif += TAB + "<ShapeRect "
+ + this.x / MILLIPOINT_CONVERSION + " "
+ + this.y / MILLIPOINT_CONVERSION + " "
+ + this.w / MILLIPOINT_CONVERSION + " "
+ + this.h / MILLIPOINT_CONVERSION + " >";
-
stream.write(mif.getBytes());
for (int i = 0; i < content.size(); i++) {
((ImportObject) content.get(i)).output(stream);
}
- mif = "\n> #End Frame";
+ mif = EOL + "> #End Frame";
stream.write(mif.getBytes());
-
-
-
}
public int getID() {
-
return this.id;
}
@@ -351,16 +357,21 @@
public void output(final OutputStream stream) throws IOException {
- String mif = "\n<TextRect" + "\n\t<ID " + textRectID + ">"
- + "\n\t<ShapeRect " + rx / 1000f + " " + ry / 1000f
- + " " + w / 1000f + " " + h / 1000f + ">";
+ String mif = EOL
+ + "<TextRect" + EOL
+ + TAB + "<ID " + textRectID + ">" + EOL
+ + TAB + "<ShapeRect " + rx / MILLIPOINT_CONVERSION + " "
+ + ry / MILLIPOINT_CONVERSION + " "
+ + w / MILLIPOINT_CONVERSION + " "
+ + h / MILLIPOINT_CONVERSION + ">";
if (numCols > 1) {
- mif += "\n<TRNumColumns " + numCols + ">";
- mif += "\n<TRColumnGap " + colGap / 1000f + ">";
+ mif += EOL + "<TRNumColumns " + numCols + ">";
+ mif += EOL + "<TRColumnGap "
+ + colGap / MILLIPOINT_CONVERSION + ">";
}
- mif += "\n> #End TextRect";
+ mif += EOL + "> #End TextRect";
final byte buf[] = mif.getBytes();
stream.write(buf);
}
@@ -405,15 +416,15 @@
public void output(final OutputStream stream) throws IOException {
- String mif = "\n<Page" + "\n\t<PageType " + pageType + ">"
- + "\n\t<PageBackground " + "`" + pageBackground
- + "'" + ">";
+ String mif = EOL + "<Page" + EOL
+ + TAB + "<PageType " + pageType + ">" + EOL
+ + TAB + "<PageBackground " + "`" + pageBackground + "'" + ">";
final byte buf[] = mif.getBytes();
stream.write(buf);
for (int i = 0; i < textRects.size(); i++) {
((TextRect) textRects.get(i)).output(stream);
}
- mif = "\n> #End Page\n";
+ mif = EOL + "> #End Page" + EOL;
stream.write(mif.getBytes());
}
}
@@ -466,12 +477,12 @@
}
public void output(final OutputStream stream) throws IOException {
- String mif = "\n<TextFlow";
+ String mif = EOL + "<TextFlow";
stream.write(mif.getBytes());
for (int i = 0; i < paras.size(); i++) {
((Para) paras.get(i)).output(stream);
}
- mif = "\n> #End TextFlow";
+ mif = EOL + "> #End TextFlow";
stream.write(mif.getBytes());
}
}
@@ -527,21 +538,24 @@
public void output(final OutputStream stream) throws IOException {
- String mif = "\n<Para";
+ String mif = EOL + "<Para";
// Is there a block property?
if (pgf != null) {
- mif += "\n<Pgf";
- mif += "\n<PgfTag `Body'>";
- mif += "\n<PgfLIndent " + pgf.startIndent / 1000f + ">";
- mif += "\n<PgfRIndent " + pgf.endIndent / 1000f + ">";
- mif += "\n>";
+ mif += EOL;
+ mif += "<Pgf" + EOL;
+ mif += "<PgfTag `Body'>" + EOL;
+ mif += "<PgfLIndent "
+ + pgf.startIndent / MILLIPOINT_CONVERSION + ">" + EOL;
+ mif += "<PgfRIndent "
+ + pgf.endIndent / MILLIPOINT_CONVERSION + ">" + EOL;
+ mif += ">";
}
stream.write(mif.getBytes());
for (int i = 0; i < paraLines.size(); i++) {
((ParaLine) paraLines.get(i)).output(stream);
}
- mif = "\n> #End ParaLine";
+ mif = EOL + "> #End ParaLine";
stream.write(mif.getBytes());
}
@@ -576,32 +590,34 @@
public void output(final OutputStream stream) throws IOException {
- String mif = "\n<ParaLine";
+ String mif = EOL + "<ParaLine";
// tables dont need the textrectid
if (textRectID != 0) {
- mif += "\n\t<TextRectID " + textRectID + ">";
+ mif += EOL + TAB + "<TextRectID " + textRectID + ">";
}
stream.write(mif.getBytes());
for (int i = 0; i < content.size(); i++) {
final Object elem = content.get(i);
if (elem instanceof String) {
// Output newlines as char hard return
- if (elem.equals("\n")) {
- mif = "\n<Char HardReturn>";
+ if (elem.equals(EOL)) {
+ mif = EOL + "<Char HardReturn>";
} else {
- mif = "\n\t<String `" + mifEncode((String) elem) + "'>";
+ mif = EOL + TAB + "<String `" + mifEncode((String) elem)
+ + "'>";
}
stream.write(mif.getBytes());
} else if (elem instanceof Frame) {
- mif = "\n\t<AFrame " + ((Frame) elem).getID() + " >";
+ mif = EOL + TAB + "<AFrame " + ((Frame) elem).getID()
+ + " >";
stream.write(mif.getBytes());
} else if (elem instanceof Tbl) {
- mif = "\n\t<ATbl " + ((Tbl) elem).getID() + " >";
+ mif = EOL + TAB + "<ATbl " + ((Tbl) elem).getID() + " >";
stream.write(mif.getBytes());
}
}
- mif = "\n> #End ParaLine";
+ mif = EOL + "> #End ParaLine";
stream.write(mif.getBytes());
}
@@ -617,8 +633,12 @@
public PgfCatalog() { }
public void output(final OutputStream stream) throws IOException {
- final String mif = "\n<PgfCatalog" + "\n<Pgf" + "\n<PgfTag `Body'>"
- + "\n>" + "\n>";
+ final String mif = EOL
+ + "<PgfCatalog" + EOL
+ + "<Pgf" + EOL
+ + "<PgfTag `Body'>" + EOL
+ + ">" + EOL
+ + ">";
stream.write(mif.getBytes());
}
@@ -661,14 +681,15 @@
public void output(final OutputStream stream) throws IOException {
- String mif = "\n<Ruling \n<RulingTag `Default'>";
- mif += "\n<RulingPenWidth " + penWidth + ">";
- mif += "\n<RulingPen " + pen + ">";
- mif += "\n<RulingLines " + lines + ">";
- mif += "\n>";
+ String mif = EOL
+ + "<Ruling" + EOL
+ + "<RulingTag `Default'>" + EOL;
+ mif += "<RulingPenWidth " + penWidth + ">" + EOL;
+ mif += "<RulingPen " + pen + ">" + EOL;
+ mif += "<RulingLines " + lines + ">" + EOL;
+ mif += ">";
stream.write(mif.getBytes());
}
-
}
/**
@@ -688,12 +709,12 @@
public void output(final OutputStream stream) throws IOException {
- String mif = "\n<RulingCatalog";
+ String mif = EOL + "<RulingCatalog";
stream.write(mif.getBytes());
for (int i = 0; i < ruling.size(); i++) {
((Ruling) ruling.get(i)).output(stream);
}
- mif = "\n> #End RulingCatalog";
+ mif = EOL + "> #End RulingCatalog";
stream.write(mif.getBytes());
}
@@ -750,7 +771,8 @@
public void output(final OutputStream stream) throws IOException {
- final String mif = "\n\t<TblColumnWidth " + width + " >";
+ final String mif = EOL + TAB + "<TblColumnWidth " + width
+ + " >";
stream.write(mif.getBytes());
}
@@ -785,13 +807,14 @@
public void output(final OutputStream stream)
throws IOException {
- String mif = "\n\t\t<Cell" + "\n\t\t<CellContent";
+ String mif = EOL + TAB + TAB + "<Cell" + EOL
+ + TAB + TAB + "<CellContent";
stream.write(mif.getBytes());
for (int i = 0; i < paras.size(); i++) {
((Para) paras.get(i)).output(stream);
}
- mif = "\n\t\t> #End CellContent";
- mif += "\n\t> #End Cell";
+ mif = EOL + TAB + TAB + "> #End CellContent";
+ mif += EOL + TAB + "> #End Cell";
stream.write(mif.getBytes());
}
}
@@ -805,12 +828,12 @@
}
public void output(final OutputStream stream) throws IOException {
- String mif = "\n\t<Row";
+ String mif = EOL + TAB + "<Row";
stream.write(mif.getBytes());
for (int i = 0; i < cells.size(); i++) {
((Cell) cells.get(i)).output(stream);
}
- mif = "\n\t> #End Row";
+ mif = EOL + TAB + "> #End Row";
stream.write(mif.getBytes());
}
}
@@ -866,19 +889,20 @@
public void output(final OutputStream stream) throws IOException {
- String mif = "\n<Tbl" + "\n\t<TblID " + id + " >";
+ String mif = EOL + "<Tbl" + EOL + TAB + "<TblID " + id + " >" + EOL;
// note tbl format to be added in a later release
- mif += "\n<TblTag Body>" + "\n<TblFormat";
- mif += "\n<TblColumnRuling `Default'>";
- mif += "\n<TblBodyRowRuling `Default'>";
- mif += "\n<TblLRuling `Default'>";
- mif += "\n<TblBRuling `Default'>";
- mif += "\n<TblRRuling `Default'>";
- mif += "\n<TblTRuling `Default'>";
+ mif += "<TblTag Body>" + EOL;
+ mif += "<TblFormat" + EOL;
+ mif += "<TblColumnRuling `Default'>" + EOL;
+ mif += "<TblBodyRowRuling `Default'>" + EOL;
+ mif += "<TblLRuling `Default'>" + EOL;
+ mif += "<TblBRuling `Default'>" + EOL;
+ mif += "<TblRRuling `Default'>" + EOL;
+ mif += "<TblTRuling `Default'>" + EOL;
- mif += "\n> #End TblFormat";
- mif += "\n\t<TblNumColumns " + tblColumns.size() + " >";
+ mif += "> #End TblFormat" + EOL;
+ mif += TAB + "<TblNumColumns " + tblColumns.size() + " >";
stream.write(mif.getBytes());
if (!tblHead.isEmpty()) {
@@ -892,14 +916,14 @@
}
}
if (!tblBody.isEmpty()) {
- mif = "\n\t<TblBody";
+ mif = EOL + TAB + "<TblBody";
stream.write(mif.getBytes());
for (int i = 0; i < tblBody.size(); i++) {
((Row) tblBody.get(i)).output(stream);
}
- mif = "\n\t> #End tblBody";
+ mif = EOL + TAB + "> #End tblBody";
}
- mif += "\n> #End Table";
+ mif += EOL + "> #End Table";
stream.write(mif.getBytes());
}
@@ -993,29 +1017,29 @@
}
public void output(final OutputStream stream) throws IOException {
- String mif = "<MIFFile 5.00>" + "\n<Units Upt>";
+ String mif = "<MIFFile 5.00>" + EOL + "<Units Upt>";
stream.write(mif.getBytes());
pgfCatalog.output(stream);
rulingCatalog.output(stream);
document.output(stream);
if (!aFrames.isEmpty()) {
- mif = "\n<AFrames";
+ mif = EOL + "<AFrames";
stream.write(mif.getBytes());
for (int i = 0; i < aFrames.size(); i++) {
((Frame) aFrames.get(i)).output(stream);
}
- mif = "\n>";
+ mif = EOL + ">";
stream.write(mif.getBytes());
}
if (!tables.isEmpty()) {
- mif = "\n<Tbls";
+ mif = EOL + "<Tbls";
stream.write(mif.getBytes());
for (int i = 0; i < tables.size(); i++) {
((Tbl) tables.get(i)).output(stream);
}
- mif = "\n>";
+ mif = EOL + ">";
stream.write(mif.getBytes());
}
@@ -1091,7 +1115,7 @@
public void startLine() {
if (curFlow.curPara().curParaLine() != null) {
- this.addToStream("\n");
+ this.addToStream(EOL);
curFlow.curPara().startParaLine();
} else {
curFlow.curPara().startParaLine();
Modified: trunk/foray/scripts/checkstyle-suppressions.xml
===================================================================
--- trunk/foray/scripts/checkstyle-suppressions.xml 2006-09-09 18:29:56 UTC (rev 8011)
+++ trunk/foray/scripts/checkstyle-suppressions.xml 2006-09-09 18:59:26 UTC (rev 8012)
@@ -22,8 +22,6 @@
<suppress checks="MagicNumber"
files="org.foray.hyphenR.*"/>
<suppress checks="MagicNumber"
- files="org.foray.mif.*"/>
- <suppress checks="MagicNumber"
files="org.foray.pdf.*"/>
<suppress checks="MagicNumber"
files="org.foray.pioneer.*"/>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|