Skip to content

Instantly share code, notes, and snippets.

View davidjgraph's full-sized avatar
🏠
Typing...

David Benson davidjgraph

🏠
Typing...
View GitHub Profile
@davidjgraph
davidjgraph / drawioClientSVG
Created January 15, 2015 11:15
The draw.io code invoked on a download as SVG
else if (format == 'svg')
{
var bg = this.editor.graph.background;
if (bg == 'none')
{
bg = null;
}
// JPG does not support transparent backgrounds
@davidjgraph
davidjgraph / nodisplay.xml
Created April 11, 2015 12:46
XML doesn't load
<mxGraphModel><root><mxCell id="0"/><mxCell id="1" parent="0"/><mxCell id="2" parent="1" style="gradientColor=#ffffff;gradientDirection=north;spacingRight=-1.39;fillColor=#f0f0f0;shadow=1;spacingTop=-1.39;spacingLeft=-1.39;strokeColor=#404040;whiteSpace=wrap;spacingBottom=-1.39;strokeWidth=0.7;group;" value="" vertex="1"><mxGeometry as="geometry" height="70.0" width="410.0" x="150.0" y="280.0"/></mxCell><mxCell id="3" parent="2" style="gradientColor=#ffffff;gradientDirection=north;spacingRight=-1.39;fillColor=#f0f0f0;shadow=1;spacingTop=-1.39;shape=mxgraph.flowchart.process;spacingLeft=-1.39;strokeColor=#404040;whiteSpace=wrap;spacingBottom=-1.39;strokeWidth=0.7;" value="" vertex="1"><mxGeometry as="geometry" height="60.0" width="100.0" y="10.0"/></mxCell><mxCell id="4" parent="2" style="gradientColor=#ffffff;gradientDirection=north;spacingRight=-1.39;fillColor=#f0f0f0;shadow=1;spacingTop=-1.39;spacingLeft=-1.39;strokeColor=#404040;whiteSpace=wrap;spacingBottom=-1.39;strokeWidth=0.7;" value="" vertex="1"><mxG
@davidjgraph
davidjgraph / webViewExportText.java
Created September 3, 2015 12:15
Testing draw.io (mxGraph) image export using Java WebView
import javafx.application.Application;
import javafx.beans.value.*;
import javafx.concurrent.Worker.State;
import javafx.embed.swing.SwingFXUtils;
import javafx.scene.Scene;
import javafx.scene.image.*;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
@davidjgraph
davidjgraph / PropGen.java
Created October 26, 2012 23:04
Properties files generator using tab separated values spreadsheet as input
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import javax.swing.JFileChooser;
@davidjgraph
davidjgraph / fastOrganicLayout.html
Created November 4, 2015 14:06
organic layout parameters
<!--
Copyright (c) 2006-2013, JGraph Ltd
Hierarchical Layout example for mxGraph. This example demonstrates the
use of the hierarchical and organic layouts. Note that the hierarchical
layout requires another script tag in the head of the page.
-->
<html>
<head>
<title>Hierarchical Layout example for mxGraph</title>
@davidjgraph
davidjgraph / gist:5309973
Last active December 15, 2015 19:18
mxUtils.getXml patch in mxGraph 1.12.0.1
mxUtils.getXml: function(node, linefeed)
{
var xml = '';
if (window.XMLSerializer != null)
{
var xmlSerializer = new XMLSerializer();
xml = xmlSerializer.serializeToString(node);
}
else if (node.xml != null)
@davidjgraph
davidjgraph / Editor.setGraphXml.js
Created April 4, 2013 12:53
The patch used in draw.io to load diagrams that had their outer XML element stripped by saving in Firefox 20
/**
* Sets the XML node for the current diagram.
*/
Editor.prototype.setGraphXml = function(node)
{
var dec = new mxCodec(node.ownerDocument);
if (node.nodeName == 'mxGraphModel')
{
this.graph.view.scale = 1;
@davidjgraph
davidjgraph / gist:5349225
Created April 9, 2013 20:42
Workaround for mxGraph hierarchical layout for prototype.js bug
mxHierarchicalLayout.prototype.run = function(parent)
{
// Separate out unconnected hierarchies
var hierarchyVertices = [];
var allVertexSet = [];
if (this.roots == null && parent != null)
{
var filledVertexSet = Object();
this.filterDescendants(parent, filledVertexSet);
@davidjgraph
davidjgraph / gist:5349594
Created April 9, 2013 21:32
Prototype workaround 2
mxHierarchicalLayout.prototype.run = function(parent)
{
// Separate out unconnected hierarchies
var hierarchyVertices = [];
var allVertexSet = [];
if (this.roots == null && parent != null)
{
var filledVertexSet = Object();
this.filterDescendants(parent, filledVertexSet);
@davidjgraph
davidjgraph / gist:5547214
Created May 9, 2013 12:40
single label ER changes
var s = mxConstants.STYLE_VERTICAL_LABEL_POSITION + '=bottom;' + mxConstants.STYLE_VERTICAL_ALIGN + '=top;' + mxConstants.STYLE_STROKEWIDTH + '=2;';
content.appendChild(this.createVertexTemplate(s + mxConstants.STYLE_SHAPE + '=mxgraph.er.attribute;buttonText=Attribute;textColor=#000000;fontSize=17;buttonStyle=dblFrame;' + mxConstants.STYLE_FILLCOLOR + '=#ffffff;', w, h, '', 'Attribute', false));
content.appendChild(this.createVertexTemplate(s + mxConstants.STYLE_SHAPE + '=mxgraph.er.bachmans;textColor=#000000;' + mxConstants.STYLE_FONTSIZE + '=17;', w * 3, h * 2, '', 'ERD Bachman\'s Notation', false));
content.appendChild(this.createVertexTemplate(s + mxConstants.STYLE_SHAPE + '=mxgraph.er.chens;textColor=#000000;' + mxConstants.STYLE_FONTSIZE + '=17;', w * 3, h, '', 'ERD Chen\'s Notation', false));
content.appendChild(this.createVertexTemplate(s + mxConstants.STYLE_SHAPE + '=mxgraph.er.cloud;buttonText=Cloud;textColor=#000000;' + mxConstants.STYLE_FONTSIZE + '=17;', w, h, '', 'Cloud', false))