// /* // * Copyright 2009 ZXing authors // * // * Licensed under the Apache License, Version 2.0 (the "License"); // * you may not use this file except in compliance with the License. // * You may obtain a copy of the License at // * // * http://www.apache.org/licenses/LICENSE-2.0 // * // * Unless required by applicable law or agreed to in writing, software // * distributed under the License is distributed on an "AS IS" BASIS, // * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // * See the License for the specific language governing permissions and // * limitations under the License. // */ using System; using ZXing.Common; namespace ZXing.PDF417.Internal { /// /// A Codeword in the PDF417 barcode /// /// Guenther Grau (Java Core) /// Stephen Furlani (C# Port) public sealed class Codeword { /// /// Default value for the RowNumber (-1 being an invalid real number) /// private static readonly int BARCODE_ROW_UNKNOWN = -1; public int StartX { get; private set; } public int EndX { get; private set; } public int Bucket { get; private set; } public int Value { get; private set; } public int RowNumber { get; set; } /// /// Initializes a new instance of the class. /// /// Start x. /// End x. /// Bucket. /// Value. public Codeword(int startX, int endX, int bucket, int value) { this.StartX = startX; this.EndX = endX; this.Bucket = bucket; this.Value = value; this.RowNumber = BARCODE_ROW_UNKNOWN; } /// /// Gets the width. /// /// The width. public int Width { get { return EndX - StartX; } } /// /// Gets a value indicating whether this instance has valid row number. /// /// true if this instance has valid row number; otherwise, false. public bool HasValidRowNumber { get { return IsValidRowNumber(RowNumber); } } /// /// Determines whether this instance is valid row number the specified rowNumber. /// /// true if this instance is valid row number the specified rowNumber; otherwise, false. /// Row number. public bool IsValidRowNumber(int rowNumber) { return rowNumber != BARCODE_ROW_UNKNOWN && Bucket == (rowNumber % 3) * 3; } /// /// Sets the row number as the row's indicator column. /// public void SetRowNumberAsRowIndicatorColumn() { this.RowNumber = (Value / 30) * 3 + Bucket / 3; } /// /// Returns a that represents the current . /// /// A that represents the current . public override string ToString() { return RowNumber + "|" + Value; } } }