/* * Copyright 2010-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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. */ package com.amazonaws.services.comprehend.model; import java.io.Serializable; /** *
* The bounding box around the detected page or around an element on a document * page. The left (x-coordinate) and top (y-coordinate) are coordinates that * represent the top and left sides of the bounding box. Note that the * upper-left corner of the image is the origin (0,0). *
** For additional information, see BoundingBox in the Amazon Textract API reference. *
*/ public class BoundingBox implements Serializable { /** ** The height of the bounding box as a ratio of the overall document page * height. *
*/ private Float height; /** ** The left coordinate of the bounding box as a ratio of overall document * page width. *
*/ private Float left; /** ** The top coordinate of the bounding box as a ratio of overall document * page height. *
*/ private Float top; /** ** The width of the bounding box as a ratio of the overall document page * width. *
*/ private Float width; /** ** The height of the bounding box as a ratio of the overall document page * height. *
* * @return* The height of the bounding box as a ratio of the overall document * page height. *
*/ public Float getHeight() { return height; } /** ** The height of the bounding box as a ratio of the overall document page * height. *
* * @param height* The height of the bounding box as a ratio of the overall * document page height. *
*/ public void setHeight(Float height) { this.height = height; } /** ** The height of the bounding box as a ratio of the overall document page * height. *
** Returns a reference to this object so that method calls can be chained * together. * * @param height
* The height of the bounding box as a ratio of the overall * document page height. *
* @return A reference to this updated object so that method calls can be * chained together. */ public BoundingBox withHeight(Float height) { this.height = height; return this; } /** ** The left coordinate of the bounding box as a ratio of overall document * page width. *
* * @return* The left coordinate of the bounding box as a ratio of overall * document page width. *
*/ public Float getLeft() { return left; } /** ** The left coordinate of the bounding box as a ratio of overall document * page width. *
* * @param left* The left coordinate of the bounding box as a ratio of overall * document page width. *
*/ public void setLeft(Float left) { this.left = left; } /** ** The left coordinate of the bounding box as a ratio of overall document * page width. *
** Returns a reference to this object so that method calls can be chained * together. * * @param left
* The left coordinate of the bounding box as a ratio of overall * document page width. *
* @return A reference to this updated object so that method calls can be * chained together. */ public BoundingBox withLeft(Float left) { this.left = left; return this; } /** ** The top coordinate of the bounding box as a ratio of overall document * page height. *
* * @return* The top coordinate of the bounding box as a ratio of overall * document page height. *
*/ public Float getTop() { return top; } /** ** The top coordinate of the bounding box as a ratio of overall document * page height. *
* * @param top* The top coordinate of the bounding box as a ratio of overall * document page height. *
*/ public void setTop(Float top) { this.top = top; } /** ** The top coordinate of the bounding box as a ratio of overall document * page height. *
** Returns a reference to this object so that method calls can be chained * together. * * @param top
* The top coordinate of the bounding box as a ratio of overall * document page height. *
* @return A reference to this updated object so that method calls can be * chained together. */ public BoundingBox withTop(Float top) { this.top = top; return this; } /** ** The width of the bounding box as a ratio of the overall document page * width. *
* * @return* The width of the bounding box as a ratio of the overall document * page width. *
*/ public Float getWidth() { return width; } /** ** The width of the bounding box as a ratio of the overall document page * width. *
* * @param width* The width of the bounding box as a ratio of the overall * document page width. *
*/ public void setWidth(Float width) { this.width = width; } /** ** The width of the bounding box as a ratio of the overall document page * width. *
** Returns a reference to this object so that method calls can be chained * together. * * @param width
* The width of the bounding box as a ratio of the overall * document page width. *
* @return A reference to this updated object so that method calls can be * chained together. */ public BoundingBox withWidth(Float width) { this.width = width; return this; } /** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getHeight() != null) sb.append("Height: " + getHeight() + ","); if (getLeft() != null) sb.append("Left: " + getLeft() + ","); if (getTop() != null) sb.append("Top: " + getTop() + ","); if (getWidth() != null) sb.append("Width: " + getWidth()); sb.append("}"); return sb.toString(); } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getHeight() == null) ? 0 : getHeight().hashCode()); hashCode = prime * hashCode + ((getLeft() == null) ? 0 : getLeft().hashCode()); hashCode = prime * hashCode + ((getTop() == null) ? 0 : getTop().hashCode()); hashCode = prime * hashCode + ((getWidth() == null) ? 0 : getWidth().hashCode()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof BoundingBox == false) return false; BoundingBox other = (BoundingBox) obj; if (other.getHeight() == null ^ this.getHeight() == null) return false; if (other.getHeight() != null && other.getHeight().equals(this.getHeight()) == false) return false; if (other.getLeft() == null ^ this.getLeft() == null) return false; if (other.getLeft() != null && other.getLeft().equals(this.getLeft()) == false) return false; if (other.getTop() == null ^ this.getTop() == null) return false; if (other.getTop() != null && other.getTop().equals(this.getTop()) == false) return false; if (other.getWidth() == null ^ this.getWidth() == null) return false; if (other.getWidth() != null && other.getWidth().equals(this.getWidth()) == false) return false; return true; } }