mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
Modified signature for returning the file instance (Heroku read-only needs this)
This commit is contained in:
parent
d95b1d2f14
commit
6e13ce07f0
1 changed files with 13 additions and 10 deletions
|
|
@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.geom.Ellipse2D;
|
import java.awt.geom.Ellipse2D;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -270,20 +271,21 @@ public class Plotter {
|
||||||
*
|
*
|
||||||
* @param pngFileName - path and filename
|
* @param pngFileName - path and filename
|
||||||
* @param plotTitle - title that appears on top of image
|
* @param plotTitle - title that appears on top of image
|
||||||
|
* @return BufferedImage image to write
|
||||||
*/
|
*/
|
||||||
public void plot(String pngFileName, String plotTitle) {
|
public BufferedImage plot(String pngFileName, String plotTitle) {
|
||||||
String filename = pngFileName;
|
String filename = pngFileName;
|
||||||
if (!pngFileName.endsWith(".png")) filename += ".png";
|
if (!pngFileName.endsWith(".png")) filename += ".png";
|
||||||
if (plotSolutionAsWell) {
|
if (plotSolutionAsWell) {
|
||||||
plot(vrp, routes, filename, plotTitle);
|
return plot(vrp, routes, filename, plotTitle);
|
||||||
} else if (!(vrp.getInitialVehicleRoutes().isEmpty())) {
|
} else if (!(vrp.getInitialVehicleRoutes().isEmpty())) {
|
||||||
plot(vrp, vrp.getInitialVehicleRoutes(), filename, plotTitle);
|
return plot(vrp, vrp.getInitialVehicleRoutes(), filename, plotTitle);
|
||||||
} else {
|
} else {
|
||||||
plot(vrp, null, filename, plotTitle);
|
return plot(vrp, null, filename, plotTitle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void plot(VehicleRoutingProblem vrp, final Collection<VehicleRoute> routes, String pngFile, String title) {
|
private BufferedImage plot(VehicleRoutingProblem vrp, final Collection<VehicleRoute> routes, String pngFile, String title) {
|
||||||
log.info("plot to {}", pngFile);
|
log.info("plot to {}", pngFile);
|
||||||
XYSeriesCollection problem;
|
XYSeriesCollection problem;
|
||||||
XYSeriesCollection solution = null;
|
XYSeriesCollection solution = null;
|
||||||
|
|
@ -295,7 +297,7 @@ public class Plotter {
|
||||||
if (routes != null) solution = makeSolutionSeries(vrp, routes);
|
if (routes != null) solution = makeSolutionSeries(vrp, routes);
|
||||||
} catch (NoLocationFoundException e) {
|
} catch (NoLocationFoundException e) {
|
||||||
log.warn("cannot plot vrp, since coord is missing");
|
log.warn("cannot plot vrp, since coord is missing");
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
final XYPlot plot = createPlot(problem, shipments, solution);
|
final XYPlot plot = createPlot(problem, shipments, solution);
|
||||||
JFreeChart chart = new JFreeChart(title, plot);
|
JFreeChart chart = new JFreeChart(title, plot);
|
||||||
|
|
@ -305,6 +307,7 @@ public class Plotter {
|
||||||
chart.addLegend(legend);
|
chart.addLegend(legend);
|
||||||
|
|
||||||
save(chart, pngFile);
|
save(chart, pngFile);
|
||||||
|
return chart.createBufferedImage(1024, 1024);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue