add svg save
This commit is contained in:
@@ -48,6 +48,7 @@ import org.artisanlogiciel.util.UTF8Control;
|
|||||||
|
|
||||||
import org.artisanlogiciel.graphics.Drawing;
|
import org.artisanlogiciel.graphics.Drawing;
|
||||||
import org.artisanlogiciel.graphics.DrawingLine;
|
import org.artisanlogiciel.graphics.DrawingLine;
|
||||||
|
import org.artisanlogiciel.graphics.SvgWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display is Main JFrame for this tool
|
* Display is Main JFrame for this tool
|
||||||
@@ -250,6 +251,18 @@ public class Display extends JFrame
|
|||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// to allow to log / write somewher into screen...
|
||||||
|
void writeSentence(String pSentence)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
System.out.println( pSentence);
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeError(String pError)
|
||||||
|
{
|
||||||
|
System.err.println(pError);
|
||||||
|
}
|
||||||
|
|
||||||
void saveImc()
|
void saveImc()
|
||||||
{
|
{
|
||||||
Drawing d = createDrawing();
|
Drawing d = createDrawing();
|
||||||
@@ -257,14 +270,14 @@ public class Display extends JFrame
|
|||||||
if ( d != null )
|
if ( d != null )
|
||||||
{
|
{
|
||||||
File outfile = new File(params.getSaveDir(), params.getName() + ".imc");
|
File outfile = new File(params.getSaveDir(), params.getName() + ".imc");
|
||||||
System.out.println("Saving to " + outfile + " ...");
|
writeSentence("Saving to " + outfile + " ...");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataOutputStream out = new DataOutputStream(new FileOutputStream(outfile));
|
DataOutputStream out = new DataOutputStream(new FileOutputStream(outfile));
|
||||||
d.saveLinesKompressed(out);
|
d.saveLinesKompressed(out);
|
||||||
out.flush();
|
out.flush();
|
||||||
out.close();
|
out.close();
|
||||||
System.out.println("... Done.");
|
writeSentence("... Done.");
|
||||||
}
|
}
|
||||||
catch (IOException io)
|
catch (IOException io)
|
||||||
{
|
{
|
||||||
@@ -273,6 +286,36 @@ public class Display extends JFrame
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void saveSvg()
|
||||||
|
{
|
||||||
|
Drawing d = createDrawing();
|
||||||
|
|
||||||
|
if ( d != null )
|
||||||
|
{
|
||||||
|
File outfile = new File(params.getSaveDir(), params.getName() + ".svg");
|
||||||
|
writeSentence("Saving to " + outfile + " ...");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DataOutputStream out = new DataOutputStream(new FileOutputStream(outfile));
|
||||||
|
SvgWriter writer = new SvgWriter(d.getInternLines());
|
||||||
|
writer.writeTo(out);
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
|
writeSentence("... Done.");
|
||||||
|
}
|
||||||
|
catch (IOException io)
|
||||||
|
{
|
||||||
|
io.printStackTrace(System.err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writeError("drawing creation failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void savePng()
|
void savePng()
|
||||||
{
|
{
|
||||||
File file = new File("snapshot.png");
|
File file = new File("snapshot.png");
|
||||||
@@ -546,6 +589,15 @@ public class Display extends JFrame
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
savePngButton.addActionListener(savePngAction);
|
savePngButton.addActionListener(savePngAction);
|
||||||
|
final JButton saveSvgButton = new JButton(labels.getString("save") +" svg");
|
||||||
|
Action saveSvgAction = new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent evt)
|
||||||
|
{
|
||||||
|
writeSentence("save png");
|
||||||
|
saveSvg();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
saveSvgButton.addActionListener(saveSvgAction);
|
||||||
final JButton saveButton = new JButton(labels.getString("save") +" raw");
|
final JButton saveButton = new JButton(labels.getString("save") +" raw");
|
||||||
Action saveAction = new AbstractAction() {
|
Action saveAction = new AbstractAction() {
|
||||||
public void actionPerformed(ActionEvent evt)
|
public void actionPerformed(ActionEvent evt)
|
||||||
@@ -589,10 +641,15 @@ public class Display extends JFrame
|
|||||||
resizecontrol.add(showAll);
|
resizecontrol.add(showAll);
|
||||||
resizecontrol.add(slider);
|
resizecontrol.add(slider);
|
||||||
resizecontrol.add(autoSlide);
|
resizecontrol.add(autoSlide);
|
||||||
resizecontrol.add(saveName);
|
|
||||||
resizecontrol.add(savePngButton);
|
// todo dedicate a panel for save
|
||||||
resizecontrol.add(saveButton);
|
JPanel savePanel = resizecontrol;
|
||||||
resizecontrol.add(saveImcButton);
|
savePanel.add(saveName);
|
||||||
|
savePanel.add(saveSvgButton);
|
||||||
|
savePanel.add(savePngButton);
|
||||||
|
savePanel.add(saveButton);
|
||||||
|
savePanel.add(saveImcButton);
|
||||||
|
|
||||||
resizecontrol.add(quitButton);
|
resizecontrol.add(quitButton);
|
||||||
|
|
||||||
add(controlDisplayPanel, BorderLayout.SOUTH);
|
add(controlDisplayPanel, BorderLayout.SOUTH);
|
||||||
|
|||||||
Reference in New Issue
Block a user