All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.datasyslab.geosparkviz.utils.Pixel Maven / Gradle / Ivy

There is a newer version: 1.1.3
Show newest version
/**
 * FILE: Pixel.java
 * PATH: org.datasyslab.geosparkviz.utils.Pixel.java
 * Copyright (c) 2015-2017 GeoSpark Development Team
 * All rights reserved.
 */
package org.datasyslab.geosparkviz.utils;

import java.io.Serializable;

// TODO: Auto-generated Javadoc
/**
 * The Class Pixel.
 */
public class Pixel implements Serializable{
    
    /** The x. */
    private int x;
    
    /** The y. */
    private int y;
    
    /** The resolution X. */
    private int resolutionX;
    
    /** The resolution Y. */
    private int resolutionY;
    
    /** The is duplicate. */
    private boolean isDuplicate = false;
    
    /** The current partition id. */
    private int currentPartitionId = -1;

    /**
     * Instantiates a new pixel.
     *
     * @param x the x
     * @param y the y
     * @param resolutionX the resolution X
     * @param resolutionY the resolution Y
     * @param isDuplicate the is duplicate
     * @param currentPartitionId the current partition id
     */
    public Pixel(int x, int y, int resolutionX, int resolutionY, boolean isDuplicate, int currentPartitionId)
    {
        this.x = x;
        this.y = y;
        this.resolutionX=resolutionX;
        this.resolutionY=resolutionY;
        this.isDuplicate = isDuplicate;
        this.currentPartitionId = currentPartitionId;
    }

    /**
     * Instantiates a new pixel.
     *
     * @param x the x
     * @param y the y
     * @param resolutionX the resolution X
     * @param resolutionY the resolution Y
     */
    public Pixel(int x, int y, int resolutionX, int resolutionY)
    {
        this.x = x;
        this.y = y;
        this.resolutionX=resolutionX;
        this.resolutionY=resolutionY;
    }
    
    /**
     * Checks if is duplicate.
     *
     * @return true, if is duplicate
     */
    public boolean isDuplicate() {
        return isDuplicate;
    }

    /**
     * Sets the duplicate.
     *
     * @param duplicate the new duplicate
     */
    public void setDuplicate(boolean duplicate) {
        isDuplicate = duplicate;
    }

    /**
     * Gets the current partition id.
     *
     * @return the current partition id
     */
    public int getCurrentPartitionId() {
        return currentPartitionId;
    }

    /**
     * Sets the current partition id.
     *
     * @param currentPartitionId the new current partition id
     */
    public void setCurrentPartitionId(int currentPartitionId) {
        this.currentPartitionId = currentPartitionId;
    }

    /**
     * Gets the x.
     *
     * @return the x
     */
    public int getX() {
        return x;
    }

    /**
     * Gets the y.
     *
     * @return the y
     */
    public int getY() {
        return y;
    }


    /* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object o) {

        /*
        Pixel anotherObject = (Pixel) o;
        if(this.hashCode()==anotherObject.hashCode()&&this.getCurrentPartitionId()==anotherObject.getCurrentPartitionId()&&this.isDuplicate()==anotherObject.isDuplicate())
        {
            return true;
        }
        else return false;
        */
        return this.hashCode()==o.hashCode();
    }



    /* (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        /*
        int result = 17;
        result = 31 * result + this.getX();
        result = 31 * result + this.getY();
        //result = 31 * result + this.getCurrentPartitionId();
        return result;
        */
        int id = -1;
        try {
            id = RasterizationUtils.Encode2DTo1DId(resolutionX,resolutionY,x,y);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return id;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy