/* * 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 IntegerVector4D implements Serializable, Cloneable { private static final long serialVersionUID = 1L; private final int x; private final int y; private final int z; private final int w; /** * @param x * @param y * @param z * @param w */ public IntegerVector4D(final int x, final int y, final int z, final int w) { this.x = x; this.y = y; this.z = z; this.w = w; } /** * @return the w */ public int getW() { return w; } /** * @return the x */ public int getX() { return x; } /** * @return the y */ public int getY() { return y; } /** * @return the z */ public int getZ() { return z; } /** * @see java.lang.Object#toString() */ @Override public String toString() { final StringBuilder builder = new StringBuilder(); builder.append(x); builder.append(", "); builder.append(y); builder.append(", "); builder.append(z); builder.append(", "); builder.append(w); return builder.toString(); } /** * @param value * @return */ public static IntegerVector4D valueOf(final String value) { final StringTokenizer tkn = new StringTokenizer(value, ","); final String x = tkn.nextToken().trim(); final String y = tkn.nextToken().trim(); final String z = tkn.nextToken().trim(); final String w = tkn.nextToken().trim(); return new IntegerVector4D(Integer.valueOf(x), Integer.valueOf(y), Integer.valueOf(z), Integer.valueOf(w)); } /** * @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 IntegerVector4D other = (IntegerVector4D) obj; if (w != other.w) { return false; } if (x != other.x) { return false; } if (y != other.y) { return false; } if (z != other.z) { return false; } return true; } /** * @see java.lang.Object#clone() */ @Override public IntegerVector4D clone() { return new IntegerVector4D(x, y, z, w); } }