/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.
 */
package org.apache.fontbox.util;


import java.util.List;

/**
 * This is an implementation of a bounding box.  This was originally written for the
 * AMF parser.
 *
 * @author Ben Litchfield (ben@benlitchfield.com)
 */
public class BoundingBox
{
    private float lowerLeftX;
    private float lowerLeftY;
    private float upperRightX;
    private float upperRightY;

    /**
     * Default constructor.
     */
    public BoundingBox() 
    {
    }
    
    /**
     * Constructor.
     * 
     * @param minX lower left x value
     * @param minY lower left y value
     * @param maxX upper right x value
     * @param maxY upper right y value
     */
    public BoundingBox(float minX, float minY, float maxX, float maxY) 
    {
        lowerLeftX = minX;
        lowerLeftY = minY;
        upperRightX = maxX;
        upperRightY = maxY;
    }

    /**
     * Constructor.
     *
     * @param numbers list of four numbers
     */
    public BoundingBox(List<Number> numbers)
    {
        lowerLeftX = numbers.get(0).floatValue();
        lowerLeftY = numbers.get(1).floatValue();
        upperRightX = numbers.get(2).floatValue();
        upperRightY = numbers.get(3).floatValue();
    }

    /**
     * Getter for property lowerLeftX.
     *
     * @return Value of property lowerLeftX.
     */
    public float getLowerLeftX()
    {
        return lowerLeftX;
    }

    /**
     * Setter for property lowerLeftX.
     *
     * @param lowerLeftXValue New value of property lowerLeftX.
     */
    public void setLowerLeftX(float lowerLeftXValue)
    {
        this.lowerLeftX = lowerLeftXValue;
    }

    /**
     * Getter for property lowerLeftY.
     *
     * @return Value of property lowerLeftY.
     */
    public float getLowerLeftY()
    {
        return lowerLeftY;
    }

    /**
     * Setter for property lowerLeftY.
     *
     * @param lowerLeftYValue New value of property lowerLeftY.
     */
    public void setLowerLeftY(float lowerLeftYValue)
    {
        this.lowerLeftY = lowerLeftYValue;
    }

    /**
     * Getter for property upperRightX.
     *
     * @return Value of property upperRightX.
     */
    public float getUpperRightX()
    {
        return upperRightX;
    }

    /**
     * Setter for property upperRightX.
     *
     * @param upperRightXValue New value of property upperRightX.
     */
    public void setUpperRightX(float upperRightXValue)
    {
        this.upperRightX = upperRightXValue;
    }

    /**
     * Getter for property upperRightY.
     *
     * @return Value of property upperRightY.
     */
    public float getUpperRightY()
    {
        return upperRightY;
    }

    /**
     * Setter for property upperRightY.
     *
     * @param upperRightYValue New value of property upperRightY.
     */
    public void setUpperRightY(float upperRightYValue)
    {
        this.upperRightY = upperRightYValue;
    }
    
    /**
     * This will get the width of this rectangle as calculated by
     * upperRightX - lowerLeftX.
     *
     * @return The width of this rectangle.
     */
    public float getWidth()
    {
        return getUpperRightX() - getLowerLeftX();
    }

    /**
     * This will get the height of this rectangle as calculated by
     * upperRightY - lowerLeftY.
     *
     * @return The height of this rectangle.
     */
    public float getHeight()
    {
        return getUpperRightY() - getLowerLeftY();
    }
    
    /**
     * Checks if a point is inside this rectangle.
     * 
     * @param x The x coordinate.
     * @param y The y coordinate.
     * 
     * @return true If the point is on the edge or inside the rectangle bounds. 
     */
    public boolean contains( float x, float y )
    {
        return x >= lowerLeftX && x <= upperRightX &&
               y >= lowerLeftY && y <= upperRightY;
    }
    
    /**
     * This will return a string representation of this rectangle.
     *
     * @return This object as a string.
     */
    public String toString()
    {
        return "[" + getLowerLeftX() + "," + getLowerLeftY() + "," +
                     getUpperRightX() + "," + getUpperRightY() +"]";
    }

    /**
     * Unions the given bounding boxes and puts the result into the 
     * specified result bounding box.
     * 
     * @param bBox1 the first bounding box to be combined with each other
     * @param bBox2 the second bounding box to be combined with each other
     * @param result the bounding box that holds the results of the union
     * 
     */
    public static void union(BoundingBox bBox1, BoundingBox bBox2, BoundingBox result)
    {
        float x1 = Math.min(bBox1.getLowerLeftX(), bBox2.getLowerLeftX());
        float y1 = Math.min(bBox1.getLowerLeftY(), bBox2.getLowerLeftY());
        float x2 = Math.max(bBox1.getUpperRightX(), bBox2.getUpperRightX());
        float y2 = Math.max(bBox1.getUpperRightY(), bBox2.getUpperRightY());
        if (x2 < x1)
        {
            float temp = x1;
            x1 = x2;
            x2 = temp;
        }
        if (y2 < y1)
        {
            float temp = y1;
            y1 = y2;
            y2 = temp;
        }
        result = new BoundingBox(x1, y1, x2, y2);
    }
}
@@ -4726,32 +4726,46 @@
 string.%0A     */%0A
+    @Override%0A
     public Strin
@@ -4777,16 +4777,16 @@
 tring()%0A
-
     %7B%0A  
@@ -4932,1048 +4932,5 @@
  %7D%0A%0A
-    /**%0A     * Unions the given bounding boxes and puts the result into the %0A     * specified result bounding box.%0A     * %0A     * @param bBox1 the first bounding box to be combined with each other%0A     * @param bBox2 the second bounding box to be combined with each other%0A     * @param result the bounding box that holds the results of the union%0A     * %0A     */%0A    public static void union(BoundingBox bBox1, BoundingBox bBox2, BoundingBox result)%0A    %7B%0A        float x1 = Math.min(bBox1.getLowerLeftX(), bBox2.getLowerLeftX());%0A        float y1 = Math.min(bBox1.getLowerLeftY(), bBox2.getLowerLeftY());%0A        float x2 = Math.max(bBox1.getUpperRightX(), bBox2.getUpperRightX());%0A        float y2 = Math.max(bBox1.getUpperRightY(), bBox2.getUpperRightY());%0A        if (x2 %3C x1)%0A        %7B%0A            float temp = x1;%0A            x1 = x2;%0A            x2 = temp;%0A        %7D%0A        if (y2 %3C y1)%0A        %7B%0A            float temp = y1;%0A            y1 = y2;%0A            y2 = temp;%0A        %7D%0A        result = new BoundingBox(x1, y1, x2, y2);%0A    %7D%0A
 %7D

remove method introduced in rev 1604572 that isn't used anymore and did nothing due to error in last line