Skip to content

Commit

Permalink
6.0.1.3 release
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjgraph committed Nov 10, 2016
1 parent f8a1e09 commit 3cd747c
Show file tree
Hide file tree
Showing 22 changed files with 3,832 additions and 3,557 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
09-NOV-2016: 6.0.1.3

- Shift+Drop ignores embedded XML in images
- Alt+Drop ignores highlighted drop target

07-NOV-2016: 6.0.1.2

- Adds new electrical shapes
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.0.1.2
6.0.1.3
75 changes: 39 additions & 36 deletions src/com/mxgraph/io/gliffy/importer/GliffyDiagramConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
import com.mxgraph.io.gliffy.model.Constraints;
import com.mxgraph.io.gliffy.model.Diagram;
import com.mxgraph.io.gliffy.model.EmbeddedResources.Resource;
import com.mxgraph.io.gliffy.model.GliffyObject;
import com.mxgraph.io.gliffy.model.GliffyText;
import com.mxgraph.io.gliffy.model.Graphic;
import com.mxgraph.io.gliffy.model.Graphic.GliffyImage;
import com.mxgraph.io.gliffy.model.Graphic.GliffyLine;
import com.mxgraph.io.gliffy.model.Graphic.GliffyMindmap;
import com.mxgraph.io.gliffy.model.Graphic.GliffyShape;
import com.mxgraph.io.gliffy.model.Graphic.GliffySvg;
import com.mxgraph.io.gliffy.model.GliffyObject;
import com.mxgraph.model.mxCell;
import com.mxgraph.model.mxGeometry;
import com.mxgraph.model.mxICell;
import com.mxgraph.util.mxDomUtils;
import com.mxgraph.util.mxPoint;
import com.mxgraph.util.mxXmlUtils;
Expand Down Expand Up @@ -103,39 +103,14 @@ private void start()

}

@SuppressWarnings("unused")
private void correctLineEndings()
{
java.lang.Object[] edges = drawioDiagram.getAllEdges(new java.lang.Object[] { drawioDiagram.getDefaultParent() });

for (int i = 0; i < edges.length; i++)
{
mxCell edge = (mxCell) edges[i];

mxICell source = edge.getTerminal(true);
mxICell target = edge.getTerminal(false);
mxPoint srcP = edge.getGeometry().getSourcePoint();
mxPoint trgtP = edge.getGeometry().getTargetPoint();

// TODO should this be logging instead?
// if (target != null)
// {
// if (trgtP != null)
// System.out.println(target.getGeometry().contains(trgtP.getX(), trgtP.getY()));
// if (srcP != null)
// System.out.println(source.getGeometry().contains(srcP.getX(), srcP.getY()));
// }
}
}

/**
* Imports the objects into the draw.io diagram. Recursively adds the children
*/
private void importObject(GliffyObject obj, GliffyObject gliffyParent)
{
mxCell parent = gliffyParent != null ? gliffyParent.mxObject : null;

if (!obj.isLine())
//if (!obj.isLine())
{
drawioDiagram.addCell(obj.mxObject, parent);

Expand All @@ -153,15 +128,15 @@ private void importObject(GliffyObject obj, GliffyObject gliffyParent)
}
}
}
else
if (obj.isLine())
{
// gets the terminal cells for the edge
mxCell startTerminal = getTerminalCell(obj, true);
mxCell endTerminal = getTerminalCell(obj, false);

drawioDiagram.addCell(obj.getMxObject(), parent, null, startTerminal, endTerminal);

applyControlPoints(obj, startTerminal, endTerminal);
setWaypoints(obj, startTerminal, endTerminal);
}
}

Expand Down Expand Up @@ -226,9 +201,13 @@ private mxCell getTerminalCell(GliffyObject gliffyEdge, boolean start)
}

/**
* Sets the waypoints
*
* @param object Gliffy line
* @param startTerminal starting point
* @param endTerminal ending point
*/
private void applyControlPoints(GliffyObject object, mxCell startTerminal, mxCell endTerminal)
private void setWaypoints(GliffyObject object, mxCell startTerminal, mxCell endTerminal)
{
mxCell cell = object.getMxObject();
mxGeometry geo = drawioDiagram.getModel().getGeometry(cell);
Expand Down Expand Up @@ -268,6 +247,7 @@ private void applyControlPoints(GliffyObject object, mxCell startTerminal, mxCel
}

drawioDiagram.getModel().setGeometry(cell, geo);

}

/**
Expand All @@ -288,7 +268,7 @@ private void collectVerticesAndConvert(Map<Integer, GliffyObject> vertices, Coll
}

// don't collect for swimlanes and mindmaps, their children are treated differently
if (object.isGroup())
if (object.isGroup() || (object.isLine() && object.hasChildren()))
{
collectVerticesAndConvert(vertices, object.children, object);
}
Expand Down Expand Up @@ -363,8 +343,11 @@ private mxCell convertGliffyObject(GliffyObject gliffyObject, GliffyObject paren
style.append("shape=" + StencilTranslator.translate(gliffyObject.uid)).append(";");
style.append("shadow=" + (shape.dropShadow ? 1 : 0)).append(";");
style.append("strokeWidth=" + shape.strokeWidth).append(";");
style.append("fillColor=" + shape.fillColor).append(";");
style.append("strokeColor=" + shape.strokeColor).append(";");

if(style.lastIndexOf("fillColor") == -1)
style.append("fillColor=" + shape.fillColor).append(";");
if(style.lastIndexOf("strokeColor") == -1)
style.append("strokeColor=" + shape.strokeColor).append(";");

if (shape.gradient)
{
Expand Down Expand Up @@ -404,7 +387,27 @@ else if (gliffyObject.isText())
if (gliffyObject.parent != null && !gliffyObject.parent.isGroup())
{
mxGeometry parentGeometry = gliffyObject.parent.mxObject.getGeometry();
cell.setGeometry(new mxGeometry(0, 0, parentGeometry.getWidth(), parentGeometry.getHeight()));

//if text is a child of a line, special positioning is in place
if(gliffyObject.parent.isLine())
{
/* Gliffy's text offset is a float in the range of [0,1]
* draw.io's text offset is a float in the range of [-1,-1] (while still keeping the text within the line)
* The equation that translates Gliffy offset to draw.io offset is : G*2 - 1 = D
*/
mxGeometry mxGeo = new mxGeometry(graphic.Text.lineTValue != null ? graphic.Text.lineTValue * 2 -1 : GliffyText.DEFAULT_LINE_T_VALUE, 0, 0, 0);
mxGeo.setOffset(new mxPoint());
cell.setGeometry(mxGeo);

style.append("labelBackgroundColor=" + gliffyDiagram.stage.getBackgroundColor()).append(";");
//should we force horizontal align for text on lines?
style.append("align=center;");
}
else
{
cell.setGeometry(new mxGeometry(0, 0, parentGeometry.getWidth(), parentGeometry.getHeight()));
}

cell.getGeometry().setRelative(true);
}
}
Expand Down Expand Up @@ -523,11 +526,11 @@ else if (gliffyObject.isMindmap())
if (!gliffyObject.isLine() && textObject != null)
{
style.append(textObject.graphic.getText().getStyle());
cell.setValue(textObject.getText());
}

if (textObject != null)
{
cell.setValue(textObject.getText());
style.append("html=1;nl2Br=0;whiteSpace=wrap");
}

Expand Down
Loading

0 comments on commit 3cd747c

Please sign in to comment.