mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-15 07:48:29 -04:00
added image export
This commit is contained in:
parent
880aa173e8
commit
e49d0702d1
@ -49,7 +49,7 @@ public class GraphicSwing implements Graphic {
|
|||||||
if (p.isClosed())
|
if (p.isClosed())
|
||||||
path.closePath();
|
path.closePath();
|
||||||
|
|
||||||
if (style.isFilled())
|
if (style.isFilled() && p.isClosed())
|
||||||
gr.fill(path);
|
gr.fill(path);
|
||||||
gr.draw(path);
|
gr.draw(path);
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,9 @@ public final class GraphicsImage extends GraphicSwing implements Closeable {
|
|||||||
public static GraphicsImage create(OutputStream out, Vector min, Vector max, String format) {
|
public static GraphicsImage create(OutputStream out, Vector min, Vector max, String format) {
|
||||||
int thickness = Style.NORMAL.getThickness();
|
int thickness = Style.NORMAL.getThickness();
|
||||||
BufferedImage bi
|
BufferedImage bi
|
||||||
= new BufferedImage(max.x - min.x + thickness * 2,
|
= new BufferedImage(
|
||||||
max.y - min.y + thickness * 2,
|
(max.x - min.x + thickness * 2) * 2,
|
||||||
|
(max.y - min.y + thickness * 2) * 2,
|
||||||
BufferedImage.TYPE_INT_ARGB);
|
BufferedImage.TYPE_INT_ARGB);
|
||||||
Graphics2D gr = bi.createGraphics();
|
Graphics2D gr = bi.createGraphics();
|
||||||
gr.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
gr.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||||
@ -38,6 +39,7 @@ public final class GraphicsImage extends GraphicSwing implements Closeable {
|
|||||||
gr.setColor(new Color(255, 255, 255, 0));
|
gr.setColor(new Color(255, 255, 255, 0));
|
||||||
gr.fillRect(0, 0, bi.getWidth(), bi.getHeight());
|
gr.fillRect(0, 0, bi.getWidth(), bi.getHeight());
|
||||||
|
|
||||||
|
gr.scale(2, 2);
|
||||||
gr.translate(thickness - min.x, thickness - min.y);
|
gr.translate(thickness - min.x, thickness - min.y);
|
||||||
|
|
||||||
return new GraphicsImage(out, gr, bi, format);
|
return new GraphicsImage(out, gr, bi, format);
|
||||||
|
@ -33,6 +33,7 @@ import java.awt.event.WindowAdapter;
|
|||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -197,6 +198,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
|
|||||||
JMenu export = new JMenu(Lang.get("menu_export"));
|
JMenu export = new JMenu(Lang.get("menu_export"));
|
||||||
export.add(new ExportAction(Lang.get("menu_exportSVG"), "svg", GraphicSVGIndex::new));
|
export.add(new ExportAction(Lang.get("menu_exportSVG"), "svg", GraphicSVGIndex::new));
|
||||||
export.add(new ExportAction(Lang.get("menu_exportSVGLaTex"), "svg", GraphicSVGLaTeX::new));
|
export.add(new ExportAction(Lang.get("menu_exportSVGLaTex"), "svg", GraphicSVGLaTeX::new));
|
||||||
|
export.add(new ExportAction(Lang.get("menu_exportPNG"), "png", (file, min, max) -> GraphicsImage.create(new FileOutputStream(file), min, max, "PNG")));
|
||||||
|
|
||||||
JMenu file = new JMenu(Lang.get("menu_file"));
|
JMenu file = new JMenu(Lang.get("menu_file"));
|
||||||
bar.add(file);
|
bar.add(file);
|
||||||
|
@ -230,6 +230,7 @@ menu_editAttributes_tt=Diese Attribute beeinflussen das Modell, wenn es in ander
|
|||||||
menu_fast=Schneller Lauf
|
menu_fast=Schneller Lauf
|
||||||
menu_fast_tt=F\u00FChrt das Modell aus, bis ein Stopsignal \u00FCber ein BRK-Element detektiert wird.
|
menu_fast_tt=F\u00FChrt das Modell aus, bis ein Stopsignal \u00FCber ein BRK-Element detektiert wird.
|
||||||
menu_export=Export
|
menu_export=Export
|
||||||
|
menu_exportPNG=Export PNG
|
||||||
menu_exportSVG=Export SVG
|
menu_exportSVG=Export SVG
|
||||||
menu_exportSVGLaTex=Export SVG+LaTeX
|
menu_exportSVGLaTex=Export SVG+LaTeX
|
||||||
menu_delete=L\u00F6schen
|
menu_delete=L\u00F6schen
|
||||||
|
@ -218,6 +218,7 @@ menu_fast_tt=Runs the model until a break is detected by the BRK element.
|
|||||||
menu_export=Export
|
menu_export=Export
|
||||||
menu_exportSVG=Export SVG
|
menu_exportSVG=Export SVG
|
||||||
menu_exportSVGLaTex=Export SVG+LaTeX
|
menu_exportSVGLaTex=Export SVG+LaTeX
|
||||||
|
menu_exportPNG=Export PNG
|
||||||
menu_delete=Delete elements
|
menu_delete=Delete elements
|
||||||
menu_delete_tt=Delete selected single element or group of elements
|
menu_delete_tt=Delete selected single element or group of elements
|
||||||
menu_editRunAttributes=Simulation Settings
|
menu_editRunAttributes=Simulation Settings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user