AuD
Lecture 'Algorithmen und Datenstrukturen' (code examples)
aud.util.SVGViewer Class Reference

Simple SVG viewer based on Batik's SVGCanvas. More...

+ Collaboration diagram for aud.util.SVGViewer:

Public Member Functions

 SVGViewer (JFrame parent, File svgfile)
 create new instance More...
 
JFrame parent ()
 get parent widget More...
 
JLabel statusbar ()
 get status bar More...
 
void close ()
 close viewer More...
 
void display (File file)
 display svg file
More...
 
void display ()
 display current svg file
More...
 
void setExitOnClose ()
 exit application if viewer is closed More...
 

Static Public Member Functions

static void help ()
 print help (mouse/key bindings) to stdout More...
 
static SVGViewer displayWindow (File file, String caption)
 create new SVGViewer (toplevel window) and display file
More...
 
static void main (String[] args)
 visualize given dot files (file names as command line arguments) More...
 

Protected Member Functions

JComponent createComponents ()
 

Protected Attributes

JFrame frame
 
JSVGCanvas svgCanvas
 
JLabel label
 
File svgfile
 

Detailed Description

Simple SVG viewer based on Batik's SVGCanvas.

Usage:

  • Shift+Mouse Left = pan
  • Shift+Mouse Right (drag) = zoom in/out
  • Ctrl+Mouse Left = rectangle zoom
  • Ctrl+Mouse Right (drag) = rotate [disabled]
  • Ctrl+I = zoom in
  • Ctrl+O = zoom out

See also
DotViewer

Definition at line 33 of file SVGViewer.java.

Constructor & Destructor Documentation

◆ SVGViewer()

aud.util.SVGViewer.SVGViewer ( JFrame  parent,
File  svgfile 
)

create new instance

Definition at line 41 of file SVGViewer.java.

41 {
43 svgCanvas=new JSVGCanvas();
44 //svgCanvas.setEnableRotateInteractor(false);
45
46 label=new JLabel();
47 parent.getContentPane().add(createComponents());
48
49 if (svgfile==null) {
50 try {
51 svgfile=File.createTempFile("aud-svgviewer-",".svg");
52 } catch (IOException e) {
53 System.err.println("ERROR: "+e.getMessage());
54 System.exit(-1);
55 }
56 svgfile.deleteOnExit();
57 }
58 }
JFrame parent()
get parent widget
Definition: SVGViewer.java:61
JComponent createComponents()
Definition: SVGViewer.java:71
JSVGCanvas svgCanvas
Definition: SVGViewer.java:36

References aud.util.SVGViewer.createComponents(), aud.util.SVGViewer.frame, aud.util.SVGViewer.label, aud.util.SVGViewer.parent(), aud.util.SVGViewer.svgCanvas, and aud.util.SVGViewer.svgfile.

+ Here is the call graph for this function:

Member Function Documentation

◆ close()

void aud.util.SVGViewer.close ( )

close viewer

Definition at line 66 of file SVGViewer.java.

66 {
67 frame.setVisible(false);
68 frame.dispose();
69 }

References aud.util.SVGViewer.frame.

◆ createComponents()

JComponent aud.util.SVGViewer.createComponents ( )
protected

Definition at line 71 of file SVGViewer.java.

71 {
72 final JPanel panel = new JPanel(new BorderLayout());
73 @SuppressWarnings("unused")
74 final JSVGScrollPane pane = new JSVGScrollPane(svgCanvas);
75
76 panel.add("Center", svgCanvas);
77 panel.add("South", label);
78 return panel;
79 }

References aud.util.SVGViewer.label, and aud.util.SVGViewer.svgCanvas.

Referenced by aud.util.SVGViewer.SVGViewer().

+ Here is the caller graph for this function:

◆ display() [1/2]

void aud.util.SVGViewer.display ( )

display current svg file

Definition at line 87 of file SVGViewer.java.

87 {
88 svgCanvas.setURI(svgfile.toURI().toString());
89 }

References aud.util.SVGViewer.svgCanvas, and aud.util.SVGViewer.svgfile.

Referenced by aud.util.SVGViewer.display().

+ Here is the caller graph for this function:

◆ display() [2/2]

void aud.util.SVGViewer.display ( File  file)

display svg file

Definition at line 82 of file SVGViewer.java.

82 {
83 svgfile=file;
84 display();
85 }
void display()
display current svg file
Definition: SVGViewer.java:87

References aud.util.SVGViewer.display(), and aud.util.SVGViewer.svgfile.

Referenced by aud.util.SVGViewer.displayWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ displayWindow()

static SVGViewer aud.util.SVGViewer.displayWindow ( File  file,
String  caption 
)
static

create new SVGViewer (toplevel window) and display file

Definition at line 106 of file SVGViewer.java.

106 {
107 JFrame f=new JFrame(caption!=null ? caption : "aud.util.SVGViewer");
108 SVGViewer svg=new SVGViewer(f,file);
109 f.setSize(800, 600);
110 f.setVisible(true);
111 if (file!=null)
112 svg.display(file);
113 return svg;
114 }
SVGViewer(JFrame parent, File svgfile)
create new instance
Definition: SVGViewer.java:41

References aud.util.SVGViewer.display().

Referenced by aud.util.SVGViewer.main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ help()

static void aud.util.SVGViewer.help ( )
static

print help (mouse/key bindings) to stdout

Definition at line 92 of file SVGViewer.java.

92 {
93 System.out.println
94 ( "Batik JSVGCanvas overview\n"+
95 "-------------------------\n"+
96 "Shift+Mouse Left\tpan\n"+
97 "Shift+Mouse Right\tzoom in/out (drag)\n"+
98 "Ctrl+Mouse Left\trectangle zoom\n"+
99 "Ctrl+Mouse Right\trotate [disabled!]\n"+
100 "Ctrl+I\tzoom in\n"+
101 "Ctrl+O\tzoom out\n"
102 );
103 }

Referenced by aud.util.SVGViewer.main().

+ Here is the caller graph for this function:

◆ main()

static void aud.util.SVGViewer.main ( String[]  args)
static

visualize given dot files (file names as command line arguments)

Definition at line 126 of file SVGViewer.java.

126 {
127 if (args.length==0) {
128 System.err.println("usage: java aud.util.SVGViewer file.svg\n");
129 SVGViewer.help();
130 }
131 else
132 for (String arg : args) {
133 SVGViewer v=SVGViewer.displayWindow(new File(arg),arg);
134 v.setExitOnClose();
135 }
136 }

References aud.util.SVGViewer.displayWindow(), aud.util.SVGViewer.help(), and aud.util.SVGViewer.setExitOnClose().

+ Here is the call graph for this function:

◆ parent()

JFrame aud.util.SVGViewer.parent ( )

get parent widget

Definition at line 61 of file SVGViewer.java.

61{ return frame; }

References aud.util.SVGViewer.frame.

Referenced by aud.util.SVGViewer.setExitOnClose(), and aud.util.SVGViewer.SVGViewer().

+ Here is the caller graph for this function:

◆ setExitOnClose()

void aud.util.SVGViewer.setExitOnClose ( )

exit application if viewer is closed

Definition at line 117 of file SVGViewer.java.

117 {
118 parent().addWindowListener(new WindowAdapter() {
119 public void windowClosing(WindowEvent e) {
120 System.exit(0);
121 }
122 });
123 }

References aud.util.SVGViewer.parent().

Referenced by aud.util.SVGViewer.main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ statusbar()

JLabel aud.util.SVGViewer.statusbar ( )

get status bar

Definition at line 63 of file SVGViewer.java.

63{ return label; }

References aud.util.SVGViewer.label.

Member Data Documentation

◆ frame

JFrame aud.util.SVGViewer.frame
protected

◆ label

JLabel aud.util.SVGViewer.label
protected

◆ svgCanvas

JSVGCanvas aud.util.SVGViewer.svgCanvas
protected

◆ svgfile

File aud.util.SVGViewer.svgfile
protected

Definition at line 38 of file SVGViewer.java.

Referenced by aud.util.SVGViewer.display(), and aud.util.SVGViewer.SVGViewer().


The documentation for this class was generated from the following file: