Skip to content

Instantly share code, notes, and snippets.

@davidjgraph
Created September 13, 2013 14:55
Show Gist options
  • Save davidjgraph/6551794 to your computer and use it in GitHub Desktop.
Save davidjgraph/6551794 to your computer and use it in GitHub Desktop.
zh IE6 leak
<!--
$Id: images.html,v 1.25 2012/11/20 09:06:07 gaudenz Exp $
Copyright (c) 2006-2010, JGraph Ltd
Images example for mxGraph. This example demonstrates using
background images and images for for the label- and image-shape.
-->
<html>
<head>
<title></title>
<!-- Sets the basepath for the library if not in same directory -->
<script type="text/javascript">
mxBasePath = '../src';
</script>
<!-- Loads and initializes the library -->
<script type="text/javascript" src="../src/js/mxClient.js"></script>
<!-- Example code -->
<script type="text/javascript">
function main(container)
{
// Checks if the browser is supported
if (!mxClient.isBrowserSupported())
{
// Displays an error message if the browser is not supported.
mxUtils.error('Browser is not supported!', 200, false);
}
else
{
// Creates the graph inside the given container
var graph = new mxGraph(container);
configureStylesheet(graph);
// var pregetImage=mxGraph.prototype.getImage();
mxGraph.prototype.getImage=function(state){
var oldImage= (state != null && state.style != null) ?
state.style[mxConstants.STYLE_IMAGE] : null;
var imageStyle=['images/icons48/gear.png','images/icons48/server.png','images/icons48/mail_new.png','images/icons48/keys.png','images/icons48/column.png'];
var rand = Math.floor(Math.random()*4);
return imageStyle[rand];
}
var parent = graph.getDefaultParent();
var index=0;
var rowCnt=20;
var colCnt=20;
var vertexes=new Array(); //先声明一维
for(var i=0;i<rowCnt;i++){ //一维长度为rowCnt
vertexes[i]=new Array(); //在声明二维
for(var j=0;j<colCnt;j++){ //二维长度为colCnt
vertexes[i][j]=0;
}
}
var startX=20;
var startY=10;
var gapX=60;
var gapY=90;
for (var i = 0; i < rowCnt; i++) {
for (var j = 0; j < colCnt; j++) {
vertexes[i][j]= graph.insertVertex(parent, null, '', startX+i*gapX,startY+j*gapY, 50, 60, 'image');
}
}
setInterval(function(){
randomSetImage(graph);
},3000);
}
};
function randomSetImage(graph){
//var root=graph.getChildCells(graph.model.getRoot());
//var cells=root[0].children;
graph.refresh();
}
function configureStylesheet(graph)
{
var style = new Object();
style[mxConstants.STYLE_SHAPE] = mxConstants.SHAPE_IMAGE;
style[mxConstants.STYLE_PERIMETER] = mxPerimeter.RectanglePerimeter;
style[mxConstants.STYLE_IMAGE] = 'images/icons48/keys.png';
style[mxConstants.STYLE_FONTCOLOR] = '#FFFFFF';
graph.getStylesheet().putCellStyle('image', style);
};
</script>
</head>
<!-- Page passes the container for the graph to the program -->
<body onload="main(document.getElementById('graphContainer'))">
<!-- Creates a container for the graph -->
<div id="graphContainer" style="position:relative;overflow:hidden;width:1280px;height:800px;cursor:default;">
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment