Back to project page donatello-y-raphael.
The source code is released under:
MIT License
If you think the Android project donatello-y-raphael listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.example.ATracePath; /* w w w . j a v a 2 s . c om*/ import android.graphics.Color; import android.util.Log; import java.util.ArrayList; import java.util.List; /** * Created by yngvi on 5.9.2014. */ public class Cellpath { private ArrayList<Coordinate> m_path = new ArrayList<Coordinate>(); public void append( Coordinate co ) { int idx = m_path.indexOf( co ); if ( idx >= 0 ) { for ( int i=m_path.size()-1; i > idx; --i ) { m_path.remove(i); } } else { m_path.add(co); } } public List<Coordinate> getCoordinates() { return m_path; } public void reset() { m_path.clear(); } public boolean isEmpty() { return m_path.isEmpty(); } @Override public String toString() { String str = ""; for (int i = 0; i < m_path.size(); i++) { str += " " + m_path.get(i); } return str; } public boolean findCoordinate(Coordinate co) { for (int i = 0; i < m_path.size(); i++) { if (co.equals(m_path.get(i))) { removeTail(i); return true; } } return false; } public int getColor() { if (m_path.size() > 0) { return m_path.get(0).getColor(); } return Color.TRANSPARENT; } public void removeTail(int index) { m_path = new ArrayList<Coordinate>(m_path.subList(0, index)); } public int pathSize() { return m_path.size(); } }