Skip to content
Snippets Groups Projects
Commit 5197d64b authored by David Hoksza's avatar David Hoksza
Browse files

scaling of converted images

parent 44168fd6
No related branches found
No related tags found
3 merge requests!630WIP: Resolve "The privileges of a new user are not saved in some cases",!442Problem with exporting to celldesigner and parsing from celldesigner,!440Problem with exporting to celldesigner
......@@ -152,10 +152,23 @@ public class ConvertRestImpl extends BaseRestImpl {
}
private AbstractImageGenerator.Params createImageParams(Model model){
Double targetHeight = 848.0;
Double targetWidth = 595.0;
Double padding = 5.0;
Double w = model.getWidth();
Double h = model.getHeight();
Double scale = targetWidth / w;
if (h * scale > targetHeight) {
scale = targetHeight / h;
}
return new AbstractImageGenerator.Params().//
model(model).//
width(model.getWidth()).//
height(model.getHeight());
width(targetWidth+padding).//
height(targetHeight+padding).//
scale(1/scale);
}
......
......@@ -3,7 +3,10 @@ package lcsb.mapviewer.api.convert;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
......@@ -133,7 +136,25 @@ public class ConvertRestImplTest extends RestTestFunctions {
try {
File file = new File("testFiles/convert/sample-cd.xml");
String content = FileUtils.readFileToString(file);
String result = convertRestImpl.converToImage(token, "CellDesigner_SBML", "svg", content).toString();
String result = convertRestImpl.converToImage(token, "CellDesigner_SBML", "svg", content).toString();
// FileOutputStream outputStream = new FileOutputStream("sample-cd.png");
// outputStream.write(convertRestImpl.converToImage(token, "CellDesigner_SBML", "png", content).toByteArray());
// outputStream.close();
assertTrue(result.contains("<rect"));
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testCelDesigner2Sbgn() throws Exception {
try {
File file = new File("testFiles/convert/sample-cd.xml");
String content = FileUtils.readFileToString(file);
String result = convertRestImpl.convert(token, "CellDesigner_SBML", "SBGN-ML", content).toString();
assertTrue(result.contains("<rect"));
} catch (Exception e) {
e.printStackTrace();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment