X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.diagram%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fparticipant%2FSVGTransfer.java;fp=bundles%2Forg.simantics.diagram%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fparticipant%2FSVGTransfer.java;h=539e22e3d18ec89d8a0cb97a135525f9f3699839;hp=0000000000000000000000000000000000000000;hb=7c341eb5f602ee3c7255e933204f4f72a6d455fa;hpb=e8b96542ea305825ae4dbf7c35f11275689ef564 diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/SVGTransfer.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/SVGTransfer.java new file mode 100644 index 000000000..539e22e3d --- /dev/null +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/SVGTransfer.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2020 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Semantum Oy - initial API and implementation + *******************************************************************************/ +package org.simantics.diagram.participant; + +import java.nio.charset.StandardCharsets; + +import org.eclipse.swt.dnd.ByteArrayTransfer; + +public class SVGTransfer extends ByteArrayTransfer { + private static SVGTransfer instance = new SVGTransfer(); + private static final String TYPE_NAME = "image/svg+xml"; + private static final int TYPE_ID = registerType(TYPE_NAME); + + public static byte[] formatContent(String svg) { + return svg.getBytes(StandardCharsets.UTF_8); + } + + public static SVGTransfer getInstance () { + return instance; + } + + @Override + protected int[] getTypeIds(){ + return new int[] {TYPE_ID}; + } + + @Override + protected String[] getTypeNames(){ + return new String[] {TYPE_NAME}; + } +} \ No newline at end of file