/* SOMParticle.java * * You may use and distribute under the terms of either the GNU Lesser * General Public License, either version 2 of the license or, * at your choice, any later version. Alternatively, you may use and * distribute under the terms of the XPL. * * See the LICENSE.lgpl and LICENSE.xpl files for the specific terms of * the licenses. * * This software 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 README * file for more details. * */ /* * Written by Kimmo Wideroos */ // som particle, implements ZZMap.Particle interface package org.gzigzag.map; import org.gzigzag.*; import java.util.*; public class SOMParticle implements ZZMap.Particle { private float x, y; private int[] q; private float priority = 0; private int id; private ZZCell cell; public SOMParticle(int id, ZZCell c, float x, float y, int[] q) { this.q = new int[q.length]; System.arraycopy(q, 0, this.q, 0, q.length); this.x = x; this.y = y; this.id = id; this.cell = c; } public SOMParticle(int id, ZZCell c, int[] q) { this.q = new int[q.length]; System.arraycopy(q, 0, this.q, 0, q.length); Random r = new Random(System.currentTimeMillis()); this.x = r.nextFloat(); this.y = r.nextFloat(); this.id = id; this.cell = c; } public int id() { return id; } public ZZCell cell() { return this.cell; } public int q(int ind) { return q[ind]; } public int[] q() { return q; } public void setq(int ind, int qval) { q[ind] = qval; } public float x() { return x; } public float y() { return y; } public void x(float new_x) { x = new_x; } public void y(float new_y) { y = new_y; } public float[] coord() { return new float[] {x, y}; } public void coord(float[] new_c) { x = new_c[0]; y = new_c[1]; } public float priority() { return priority; } public void setPriority(float new_p) { priority = new_p; } public int size() { return q.length; } }