Search in sources :

Example 1 with Track

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");
}
Also used : MapWay(aimax.osm.data.entities.MapWay) MapEntity(aimax.osm.data.entities.MapEntity) MapNode(aimax.osm.data.entities.MapNode) Track(aimax.osm.data.entities.Track)

Example 2 with Track

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()));
}
Also used : MapEvent(aimax.osm.data.MapEvent) Track(aimax.osm.data.entities.Track)

Example 3 with Track

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()));
}
Also used : Position(aimax.osm.data.Position) MapEvent(aimax.osm.data.MapEvent) Track(aimax.osm.data.entities.Track)

Example 4 with Track

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));
    }
}
Also used : MapEvent(aimax.osm.data.MapEvent) Track(aimax.osm.data.entities.Track)

Aggregations

Track (aimax.osm.data.entities.Track)4 MapEvent (aimax.osm.data.MapEvent)3 Position (aimax.osm.data.Position)1 MapEntity (aimax.osm.data.entities.MapEntity)1 MapNode (aimax.osm.data.entities.MapNode)1 MapWay (aimax.osm.data.entities.MapWay)1