⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 footprint.java

📁 Java source code for the Ant Colony Optimization Problem.
💻 JAVA
字号:
package jwo.jpss.spatial;   // Part of the spatial modelling package.
import java.io.Serializable;

//  ***************************************************************
/** Class for defining the spatial footprint of an object.
  * Using this class to wrap all public communication of locations
  * and boundaries ensures maximum flexibility. Current model 
  * assumes 2d Cartesian referencing, but can be adapted in future.
  * @author Jo Wood
  * @version 1.2, 6th September, 2001.
  */
//  ***************************************************************

public class Footprint implements Serializable
{
    // ----------------- Object variables --------------------
    		    
    private float x,y,             // Point location/origin.
    	          width,height;    // Width and height of MER.
    private int   type;            // Type of spatial footprint.
    
    // ------------------- Constructors ----------------------
       
    /** Creates a point footprint with given x,y location.
      * @param x X coordinate of footprint's location. 
      * @param y Y coordinate of footprint's location.
      */
    public Footprint(float x, float y)
    {
    	this.x = x;
    	this.y = y;
    	width  = 0;
    	height = 0;
    	type   = SpatialModel.POINT;
    }
    
    /** Creates a 2d areal footprint with given origin, width and height.
      * @param x X coordinate of footprint's origin. 
      * @param y Y coordinate of footprint's origin.
      * @param width Width of object (in x direction).
      * @param height Height of object (in y direction).
      */
    public Footprint(float x, float y, float width, float height)
    {
    	this.x      = x;
    	this.y      = y;
    	this.width  = width;
    	this.height = height;
    	type        = SpatialModel.AREA;
    }

    // -------------- Accessor/mutator methods ---------------
    
    /** Reports the x origin of the footprint.
      * @return xOrigin Cartesian x coordinate of footprint.
      */
    public float getXOrigin()
    {
    	return x;
    }
    
    /** Sets the x origin of the footprint.
      * @param xOrigin New x origin of the footprint.
      */
    public void setXOrigin(float xOrigin)
    {
    	this.x = xOrigin;
    }
    
    /** Reports the y origin of the footprint.
      * @return yOrigin Cartesian y coordinate of footprint.
      */
    public float getYOrigin()
    {
    	return y;
    }
    
    /** Sets the y origin of the footprint.
      * @param yOrigin New y origin of the footprint.
      */
    public void setYOrigin(float yOrigin)
    {
    	this.y = yOrigin;
    }
    
    /** Reports the width of the footprint's Minimum Enclosing Rectangle.
      * @return width MER's width (in the x direction).
      */
    public float getMERWidth()
    {
    	return width;
    }
    
    /** Sets the width of the footprint's Minimum Enclosing Rectangle.
      * @param width New width of the MER (in the x direction).
      */
    public void setMERWidth(float width)
    {
    	this.width = width;
    }
        
    /** Reports the height of the footprint's Minimum Enclosing Rectangle.
      * @return height MER's height (in the y direction).
      */
    public float getMERHeight()
    {
    	return height;
    }
    
   /** Sets the width of the footprint's Minimum Enclosing Rectangle.
      * @param width New width of the MER (in the x direction).
      */
    public void setMERHeight(float height)
    {
    	this.height = height;
    }
    
    /** Reports the type of spatial footprint.
      * @return Type of spatial footprint.
      */
    public int getType()
    {
    	return type;
    }
    
    /** Sets the type of spatial footprint.
      * @param type Type of spatial footprint.
      */
    public void setType(int type)
    {
    	this.type = type;
    }

    // ---------------------- Overridden methods -----------------------

    /** Reports the details of this footprint.
      * @return Summary of this footprint.
      */
    public String toString()
    {
        return new String("Footprint with corners ("+x+","+y+") and ("+
                          (x+width)+","+(y+height)+")");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -