Previous: JDR Binary Format  Up: Manual Home  Next: Multilingual Support

AJR Format

Jpgfdraw's AJR file format is an ASCII format written primarily to assist file format conversion.

The current AJR file format version is 1.5.

If you use the uk.ac.uea.cmp.nlct.jdr package, you can load and save an AJR file using the AJR.load() and AJR.save() methods. Notes:

• All elements within the AJR should be separated by white space.

• Tabs and new line characters are treated as a space.

• It is inadvisable to have new lines within a literal string, as a carriage return followed by line feed may be interpreted as two spaces rather than one.

• Multiple spaces are treated as a single space, unless they occur within a literal string.

• Literal strings are not delimited, but are always preceded by a number indicating the length of the string. There should only be a single space between the length and the start of the string. Note that 9 SansSerif (one space) is not the same as 9  SansSerif (two spaces). The latter will cause an error as the string will be interpreted as " SansSeri". The only exceptions are strings that are guaranteed never to contain spaces (such as the file type identifier AJR and paper size textual identifiers.)

• Take care when editing literal strings, as you will also have to remember to update the string length as well. For example, if you want to change the font family from SansSerif to Lucida Sans, you will have to change:
9 SansSerif

to
11 Lucida Sans


• The default unit is bp unless otherwise stated.

The AJR file format is as follows:

1. The file must start with AJR followed by white space and the version. For example:
AJR 1.1

indicates the AJR version 1.1 format.

2. Next there must be an integer (followed by white space) indicating whether or not the Jpgfdraw settings are stored. AJR v1.3 onwards allows 3 possible values: 0 (no settings), 1 (all settings) and 2 (paper size only). Versions prior to that only allow 0 (no settings) and 1 (all settings).

If a 2 is found, it should be followed by the paper size (see below), otherwise if a 1 is found, all the settings information must follow:

a
A 0 or 1 indicating whether or not to display the grid.

b
A 0 or 1 indicating whether or not to lock the grid.

c
A 0 or 1 indicating whether or not to show the rulers.

d
A number indicating which tool to select. This must be an integer between 0 and 7 (inclusive). Table A.1 indicates the integer ID for each tool.

e
An number indicating the normal font size. (This is used as the default in the font settings dialog box, and as the normal size font for the LaTeX font size conversions.)

f
The paper size (see below).

g
The grid style:

AJR1.0-1.5
1. A number representing the unit used for the rulers and grid. This should be one of: 0 (TeX pt), 1 (inches), 2 (centimetres) or 3 (PostScript points). To write:
dout.writeByte(unitType);

byte unitType = din.readByte();


2. Two integers representing the major grid divisions and the subdivisions, respectively.
AJR1.0-1.5
AJR1.6 onwards
A number representing the grid style ID. This may be:
0
A rectangular grid. This is then followed by:
1. An integer representing the unit ID (as above).

2. A floating-point number representing the major grid division.

3. An integer representing the grid subdivision.
1
A radial grid. This is then followed by:
1. An integer representing the unit ID (as above).

2. A floating-point number representing the major grid division.

3. An integer representing the grid subdivision.

4. An integer representing the number of spokes.
AJR1.6 onwards

3. AJR1.0-1.2
The paper size is specified by: <id> [<w> <h> <orient>] The paper size is indicated by an integer <id> which must be in the range 0 to 18. The corresponding paper sizes are listed in Table A.2. The width <w>, height <h> and orientation <orient> should only be present when <id> is 18. The orientation is indicated 0 (portrait) or 1 (landscape).
AJR1.0-1.2
AJR1.3 onwards
The paper size is specified by: <id> [<w> <h>] The paper identifier <id> may be either an integer in the range 0 to 72 or a string. Tables A.2 and A.3 list the paper sizes that correspond to an integer <id>. Table 3.1 indicate the allowed values where <id> is a string. The width <w> and height <h> should only be present when <id> is 18 or is the string "user".
AJR1.3 onwards

1. an AJR file whose first two lines contains:
AJR 1.2
1 0 1 1 0 10 14 3 100 10

indicates: AJR v1.2 file (first line), all settings provided (1), don't show the grid (0), lock the grid (1), show rulers (1), select tool (0), the normal font size is 10pt (10), A5 landscape (14), use PostScript points in the rulers and grid (3), with each major division of width 100bp with 10 subdivisions.

2. an AJR file whose first two lines contains:
AJR 1.3
2 a4r

indicates: AJR v1.3 file (first line), only the paper size is specified (2), A4 landscape paper (a4r)

3. an AJR file whose first two lines contains:
AJR 1.3
2 user 3in 4in

indicates: AJR v1.3 file (first line), only the paper size is specified (2), the paper size is a custom size with width 3 inches and height 4 inches.

4. The objects that constitute the picture are now stored. When saving to a file, an outer grouping is implied that is not evident whilst using Jpgfdraw. This means that there should always be a single group structure saved to file which contains all the objects that constitute the picture. Each object is then recursively stored. For example, if a picture contains a path, a group and a text area, in the AJR file these three objects will be stored as a single group structure containing the three objects. If in Jpgfdraw you explicitly group all the objects, then in the AJR file, the outermost implicit group will contain only one object which will be this group.

Each object has the following format:
AJR1.0 & 1.1
<id-char> <object-specs> <fflag> [<flowframe-specs>]
AJR1.0 & 1.1
AJR1.2 onwards
<id-char> <object-specs> <fflag> [<flowframe-specs>] <description-specs>
AJR1.2 onwards
where <id-char> is a character determining the object type:
AJR1.0-1.4
AJR1.0-1.4
AJR1.5
AJR1.5
AJR1.5
AJR1.5

The object specifications <object-specs> vary according to the object type and are described below. <fflag> must be either 1 or 0 indicating whether or not this object has flowframe data associated with it. If 1, then the flowframe specifications <flowframe-specs> should follow (see below), otherwise <flowframe-specs> should be omitted. Note that AJR version 1.2 onwards contains <description-specs>, which was omitted in earlier versions.

1. Group data, G, is stored as follows:

<n> {<object data> }+

where <n> is an integer indicating the number of objects within the group, there should then follow <n> lots of <object data>, where <object data> is the data for each object within the group, where the object data is as described above.

2. Path data, P, is stored as follows:
AJR1.0-1.2
<line colour> <fill colour> <line style> O|C <n> <segment data>+
AJR1.0-1.2
AJR1.3 onwards
<line colour> <fill colour> <line style> O|C <n> <start point> <segment data>+
AJR1.3 onwards
where <line colour> and <fill colour> contain the line and fill colour data (see below), <line style> is the line style data (see below). The character O or C indicates whether the path is open or closed, <n> is an integer indicating the number of segments that constitute the path. Note that AJR v1.3 has removed the redundancy in earlier versions. From version 1.3, <n> must be followed by the path's starting point, <start point>, which should be two white space separated numbers indicating the x and y co-ordinates, respectively, this is then followed by <n> lots of <segment data> (described below).

1. Colour data is stored as follows: <col-id> [<colour-specs> ], where <col-id> is a character representing the colour type. Available types are listed in Table A.4.

1. Single RGB colour data is specified as:

<R> <G> <B> <A>

where each element is a number between 0 and 1 (inclusive), and <R> represents the red value, <G> represents the green value, <B> represents the blue value, and <A> represents the alpha (transparency) value.

2. Single CMYK colour data is specified as:

<C> <M> <Y> <K> <A>

where each element is a number between 0 and 1 (inclusive), and <C> represents the cyan value, <M> represents the magenta value, <Y> represents the yellow value, <K> represents the black value, and <A> represents the alpha (transparency) value.

3. As from AJR v1.4, single HSB colour data is specified as:

<H> <S> <B> <A>

where each element is a number with all values except <H> lying between 0 and 1 (inclusive). <H> represents the hue which must be in the range [0,360), <S> represents the saturation, <B> represents the brightness, and <A> represents the alpha (transparency) value.

4. As from AJR v1.4, single grey scale data is specified as:

<G> <A>

where each element is a number between 0 and 1 (inclusive), and <G> represents the grey scale, and <A> represents the alpha (transparency) value.

5. Linear gradient colour data is specified as:

<start-col-id> <start-col-specs> <end-col-id> <end-col-specs> <direction>

where <start-col-id> is the colour identifier for the starting colour and <start-col-specs> is the colour specification, and <end-col-id> is the colour identifier for the end colour and <end-col-specs> is the colour specification. The colour identifiers may be any of those listed in Table A.4 except the linear or radial gradient types. The colour specifications are as described above. The gradient direction, <direction>, is an integer and may only take one of the following values: 0 (North), 1 (North East), 2 (East), 3 (South East), 4 (South), 5 (South West), 6 (West) and 7 (North West).

6. AJR v1.3 onwards also provides radial gradient colour data which is specified as:

<start-col-id> <start-col-specs> <end-col-id> <end-col-specs> <start location>

where <start-col-id> is the colour identifier for the starting colour and <start-col-specs> is the colour specification, and <end-col-id> is the colour identifier for the end colour and <end-col-specs> is the colour specification. The colour identifiers may be any of those listed in Table A.4 except the linear or radial gradient types. The colour specifications are as described above. The starting location, <start location>, is an integer and may only take one of the following values: 0 (North), 1 (North East), 2 (East), 3 (South East), 4 (South), 5 (South West), 6 (West), 7 (North West) and 8 (Centre).

2. The line style data has changed as from AJR v1.1 to take into account the inclusion of mid point markers, and is stored as follows:
AJR1.0
<linewidth> <dash> <cap> <join> [<mitre-limit>] <winding> <start arrow> <end arrow>
AJR1.0
AJR1.1 onwards
<linewidth> <dash> <cap> <join> [<mitre-limit>] <winding> <start arrow> <mid marker> <end arrow>
AJR1.1 onwards
where:
1. <linewidth> the line width (in PostScript points).

2. <dash> is the dash pattern. This is stored as:

<n> [<pattern>+ <offset>]

where <n> is 0 if there is no dash pattern (i.e. a solid line) or the number of patterns. There should be an even number of patterns, the odd numbered patterns represent the dash length, the even numbered patterns represent the dash gap. The patterns should be stored as decimal numbers (in PostScript points). Lastly, the offset should be a decimal number (in PostScript points). Note that if <n> is 0, there should be no <pattern> or <offset>.

3. <cap> is the cap style, this is an integer. It may only have one of the following values: 0 (butt), 1 (round) or 2 (square).

4. <join> is the join style, this is an integer. It may only have one of the following values: 0 (mitre), 1 (round) or 2 (bevel).

5. <mitre-limit> is the mitre-limit, this is a decimal number, and should only be stored if the join style is a mitre.

6. <winding> is the winding rule, this is an integer. It may only have one of the following values: 0 (Even-Odd) or 1 (Non Zero).

7. <start arrow> and <end arrow> are the starting and ending arrow styles. The <mid marker> is the style for the mid-point markers. Each marker type (start/mid/end) has the same format, but the file format varies as follows:
AJR1.0
<id> [<size> <is double> <is reversed>]

where <id> is an integer identifying the arrow type. This may be one of: 0 (none), 1 (pointed), 2 (triangle), 3 (circle), 4 (diamond), 5 (square), 6 (bar) or 7 (single). <size> is a number representing the arrow size. (Some arrows only have a fixed size, but a size must still be present.) <is double> is an integer indicating whether the arrow head is a double arrow (2) or a single arrow (1). <is reversed> indicates whether the arrow head has been reversed, and should be either 1 (reversed) or 0 (not reversed). The values <size> <is double> <is reversed> are omitted if <id> equals 0 (no arrow head).
AJR1.0
AJR1.1-1.3
<id> [<marker data> ]

where <id> is an integer identifying the marker type. If <id> is 0, then <marker data> should be omitted, otherwise it should be present. Valid <id> values are listed in Table A.5.

The <marker data> is stored as follows:

<size> <repeat> <is reversed> <orient data> <colour data> <overlay> <composite data>

where:

• <size> is a decimal number representing the marker size (some markers will ignore this attribute, but it must still be present in the file.)

• <repeat> is an integer identifying the repeat factor (a value of 1 indicates a single marker, a value of 2 indicates a double marker, a value of 3 indicates a triple marker.)

• <is reversed> indicates whether or not the marker has been reversed, it must be either 0 (not reversed) or 1 (reversed).

• <orient data> is the marker orientation data. This has the form <auto-orient> [<angle> ] where <auto-orient> is either 1 or 0, indicating whether the marker should be oriented along the path. If <auto-orient> is 1, <angle> should be omitted, otherwise <angle> should be a floating point number representing the orientation angle (in Radians).

• <colour data> is the marker colour. This has the same form as the line/fill/text colour data defined earlier, except a transparent value indicates the colour should be derived from the path to which the marker is attached, and there is no provision for gradient paint markers.

• <overlay> is a number indicating whether to overlay composite markers. This may be either 0 (don't overlay) or 1 (overlay).

• <composite data> is the data for composite markers. This has the same format as the <marker data>. If the <composite data> has a marker id of 0, then the marker is not a composite marker. Although the format allows for nested composite markers, Jpgfdraw's marker settings dialog boxes do not allow for it.

AJR1.1-1.3
AJR1.4 onwards
<id> [<marker data> ]

where <id> is an integer identifying the marker type. If <id> is 0, then <marker data> should be omitted, otherwise it should be present. Valid <id> values are listed in Table A.5 and Table A.6. Additional markers listed in Table A.7 are also available for version 1.6 onwards.

The <marker data> is stored as follows:

<size> <repeat> <is reversed> <orient data> <colour data> <overlay> [<user offset flag> [<user offset>] <repeat offset flag> [<repeat offset>]] <composite data>

where: <user offset flag> [<user offset>] <repeat offset flag> [<repeat offset>] are only specified if <overlay> is 0. <user offset> and <repeat offset> are only specified if <user offset flag> or <repeat offset flag> are 1, respectively. The remaining values are as for AJR versions 1.1-1.3 described above.

• <user offset flag> is a number indicating whether the marker offset is specified by the user (1) or determined automatically (0).

• <user offset> is a decimal number indicating the marker offset from the vertex.

• <repeat offset flag> is a number indicating whether the repeat offset (i.e. gap between repeat markers) is specified by the user (1) or determined automatically (0).

• <repeat offset> is a decimal number indicating the gap between repeat markers.
AJR1.4 onwards

3. Segments are stored as follows:

<id> <specs>

where <id> is a character representing the segment type. This can be one of: B (cubic Bézier), L (line) or M (move). The specification <specs> depends on the segment type:

1. Bézier segments are stored as follows:
AJR1.0-1.2
<c0x> <c0y> <c1x> <c1y> <c2x> <c2y> <c3x> <c3y>
AJR1.0-1.2
AJR1.3 onwards
<c1x> <c1y> <c2x> <c2y> <c3x> <c3y>
AJR1.3 onwards
where <c0x> and <c0y> are the x and y co-ordinates of the starting point, <c1x> and <c1y> are the x and y co-ordinates of the first curvature control point, <c2x> and <c2y> are the x and y co-ordinates of the second curvature control point, and <c3x> and <c3y> are the x and y co-ordinates of the end point. All values are stored as PostScript points.

2. Line and move to (gap) segments are stored as follows:
AJR1.0-1.2
<x0> <y0> <x1> <y1>
AJR1.0-1.2
AJR1.3 onwards
<x1> <y1>
AJR1.3 onwards
where <x0> and <y0> are the x and y co-ordinates of the starting point and <x1> and <y1> are the x and y co-ordinates of the end point.

3. Text area data is stored as follows:

<fam-length> <family> <shape> <series> <size> <transformation> <latex-flag> [<latex-specs>] <text colour> <text-length> <text>

where:
1. <fam-length> is an integer that is the length of the font family name, and <family> is the font family name.

2. <shape> is an integer representing the font shape. This can have one of two values: 0 (upright) or 1 (italic).

3. <series> is an integer representing the font series. This can have one of two values: 0 (medium) or 1 (bold).

4. <size> is the font size stored as an integer.

5. <transformation> is the transformation matrix. The origin is taken to be the leftmost point along the baseline of the text. The transformation is stored as:

<m0> <m1> <m2> <m3> <m4> <m5>

where each element is a floating point number. The transformation matrix used is given by:

6. <latex-flag> indicates whether or not the <latex-specs> are present. It may be either 1 (present) or 0 (absent).

7. <latex-specs> contains the LaTeX information, and has the format:

<lfam-length> [<lfamily>] <lseries-length> [<lseries>] <lshape-length> [<lshape>] <lsize-length> [<lsize>] <halign> <valign> <ltext-length> [<ltext>]

where:
1. <lfam-length> is an integer indicating the number of characters in <lfamily> where <lfamily> is a string containing the LaTeX family declaration (e.g. \rmfamily). If <lfam-length> is zero, <lfamily> is omitted. (<lfam-length> must not be negative.)

2. <lseries-length> is an integer indicating the number of characters in <lseries> where <lseries> is a string containing the LaTeX series declaration (e.g. \bfseries). If <lseries-length> is zero, <lseries> is omitted. (<lseries-length> must not be negative.)

3. <lshape-length> is an integer indicating the number of characters in <lshape> where <lshape> is a string containing the LaTeX shape declaration (e.g. \itshape). If <lshape-length> is zero, <lshape> is omitted. (<lshape-length> must not be negative.)

4. <lsize-length> is an integer indicating the number of characters in <lsize> where <lsize> is a string containing the LaTeX size declaration (e.g. \large). If <lsize-length> is zero, <lsize> is omitted. (<lsize-length> must not be negative.)

5. <halign> is an integer indicating the horizontal alignment of the \pgfbox command. It may only take one of the following values: 0 (left), 1 (centre) or 2 (right).

6. <valign> is an integer indicating the vertical alignment of the \pgfbox command. It may only take one of the following values: 0 (top), 1 (centre), 2 (base) or 3 (bottom).

7. <ltext-length> is an integer indicating the number of characters in <ltext> where <ltext> is a string containing the LaTeX alternative to <text>. If <ltext-length> is zero, <ltext> is omitted. (<ltext-length> must not be negative.)

8. <text colour> is the text colour. This has the same format as the path line and fill colours described above.

9. <text length> is the number of characters contained in the text area and <text> are the characters contained in the text area. <text length> must be strictly positive.

4. Text-paths are not available for versions below 1.5. For newer versions, the specifications are stored as follows:

<text colour> <fam-length> <family> <shape> <series> <size> <transformation> <latex-flag> [<latex-specs>] <text-length> <text> O|C <n> <start point> <segment data>+

where the text information (<text colour> to <text>) is as described above for text areas. The remaining information is as described above for paths.

5. Rotational patterns are not available for versions below 1.6. For newer versions, the specifications are stored as follows:

<shape-specs><anchor-x><anchor-y><angle><replicas><mode><show>

where:
1. <shape-specs> are the underlying object's specifications as described above. (Bitmap and text specifications not permitted.)

2. <anchor-x> is a floating-point number representing the x-coordinate of the anchor point.

3. <anchor-y> is a floating-point number representing the y-coordinate of the anchor point.

4. <angle> is a floating-point number representing the angle of rotation.

5. <replicas> is an integer representing the number of replicas.

6. <mode> is a boolean variable, true if single-path mode.

7. <show> is a boolean variable, true if the underlying path is visible.

6. Scaled patterns are not available for versions below 1.6. For newer versions, the specifications are stored as follows:

where <shape-specs>, <anchor-x>, <anchor-y>, <replicas>, <mode> and <show> are as above. Additionally:
1. <adjust-x> is a floating-point number representing the x-coordinate of the adjust control point.

2. <adjust-y> is a floating-point number representing the y-coordinate of the adjust control point.

3. <scale-x> is a floating-point number representing the x-scale factor.

4. <scale-y> is a floating-point number representing the y-scale factor.

7. Spiral patterns are not available for versions below 1.6. For newer versions, the specifications are stored as follows:

1. <angle> is a floating-point number representing the spiral angle parameter.

2. <distance> is a floating-point number representing the spiral distance parameter.

8. Bitmap data is stored as follows:

<filename-length> <filename> <latex-flag> [<latex-bitmap-specs>] <transformation>

where:
1. <filename-length> is an integer indicating the number of characters in the file name, and <filename> is the file name. Note that <filename-length> must be strictly positive.

2. <latex-flag> indicates whether or not <latex-bitmap-specs> is present. It may be either 1 (present) or 0 (absent).

3. <latex-bitmaps-specs> has the following format:

<lfilename-length> [<lfilename>] <imgcmd-length> [<imgcmd>]

where <lfilename-length> is an integer indicating the number of characters in <lfilename>, and <lfilename> is the LaTeX path to the bitmap file. If <lfilename-length> is 0, <lfilename> is omitted.

<imgcmd-length> is an integer indicating the number of characters in <imgcmd>, where <imgcmd> is a string containing the LaTeX command name to include the bitmap (e.g. \pgfimage.) If <imgcmd-length> is 0, <imgcmd> is omitted.

4. <transformation> is the transformation matrix, and has the same format as the text area transformation matrix (see above.) The origin is the bottom left corner of the bitmap.

5. Flow frame data is stored as follows:
1. The frame type is stored as an integer. This may only take one of the following values: 0 (static), 1 (flow), 2 (dynamic) and 3 (typeblock). There should only be one typeblock and this should belong to the outermost implicit group.

2. If <type> is not equal to 3 (i.e. is not the typeblock), the following information should also be saved: <border> <label-length> <label> <page list-length> <page list> where:

1. <border> indicates whether or not the frame should have a border, this may be either 1 (border) or 0 (no border).

2. <label-length> <label> is the frame's label where <label-length> is the number of characters in <label>.

3. <page list-length> <page list> is the page list for the frame where <page list-length> is the number of characters in <page list>.

3. The margin information should then be stored in the form: <top> <bottom> <left> <right> where each value is a floating point value.

4. As from AJR v1.2 extra information is contained if the frame type is either 0 (static frame) or 2 (dynamic frame) relating to the paragraph shape. This is an integer that can be 0 (standard shape), 1 (use \parshape) or 2 (use \shapepar).

5. As from AJR v1.3 extra information is contained if the frame type is either 0 (static frame) or 2 (dynamic frame) relating to the vertical alignment of material in the frame. This is an integer that can be 0 (top), 1 (centre) or 2 (bottom).

6. AJR v1.2 onwards also contains the object's description. This is saved in the form:

<desc-length> [<description>]

where <desc-length> is an integer indicating the length of the description string. This may be zero, in which case <description> is omitted.

Previous: JDR Binary Format  Up: Manual Home  Next: Multilingual Support
© 2012 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The logo was derived from a painting by Magdalene Pritchett.