Commit 848fa317 authored by Aliaksandr Halavatyi's avatar Aliaksandr Halavatyi
Browse files

imaplementing WellPosition class

parent 5b27b301
......@@ -8,7 +8,7 @@
<version>5.0</version> <relativePath /> </parent> -->
<description>Collection of tools for automated (feedback) microscopy data acquisition and analysis</description>
package automic.geom;
public class WellPosition implements Comparable<WellPosition> {
private String well;
private Integer position;
public WellPosition(String _well, int _position) {
public String getWell() {
return well;
public int getPosition() {
return position;
public int compareTo(WellPosition reference){
int wellComparison=this.well.compareTo(reference.well);
if (wellComparison!=0)
return wellComparison;
return this.position.compareTo(reference.position);
public String toString() {
return String.format("Well: %s; Position: %d", well, position);
public final int hashCode() {
int result = 1000;
if (well != null) {
result = 31 * result + well.hashCode();
if (position != null) {
result = 31 * result + position;
return result;
public boolean equals(Object reference) {
if (reference == this)
return true;
if (!(reference instanceof WellPosition))
return false;
WellPosition referenceO = (WellPosition) reference;
return (this.compareTo(referenceO)==0);
package automic.geom;
import java.util.LinkedHashMap;
import java.util.Map;
public class TestWellPosition {
public static void main(String[] args){
WellPosition wp1=new WellPosition("A01", 1);
WellPosition wp1_1=new WellPosition("A01", 1);
WellPosition wp1_2=new WellPosition("A01", 2);
WellPosition wp2_1=new WellPosition("B02", 1);
WellPosition wp2_2=new WellPosition("B02", 2);
System.out.println(String.format("(%s) compared to (%s): %s", wp1, wp1_1,(wp1.compareTo(wp1_1))));
System.out.println(String.format("(%s) compared to (%s): %s", wp1, wp1_2,(wp1.compareTo(wp1_2))));
System.out.println(String.format("(%s) compared to (%s): %s", wp1, wp2_1,(wp1.compareTo(wp2_1))));
System.out.println(String.format("(%s) compared to (%s): %s", wp2_2, wp2_1,(wp2_2.compareTo(wp2_1))));
Map<WellPosition, Point3D> platePositions=new LinkedHashMap<WellPosition, Point3D>();
platePositions.put(wp1_1, new Point3D(0, 0, 0));
platePositions.put(wp1, new Point3D(0, 0, 0));
System.out.println(String.format("(%s) hash code is: %d", wp1, wp1.hashCode()));
System.out.println(String.format("(%s) hash code is: %d", wp1_1, wp1_1.hashCode()));
System.out.println(String.format("(%s) hash code is: %d", wp1_2, wp1_2.hashCode()));
System.out.println(String.format("(%s) hash code is: %d", wp2_1, wp2_1.hashCode()));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment