-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathExportViewer.java
More file actions
38 lines (32 loc) · 1.1 KB
/
ExportViewer.java
File metadata and controls
38 lines (32 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package nodebox.client;
import nodebox.graphics.Grob;
import nodebox.node.Node;
import javax.swing.*;
import java.awt.*;
public class ExportViewer extends JFrame {
private Node network;
private Viewer viewer;
public ExportViewer(Node exportNetwork) {
super("Exporting...");
network = exportNetwork;
viewer = new Viewer();
getContentPane().add(viewer);
setSize(600, 600);
}
public void updateFrame() {
viewer.repaint();
}
private class Viewer extends JComponent {
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Object outputValue = network.getOutputValue();
g2.translate(getWidth() / 2, getHeight() / 2);
if (outputValue instanceof Grob) {
if (outputValue instanceof nodebox.graphics.Canvas)
g2.clip(((Grob) outputValue).getBounds().getRectangle2D());
((Grob) outputValue).draw(g2);
}
}
}
}