Ejemplo n.º 1
0
  /**
   * Gets the binary data for output to file
   *
   * @return the binary data
   */
  public byte[] getData() {
    data = new byte[34];

    // Paper size
    IntegerHelper.getTwoBytes(paperSize, data, 0);

    // Scale factor
    IntegerHelper.getTwoBytes(scaleFactor, data, 2);

    // Page start
    IntegerHelper.getTwoBytes(pageStart, data, 4);

    // Fit width
    IntegerHelper.getTwoBytes(fitWidth, data, 6);

    // Fit height
    IntegerHelper.getTwoBytes(fitHeight, data, 8);

    // grbit
    int options = 0;
    if (orientation == PageOrientation.PORTRAIT) {
      options |= 0x02;
    }

    if (pageStart != 0) {
      options |= 0x80;
    }

    if (!initialized) {
      options |= 0x04;
    }

    IntegerHelper.getTwoBytes(options, data, 10);

    // print resolution
    IntegerHelper.getTwoBytes(horizontalPrintResolution, data, 12);

    // vertical print resolution
    IntegerHelper.getTwoBytes(verticalPrintResolution, data, 14);

    // header margin
    DoubleHelper.getIEEEBytes(headerMargin, data, 16);

    // footer margin
    DoubleHelper.getIEEEBytes(footerMargin, data, 24);

    // Number of copies
    IntegerHelper.getTwoBytes(copies, data, 32);

    return data;
  }
Ejemplo n.º 2
0
  /**
   * Gets the token representation of this item in RPN
   *
   * @return the bytes applicable to this formula
   */
  byte[] getBytes() {
    byte[] data = new byte[9];
    data[0] = Token.DOUBLE.getCode();

    DoubleHelper.getIEEEBytes(value, data, 1);

    return data;
  }
Ejemplo n.º 3
0
  /**
   * Reads the ptg data from the array starting at the specified position
   *
   * @param data the RPN array
   * @param pos the current position in the array, excluding the ptg identifier
   * @return the number of bytes read
   */
  public int read(byte[] data, int pos) {
    value = DoubleHelper.getIEEEDouble(data, pos);

    return 8;
  }