|
mxGraph 2.1.0.2 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.mxgraph.util.mxImageBundle
public class mxImageBundle
Maps from keys to base64 encoded images or file locations. All values must
be URLs or use the format data:image/format followed by a comma and the base64
encoded image data, eg. "data:image/gif,XYZ", where XYZ is the base64 encoded
image data.
To add a new image bundle to an existing graph, the following code is used:
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.
Field Summary | |
---|---|
protected Map<String,String> |
images
Maps from keys to images. |
Constructor Summary | |
---|---|
mxImageBundle()
|
Method Summary | |
---|---|
String |
getImage(String key)
Returns the value for the given key. |
Map<String,String> |
getImages()
Returns the images. |
void |
putImage(String key,
String value)
Adds the specified entry to the map. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Map<String,String> images
Constructor Detail |
---|
public mxImageBundle()
Method Detail |
---|
public Map<String,String> getImages()
public void putImage(String key, String value)
public String getImage(String key)
|
mxGraph 2.1.0.2 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |