/* * JAME 6.2.1 * http://jame.sourceforge.net * * Copyright 2001, 2016 Andrea Medeghini * * This file is part of JAME. * * JAME is an application for creating fractals and other graphics artifacts. * * JAME is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * JAME is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with JAME. If not, see <http://www.gnu.org/licenses/>. * */ package net.sf.jame.core.util; import java.io.Serializable; import java.util.StringTokenizer; /** * @author Andrea Medeghini */ public class IntegerVector2D implements Serializable, Cloneable { private static final long serialVersionUID = 1L; private int x; private int y; /** * */ public IntegerVector2D() { } /** * @param x * @param y */ public IntegerVector2D(final int x, final int y) { this.x = x; this.y = y; } /** * @return the x */ public int getX() { return x; } /** * @return the y */ public int getY() { return y; } /** * @see java.lang.Object#toString() */ @Override public String toString() { final StringBuilder builder = new StringBuilder(); builder.append(x); builder.append(", "); builder.append(y); return builder.toString(); } /** * @param value * @return */ public static IntegerVector2D valueOf(final String value) { final StringTokenizer tkn = new StringTokenizer(value, ","); final String x = tkn.nextToken().trim(); final String y = tkn.nextToken().trim(); return new IntegerVector2D(Integer.valueOf(x), Integer.valueOf(y)); } /** * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } final IntegerVector2D other = (IntegerVector2D) obj; if (x != other.x) { return false; } if (y != other.y) { return false; } return true; } /** * @see java.lang.Object#clone() */ @Override public IntegerVector2D clone() { return new IntegerVector2D(x, y); } }