|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.Writer
jmri.util.davidflanagan.HardcopyWriter
public class HardcopyWriter
This is from Chapter 12 of the O'Reilly Java book by David Flanagan with the alligator on the front.
| Nested Class Summary | |
|---|---|
static class |
HardcopyWriter.PrintCanceledException
|
| Field Summary | |
|---|---|
protected int |
charnum
|
protected int |
charoffset
|
protected int |
chars_per_line
|
protected int |
charwidth
|
protected JButton |
closeButton
|
protected Color |
color
|
protected Font |
font
|
protected String |
fontName
|
protected int |
fontsize
|
protected int |
fontStyle
|
protected Frame |
frame
|
protected Font |
headerfont
|
protected FontMetrics |
headermetrics
|
protected int |
headery
|
protected int |
height
|
protected boolean |
isPreview
|
protected PrintJob |
job
|
protected String |
jobname
|
protected String |
line
|
protected int |
lineascent
|
protected int |
lineheight
|
protected int |
linenum
|
protected int |
lines_per_page
|
protected FontMetrics |
metrics
|
protected JButton |
nextButton
|
protected Graphics |
page
|
protected JLabel |
pageCount
|
protected int |
pagedpi
|
protected Vector<Image> |
pageImages
|
protected int |
pagenum
|
protected Dimension |
pagesize
|
protected Graphics |
previewedPage
|
protected JmriJFrame |
previewFrame
|
protected ImageIcon |
previewIcon
|
protected Image |
previewImage
|
protected Graphics |
previewImagegr
|
protected JLabel |
previewLabel
|
protected JPanel |
previewPanel
|
protected JToolBar |
previewToolBar
|
protected JButton |
previousButton
|
protected String |
time
|
protected JLabel |
totalPages
|
protected int |
width
|
protected int |
x0
|
protected int |
y0
|
| Fields inherited from class java.io.Writer |
|---|
lock |
| Constructor Summary | |
|---|---|
HardcopyWriter(Frame frame,
String jobname,
int fontsize,
double leftmargin,
double rightmargin,
double topmargin,
double bottommargin,
boolean preview)
|
|
HardcopyWriter(Frame frame,
String jobname,
int fontsize,
double leftmargin,
double rightmargin,
double topmargin,
double bottommargin,
boolean preview,
String printerName)
|
|
| Method Summary | |
|---|---|
void |
close()
method modified by Dennis Miller to add preview capability |
protected void |
displayPage()
Method to display a page image in the preview pane Not in original class but added later by Dennis Miller |
void |
dispose()
Dispose added so that a preview can be canceled |
void |
flush()
|
int |
getCharactersPerLine()
Return the number of columns of characters that fit on a page |
int |
getCharWidth()
|
int |
getCurrentLineNumber()
Get the current linenumber. |
int |
getFontSize()
|
int |
getLineAscent()
|
int |
getLineHeight()
|
int |
getLinesPerPage()
Return the number of lines that fit on a page |
void |
increaseLineSpacing(int percent)
Increase line spacing by a percentage This method should be invoked immediately after a new HardcopyWriter is created. |
protected void |
newline()
Internal method begins a new line method modified by Dennis Miller to add preview capability |
protected void |
newpage()
Internal method beings a new page and prints the header method modified by Dennis Miller to add preview capability |
void |
pageBreak()
End the current page. |
void |
setFontName(String name)
|
void |
setFontStyle(int style)
|
void |
setTextColor(Color c)
sets the default text color |
protected void |
toolBarInit()
Creates a print preview toolbar added by Dennis Miller |
void |
write(char[] buffer,
int index,
int len)
write method, implemented by all Write subclasses |
void |
write(Color c,
String s)
Write the String with the desired color. |
void |
write(Image c,
Component i)
Write a graphic to the printout. |
void |
write(int rowStart,
int colStart,
int rowEnd,
int colEnd)
Draw a line on the printout. |
void |
write(JWindow jW)
A Method to allow a JWindow to print itself at the current line position This was not in the original class, but was added afterwards by Dennis Miller. |
void |
writeBorders()
Print vertical borders on the current line at the left and right sides of the page at character positions 0 and chars_per_line + 1. |
void |
writeNoScale(Image c,
Component i)
Write a graphic to the printout. |
| Methods inherited from class java.io.Writer |
|---|
append, append, append, write, write, write, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected PrintJob job
protected Graphics page
protected String jobname
protected String line
protected int fontsize
protected String time
protected Dimension pagesize
protected int pagedpi
protected Font font
protected Font headerfont
protected String fontName
protected int fontStyle
protected FontMetrics metrics
protected FontMetrics headermetrics
protected int x0
protected int y0
protected int height
protected int width
protected int headery
protected int charwidth
protected int lineheight
protected int lineascent
protected int chars_per_line
protected int lines_per_page
protected int charnum
protected int linenum
protected int charoffset
protected int pagenum
protected Color color
protected boolean isPreview
protected Graphics previewedPage
protected Image previewImage
protected Graphics previewImagegr
protected Vector<Image> pageImages
protected JmriJFrame previewFrame
protected JPanel previewPanel
protected ImageIcon previewIcon
protected JLabel previewLabel
protected JToolBar previewToolBar
protected Frame frame
protected JButton nextButton
protected JButton previousButton
protected JButton closeButton
protected JLabel pageCount
protected JLabel totalPages
| Constructor Detail |
|---|
public HardcopyWriter(Frame frame,
String jobname,
int fontsize,
double leftmargin,
double rightmargin,
double topmargin,
double bottommargin,
boolean preview)
throws HardcopyWriter.PrintCanceledException
HardcopyWriter.PrintCanceledException
public HardcopyWriter(Frame frame,
String jobname,
int fontsize,
double leftmargin,
double rightmargin,
double topmargin,
double bottommargin,
boolean preview,
String printerName)
throws HardcopyWriter.PrintCanceledException
HardcopyWriter.PrintCanceledException| Method Detail |
|---|
protected void toolBarInit()
protected void displayPage()
public void write(char[] buffer,
int index,
int len)
write in class Writer
public void write(Color c,
String s)
throws IOException
c - the color desired for this Strings - the String
IOExceptionpublic void flush()
flush in interface Flushableflush in class Writerpublic void close()
close in interface Closeableclose in class Writerpublic void dispose()
public void setFontStyle(int style)
public int getLineHeight()
public int getFontSize()
public int getCharWidth()
public int getLineAscent()
public void setFontName(String name)
public void setTextColor(Color c)
c - the new default text colorpublic void pageBreak()
public int getCharactersPerLine()
public int getLinesPerPage()
protected void newline()
protected void newpage()
public void write(Image c,
Component i)
This was not in the original class, but was added afterwards by Bob Jacobsen. Modified by D Miller.
The image is positioned on the right side of the paper, at the current height.
public void writeNoScale(Image c,
Component i)
This was not in the original class, but was added afterwards by Kevin Dickerson. it is a copy of the write, but without the scaling.
The image is positioned on the right side of the paper, at the current height.
public void write(JWindow jW)
This was not in the original class, but was added afterwards by Dennis Miller.
Intended to allow for a graphic printout of the speed table, but can be used to print any window. The JWindow is passed to the method and prints itself at the current line and aligned at the left margin. The calling method should check for sufficient space left on the page and move it to the top of the next page if there isn't enough space.
public void write(int rowStart,
int colStart,
int rowEnd,
int colEnd)
This was not in the original class, but was added afterwards by Dennis Miller.
colStart and colEnd represent the horizontal character positions. The lines actually start in the middle of the character position to make it easy to draw vertical lines and space them between printed characters.
rowStart and rowEnd represent the vertical character positions. Horizontal lines are drawn underneath the row (line) number. They are offset so they appear evenly spaced, although they don't take into account any space needed for descenders, so they look best with all caps text
public int getCurrentLineNumber()
This was not in the original class, but was added afterwards by Dennis Miller.
public void writeBorders()
This was not in the original class, but was added afterwards by Dennis Miller.
public void increaseLineSpacing(int percent)
This method should be invoked immediately after a new HardcopyWriter is created.
This method was added to improve appearance when printing tables
This was not in the original class, added afterwards by DaveDuchamp.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||