use of aimax.osm.data.entities.Track in project aima-java by aimacode.
the class DefaultEntityRenderer method printBufferedObjects.
// int awnodes = 0;
/** Prints all buffered entities according to their rendering informations. */
public void printBufferedObjects() {
Collections.sort(areaBuffer, new MapAreaComparator());
Comparator<MapEntity> comp = new MapEntityComparator();
if (wayBuffer.size() < 10000)
Collections.sort(wayBuffer, comp);
if (nodeBuffer.size() < 10000)
Collections.sort(nodeBuffer, comp);
for (MapWay area : areaBuffer) printWay(area, (DefaultEntityViewInfo) area.getViewInfo(), true);
for (MapWay way : wayBuffer) printWay(way, (DefaultEntityViewInfo) way.getViewInfo(), false);
for (MapEntity node : nodeBuffer) {
MapNode n;
if (node instanceof MapWay) {
List<MapNode> wayNodes = getWayNodes((MapWay) node);
// needed to show icons for ways, whose abstraction is empty.
if (wayNodes.isEmpty())
wayNodes = ((MapWay) node).getNodes();
n = wayNodes.get(0);
} else
n = (MapNode) node;
printNode(n, (DefaultEntityViewInfo) node.getViewInfo());
}
for (Track track : trackBuffer) printTrack(track);
// System.out.print("NamesOrg: " + nameInfoBuffer.size() + "\n");
Collections.sort(nameInfoBuffer);
// remove names whose positions are to close to each other
int charSize = (int) (defaultFontSize * displayFactorSym);
for (int i = 0; i < nameInfoBuffer.size(); ++i) {
NameInfo info = nameInfoBuffer.get(i);
for (int j = 0; j < i; ++j) {
NameInfo info1 = nameInfoBuffer.get(j);
int fac = (info.name.equals(info1.name)) ? 3 : 2;
if (Math.abs(info.y - info1.y) < charSize * fac) {
fac = (info.x < info1.x) ? info.name.length() : info1.name.length();
if (Math.abs(info.x - info1.x) < charSize * fac) {
nameInfoBuffer.remove(i);
--i;
j = i;
}
}
}
}
for (NameInfo textInfo : nameInfoBuffer) {
imageBdr.setColor(textInfo.color);
imageBdr.drawString(textInfo.name, textInfo.x, textInfo.y);
}
// System.out.print("Areas: " + areaBuffer.size() + " ");
// System.out.print("Ways: " + wayBuffer.size() + " ");
// System.out.print("Nodes: " + nodeBuffer.size() + " ");
// System.out.print("Names: " + nameInfoBuffer.size() + "\n");
}
use of aimax.osm.data.entities.Track in project aima-java by aimacode.
the class DefaultMap method addToTrack.
/** {@inheritDoc} */
@Override
public void addToTrack(String trackName, Position pos) {
Track track = getTrack(trackName);
if (track == null) {
track = new DefaultTrack(nextTrackId++, trackName, trackName);
updateEntityViewInfo(track, false);
tracks.add(track);
}
track.addNode(pos);
fireMapDataEvent(new MapEvent(this, MapEvent.Type.TRACK_MODIFIED, track.getId()));
}
use of aimax.osm.data.entities.Track in project aima-java by aimacode.
the class DefaultMap method createTrack.
/** {@inheritDoc} */
@Override
public void createTrack(String trackName, List<Position> positions) {
clearTrack(trackName);
Track track = new DefaultTrack(nextTrackId++, trackName, trackName);
updateEntityViewInfo(track, false);
tracks.add(track);
for (Position pos : positions) track.addNode(pos);
fireMapDataEvent(new MapEvent(this, MapEvent.Type.TRACK_MODIFIED, track.getId()));
}
use of aimax.osm.data.entities.Track in project aima-java by aimacode.
the class DefaultMap method clearTrack.
/** {@inheritDoc} */
@Override
public void clearTrack(String trackName) {
Track track = getTrack(trackName);
if (track != null) {
tracks.remove(track);
fireMapDataEvent(new MapEvent(this, MapEvent.Type.MAP_MODIFIED));
}
}