Commit b6214a15 authored by Falucho's avatar Falucho

SVG

parent af1eec9f
......@@ -5,8 +5,11 @@ import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.List;
import java.util.*;
public class ProcesarMatriz {
......@@ -117,6 +120,40 @@ public class ProcesarMatriz {
return result;
}
public static void mergeToSvg(List<Parada> nodos, List<Parada> sig) throws Exception {
int SIZE_X = 3726;
int SIZE_Y = 2343;
StringBuilder sb = new StringBuilder("<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"" + SIZE_X + "\" height=\"" + SIZE_Y + "\">\n");
sig.forEach(e -> {
Parada centro = nodos.stream().min(Comparator.comparing(o -> dist(o, e))).get();
sb.append("<line x1=\"").append(centro.getCoordX().intValue())
.append("\" y1=\"").append(2342 - centro.getCoordY().intValue())
.append("\" x2=\"").append(e.getCoordX().intValue())
.append("\" y2=\"").append(2342 - e.getCoordY().intValue())
.append("\" style=\"stroke:rgb(255, 255, 100);stroke-width:2\"/>\n");
});
for (Parada parada : sig) {
sb.append("<circle cx=\"").append(parada.getCoordX().intValue())
.append("\" cy=\"").append(2342 - parada.getCoordY().intValue())
.append("\" r=\"2\" stroke=\"red\" stroke-width=\"1\" fill=\"red\"/>\n");
}
for (Parada parada : nodos) {
sb.append("<circle cx=\"").append(parada.getCoordX().intValue())
.append("\" cy=\"").append(2342 - parada.getCoordY().intValue())
.append("\" r=\"5\" stroke=\"green\" stroke-width=\"1\" fill=\"green\"/>\n");
}
sb.append("</svg>");
Files.write(Paths.get(WORK_DIR + "CentrosCercanos.svg"), sb.toString().getBytes(), StandardOpenOption.CREATE_NEW);
}
public static void mergeToImg(List<Parada> nodos, List<Parada> sig) throws Exception {
int SIZE_X = 3726;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment