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 / 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 / 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))
@davidjgraph
davidjgraph / gist:5644274
Created May 24, 2013 15:22
drive real time file
/*
* $Id: DriveRealTime.js,v 1.33 2013/05/07 08:55:47 gaudenz Exp $
* Copyright (c) 2011-2013, JGraph Ltd
*/
/**
* Creates an object that synchronizes the graph model and given realtime model.
* The session ID is used as a prefix in the model to produce unique IDs for new
* cells.
*
* See https://developers.google.com/drive/realtime/reference/gapi.drive.realtime
@davidjgraph
davidjgraph / draw_io_manifest
Created June 11, 2013 08:23
draw.io Google Apps Marketplace listing manifest
<ListingManifest>
<SubListings>
<SubListing>
<DisplayName>Complete</DisplayName>
<EditionId>default_edition</EditionId>
<PaymentModel>FREE</PaymentModel>
<SeatCount>1000000</SeatCount>
</SubListing>
</SubListings>
</ListingManifest>
@davidjgraph
davidjgraph / super
Created June 13, 2013 09:56
HTML superscript example
<mxGraphModel dx="800" dy="800" grid="1" guides="1" tooltips="1" connect="1" fold="1" page="1" pageScale="1" pageWidth="826" pageHeight="1169" style="default-style2">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="2" value="&lt;p style=&quot;margin: 0px; margin-top: 4px; text-align: center;&quot;&gt;&lt;strong&gt;Class&lt;/strong&gt;&lt;/p&gt;&lt;hr /&gt;&lt;p style=&quot;margin: 0px; margin-left: 4px;&quot;&gt;+ field:&lt;sup&gt;Type&lt;/sup&gt;&lt;/p&gt;&lt;hr /&gt;&lt;p style=&quot;margin: 0px; margin-left: 4px;&quot;&gt;+ method(): Type&lt;/p&gt;" style="verticalAlign=top;align=left;overflow=fill;fontSize=12;fontFamily=Helvetica;html=1" vertex="1" parent="1">
<mxGeometry x="10" y="10" width="440" height="360" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
@davidjgraph
davidjgraph / Diagramly.js
Created June 24, 2013 09:26
Diagramly.js - TinyMCE initialization
/*
* $Id: Diagramly.js,v 1.80 2013/05/31 13:17:27 david Exp $
* Copyright (c) 2006-2010, JGraph Ltd
*/
// For compatibility with open servlet on GAE
function setCurrentXml(data, filename)
{
if (window.parent != null && window.parent.openFile != null)
{
window.parent.openFile.setData(data, filename);