previous   JDR Binary FormatMultilingual Support   next


AJR Format

Jpgfdraw's 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 file using the AJR.load() and AJR.save() methods. Notes:

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 version 1.1 format.

  2. Next there must be an integer (followed by white space) indicating whether or not the Jpgfdraw || 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 .

    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 (), 1 (inches), 2 (centimetres) or 3 (). To write:
      dout.writeByte(unitType);
      
      To read:
      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 10 (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 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 that constitute the picture. Each is then recursively stored. For example, if a picture contains a , a and a , in the file these three objects will be stored as a single group structure containing the three objects. If in Jpgfdraw you explicitly all the objects, then in the file, the outermost implicit group will contain only one which will be this .

    Each 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
    • G--;
    • P--;
    • T--;
    • I--.
    AJR1.0-1.4
    AJR1.5
    As versions 1.0-1.4. Additionally:
    • X--
    AJR1.5
    AJR1.5
    As versions 1.5. Additionally:
    • R--;
    • C--;
    • L--.
    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 within the , there should then follow <n> lots of <object data>, where <object data> is the data for each within the group, where the object data is as described above.

    2. Path data, P, is stored as follows:
      AJR1.0-1.2
      <line color> <fill color> <line style> O|C <n> <segment data>+
      AJR1.0-1.2
      AJR1.3 onwards
      <line color> <fill color> <line style> O|C <n> <start point> <segment data>+
      AJR1.3 onwards
      where <line color> and <fill color> contain the line and fill color 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. Color data is stored as follows: <col-id> [<color-specs> ], where <col-id> is a character representing the color type. Available types are listed in Table A.4.

        1. Single RGB color 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 color 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 color 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 gray scale data is specified as:

          <G> <A>

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

        5. Linear gradient color data is specified as:

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

          where <start-col-id> is the color identifier for the starting color and <start-col-specs> is the color specification, and <end-col-id> is the color identifier for the end color and <end-col-specs> is the color specification. The color identifiers may be any of those listed in Table A.4 except the linear or radial gradient types. The color 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 color 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 color identifier for the starting color and <start-col-specs> is the color specification, and <end-col-id> is the color identifier for the end color and <end-col-specs> is the color specification. The color identifiers may be any of those listed in Table A.4 except the linear or radial gradient types. The color 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 (Center).

      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> <color 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).

          • <color data> is the marker color. This has the same form as the line/fill/text color data defined earlier, except a transparent value indicates the color 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> <color 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. data is stored as follows:

      <fam-length> <family> <shape> <series> <size> <transformation> <latex-flag> [<latex-specs>] <text color> <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:

        \begin{displaymath}
\left(
\begin{array}{lll}
m_0 & m_2 & m_4\\
m_1 & m_3 & m_5\\
0 & 0 & 1
\end{array}\right)
\end{displaymath}

      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 (center) 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 (center), 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 color> is the text color. This has the same format as the path line and fill colors described above.

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

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

      <text color> <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 color> to <text>) is as described above for . The remaining information is as described above for .

    5. 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. are not available for versions below 1.6. For newer versions, the specifications are stored as follows:

      <shape-specs><anchor-x><anchor-y><adjust-x><adjust-y><scale-x><scale-y><replicas><mode><show>

      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. are not available for versions below 1.6. For newer versions, the specifications are stored as follows:

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

      where <shape-specs>, <anchor-x>, <anchor-y>, <adjust-x>, <adjust-y>, <replicas>, <mode> and <show> are as above. Additionally:
      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 transformation matrix (see above.) The origin is the bottom left corner of the .

  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 (center) 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 FormatMultilingual Support   next