1 package org.simantics.scenegraph.tests;
\r
7 import javax.swing.*;
\r
9 import com.kitfox.svg.*;
\r
10 import com.kitfox.svg.app.beans.*;
\r
13 class IconPanel extends JPanel
\r
15 public static final long serialVersionUID = 0;
\r
19 public IconPanel() {
\r
20 setPreferredSize(new Dimension(400, 400));
\r
23 public void load() throws IOException
\r
25 InputStream is = getClass().getResourceAsStream("test_caption_frame.svg");
\r
26 URI uri = SVGCache.getSVGUniverse().loadSVG(is, "myImage");
\r
27 System.out.println("loaded: " + uri);
\r
28 icon = new SVGIcon();
\r
29 icon.setSvgURI(uri);
\r
32 public void paintComponent(Graphics g)
\r
34 Graphics2D g2d = (Graphics2D) g;
\r
35 final int width = getWidth();
\r
36 final int height = getHeight();
\r
38 g.setColor(getBackground());
\r
39 g.fillRect(0, 0, width, height);
\r
41 icon.paintIcon(this, g, width/20, height/20);
\r
49 public class SVGIODemoFrame extends javax.swing.JFrame
\r
51 public static final long serialVersionUID = 0;
\r
53 IconPanel panel = new IconPanel();
\r
55 /** Creates new form SVGIconDemo */
\r
56 public SVGIODemoFrame()
\r
61 } catch (IOException e) {
\r
62 e.printStackTrace();
\r
65 this.getContentPane().add(panel, BorderLayout.CENTER);
\r
70 /** This method is called from within the constructor to
\r
71 * initialize the form.
\r
72 * WARNING: Do NOT modify this code. The content of this method is
\r
73 * always regenerated by the Form Editor.
\r
75 private void initComponents()
\r
78 setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
\r
79 setLayout(new java.awt.BorderLayout());
\r
83 public static void main(String args[])
\r
85 java.awt.EventQueue.invokeLater(new Runnable()
\r
89 new SVGIODemoFrame().setVisible(true);
\r