|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jfig.objects.FigParser
FIG 2.1, 3.1, 3.2 format parser.
This class parses input files in FIG 2.1, FIG 3.1, and FIG 3.2 formats and generates a corresponding representation built from the jfig.objects classes. For a direct interface to the jfig editor, the objects read are inserted into a jfig.objects.FigObjectList object list, which keeps the hierarchical structure of the input with its possibly nested compound objects. To parse a FIG file, call parse_fig_file() and supply the necessary input stream, default attributes and transformation, and an empty object list to be filled.
In order to allow for background parsing of FIG files, this class also provides a threaded variant of the parse_fig_file() method, which uses the run() method from Runnable().
FigObject
,
FigObjectList
Field Summary | |
(package private) java.util.Vector |
actionListeners
|
(package private) ColorCache |
colorCache
|
(package private) java.lang.StringBuffer |
comment
|
(package private) boolean |
debug
|
(package private) boolean |
enableMessages
|
(package private) boolean |
enableNonASCII
|
(package private) boolean |
fastMessages
|
(package private) int |
fig_version
|
(package private) java.lang.String |
gl_filename
|
(package private) java.lang.String |
gl_filetype
|
(package private) StatusMessage |
helper
|
(package private) int |
input_resolution
|
(package private) int |
line_number
|
(package private) int |
n_errors
|
(package private) ObjectPainter |
painter
|
(package private) java.lang.String[] |
paperSizes
|
(package private) ConsoleMessage |
printer
|
(package private) java.lang.Thread |
reader
|
boolean |
solaris_is_broken
|
(package private) FigAttribs |
t_attribs
|
(package private) int |
t_errors
|
(package private) java.io.InputStream |
t_f
|
(package private) boolean |
t_inside_compound
|
(package private) boolean |
t_merge
|
(package private) FigObjectList |
t_OL
|
(package private) boolean |
t_top_level
|
(package private) FigTrafo2D |
t_trafo
|
Constructor Summary | |
FigParser()
|
|
FigParser(java.lang.Object app)
|
|
FigParser(java.lang.Object app,
StatusMessage helper)
|
Method Summary | |
void |
addActionListener(java.awt.event.ActionListener AL)
|
(package private) java.lang.String |
buildString(java.lang.String src)
build the actual text String for a FigText object from the FIG 3.1 file string. |
(package private) void |
check_add_object_comment(FigObject object)
|
(package private) static double |
clipRotationAngle(double radians)
clip the given rotation angle (in radians) to the range 0..2*PI |
(package private) void |
collect_object_comment(java.lang.String line)
add the specified string 'line' to the current per-object comment. |
(package private) double |
fig_arrow_scale(double x)
|
(package private) java.awt.Color |
fig_color(int index)
return the Color object corresponding to FIG3.1 color index |
(package private) double |
fig_scale(double x)
|
(package private) int |
fig_scale(int x)
scale from FIG3.1 units (1200dpi, origin at top left) to jfig units (2400dpi, origin at top left). |
(package private) int |
fig_thickness(int x)
scale from FIG3.1 line thickness (in units of 1/80th inch) (=approx with in pixels on 75dpi screen) to jfig units at 2400dpi (with 30/2400 = 1/80). |
(package private) void |
handle_backward_arrow(FigAttribs attribs,
FigArrowParams b_arrow_params)
|
(package private) void |
handle_forward_arrow(FigAttribs attribs,
FigArrowParams f_arrow_params)
|
(package private) void |
handleFillStyle(int fill_color,
FigAttribs attribs)
set attribs.fillStyle and calculate the fillColor as a function of lineColor, fillColor and fig_area_fill |
(package private) void |
handleLineStyle(FigAttribs attribs,
int line_style,
double style_val)
FORMAT3.2 states that style_val is the length of on/off dashes or dot separation, in 1/80 inch units. |
void |
message(java.lang.String msg)
|
void |
notifyOurActionListeners(boolean merge)
|
(package private) java.awt.Color |
old_fig_color(int index)
|
(package private) void |
old_handleFillStyle(FigAttribs attribs)
|
(package private) void |
parse_fig_arc(java.io.BufferedReader f,
java.lang.String line,
FigAttribs attribs,
FigTrafo2D trafo,
FigObjectList OL)
|
(package private) void |
parse_fig_arrow(java.io.BufferedReader f,
FigArrowParams p)
parse a FIG3.1 arrow parameter line from the stream f. |
(package private) void |
parse_fig_ellipse(java.io.BufferedReader f,
java.lang.String line,
FigAttribs attribs,
FigTrafo2D trafo,
FigObjectList OL)
|
int |
parse_fig_file_not_threaded(java.io.InputStream f,
boolean top_level,
boolean inside_compound,
boolean merge,
FigAttribs attribs,
FigTrafo2D trafo,
FigObjectList OL)
parse_fig_file_not_threaded(): substitute for the function for parse_fig_file_threaded(), because thread scheduling is broken under Solaris JDK 1.1beta... |
int |
parse_fig_file_threaded(java.io.InputStream f,
boolean top_level,
boolean inside_compound,
boolean merge,
FigAttribs attribs,
FigTrafo2D trafo,
FigObjectList OL)
parse_fig_file_threaded(): parse a FIG 3.1 file in a separate Thread. |
int |
parse_fig_file(java.io.InputStream ff,
boolean top_level,
boolean inside_compound,
FigAttribs attribs,
FigTrafo2D trafo,
FigObjectList OL)
read an FIG3.1 file from stream f, and insert the objects found into the objectList. |
(package private) void |
parse_fig_header(java.io.BufferedReader f,
FigAttribs attribs,
FigTrafo2D trafo,
FigObjectList OL)
Try to parse a FIG 3.1 / FIG 2.1 file header from stream f. |
(package private) void |
parse_fig_pointline(java.io.BufferedReader f,
int npoints,
int[] xpoints,
int[] ypoints)
parse a FIG3.1 file for polyline coordinates |
(package private) void |
parse_fig_polyline(java.io.BufferedReader f,
java.lang.String line,
FigAttribs attribs,
FigTrafo2D trafo,
FigObjectList OL)
parse a FIG3.1 polyline object from the stream f, where line is the current line on the stream f. |
(package private) void |
parse_fig_pseudocolor(java.io.BufferedReader f,
java.lang.String line,
FigAttribs attribs,
FigObjectList OL)
|
(package private) void |
parse_fig_spline(java.io.BufferedReader f,
java.lang.String line,
FigAttribs attribs,
FigTrafo2D trafo,
FigObjectList OL)
|
(package private) void |
parse_fig_text(java.io.BufferedReader f,
java.lang.String line,
FigAttribs attribs,
FigTrafo2D trafo,
FigObjectList OL)
|
(package private) int |
parse_fig21_pointline(java.io.BufferedReader f)
parse a FIG2.1 file for polyline coordinates Because FIG 2.1 does not store the number of points, we cannot pre allocate the point arrays. |
(package private) void |
parse_fig31_cpointline(java.io.BufferedReader f,
int npoints,
double[] xpoints,
double[] ypoints)
parse a FIG3.1 file for spline control point coordinates |
(package private) void |
parse_fig32_cpointline(java.io.BufferedReader f,
int npoints,
double[] sfactors)
parse FIG3.2 spline control point values (and ignore them) |
(package private) void |
parse_fig32_header(java.io.BufferedReader f,
FigAttribs attribs,
FigTrafo2D trafo,
FigObjectList OL)
Try to parse a FIG 3.2 file header from reader f. |
void |
parse_jfig_trigger(java.io.BufferedReader f,
java.lang.String line,
FigAttribs attribs,
FigTrafo2D trafo,
FigObjectList OL)
|
(package private) void |
parse_text_plain(java.lang.String firstLine,
java.io.BufferedReader f,
FigAttribs attribs,
FigTrafo2D trafo,
FigObjectList OL)
parse_text_plain: simple hack to read text/plain and related files. |
void |
reset_debug()
|
void |
run()
|
void |
set_debug()
|
void |
setConsole(ConsoleMessage printer)
|
void |
setFilenameAndType(java.lang.String fname,
java.lang.String ftype)
|
void |
setObjectPainter(ObjectPainter _painter)
|
void |
setStatusMessage(StatusMessage helper)
|
(package private) java.lang.String |
skip_fig_comments(java.io.BufferedReader f)
|
void |
statusMessage(java.lang.String msg)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
boolean debug
boolean fastMessages
int n_errors
int line_number
ColorCache colorCache
int input_resolution
int fig_version
StatusMessage helper
ConsoleMessage printer
ObjectPainter painter
java.util.Vector actionListeners
java.lang.String gl_filename
java.lang.String gl_filetype
java.lang.StringBuffer comment
boolean enableNonASCII
boolean enableMessages
java.lang.String[] paperSizes
public boolean solaris_is_broken
int t_errors
boolean t_top_level
boolean t_inside_compound
boolean t_merge
FigAttribs t_attribs
FigTrafo2D t_trafo
FigObjectList t_OL
java.lang.Thread reader
java.io.InputStream t_f
Constructor Detail |
public FigParser(java.lang.Object app)
public FigParser(java.lang.Object app, StatusMessage helper)
public FigParser()
Method Detail |
public void addActionListener(java.awt.event.ActionListener AL)
public void setFilenameAndType(java.lang.String fname, java.lang.String ftype)
public void setObjectPainter(ObjectPainter _painter)
public void setStatusMessage(StatusMessage helper)
public void setConsole(ConsoleMessage printer)
public void set_debug()
public void reset_debug()
public void parse_jfig_trigger(java.io.BufferedReader f, java.lang.String line, FigAttribs attribs, FigTrafo2D trafo, FigObjectList OL)
final int fig_scale(int x)
This function uses the global variable input_resolution for the coordinate transformation. Hack for FIG 2.1 files We increment all coordinates by 1 to shift the figure back onto the grid...
final double fig_scale(double x)
final double fig_arrow_scale(double x)
static double clipRotationAngle(double radians)
final int fig_thickness(int x)
final java.awt.Color old_fig_color(int index)
final java.awt.Color fig_color(int index)
final void handleLineStyle(FigAttribs attribs, int line_style, double style_val)
final void handleFillStyle(int fill_color, FigAttribs attribs)
final void old_handleFillStyle(FigAttribs attribs)
final void handle_forward_arrow(FigAttribs attribs, FigArrowParams f_arrow_params)
final void handle_backward_arrow(FigAttribs attribs, FigArrowParams b_arrow_params)
void collect_object_comment(java.lang.String line)
void check_add_object_comment(FigObject object)
void parse_fig_pseudocolor(java.io.BufferedReader f, java.lang.String line, FigAttribs attribs, FigObjectList OL)
void parse_fig_ellipse(java.io.BufferedReader f, java.lang.String line, FigAttribs attribs, FigTrafo2D trafo, FigObjectList OL)
void parse_fig_spline(java.io.BufferedReader f, java.lang.String line, FigAttribs attribs, FigTrafo2D trafo, FigObjectList OL)
java.lang.String buildString(java.lang.String src)
Note that the jfig parser - unlike xfig - will also recognize Java unicode escapes ' ' to '?'.
void parse_fig_text(java.io.BufferedReader f, java.lang.String line, FigAttribs attribs, FigTrafo2D trafo, FigObjectList OL)
void parse_fig_arc(java.io.BufferedReader f, java.lang.String line, FigAttribs attribs, FigTrafo2D trafo, FigObjectList OL)
void parse_fig_pointline(java.io.BufferedReader f, int npoints, int[] xpoints, int[] ypoints)
f
- The stream to parsenpoints
- The number of (x,y) coordinate pairsint parse_fig21_pointline(java.io.BufferedReader f)
f
- The stream to parsevoid parse_fig32_cpointline(java.io.BufferedReader f, int npoints, double[] sfactors)
void parse_fig31_cpointline(java.io.BufferedReader f, int npoints, double[] xpoints, double[] ypoints)
f
- The stream to parsenpoints
- The number of (x,y) coordinate pairsvoid parse_fig_arrow(java.io.BufferedReader f, FigArrowParams p)
void parse_fig_polyline(java.io.BufferedReader f, java.lang.String line, FigAttribs attribs, FigTrafo2D trafo, FigObjectList OL)
The string 'line' should contain the following: object_code (2), sub_type( polyline/box/polygon/arc/box/image), line_style, thickness, pen_color, fill_color, depth, pen_style (unused), area_fill. style_val, join_style, cap_style, radius, forward-arrow, backward-arrow, npoints. Then follow the forward-arrow and backward-arrow and point lines.
void parse_text_plain(java.lang.String firstLine, java.io.BufferedReader f, FigAttribs attribs, FigTrafo2D trafo, FigObjectList OL)
Unfortunately, the main parser has already read one line of the input stream and we cannot easily back up. So we expect the contents of the first line of the file as additional parameter.
java.lang.String skip_fig_comments(java.io.BufferedReader f) throws java.io.IOException
java.io.IOException
void parse_fig32_header(java.io.BufferedReader f, FigAttribs attribs, FigTrafo2D trafo, FigObjectList OL)
void parse_fig_header(java.io.BufferedReader f, FigAttribs attribs, FigTrafo2D trafo, FigObjectList OL)
public int parse_fig_file(java.io.InputStream ff, boolean top_level, boolean inside_compound, FigAttribs attribs, FigTrafo2D trafo, FigObjectList OL)
The flag 'top_level' indicates that we should read the FIG3.1 header. This is set to true on the first call, and set to false on recursive calls when parsing compound objects.
Return the number of parser errors encountered.
public int parse_fig_file_not_threaded(java.io.InputStream f, boolean top_level, boolean inside_compound, boolean merge, FigAttribs attribs, FigTrafo2D trafo, FigObjectList OL)
public void notifyOurActionListeners(boolean merge)
public int parse_fig_file_threaded(java.io.InputStream f, boolean top_level, boolean inside_compound, boolean merge, FigAttribs attribs, FigTrafo2D trafo, FigObjectList OL)
public void run()
run
in interface java.lang.Runnable
public void message(java.lang.String msg)
public void statusMessage(java.lang.String msg)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |