public class mxImageBundle
extends java.lang.Object
mxImageBundle bundle = new mxImageBundle();
bundle.PutImage("myImage", "data:image/gif,R0lGODlhEAAQAMIGAAAAAICAAICAgP" +
"//AOzp2O3r2////////yH+FUNyZWF0ZWQgd2l0aCBUaGUgR0lNUAAh+QQBCgAHACwAAAAA" +
"EAAQAAADTXi63AowynnAMDfjPUDlnAAJhmeBFxAEloliKltWmiYCQvfVr6lBPB1ggxN1hi" +
"laSSASFQpIV5HJBDyHpqK2ejVRm2AAgZCdmCGO9CIBADs=");
graph.addImageBundle(bundle);
The image can then be referenced in any cell style using image=myImage.
If you are using mxOutline, you should use the same image bundles in the
graph that renders the outline.
To convert a given BufferedImage to a base64 encoded String, the following
code can be used:
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ImageIO.write(image, "png", bos);
System.out.println("base64=" + mxBase64.encodeToString(
bos.toByteArray(), false));
The value is decoded in mxUtils.loadImage. The keys for images are resolved
and the short format above is converted to a data URI in
mxGraph.postProcessCellStyle.Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,java.lang.String> |
images
Maps from keys to images.
|
Constructor and Description |
---|
mxImageBundle() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getImage(java.lang.String key)
Returns the value for the given key.
|
java.util.Map<java.lang.String,java.lang.String> |
getImages()
Returns the images.
|
void |
putImage(java.lang.String key,
java.lang.String value)
Adds the specified entry to the map.
|
protected java.util.Map<java.lang.String,java.lang.String> images
public java.util.Map<java.lang.String,java.lang.String> getImages()
public void putImage(java.lang.String key, java.lang.String value)
public java.lang.String getImage(java.lang.String key)
Copyright (c) 2010-2017 Gaudenz Alder, JGraph Ltd. All rights reserved.