Java Code Examples for org.apache.batik.swing.JSVGCanvas

The following examples show how to use org.apache.batik.swing.JSVGCanvas. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: jetpad-projectional-open-source   Source File: AwtDemo.java    License: Apache License 2.0 6 votes vote down vote up
private static void noViewDemo() {
  JFrame frame = new JFrame("Svg Awt Demo");
  frame.setLayout(new BorderLayout());

  JSVGCanvas svgCanvas = new JSVGCanvas();
  svgCanvas.setDocumentState(AbstractJSVGComponent.ALWAYS_DYNAMIC);

  final SvgSvgElement svgRoot = DemoModel.createModel();
  SvgRootDocumentMapper mapper = new SvgRootDocumentMapper(svgRoot);
  mapper.attachRoot();

  svgCanvas.setSVGDocument(mapper.getTarget());

  svgCanvas.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent e) {
      super.mouseClicked(e);
      DemoModel.addCircle(svgRoot, e.getX(), e.getY());
    }
  });

  frame.add(svgCanvas);
  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  frame.setSize(800, 600);
  frame.setVisible(true);
}