]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram/src/org/simantics/diagram/participant/SVGTransfer.java
Option to copy diagram selection to clipboard as SVG graphics
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / participant / SVGTransfer.java
1 /*******************************************************************************
2  * Copyright (c) 2020 Association for Decentralized Information Management in
3  * Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     Semantum Oy - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.diagram.participant;
13
14 import java.nio.charset.StandardCharsets;
15
16 import org.eclipse.swt.dnd.ByteArrayTransfer;
17
18 public class SVGTransfer extends ByteArrayTransfer {
19     private static SVGTransfer instance = new SVGTransfer();
20     private static final String TYPE_NAME = "image/svg+xml";
21     private static final int TYPE_ID = registerType(TYPE_NAME);
22
23     public static byte[] formatContent(String svg) {
24         return svg.getBytes(StandardCharsets.UTF_8);
25     }
26
27     public static SVGTransfer getInstance () {
28         return instance;
29     }
30
31     @Override
32     protected int[] getTypeIds(){
33         return new int[] {TYPE_ID};
34     }
35
36     @Override
37     protected String[] getTypeNames(){
38         return new String[] {TYPE_NAME};
39     }
40 }