Skip to content

Commit

Permalink
Minor fixes to OnScreenLineTracker
Browse files Browse the repository at this point in the history
  • Loading branch information
marigostra committed Apr 29, 2021
1 parent 7409f61 commit 5a16f5d
Showing 1 changed file with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import org.luwrain.core.*;

public final class OnScreenLineTracker
final class OnScreenLineTracker
{
final class Vertex
{
Expand Down Expand Up @@ -75,7 +75,7 @@ void clear()
vertices.clear();
}

public OnScreenLine[] getLines()
OnScreenLine[] getLines()
{
if (vertices.size() < 2)
return new OnScreenLine[0];
Expand All @@ -98,8 +98,8 @@ private void addVertex(int pos)
int i = 0;
while(i < vertices.size() && vertices.get(i).pos < pos)
i++;
if (i < vertices.size() && vertices.get(i).pos == pos)
return;
if (i < vertices.size() && vertices.get(i).pos == pos)
return;
boolean followed = i > 0?vertices.get(i - 1).followed:false;
if (i < vertices.size())
vertices.add(i, new Vertex(pos, followed)); else
Expand All @@ -119,23 +119,19 @@ private void removeNeedless()
}
if (offset > 0)
{
final List<Vertex> t = vertices.subList(offset, vertices.size());
vertices.clear();
vertices.addAll(t);
vertices = new ArrayList(vertices.subList(offset, vertices.size()));
}
if (vertices.size() < 2)
return;
//The doubling removing;
offset = 0;
// Removing the items which present twice
offset = 0;
for(int i = 1;i < vertices.size();i++)
{
if (vertices.get(i - 1 - offset).followed == vertices.get(i).followed)
offset++; else
vertices.set(i - offset, vertices.get(i));
}
final List<Vertex> t = vertices.subList(0, vertices.size() - offset);
vertices.clear();
vertices.addAll(t);
vertices = new ArrayList(vertices.subList(0, vertices.size() - offset));
if (!vertices.isEmpty() && (vertices.size() % 2) != 0)
{
Log.warning("interaction", "on screen lines tracking has odd vertex count:" + vertices.size() + ", clearing content");
Expand Down

0 comments on commit 5a16f5d

Please sign in to comment.