8.0.0 release
This commit is contained in:
parent
1228046417
commit
12368ce346
1557 changed files with 10693 additions and 30791 deletions
|
@ -1,3 +1,8 @@
|
|||
17-JAN-2018: 8.0.0
|
||||
|
||||
- New Google repository structure
|
||||
- Uses Java 1.8
|
||||
|
||||
16-JAN-2018: 7.9.8
|
||||
|
||||
- Adds dark theme (beta)
|
||||
|
|
|
@ -19,7 +19,7 @@ The [mxGraph documentation](https://jgraph.github.io/mxgraph/) provides a lot of
|
|||
|
||||
Running
|
||||
-------
|
||||
The simplest way to run draw.io initially is to fork this project, [publish the master branch to GitHub pages](https://help.github.com/categories/github-pages-basics/) and the [pages sites](https://jgraph.github.io/drawio/war/index.html) will have the full editor functionality (sans the integrations).
|
||||
The simplest way to run draw.io initially is to fork this project, [publish the master branch to GitHub pages](https://help.github.com/categories/github-pages-basics/) and the [pages sites](https://jgraph.github.io/drawio/src/main/webapp/index.html) will have the full editor functionality (sans the integrations).
|
||||
|
||||
The full packaged .war of the client and servlets is built when the project is tagged and available on the [releases page](https://github.com/jgraph/draw.io/releases).
|
||||
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
7.9.8
|
||||
8.0.0
|
|
@ -1,8 +1,7 @@
|
|||
jscompiler=${basedir}/compiler.jar
|
||||
grapheditor.dir=${basedir}/../../war/js/mxgraph
|
||||
src.dir=${basedir}/../../src
|
||||
war.dir=${basedir}/../../war
|
||||
grapheditor.dir=${basedir}/../../src/main/webapp/js/mxgraph
|
||||
src.dir=${basedir}/../../src/main/java
|
||||
war.dir=${basedir}/../../src/main/webapp
|
||||
javac.dir=${war.dir}/WEB-INF/classes
|
||||
build.dir=${basedir}/../../build
|
||||
war.name=draw.war
|
||||
imageexport.dir=${basedir}/../imageexport
|
|
@ -12,8 +12,8 @@
|
|||
</concat>
|
||||
|
||||
<java fork="false" classname="Xml2Js" classpath=".">
|
||||
<arg value="../../war/stencils"/>
|
||||
<arg value="../../war/js/stencils.min.js"/>
|
||||
<arg value="../../src/main/webapp/stencils"/>
|
||||
<arg value="../../src/main/webapp/js/stencils.min.js"/>
|
||||
</java>
|
||||
|
||||
<jscomp compilationLevel="simple" debug="false" forceRecompile="true" output="${war.dir}/js/shapes.min.js">
|
||||
|
@ -285,8 +285,8 @@
|
|||
</sources>
|
||||
</jscomp>
|
||||
<concat destfile="${war.dir}/js/vsdx.min.js" fixlastline="yes" append="yes">
|
||||
<fileset dir="${war.dir}/js/jszip" includes="**/*.min.js"/>
|
||||
</concat>
|
||||
<fileset dir="${war.dir}/js/jszip" includes="**/*.min.js"/>
|
||||
</concat>
|
||||
|
||||
<delete file="${basedir}/.tmp1.js"/>
|
||||
|
||||
|
@ -367,18 +367,12 @@
|
|||
<!-- ================== Stand-alone war creation ============================= -->
|
||||
|
||||
<path id="javac.class.path">
|
||||
<fileset dir="${war.dir}/WEB-INF/lib" includes="mxgraph-core.jar" />
|
||||
<fileset dir="${basedir}/jars" includes="servlet-api.jar" />
|
||||
<fileset dir="${basedir}/jars" includes="commons-codec-1.10.jar" />
|
||||
<fileset dir="${basedir}/jars" includes="commons-fileupload-1.3.2.jar" />
|
||||
<fileset dir="${basedir}/jars" includes="gson-2.7.jar" />
|
||||
<fileset dir="${basedir}/jars" includes="commons-lang3-3.5.jar" />
|
||||
<fileset dir="${basedir}/jars" includes="gae-stub-1.0.1.jar" />
|
||||
<fileset dir="${war.dir}/WEB-INF/lib" />
|
||||
</path>
|
||||
|
||||
<target name="javac" depends="app" description="Java compilation">
|
||||
<mkdir dir="${javac.dir}"/>
|
||||
<javac srcdir="${src.dir}" excludes="**/EmbedServlet2.java" encoding="utf-8" destdir="${javac.dir}" source="1.7" target="1.7" debug="true" debuglevel="lines,vars,source">
|
||||
<javac includeantruntime="false" srcdir="${src.dir}" excludes="**/EmbedServlet2.java" destdir="${javac.dir}">
|
||||
<classpath refid="javac.class.path" />
|
||||
</javac>
|
||||
<copy todir="${javac.dir}" file="${src.dir}/log4j.properties" />
|
||||
|
@ -391,10 +385,12 @@
|
|||
<fileset dir="${build.dir}">
|
||||
</fileset>
|
||||
</delete>
|
||||
<delete file="${basedir}/base.min.js"/>
|
||||
<delete file="${basedir}/base-viewer.min.js"/>
|
||||
</target>
|
||||
|
||||
<target name="war" depends="javac" description="Create the stand-alone war file">
|
||||
<zip excludes="**/appengine*.jar,**/jsr*.jar,**/junit*.jar" destfile="${build.dir}/${war.name}" basedir="${war.dir}" >
|
||||
<zip destfile="${build.dir}/${war.name}" basedir="${war.dir}" >
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
|
|
|
@ -2,3 +2,5 @@ Converts from .tsv files (downloaded from eg. Google Spreadsheet) to .txt resou
|
|||
|
||||
The resources for draw.io are here:
|
||||
https://docs.google.com/spreadsheet/ccc?key=0AmQEO36liL4FdDJLWVNMaVV2UmRKSnpXU09MYkdGbEE#gid=0
|
||||
|
||||
Run ant build.xml to run the converter.
|
17
etc/propgen/build.xml
Normal file
17
etc/propgen/build.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0"?>
|
||||
<project basedir="." default="run">
|
||||
|
||||
<target name="compile">
|
||||
<mkdir dir="classes"/>
|
||||
<javac includeantruntime="false" srcdir="." destdir="classes"/>
|
||||
</target>
|
||||
|
||||
<target name="run" depends="compile">
|
||||
<java fork="true" classname="com.mxgraph.properties.PropGen">
|
||||
<classpath>
|
||||
<path location="classes"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
</project>
|
|
@ -1,2 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mxGraphModel dx="695" dy="1211" grid="0" gridSize="10" guides="1" tooltips="1" connect="0" fold="1" page="1" pageScale="1" pageWidth="826" pageHeight="1169" style="default-style2" math="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/><mxCell id="2" value="äöü" style="ellipse;whiteSpace=wrap;html=1;blue" parent="1" vertex="1"><mxGeometry x="172" y="165" width="120" height="80" as="geometry"/></mxCell><mxCell id="3" value="öäü" style="ellipse;whiteSpace=wrap;html=1;yellow" parent="1" vertex="1"><mxGeometry x="421" y="165" width="120" height="80" as="geometry"/></mxCell><mxCell id="4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;" parent="1" source="2" target="3" edge="1"><mxGeometry relative="1" as="geometry"/></mxCell></root></mxGraphModel>
|
Binary file not shown.
|
@ -1,2 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mxGraphModel dx="695" dy="1211" grid="0" gridSize="10" guides="1" tooltips="1" connect="0" fold="1" page="1" pageScale="1" pageWidth="826" pageHeight="1169" style="default-style2" math="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/><mxCell id="2" value="äöü" style="ellipse;whiteSpace=wrap;html=1;blue" parent="1" vertex="1"><mxGeometry x="172" y="165" width="120" height="80" as="geometry"/></mxCell><mxCell id="3" value="öäü" style="ellipse;whiteSpace=wrap;html=1;yellow" parent="1" vertex="1"><mxGeometry x="421" y="165" width="120" height="80" as="geometry"/></mxCell><mxCell id="4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;" parent="1" source="2" target="3" edge="1"><mxGeometry relative="1" as="geometry"/></mxCell></root></mxGraphModel>
|
|
@ -1 +0,0 @@
|
|||
{"contentType":"application/gliffy+json","version":"1.3","stage":{"background":"#FFFFFF","width":411,"height":205,"nodeIndex":2,"autoFit":true,"exportBorder":false,"gridOn":true,"snapToGrid":true,"drawingGuidesOn":true,"pageBreaksOn":false,"printGridOn":false,"printPaper":null,"printShrinkToFit":false,"printPortrait":false,"maxWidth":5000,"maxHeight":5000,"themeData":null,"viewportType":"default","fitBB":{"min":{"x":310,"y":110},"max":{"x":411,"y":205}},"printModel":{"pageSize":"a4","portrait":false,"fitToOnePage":false,"displayPageBreaks":false},"objects":[{"x":310.0,"y":110.0,"rotation":0.0,"id":0,"width":95.0,"height":95.0,"uid":"com.gliffy.shape.flowchart.flowchart_v1.default.manual_operation","order":0,"lockAspectRatio":false,"lockShape":false,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.trapezoid.basic_v1","strokeWidth":2.0,"strokeColor":"#333333","fillColor":"#FFFFFF","gradient":false,"dashStyle":null,"dropShadow":false,"state":0,"opacity":1.0,"shadowX":0.0,"shadowY":0.0}},"linkMap":[],"children":[{"x":2.0,"y":0.0,"rotation":0.0,"id":1,"width":91.0,"height":14.0,"uid":null,"order":"auto","lockAspectRatio":false,"lockShape":false,"graphic":{"type":"Text","Text":{"overflow":"none","paddingTop":8,"paddingRight":8,"paddingBottom":8,"paddingLeft":8,"outerPaddingTop":6,"outerPaddingRight":6,"outerPaddingBottom":2,"outerPaddingLeft":6,"type":"fixed","lineTValue":null,"linePerpValue":null,"cardinalityType":null,"html":"<p style=\"text-align:center;\"><span style=\"font-size:12px;text-decoration:none;font-family:Arial;\"><span style=\"text-decoration:none;\">ЂШЖЋ</span></span></p>","tid":null,"valign":"middle","vposition":"none","hposition":"none"}},"hidden":false,"layerId":"Vks6sl4vucyr"}],"hidden":false,"layerId":"Vks6sl4vucyr"}],"layers":[{"guid":"Vks6sl4vucyr","order":0,"name":"Layer 0","active":true,"locked":false,"visible":true,"nodeIndex":1}],"shapeStyles":{},"lineStyles":{},"textStyles":{}},"metadata":{"title":"untitled","revision":0,"exportBorder":false,"loadPosition":"default","libraries":["com.gliffy.libraries.flowchart.flowchart_v1.default","com.gliffy.libraries.basic.basic_v1.default","com.gliffy.libraries.swimlanes.swimlanes_v1.default","com.gliffy.libraries.images"],"lastSerialized":1436453227228},"embeddedResources":{"index":0,"resources":[]}}
|
Binary file not shown.
Before Width: | Height: | Size: 8.9 KiB |
|
@ -1,3 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="374px" height="86px" version="1.1" content="<mxfile userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36" type="device"><diagram>xZTBbqMwEIafhmOlGFI2OTY0m730lEPPLp6AJYORY0LYp88YxnEQSaWqlXqx7G+G3+N/bKIkq847w5vyTQtQUbwQ5yh5jeI4XT/j6EA/AhYzNpLCSDGyRQB7+R8o0dNWCjgSG5HVWlnZTGGu6xpyO1E8aEVbUFLDCy8fwD7nak7fpbDlSFdxGvg/kEVJ2zCWrsfI0fZeQ8CBt8o+DQhjLlxxrzVUlmzRMaM1yrhZdc5AOdemhvx9EL0WaaCenPfRB1TEiauWaoyyJHpZunGTDmM2OwZKoMW42HSltLBveO4iHXYZWWkrhSuG0w+nOquIijyBsUB3YUBU4Q50Bdb0mOKjf6hMf1FSujldaATzjS1vmrAixuk+FFfpYAlOyJX7DiV3HRq9IZ++4VCPmbr7AY+W/pPf8Gg5N0Dg46GlNrbUha652ga6MbqtBTiBxdSSh2YcdWsGG8O9tdwUQFnUKLfzp4YZUNzK0/RZf+H0uAzvc4jd/N6S7QU=</diagram></mxfile>"><defs><linearGradient x1="0%" y1="0%" x2="0%" y2="100%" id="mx-gradient-dae8fc-1-7ea6e0-1-s-0"><stop offset="0%" style="stop-color:#DAE8FC"/><stop offset="100%" style="stop-color:#7EA6E0"/></linearGradient><linearGradient x1="0%" y1="0%" x2="0%" y2="100%" id="mx-gradient-fff2cc-1-ffd966-1-s-0"><stop offset="0%" style="stop-color:#FFF2CC"/><stop offset="100%" style="stop-color:#FFD966"/></linearGradient></defs><g transform="translate(0.5,0.5)"><ellipse cx="61" cy="41" rx="60" ry="40" fill="#d0d0d0" stroke="#d0d0d0" transform="translate(2,3)" opacity="1"/><ellipse cx="61" cy="41" rx="60" ry="40" fill="url(#mx-gradient-dae8fc-1-7ea6e0-1-s-0)" stroke="#6c8ebf" pointer-events="none"/><g transform="translate(44,35)"><switch><foreignObject pointer-events="all" width="33" height="16" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 33px; white-space: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;">äöü</div></div></foreignObject><text x="17" y="14" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><ellipse cx="310" cy="41" rx="60" ry="40" fill="#d0d0d0" stroke="#d0d0d0" transform="translate(2,3)" opacity="1"/><ellipse cx="310" cy="41" rx="60" ry="40" fill="url(#mx-gradient-fff2cc-1-ffd966-1-s-0)" stroke="#d6b656" pointer-events="none"/><g transform="translate(293,35)"><switch><foreignObject pointer-events="all" width="33" height="16" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 33px; white-space: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;">öäü</div></div></foreignObject><text x="17" y="14" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><path d="M 121 41 L 243.63 41" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 248.88 41 L 241.88 44.5 L 243.63 41 L 241.88 37.5 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/></g></svg>
|
Before Width: | Height: | Size: 3.5 KiB |
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
25
etc/vsdx-convert/build.xml
Normal file
25
etc/vsdx-convert/build.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0"?>
|
||||
<project basedir="." default="run">
|
||||
|
||||
<target name="compile">
|
||||
<mkdir dir="classes"/>
|
||||
<javac includeantruntime="false" srcdir="." destdir="classes">
|
||||
<classpath>
|
||||
<path location="classes"/>
|
||||
<path location="../../classes"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="run" depends="compile">
|
||||
<java fork="true" classname="com.mxgraph.vsdxutils.VsdxBatchConvert">
|
||||
<classpath>
|
||||
<path location="classes"/>
|
||||
<path location="../../classes"/>
|
||||
<fileset dir="lib"/>
|
||||
<fileset dir="../../src/main/webapp/WEB-INF/lib"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
</project>
|
|
@ -1,4 +1,5 @@
|
|||
package com.mxgraph.vsdxutils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
|
@ -16,7 +17,7 @@ import org.xml.sax.SAXException;
|
|||
import com.mxgraph.io.mxVsdxCodec;
|
||||
import com.mxgraph.online.Utils;
|
||||
|
||||
public class vsdxBatchConvert
|
||||
public class VsdxBatchConvert
|
||||
{
|
||||
/**
|
||||
* @param args
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_101"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"candies": [
|
||||
{
|
||||
"name": "jquery",
|
||||
"version": "1.10.0-20170726",
|
||||
"lastUpdateTimestamp": 1501691304000,
|
||||
"modelVersion": "unknown",
|
||||
"transpilerVersion": "2.0.0",
|
||||
"jsOutputDirPath": "C:\\Users\\ashra\\Documents\\jsweet\\jsweet-quickstart\\webapp",
|
||||
"jsDirPath": "META-INF/resources/webjars/jquery/1.10.0-20170726",
|
||||
"jsFilesPaths": []
|
||||
}
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,23 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>jsweet-quickstart</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -1,8 +0,0 @@
|
|||
compiler.candyJsFolder=webapp
|
||||
compiler.debugMode=ts
|
||||
compiler.javascriptFolder=target/js
|
||||
compiler.moduleKind=none
|
||||
compiler.profiles=default
|
||||
compiler.sourceFolders=
|
||||
compiler.typescriptFolder=target/ts
|
||||
eclipse.preferences.version=1
|
|
@ -1,13 +0,0 @@
|
|||
1- Make sure that the Java code has no errors. Include all external libraries and create mock classes for mxGraph ones.
|
||||
2- Run JSweet: mvn generate-sources
|
||||
3- Ignore the errors. The JS file are generated although there are errors. [Errors are coming from external libraries that JSweet cannot find]
|
||||
4- Start replacing mxGraph mock classes with JS equivalents (e.g., com.mxgraph.io.vsdx.mxPoint => mxPoint). Make sure that the JS classes has the methods needed
|
||||
4.a. mxPoint has no getX/Y setX/Y, so replace them with direct fields (e.g., .getX() => .x)
|
||||
4.b. mxGeometry has no getX/Y setX/Y (get/set)Width (get/set)Height. The same for: alternateBounds sourcePoint targetPoint points offset relative
|
||||
4.c. Make sure that your mock classes do not have overloaded methods such that they are translated with the same name
|
||||
5- Do the same with all external libraries. Most of them requires equivalent JS libraries and some are supported natively by JS (e.g., DOM)
|
||||
5.a. DOM methods need to be changed to fields: (e.g., getChildNode() => childNode)
|
||||
5.b. getAttribute and hasAttribute methods exists in JS
|
||||
5.c. DOM getAttribute returns null if attribute is not found, in Java, it returns empty string!
|
||||
6- Fix JSweet errors in handling fields initialization. Default initialization must be moved before _super call. Also, !string.contains bug and model.getCells() conversion bug
|
||||
7- Try to do a test that covers all the code!
|
|
@ -1,202 +0,0 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
# JSweet quick start
|
||||
|
||||
A simple project to get started with JSweet. This project just contains a main method that shows 'Hello world' messages in two different ways. The program uses the [J4TS](https://github.com/cincheo/j4ts) candy to access `java.util` API, and the jQuery candy. Programmers can use it to set up a new JSweet project and try out some basic features.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
> git clone https://github.com/cincheo/jsweet-quickstart.git
|
||||
> cd jsweet-quickstart
|
||||
> mvn generate-sources
|
||||
> firefox webapp/index.html
|
||||
```
|
||||
|
||||
## Modify
|
||||
|
||||
At any time, you can modify the Java files (or add new files) and run ``mvn generate-sources`` to generate the corresponding JavaScript files. You can then use them in the ``index.html`` file (``<script>`` tags).
|
||||
|
||||
You can modify the generation options by modifying the plugin section for ``jsweet-maven-plugin``. When having a project with multiple source files, a good generation option to turn on is the ``bundle`` option, in order to generate all the JavaScript classes in a single file. Check the [Maven plugin](https://github.com/lgrignon/jsweet-maven-plugin) for the full option list.
|
||||
|
||||
If you want to use a JavaScript library (besides jQuery which is already enabled), you must add the Maven dependency in the ``<dependencies>`` section of the ``pom.xml``. You can copy-paste the Maven dependency description from our [Candy browser](http://www.jsweet.org/candies-snapshots/), or from our online [Maven repository](http://repository.jsweet.org/artifactory/webapp/#/artifacts/browse/tree/General/libs-snapshot-local). When running ``mvn generate-sources`` with a new library, if available in the candy, the JavaScript library will be extracted to the location given by the ``candiesJsOut`` option (here in the ``webapp`` directory). JavaScript libraries are packaged in the Jar following the [WebJars](http://www.webjars.org/) conventions. When not available, you will need to find and download the JavaScript library manually (or using a third-party tool such as [Bower](https://bower.io/)).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Java 8 JDK is required. Type in ``java -version`` in a console to make sure that you have a >1.8 JDK.
|
||||
- The `node` and `npm` executables must be in the path (https://nodejs.org).
|
||||
- Install Maven (https://maven.apache.org/install.html).
|
||||
|
|
@ -1,165 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.jsweet</groupId>
|
||||
<artifactId>jsweet-quickstart</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<name>JSweet v2 quick start</name>
|
||||
<description>A simple project structure to get started with JSweet v2</description>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>rpawlak</id>
|
||||
<name>Renaud Pawlak</name>
|
||||
<email>renaud.pawlak@gmail.com</email>
|
||||
</developer>
|
||||
</developers>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache Software License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>jsweet-plugins-release</id>
|
||||
<name>plugins-release</name>
|
||||
<url>http://repository.jsweet.org/artifactory/plugins-release-local</url>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<snapshots />
|
||||
<id>jsweet-plugins-snapshots</id>
|
||||
<name>plugins-snapshot</name>
|
||||
<url>http://repository.jsweet.org/artifactory/plugins-snapshot-local</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jsweet-central</id>
|
||||
<name>libs-release</name>
|
||||
<url>http://repository.jsweet.org/artifactory/libs-release-local</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<snapshots />
|
||||
<id>jsweet-snapshots</id>
|
||||
<name>libs-snapshot</name>
|
||||
<url>http://repository.jsweet.org/artifactory/libs-snapshot-local</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<fork>true</fork>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jsweet</groupId>
|
||||
<artifactId>jsweet-maven-plugin</artifactId>
|
||||
<version>2.0.0-rc1</version>
|
||||
<configuration>
|
||||
<verbose>true</verbose>
|
||||
<tsOut>target/ts</tsOut>
|
||||
<outDir>target/js</outDir>
|
||||
<candiesJsOut>webapp</candiesJsOut>
|
||||
<targetVersion>ES3</targetVersion>
|
||||
<bundle>true</bundle>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-js</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>jsweet</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<!--This plugin's configuration is used to store Eclipse m2e settings
|
||||
only. It has no influence on the Maven build itself. -->
|
||||
<plugin>
|
||||
<groupId>org.eclipse.m2e</groupId>
|
||||
<artifactId>lifecycle-mapping</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<configuration>
|
||||
<lifecycleMappingMetadata>
|
||||
<pluginExecutions>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>
|
||||
org.jsweet
|
||||
</groupId>
|
||||
<artifactId>
|
||||
jsweet-maven-plugin
|
||||
</artifactId>
|
||||
<versionRange>
|
||||
[1.0.0,)
|
||||
</versionRange>
|
||||
<goals>
|
||||
<goal>jsweet</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore></ignore>
|
||||
</action>
|
||||
</pluginExecution>
|
||||
</pluginExecutions>
|
||||
</lifecycleMappingMetadata>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
<dependencies>
|
||||
<!-- <dependency>
|
||||
<groupId>org.jsweet</groupId>
|
||||
<artifactId>jsweet-core</artifactId>
|
||||
<version>5-20170726</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jsweet.candies</groupId>
|
||||
<artifactId>node</artifactId>
|
||||
<version>7.5.0-20170726</version>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.jsweet.candies</groupId>
|
||||
<artifactId>jquery</artifactId>
|
||||
<version>1.10.0-20170726</version>
|
||||
</dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>org.jsweet.candies</groupId>
|
||||
<artifactId>j4ts</artifactId>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jsweet.candies</groupId>
|
||||
<artifactId>dom4</artifactId>
|
||||
<version>1.5.0-1.1.0-20160525</version>
|
||||
</dependency>-->
|
||||
<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.10</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.5</version>
|
||||
</dependency>
|
||||
<!-- dependency>
|
||||
<groupId>com.mxgraph</groupId>
|
||||
<artifactId>mxgraph-core</artifactId>
|
||||
<version>3.7.4</version>
|
||||
</dependency-->
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,14 +0,0 @@
|
|||
package com.mxgraph.io;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.mxgraph.io.mxGraph.Model;
|
||||
|
||||
public class mxCodec {
|
||||
|
||||
public Node encode(Model model) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,209 +0,0 @@
|
|||
package com.mxgraph.io;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.mxgraph.io.mxGraph.Model;
|
||||
import com.mxgraph.io.vsdx.ShapePageId;
|
||||
import com.mxgraph.io.vsdx.VsdxShape;
|
||||
import com.mxgraph.io.vsdx.mxCell;
|
||||
import com.mxgraph.io.vsdx.mxGeometry;
|
||||
import com.mxgraph.io.vsdx.mxPoint;
|
||||
import com.mxgraph.io.vsdx.mxVsdxConstants;
|
||||
import com.mxgraph.io.vsdx.mxVsdxMaster;
|
||||
import com.mxgraph.io.vsdx.mxVsdxPage;
|
||||
import com.mxgraph.io.vsdx.mxVsdxUtils;
|
||||
|
||||
public class mxVssxCodec extends mxVsdxCodec
|
||||
{
|
||||
public mxVssxCodec()
|
||||
{
|
||||
RESPONSE_END = "";
|
||||
RESPONSE_DIAGRAM_START = "";
|
||||
RESPONSE_DIAGRAM_END = "";
|
||||
RESPONSE_HEADER = "";
|
||||
}
|
||||
|
||||
public String decodeVssx(byte[] data, String charset)
|
||||
throws IOException, ParserConfigurationException, SAXException,
|
||||
TransformerException
|
||||
{
|
||||
StringBuilder library = new StringBuilder("<mxlibrary>[");
|
||||
|
||||
//process shapes in pages
|
||||
String shapesInPages = decodeVsdx(data, charset);
|
||||
|
||||
library.append(shapesInPages);
|
||||
|
||||
//process shapes in master
|
||||
Map<String, mxVsdxMaster> masterShapes = vsdxModel.getMasterShapes();
|
||||
|
||||
//using the first page as a dummy one
|
||||
mxVsdxPage page = vsdxModel.getPages().values().iterator().next();
|
||||
|
||||
if (masterShapes != null)
|
||||
{
|
||||
StringBuilder shapes = new StringBuilder();
|
||||
String comma = shapesInPages.isEmpty()? "" : ",";
|
||||
for (mxVsdxMaster master : masterShapes.values())
|
||||
{
|
||||
mxGraph shapeGraph = createMxGraph();
|
||||
|
||||
Element shapeElem = master.getMasterShape().getShape();
|
||||
VsdxShape shape = new VsdxShape(page, shapeElem, !page.isEdge(shapeElem), masterShapes, null, vsdxModel);
|
||||
mxCell cell = null;
|
||||
|
||||
if (shape.isVertex())
|
||||
{
|
||||
edgeShapeMap.clear();
|
||||
parentsMap.clear();
|
||||
cell = addShape(shapeGraph, shape, shapeGraph.getDefaultParent(),
|
||||
0, 1169); //1169 is A4 page height
|
||||
|
||||
for ( Entry<ShapePageId, VsdxShape> edgeEntry : edgeShapeMap.entrySet())
|
||||
{
|
||||
Object parent = parentsMap.get(edgeEntry.getKey());
|
||||
addUnconnectedEdge(shapeGraph, parent, edgeEntry.getValue(), 1169); //1169 is A4 page height
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cell = (mxCell) addUnconnectedEdge(shapeGraph, null, shape, 1169); //1169 is A4 page height
|
||||
}
|
||||
|
||||
if (cell != null)
|
||||
{
|
||||
shapes.append(comma);
|
||||
shapes.append("{\"xml\":\"");
|
||||
mxGeometry geo = normalizeGeo(cell);
|
||||
|
||||
sanitiseGraph(shapeGraph);
|
||||
|
||||
if (shapeGraph.getModel().getChildCount(shapeGraph.getDefaultParent()) == 0) continue;
|
||||
|
||||
String shapeXML = super.processPage(shapeGraph, null);
|
||||
shapes.append(shapeXML);
|
||||
shapes.append("\",\"w\":");
|
||||
shapes.append(geo.getWidth());
|
||||
shapes.append(",\"h\":");
|
||||
shapes.append(geo.getHeight());
|
||||
shapes.append(",\"title\":\"");
|
||||
|
||||
String shapeName = master.getName();
|
||||
if (shapeName != null) shapeName = mxVsdxUtils.htmlEntities(shapeName);
|
||||
|
||||
shapes.append(shapeName);
|
||||
|
||||
shapes.append("\"}");
|
||||
comma = ",";
|
||||
}
|
||||
}
|
||||
library.append(shapes);
|
||||
}
|
||||
library.append("]</mxlibrary>");
|
||||
|
||||
//TODO UTF-8 support is missing
|
||||
//
|
||||
// System.out.println(library);
|
||||
|
||||
return library.toString();
|
||||
}
|
||||
|
||||
protected mxGeometry normalizeGeo(mxCell cell) {
|
||||
mxGeometry geo = cell.getGeometry();
|
||||
geo.setX(0);
|
||||
geo.setY(0);
|
||||
|
||||
mxPoint srcP = geo.getSourcePoint();
|
||||
|
||||
if (cell.isEdge() && srcP != null)
|
||||
{
|
||||
transPoint(geo.getTargetPoint(), srcP);
|
||||
transPoint(geo.getOffset(), srcP);
|
||||
List<mxPoint> points = geo.getPoints();
|
||||
|
||||
if (points != null)
|
||||
{
|
||||
for (mxPoint p : points)
|
||||
{
|
||||
transPoint(p, srcP);
|
||||
}
|
||||
}
|
||||
transPoint(srcP, srcP);
|
||||
}
|
||||
return geo;
|
||||
}
|
||||
|
||||
protected void transPoint(mxPoint p, mxPoint srcP)
|
||||
{
|
||||
if (p != null)
|
||||
{
|
||||
p.setX(p.getX() - srcP.getX());
|
||||
p.setY(p.getY() - srcP.getY());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String processPage(mxGraph graph, mxVsdxPage page) throws IOException {
|
||||
Model model = graph.getModel();
|
||||
|
||||
StringBuilder shapes = new StringBuilder();
|
||||
String comma = "";
|
||||
for (Object c : model.getCells().values())
|
||||
{
|
||||
//add top level shapes only to the library
|
||||
if (graph.getDefaultParent() == model.getParent(c))
|
||||
{
|
||||
shapes.append(comma);
|
||||
shapes.append("{\"xml\":\"");
|
||||
mxGraph shapeGraph = createMxGraph();
|
||||
shapeGraph.addCell(c, null, 0 , null, null);
|
||||
sanitiseGraph(shapeGraph);
|
||||
|
||||
if (shapeGraph.getModel().getChildCount(shapeGraph.getDefaultParent()) == 0) continue;
|
||||
|
||||
mxGeometry geo = normalizeGeo((mxCell) c);
|
||||
String shapeXML = super.processPage(shapeGraph, null);
|
||||
shapes.append(shapeXML);
|
||||
shapes.append("\",\"w\":");
|
||||
shapes.append(geo.getWidth());
|
||||
shapes.append(",\"h\":");
|
||||
shapes.append(geo.getHeight());
|
||||
shapes.append(",\"title\":\"");
|
||||
String style = model.getStyle(c);
|
||||
|
||||
String name = "";
|
||||
if (style != null)
|
||||
{
|
||||
int p = style.indexOf(mxVsdxConstants.VSDX_ID);
|
||||
if (p >= 0)
|
||||
{
|
||||
p += mxVsdxConstants.VSDX_ID.length() + 1;
|
||||
int id = Integer.parseInt(style.substring(p, style.indexOf(";", p)));
|
||||
VsdxShape vsdxShape = vertexShapeMap.get(new ShapePageId(page.getId(), id));
|
||||
if (vsdxShape != null)
|
||||
name = vsdxShape.getName();
|
||||
}
|
||||
}
|
||||
shapes.append(name);
|
||||
shapes.append("\"}");
|
||||
comma = ",";
|
||||
}
|
||||
}
|
||||
|
||||
if (shapes.length() > 0)
|
||||
RESPONSE_DIAGRAM_START = ",";
|
||||
else
|
||||
RESPONSE_DIAGRAM_START = "";
|
||||
|
||||
return shapes.toString();
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package com.mxgraph.io;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
public class mxXmlUtils {
|
||||
|
||||
public static Document parseXml(String str) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getXml(Node node) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,925 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2006-2016, JGraph Ltd
|
||||
* Copyright (c) 2006-2016, Gaudenz Alder
|
||||
*/
|
||||
package com.mxgraph.io.vsdx;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import com.mxgraph.io.mxVsdxCodec;
|
||||
import com.mxgraph.io.vsdx.theme.QuickStyleVals;
|
||||
import com.mxgraph.util.mxConstants;
|
||||
|
||||
public class Shape extends Style
|
||||
{
|
||||
public final static long VSDX_START_TIME = -2209168800000L;//new Date("12/30/1899").getTime();
|
||||
/**
|
||||
* The text element of the shape, if any
|
||||
*/
|
||||
protected Element text;
|
||||
|
||||
/**
|
||||
* The text fields of the shape, if any
|
||||
*/
|
||||
protected LinkedHashMap<String, String> fields;
|
||||
|
||||
/**
|
||||
* List of paragraphs in this shape
|
||||
*/
|
||||
protected LinkedHashMap<String,Paragraph> paragraphs = null;
|
||||
|
||||
/**
|
||||
* mxGraph cell style map
|
||||
*/
|
||||
protected Map<String, String> styleMap = new HashMap<String, String>();
|
||||
|
||||
/**
|
||||
* Width of shape
|
||||
*/
|
||||
protected double width = 0;
|
||||
|
||||
/**
|
||||
* Height of shape
|
||||
*/
|
||||
protected double height = 0;
|
||||
|
||||
/**
|
||||
* Cumulative rotation of shape, including parents
|
||||
*/
|
||||
protected double rotation = 0;
|
||||
|
||||
protected double lastX = 0;
|
||||
|
||||
protected double lastY = 0;
|
||||
|
||||
protected double lastMoveX = 0;
|
||||
|
||||
protected double lastMoveY = 0;
|
||||
|
||||
protected double lastKnot = -1;
|
||||
|
||||
protected List<Element> geom;
|
||||
|
||||
protected mxVsdxGeometryList geomList = null;
|
||||
protected boolean geomListProcessed = false;
|
||||
|
||||
protected Map<String, String> imageData;
|
||||
|
||||
protected mxVsdxTheme theme;
|
||||
|
||||
protected int themeVariant = 0;
|
||||
|
||||
protected QuickStyleVals quickStyleVals;
|
||||
|
||||
protected final static String UNICODE_LINE_SEP = new String(new char[]{(char)226, (char)128, (char)168});
|
||||
|
||||
public Shape(Element shape, mxVsdxModel model)
|
||||
{
|
||||
super(shape, model);
|
||||
this.width = getScreenNumericalValue(this.cellElements.get(mxVsdxConstants.WIDTH), 0);
|
||||
this.height = getScreenNumericalValue(this.cellElements.get(mxVsdxConstants.HEIGHT), 0);
|
||||
}
|
||||
|
||||
public void setThemeAndVariant(mxVsdxTheme theme, int themeVariant)
|
||||
{
|
||||
this.theme = theme;
|
||||
this.themeVariant = themeVariant;
|
||||
}
|
||||
|
||||
public mxVsdxTheme getTheme()
|
||||
{
|
||||
if (theme != null)
|
||||
{
|
||||
theme.setVariant(themeVariant);
|
||||
}
|
||||
return theme;
|
||||
}
|
||||
|
||||
public QuickStyleVals getQuickStyleVals()
|
||||
{
|
||||
return quickStyleVals;
|
||||
}
|
||||
|
||||
protected void processGeomList(mxVsdxGeometryList parentGeoList)
|
||||
{
|
||||
if (!geomListProcessed)
|
||||
{
|
||||
geomList = new mxVsdxGeometryList(parentGeoList);
|
||||
|
||||
if (geom != null)
|
||||
{
|
||||
for (Element geoElem : geom)
|
||||
{
|
||||
geomList.addGeometry(geoElem);
|
||||
}
|
||||
}
|
||||
|
||||
geomListProcessed = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Caches the specified element
|
||||
* @param elem the element to cache
|
||||
*/
|
||||
protected void parseShapeElem(Element elem, mxVsdxModel model)
|
||||
{
|
||||
super.parseShapeElem(elem, model);
|
||||
|
||||
String childName = elem.getNodeName();
|
||||
|
||||
if (childName.equals("ForeignData"))
|
||||
{
|
||||
String filename = elem.getOwnerDocument().getDocumentURI();
|
||||
String iType = elem.getAttribute("ForeignType");
|
||||
String compression = elem.getAttribute("CompressionType");
|
||||
|
||||
if (iType.equals("Bitmap"))
|
||||
{
|
||||
compression = compression.toLowerCase();
|
||||
}
|
||||
else if (iType.equals("MetaFile"))
|
||||
{
|
||||
compression = "x-wmf";
|
||||
}
|
||||
else if (iType.equals("Enhanced Metafile") || iType.equals("EnhMetaFile"))
|
||||
{
|
||||
compression = "x-emf";
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO log and unsupported type
|
||||
return;
|
||||
}
|
||||
|
||||
Node fdChild = elem.getFirstChild();
|
||||
|
||||
if (fdChild != null)
|
||||
{
|
||||
if (fdChild instanceof Element)
|
||||
{
|
||||
Element fdElem = (Element) fdChild;
|
||||
String grandchildName = fdElem.getNodeName();
|
||||
|
||||
if (grandchildName.toLowerCase().equals("rel"))
|
||||
{
|
||||
String rid = fdElem.getAttribute("r:id");
|
||||
|
||||
if (rid != null && !rid.isEmpty())
|
||||
{
|
||||
// insert "_rel" into the path
|
||||
int index = filename.lastIndexOf('/');
|
||||
String pre = "";
|
||||
String post = "";
|
||||
|
||||
try
|
||||
{
|
||||
pre = filename.substring(0, index);
|
||||
post = filename.substring(index, filename.length());
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element relElem = model.getRelationship(rid, pre + "/_rels" + post + ".rels");
|
||||
|
||||
if (relElem != null)
|
||||
{
|
||||
String target = relElem.getAttribute("Target");
|
||||
String type = relElem.getAttribute("Type");
|
||||
index = target.lastIndexOf('/');
|
||||
|
||||
try
|
||||
{
|
||||
target = target.substring(index + 1, target.length());
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (type != null && type.endsWith("image"))
|
||||
{
|
||||
this.imageData = new HashMap<String, String>();
|
||||
String iData = model.getMedia(mxVsdxCodec.vsdxPlaceholder + "/media/" + target);
|
||||
this.imageData.put("iData", iData);
|
||||
|
||||
//since we convert BMP files to PNG, we set the compression to PNG
|
||||
if (target.toLowerCase().endsWith(".bmp"))
|
||||
{
|
||||
compression = "png";
|
||||
}
|
||||
else if (target.toLowerCase().endsWith(".emf"))
|
||||
{
|
||||
//emf can be a png or jpg or vector (which is not supported yet)
|
||||
//We use a number of bytes equal to file header length (which is safe as header in base64 requires 4n/3 bytes
|
||||
compression = iData.startsWith("iVBORw0K") ? "png" : (iData.startsWith("/9j/") ? "jpg" : compression);
|
||||
}
|
||||
|
||||
this.imageData.put("iType", compression);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO log path issue
|
||||
}
|
||||
|
||||
// more than one rel would break things
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fdChild = fdChild.getNextSibling();
|
||||
}
|
||||
}
|
||||
else if (childName.equals(mxVsdxConstants.TEXT))
|
||||
{
|
||||
this.text = elem;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Caches the specific section element
|
||||
* @param elem the element to cache
|
||||
*/
|
||||
protected void parseSection(Element elem)
|
||||
{
|
||||
String n = elem.getAttribute("N");
|
||||
|
||||
if (n.equals("Geometry"))
|
||||
{
|
||||
if (geom == null)
|
||||
{
|
||||
geom = new ArrayList<Element>();
|
||||
}
|
||||
|
||||
this.geom.add(elem);
|
||||
}
|
||||
else if (n.equals("Field"))
|
||||
{
|
||||
ArrayList<Element> rows = mxVsdxUtils.getDirectChildNamedElements(elem, "Row");
|
||||
|
||||
for (Element row : rows)
|
||||
{
|
||||
String ix = row.getAttribute("IX");
|
||||
|
||||
if (!ix.isEmpty())
|
||||
{
|
||||
if (this.fields == null)
|
||||
{
|
||||
fields = new LinkedHashMap<String, String>();
|
||||
}
|
||||
|
||||
String del = row.getAttribute("Del");
|
||||
|
||||
//supporting deletion of a field by adding an empty string such that master field is not used
|
||||
if ("1".equals(del))
|
||||
{
|
||||
this.fields.put(ix, "");
|
||||
continue;
|
||||
}
|
||||
|
||||
ArrayList<Element> cells = mxVsdxUtils.getDirectChildNamedElements(row, "Cell");
|
||||
|
||||
String value = "", format = "", calendar = "", type = "";
|
||||
for (Element cell : cells)
|
||||
{
|
||||
n = cell.getAttribute("N");
|
||||
String v = cell.getAttribute("V");
|
||||
|
||||
switch (n)
|
||||
{
|
||||
case "Value":
|
||||
value = v;
|
||||
break;
|
||||
case "Format":
|
||||
format = v;
|
||||
break;
|
||||
case "Calendar":
|
||||
calendar = v;
|
||||
break;
|
||||
case "Type":
|
||||
type = v;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!value.isEmpty())
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
//TODO support other formats and calendars
|
||||
if (format.startsWith("{{"))
|
||||
{
|
||||
value = new SimpleDateFormat(
|
||||
format.replaceAll("\\{|\\}", ""))
|
||||
//the value is the number of days after 30/12/1899 (VSDX_START_TIME)
|
||||
.format(new Date(VSDX_START_TIME + (long)(Double.parseDouble(value) * 24 * 60 * 60 * 1000)));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// System.out.println("Vsdx import: Unkown text format " + format + ". Error: " + e.getMessage());
|
||||
}
|
||||
this.fields.put(ix, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.parseSection(elem);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return mxGraph stencil XML or null or there is no displayed geometry
|
||||
*/
|
||||
protected String parseGeom()
|
||||
{
|
||||
if (!hasGeomList())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
return geomList.getShapeXML(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the Text element.
|
||||
* @return Value of the Text element.
|
||||
*/
|
||||
public String getText()
|
||||
{
|
||||
return this.text != null ? text.getTextContent() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the children Nodes of Text.
|
||||
* @return List with the children of the Text element.
|
||||
*/
|
||||
public NodeList getTextChildren()
|
||||
{
|
||||
return this.text != null ? text.getChildNodes() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the width element in pixels.
|
||||
* @return Numerical value of the width element.
|
||||
*/
|
||||
public double getWidth()
|
||||
{
|
||||
//some shapes has zero width while the height is non-zero. Setting width to 1 fixed it.
|
||||
return this.width == 0 && this.height > 0 ? 1 : this.width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the height element in pixels.
|
||||
* @return Numerical value of the height element.
|
||||
*/
|
||||
public double getHeight()
|
||||
{
|
||||
//some shapes has zero height while the width is non-zero. Setting height to 1 fixed it.
|
||||
return this.height == 0 && this.width > 0 ? 1 : this.height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the rotation.
|
||||
* @return Numerical value of the rotation
|
||||
*/
|
||||
public double getRotation()
|
||||
{
|
||||
return this.rotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the style map of this shape
|
||||
* @return the style map
|
||||
*/
|
||||
public Map<String, String> getStyleMap()
|
||||
{
|
||||
return this.styleMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not this shape has a geometry defined, locally
|
||||
* or inherited
|
||||
* @return whether the shape has a geometry
|
||||
*/
|
||||
public boolean hasGeom()
|
||||
{
|
||||
return !(this.geom == null || this.geom.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not this shape or its master has a geometry defined
|
||||
* @return whether the shape has a geometry
|
||||
*/
|
||||
public boolean hasGeomList()
|
||||
{
|
||||
return this.geomList != null && this.geomList.hasGeom();
|
||||
}
|
||||
|
||||
/**
|
||||
* Last cp IX referenced in the Text Element.
|
||||
*/
|
||||
String cp = "0";
|
||||
|
||||
/**
|
||||
* Last pp IX referenced in the Text Element.
|
||||
*/
|
||||
String pp = "0";
|
||||
|
||||
/**
|
||||
* Last tp IX referenced in the Text Element.
|
||||
*/
|
||||
String tp = "0";
|
||||
|
||||
/**
|
||||
* Last fld IX referenced in the Text Element.
|
||||
*/
|
||||
String fld = "0";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Transform plain text into a HTML list if the Para element referenced by
|
||||
* pp indicates it.
|
||||
* @param text Text to be transformed.
|
||||
* @param pp Reference to a Para element.
|
||||
* @return Text like a HTML list.
|
||||
*/
|
||||
public String textToList(String text, String pp)
|
||||
{
|
||||
if (!pp.equals(""))
|
||||
{
|
||||
String bullet = getBullet(pp);
|
||||
|
||||
if (!bullet.equals("0"))
|
||||
{
|
||||
String[] entries = text.split("\n");
|
||||
String ret = "";
|
||||
|
||||
for (String entry : entries)
|
||||
{
|
||||
ret += mxVsdxUtils.surroundByTags(entry, "li");
|
||||
}
|
||||
|
||||
ret = mxVsdxUtils.surroundByTags(ret, "ul");
|
||||
HashMap<String, String> styleMap = new HashMap<String, String>();
|
||||
|
||||
if (bullet.equals("4"))
|
||||
{
|
||||
styleMap.put("list-style-type", "square");
|
||||
}
|
||||
else
|
||||
{
|
||||
styleMap.put("list-style-type", "disc");
|
||||
}
|
||||
|
||||
ret = this.insertAttributes(ret, styleMap);
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the paragraph formated according the properties in the last
|
||||
* Para element referenced.
|
||||
* @param para Paragraph to be formated
|
||||
* @return Formated paragraph.
|
||||
*/
|
||||
public String getTextParagraphFormated(String para)
|
||||
{
|
||||
String ret = "";
|
||||
HashMap<String, String> styleMap = new HashMap<String, String>();
|
||||
styleMap.put("align", getHorizontalAlign(pp, true));
|
||||
styleMap.put("margin-left", getIndentLeft(pp));
|
||||
styleMap.put("margin-right", getIndentRight(pp));
|
||||
styleMap.put("margin-top", getSpBefore(pp) + "px");
|
||||
styleMap.put("margin-bottom", getSpAfter(pp) + "px");
|
||||
styleMap.put("text-indent", getIndentFirst(pp));
|
||||
styleMap.put("valign", getAlignVertical());
|
||||
// String spc = getSpcLine(pp);
|
||||
//TODO dividing by 0.71 gives very large line height in most of the cases. Probably we don't need it?
|
||||
// String spcNum = spc.replaceAll("[^\\d.]", "");
|
||||
// String postFix = spc.substring(spcNum.length(),spc.length());
|
||||
//double lineH = (Double.parseDouble(spcNum) / 0.71);
|
||||
// spc = Double.toString(lineH);
|
||||
//
|
||||
// if (spc.contains("."))
|
||||
// {
|
||||
// spc = spc.substring(0, spc.lastIndexOf(".") + 3);
|
||||
// }
|
||||
//
|
||||
// spc = spc + postFix;
|
||||
// styleMap.put("line-height", spc);
|
||||
styleMap.put("direction", getTextDirection(pp));
|
||||
ret += insertAttributes(para, styleMap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text formated according the properties in the last
|
||||
* Char element referenced.
|
||||
* @param text Text to be formated
|
||||
* @return Formated text.
|
||||
*/
|
||||
public String getTextCharFormated(String text)
|
||||
{
|
||||
String ret = "";
|
||||
String color = "color:" + getTextColor(cp) + ";";
|
||||
String size = "font-size:" + (Double.parseDouble(this.getTextSize(cp))) + "px;";
|
||||
String font = "font-family:" + this.getTextFont(cp) + ";";
|
||||
String direction = "direction:" + this.getRtlText(cp) + ";";
|
||||
String space = "letter-spacing:" + (Double.parseDouble(this.getLetterSpace(cp)) / 0.71) + "px;";
|
||||
String lineHeight = "line-height:" + getSpcLine(pp);
|
||||
String opacity = ";opacity:" + getTextOpacity(cp);
|
||||
String pos = this.getTextPos(cp);
|
||||
String tCase = getTextCase(cp);
|
||||
|
||||
if (tCase.equals("1"))
|
||||
{
|
||||
text = text.toUpperCase();
|
||||
}
|
||||
else if (tCase.equals("2"))
|
||||
{
|
||||
text = mxVsdxUtils.toInitialCapital(text);
|
||||
}
|
||||
|
||||
if (pos.equals("1"))
|
||||
{
|
||||
text = mxVsdxUtils.surroundByTags(text, "sup");
|
||||
}
|
||||
else if (pos.equals("2"))
|
||||
{
|
||||
text = mxVsdxUtils.surroundByTags(text, "sub");
|
||||
}
|
||||
|
||||
text = this.isBold(cp) ? mxVsdxUtils.surroundByTags(text, "b") : text;
|
||||
text = this.isItalic(cp) ? mxVsdxUtils.surroundByTags(text, "i") : text;
|
||||
text = this.isUnderline(cp) ? mxVsdxUtils.surroundByTags(text, "u") : text;
|
||||
text = this.getTextStrike(cp) ? mxVsdxUtils.surroundByTags(text, "s") : text;
|
||||
text = this.isSmallCaps(cp) ? mxVsdxUtils.toSmallCaps(text, this.getTextSize(cp)) : text;
|
||||
|
||||
ret += "<font style=\"" + size + font + color + direction + space + lineHeight + opacity + "\">" + text + "</font>";
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the direction of the text. It may be right to left or left to right.<br/>
|
||||
* This property may to be founded in the shape, master shape, stylesheet or
|
||||
* default style-sheet.
|
||||
* @param index Index of the Para element that contains the Flags element.
|
||||
* @return The direction of the text.
|
||||
*/
|
||||
public String getTextDirection(String index)
|
||||
{
|
||||
String direction = getFlags(index);
|
||||
|
||||
if (direction.equals("0"))
|
||||
{
|
||||
direction = "ltr";
|
||||
}
|
||||
else if (direction.equals("1"))
|
||||
{
|
||||
direction = "rtl";
|
||||
}
|
||||
|
||||
return direction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the space between lines in a paragraph.<br/>
|
||||
* This property may to be founded in the shape, master shape, stylesheet or
|
||||
* default style-sheet.
|
||||
* @param index Index of the Para element that contains the SpLine element.
|
||||
* @return The space between lines n pixels.
|
||||
*/
|
||||
public String getSpcLine(String index)
|
||||
{
|
||||
String ret = "0";
|
||||
boolean isPercent = false;
|
||||
double space = getSpLine(index);
|
||||
|
||||
if (space > 0)
|
||||
{
|
||||
space = space * mxVsdxUtils.conversionFactor;
|
||||
}
|
||||
else if (space == 0)
|
||||
{
|
||||
space = 100;
|
||||
isPercent = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
space = Math.abs(space) * 100;
|
||||
isPercent = true;
|
||||
}
|
||||
|
||||
ret = String.valueOf(space);
|
||||
ret += isPercent ? "%" : "px";
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the space before a paragraph.<br/>
|
||||
* This property may to be founded in the shape, master shape, stylesheet or
|
||||
* default style-sheet.
|
||||
* @param index Index of the Para element that contains the SpBefore element.
|
||||
* @return The space before the paragraph in pixels.
|
||||
*/
|
||||
public String getSpcBefore(String index)
|
||||
{
|
||||
return getSpBefore(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts the style attributes contained in attr into the text.<br/>
|
||||
* The text must be surrounded by tags html.
|
||||
* @param text Text where the attributes must be inserted.
|
||||
* @param attr Map with the attributes.
|
||||
* @return Text with the attributes applied like style.
|
||||
*/
|
||||
public String insertAttributes(String text, HashMap<String, String> attr)
|
||||
{
|
||||
if (text.contains(">"))
|
||||
{
|
||||
int i = text.indexOf(">");
|
||||
String tail = text.substring(i);
|
||||
String head = text.substring(0, i);
|
||||
|
||||
String style = " style=\"" + mxVsdxUtils.getStyleString(attr, ":") + "\"";
|
||||
return head + style + tail;
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the direction of the text. It may be right to left or left to right.<br/>
|
||||
* This property may to be founded in the shape, master shape, stylesheet or
|
||||
* default stylesheet.
|
||||
* @param index Index of the Char element that contains the RTLText element.
|
||||
* @return Direction of the text.
|
||||
*/
|
||||
public String getRtlText(String index)
|
||||
{
|
||||
Element rtlElem = getCellElement(mxVsdxConstants.RTL_TEXT, index, mxVsdxConstants.PARAGRAPH);
|
||||
String direction = getValue(rtlElem, "ltr");
|
||||
|
||||
|
||||
if (direction.equals("0"))
|
||||
{
|
||||
direction = "ltr";
|
||||
}
|
||||
else if (direction.equals("1"))
|
||||
{
|
||||
direction = "rtl";
|
||||
}
|
||||
|
||||
return direction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the style property of the Char element of index = 'index'
|
||||
* indicates bold.<br/>
|
||||
* This property may to be founded in the shape, master shape, stylesheet or
|
||||
* default stylesheet.
|
||||
* @param index Index of the Char element that contains the Style element.
|
||||
* @return Returns <code>true</code> if the style property of the Char element of
|
||||
* index = 'index' indicates bold.
|
||||
*/
|
||||
public boolean isBold(String index)
|
||||
{
|
||||
boolean isBold = false;
|
||||
String style = getTextStyle(index);
|
||||
|
||||
if (!style.equals(""))
|
||||
{
|
||||
if (style.toLowerCase().equals("themed"))
|
||||
{
|
||||
// TODO theme support
|
||||
}
|
||||
else
|
||||
{
|
||||
int value = Integer.parseInt(style);
|
||||
isBold = ((value & 1) == 1);
|
||||
}
|
||||
}
|
||||
|
||||
return isBold;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the style property of the Char element of index = 'index'
|
||||
* indicates italic.<br/>
|
||||
* This property may to be founded in the shape, master shape, stylesheet or
|
||||
* default stylesheet.
|
||||
* @param index Index of the Char element that contains the Style element.
|
||||
* @return Returns <code>true</code> if the style property of the Char element of
|
||||
* index = 'index' indicates italic.
|
||||
*/
|
||||
public boolean isItalic(String index)
|
||||
{
|
||||
boolean isItalic = false;
|
||||
String style = getTextStyle(index);
|
||||
|
||||
if (!style.equals(""))
|
||||
{
|
||||
if (style.toLowerCase().equals("themed"))
|
||||
{
|
||||
// TODO theme support
|
||||
}
|
||||
else
|
||||
{
|
||||
int value = Integer.parseInt(style);
|
||||
isItalic = ((value & 2) == 2);
|
||||
}
|
||||
}
|
||||
|
||||
return isItalic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the style property of the Char element of index = 'index'
|
||||
* indicates underline.<br/>
|
||||
* This property may to be founded in the shape, master shape, stylesheet or
|
||||
* default stylesheet.
|
||||
* @param index Index of the Char element that contains the Style element.
|
||||
* @return Returns <code>true</code> if the style property of the Char element of
|
||||
* index = 'index' indicates underline.
|
||||
*/
|
||||
public boolean isUnderline(String index)
|
||||
{
|
||||
boolean isUnderline = false;
|
||||
String style = getTextStyle(index);
|
||||
|
||||
if (!style.equals(""))
|
||||
{
|
||||
if (style.toLowerCase().equals("themed"))
|
||||
{
|
||||
// TODO theme support
|
||||
}
|
||||
else
|
||||
{
|
||||
int value = Integer.parseInt(style);
|
||||
isUnderline = ((value & 4) == 4);
|
||||
}
|
||||
}
|
||||
|
||||
return isUnderline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the style property of the Char element of index = 'index'
|
||||
* indicates small caps.<br/>
|
||||
* This property may to be founded in the shape, master shape, stylesheet or
|
||||
* default stylesheet.
|
||||
* @param index Index of the Char element that contains the Style element.
|
||||
* @return Returns <code>true</code> if the style property of the Char element of
|
||||
* index = 'index' indicates small caps.
|
||||
*/
|
||||
public boolean isSmallCaps(String index)
|
||||
{
|
||||
boolean isSmallCaps = false;
|
||||
String style = getTextStyle(index);
|
||||
|
||||
if (!style.equals(""))
|
||||
{
|
||||
if (style.toLowerCase().equals("themed"))
|
||||
{
|
||||
// TODO theme support
|
||||
}
|
||||
else
|
||||
{
|
||||
int value = Integer.parseInt(style);
|
||||
isSmallCaps = ((value & 8) == 8);
|
||||
}
|
||||
}
|
||||
|
||||
return isSmallCaps;
|
||||
}
|
||||
|
||||
public String getTextOpacity(String index)
|
||||
{
|
||||
Element colorTrans = getCellElement(mxVsdxConstants.COLOR_TRANS, index, mxVsdxConstants.CHARACTER);
|
||||
String trans = getValue(colorTrans, "0");
|
||||
String result = "1";
|
||||
|
||||
if (trans != null && !trans.isEmpty())
|
||||
{
|
||||
double tmp = 1.0 - Double.valueOf(trans);
|
||||
result = String.valueOf(tmp);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the actual text size defined by the Char element referenced in cp.<br/>
|
||||
* This property may to be founded in the shape, master shape, stylesheet or
|
||||
* default stylesheet.
|
||||
* @param index Index of the Char element that contains the Size element.
|
||||
* @return Returns the size of the font in pixels.
|
||||
*/
|
||||
public String getTextSize(String index)
|
||||
{
|
||||
Element sizeElem = getCellElement(mxVsdxConstants.SIZE, index, mxVsdxConstants.CHARACTER);
|
||||
double size = getScreenNumericalValue(sizeElem, 12);
|
||||
|
||||
return Double.toString(Math.round(size * 100) / 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the vertical align of the label.<br/>
|
||||
* The property may to be defined in master shape or text stylesheet.<br/>
|
||||
* @return Vertical align (bottom, middle and top)
|
||||
*/
|
||||
public String getAlignVertical()
|
||||
{
|
||||
String vertical = mxConstants.ALIGN_MIDDLE;
|
||||
|
||||
int align = Integer.parseInt(getValue(this.getCellElement(mxVsdxConstants.VERTICAL_ALIGN), "1"));
|
||||
|
||||
if (align == 0)
|
||||
{
|
||||
vertical = mxConstants.ALIGN_TOP;
|
||||
}
|
||||
else if (align == 2)
|
||||
{
|
||||
vertical = mxConstants.ALIGN_BOTTOM;
|
||||
}
|
||||
|
||||
return vertical;
|
||||
}
|
||||
|
||||
public mxVsdxGeometryList getGeomList()
|
||||
{
|
||||
return geomList;
|
||||
}
|
||||
|
||||
public double getLastX() {
|
||||
return lastX;
|
||||
}
|
||||
|
||||
public double getLastY() {
|
||||
return lastY;
|
||||
}
|
||||
|
||||
public double getLastMoveX() {
|
||||
return lastMoveX;
|
||||
}
|
||||
|
||||
public double getLastMoveY() {
|
||||
return lastMoveY;
|
||||
}
|
||||
|
||||
public double getLastKnot() {
|
||||
return lastKnot;
|
||||
}
|
||||
|
||||
public void setLastX(double lastX) {
|
||||
this.lastX = lastX;
|
||||
}
|
||||
|
||||
public void setLastY(double lastY) {
|
||||
this.lastY = lastY;
|
||||
}
|
||||
|
||||
public void setLastMoveX(double lastMoveX) {
|
||||
this.lastMoveX = lastMoveX;
|
||||
}
|
||||
|
||||
public void setLastMoveY(double lastMoveY) {
|
||||
this.lastMoveY = lastMoveY;
|
||||
}
|
||||
|
||||
public void setLastKnot(double lastKnot) {
|
||||
this.lastKnot = lastKnot;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,73 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.geometry;
|
||||
|
||||
import com.mxgraph.io.vsdx.Shape;
|
||||
import com.mxgraph.io.vsdx.mxPoint;
|
||||
import com.mxgraph.io.vsdx.mxVsdxUtils;
|
||||
|
||||
public class ArcTo extends Row
|
||||
{
|
||||
public ArcTo(int index, Double x, Double y, Double a)
|
||||
{
|
||||
super(index, x, y);
|
||||
this.a = a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(mxPoint p, Shape shape)
|
||||
{
|
||||
if (this.x != null && this.y != null && this.a != null)
|
||||
{
|
||||
double h = shape.getHeight();
|
||||
double w = shape.getWidth();
|
||||
double x0 = Math.round(shape.getLastX() * w) / 100;
|
||||
double y0 = Math.round(shape.getLastY() * h) / 100;
|
||||
double x = this.x * mxVsdxUtils.conversionFactor;
|
||||
|
||||
double y = this.y * mxVsdxUtils.conversionFactor;
|
||||
y = h - y;
|
||||
|
||||
double a = this.a * mxVsdxUtils.conversionFactor;
|
||||
|
||||
double dx = Math.abs(x - x0);
|
||||
double dy = Math.abs(y - y0);
|
||||
|
||||
double rx = (a * 0.5) + (dx * dx + dy * dy) / (8.0 * a);
|
||||
double ry = rx;
|
||||
double r0 = Math.abs(rx);
|
||||
|
||||
rx = rx * 100 / w;
|
||||
ry = ry * 100 / h;
|
||||
x = x * 100 / w;
|
||||
y = y * 100 / h;
|
||||
rx = Math.round(rx * 100.0) / 100.0;
|
||||
ry = Math.round(ry * 100.0) / 100.0;
|
||||
x = Math.round(x * 100.0) / 100.0;
|
||||
y = Math.round(y * 100.0) / 100.0;
|
||||
|
||||
a = Math.round(a * 100.0) / 100.0;
|
||||
rx = Math.abs(rx);
|
||||
ry = Math.abs(ry);
|
||||
|
||||
//determine sweep and large-arc flag
|
||||
String sf = (a < 0) ? "1" : "0";
|
||||
String laf = (r0 < Math.abs(a)) ? "1" : "0";
|
||||
|
||||
shape.setLastX(x);
|
||||
shape.setLastY(y);
|
||||
|
||||
return "<arc" +
|
||||
" rx=\"" + String.valueOf(rx) +
|
||||
"\" ry=\"" + String.valueOf(ry) +
|
||||
"\" x=\"" + String.valueOf(x) +
|
||||
"\" y=\"" + String.valueOf(y) +
|
||||
"\" x-axis-rotation=\"0" +
|
||||
"\" large-arc-flag=\"" + laf +
|
||||
"\" sweep-flag=\"" + sf +
|
||||
"\"/>";
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.geometry;
|
||||
|
||||
import com.mxgraph.io.vsdx.Shape;
|
||||
import com.mxgraph.io.vsdx.mxPoint;
|
||||
|
||||
public class DelRow extends Row{
|
||||
|
||||
public DelRow(int index) {
|
||||
super(index, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(mxPoint p, Shape shape)
|
||||
{
|
||||
//Nothing
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,204 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.geometry;
|
||||
|
||||
import com.mxgraph.io.vsdx.Shape;
|
||||
import com.mxgraph.io.vsdx.mxVsdxUtils;
|
||||
import com.mxgraph.io.vsdx.mxPoint;
|
||||
|
||||
public class Ellipse extends Row
|
||||
{
|
||||
public Ellipse(int index, Double x, Double y, Double a, Double b, Double c, Double d)
|
||||
{
|
||||
super(index, x, y);
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
this.d = d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(mxPoint p, Shape shape)
|
||||
{
|
||||
if (this.x != null && this.y != null && this.a != null && this.b != null && this.c != null && this.d != null)
|
||||
{
|
||||
double h = shape.getHeight();
|
||||
double w = shape.getWidth();
|
||||
|
||||
double x = this.x * mxVsdxUtils.conversionFactor;
|
||||
double y = this.y * mxVsdxUtils.conversionFactor;
|
||||
y = h - y;
|
||||
double a = this.a * mxVsdxUtils.conversionFactor;
|
||||
double b = this.b * mxVsdxUtils.conversionFactor;
|
||||
b = h - b;
|
||||
double c = this.c * mxVsdxUtils.conversionFactor;
|
||||
double d = this.d * mxVsdxUtils.conversionFactor;
|
||||
d = h - d;
|
||||
|
||||
double dx1 = Math.abs(a - x);
|
||||
double dy1 = Math.abs(b - y);
|
||||
double r1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
|
||||
|
||||
double dx2 = Math.abs(c - x);
|
||||
double dy2 = Math.abs(d - y);
|
||||
double r2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
|
||||
double newX = x * 100 / w;
|
||||
double newY = y * 100 / h;
|
||||
double newW = (r1 * 100 / w)/2;
|
||||
double newH = (r2 * 100 / h)/2;
|
||||
newH = Math.round(newH * 100.0) / 100.0;
|
||||
newW = Math.round(newW * 100.0) / 100.0;
|
||||
double newX1 = Math.round((newX - 2 * newW) * 100.0) / 100.0;
|
||||
double newX2 = Math.round((newX + 2 * newW) * 100.0) / 100.0;
|
||||
newY = Math.round(newY * 100.0) / 100.0;
|
||||
|
||||
|
||||
return "<move x=\"" + String.valueOf(newX1) + "\" y=\"" + String.valueOf(newY) + "\"/>" +
|
||||
"<arc" +
|
||||
" rx=\"" + String.valueOf(newW) +
|
||||
"\" ry=\"" + String.valueOf(newH) +
|
||||
"\" x=\"" + String.valueOf(newX2) +
|
||||
"\" y=\"" + String.valueOf(newY) +
|
||||
"\" x-axis-rotation=\"0\" large-arc-flag=\"1\" sweep-flag=\"0\"/>" +
|
||||
|
||||
"<arc" +
|
||||
" rx=\"" + String.valueOf(newW) +
|
||||
"\" ry=\"" + String.valueOf(newH) +
|
||||
"\" x=\"" + String.valueOf(newX1) +
|
||||
"\" y=\"" + String.valueOf(newY) +
|
||||
"\" x-axis-rotation=\"0\" large-arc-flag=\"1\" sweep-flag=\"0\"/>";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
// public String handle1(mxPoint p, Shape1 shape)
|
||||
// {
|
||||
// if (this.x != null && this.y != null && this.a != null && this.b != null && this.c != null && this.d != null)
|
||||
// {
|
||||
// double h = shape.getHeight();
|
||||
// double w = shape.getWidth();
|
||||
//
|
||||
// double x = this.x * mxVsdxUtils.conversionFactor;
|
||||
// double y = this.y * mxVsdxUtils.conversionFactor;
|
||||
// y = h - y;
|
||||
// double a = this.a * mxVsdxUtils.conversionFactor;
|
||||
// double b = this.b * mxVsdxUtils.conversionFactor;
|
||||
// b = h - b;
|
||||
// double c = this.c * mxVsdxUtils.conversionFactor;
|
||||
// double d = this.d * mxVsdxUtils.conversionFactor;
|
||||
// d = h - d;
|
||||
//
|
||||
// double dx1 = Math.abs(a - x);
|
||||
// double dy1 = Math.abs(b - y);
|
||||
// double r1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
|
||||
//
|
||||
// double dx2 = Math.abs(c - x);
|
||||
// double dy2 = Math.abs(d - y);
|
||||
// double r2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
|
||||
// double newX = x * 100 / w;
|
||||
// double newY = y * 100 / h;
|
||||
// double newW = (r1 * 100 / w)/2;
|
||||
// double newH = (r2 * 100 / h)/2;
|
||||
// newH = Math.round(newH * 100.0) / 100.0;
|
||||
// newW = Math.round(newW * 100.0) / 100.0;
|
||||
// double newX1 = Math.round((newX - 2 * newW) * 100.0) / 100.0;
|
||||
// double newX2 = Math.round((newX + 2 * newW) * 100.0) / 100.0;
|
||||
// newY = Math.round(newY * 100.0) / 100.0;
|
||||
//
|
||||
//
|
||||
// return "<move x=\"" + String.valueOf(newX1) + "\" y=\"" + String.valueOf(newY) + "\"/>" +
|
||||
// "<arc" +
|
||||
// " rx=\"" + String.valueOf(newW) +
|
||||
// "\" ry=\"" + String.valueOf(newH) +
|
||||
// "\" x=\"" + String.valueOf(newX2) +
|
||||
// "\" y=\"" + String.valueOf(newY) +
|
||||
// "\" x-axis-rotation=\"0\" large-arc-flag=\"1\" sweep-flag=\"0\"/>" +
|
||||
//
|
||||
// "<arc" +
|
||||
// " rx=\"" + String.valueOf(newW) +
|
||||
// "\" ry=\"" + String.valueOf(newH) +
|
||||
// "\" x=\"" + String.valueOf(newX1) +
|
||||
// "\" y=\"" + String.valueOf(newY) +
|
||||
// "\" x-axis-rotation=\"0\" large-arc-flag=\"1\" sweep-flag=\"0\"/>";
|
||||
// }
|
||||
//
|
||||
// return "";
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public String handle2(mxPoint p, Shape1 shape)
|
||||
// {
|
||||
// if (this.x != null && this.y != null && this.a != null && this.b != null && this.c != null && this.d != null)
|
||||
// {
|
||||
// double h = shape.getHeight();
|
||||
// double w = shape.getWidth();
|
||||
//
|
||||
// double x = this.x * mxVsdxUtils.conversionFactor;
|
||||
// double y = this.y * mxVsdxUtils.conversionFactor;
|
||||
// y = h - y;
|
||||
// double a = this.a * mxVsdxUtils.conversionFactor;
|
||||
// double b = this.b * mxVsdxUtils.conversionFactor;
|
||||
// b = h - b;
|
||||
// double c = this.c * mxVsdxUtils.conversionFactor;
|
||||
// double d = this.d * mxVsdxUtils.conversionFactor;
|
||||
// d = h - d;
|
||||
//
|
||||
// double dx1 = Math.abs(a - x);
|
||||
// double dy1 = Math.abs(b - y);
|
||||
// double r1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
|
||||
//
|
||||
// double dx2 = Math.abs(c - x);
|
||||
// double dy2 = Math.abs(d - y);
|
||||
// double r2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
|
||||
// double newX = (x - r1) * 100 / w;
|
||||
// double newY = (y - r2) * 100 / h;
|
||||
// double newW = 2 * r1 * 100 / w;
|
||||
// double newH = 2 * r2 * 100 / h;
|
||||
// newH = Math.round(newH * 100.0) / 100.0;
|
||||
// newW = Math.round(newW * 100.0) / 100.0;
|
||||
// newX = Math.round(newX * 100.0) / 100.0;
|
||||
// newY = Math.round(newY * 100.0) / 100.0;
|
||||
//
|
||||
// return "<ellipse" +
|
||||
// " x=\"" + String.valueOf(newX) +
|
||||
// "\" y=\"" + String.valueOf(newY) +
|
||||
// "\" w=\"" + String.valueOf(newW) +
|
||||
// "\" h=\"" + String.valueOf(newH) +
|
||||
// "\"/>";
|
||||
// }
|
||||
//
|
||||
// return "";
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public static class Shape1 {
|
||||
// double width, height;
|
||||
//
|
||||
// public double getWidth() {
|
||||
// return width;
|
||||
// }
|
||||
//
|
||||
// public double getHeight() {
|
||||
// return height;
|
||||
// }
|
||||
//
|
||||
// public void setWidth(double width) {
|
||||
// this.width = width;
|
||||
// }
|
||||
//
|
||||
// public void setHeight(double height) {
|
||||
// this.height = height;
|
||||
// }
|
||||
//
|
||||
// public Shape1(double width, double height) {
|
||||
// this.width = width;
|
||||
// this.height = height;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// public static void main(String[] args) {
|
||||
// Shape1 shape = new Shape1(160.91, 76.2);
|
||||
// Ellipse ellipse = new Ellipse(0, 0.5, 0.1, 0.93, 0.1, 0.90, 0.50);
|
||||
// System.out.println(ellipse.handle1(null, shape));
|
||||
// System.out.println(ellipse.handle2(null, shape));
|
||||
// }
|
||||
}
|
|
@ -1,166 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.geometry;
|
||||
|
||||
import com.mxgraph.io.vsdx.Shape;
|
||||
import com.mxgraph.io.vsdx.mxVsdxUtils;
|
||||
import com.mxgraph.io.vsdx.mxPoint;
|
||||
|
||||
public class EllipticalArcTo extends Row
|
||||
{
|
||||
public EllipticalArcTo(int index, Double x, Double y, Double a, Double b, Double c, Double d)
|
||||
{
|
||||
super(index, x, y);
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
this.d = d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(mxPoint p, Shape shape)
|
||||
{
|
||||
if (this.x != null && this.y != null && this.a != null && this.b != null && this.c != null && this.d != null)
|
||||
{
|
||||
double h = shape.getHeight();
|
||||
double w = shape.getWidth();
|
||||
|
||||
double x = this.x * mxVsdxUtils.conversionFactor;
|
||||
double y = this.y * mxVsdxUtils.conversionFactor;
|
||||
y = h - y;
|
||||
double a = this.a * mxVsdxUtils.conversionFactor;
|
||||
double b = this.b * mxVsdxUtils.conversionFactor;
|
||||
double c = this.c;
|
||||
double d = this.d;
|
||||
|
||||
x = x * 100.0 / w;
|
||||
y = y * 100.0 / h;
|
||||
|
||||
double x1 = shape.getLastX() * w / 100.0;
|
||||
double y1 = shape.getLastY() * h / 100.0;
|
||||
|
||||
double x2 = x * w / 100.0;
|
||||
double y2 = y * h / 100.0;
|
||||
|
||||
double x3 = a;
|
||||
double y3 = h - b;
|
||||
|
||||
double ang = -c;
|
||||
|
||||
double p1x = Math.sqrt(x1 * x1 + y1 * y1) * Math.cos(Math.atan2(y1, x1) - ang);
|
||||
double p1y = Math.sqrt(x1 * x1 + y1 * y1) * Math.sin(Math.atan2(y1, x1) - ang);
|
||||
|
||||
double p2x = Math.sqrt(x2 * x2 + y2 * y2) * Math.cos(Math.atan2(y2, x2) - ang);
|
||||
double p2y = Math.sqrt(x2 * x2 + y2 * y2) * Math.sin(Math.atan2(y2, x2) - ang);
|
||||
|
||||
double p3x = Math.sqrt(x3 * x3 + y3 * y3) * Math.cos(Math.atan2(y3, x3) - ang);
|
||||
double p3y = Math.sqrt(x3 * x3 + y3 * y3) * Math.sin(Math.atan2(y3, x3) - ang);
|
||||
|
||||
double p0x = ((p1x-p2x)*(p1x+p2x)*(p2y-p3y)-(p2x-p3x)*(p2x+p3x)*(p1y-p2y)+d*d*(p1y-p2y)*(p2y-p3y)*(p1y-p3y))/(2*((p1x-p2x)*(p2y-p3y)-(p2x-p3x)*(p1y-p2y)));
|
||||
double p0y = ((p1x-p2x)*(p2x-p3x)*(p1x-p3x)/(d*d)+(p2x-p3x)*(p1y-p2y)*(p1y+p2y)-(p1x-p2x)*(p2y-p3y)*(p2y+p3y))/(2*((p2x-p3x)*(p1y-p2y)-(p1x-p2x)*(p2y-p3y)));
|
||||
|
||||
double newX = Math.sqrt(p0x * p0x + p0y * p0y) * Math.cos(Math.atan2(p0y, p0x) + ang);
|
||||
double newY = Math.sqrt(p0x * p0x + p0y * p0y) * Math.sin(Math.atan2(p0y, p0x) + ang);
|
||||
|
||||
newX = newX * w / 100.0;
|
||||
newY = newY * h / 100.0;
|
||||
|
||||
double dx = p1x - p0x;
|
||||
double dy = p1y - p0y;
|
||||
double rx = Math.sqrt(dx * dx + dy * dy * d * d);
|
||||
double ry = rx / d;
|
||||
double rot = Math.toDegrees(ang);
|
||||
|
||||
rx = rx * 100.0 / w;
|
||||
ry = ry * 100.0 / h;
|
||||
|
||||
x = Math.round(x * 100.0) / 100.0;
|
||||
y = Math.round(y * 100.0) / 100.0;
|
||||
rx = Math.round(rx * 100.0) / 100.0;
|
||||
ry = Math.round(ry * 100.0) / 100.0;
|
||||
rot = Math.round(rot * 100.0) / 100.0;
|
||||
|
||||
//determine sweep
|
||||
//TODO fix rare error (file "1 Supported Forms" shape "storeddata" on page 5)
|
||||
double sweep = (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1);
|
||||
String sf = (sweep > 0) ? "0" : "1";
|
||||
|
||||
//determine large arc flag
|
||||
String laf = "0";
|
||||
|
||||
if (mxVsdxUtils.isInsideTriangle(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y) &&
|
||||
isReflexAngle(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y))
|
||||
{
|
||||
laf = "1";
|
||||
}
|
||||
|
||||
shape.setLastX(x);
|
||||
shape.setLastY(y);
|
||||
|
||||
return "<arc" +
|
||||
" rx=\"" + String.valueOf(rx) +
|
||||
"\" ry=\"" + String.valueOf(ry) +
|
||||
"\" x=\"" + String.valueOf(x) +
|
||||
"\" y=\"" + String.valueOf(y) +
|
||||
"\" x-axis-rotation=\"" + String.valueOf(rot) +
|
||||
"\" large-arc-flag=\"" + laf +
|
||||
"\" sweep-flag=\"" + sf +
|
||||
"\"/>";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x0 y0 center point of ellipse containing the arc
|
||||
* @param x1 y1 starting point of the arc
|
||||
* @param x2 y2 endpoint of the arc
|
||||
* @param x3 y3 control point
|
||||
* @return true if the start to end angle that contains the control point is a reflex angle
|
||||
*/
|
||||
protected boolean isReflexAngle(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3)
|
||||
{
|
||||
x1 = x1 - x0;
|
||||
y1 = y1 - y0;
|
||||
x2 = x2 - x0;
|
||||
y2 = y2 - y0;
|
||||
x2 = x3 - x0;
|
||||
y3 = y3 - y0;
|
||||
x0 = 0;
|
||||
y0 = 0;
|
||||
|
||||
double aStart = Math.toDegrees(Math.atan2(y1, x1) - Math.atan2(y0, x0));
|
||||
double aEnd = Math.toDegrees(Math.atan2(y2, x2) - Math.atan2(y0, x0));
|
||||
double aCP = Math.toDegrees(Math.atan2(y3, x3) - Math.atan2(y0, x0));
|
||||
|
||||
aStart = (aStart - aCP) % 360;
|
||||
aEnd = (aEnd - aCP) % 360;
|
||||
|
||||
if (aStart > 180)
|
||||
{
|
||||
aStart = aStart - 360;
|
||||
}
|
||||
else if (aStart < -180)
|
||||
{
|
||||
aStart = aStart + 360;
|
||||
}
|
||||
|
||||
if (aEnd > 180)
|
||||
{
|
||||
aEnd = aEnd - 360;
|
||||
}
|
||||
else if (aEnd < -180)
|
||||
{
|
||||
aEnd = aEnd + 360;
|
||||
}
|
||||
|
||||
if ((aStart > 0 && aEnd < 0) || (aStart < 0 && aEnd > 0))
|
||||
{
|
||||
if (Math.abs(aStart - aEnd) > 180)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.geometry;
|
||||
|
||||
import com.mxgraph.io.vsdx.Shape;
|
||||
import com.mxgraph.io.vsdx.mxPoint;
|
||||
|
||||
public class InfiniteLine extends Row
|
||||
{
|
||||
public InfiniteLine(int index, Double x, Double y, Double a, Double b)
|
||||
{
|
||||
super(index, x, y);
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(mxPoint p, Shape shape)
|
||||
{
|
||||
//TODO implement this!
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.geometry;
|
||||
|
||||
import com.mxgraph.io.vsdx.Shape;
|
||||
import com.mxgraph.io.vsdx.mxVsdxUtils;
|
||||
import com.mxgraph.io.vsdx.mxPoint;
|
||||
|
||||
public class LineTo extends Row
|
||||
{
|
||||
|
||||
public LineTo(int index, Double x, Double y)
|
||||
{
|
||||
super(index, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(mxPoint p, Shape shape)
|
||||
{
|
||||
double x = p.getX(), y = p.getY();
|
||||
double h = shape.getHeight();
|
||||
double w = shape.getWidth();
|
||||
|
||||
if (this.x != null && this.y != null)
|
||||
{
|
||||
x = this.x * mxVsdxUtils.conversionFactor;
|
||||
y = this.y * mxVsdxUtils.conversionFactor;
|
||||
}
|
||||
|
||||
x = x * 100.0 / w;
|
||||
y = y * 100.0 / h;
|
||||
y = 100 - y;
|
||||
|
||||
x = Math.round(x * 100.0) / 100.0;
|
||||
y = Math.round(y * 100.0) / 100.0;
|
||||
|
||||
p.setX(x);
|
||||
p.setY(y);
|
||||
shape.setLastX(x);
|
||||
shape.setLastY(y);
|
||||
|
||||
return "<" + "line" + " x=\"" + String.valueOf(x) + "\" y=\"" + String.valueOf(y) + "\"/>";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.geometry;
|
||||
|
||||
import com.mxgraph.io.vsdx.Shape;
|
||||
import com.mxgraph.io.vsdx.mxVsdxUtils;
|
||||
import com.mxgraph.io.vsdx.mxPoint;
|
||||
|
||||
public class MoveTo extends Row
|
||||
{
|
||||
public MoveTo(int index, Double x, Double y)
|
||||
{
|
||||
super(index, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(mxPoint p, Shape shape)
|
||||
{
|
||||
double x = p.getX(), y = p.getY();
|
||||
double h = shape.getHeight();
|
||||
double w = shape.getWidth();
|
||||
|
||||
if (this.x != null && this.y != null)
|
||||
{
|
||||
x = this.x * mxVsdxUtils.conversionFactor;
|
||||
y = this.y * mxVsdxUtils.conversionFactor;
|
||||
}
|
||||
|
||||
x = x * 100.0 / w;
|
||||
y = y * 100.0 / h;
|
||||
y = 100 - y;
|
||||
|
||||
x = Math.round(x * 100.0) / 100.0;
|
||||
y = Math.round(y * 100.0) / 100.0;
|
||||
|
||||
p.setX(x);
|
||||
p.setY(y);
|
||||
shape.setLastX(x);
|
||||
shape.setLastY(y);
|
||||
shape.setLastMoveX(x);
|
||||
shape.setLastMoveY(y);
|
||||
|
||||
return "<" + "move" + " x=\"" + String.valueOf(x) + "\" y=\"" + String.valueOf(y) + "\"/>";
|
||||
}
|
||||
}
|
|
@ -1,248 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.geometry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.mxgraph.io.vsdx.Shape;
|
||||
import com.mxgraph.io.vsdx.mxVsdxUtils;
|
||||
import com.mxgraph.io.vsdx.mxPoint;
|
||||
|
||||
public class NURBSTo extends Row
|
||||
{
|
||||
public NURBSTo(int index, Double x, Double y, Double a, Double b, Double c, Double d, String e)
|
||||
{
|
||||
super(index, x, y);
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
this.d = d;
|
||||
this.formulaE = e;
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds the NURBS array that is part of the VSDX NURBSTo element, together with some helper functions
|
||||
*
|
||||
*/
|
||||
private class Nurbs
|
||||
{
|
||||
|
||||
List<Double> nurbsValues = new ArrayList<Double>();
|
||||
|
||||
public Nurbs(String s, double w, double h)
|
||||
{
|
||||
List<String> n = Arrays.asList(s.split("\\s*,\\s*"));
|
||||
|
||||
for (int i = 0; i < n.size(); i++)
|
||||
{
|
||||
if ((i > 3) && (i % 4 == 0))
|
||||
{
|
||||
nurbsValues.add(Double.parseDouble(n.get(i)) * 100.0);
|
||||
}
|
||||
else if ((i > 3) && (i % 4 == 1))
|
||||
{
|
||||
nurbsValues.add(100 - Double.parseDouble(n.get(i)) * 100.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
nurbsValues.add(Double.parseDouble(n.get(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lastKnot the last knot outside of the nurbs string. Obtain it with this.getA()
|
||||
* @return true if knots are ordered by sets of 3
|
||||
*/
|
||||
public boolean isOrderedByThree(double lastKnot)
|
||||
{
|
||||
|
||||
for (int i = 0; i + 2 < (this.getSize()) ; i = i + 3)
|
||||
{
|
||||
double k = Math.round(this.getKnot((i)) * 100.0) / 100.0;
|
||||
double k1 = Math.round(this.getKnot((i + 1)) * 100.0) / 100.0;
|
||||
double k2 = Math.round(this.getKnot((i + 2)) * 100.0) / 100.0;
|
||||
|
||||
if (k != k1 || k != k2 || k1 != k2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
double k = Math.round(this.getKnot((this.getSize() - 2)) * 10.0) / 10.0;
|
||||
double k1 = Math.round(this.getKnot((this.getSize() - 1)) * 10.0) / 10.0;
|
||||
double lk = Math.round(lastKnot * 10.0) / 10.0;
|
||||
|
||||
if (k != k1 || k != lk || k1 != lk)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number of points, not including the last one (which is outside of the nurbs string)
|
||||
*/
|
||||
public int getSize()
|
||||
{
|
||||
return ((nurbsValues.size() / 4) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return last knot (element knotLast)
|
||||
*/
|
||||
public double getKnotLast()
|
||||
{
|
||||
return nurbsValues.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return degree of the NURBS (element degree)
|
||||
*/
|
||||
public double getDegree()
|
||||
{
|
||||
return nurbsValues.get(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 0 if X is relative, otherwise X is in the coordinate system of the shape (element xType)
|
||||
*/
|
||||
public double getXType()
|
||||
{
|
||||
return nurbsValues.get(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 0 if Y is relative, otherwise Y is in the coordinate system of the shape (element yType)
|
||||
*/
|
||||
public double getYType()
|
||||
{
|
||||
return nurbsValues.get(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the i-th X coordinate
|
||||
*/
|
||||
public double getX(int i)
|
||||
{
|
||||
return nurbsValues.get((i + 1) * 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the i-th Y coordinate
|
||||
*/
|
||||
public double getY(int i)
|
||||
{
|
||||
return nurbsValues.get((i + 1) * 4 + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the i-th knot
|
||||
*/
|
||||
public double getKnot(int i)
|
||||
{
|
||||
return nurbsValues.get((i + 1) * 4 + 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the i-th weight
|
||||
*/
|
||||
public double getWeight(int i)
|
||||
{
|
||||
return nurbsValues.get((i + 1) * 4 + 3);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class for geometry
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public String handle(mxPoint p, Shape shape)
|
||||
{
|
||||
if (this.x != null && this.y != null && this.formulaE != null)
|
||||
{
|
||||
double h = shape.getHeight();
|
||||
double w = shape.getWidth();
|
||||
|
||||
double x = this.x * mxVsdxUtils.conversionFactor;
|
||||
double y = this.y * mxVsdxUtils.conversionFactor;
|
||||
String eValue = this.formulaE.replace("NURBS(", "");
|
||||
eValue = eValue.replace(")", "");
|
||||
|
||||
Nurbs nurbs = new Nurbs(eValue, w, h);
|
||||
|
||||
if (nurbs.getSize() >= 2)
|
||||
{
|
||||
double x1 = nurbs.getX(0);
|
||||
double y1 = nurbs.getY(0);
|
||||
double x2 = nurbs.getX(1);
|
||||
double y2 = nurbs.getY(1);
|
||||
|
||||
y = y * 100.0 / h;
|
||||
x = x * 100.0 / w;
|
||||
y = 100 - y;
|
||||
x = Math.round(x * 100.0) / 100.0;
|
||||
y = Math.round(y * 100.0) / 100.0;
|
||||
|
||||
x1 = Math.round(x1 * 100.0) / 100.0;
|
||||
y1 = Math.round(y1 * 100.0) / 100.0;
|
||||
x2 = Math.round(x2 * 100.0) / 100.0;
|
||||
y2 = Math.round(y2 * 100.0) / 100.0;
|
||||
|
||||
shape.setLastX(x);
|
||||
shape.setLastY(y);
|
||||
|
||||
// solution for degree 3 rational b spline where knots are grouped by sets of 3
|
||||
if (nurbs.getDegree() == 3 && nurbs.isOrderedByThree(this.getA()))
|
||||
{
|
||||
//first control points
|
||||
List<mxPoint> cp1 = new ArrayList<mxPoint>();
|
||||
//second control points
|
||||
List<mxPoint> cp2 = new ArrayList<mxPoint>();
|
||||
//nuts
|
||||
List<mxPoint> nut = new ArrayList<mxPoint>();
|
||||
int nurbsize = nurbs.getSize();
|
||||
|
||||
for (int i = 0; i < nurbsize - 1; i = i + 3)
|
||||
{
|
||||
cp1.add(new mxPoint(nurbs.getX(i), nurbs.getY(i)));
|
||||
cp2.add(new mxPoint(nurbs.getX(i + 1), nurbs.getY(i + 1)));
|
||||
|
||||
if (i < nurbsize - 2)
|
||||
{
|
||||
nut.add(new mxPoint(nurbs.getX(i + 2), nurbs.getY(i + 2)));
|
||||
}
|
||||
else
|
||||
{
|
||||
nut.add(new mxPoint(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
//form path data
|
||||
String result = "";
|
||||
|
||||
for (int i = 0; i < cp1.size(); i++)
|
||||
{
|
||||
result += "<curve x1=\"" + cp1.get(i).getX() + "\" y1=\"" + cp1.get(i).getY() +
|
||||
"\" x2=\"" + cp2.get(i).getX() + "\" y2=\"" + cp2.get(i).getY() +
|
||||
"\" x3=\"" + nut.get(i).getX() + "\" y3=\"" + nut.get(i).getY() + "\"/>\n";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "<curve x1=\"" + String.valueOf(x1) + "\" y1=\"" + String.valueOf(y1) +
|
||||
"\" x2=\"" + String.valueOf(x2) + "\" y2=\"" + String.valueOf(y2) +
|
||||
"\" x3=\"" + String.valueOf(x) + "\" y3=\"" + String.valueOf(y) + "\"/>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.geometry;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import com.mxgraph.io.vsdx.Shape;
|
||||
import com.mxgraph.io.vsdx.mxVsdxUtils;
|
||||
import com.mxgraph.io.vsdx.mxPoint;
|
||||
|
||||
public class PolylineTo extends Row
|
||||
{
|
||||
public PolylineTo(int index, Double x, Double y, String a)
|
||||
{
|
||||
super(index, x, y);
|
||||
this.formulaA = a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(mxPoint p, Shape shape)
|
||||
{
|
||||
String result = "";
|
||||
|
||||
if (this.x != null && this.y != null && this.formulaA != null)
|
||||
{
|
||||
double h = shape.getHeight();
|
||||
double w = shape.getWidth();
|
||||
double x = this.x * mxVsdxUtils.conversionFactor;
|
||||
double y = this.y * mxVsdxUtils.conversionFactor;
|
||||
x = x * 100.0 / w;
|
||||
y = y * 100.0 / h;
|
||||
y = 100 - y;
|
||||
x = Math.round(x * 100.0) / 100.0;
|
||||
y = Math.round(y * 100.0) / 100.0;
|
||||
|
||||
String aValue = this.formulaA.replaceAll("\\s","").toLowerCase().replaceAll("polyline\\(","").replaceAll("\\)", "");
|
||||
|
||||
if (aValue.equals("inh"))
|
||||
{
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
LinkedList<String> polyEntriesList = new LinkedList<String>(Arrays.asList(aValue.split(",")));
|
||||
|
||||
double xRel = Double.parseDouble(polyEntriesList.remove(0));
|
||||
double yRel = Double.parseDouble(polyEntriesList.remove(0));
|
||||
double currX = 0;
|
||||
double currY = 0;
|
||||
|
||||
while (polyEntriesList.size() > 0)
|
||||
{
|
||||
currX = Double.valueOf(polyEntriesList.remove(0)) * mxVsdxUtils.conversionFactor;
|
||||
currY = Double.valueOf(polyEntriesList.remove(0)) * mxVsdxUtils.conversionFactor;
|
||||
|
||||
if (xRel == 1)
|
||||
{
|
||||
currX = currX * 100.0 / w;
|
||||
}
|
||||
|
||||
if (xRel == 1)
|
||||
{
|
||||
currY = currY * 100.0 / h;
|
||||
}
|
||||
|
||||
|
||||
currY = 100 - currY;
|
||||
|
||||
currX = Math.round(currX * 100.0) / 100.0;
|
||||
currY = Math.round(currY * 100.0) / 100.0;
|
||||
|
||||
shape.setLastX(currX);
|
||||
shape.setLastY(currY);
|
||||
|
||||
result += "<line x=\"" + String.valueOf(currX) + "\" y=\"" + String.valueOf(currY) + "\"/>";
|
||||
}
|
||||
|
||||
result += "<line x=\"" + String.valueOf(x) + "\" y=\"" + String.valueOf(y) + "\"/>";
|
||||
|
||||
if (shape.getLastMoveX() == x && shape.getLastMoveY() == y)
|
||||
{
|
||||
result += "<close/>";
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.geometry;
|
||||
|
||||
import com.mxgraph.io.vsdx.Shape;
|
||||
import com.mxgraph.io.vsdx.mxPoint;
|
||||
|
||||
public class RelCubBezTo extends Row
|
||||
{
|
||||
public RelCubBezTo(int index, Double x, Double y, Double a, Double b, Double c, Double d)
|
||||
{
|
||||
super(index, x, y);
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
this.d = d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(mxPoint p, Shape shape)
|
||||
{
|
||||
if (this.x != null && this.y != null && this.a != null && this.b != null && this.c != null && this.d != null)
|
||||
{
|
||||
double x = this.x * 100;
|
||||
double y = 100 - this.y * 100;
|
||||
double x1 = this.a * 100.0;
|
||||
double y1 = 100 - this.b * 100.0;
|
||||
double x2 = this.c * 100.0;
|
||||
double y2 = 100 - this.d * 100.0;
|
||||
|
||||
x = Math.round(x * 100.0) / 100.0;
|
||||
y = Math.round(y * 100.0) / 100.0;
|
||||
x1 = Math.round(x1 * 100.0) / 100.0;
|
||||
y1 = Math.round(y1 * 100.0) / 100.0;
|
||||
x2 = Math.round(x2 * 100.0) / 100.0;
|
||||
y2 = Math.round(y2 * 100.0) / 100.0;
|
||||
|
||||
shape.setLastX(x);
|
||||
shape.setLastY(y);
|
||||
|
||||
return "<curve x1=\"" + String.valueOf(x1) + "\" y1=\"" + String.valueOf(y1) +
|
||||
"\" x2=\"" + String.valueOf(x2) + "\" y2=\"" + String.valueOf(y2) +
|
||||
"\" x3=\"" + String.valueOf(x) + "\" y3=\"" + String.valueOf(y) + "\"/>";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.geometry;
|
||||
|
||||
import com.mxgraph.io.vsdx.Shape;
|
||||
import com.mxgraph.io.vsdx.mxVsdxUtils;
|
||||
import com.mxgraph.io.vsdx.mxPoint;
|
||||
|
||||
public class RelEllipticalArcTo extends EllipticalArcTo
|
||||
{
|
||||
public RelEllipticalArcTo(int index, Double x, Double y, Double a, Double b, Double c, Double d)
|
||||
{
|
||||
super(index, x, y, a, b, c, d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(mxPoint p, Shape shape) {
|
||||
if (this.x != null && this.y != null && this.a != null && this.b != null && this.c != null && this.d != null)
|
||||
{
|
||||
double h = shape.getHeight() / mxVsdxUtils.conversionFactor;
|
||||
double w = shape.getWidth() / mxVsdxUtils.conversionFactor;
|
||||
this.x *= w;
|
||||
this.y *= h;
|
||||
this.a *= w;
|
||||
this.b *= h;
|
||||
}
|
||||
return super.handle(p, shape);
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.geometry;
|
||||
|
||||
import com.mxgraph.io.vsdx.Shape;
|
||||
import com.mxgraph.io.vsdx.mxPoint;
|
||||
|
||||
public class RelLineTo extends Row
|
||||
{
|
||||
|
||||
public RelLineTo(int index, Double x, Double y)
|
||||
{
|
||||
super(index, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(mxPoint p, Shape shape)
|
||||
{
|
||||
double x = p.getX(), y = p.getY();
|
||||
|
||||
if (this.x != null && this.y != null)
|
||||
{
|
||||
x = this.x * 100;
|
||||
y = 100 - this.y * 100;
|
||||
}
|
||||
|
||||
x = Math.round(x * 100.0) / 100.0;
|
||||
y = Math.round(y * 100.0) / 100.0;
|
||||
|
||||
p.setX(x);
|
||||
p.setY(y);
|
||||
shape.setLastX(x);
|
||||
shape.setLastY(y);
|
||||
|
||||
return "<" + "line" + " x=\"" + String.valueOf(x) + "\" y=\"" + String.valueOf(y) + "\"/>";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.geometry;
|
||||
|
||||
import com.mxgraph.io.vsdx.Shape;
|
||||
import com.mxgraph.io.vsdx.mxPoint;
|
||||
|
||||
public class RelMoveTo extends Row
|
||||
{
|
||||
|
||||
public RelMoveTo(int index, Double x, Double y)
|
||||
{
|
||||
super(index, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(mxPoint p, Shape shape)
|
||||
{
|
||||
double x = p.getX(), y = p.getY();
|
||||
|
||||
if (this.x != null && this.y != null)
|
||||
{
|
||||
x = this.x * 100;
|
||||
y = 100 - this.y * 100;
|
||||
}
|
||||
|
||||
x = Math.round(x * 100.0) / 100.0;
|
||||
y = Math.round(y * 100.0) / 100.0;
|
||||
|
||||
p.setX(x);
|
||||
p.setY(y);
|
||||
shape.setLastX(x);
|
||||
shape.setLastY(y);
|
||||
shape.setLastMoveX(x);
|
||||
shape.setLastMoveY(y);
|
||||
|
||||
return "<" + "move" + " x=\"" + String.valueOf(x) + "\" y=\"" + String.valueOf(y) + "\"/>";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.geometry;
|
||||
|
||||
import com.mxgraph.io.vsdx.Shape;
|
||||
import com.mxgraph.io.vsdx.mxPoint;
|
||||
|
||||
public class RelQuadBezTo extends Row
|
||||
{
|
||||
public RelQuadBezTo(int index, Double x, Double y, Double a, Double b)
|
||||
{
|
||||
super(index, x, y);
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(mxPoint p, Shape shape)
|
||||
{
|
||||
if (this.x != null && this.y != null && this.a != null && this.b != null)
|
||||
{
|
||||
double x = this.x * 100;
|
||||
double y = 100 - this.y * 100;
|
||||
double x1 = this.a * 100.0;
|
||||
double y1 = 100 - this.b * 100.0;
|
||||
|
||||
x = Math.round(x * 100.0) / 100.0;
|
||||
y = Math.round(y * 100.0) / 100.0;
|
||||
x1 = Math.round(x1 * 100.0) / 100.0;
|
||||
y1 = Math.round(y1 * 100.0) / 100.0;
|
||||
|
||||
shape.setLastX(x);
|
||||
shape.setLastY(y);
|
||||
|
||||
return "<quad x1=\"" + String.valueOf(x1) + "\" y1=\"" + String.valueOf(y1) +
|
||||
"\" x2=\"" + String.valueOf(x) + "\" y2=\"" + String.valueOf(y) + "\"/>";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.geometry;
|
||||
|
||||
import com.mxgraph.io.vsdx.Shape;
|
||||
import com.mxgraph.io.vsdx.mxPoint;
|
||||
|
||||
public abstract class Row
|
||||
{
|
||||
protected Double x, y, a, b, c, d;
|
||||
protected String formulaA, formulaE;
|
||||
protected int index;
|
||||
|
||||
public Row(int index, Double x, Double y)
|
||||
{
|
||||
this.index = index;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
//TODO probably point p is not needed as the point from previous step is stored in lastP?
|
||||
public abstract String handle(mxPoint p, Shape shape);
|
||||
|
||||
public Double getX()
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
public Double getY()
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
public Double getA() {
|
||||
return a;
|
||||
}
|
||||
|
||||
public Double getB() {
|
||||
return b;
|
||||
}
|
||||
|
||||
public Double getC() {
|
||||
return c;
|
||||
}
|
||||
|
||||
public Double getD() {
|
||||
return d;
|
||||
}
|
||||
|
||||
public String getFormulaA() {
|
||||
return formulaA;
|
||||
}
|
||||
|
||||
public String getFormulaE() {
|
||||
return formulaE;
|
||||
}
|
||||
|
||||
public int getIndex()
|
||||
{
|
||||
return index;
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.geometry;
|
||||
|
||||
import com.mxgraph.io.vsdx.Shape;
|
||||
import com.mxgraph.io.vsdx.mxVsdxUtils;
|
||||
import com.mxgraph.io.vsdx.mxPoint;
|
||||
|
||||
public class SplineKnot extends Row
|
||||
{
|
||||
public SplineKnot(int index, Double x, Double y, Double a)
|
||||
{
|
||||
super(index, x, y);
|
||||
this.a = a;
|
||||
}
|
||||
|
||||
//TODO Is this complete?
|
||||
@Override
|
||||
public String handle(mxPoint p, Shape shape)
|
||||
{
|
||||
if (this.x != null && this.y != null && this.a != null)
|
||||
{
|
||||
//double h = this.getHeight();
|
||||
//double w = this.getWidth();
|
||||
double x = this.x * mxVsdxUtils.conversionFactor;
|
||||
double y = this.y * mxVsdxUtils.conversionFactor;
|
||||
double a = this.a;
|
||||
|
||||
double knot = a;
|
||||
// x = x * 100.0 / w;
|
||||
// y = y * 100.0 / h;
|
||||
y = 100 - y;
|
||||
x = Math.round(x * 100.0) / 100.0;
|
||||
y = Math.round(y * 100.0) / 100.0;
|
||||
knot = Math.round(knot * 100.0) / 100.0;
|
||||
|
||||
shape.setLastX(x);
|
||||
shape.setLastY(y);
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.geometry;
|
||||
|
||||
import com.mxgraph.io.vsdx.Shape;
|
||||
import com.mxgraph.io.vsdx.mxVsdxUtils;
|
||||
import com.mxgraph.io.vsdx.mxPoint;
|
||||
|
||||
public class SplineStart extends Row
|
||||
{
|
||||
public SplineStart(int index, Double x, Double y, Double a, Double b, Double c, Double d)
|
||||
{
|
||||
super(index, x, y);
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
this.d = d;
|
||||
}
|
||||
|
||||
//TODO Is this complete?
|
||||
@Override
|
||||
public String handle(mxPoint p, Shape shape)
|
||||
{
|
||||
if (this.x != null && this.y != null && this.a != null && this.b != null && this.c != null && this.d != null)
|
||||
{
|
||||
double h = shape.getHeight();
|
||||
double w = shape.getWidth();
|
||||
|
||||
double x = this.x * mxVsdxUtils.conversionFactor;
|
||||
double y = this.y * mxVsdxUtils.conversionFactor;
|
||||
//double a = Double.parseDouble(aValue);
|
||||
//double b = Double.parseDouble(bValue);
|
||||
double c = this.c;
|
||||
int d = this.d.intValue();
|
||||
|
||||
//double firstKnot = b;
|
||||
//double secondKnot = a;
|
||||
double lastKnot = c;
|
||||
|
||||
shape.setLastKnot(lastKnot);
|
||||
|
||||
int degree = d;
|
||||
// x = x * 100.0 / w;
|
||||
// y = y * 100.0 / h;
|
||||
y = 100 - y;
|
||||
x = Math.round(x * 100.0) / 100.0;
|
||||
y = Math.round(y * 100.0) / 100.0;
|
||||
lastKnot = Math.round(lastKnot * 100.0) / 100.0;
|
||||
double x0 = shape.getLastX() * w / 100.0;
|
||||
double y0 = shape.getLastY() * h / 100.0;
|
||||
|
||||
shape.setLastX(x);
|
||||
shape.setLastY(y);
|
||||
|
||||
return "<curve ";
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,349 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2007, Gaudenz Alder
|
||||
*/
|
||||
package com.mxgraph.io.vsdx;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* Cells are the elements of the graph model. They represent the state
|
||||
* of the groups, vertices and edges in a graph.
|
||||
*
|
||||
* <h4>Edge Labels</h4>
|
||||
*
|
||||
* Using the x- and y-coordinates of a cell's geometry it is
|
||||
* possible to position the label on edges on a specific location
|
||||
* on the actual edge shape as it appears on the screen. The
|
||||
* x-coordinate of an edge's geometry is used to describe the
|
||||
* distance from the center of the edge from -1 to 1 with 0
|
||||
* being the center of the edge and the default value. The
|
||||
* y-coordinate of an edge's geometry is used to describe
|
||||
* the absolute, orthogonal distance in pixels from that
|
||||
* point. In addition, the mxGeometry.offset is used
|
||||
* as a absolute offset vector from the resulting point.
|
||||
*
|
||||
* The width and height of an edge geometry are ignored.
|
||||
*
|
||||
* To add more than one edge label, add a child vertex with
|
||||
* a relative geometry. The x- and y-coordinates of that
|
||||
* geometry will have the same semantiv as the above for
|
||||
* edge labels.
|
||||
*/
|
||||
public class mxCell implements Cloneable, Serializable
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 910211337632342672L;
|
||||
|
||||
/**
|
||||
* Holds the Id. Default is null.
|
||||
*/
|
||||
protected String id;
|
||||
|
||||
/**
|
||||
* Holds the user object. Default is null.
|
||||
*/
|
||||
protected Object value;
|
||||
|
||||
/**
|
||||
* Holds the geometry. Default is null.
|
||||
*/
|
||||
protected mxGeometry geometry;
|
||||
|
||||
/**
|
||||
* Holds the style as a string of the form
|
||||
* stylename[;key=value]. Default is null.
|
||||
*/
|
||||
protected String style;
|
||||
|
||||
/**
|
||||
* Specifies whether the cell is a vertex or edge and whether it is
|
||||
* connectable, visible and collapsed. Default values are false, false,
|
||||
* true, true and false respectively.
|
||||
*/
|
||||
protected boolean vertex = false, edge = false, connectable = true,
|
||||
visible = true, collapsed = false;
|
||||
|
||||
|
||||
/**
|
||||
* Holds the child cells and connected edges.
|
||||
*/
|
||||
protected List<Object> children, edges;
|
||||
|
||||
/**
|
||||
* Constructs a new cell with an empty user object.
|
||||
*/
|
||||
public mxCell()
|
||||
{
|
||||
this(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new cell for the given user object.
|
||||
*
|
||||
* @param value
|
||||
* Object that represents the value of the cell.
|
||||
*/
|
||||
public mxCell(Object value)
|
||||
{
|
||||
this(value, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new cell for the given parameters.
|
||||
*
|
||||
* @param value Object that represents the value of the cell.
|
||||
* @param geometry Specifies the geometry of the cell.
|
||||
* @param style Specifies the style as a formatted string.
|
||||
*/
|
||||
public mxCell(Object value, mxGeometry geometry, String style)
|
||||
{
|
||||
setValue(value);
|
||||
setGeometry(geometry);
|
||||
setStyle(style);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.mxgraph.model.mxICell#getId()
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.mxgraph.model.mxICell#setId(String)
|
||||
*/
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.mxgraph.model.mxICell#getValue()
|
||||
*/
|
||||
public Object getValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.mxgraph.model.mxICell#setValue(Object)
|
||||
*/
|
||||
public void setValue(Object value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.mxgraph.model.mxICell#getGeometry()
|
||||
*/
|
||||
public mxGeometry getGeometry()
|
||||
{
|
||||
return geometry;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.mxgraph.model.mxICell#setGeometry(com.mxgraph.model.mxGeometry)
|
||||
*/
|
||||
public void setGeometry(mxGeometry geometry)
|
||||
{
|
||||
this.geometry = geometry;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.mxgraph.model.mxICell#getStyle()
|
||||
*/
|
||||
public String getStyle()
|
||||
{
|
||||
return style;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.mxgraph.model.mxICell#setStyle(String)
|
||||
*/
|
||||
public void setStyle(String style)
|
||||
{
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.mxgraph.model.mxICell#isVertex()
|
||||
*/
|
||||
public boolean isVertex()
|
||||
{
|
||||
return vertex;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.mxgraph.model.mxICell#setVertex(boolean)
|
||||
*/
|
||||
public void setVertex(boolean vertex)
|
||||
{
|
||||
this.vertex = vertex;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.mxgraph.model.mxICell#isEdge()
|
||||
*/
|
||||
public boolean isEdge()
|
||||
{
|
||||
return edge;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.mxgraph.model.mxICell#setEdge(boolean)
|
||||
*/
|
||||
public void setEdge(boolean edge)
|
||||
{
|
||||
this.edge = edge;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.mxgraph.model.mxICell#isConnectable()
|
||||
*/
|
||||
public boolean isConnectable()
|
||||
{
|
||||
return connectable;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.mxgraph.model.mxICell#setConnectable(boolean)
|
||||
*/
|
||||
public void setConnectable(boolean connectable)
|
||||
{
|
||||
this.connectable = connectable;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.mxgraph.model.mxICell#isVisible()
|
||||
*/
|
||||
public boolean isVisible()
|
||||
{
|
||||
return visible;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.mxgraph.model.mxICell#setVisible(boolean)
|
||||
*/
|
||||
public void setVisible(boolean visible)
|
||||
{
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.mxgraph.model.mxICell#isCollapsed()
|
||||
*/
|
||||
public boolean isCollapsed()
|
||||
{
|
||||
return collapsed;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.mxgraph.model.mxICell#setCollapsed(boolean)
|
||||
*/
|
||||
public void setCollapsed(boolean collapsed)
|
||||
{
|
||||
this.collapsed = collapsed;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.mxgraph.model.mxICell#getChildCount()
|
||||
*/
|
||||
public int getChildCount()
|
||||
{
|
||||
return (children != null) ? children.size() : 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.mxgraph.model.mxICell#getEdgeCount()
|
||||
*/
|
||||
public int getEdgeCount()
|
||||
{
|
||||
return (edges != null) ? edges.size() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the specified attribute from the user object if it is an XML
|
||||
* node.
|
||||
*
|
||||
* @param name Name of the attribute whose value should be returned.
|
||||
* @return Returns the value of the given attribute or null.
|
||||
*/
|
||||
public String getAttribute(String name)
|
||||
{
|
||||
return getAttribute(name, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the specified attribute from the user object if it is an XML
|
||||
* node.
|
||||
*
|
||||
* @param name Name of the attribute whose value should be returned.
|
||||
* @param defaultValue Default value to use if the attribute has no value.
|
||||
* @return Returns the value of the given attribute or defaultValue.
|
||||
*/
|
||||
public String getAttribute(String name, String defaultValue)
|
||||
{
|
||||
Object userObject = getValue();
|
||||
String val = null;
|
||||
|
||||
if (userObject instanceof Element)
|
||||
{
|
||||
Element element = (Element) userObject;
|
||||
val = element.getAttribute(name);
|
||||
}
|
||||
|
||||
if (val == null)
|
||||
{
|
||||
val = defaultValue;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the specified attribute on the user object if it is an XML node.
|
||||
*
|
||||
* @param name Name of the attribute whose value should be set.
|
||||
* @param value New value of the attribute.
|
||||
*/
|
||||
public void setAttribute(String name, String value)
|
||||
{
|
||||
Object userObject = getValue();
|
||||
|
||||
if (userObject instanceof Element)
|
||||
{
|
||||
Element element = (Element) userObject;
|
||||
element.setAttribute(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of the user object. This implementation clones any XML
|
||||
* nodes or otherwise returns the same user object instance.
|
||||
*/
|
||||
protected Object cloneValue()
|
||||
{
|
||||
Object value = getValue();
|
||||
|
||||
if (value instanceof Node)
|
||||
{
|
||||
value = ((Node) value).cloneNode(true);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public mxCell getChildAt(int i) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,371 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2007, Gaudenz Alder
|
||||
*/
|
||||
package com.mxgraph.io.vsdx;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Represents the geometry of a cell. For vertices, the geometry consists
|
||||
* of the x- and y-location, as well as the width and height. For edges,
|
||||
* the geometry either defines the source- and target-terminal, or it
|
||||
* defines the respective terminal points.
|
||||
*
|
||||
* For edges, if the geometry is relative (default), then the x-coordinate
|
||||
* is used to describe the distance from the center of the edge from -1 to 1
|
||||
* with 0 being the center of the edge and the default value, and the
|
||||
* y-coordinate is used to describe the absolute, orthogonal distance in
|
||||
* pixels from that point. In addition, the offset is used as an absolute
|
||||
* offset vector from the resulting point.
|
||||
*/
|
||||
public class mxGeometry extends mxRectangle
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 2649828026610336589L;
|
||||
|
||||
/**
|
||||
* Global switch to translate the points in translate. Default is true.
|
||||
*/
|
||||
public static transient boolean TRANSLATE_CONTROL_POINTS = true;
|
||||
|
||||
/**
|
||||
* Stores alternate values for x, y, width and height in a rectangle.
|
||||
* Default is null.
|
||||
*/
|
||||
protected mxRectangle alternateBounds;
|
||||
|
||||
/**
|
||||
* Defines the source- and target-point of the edge. This is used if the
|
||||
* corresponding edge does not have a source vertex. Otherwise it is
|
||||
* ignored. Default is null.
|
||||
*/
|
||||
protected mxPoint sourcePoint, targetPoint;
|
||||
|
||||
/**
|
||||
* List of mxPoints which specifies the control points along the edge.
|
||||
* These points are the intermediate points on the edge, for the endpoints
|
||||
* use targetPoint and sourcePoint or set the terminals of the edge to
|
||||
* a non-null value. Default is null.
|
||||
*/
|
||||
protected List<mxPoint> points;
|
||||
|
||||
/**
|
||||
* Holds the offset of the label for edges. This is the absolute vector
|
||||
* between the center of the edge and the top, left point of the label.
|
||||
* Default is null.
|
||||
*/
|
||||
protected mxPoint offset;
|
||||
|
||||
/**
|
||||
* Specifies if the coordinates in the geometry are to be interpreted as
|
||||
* relative coordinates. Default is false. This is used to mark a geometry
|
||||
* with an x- and y-coordinate that is used to describe an edge label
|
||||
* position, or a relative location with respect to a parent cell's
|
||||
* width and height.
|
||||
*/
|
||||
protected boolean relative = false;
|
||||
|
||||
/**
|
||||
* Constructs a new geometry at (0, 0) with the width and height set to 0.
|
||||
*/
|
||||
public mxGeometry()
|
||||
{
|
||||
this(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a geometry using the given parameters.
|
||||
*
|
||||
* @param x X-coordinate of the new geometry.
|
||||
* @param y Y-coordinate of the new geometry.
|
||||
* @param width Width of the new geometry.
|
||||
* @param height Height of the new geometry.
|
||||
*/
|
||||
public mxGeometry(double x, double y, double width, double height)
|
||||
{
|
||||
super(x, y, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the alternate bounds.
|
||||
*/
|
||||
public mxRectangle getAlternateBounds()
|
||||
{
|
||||
return alternateBounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the alternate bounds to the given rectangle.
|
||||
*
|
||||
* @param rect Rectangle to be used for the alternate bounds.
|
||||
*/
|
||||
public void setAlternateBounds(mxRectangle rect)
|
||||
{
|
||||
alternateBounds = rect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the source point.
|
||||
*
|
||||
* @return Returns the source point.
|
||||
*/
|
||||
public mxPoint getSourcePoint()
|
||||
{
|
||||
return sourcePoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source point.
|
||||
*
|
||||
* @param sourcePoint Source point to be used.
|
||||
*/
|
||||
public void setSourcePoint(mxPoint sourcePoint)
|
||||
{
|
||||
this.sourcePoint = sourcePoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the target point.
|
||||
*
|
||||
* @return Returns the target point.
|
||||
*/
|
||||
public mxPoint getTargetPoint()
|
||||
{
|
||||
return targetPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the target point.
|
||||
*
|
||||
* @param targetPoint Target point to be used.
|
||||
*/
|
||||
public void setTargetPoint(mxPoint targetPoint)
|
||||
{
|
||||
this.targetPoint = targetPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of control points.
|
||||
*/
|
||||
public List<mxPoint> getPoints()
|
||||
{
|
||||
return points;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list of control points to the given list.
|
||||
*
|
||||
* @param value List that contains the new control points.
|
||||
*/
|
||||
public void setPoints(List<mxPoint> value)
|
||||
{
|
||||
points = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the offset.
|
||||
*/
|
||||
public mxPoint getOffset()
|
||||
{
|
||||
return offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the offset to the given point.
|
||||
*
|
||||
* @param offset Point to be used for the offset.
|
||||
*/
|
||||
public void setOffset(mxPoint offset)
|
||||
{
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true of the geometry is relative.
|
||||
*/
|
||||
public boolean isRelative()
|
||||
{
|
||||
return relative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the relative state of the geometry.
|
||||
*
|
||||
* @param value Boolean value to be used as the new relative state.
|
||||
*/
|
||||
public void setRelative(boolean value)
|
||||
{
|
||||
relative = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps the x, y, width and height with the values stored in
|
||||
* alternateBounds and puts the previous values into alternateBounds as
|
||||
* a rectangle. This operation is carried-out in-place, that is, using the
|
||||
* existing geometry instance. If this operation is called during a graph
|
||||
* model transactional change, then the geometry should be cloned before
|
||||
* calling this method and setting the geometry of the cell using
|
||||
* mxGraphModel.setGeometry.
|
||||
*/
|
||||
public void swap()
|
||||
{
|
||||
if (alternateBounds != null)
|
||||
{
|
||||
mxRectangle old = new mxRectangle(getX(), getY(), getWidth(),
|
||||
getHeight());
|
||||
|
||||
x = alternateBounds.getX();
|
||||
y = alternateBounds.getY();
|
||||
width = alternateBounds.getWidth();
|
||||
height = alternateBounds.getHeight();
|
||||
|
||||
alternateBounds = old;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the point representing the source or target point of this edge.
|
||||
* This is only used if the edge has no source or target vertex.
|
||||
*
|
||||
* @param isSource Boolean that specifies if the source or target point
|
||||
* should be returned.
|
||||
* @return Returns the source or target point.
|
||||
*/
|
||||
public mxPoint getTerminalPoint(boolean isSource)
|
||||
{
|
||||
return (isSource) ? sourcePoint : targetPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sourcePoint or targetPoint to the given point and returns the
|
||||
* new point.
|
||||
*
|
||||
* @param point Point to be used as the new source or target point.
|
||||
* @param isSource Boolean that specifies if the source or target point
|
||||
* should be set.
|
||||
* @return Returns the new point.
|
||||
*/
|
||||
public mxPoint setTerminalPoint(mxPoint point, boolean isSource)
|
||||
{
|
||||
if (isSource)
|
||||
{
|
||||
sourcePoint = point;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetPoint = point;
|
||||
}
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the geometry by the specified amount. That is, x and y of the
|
||||
* geometry, the sourcePoint, targetPoint and all elements of points are
|
||||
* translated by the given amount. X and y are only translated if the
|
||||
* geometry is not relative. If TRANSLATE_CONTROL_POINTS is false, then
|
||||
* are not modified by this function.
|
||||
*
|
||||
* @param dx Integer that specifies the x-coordinate of the translation.
|
||||
* @param dy Integer that specifies the y-coordinate of the translation.
|
||||
*/
|
||||
public void translate(double dx, double dy)
|
||||
{
|
||||
// Translates the geometry
|
||||
if (!isRelative())
|
||||
{
|
||||
x += dx;
|
||||
y += dy;
|
||||
}
|
||||
|
||||
// Translates the source point
|
||||
if (sourcePoint != null)
|
||||
{
|
||||
sourcePoint.setX(sourcePoint.getX() + dx);
|
||||
sourcePoint.setY(sourcePoint.getY() + dy);
|
||||
}
|
||||
|
||||
// Translates the target point
|
||||
if (targetPoint != null)
|
||||
{
|
||||
targetPoint.setX(targetPoint.getX() + dx);
|
||||
targetPoint.setY(targetPoint.getY() + dy);
|
||||
}
|
||||
|
||||
// Translate the control points
|
||||
if (TRANSLATE_CONTROL_POINTS && points != null)
|
||||
{
|
||||
int count = points.size();
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
mxPoint pt = points.get(i);
|
||||
|
||||
pt.setX(pt.getX() + dx);
|
||||
pt.setY(pt.getY() + dy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of the cell.
|
||||
*/
|
||||
public Object clone()
|
||||
{
|
||||
mxGeometry clone = (mxGeometry) super.clone();
|
||||
|
||||
clone.setX(getX());
|
||||
clone.setY(getY());
|
||||
clone.setWidth(getWidth());
|
||||
clone.setHeight(getHeight());
|
||||
clone.setRelative(isRelative());
|
||||
|
||||
List<mxPoint> pts = getPoints();
|
||||
|
||||
if (pts != null)
|
||||
{
|
||||
clone.points = new ArrayList<mxPoint>(pts.size());
|
||||
|
||||
for (int i = 0; i < pts.size(); i++)
|
||||
{
|
||||
clone.points.add((mxPoint) pts.get(i).clone());
|
||||
}
|
||||
}
|
||||
|
||||
mxPoint tp = getTargetPoint();
|
||||
|
||||
if (tp != null)
|
||||
{
|
||||
clone.setTargetPoint((mxPoint) tp.clone());
|
||||
}
|
||||
|
||||
mxPoint sp = getSourcePoint();
|
||||
|
||||
if (sp != null)
|
||||
{
|
||||
setSourcePoint((mxPoint) sp.clone());
|
||||
}
|
||||
|
||||
mxPoint off = getOffset();
|
||||
|
||||
if (off != null)
|
||||
{
|
||||
clone.setOffset((mxPoint) off.clone());
|
||||
}
|
||||
|
||||
mxRectangle alt = getAlternateBounds();
|
||||
|
||||
if (alt != null)
|
||||
{
|
||||
setAlternateBounds((mxRectangle) alt.clone());
|
||||
}
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,138 +0,0 @@
|
|||
package com.mxgraph.io.vsdx;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Implements a 2-dimensional point with double precision coordinates.
|
||||
*/
|
||||
public class mxPoint implements Serializable, Cloneable
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6554231393215892186L;
|
||||
|
||||
/**
|
||||
* Holds the x- and y-coordinates of the point. Default is 0.
|
||||
*/
|
||||
protected double x, y;
|
||||
|
||||
/**
|
||||
* Constructs a new point at (0, 0).
|
||||
*/
|
||||
public mxPoint()
|
||||
{
|
||||
this(0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new point at the location of the given point.
|
||||
*
|
||||
* @param point Point that specifies the location.
|
||||
*/
|
||||
public mxPoint(mxPoint point)
|
||||
{
|
||||
this(point.getX(), point.getY());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new point at (x, y).
|
||||
*
|
||||
* @param x X-coordinate of the point to be created.
|
||||
* @param y Y-coordinate of the point to be created.
|
||||
*/
|
||||
public mxPoint(double x, double y)
|
||||
{
|
||||
setX(x);
|
||||
setY(y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the x-coordinate of the point.
|
||||
*
|
||||
* @return Returns the x-coordinate.
|
||||
*/
|
||||
public double getX()
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the x-coordinate of the point.
|
||||
*
|
||||
* @param value Double that specifies the new x-coordinate.
|
||||
*/
|
||||
public void setX(double value)
|
||||
{
|
||||
x = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the x-coordinate of the point.
|
||||
*
|
||||
* @return Returns the x-coordinate.
|
||||
*/
|
||||
public double getY()
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the y-coordinate of the point.
|
||||
*
|
||||
* @param value Double that specifies the new x-coordinate.
|
||||
*/
|
||||
public void setY(double value)
|
||||
{
|
||||
y = value;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns true if the given object equals this rectangle.
|
||||
*/
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj instanceof mxPoint)
|
||||
{
|
||||
mxPoint pt = (mxPoint) obj;
|
||||
|
||||
return pt.getX() == getX() && pt.getY() == getY();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of the same point.
|
||||
*/
|
||||
public Object clone()
|
||||
{
|
||||
mxPoint clone;
|
||||
|
||||
try
|
||||
{
|
||||
clone = (mxPoint) super.clone();
|
||||
}
|
||||
catch (CloneNotSupportedException e)
|
||||
{
|
||||
clone = new mxPoint();
|
||||
}
|
||||
|
||||
clone.setX(getX());
|
||||
clone.setY(getY());
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a <code>String</code> that represents the value
|
||||
* of this <code>mxPoint</code>.
|
||||
* @return a string representation of this <code>mxPoint</code>.
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return getClass().getName() + "[" + x + ", " + y + "]";
|
||||
}
|
||||
}
|
|
@ -1,250 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2007-2010, Gaudenz Alder, David Benson
|
||||
*/
|
||||
package com.mxgraph.io.vsdx;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
/**
|
||||
* Implements a 2-dimensional rectangle with double precision coordinates.
|
||||
*/
|
||||
public class mxRectangle extends mxPoint
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3793966043543578946L;
|
||||
|
||||
/**
|
||||
* Holds the width and the height. Default is 0.
|
||||
*/
|
||||
protected double width, height;
|
||||
|
||||
/**
|
||||
* Constructs a new rectangle at (0, 0) with the width and height set to 0.
|
||||
*/
|
||||
public mxRectangle()
|
||||
{
|
||||
this(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a copy of the given rectangle.
|
||||
*
|
||||
* @param rect Rectangle to construct a copy of.
|
||||
*/
|
||||
public mxRectangle(Rectangle2D rect)
|
||||
{
|
||||
this(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a copy of the given rectangle.
|
||||
*
|
||||
* @param rect Rectangle to construct a copy of.
|
||||
*/
|
||||
public mxRectangle(mxRectangle rect)
|
||||
{
|
||||
this(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a rectangle using the given parameters.
|
||||
*
|
||||
* @param x X-coordinate of the new rectangle.
|
||||
* @param y Y-coordinate of the new rectangle.
|
||||
* @param width Width of the new rectangle.
|
||||
* @param height Height of the new rectangle.
|
||||
*/
|
||||
public mxRectangle(double x, double y, double width, double height)
|
||||
{
|
||||
super(x, y);
|
||||
|
||||
setWidth(width);
|
||||
setHeight(height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width of the rectangle.
|
||||
*
|
||||
* @return Returns the width.
|
||||
*/
|
||||
public double getWidth()
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the width of the rectangle.
|
||||
*
|
||||
* @param value Double that specifies the new width.
|
||||
*/
|
||||
public void setWidth(double value)
|
||||
{
|
||||
width = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the height of the rectangle.
|
||||
*
|
||||
* @return Returns the height.
|
||||
*/
|
||||
public double getHeight()
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the height of the rectangle.
|
||||
*
|
||||
* @param value Double that specifies the new height.
|
||||
*/
|
||||
public void setHeight(double value)
|
||||
{
|
||||
height = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this rectangle to the specified values
|
||||
*
|
||||
* @param x the new x-axis position
|
||||
* @param y the new y-axis position
|
||||
* @param w the new width of the rectangle
|
||||
* @param h the new height of the rectangle
|
||||
*/
|
||||
public void setRect(double x, double y, double w, double h)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given rectangle to this rectangle.
|
||||
*/
|
||||
public void add(mxRectangle rect)
|
||||
{
|
||||
if (rect != null)
|
||||
{
|
||||
double minX = Math.min(x, rect.x);
|
||||
double minY = Math.min(y, rect.y);
|
||||
double maxX = Math.max(x + width, rect.x + rect.width);
|
||||
double maxY = Math.max(y + height, rect.y + rect.height);
|
||||
|
||||
x = minX;
|
||||
y = minY;
|
||||
width = maxX - minX;
|
||||
height = maxY - minY;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the x-coordinate of the center.
|
||||
*
|
||||
* @return Returns the x-coordinate of the center.
|
||||
*/
|
||||
public double getCenterX()
|
||||
{
|
||||
return getX() + getWidth() / 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the y-coordinate of the center.
|
||||
*
|
||||
* @return Returns the y-coordinate of the center.
|
||||
*/
|
||||
public double getCenterY()
|
||||
{
|
||||
return getY() + getHeight() / 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Grows the rectangle by the given amount, that is, this method subtracts
|
||||
* the given amount from the x- and y-coordinates and adds twice the amount
|
||||
* to the width and height.
|
||||
*
|
||||
* @param amount Amount by which the rectangle should be grown.
|
||||
*/
|
||||
public void grow(double amount)
|
||||
{
|
||||
x -= amount;
|
||||
y -= amount;
|
||||
width += 2 * amount;
|
||||
height += 2 * amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given point is contained in the rectangle.
|
||||
*
|
||||
* @param x X-coordinate of the point.
|
||||
* @param y Y-coordinate of the point.
|
||||
* @return Returns true if the point is contained in the rectangle.
|
||||
*/
|
||||
public boolean contains(double x, double y)
|
||||
{
|
||||
return (this.x <= x && this.x + width >= x && this.y <= y && this.y
|
||||
+ height >= y);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the bounds as a new rectangle.
|
||||
*
|
||||
* @return Returns a new rectangle for the bounds.
|
||||
*/
|
||||
public Rectangle getRectangle()
|
||||
{
|
||||
int ix = (int) Math.round(x);
|
||||
int iy = (int) Math.round(y);
|
||||
int iw = (int) Math.round(width - ix + x);
|
||||
int ih = (int) Math.round(height - iy + y);
|
||||
|
||||
return new Rectangle(ix, iy, iw, ih);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns true if the given object equals this rectangle.
|
||||
*/
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj instanceof mxRectangle)
|
||||
{
|
||||
mxRectangle rect = (mxRectangle) obj;
|
||||
|
||||
return rect.getX() == getX() && rect.getY() == getY()
|
||||
&& rect.getWidth() == getWidth()
|
||||
&& rect.getHeight() == getHeight();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of the same rectangle.
|
||||
*/
|
||||
public Object clone()
|
||||
{
|
||||
mxRectangle clone = (mxRectangle) super.clone();
|
||||
|
||||
clone.setWidth(getWidth());
|
||||
clone.setHeight(getHeight());
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <code>String</code> representation of this
|
||||
* <code>mxRectangle</code>.
|
||||
* @return a <code>String</code> representing this
|
||||
* <code>mxRectangle</code>.
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return getClass().getName() + "[x=" + x + ",y=" + y + ",w=" + width
|
||||
+ ",h=" + height + "]";
|
||||
}
|
||||
}
|
|
@ -1,181 +0,0 @@
|
|||
package com.mxgraph.io.vsdx;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import com.mxgraph.io.vsdx.geometry.Row;
|
||||
import com.mxgraph.io.vsdx.geometry.RowFactory;
|
||||
|
||||
public class mxVsdxGeometry {
|
||||
private int index;
|
||||
|
||||
private boolean noFill = false, noLine = false, noShow = false, noSnap = false, noQuickDrag = false;
|
||||
|
||||
private ArrayList<Row> rows = null;
|
||||
|
||||
private int getIndex(Element elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Integer.parseInt(elem.getAttribute("IX"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//Some non-standard visio file omit the index when it is zero
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public mxVsdxGeometry(Element elem)
|
||||
{
|
||||
index = getIndex(elem);
|
||||
processGeoElem(elem);
|
||||
}
|
||||
|
||||
public mxVsdxGeometry(Element elem, List<mxVsdxGeometry> parentGeo)
|
||||
{
|
||||
index = getIndex(elem);
|
||||
if (parentGeo != null && index < parentGeo.size())
|
||||
{
|
||||
//inherit all parent values including
|
||||
this.inheritGeo(parentGeo.get(index));
|
||||
}
|
||||
processGeoElem(elem);
|
||||
}
|
||||
|
||||
private void processGeoElem(Element elem)
|
||||
{
|
||||
ArrayList<Element> cellElems = mxVsdxUtils.getDirectChildNamedElements(elem, "Cell");
|
||||
ArrayList<Element> rowElems = mxVsdxUtils.getDirectChildNamedElements(elem, "Row");
|
||||
|
||||
if (rows == null)
|
||||
{
|
||||
rows = new ArrayList<>(rowElems.size());
|
||||
|
||||
//set the list size to row size
|
||||
for (int i = 0; i < rowElems.size(); i++)
|
||||
{
|
||||
rows.add(null);
|
||||
}
|
||||
}
|
||||
|
||||
for (Element cellElem : cellElems)
|
||||
{
|
||||
String name = cellElem.getAttribute("N");
|
||||
String val = cellElem.getAttribute("V");
|
||||
switch (name)
|
||||
{
|
||||
case "NoFill":
|
||||
noFill = "1".equals(val);
|
||||
break;
|
||||
case "NoLine":
|
||||
noLine = "1".equals(val);
|
||||
break;
|
||||
case "NoShow":
|
||||
noShow = "1".equals(val);
|
||||
break;
|
||||
case "NoSnap":
|
||||
noSnap = "1".equals(val);
|
||||
break;
|
||||
case "NoQuickDrag":
|
||||
noQuickDrag = "1".equals(val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int rowsLen = rows.size();
|
||||
boolean sortNeeded = false;
|
||||
|
||||
for (Element rowElem : rowElems)
|
||||
{
|
||||
Row row = RowFactory.getRowObj(rowElem, rows);
|
||||
|
||||
//this can happen when child geo has more rows than parent
|
||||
if (row.getIndex() > rowsLen)
|
||||
{
|
||||
rows.add(row);
|
||||
sortNeeded = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
rows.set(row.getIndex() - 1, row);
|
||||
}
|
||||
}
|
||||
|
||||
if (sortNeeded)
|
||||
{
|
||||
Collections.sort(rows, new Comparator<Row>()
|
||||
{
|
||||
@Override
|
||||
public int compare(Row r1, Row r2)
|
||||
{
|
||||
return r1.getIndex() - r2.getIndex();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void inheritGeo(mxVsdxGeometry parent)
|
||||
{
|
||||
this.noFill = parent.noFill;
|
||||
this.noLine = parent.noLine;
|
||||
this.noShow = parent.noShow;
|
||||
this.noSnap = parent.noSnap;
|
||||
this.noQuickDrag = parent.noQuickDrag;
|
||||
rows = new ArrayList<>();
|
||||
this.rows.addAll(parent.rows);
|
||||
}
|
||||
|
||||
public int getIndex()
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
public boolean isNoFill()
|
||||
{
|
||||
return noFill;
|
||||
}
|
||||
|
||||
public boolean isNoLine()
|
||||
{
|
||||
return noLine;
|
||||
}
|
||||
|
||||
public boolean isNoShow()
|
||||
{
|
||||
return noShow;
|
||||
}
|
||||
|
||||
public boolean isNoSnap()
|
||||
{
|
||||
return noSnap;
|
||||
}
|
||||
|
||||
public boolean isNoQuickDrag()
|
||||
{
|
||||
return noQuickDrag;
|
||||
}
|
||||
|
||||
public ArrayList<Row> getRows()
|
||||
{
|
||||
return rows;
|
||||
}
|
||||
|
||||
public String getPathXML(mxPoint p, Shape shape)
|
||||
{
|
||||
if (noShow) return "";
|
||||
|
||||
StringBuilder geomElemParsed = new StringBuilder();
|
||||
|
||||
for (Row row : rows)
|
||||
{
|
||||
geomElemParsed.append(row.handle(p, shape));
|
||||
}
|
||||
|
||||
return geomElemParsed.toString();
|
||||
}
|
||||
}
|
|
@ -1,260 +0,0 @@
|
|||
package com.mxgraph.io.vsdx;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import com.mxgraph.io.vsdx.geometry.LineTo;
|
||||
import com.mxgraph.io.vsdx.geometry.MoveTo;
|
||||
import com.mxgraph.io.vsdx.geometry.Row;
|
||||
|
||||
public class mxVsdxGeometryList
|
||||
{
|
||||
private List<mxVsdxGeometry> geomList = new ArrayList<>();
|
||||
private List<mxVsdxGeometry> parentGeomList = null;
|
||||
private boolean sortNeeded = false;
|
||||
|
||||
public mxVsdxGeometryList(mxVsdxGeometryList parentGeoList)
|
||||
{
|
||||
if (parentGeoList != null)
|
||||
{
|
||||
parentGeomList = parentGeoList.geomList;
|
||||
geomList.addAll(parentGeoList.geomList);
|
||||
}
|
||||
}
|
||||
|
||||
public void addGeometry(Element geoElem)
|
||||
{
|
||||
mxVsdxGeometry geo = new mxVsdxGeometry(geoElem, parentGeomList);
|
||||
|
||||
if (geo.getIndex() < geomList.size())
|
||||
{
|
||||
geomList.set(geo.getIndex(), geo);
|
||||
}
|
||||
else
|
||||
{
|
||||
geomList.add(geo);
|
||||
sortNeeded = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void sort()
|
||||
{
|
||||
if (sortNeeded)
|
||||
{
|
||||
Collections.sort(geomList, new Comparator<mxVsdxGeometry>()
|
||||
{
|
||||
@Override
|
||||
public int compare(mxVsdxGeometry g1, mxVsdxGeometry g2) {
|
||||
return g1.getIndex() - g2.getIndex();
|
||||
}
|
||||
});
|
||||
sortNeeded = false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isNoShow()
|
||||
{
|
||||
for (mxVsdxGeometry geo : geomList)
|
||||
{
|
||||
if (!geo.isNoShow()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isNoFill()
|
||||
{
|
||||
for (mxVsdxGeometry geo : geomList)
|
||||
{
|
||||
if (!(geo.isNoShow() || geo.isNoFill())) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isNoLine()
|
||||
{
|
||||
for (mxVsdxGeometry geo : geomList)
|
||||
{
|
||||
if (!(geo.isNoShow() || geo.isNoLine())) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasGeom()
|
||||
{
|
||||
return !geomList.isEmpty();
|
||||
}
|
||||
|
||||
private void rotatedPoint(mxPoint pt, double cos, double sin)
|
||||
{
|
||||
double x1 = pt.getX() * cos - pt.getY() * sin;
|
||||
double y1 = pt.getY() * cos + pt.getX() * sin;
|
||||
|
||||
pt.setX(x1);
|
||||
pt.setY(y1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of routing points of a edge shape.
|
||||
* @param parentHeight Height of the parent of the shape.
|
||||
* @return List of mxPoint that represents the routing points.
|
||||
*/
|
||||
public List<mxPoint> getRoutingPoints(double parentHeight, mxPoint startPoint, double rotation)
|
||||
{
|
||||
sort();
|
||||
|
||||
List<mxPoint> points = new ArrayList<mxPoint>();
|
||||
|
||||
//Adding the starting point as a routing point instead of setting the entryX/Y
|
||||
points.add(new mxPoint(startPoint));
|
||||
|
||||
double offsetX = 0;
|
||||
double offsetY = 0;
|
||||
|
||||
for (mxVsdxGeometry geo : geomList)
|
||||
{
|
||||
if (!geo.isNoShow())
|
||||
{
|
||||
ArrayList<Row> rows = geo.getRows();
|
||||
|
||||
for (Row row : rows)
|
||||
{
|
||||
if (row instanceof MoveTo)
|
||||
{
|
||||
offsetX = row.getX() != null? row.getX() : 0;
|
||||
offsetY = row.getY() != null? row.getY() : 0;
|
||||
}
|
||||
else if (row instanceof LineTo)
|
||||
{
|
||||
|
||||
double x = row.getX() != null? row.getX() : 0, y = row.getY() != null? row.getY() : 0;
|
||||
|
||||
mxPoint p = new mxPoint(x, y);
|
||||
if (rotation != 0)
|
||||
{
|
||||
rotation = Math.toRadians(360 - rotation);
|
||||
rotatedPoint(p, Math.cos(rotation), Math.sin(rotation));
|
||||
}
|
||||
|
||||
x = (p.getX() - offsetX) * mxVsdxUtils.conversionFactor;
|
||||
x += startPoint.getX();
|
||||
|
||||
y = ((p.getY() - offsetY) * mxVsdxUtils.conversionFactor) * -1;
|
||||
y += startPoint.getY();
|
||||
|
||||
x = Math.round(x * 100.0) / 100.0;
|
||||
y = Math.round(y * 100.0) / 100.0;
|
||||
|
||||
p.setX(x);
|
||||
p.setY(y);
|
||||
points.add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
public String getShapeXML(Shape shape)
|
||||
{
|
||||
mxPoint p = new mxPoint(0, 0);
|
||||
|
||||
StringBuilder parsedGeom = new StringBuilder("<shape strokewidth=\"inherit\"><foreground>");
|
||||
int initSize = parsedGeom.length();
|
||||
|
||||
int lastGeoStyle = -1;
|
||||
|
||||
//first all geo with fill then without
|
||||
lastGeoStyle = processGeo(shape, p, parsedGeom, lastGeoStyle, true);
|
||||
|
||||
lastGeoStyle = processGeo(shape, p, parsedGeom, lastGeoStyle, false);
|
||||
|
||||
if (parsedGeom.length() == initSize)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
closePath(parsedGeom, lastGeoStyle);
|
||||
}
|
||||
|
||||
//System.out.println(parsedGeom);
|
||||
|
||||
parsedGeom.append("</foreground></shape>");
|
||||
return parsedGeom.toString();
|
||||
}
|
||||
|
||||
private int processGeo(Shape shape, mxPoint p, StringBuilder parsedGeom, int lastGeoStyle, boolean withFill) {
|
||||
for (mxVsdxGeometry geo : geomList)
|
||||
{
|
||||
|
||||
if (withFill == geo.isNoFill()) continue;
|
||||
|
||||
String str = geo.getPathXML(p, shape);
|
||||
|
||||
if (!str.isEmpty())
|
||||
{
|
||||
int geoStyle = getGeoStyle(geo);
|
||||
|
||||
if (lastGeoStyle == -1) //first one
|
||||
{
|
||||
parsedGeom.append("<path>");
|
||||
parsedGeom.append(str);
|
||||
}
|
||||
else if (lastGeoStyle != geoStyle)
|
||||
{
|
||||
closePath(parsedGeom, lastGeoStyle);
|
||||
parsedGeom.append("<path>");
|
||||
parsedGeom.append(str);
|
||||
}
|
||||
else
|
||||
{
|
||||
//parsedGeom.append("<close/>");
|
||||
parsedGeom.append(str);
|
||||
}
|
||||
lastGeoStyle = geoStyle;
|
||||
}
|
||||
}
|
||||
return lastGeoStyle;
|
||||
}
|
||||
|
||||
private int getGeoStyle(mxVsdxGeometry geo)
|
||||
{
|
||||
int geoStyle = 0;
|
||||
if (!geo.isNoLine() && !geo.isNoFill())
|
||||
{
|
||||
geoStyle = 1;
|
||||
}
|
||||
else if (!geo.isNoFill())
|
||||
{
|
||||
geoStyle = 2;
|
||||
}
|
||||
else if (!geo.isNoLine())
|
||||
{
|
||||
geoStyle = 3;
|
||||
}
|
||||
return geoStyle;
|
||||
}
|
||||
|
||||
private void closePath(StringBuilder parsedGeom, int geoStyle)
|
||||
{
|
||||
parsedGeom.append("</path>");
|
||||
if (geoStyle == 1)
|
||||
{
|
||||
parsedGeom.append("<fillstroke/>");
|
||||
}
|
||||
else if (geoStyle == 2)
|
||||
{
|
||||
parsedGeom.append("<fill/>");
|
||||
}
|
||||
else if (geoStyle == 3)
|
||||
{
|
||||
parsedGeom.append("<stroke/>");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,413 +0,0 @@
|
|||
package com.mxgraph.io.vsdx;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import com.mxgraph.io.mxVsdxCodec;
|
||||
|
||||
public class mxVsdxPage {
|
||||
|
||||
/**
|
||||
* Unique ID of the element within its parent element
|
||||
*/
|
||||
protected Integer Id = null;
|
||||
|
||||
/**
|
||||
* Name of the page taken from the "name" attribute of the page element
|
||||
*/
|
||||
protected String pageName = null;
|
||||
|
||||
protected boolean isBackground = false;
|
||||
|
||||
protected Integer backPageId = null;
|
||||
|
||||
protected mxVsdxPage backPage = null;
|
||||
|
||||
protected Element pageElement = null;
|
||||
|
||||
protected Element pageSheet = null;
|
||||
|
||||
protected mxVsdxModel model = null;
|
||||
|
||||
protected Map<Integer, VsdxShape> shapes = new LinkedHashMap<Integer, VsdxShape>();
|
||||
|
||||
protected Map<Integer, mxVsdxConnect> connects = new LinkedHashMap<Integer, mxVsdxConnect>();
|
||||
|
||||
// cell in the PageSheet
|
||||
protected Map<String, Element> cellElements = new HashMap<String, Element>();
|
||||
|
||||
public mxVsdxPage(Element pageElem, mxVsdxModel model) {
|
||||
this.model = model;
|
||||
this.pageElement = pageElem;
|
||||
|
||||
String backGround = pageElem.getAttribute(mxVsdxConstants.BACKGROUND);
|
||||
this.isBackground = (backGround != null && backGround.equals(mxVsdxConstants.TRUE)) ? true : false;
|
||||
String back = pageElem.getAttribute(mxVsdxConstants.BACK_PAGE);
|
||||
|
||||
if (!isBackground && back != null && back.length() > 0)
|
||||
{
|
||||
this.backPageId = Integer.valueOf(back);
|
||||
}
|
||||
|
||||
this.Id = Integer.valueOf(pageElem.getAttribute(mxVsdxConstants.ID));
|
||||
this.pageName = pageElem.getAttribute(mxVsdxConstants.NAME);
|
||||
|
||||
ArrayList<Element> pageSheets = mxVsdxUtils.getDirectChildNamedElements(pageElem, "PageSheet");
|
||||
|
||||
if (pageSheets.size() > 0)
|
||||
{
|
||||
Element pageSheet = pageSheets.get(0);
|
||||
ArrayList<Element> cells = mxVsdxUtils.getDirectChildNamedElements(pageSheet, "Cell");
|
||||
|
||||
for (Element cellElem : cells)
|
||||
{
|
||||
String n = cellElem.getAttribute("N");
|
||||
this.cellElements.put(n, cellElem);
|
||||
}
|
||||
}
|
||||
|
||||
parseNodes(pageElem, model, "pages");
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the child nodes of the given element
|
||||
* @param pageElem the parent whose children to parse
|
||||
* @param model the model of the vsdx file
|
||||
* @param pageName page information is split across pages.xml and pageX.xml where X is any number. We have to know which we're currently parsing to use the correct relationships file.
|
||||
*/
|
||||
protected void parseNodes(Node pageElem, mxVsdxModel model, String pageName)
|
||||
{
|
||||
Node pageChild = pageElem.getFirstChild();
|
||||
|
||||
while (pageChild != null)
|
||||
{
|
||||
if (pageChild instanceof Element)
|
||||
{
|
||||
Element pageChildElem = (Element) pageChild;
|
||||
String childName = pageChildElem.getNodeName();
|
||||
|
||||
if (childName.equals("Rel"))
|
||||
{
|
||||
resolveRel(pageChildElem, model, pageName);
|
||||
}
|
||||
else if (childName.equals("Shapes"))
|
||||
{
|
||||
this.shapes = parseShapes(pageChildElem, null, false);
|
||||
}
|
||||
else if (childName.equals("Connects"))
|
||||
{
|
||||
NodeList connectList = pageChildElem.getElementsByTagName(mxVsdxConstants.CONNECT);
|
||||
Node connectNode = (connectList != null && connectList.getLength() > 0) ? connectList.item(0) : null;
|
||||
//mxVdxConnect currentConnect = null;
|
||||
|
||||
while (connectNode != null)
|
||||
{
|
||||
if (connectNode instanceof Element)
|
||||
{
|
||||
Element connectElem = (Element) connectNode;
|
||||
mxVsdxConnect connect = new mxVsdxConnect(connectElem);
|
||||
Integer fromSheet = connect.getFromSheet();
|
||||
mxVsdxConnect previousConnect = (fromSheet != null && fromSheet > -1) ? connects.get(fromSheet) : null;
|
||||
|
||||
if (previousConnect != null)
|
||||
{
|
||||
previousConnect.addConnect(connectElem);
|
||||
}
|
||||
else
|
||||
{
|
||||
connects.put(connect.getFromSheet(), connect);
|
||||
}
|
||||
}
|
||||
|
||||
connectNode = connectNode.getNextSibling();
|
||||
}
|
||||
}
|
||||
else if (childName.equals("PageSheet"))
|
||||
{
|
||||
this.pageSheet = pageChildElem;
|
||||
}
|
||||
}
|
||||
|
||||
pageChild = pageChild.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param relNode
|
||||
* @param model
|
||||
* @param pageName
|
||||
*/
|
||||
protected void resolveRel(Element relNode, mxVsdxModel model, String pageName)
|
||||
{
|
||||
Element relElem = model.getRelationship(relNode.getAttribute("r:id"), mxVsdxCodec.vsdxPlaceholder + "/pages/" + "_rels/" + pageName + ".xml.rels");
|
||||
|
||||
String target = relElem.getAttribute("Target");
|
||||
String type = relElem.getAttribute("Type");
|
||||
|
||||
if (String.valueOf(type).endsWith("page"))
|
||||
{
|
||||
Document pageDoc = null;
|
||||
|
||||
if (type != null && type.endsWith("page"))
|
||||
{
|
||||
pageDoc = model.getXmlDoc(mxVsdxCodec.vsdxPlaceholder + "/pages/" + target);
|
||||
}
|
||||
|
||||
if (pageDoc != null)
|
||||
{
|
||||
Node child = pageDoc.getFirstChild();
|
||||
|
||||
while (child != null)
|
||||
{
|
||||
if (child instanceof Element && ((Element)child).getTagName().equals("PageContents"))
|
||||
{
|
||||
int index = target.indexOf('.');
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
parseNodes(child, model, target.substring(0, index));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, VsdxShape> parseShapes(Element shapesElement, mxVsdxMaster master, boolean recurse)
|
||||
{
|
||||
Map<Integer, VsdxShape> shapes = new LinkedHashMap<Integer, VsdxShape>();
|
||||
NodeList shapeList = shapesElement.getElementsByTagName(mxVsdxConstants.SHAPE);
|
||||
|
||||
Node shapeNode = (shapeList != null && shapeList.getLength() > 0) ? shapeList.item(0) : null;
|
||||
|
||||
while (shapeNode != null)
|
||||
{
|
||||
if (shapeNode instanceof Element)
|
||||
{
|
||||
Element shapeElem = (Element) shapeNode;
|
||||
mxVsdxMaster masterTmp = master;
|
||||
|
||||
// Work out node type
|
||||
if (masterTmp == null)
|
||||
{
|
||||
//If the shape has the Master attribute the master shape is the first
|
||||
//shape of the master element.
|
||||
String masterId = shapeElem.getAttribute(mxVsdxConstants.MASTER);
|
||||
|
||||
if (masterId != null && !masterId.equals(""))
|
||||
{
|
||||
masterTmp = model.getMaster(masterId);
|
||||
}
|
||||
}
|
||||
|
||||
boolean isEdge = isEdge(shapeElem);
|
||||
|
||||
// If the master of the shape has an xform1D, it's an edge
|
||||
if (!isEdge && masterTmp != null)
|
||||
{
|
||||
String masterId = shapeElem.getAttribute(mxVsdxConstants.MASTER_SHAPE);
|
||||
|
||||
Element elem = masterTmp.getMasterElement();
|
||||
if (masterId != null && !masterId.equals(""))
|
||||
{
|
||||
elem = masterTmp.getSubShape(masterId).getShape();
|
||||
}
|
||||
isEdge = isEdge(elem);
|
||||
}
|
||||
|
||||
//String type = mxVdxShape.getType(shapeElem);
|
||||
|
||||
VsdxShape shape = this.createCell(shapeElem, !isEdge, masterTmp);
|
||||
|
||||
shapes.put(shape.getId(), shape);
|
||||
}
|
||||
|
||||
shapeNode = shapeNode.getNextSibling();
|
||||
}
|
||||
|
||||
return shapes;
|
||||
}
|
||||
|
||||
protected VsdxShape createCell(Element shapeElem, boolean vertex, mxVsdxMaster masterTmp)
|
||||
{
|
||||
return new VsdxShape(this, shapeElem, vertex, this.model.getMasterShapes(), masterTmp, this.model);
|
||||
}
|
||||
|
||||
public boolean isEdge(Element shape)
|
||||
{
|
||||
if (shape != null)
|
||||
{
|
||||
NodeList children = shape.getChildNodes();
|
||||
|
||||
if (children != null)
|
||||
{
|
||||
Node childNode = children.item(0);
|
||||
|
||||
while (childNode != null)
|
||||
{
|
||||
if (childNode instanceof Element)
|
||||
{
|
||||
Element childElem = (Element) childNode;
|
||||
|
||||
if (childElem.getNodeName().equals("Cell"))
|
||||
{
|
||||
String n = childElem.getAttribute("N");
|
||||
|
||||
if (n.equals("BeginX") || n.equals("BeginY") || n.equals("EndY") || n.equals("EndX"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
childNode = childNode.getNextSibling();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width and height of a Page expressed as an mxPoint.
|
||||
* @return mxPoint that represents the dimensions of the page
|
||||
*/
|
||||
public mxPoint getPageDimensions()
|
||||
{
|
||||
double pageH = 0;
|
||||
double pageW = 0;
|
||||
|
||||
Element height = this.cellElements.get("PageHeight");
|
||||
Element width = this.cellElements.get("PageWidth");
|
||||
|
||||
if (height != null)
|
||||
{
|
||||
pageH = Double.valueOf(height.getAttribute("V")) * mxVsdxUtils.conversionFactor;
|
||||
pageH = Math.round(pageH * 100.0) / 100.0;
|
||||
}
|
||||
|
||||
if (width != null)
|
||||
{
|
||||
pageW = Double.valueOf(width.getAttribute("V")) * mxVsdxUtils.conversionFactor;
|
||||
pageW = Math.round(pageW * 100.0) / 100.0;
|
||||
}
|
||||
|
||||
return new mxPoint(pageW, pageH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the drawing scale attribute of this page
|
||||
* @return the DrawingScale
|
||||
*/
|
||||
public double getDrawingScale()
|
||||
{
|
||||
Element scale = this.cellElements.get("DrawingScale");
|
||||
|
||||
if (scale != null)
|
||||
{
|
||||
return Double.valueOf(scale.getAttribute("V")) * mxVsdxUtils.conversionFactor;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the page scale attribute of this page
|
||||
* @return the PageScale
|
||||
*/
|
||||
public double getPageScale()
|
||||
{
|
||||
Element scale = this.cellElements.get("PageScale");
|
||||
|
||||
if (scale != null)
|
||||
{
|
||||
return Double.valueOf(scale.getAttribute("V")) * mxVsdxUtils.conversionFactor;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public String getCellValue(String cellName)
|
||||
{
|
||||
Element cell = this.cellElements.get(cellName);
|
||||
|
||||
if (cell != null)
|
||||
{
|
||||
return cell.getAttribute("V");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getCellIntValue(String cellName, int defVal)
|
||||
{
|
||||
String val = getCellValue(cellName);
|
||||
|
||||
if (val != null)
|
||||
{
|
||||
return Integer.parseInt(val);
|
||||
}
|
||||
|
||||
return defVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the page
|
||||
* @return the ID of the page
|
||||
*/
|
||||
public Integer getId()
|
||||
{
|
||||
return this.Id;
|
||||
}
|
||||
public String getPageName()
|
||||
{
|
||||
return this.pageName;
|
||||
}
|
||||
|
||||
public Map<Integer, VsdxShape> getShapes()
|
||||
{
|
||||
return this.shapes;
|
||||
}
|
||||
|
||||
public Map<Integer, mxVsdxConnect> getConnects()
|
||||
{
|
||||
return this.connects;
|
||||
}
|
||||
|
||||
public boolean isBackground()
|
||||
{
|
||||
return this.isBackground;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the background page ID, if any
|
||||
* @return the ID of any background page or null for no background page
|
||||
*/
|
||||
public Integer getBackPageId()
|
||||
{
|
||||
return this.backPageId;
|
||||
}
|
||||
|
||||
public void setBackPage(mxVsdxPage page)
|
||||
{
|
||||
this.backPage = page;
|
||||
}
|
||||
|
||||
public mxVsdxPage getBackPage()
|
||||
{
|
||||
return this.backPage;
|
||||
}
|
||||
}
|
|
@ -1,289 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2006-2016, JGraph Ltd
|
||||
* Copyright (c) 2006-2016, Gaudenz Alder
|
||||
*/
|
||||
package com.mxgraph.io.vsdx;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.mxgraph.util.mxConstants;
|
||||
|
||||
/**
|
||||
* General utilities for .vdx format support
|
||||
*/
|
||||
public class mxVsdxUtils
|
||||
{
|
||||
private static double screenCoordinatesPerCm = 40;
|
||||
|
||||
private static final double CENTIMETERS_PER_INCHES = 2.54;
|
||||
|
||||
public static final double conversionFactor = screenCoordinatesPerCm * CENTIMETERS_PER_INCHES;
|
||||
|
||||
private static final Logger log = Logger.getLogger(mxVsdxUtils.class.getName());
|
||||
|
||||
/**
|
||||
* Returns a collection of direct child Elements that match the specified tag name
|
||||
* @param parent the parent whose direct children will be processed
|
||||
* @param name the child tag name to match
|
||||
* @return a collection of matching Elements
|
||||
*/
|
||||
public static ArrayList<Element> getDirectChildNamedElements(Element parent, String name)
|
||||
{
|
||||
ArrayList<Element> result = new ArrayList<Element>();
|
||||
|
||||
for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling())
|
||||
{
|
||||
if (child instanceof Element && name.equals(child.getNodeName()))
|
||||
{
|
||||
result.add((Element)child);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a collection of direct child Elements
|
||||
* @param parent the parent whose direct children will be processed
|
||||
* @return a collection of all child Elements
|
||||
*/
|
||||
public static ArrayList<Element> getDirectChildElements(Element parent)
|
||||
{
|
||||
ArrayList<Element> result = new ArrayList<Element>();
|
||||
|
||||
for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling())
|
||||
{
|
||||
if (child instanceof Element)
|
||||
{
|
||||
result.add((Element)child);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first direct child Element
|
||||
* @param parent the parent whose direct first child will be processed
|
||||
* @return the first child Element
|
||||
*/
|
||||
public static Element getDirectFirstChildElement(Element parent)
|
||||
{
|
||||
for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling())
|
||||
{
|
||||
if (child instanceof Element)
|
||||
{
|
||||
return (Element)child;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of an integer attribute or the default value
|
||||
* @param elem Element
|
||||
* @param attName Attribute name
|
||||
* @param defVal default value
|
||||
* @return the parsed attribute value or the default value
|
||||
*/
|
||||
public static int getIntAttr(Element elem, String attName, int defVal)
|
||||
{
|
||||
try
|
||||
{
|
||||
String val = elem.getAttribute(attName);
|
||||
if (val != null)
|
||||
{
|
||||
return Integer.parseInt(val);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
//nothing, just return the default value
|
||||
}
|
||||
return defVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of an integer attribute or zero
|
||||
* @param elem Element
|
||||
* @param attName Attribute name
|
||||
* @return the parsed attribute value or zero
|
||||
*/
|
||||
public static int getIntAttr(Element elem, String attName)
|
||||
{
|
||||
return getIntAttr(elem, attName, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string that represents the content of a given style map.
|
||||
* @param styleMap Map with the styles values
|
||||
* @return string that represents the style.
|
||||
*/
|
||||
public static String getStyleString(Map<String, String> styleMap, String asig)
|
||||
{
|
||||
String style = "";
|
||||
Iterator<String> it = styleMap.values().iterator();
|
||||
Iterator<String> kit = styleMap.keySet().iterator();
|
||||
|
||||
while (kit.hasNext())
|
||||
{
|
||||
String key = kit.next();
|
||||
Object value = it.next();
|
||||
|
||||
if(!key.equals(mxConstants.STYLE_SHAPE) || (!styleMap.get(key).startsWith("image") && !styleMap.get(key).startsWith("rounded=")))
|
||||
{
|
||||
try
|
||||
{
|
||||
style = style + key + asig;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "mxVsdxUtils.getStyleString," + e.toString() + ",style.length=" + style.length() +
|
||||
",key.length=" + key.length() + ",asig.length=" + asig.length());
|
||||
}
|
||||
}
|
||||
|
||||
style = style + value + ";";
|
||||
}
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a text surrounded by tags html.
|
||||
* @param text Text to be surrounded.
|
||||
* @param tag Name of the tag.
|
||||
* @return < tag > text < /tag >
|
||||
*/
|
||||
public static String surroundByTags(String text, String tag)
|
||||
{
|
||||
return "<" + tag + ">" + text + "</" + tag + ">";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts the ampersand, quote, prime, less-than and greater-than
|
||||
* characters to their corresponding HTML entities in the given string.
|
||||
*
|
||||
* Note: this is the same method of mxUtils but we cannot use it as it is not compatible with google app engine
|
||||
*/
|
||||
public static String htmlEntities(String text)
|
||||
{
|
||||
return text.replaceAll("&", "&").replaceAll("\"", """)
|
||||
.replaceAll("'", "′").replaceAll("<", "<")
|
||||
.replaceAll(">", ">");
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the initial letter of each word in text to uppercase
|
||||
* @param text Text to be transformed.
|
||||
* @return Text with initial capitals.
|
||||
*/
|
||||
public static String toInitialCapital(String text)
|
||||
{
|
||||
String[] words = text.split(" ");
|
||||
String ret = "";
|
||||
|
||||
for (String word : words)
|
||||
{
|
||||
String begin = word.substring(0, 1);
|
||||
word = word.substring(1);
|
||||
begin = begin.toUpperCase();
|
||||
ret += begin + word;
|
||||
}
|
||||
|
||||
return ret.substring(0, ret.length());
|
||||
}
|
||||
|
||||
/**
|
||||
* Trnsforms each lower case letter in text to small capital.
|
||||
* @param text Text to be transformed.
|
||||
* @param size Size of the original text.
|
||||
* @return Text in small capitals.
|
||||
*/
|
||||
public static String toSmallCaps(String text, String size)
|
||||
{
|
||||
String ret = "";
|
||||
|
||||
if (!size.equals(ret))
|
||||
{
|
||||
char a = 'a';
|
||||
char z = 'z';
|
||||
char[] letters = text.toCharArray();
|
||||
|
||||
for (char c : letters)
|
||||
{
|
||||
if (c >= a && c <= z)
|
||||
{
|
||||
String s = String.valueOf(c);
|
||||
s = s.toUpperCase();
|
||||
ret += "<font style=\"font-size:" + Double.valueOf(size) / 1.28 + "px\">" + s + "</font>";
|
||||
}
|
||||
else
|
||||
{
|
||||
ret += c;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = text;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a style map from a String with style definitions.
|
||||
* @param style Definition of the style.
|
||||
* @param asig Asignation simbol used in 'style'.
|
||||
* @return Map with the style properties.
|
||||
*/
|
||||
public static HashMap<String, Object> getStyleMap(String style, String asig)
|
||||
{
|
||||
HashMap<String, Object> styleMap = new HashMap<String, Object>();
|
||||
|
||||
String[] entries = style.split(";");
|
||||
|
||||
for (String entry : entries)
|
||||
{
|
||||
int index = entry.indexOf(asig);
|
||||
String key = entry.substring(0, index);
|
||||
String value = entry.substring(index + 1);
|
||||
styleMap.put(key, value);
|
||||
}
|
||||
|
||||
return styleMap;
|
||||
}
|
||||
|
||||
public static boolean isInsideTriangle(double x, double y, double ax, double ay, double bx, double by, double cx, double cy)
|
||||
{
|
||||
bx = bx - ax;
|
||||
by = by - ay;
|
||||
cx = cx - ax;
|
||||
cy = cy - ay;
|
||||
ax = 0;
|
||||
ay = 0;
|
||||
|
||||
double d = bx * cy - cx * by;
|
||||
double wa = (x * (by - cy) + y * (cx - bx) + bx * cy - cx * by) / d;
|
||||
double wb = (x * cy - y * cx) / d;
|
||||
double wc = (y * bx - x * by) / d;
|
||||
|
||||
if(wa > 0 && wa < 1 && wb > 0 && wb < 1 && wc > 0 && wc < 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,222 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2006-2016, JGraph Ltd
|
||||
* Copyright (c) 2006-2016, Gaudenz Alder
|
||||
*/
|
||||
package com.mxgraph.online;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.zip.Deflater;
|
||||
import java.util.zip.Inflater;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
|
||||
import com.mxgraph.io.vsdx.mxGeometry;
|
||||
import com.mxgraph.io.vsdx.mxPoint;
|
||||
|
||||
/**
|
||||
*
|
||||
* String/byte array encoding/manipulation utilities
|
||||
*
|
||||
*/
|
||||
public class Utils
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static String CHARSET_FOR_URL_ENCODING = "ISO-8859-1";
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected static final int IO_BUFFER_SIZE = 4 * 1024;
|
||||
|
||||
/**
|
||||
* Applies a standard inflate algo to the input byte array
|
||||
* @param binary the byte array to inflate
|
||||
* @return the inflated String
|
||||
*
|
||||
*/
|
||||
public static String inflate(byte[] binary) throws IOException
|
||||
{
|
||||
StringBuffer result = new StringBuffer();
|
||||
InputStream in = new InflaterInputStream(
|
||||
new ByteArrayInputStream(binary), new Inflater(true));
|
||||
|
||||
while (in.available() != 0)
|
||||
{
|
||||
byte[] buffer = new byte[IO_BUFFER_SIZE];
|
||||
int len = in.read(buffer, 0, IO_BUFFER_SIZE);
|
||||
|
||||
if (len <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
result.append(new String(buffer, 0, len));
|
||||
}
|
||||
|
||||
in.close();
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a standard deflate algo to the input String
|
||||
* @param inString the String to deflate
|
||||
* @return the deflated byte array
|
||||
*
|
||||
*/
|
||||
public static byte[] deflate(String inString) throws IOException
|
||||
{
|
||||
Deflater deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, true);
|
||||
byte[] inBytes = inString.getBytes("UTF-8");
|
||||
deflater.setInput(inBytes);
|
||||
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(
|
||||
inBytes.length);
|
||||
deflater.finish();
|
||||
byte[] buffer = new byte[IO_BUFFER_SIZE];
|
||||
|
||||
while (!deflater.finished())
|
||||
{
|
||||
int count = deflater.deflate(buffer); // returns the generated code... index
|
||||
outputStream.write(buffer, 0, count);
|
||||
}
|
||||
|
||||
outputStream.close();
|
||||
byte[] output = outputStream.toByteArray();
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the input stream to the output stream using the default buffer size
|
||||
* @param in the input stream
|
||||
* @param out the output stream
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void copy(InputStream in, OutputStream out) throws IOException
|
||||
{
|
||||
copy(in, out, IO_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the input stream to the output stream using the specified buffer size
|
||||
* @param in the input stream
|
||||
* @param out the output stream
|
||||
* @param bufferSize the buffer size to use when copying
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void copy(InputStream in, OutputStream out, int bufferSize)
|
||||
throws IOException
|
||||
{
|
||||
byte[] b = new byte[bufferSize];
|
||||
int read;
|
||||
|
||||
while ((read = in.read(b)) != -1)
|
||||
{
|
||||
out.write(b, 0, read);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an input stream and returns the result as a String
|
||||
* @param stream the input stream to read
|
||||
* @return a String representation of the input stream
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String readInputStream(InputStream stream) throws IOException
|
||||
{
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(stream));
|
||||
StringBuffer result = new StringBuffer();
|
||||
String tmp = reader.readLine();
|
||||
|
||||
while (tmp != null)
|
||||
{
|
||||
result.append(tmp + "\n");
|
||||
tmp = reader.readLine();
|
||||
}
|
||||
|
||||
reader.close();
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the passed String as UTF-8 using an algorithm that's compatible
|
||||
* with JavaScript's <code>encodeURIComponent</code> function. Returns
|
||||
* <code>null</code> if the String is <code>null</code>.
|
||||
*
|
||||
* @param s The String to be encoded
|
||||
* @param charset the character set to base the encoding on
|
||||
* @return the encoded String
|
||||
*/
|
||||
public static String encodeURIComponent(String s, String charset)
|
||||
{
|
||||
if (s == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
String result;
|
||||
|
||||
try
|
||||
{
|
||||
result = URLEncoder.encode(s, charset).replaceAll("\\+", "%20")
|
||||
.replaceAll("\\%21", "!").replaceAll("\\%27", "'").replaceAll("\\%28", "(")
|
||||
.replaceAll("\\%29", ")").replaceAll("\\%7E", "~");
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
// This exception should never occur
|
||||
result = s;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates the given point by the given cos and sin.
|
||||
*/
|
||||
public static mxPoint getRotatedPoint(mxPoint pt, double cos, double sin,
|
||||
mxPoint c)
|
||||
{
|
||||
double x = pt.getX() - c.getX();
|
||||
double y = pt.getY() - c.getY();
|
||||
|
||||
double x1 = x * cos - y * sin;
|
||||
double y1 = y * cos + x * sin;
|
||||
|
||||
return new mxPoint(x1 + c.getX(), y1 + c.getY());
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates the given geometry (in place) by the given rotation (in degrees).
|
||||
*/
|
||||
public static void rotatedGeometry(mxGeometry geo, double rotation,
|
||||
double cx, double cy)
|
||||
{
|
||||
rotation = Math.toRadians(rotation);
|
||||
double cos = Math.cos(rotation), sin = Math.sin(rotation);
|
||||
|
||||
double x = geo.getCenterX() - cx;
|
||||
double y = geo.getCenterY() - cy;
|
||||
|
||||
double x1 = x * cos - y * sin;
|
||||
double y1 = y * cos + x * sin;
|
||||
|
||||
geo.setX(Math.round(x1 + cx - geo.getWidth() / 2));
|
||||
geo.setY(Math.round(y1 + cy - geo.getHeight() / 2));
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,12 +0,0 @@
|
|||
package com.mxgraph.io.gliffy.model;
|
||||
|
||||
public class LinkMap {
|
||||
|
||||
public String url;
|
||||
|
||||
public LinkMap() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2006-2016, JGraph Ltd
|
||||
* Copyright (c) 2006-2016, Gaudenz Alder
|
||||
*/
|
||||
package com.mxgraph.io.vsdx;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Represents a single formatted section of text
|
||||
*
|
||||
*/
|
||||
public class Paragraph
|
||||
{
|
||||
protected ArrayList<String> values;
|
||||
|
||||
protected ArrayList<String> charIndices;
|
||||
|
||||
protected ArrayList<String> fields;
|
||||
|
||||
protected String paraIndex;
|
||||
|
||||
public Paragraph(String val, String ch, String pg, String field)
|
||||
{
|
||||
this.values = new ArrayList<String>();
|
||||
this.values.add(val);
|
||||
this.charIndices = new ArrayList<String>();
|
||||
this.charIndices.add(ch);
|
||||
this.fields = new ArrayList<String>();
|
||||
this.fields.add(field);
|
||||
this.paraIndex = pg;
|
||||
}
|
||||
|
||||
public void addText(String val, String ch, String field)
|
||||
{
|
||||
this.values.add(val);
|
||||
this.charIndices.add(ch);
|
||||
this.fields.add(field);
|
||||
}
|
||||
|
||||
public String getParagraphIndex()
|
||||
{
|
||||
return this.paraIndex;
|
||||
}
|
||||
|
||||
public String getValue(int index)
|
||||
{
|
||||
return values.get(index);
|
||||
}
|
||||
|
||||
public int numValues()
|
||||
{
|
||||
return this.values.size();
|
||||
}
|
||||
|
||||
public String getChar(int index)
|
||||
{
|
||||
return charIndices.get(index);
|
||||
}
|
||||
|
||||
public String getField(int index)
|
||||
{
|
||||
return fields.get(index);
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2006-2016, JGraph Ltd
|
||||
* Copyright (c) 2006-2016, Gaudenz Alder
|
||||
*/
|
||||
package com.mxgraph.io.vsdx;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Wrapper for a Section element https://msdn.microsoft.com/en-us/library/office/jj684189.aspx
|
||||
*
|
||||
*/
|
||||
public class Section
|
||||
{
|
||||
/**
|
||||
* The section element
|
||||
*/
|
||||
protected Element elem = null;
|
||||
|
||||
/**
|
||||
* Constructs a new Section
|
||||
* @param elem the Element to wrap
|
||||
*/
|
||||
public Section(Element elem)
|
||||
{
|
||||
this.elem = elem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the specified cell by key by row index, if it exists
|
||||
* @param index the row index to search
|
||||
* @param cellKey the name of the Cell to search for
|
||||
* @return the Element of the specified Cell, if null if it doesn't exist
|
||||
*/
|
||||
public Element getIndexedCell(String index, String cellKey)
|
||||
{
|
||||
ArrayList<Element> rows = mxVsdxUtils.getDirectChildNamedElements(this.elem, "Row");
|
||||
|
||||
for (int i=0; i < rows.size(); i++)
|
||||
{
|
||||
Element row = rows.get(i);
|
||||
String n = row.getAttribute("IX");
|
||||
|
||||
// If index is null always match. For example, you can have a shape text with no paragraph index.
|
||||
// When it checks the master shape the first paragraph should be used (or maybe the lowest index?)
|
||||
if (n.equals(index) || index == null)
|
||||
{
|
||||
ArrayList<Element> cells = mxVsdxUtils.getDirectChildNamedElements(row, "Cell");
|
||||
|
||||
for (int j=0; j < cells.size(); j++)
|
||||
{
|
||||
Element cell = cells.get(j);
|
||||
n = cell.getAttribute("N");
|
||||
|
||||
if (n.equals(cellKey))
|
||||
{
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2010-2016, JGraph Ltd
|
||||
* Copyright (c) 2010-2016, Gaudenz Alder
|
||||
*/
|
||||
package com.mxgraph.io.vsdx;
|
||||
|
||||
/**
|
||||
* Wraps the page and shape ID within that page to create a unique ID
|
||||
*/
|
||||
public class ShapePageId
|
||||
{
|
||||
private int pageNumber;
|
||||
|
||||
private int Id;
|
||||
|
||||
public ShapePageId(int pageNumber, int Id)
|
||||
{
|
||||
this.pageNumber = pageNumber;
|
||||
this.Id = Id;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return Id;
|
||||
}
|
||||
|
||||
public int getPageNumber()
|
||||
{
|
||||
return pageNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj == null || getClass() != obj.getClass())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final ShapePageId other = (ShapePageId) obj;
|
||||
|
||||
if (this.pageNumber != other.pageNumber || this.Id != other.Id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return 100000 * this.pageNumber + this.Id;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,97 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.export;
|
||||
|
||||
public class ModelExtAttrib
|
||||
{
|
||||
private double pageScale = 1,
|
||||
pageWidth = 839, pageHeight = 1188, //A4 size in pixels as a default
|
||||
gridSize = 10;
|
||||
private boolean pageVisible = true, gridEnabled = true, guidesEnabled = true, foldingEnabled = true,
|
||||
shadowVisible = false, tooltips = true, connect = true, arrows = true, mathEnabled = true;
|
||||
private String backgroundClr = "#FFFFFF";
|
||||
//TODO add backgroundImage support
|
||||
|
||||
public double getPageScale() {
|
||||
return pageScale;
|
||||
}
|
||||
public double getPageWidth() {
|
||||
return pageWidth;
|
||||
}
|
||||
public double getPageHeight() {
|
||||
return pageHeight;
|
||||
}
|
||||
public double getGridSize() {
|
||||
return gridSize;
|
||||
}
|
||||
public boolean isPageVisible() {
|
||||
return pageVisible;
|
||||
}
|
||||
public boolean isGridEnabled() {
|
||||
return gridEnabled;
|
||||
}
|
||||
public boolean isGuidesEnabled() {
|
||||
return guidesEnabled;
|
||||
}
|
||||
public boolean isFoldingEnabled() {
|
||||
return foldingEnabled;
|
||||
}
|
||||
public boolean isShadowVisible() {
|
||||
return shadowVisible;
|
||||
}
|
||||
public boolean isTooltips() {
|
||||
return tooltips;
|
||||
}
|
||||
public boolean isConnect() {
|
||||
return connect;
|
||||
}
|
||||
public boolean isArrows() {
|
||||
return arrows;
|
||||
}
|
||||
public boolean isMathEnabled() {
|
||||
return mathEnabled;
|
||||
}
|
||||
public String getBackgroundClr() {
|
||||
return backgroundClr;
|
||||
}
|
||||
public void setPageScale(double pageScale) {
|
||||
this.pageScale = pageScale;
|
||||
}
|
||||
public void setPageWidth(double pageWidth) {
|
||||
this.pageWidth = pageWidth;
|
||||
}
|
||||
public void setPageHeight(double pageHeight) {
|
||||
this.pageHeight = pageHeight;
|
||||
}
|
||||
public void setGridSize(double gridSize) {
|
||||
this.gridSize = gridSize;
|
||||
}
|
||||
public void setPageVisible(boolean pageVisible) {
|
||||
this.pageVisible = pageVisible;
|
||||
}
|
||||
public void setGridEnabled(boolean gridEnabled) {
|
||||
this.gridEnabled = gridEnabled;
|
||||
}
|
||||
public void setGuidesEnabled(boolean guidesEnabled) {
|
||||
this.guidesEnabled = guidesEnabled;
|
||||
}
|
||||
public void setFoldingEnabled(boolean foldingEnabled) {
|
||||
this.foldingEnabled = foldingEnabled;
|
||||
}
|
||||
public void setShadowVisible(boolean shadowVisible) {
|
||||
this.shadowVisible = shadowVisible;
|
||||
}
|
||||
public void setTooltips(boolean tooltips) {
|
||||
this.tooltips = tooltips;
|
||||
}
|
||||
public void setConnect(boolean connect) {
|
||||
this.connect = connect;
|
||||
}
|
||||
public void setArrows(boolean arrows) {
|
||||
this.arrows = arrows;
|
||||
}
|
||||
public void setMathEnabled(boolean mathEnabled) {
|
||||
this.mathEnabled = mathEnabled;
|
||||
}
|
||||
public void setBackgroundClr(String backgroundClr) {
|
||||
this.backgroundClr = backgroundClr;
|
||||
}
|
||||
}
|
|
@ -1,553 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.export;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.TransformerFactoryConfigurationError;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import com.mxgraph.io.mxCodec;
|
||||
import com.mxgraph.io.vsdx.mxVsdxUtils;
|
||||
import com.mxgraph.model.mxCell;
|
||||
import com.mxgraph.model.mxGeometry;
|
||||
import com.mxgraph.model.mxGraphModel;
|
||||
import com.mxgraph.online.Utils;
|
||||
import com.mxgraph.online.mxBase64;
|
||||
import com.mxgraph.util.mxXmlUtils;
|
||||
import com.mxgraph.view.mxGraph;
|
||||
import com.mxgraph.view.mxGraphHeadless;
|
||||
|
||||
public class mxVsdxExporter
|
||||
{
|
||||
private static final String PAGES_TYPE = "http://schemas.microsoft.com/visio/2010/relationships/page";
|
||||
private static final String RELS_XMLNS = "http://schemas.openxmlformats.org/package/2006/relationships";
|
||||
private static final String XML_SPACE = "preserve";
|
||||
private static final String XMLNS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
||||
private static final String XMLNS = "http://schemas.microsoft.com/office/visio/2012/main";
|
||||
private static final String VISIO_PAGES = "visio/pages/";
|
||||
private static final String PREFEX = "com/mxgraph/io/vsdx/resources/export/";
|
||||
private static final String VSDX_ENC = "ISO-8859-1";
|
||||
private static final String OVERRIDE = "Override";
|
||||
private static final String PART_NAME = "PartName";
|
||||
private static final String DOC_PROPS_CUSTOM_XML = "docProps/custom.xml";
|
||||
private static final String DOC_PROPS_CORE_XML = "docProps/core.xml";
|
||||
private static final String DOC_PROPS_APP_XML = "docProps/app.xml";
|
||||
private static final String _RELS_RELS_FILE = "_rels/.rels";
|
||||
private static final String CONTENT_TYPES_XML = "[Content_Types].xml";
|
||||
private static final String VISIO_MASTERS_RELS_MASTERS_XML_RELS = "visio/masters/_rels/masters.xml.rels";
|
||||
private static final String VISIO_MASTERS_MASTERS_XML = "visio/masters/masters.xml";
|
||||
private static final String VISIO_RELS_DOCUMENT_XML_RELS = "visio/_rels/document.xml.rels";
|
||||
private static final String VISIO_WINDOWS_XML = "visio/windows.xml";
|
||||
private static final String VISIO_DOCUMENT_XML = "visio/document.xml";
|
||||
private static final String VISIO_PAGES_RELS = "visio/pages/_rels/";
|
||||
|
||||
private static byte[] documentFile;
|
||||
private static byte[] windowsFile;
|
||||
private static byte[] visioRelsFile;
|
||||
private static byte[] mastersFile;
|
||||
private static byte[] mastersRelsFile;
|
||||
private static byte[] contentTypeFile;
|
||||
private static byte[] _relsFile;
|
||||
private static byte[] appFile;
|
||||
private static byte[] coreFile;
|
||||
private static byte[] customFile;
|
||||
private static byte[] pageRelFile;
|
||||
|
||||
//Load the constant vsdx files statically so it can be used faster for all export operations
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
ClassLoader classLoader = mxVsdxExporter.class.getClassLoader();
|
||||
|
||||
String file = PREFEX + VISIO_DOCUMENT_XML;
|
||||
int size = (int) new File(classLoader.getResource(file).getFile()).length();
|
||||
InputStream in = classLoader.getResourceAsStream(file);
|
||||
|
||||
documentFile = new byte[size];
|
||||
in.read(documentFile);
|
||||
|
||||
file = PREFEX + VISIO_WINDOWS_XML;
|
||||
size = (int) new File(classLoader.getResource(file).getFile()).length();
|
||||
in = classLoader.getResourceAsStream(file);
|
||||
|
||||
windowsFile = new byte[size];
|
||||
in.read(windowsFile);
|
||||
|
||||
file = PREFEX + VISIO_RELS_DOCUMENT_XML_RELS;
|
||||
size = (int) new File(classLoader.getResource(file).getFile()).length();
|
||||
in = classLoader.getResourceAsStream(file);
|
||||
|
||||
visioRelsFile = new byte[size];
|
||||
in.read(visioRelsFile);
|
||||
|
||||
file = PREFEX + VISIO_MASTERS_MASTERS_XML;
|
||||
size = (int) new File(classLoader.getResource(file).getFile()).length();
|
||||
in = classLoader.getResourceAsStream(file);
|
||||
|
||||
mastersFile = new byte[size];
|
||||
in.read(mastersFile);
|
||||
|
||||
file = PREFEX + VISIO_MASTERS_RELS_MASTERS_XML_RELS;
|
||||
size = (int) new File(classLoader.getResource(file).getFile()).length();
|
||||
in = classLoader.getResourceAsStream(file);
|
||||
|
||||
mastersRelsFile = new byte[size];
|
||||
in.read(mastersRelsFile);
|
||||
|
||||
file = PREFEX + CONTENT_TYPES_XML;
|
||||
size = (int) new File(URLDecoder.decode(classLoader.getResource(file).getFile(), "UTF8")).length();
|
||||
in = classLoader.getResourceAsStream(file);
|
||||
|
||||
contentTypeFile = new byte[size];
|
||||
in.read(contentTypeFile);
|
||||
|
||||
file = PREFEX + _RELS_RELS_FILE;
|
||||
size = (int) new File(classLoader.getResource(file).getFile()).length();
|
||||
in = classLoader.getResourceAsStream(file);
|
||||
|
||||
_relsFile = new byte[size];
|
||||
in.read(_relsFile);
|
||||
|
||||
file = PREFEX + DOC_PROPS_APP_XML;
|
||||
size = (int) new File(classLoader.getResource(file).getFile()).length();
|
||||
in = classLoader.getResourceAsStream(file);
|
||||
|
||||
appFile = new byte[size];
|
||||
in.read(appFile);
|
||||
|
||||
file = PREFEX + DOC_PROPS_CORE_XML;
|
||||
size = (int) new File(classLoader.getResource(file).getFile()).length();
|
||||
in = classLoader.getResourceAsStream(file);
|
||||
|
||||
coreFile = new byte[size];
|
||||
in.read(coreFile);
|
||||
|
||||
file = PREFEX + DOC_PROPS_CUSTOM_XML;
|
||||
size = (int) new File(classLoader.getResource(file).getFile()).length();
|
||||
in = classLoader.getResourceAsStream(file);
|
||||
|
||||
customFile = new byte[size];
|
||||
in.read(customFile);
|
||||
|
||||
file = PREFEX + VISIO_PAGES_RELS + "page1.xml.rels";
|
||||
size = (int) new File(classLoader.getResource(file).getFile()).length();
|
||||
in = classLoader.getResourceAsStream(file);
|
||||
|
||||
pageRelFile = new byte[size];
|
||||
in.read(pageRelFile);
|
||||
}
|
||||
catch (Exception e) //We shouldn't get any exception as long as files exist.
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill the required files in vsdx format which are constants in our exporter
|
||||
* @param zip ZipOutputStream of vsdx file
|
||||
* @param pageCount The number of pages in the mxFile
|
||||
* @throws IOException
|
||||
*/
|
||||
private void createVsdxSkeleton(ZipOutputStream zip, int pageCount) throws IOException
|
||||
{
|
||||
zip.putNextEntry(new ZipEntry(VISIO_PAGES_RELS + "page1.xml.rels"));
|
||||
zip.write(pageRelFile);
|
||||
|
||||
if (pageCount == 1)
|
||||
{
|
||||
zip.putNextEntry(new ZipEntry(CONTENT_TYPES_XML));
|
||||
zip.write(contentTypeFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Add the remaining pages
|
||||
Document doc = mxXmlUtils.parseXml(new String(contentTypeFile));
|
||||
Element root = doc.getDocumentElement();
|
||||
|
||||
ArrayList<Element> overrides = mxVsdxUtils.getDirectChildNamedElements(root, OVERRIDE);
|
||||
Element page1 = null;
|
||||
|
||||
for (Element override : overrides)
|
||||
{
|
||||
if ("/visio/pages/page1.xml".equals(override.getAttribute(PART_NAME)))
|
||||
{
|
||||
page1 = override;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 2; i <= pageCount; i++)
|
||||
{
|
||||
zip.putNextEntry(new ZipEntry(VISIO_PAGES_RELS + "page" + i + ".xml.rels"));
|
||||
zip.write(pageRelFile);
|
||||
|
||||
Element newPage = (Element) page1.cloneNode(false);
|
||||
newPage.setAttribute(PART_NAME, "/visio/pages/page" + i + ".xml");
|
||||
root.appendChild(newPage);
|
||||
}
|
||||
|
||||
zip.putNextEntry(new ZipEntry(CONTENT_TYPES_XML));
|
||||
zip.write(("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + mxXmlUtils.getXml(doc)).getBytes(VSDX_ENC));
|
||||
}
|
||||
|
||||
|
||||
|
||||
zip.putNextEntry(new ZipEntry(_RELS_RELS_FILE));
|
||||
zip.write(_relsFile);
|
||||
|
||||
zip.putNextEntry(new ZipEntry(DOC_PROPS_APP_XML));
|
||||
zip.write(appFile);
|
||||
|
||||
zip.putNextEntry(new ZipEntry(DOC_PROPS_CORE_XML));
|
||||
zip.write(coreFile);
|
||||
|
||||
zip.putNextEntry(new ZipEntry(DOC_PROPS_CUSTOM_XML));
|
||||
zip.write(customFile);
|
||||
|
||||
zip.putNextEntry(new ZipEntry(VISIO_DOCUMENT_XML));
|
||||
zip.write(documentFile);
|
||||
|
||||
zip.putNextEntry(new ZipEntry(VISIO_WINDOWS_XML));
|
||||
zip.write(windowsFile);
|
||||
|
||||
zip.putNextEntry(new ZipEntry(VISIO_RELS_DOCUMENT_XML_RELS));
|
||||
zip.write(visioRelsFile);
|
||||
|
||||
zip.putNextEntry(new ZipEntry(VISIO_MASTERS_MASTERS_XML));
|
||||
zip.write(mastersFile);
|
||||
|
||||
zip.putNextEntry(new ZipEntry(VISIO_MASTERS_RELS_MASTERS_XML_RELS));
|
||||
zip.write(mastersRelsFile);
|
||||
|
||||
zip.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Convert mxFile into a vdsx file
|
||||
* @param mxFileXML mxFile xml string
|
||||
* @param out output stream where vsdx file is written to
|
||||
* @return true if successful, false otherwise (stream should be discarded and closed)
|
||||
*/
|
||||
public boolean exportMxFile(String mxFileXML, OutputStream out)
|
||||
{
|
||||
try
|
||||
{
|
||||
ZipOutputStream zip = new ZipOutputStream(out);
|
||||
DocumentBuilder docBuilder = mxXmlUtils.getDocumentBuilder();
|
||||
LinkedHashMap<String, Document> pages = new LinkedHashMap<>();
|
||||
LinkedHashMap<String, ModelExtAttrib> modelsAttr = new LinkedHashMap<>();
|
||||
|
||||
Document doc = mxXmlUtils.parseXml(mxFileXML);
|
||||
ArrayList<Element> diagrams = mxVsdxUtils.getDirectChildNamedElements(doc.getDocumentElement(), "diagram");
|
||||
mxCodec codec = new mxCodec();
|
||||
|
||||
for (Element diagram : diagrams)
|
||||
{
|
||||
String diagramName = diagram.getAttribute("name");
|
||||
String diagramB64 = diagram.getFirstChild().getTextContent();
|
||||
byte[] deflated = mxBase64.decodeFast(diagramB64);
|
||||
String uriEncoded = Utils.inflate(deflated);
|
||||
String xml = URLDecoder.decode(uriEncoded, Utils.CHARSET_FOR_URL_ENCODING);
|
||||
Element modelNode = mxXmlUtils.parseXml(xml).getDocumentElement();
|
||||
ModelExtAttrib modelAttrib = getModelExtAttributes(modelNode);
|
||||
mxGraphModel model = (mxGraphModel) codec.decode(modelNode);
|
||||
pages.put(diagramName, convertMxModel2Page(docBuilder, model, diagramName, modelAttrib));
|
||||
modelsAttr.put(diagramName, modelAttrib);
|
||||
}
|
||||
|
||||
createVsdxSkeleton(zip, pages.size());
|
||||
|
||||
addPagesXML(docBuilder, zip, pages, modelsAttr);
|
||||
|
||||
zip.close();
|
||||
return true;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private Double getDouble(String val)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (val != null && !val.isEmpty())
|
||||
{
|
||||
return Double.valueOf(val);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//fallback to null
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private ModelExtAttrib getModelExtAttributes(Element modelNode)
|
||||
{
|
||||
ModelExtAttrib attr = new ModelExtAttrib();
|
||||
|
||||
try
|
||||
{
|
||||
String grid = modelNode.getAttribute("grid");
|
||||
if (!grid.isEmpty()) attr.setGridEnabled("1".equals(grid));
|
||||
|
||||
Double gridSize = getDouble(modelNode.getAttribute("gridSize"));
|
||||
if (gridSize != null) attr.setGridSize(gridSize);
|
||||
|
||||
String guides = modelNode.getAttribute("guides");
|
||||
if (!guides.isEmpty()) attr.setGuidesEnabled("1".equals(guides));
|
||||
|
||||
String page = modelNode.getAttribute("page");
|
||||
if (!page.isEmpty()) attr.setPageVisible("1".equals(page));
|
||||
|
||||
Double pageScale = getDouble(modelNode.getAttribute("pageScale"));
|
||||
if (pageScale != null) attr.setPageScale(pageScale);
|
||||
|
||||
Double pageWidth = getDouble(modelNode.getAttribute("pageWidth"));
|
||||
if (pageWidth != null) attr.setPageWidth(pageWidth);
|
||||
|
||||
Double pageHeight = getDouble(modelNode.getAttribute("pageHeight"));
|
||||
if (pageHeight != null) attr.setPageHeight(pageHeight);
|
||||
|
||||
String background = modelNode.getAttribute("background");
|
||||
if (!background.isEmpty()) attr.setBackgroundClr(background);
|
||||
|
||||
String math = modelNode.getAttribute("math");
|
||||
if (!math.isEmpty()) attr.setMathEnabled("1".equals(math));
|
||||
|
||||
String shadow = modelNode.getAttribute("shadow");
|
||||
if (!shadow.isEmpty()) attr.setShadowVisible("1".equals(shadow));
|
||||
|
||||
//these most probably not needed in vsdx
|
||||
String tooltips = modelNode.getAttribute("tooltips");
|
||||
if (!tooltips.isEmpty()) attr.setTooltips("1".equals(tooltips));
|
||||
|
||||
String connect = modelNode.getAttribute("connect");
|
||||
if (!connect.isEmpty()) attr.setConnect("1".equals(connect));
|
||||
|
||||
String arrows = modelNode.getAttribute("arrows");
|
||||
if (!arrows.isEmpty()) attr.setArrows("1".equals(arrows));
|
||||
|
||||
String fold = modelNode.getAttribute("fold");
|
||||
if (!fold.isEmpty()) attr.setFoldingEnabled("1".equals(fold));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//nothing, fallback to defaults
|
||||
}
|
||||
return attr;
|
||||
}
|
||||
|
||||
private void addPagesXML(DocumentBuilder docBuilder, ZipOutputStream zip, LinkedHashMap<String, Document> pages, LinkedHashMap<String, ModelExtAttrib> modelsAttr)
|
||||
throws TransformerFactoryConfigurationError, TransformerException, IOException
|
||||
{
|
||||
Document pagesXmlDoc = docBuilder.newDocument();
|
||||
Document pagesRelsXmlDoc = docBuilder.newDocument();
|
||||
|
||||
Element pagesRoot = pagesXmlDoc.createElement("Pages");
|
||||
pagesRoot.setAttribute("xmlns", XMLNS);
|
||||
pagesRoot.setAttribute("xmlns:r", XMLNS_R);
|
||||
pagesRoot.setAttribute("xml:space", XML_SPACE);
|
||||
|
||||
Element pagesRelsRoot = pagesRelsXmlDoc.createElement("Relationships");
|
||||
pagesRelsRoot.setAttribute("xmlns", RELS_XMLNS);
|
||||
|
||||
int i = 1;
|
||||
for (Entry<String, Document> pair : pages.entrySet())
|
||||
{
|
||||
String name = pair.getKey();
|
||||
String pageName = "page" + i + ".xml";
|
||||
|
||||
Element pageE = pagesXmlDoc.createElement("Page");
|
||||
pageE.setAttribute("ID", String.valueOf(i-1));
|
||||
pageE.setAttribute("NameU", name);
|
||||
pageE.setAttribute("Name", name);
|
||||
|
||||
Element pageSheet = pagesXmlDoc.createElement("PageSheet");
|
||||
|
||||
ModelExtAttrib modelAttr = modelsAttr.get(name);
|
||||
|
||||
pageSheet.appendChild(createCellElemScaled("PageWidth", modelAttr.getPageWidth(), pagesXmlDoc));
|
||||
pageSheet.appendChild(createCellElemScaled("PageHeight", modelAttr.getPageHeight(), pagesXmlDoc));
|
||||
pageSheet.appendChild(createCellElem("PageScale", modelAttr.getPageScale(), pagesXmlDoc));
|
||||
pageSheet.appendChild(createCellElem("DrawingScale", 1, pagesXmlDoc));
|
||||
|
||||
Element relE = pagesXmlDoc.createElement("Rel");
|
||||
relE.setAttribute("r:id", "rId" + i);
|
||||
|
||||
pageE.appendChild(pageSheet);
|
||||
pageE.appendChild(relE);
|
||||
pagesRoot.appendChild(pageE);
|
||||
|
||||
Element relationship = pagesRelsXmlDoc.createElement("Relationship");
|
||||
relationship.setAttribute("Id", "rId" + i);
|
||||
relationship.setAttribute("Type", PAGES_TYPE);
|
||||
relationship.setAttribute("Target", pageName);
|
||||
pagesRelsRoot.appendChild(relationship);
|
||||
|
||||
//Note:Each page rels is created with the skeleton as they are constants
|
||||
|
||||
//write the page docs
|
||||
Document xmlDoc = pair.getValue();
|
||||
writeXmlDoc2Zip(zip, VISIO_PAGES + pageName, xmlDoc);
|
||||
i++;
|
||||
}
|
||||
|
||||
pagesXmlDoc.appendChild(pagesRoot);
|
||||
pagesRelsXmlDoc.appendChild(pagesRelsRoot);
|
||||
writeXmlDoc2Zip(zip, VISIO_PAGES + "pages.xml", pagesXmlDoc);
|
||||
writeXmlDoc2Zip(zip, VISIO_PAGES + "_rels/pages.xml.rels", pagesRelsXmlDoc);
|
||||
}
|
||||
|
||||
private void writeXmlDoc2Zip(ZipOutputStream zip, String name, Document xmlDoc)
|
||||
throws IOException, UnsupportedEncodingException, TransformerConfigurationException,
|
||||
TransformerFactoryConfigurationError, TransformerException {
|
||||
zip.putNextEntry(new ZipEntry(name));
|
||||
|
||||
Source source = new DOMSource(xmlDoc);
|
||||
StreamResult result = new StreamResult(new OutputStreamWriter(zip, VSDX_ENC));
|
||||
Transformer xformer = TransformerFactory.newInstance().newTransformer();
|
||||
xformer.transform(source, result);
|
||||
}
|
||||
|
||||
private Element createCellElemScaled(String name, double val, Document xmlDoc)
|
||||
{
|
||||
return createCellElem(name, val / mxVsdxUtils.conversionFactor, xmlDoc);
|
||||
}
|
||||
|
||||
private Element createCellElem(String name, double val, Document xmlDoc)
|
||||
{
|
||||
Element cell = xmlDoc.createElement("Cell");
|
||||
cell.setAttribute("N", name);
|
||||
cell.setAttribute("V", String.valueOf(val));
|
||||
return cell;
|
||||
}
|
||||
|
||||
protected Element createRow(String type, String index, double x, double y, Document xmlDoc)
|
||||
{
|
||||
Element row = xmlDoc.createElement("Row");
|
||||
row.setAttribute("T", type);
|
||||
row.setAttribute("IX", index);
|
||||
row.appendChild(createCellElem("X", x, xmlDoc));
|
||||
row.appendChild(createCellElem("Y", y, xmlDoc));
|
||||
return row;
|
||||
}
|
||||
|
||||
private Element createGeoElem(mxCell cell, Document xmlDoc)
|
||||
{
|
||||
Element geoSec = xmlDoc.createElement("Section");
|
||||
|
||||
geoSec.setAttribute("N", "Geometry");
|
||||
geoSec.setAttribute("IX", "0");
|
||||
|
||||
//now just create a rectangle
|
||||
geoSec.appendChild(createRow("MoveTo", "1", 0, 0, xmlDoc));
|
||||
geoSec.appendChild(createRow("RelLineTo", "2", 1, 0, xmlDoc));
|
||||
geoSec.appendChild(createRow("RelLineTo", "3", 1, 1, xmlDoc));
|
||||
geoSec.appendChild(createRow("RelLineTo", "4", 0, 1, xmlDoc));
|
||||
geoSec.appendChild(createRow("RelLineTo", "5", 0, 0, xmlDoc));
|
||||
|
||||
return geoSec;
|
||||
}
|
||||
|
||||
private Element convertMxCell2Shape(mxCell cell, mxGraphModel model, Document xmlDoc, double parentHeight)
|
||||
{
|
||||
mxGeometry geo = model.getGeometry(cell);
|
||||
|
||||
if (geo != null)
|
||||
{
|
||||
Element shape = xmlDoc.createElement("Shape");
|
||||
|
||||
shape.setAttribute("ID", cell.getId());
|
||||
shape.setAttribute("NameU", "NotYet");
|
||||
shape.setAttribute("Type", "Shape");
|
||||
|
||||
double hw = geo.getWidth()/2, hh = geo.getHeight()/2;
|
||||
|
||||
shape.appendChild(createCellElemScaled("PinX", geo.getX() + hw, xmlDoc));
|
||||
shape.appendChild(createCellElemScaled("PinY", parentHeight - geo.getY() - hh, xmlDoc));
|
||||
shape.appendChild(createCellElemScaled("Width", geo.getWidth(), xmlDoc));
|
||||
shape.appendChild(createCellElemScaled("Height", geo.getHeight(), xmlDoc));
|
||||
shape.appendChild(createCellElemScaled("LocPinX", hw, xmlDoc));
|
||||
shape.appendChild(createCellElemScaled("LocPinY", hh, xmlDoc));
|
||||
|
||||
shape.appendChild(createGeoElem(cell, xmlDoc));
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Document convertMxModel2Page(DocumentBuilder docBuilder, mxGraphModel model, String name, ModelExtAttrib modelAttrib)
|
||||
{
|
||||
Document xmlDoc = docBuilder.newDocument();
|
||||
|
||||
Element root = xmlDoc.createElement("PageContents");
|
||||
root.setAttribute("xmlns", XMLNS);
|
||||
root.setAttribute("xmlns:r", XMLNS_R);
|
||||
root.setAttribute("xml:space", XML_SPACE);
|
||||
|
||||
Element shapes = xmlDoc.createElement("Shapes");
|
||||
root.appendChild(shapes);
|
||||
|
||||
mxGraph graph = new mxGraphHeadless(model);
|
||||
Object defParent = graph.getDefaultParent();
|
||||
|
||||
for (Object c : model.getCells().values())
|
||||
{
|
||||
//top-most cells
|
||||
if (model.getParent(c) == defParent)
|
||||
{
|
||||
Element shape = convertMxCell2Shape((mxCell) c, model, xmlDoc, modelAttrib.getPageHeight());
|
||||
|
||||
if (shape != null)
|
||||
shapes.appendChild(shape);
|
||||
}
|
||||
}
|
||||
|
||||
xmlDoc.appendChild(root);
|
||||
return xmlDoc;
|
||||
}
|
||||
|
||||
// public static void main(String[] args)
|
||||
// {
|
||||
// try {
|
||||
// String mxFileXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><mxfile><diagram name=\"Page-1\">7ZZbk5owFMc/DTPtixPC/VG87G697Ky43t4CREgFwkAE3E/fIFGhzs5uO+1Lpzij8sv/5JCT849KyiCuHjKUhjPq40iCwK8kZShBKMtA5x81OTVEM60GBBnxhegGHPKGBQSCHomP846QURoxknahR5MEe6zDUJbRsivb06ibNUUBvgOOh6J7uiY+C6/rAreBR0yCUKQ2NTHgIu8QZPSYiHwSVPbnqxmO0XWuBuQh8mnZoPMUykgCfan+DiRlkFHKOugyEFcDHNU1v5SzyT/+nPi6vAwn7DfioXh4droULMiQT/hkAxrR7IwURTFN1ZUUe0+iqMVVzdV1lfMi96unIYcyv4mQiyP7Wr2LPqEJz2DzMqV1ppzhxCPRl2I1tod0Fowey/miohPzZbPmTx/Pl6vTOtqGO2Tt8Xg6cR/SiRcXnvL81lfdRRrow+EgBIN0ZPK+cRf549bRBugtf3aG2/jbqPy+nMtamRqmBystIX1jpmTqCmhbPJKg7a/mxgId1xqkQXZUx0cHLYnMVnHKk2+exjO222/lV6Iux/bhwANesgV/n9q41KitR88HDS4T6lS76fYVeX6xKGweaShF/4XrNpa10wyiFRs9n0RjL4cJ/lqvnmX0gFsl5IZyFViPpMgjSTDF+3obQQ9A0Llk8yayKWM0/lC2EF39jipkcSS2TAQsafq+/LyZuG4b3kh2GRKGHR5W72XJj47r4i4uk3sW0Di9b1DRswXOGK5a6L5hb237gGmMWXbi95cQaDTznC4HjtzTrNYl0pQ312vAbFjYMrxhGj1VnDfirAmuyd41Ut2ijZc+ZTPlQ5sJe/zkMAMgXzXaDoP/HfZrDrPOr3/RYaCnK3/TYYYs92DHYzqwuh67s1jtQv3eZFDXe8YfMtmZt35Oha71/+XMfwA=</diagram><diagram name=\"Page-2\">nZTbkqIwEIafhqrdGwuIEbwUlJldD1Mjjqe7CAGyBkKFCDhPv0HigbWmdmtzofD132nS6W4NuGn9wlGezFmIqWbqYa2BsWaahqEP5F9Dzi2B9rAFMSehEt2BTz6xgrqiJxLioiMUjFFB8i4MWJbhQHQY4pxVXVnEaDdqjmL8BPwA0We6IaFIbufS74ZXTOJEhbahMhxQcIw5O2UqnmaC6LJac4pue7WgSFDIqhZdtgATTR9pzbOuAZczJjroakhrF9Mm59d0tvG9fxPfjsdxJv7D31QfL87XhMUchURu5jLKuEQZy6TFiQilVyRTcQBRKFMBnLII6x9jCQ35QtEBU+eWuD+2kBnKmyCFwFlA6Ldy7TljNo8nr9ViWbOp/b7dyA9PF6v1eUN3yR4NI+zNpoeXfBqkZQDePkf9wzKPB+Oxm+huPrFlyRyWxevOhy76LN788S79Oal+rRYGrHLLDswaZmRkzQHvr3W4wxPNdML1wlqi0waaLOanvnfy0YoYYp3mMvj2hzcX+2hnfJD+ynOOR+nwzpfyd+bgCjJnQN+O0FxlzK/3s90HCsJyWTrS0wLl6F3qtsPhHloElttBMaVeUJgZ/t6cXnB2xA8pBBjacNhYchSQLJ7hqLlBvaebemcZ9l3kMCFY+lfZUhX0F6pEpFRdmXJYsfxr+eUycVMxsoacKiEC+9KtuctKTo3b4a4NZvSgbUGJn4tT1WuJucD1A3ou1nvJvmCWYsHP8v3qYlk9u91JjSUDmj0wfFjKXN17HkDYU8MseWh4s2/0gJo3atbEt4BfNlJTp20vddtc8odOV7qH0XrhvwE=</diagram><diagram name=\"Page-3\">7VhZc6pIFP41Vs08jNWs4qMgCmJwwS2+ITTQgjQiCvjrp1GMEuNNcm9y52EuVZb0x1n6LN9hqTHSJuvGZuQ9YRsGNRrYWY1p12iaEliG/BVIfkaaAn0G3BjZpdAVMNARliAo0T2y4a4imGAcJCiqghYOQ2glFcyMY5xWxRwcVL1GpgvvAMMyg3t0juzEK1EKgOsFBSLXK10LXHlhZVq+G+N9WPqr0YxzOs6XN+aLrTOw80wbp2foZIKRa6BVK85BjZFijJMKdLmwySQYFDm/pPPsv/Mx4ZfwYhgmP6FfFnOX5JeEubFpI2JMwgGOCRTikFwRHRQEr6DDzs7UNllTZBGYKxiILzl7JbpLYuzD12BkWih0+9Apdv4PXQdNtnlzCFcZEScJ3rwnNS7L+EOhCY4einjJJijjOUUBiyyRvImphxJoEANFklLClJeYLk1F1Rs8Ae/LUVboAOMEZjfQfXmuRepCvIFJnJN1qUIas87dbrdxNluyssHXqdtYyrKm147naFAvdbybdqd5UGe4km4l1dwX7w/7iOBlK32oy5if6TJCOAbwvMXcthr9fqt5ZlQ42SUwtFDw1/Q4o/s7Tu3L3kyfqLiPQu0I2OQI0iiftSg7kKmnXfyUAzfJUSruAkNfzOZ6aA9zRPUniMTa6wuU6pITtSf7Mh5pZMrRnXZ3LIlTw3GXrGioNVocj4zplklpNJCsYxtsMm2kzAiuAlqX2rrVOlLbp+d11JXNiewfFQpwviqrvanbUoW95+XeSBLVVbZlW3/fkYakg6ZYpmH9fubc0OIDJPoy5tC/xpySGjxXBwK4HtRHqUExoE4J300N9suowXyaGsms329jNZWHualsQjP2XBIvqUQHDccuBjN/O98e1kwnsRR52PUTet7dQMr3hC4fL8brjdhLRoqQdri9gnbdrjZfxPm2pVtzLV2uWvthDxvEmBkO+NVhTM6W5Ne0h5OQ2crrcGxIiOKDrDcf6a1+vt5nKlZkZ75Ie67U7LmtZicKPQ1trXgiA8VsRLLdWOqgZdmxRvbZcxqdwTO9MfZtNQol1ul1lCRbehvCJsjP06bRnhdVojvhYDO2nhcsyIxlkOtPPmg6WVM9tqC0h+CoUz0rRkvF97I5Bm1nciDWQ01YeAtrIg18q6kc+hPWN1WjGAKr7uk2z7T/kPSXSVqqNKk6Rd+QlLkjKcMIdZb/r25g3JexlP80S8OlMpax6spy0c2eb1miMuMTco6HvaC7lHr5DBzIHBFNzbfC+cZkomXjSE8XAfb4xmDuSl24Fhl77tOcMBEMaGlcEoN2Yyp2MlXr7RXTHTD6lIYi5/e6OmWtbDZlc07bESeaun1m9/zAeOLMLGL6sqt3aHmBls6JgiwEqUYdJW2BRlZf6SM3ygzlyDUODkmA2PQKNUXacf2Yo/S+LR/lddQZgaHZJQ2rdeJ1pBupbw9U7KwF29zr6WxaBOfM9i4eNzrPlvKHZ/8XnvHf+fzMVx6ZKZaq08JNufjvDq7xXcFRdPVtgOGZOsf8ztCEu/n4MvAapJ1hePkyQB7GHg/A6yt2QQszTlrFB4CbF06SJkRe7VsBckMCb5BtF/4K+xfRVYAt/615QTU5brW6mxegDm4JUTwgvjUwHokVu6yE9mqGPNCDtguNMlllcI/mygML1cHyeojQp6xnKFmcLZSr58pqCGNE+gDGpRHSlXF+o1Asn6vLqsqjdt7hfWzBCqNJnlyYVHhQ5ODzLR/DwEzQofp1563GfmTvYpU0jJnf6EYYhcnufc3rroaFxk+MmLcY9yEPr3l+st/8Wpun2cF+yOZpSpzT+J7g1W3phvQUuLlZChTN0tVaYsfZkY758UbKQfXSHx8fZSf85qPcxdL1K+gJ/xc=</diagram></mxfile>";
|
||||
// //"<?xml version=\"1.0\" encoding=\"UTF-8\"?><mxfile><diagram name=\"Page-1\">7VhZk6JIEP41Ruw+jFEUp4+CKFfjgVf7hlAcghQiCvjrt1C7G7XdmZ7Y2d2HIcKIyqzKrDy+ryhs0dK2HGR2GrxgF8UtCPZ5FaMW3WtB6CLPPsT5t7MKEkWLllu0lGGcX0bbUkJxbRS6FwtQL4L9J7PUeRakdoaS/EcM4KPB1UcjSj+z3ZDMSzjGGVElOCEzohfG8Z3quHdLtUdkigixvUaxaDuRn+FD4t4t3ecZjtC9MrWdMPEN5NXBfINt0GE6jUf4WCPiPMfb762ahH7wXVdTnD5dEuTb+JrPOQtUFw4QqQjCHFnEQV2kgvT3PadF6OZBbdPmOaK8lPOIshyVjQpf+zFAeIvyrCJL7P213O+q2jBA1xTqbnGgTbMXfXHdhUgsBG3+or3uAKHQZpupXKeryzTPtalmnrCJETK4wuRzyNCPkIE/A5kWpGnAcQ7dxA38Pm4CO6032ecoccL4j9lpDo09qxpyMDenKjbCRD8BJj+BIq3mXcqNZepln71UwM+rsBD3sWUu5wszcUdVSBnTkOSrGQKl+mSganIk47F+QkToDSaSOLM8f8WIltqC4mRszXZ0AcOh5Jx6YFvqY2VO9CqAptQzne6J2r28btKBbE/l6KRQgI1UWdVmflcVDkFQBWNJVNfljun++cAAUg5IMTTv/Ps0aGD8Bxjx39OAokGbEv6OBlecc2wbCODjob6Cc+ZX4pz+Ms7zuWH0sFrIo8pWtomdBT4pASlrPxxNfAzm0W6xO27ofu4o8mgQ5XAx2CIqCoQBly0nm62o5WNFKPrsQQn3g4G+WGbVrms6C71YrbuHkYYt4sxOhtz6OCGjFfl13NE0oXfyJplYUkhxcaktxmbXqDaHUsWK7C2WheZLHc3vdvppEujhzsmmMlBsPpVdfmWCruNmOolT8/j+8BVurUNPTROJ8bS+kperYEuogbhF0bF6i7o1sJ8MtxPndcmA0lrFlfkSgY5XdtRTF0kHBE4mpTlZuFKioFxg0POmR+I90YVlsHSm0jByOsrRmDKRrVo1o9eDou4B3fvNuH/+xUPTQpvhbt48HapNwQbl6K9Qjv2VlOO+TLlkpUxkrPqyXEMziBxHVOZcTsZ4pMWDlaRVc3Ak54Ro65GTLLY2na74E5wtYxxw/HDhSwO0EWl3EUFWmAoWcnQ2z0CPn4n9UtW1g2L7Q9qcQSSykTYwKWftMgVTsfqebKKru1fmwA2tF9YuU9qQfbMP5WW48s58YhAodOok6ctw7BiKEfppaSknlj96pABiJ6jNFGnPGhlLmYYrn+RN2h+DkT0g6NP72SY1rSJyhyr2NoJrH8xiPquT8+YHH0/4/quj/CbN/5803NMr/E9n0bhFcjcvVIqh2lBoVJr7SqT8L4uUgnwb3ERKc3Sbpb8aKXJ9dBPYW+jC8+8kfMgcdNOKxmH1fvrwBFsoca3wVM+Qe8nz04hQzDs/Z4zaWd7NMlw0PrJIsULHjrtx6CdEvQ1dt96v9v+2dB1jJ/qMvFSHZdfrB/KCNmgCsL4rfcbeZ8vqKG9SuyP0E7u63Na1WNfknpH8iYdblt8zGp6rXob58uLhKr3eSCOUhQRRKLs6IQ3OqoZBLb7eircm556TCvgob+D8RxGcodjOw2MTdmdT0km7aZXiMMn3Dc+jWvHzZH1w8Mihs4POF43OxGPuyHZJ5s7FW2bY8/akdE0npNagcaILFGQev1HfS/sZpYn48S/KZfnHfzC0/Bc=</diagram><diagram name=\"Page-2\">jVPbcpswEP0aZtqHMiBZBj+am5P6NsHENn6TQVxqgRiQAefrKwxOaDtpqwcNe3bPrpY9K0EzaxclLpI1CwmVgFLxGyUStCQAQhLhK+Xf7hAQgARtCZolY7z/ylqT0I6Uhj1D6YKA84lXvXuVApck5/9DAH8ShhyjV8YlDlPhNxllpYBylguPEaWUPiAJwDOMwigSeF2F7bMlQFUYFJ8JNXBwiUt2zcPfUlQJLroiFSd5kNIv9d4xLLaO7adm47Zsqb8cD+Lx2cbb3w7UT054FhFntTwvimWQ1QHcvs0nZ7eIp5ZlJopZ2HpOgrNbPfk7ZOK3aruz/Oy73fzwNipqCk0PQIvydK6tYTnZK8gntgSMcL/RXHw9IMDi8jpxrjvspSrfZ4Uofnx21vwU+eprOvEc43IRhJfSFffKIA1ixpRuLwh4Odu1p5X/ioOwdmtDMDVYz19E3HE2OyEtRfVxWi2pE1QgJ1+77nnJLmT0CyFBOpp1ngIHaR6vSNQNRZEVoPxyVP0jyGCcs+yfYW4aJ39JlvCMDiMbCB4rPg+/D5N0IlKE1SQpJztB62bZCK2/N3dIQ550eWWka0jAvbhqUnLSjvQ2qHNBWEZ4eRMhuBrE9w51xIQMbXTanagy7OFmKCMsiJA87dFHAU2T9R65DQgCMpyNjj5ekk5w/Z48zI99vPtG2wztnw==</diagram><diagram name=\"Page-3\">7VVdb5swFP01SNvDkLExkMdCQtvloypJ8/VmwAEWgxE4QPrraxLaknXtPrSnaSAh7rn3+HLxObKCnLS5LkgeT3lImQJBKY6MKmioQBjSHTkw8eUEQQkoaKQgp+BcnN/SxqGsJSXhmQHaIui+k9VOWZCTgmbiVwjwLaFbo/eVUUHCROYdznhxghBClqX7CrJ3CWM9XMe+YegSr8qwuR1KUJMBIz5lNgn2UcEPWfhcn/FMdrDLmORtp1LQLEjYp2rp2kM+jUY39cxr+Ni6X6/kBOlssTyu2CbeksGOupOxf52Pg7QK0N3jle57eWQMh04MnHxkZTTwvfJmM8cOeSzv5sNN+nVUf1vMNFznphXABmfJlTlFhb4EeENHCrTD5cz0yGGFIY+Kg+4e5mSRaGKZ5rL5+tadiu1uoz0k+sK193tJuC88+ZzYtMbcNtjdHsNFxufNdrJ5IEFYeZUtmSaqru5l3Xow2GIzwdXaKMfMDUqY0c/t9KLge9r7hRBiH8E2k5MgyaIJ3bU7A1QAwcWlWa9FNheCpz8t85Io/mCxWKSs27KOsOD5++WnzaStkoCM6jgRdC5p7V7WUvAvw62SUMTtuuoAYImeBVbRQtCmp7lOodeUp1QUR1lCyk6AL1BLjGk3hQxNy1T1M1x3XWSEgaWedQ+eG0DzGTl2CNBUPOhdWt8ord7OXvmxb9Cf+KbT+3eWMQEJdbNvGfjfMr9nmcHp/hctA1QD/WXLQMNQzTeWae1gXFjG1DQVXljGAINLy3zgGBm+nmKnXO8MRKMn</diagram></mxfile>";
|
||||
// //"<?xml version=\"1.0\" encoding=\"UTF-8\"?><mxfile><diagram name=\"Page-1\">3ZZZs6JGFMc/za1KHnKLfXkEAUFARAWFN5Zm33f89Gm8zuROMpOkUqk8BAW7/6fP6fX85A3flcu+85pEr0NQvGFIP6wFeMOFNwwLQeSNxfDLU8Kg8IaLb/iuq+vho1QuO1BsTmn44YFsjTDpB1b0aUUarwPV8HccsD86vGJ8GmXceWEK7bu6qDsoVXUFLXyUFsUX6Q3DSZ/1QxLqUx8uigBFFFa8Io0rWA6gP4At+cLzQcF7QR539ViFv4vZJ16z9doPoArS4qfFjvy86WfhhHhyaywH6Q3jo4Gd4JQcrc4dt91nokFjNNQnCz1eS7Ng1W52L46XYaRUQ92w4cMv2dCEv5uwjFLHshSMkQGwPz1sERaje7DcSb0h3GiPE6TQifQCZJq9wBWUcLaVSXBC/ChbgH6UpzZIEEO/tC7rOpxSs+i0GuGIM9Z0WfoKmEFWBv5B5ptGzIlcTmCvqv3YC7orH+oTjNjRiklmBiz5whH0dquu7HCSLTlUZIEJNUC21u0ORy7RdOffsQMjJOKgHsx4tTSTS82M3x1NpbG7khKQWbLqW2jVgqPiXGsJdYzySpKOTIJyTmcCru8vXNcX59jrdemguvbtyvkP/VifQqE8OiRfHw0uX4z97pAHaCCwfY6t1NX3Zt3d7bk1MClG6rFh9ru2nKvcDQrK4ps41B4VHOMycZla9L3icLs7rAOBW3NR5JMRmcXGw7RoyeZg9K4SemEjD4ujc3y1b2fQEPA4SuQSw+dcZEb/yNhjEmlV7sGtlrDHzRlb/WjpqMcYN7iK8HtDcHdiKftKc0KRnpSbJ9/4WbFPkxg+WiM0DuZhCbJhVr26uw/VDg+sjrfo6SF2F9ViuSATH3xzjgKqHU/xeTUIRqDsoxLu+KwtTgEIkGoRb6mnsIdJOsAuO31YdZXRBs0FnoY6Gv2IHCDZV7xciT5BWpk952m2nZRJ6LR5Swlc+HnLBtANaeAV3CsRyjQMi+dRH7o6B58SiH1+NkvjBWkVayDaUhJ5RzDkmwtlfmvE18NQl3/Z7JzGyZ8ES4ayeCXsy+FaNz9u/sxcsCEEgbU5SQdwgW5b4s6QdF8nd0vDIXmGoaH2wZXJK8YXV14CXCCwfGLPi1R7UJdg6FbYxOtfIPoqbY4JeE0KVgkWfUfoD31+9QprNE69Ux/qlx4o8h1hP10vp/XFQ4x5J9lP88U/4xMWXgT9Pk3xf0JTuPNU4LNR9EekRiCKnvpXpGL/HUHJPOVliWSyfUWRFTv4KLmjMlwmsA7H/Q2rJGExR+vOsCEtRghVJShkZ5af+mslE1GFa9O2dIMCH4cFOmQ+A7RHojxguVJCIVPszdYzomgZFE7eDeMZ904q6HVSDHOGNd3K5hkpPccUZlpSyYovd1WOyDTCInqwVH6fYBOmooILsCprr2N+esyBBj3RJij9DUY+3vkQUrzLXAuIUN6MU1MzzXFDqG4qhSUPvdiYYLz0ZXsuc3PirVo+88OO1/jgeJ84Xs3YM+9kieBoV3F1lNvZSseuNB+x6wcuLTvOTGl3T+cPqS7yF2LpyapymqHAsNuSuRdR46w5QWs5YqpD16t0G2YH0nAVo+Cd+hTBUTbwXp3YWvsu4ySTqRlZmXtX2guOkB6T0fekaF0Iwz01RXHGATvsQLcryzxmPSaHzhKYtz21VvlmUdtfDLhdUD8jKiwf2v4AEXqBotr5QGPtbbulc2GNM9dYZ3JHXyjT4NIDS2dBm1WXi7UL7godqGWropU7D0ihzrZBM4uqp8XJlJVFnz3rjoytM7S5aJyxIjZcC0kQZT+2FouS2gXkZ+9YC6sN9lfY3c29lg46295tZRCNhRDFXQcc7WvVzoSe4O2VPOdrw8A0kk619vP3IEkQNMFG/0dIQoBRv1Hy34AiiqBf6PeJiSiJvRPfMJFgyXf8GwwSGPlOkH+Cvu0F5utL6tP26RUXF38F</diagram></mxfile>";
|
||||
//
|
||||
// FileOutputStream fileWriter = null;
|
||||
// fileWriter = new FileOutputStream("g:/work/test.vsdx");
|
||||
//
|
||||
// new mxVsdxExporter().exportMxFile(mxFileXML, fileWriter);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
}
|
|
@ -1,142 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.geometry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import com.mxgraph.io.vsdx.mxVsdxUtils;
|
||||
|
||||
public class RowFactory
|
||||
{
|
||||
private static int getIndex(Element elem)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Integer.parseInt(elem.getAttribute("IX"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//Some non-standard visio file omit the index when it is one
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private static Double getDoubleVal(String val)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (val != null && !val.isEmpty())
|
||||
{
|
||||
return Double.valueOf(val);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//nothing
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Row getRowObj(Element elem, List<Row> pRows)
|
||||
{
|
||||
String rowType = elem.getAttribute("T");
|
||||
int index = getIndex(elem);
|
||||
String del = elem.getAttribute("Del");
|
||||
if (!del.equals("1"))
|
||||
{
|
||||
Row parentObj = null;
|
||||
|
||||
if (index <= pRows.size())
|
||||
{
|
||||
parentObj = pRows.get(index - 1);
|
||||
}
|
||||
|
||||
Double x = null, y = null, a = null, b = null, c = null, d = null;
|
||||
String formulaE = null, formulaA = null;
|
||||
|
||||
if (parentObj != null)
|
||||
{
|
||||
x = parentObj.getX();
|
||||
y = parentObj.getY();
|
||||
a = parentObj.getA();
|
||||
b = parentObj.getB();
|
||||
c = parentObj.getC();
|
||||
d = parentObj.getD();
|
||||
formulaA = parentObj.getFormulaA();
|
||||
formulaE = parentObj.getFormulaE();
|
||||
}
|
||||
|
||||
ArrayList<Element> cells = mxVsdxUtils.getDirectChildElements(elem);
|
||||
|
||||
for (Element cell : cells)
|
||||
{
|
||||
String name = cell.getAttribute("N");
|
||||
String val = cell.getAttribute("V");
|
||||
|
||||
switch (name)
|
||||
{
|
||||
case "X":
|
||||
x = getDoubleVal(val);
|
||||
break;
|
||||
case "Y":
|
||||
y = getDoubleVal(val);
|
||||
break;
|
||||
case "A":
|
||||
a = getDoubleVal(val);
|
||||
//TODO check the reason for this
|
||||
//Special case for PolylineTo where we need the F attribute instead of V
|
||||
formulaA = cell.getAttribute("V");
|
||||
break;
|
||||
case "B":
|
||||
b = getDoubleVal(val);
|
||||
break;
|
||||
case "C":
|
||||
c = getDoubleVal(val);
|
||||
break;
|
||||
case "D":
|
||||
d = getDoubleVal(val);
|
||||
break;
|
||||
case "E":
|
||||
formulaE = val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (rowType)
|
||||
{
|
||||
case "MoveTo":
|
||||
return new MoveTo(index, x, y);
|
||||
case "LineTo":
|
||||
return new LineTo(index, x, y);
|
||||
case "ArcTo":
|
||||
return new ArcTo(index, x, y, a);
|
||||
case "Ellipse":
|
||||
return new Ellipse(index, x, y, a, b, c, d);
|
||||
case "EllipticalArcTo":
|
||||
return new EllipticalArcTo(index, x, y, a, b, c, d);
|
||||
case "InfiniteLine":
|
||||
return new InfiniteLine(index, x, y, a, b);
|
||||
case "NURBSTo":
|
||||
return new NURBSTo(index, x, y, a, b, c, d, formulaE);
|
||||
case "PolylineTo":
|
||||
return new PolylineTo(index, x, y, formulaA);
|
||||
case "RelCubBezTo":
|
||||
return new RelCubBezTo(index, x, y, a, b, c, d);
|
||||
case "RelEllipticalArcTo":
|
||||
return new RelEllipticalArcTo(index, x, y, a, b, c, d);
|
||||
case "RelLineTo":
|
||||
return new RelLineTo(index, x, y);
|
||||
case "RelMoveTo":
|
||||
return new RelMoveTo(index, x, y);
|
||||
case "RelQuadBezTo":
|
||||
return new RelQuadBezTo(index, x, y, a, b);
|
||||
case "SplineKnot":
|
||||
return new SplineKnot(index, x, y, a);
|
||||
case "SplineStart":
|
||||
return new SplineStart(index, x, y, a, b, c, d);
|
||||
}
|
||||
}
|
||||
return new DelRow(index);
|
||||
}
|
||||
}
|
|
@ -1,163 +0,0 @@
|
|||
package com.mxgraph.io.vsdx;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
/**
|
||||
* This is a singleton class that stores various global properties to document.<br/>
|
||||
* The properties are:
|
||||
* <ul>
|
||||
* <li>
|
||||
* document's colors
|
||||
* </li>
|
||||
* <li>
|
||||
* document's fonts
|
||||
* </li>
|
||||
* <li>
|
||||
* default text style
|
||||
* </li>
|
||||
* <li>
|
||||
* default line style
|
||||
* </li>
|
||||
* <li>
|
||||
* default fill style
|
||||
* </li>
|
||||
* </ul>
|
||||
*/
|
||||
public class mxPropertiesManager
|
||||
{
|
||||
/**
|
||||
* Map with the document's colors.<br/>
|
||||
* The key is the index number and the value is the hex representation of the color.
|
||||
*/
|
||||
private HashMap<String, String> colorElementMap = new HashMap<String, String>();
|
||||
|
||||
/**
|
||||
* Map with the document's fonts.<br/>
|
||||
* The key is the ID and the value is the name of the font.
|
||||
*/
|
||||
private HashMap<String, String> fontElementMap = new HashMap<String, String>();
|
||||
|
||||
/**
|
||||
* Best guess at default colors if 0-23 are missing in the document (seems to always be the case for vsdx)
|
||||
*/
|
||||
private static final Map<String, String> defaultColors = new HashMap<String, String>();
|
||||
|
||||
static
|
||||
{
|
||||
defaultColors.put("0", "#000000");
|
||||
defaultColors.put("1", "#FFFFFF");
|
||||
defaultColors.put("2", "#FF0000");
|
||||
defaultColors.put("3", "#00FF00");
|
||||
defaultColors.put("4", "#0000FF");
|
||||
defaultColors.put("5", "#FFFF00");
|
||||
defaultColors.put("6", "#FF00FF");
|
||||
defaultColors.put("7", "#00FFFF");
|
||||
defaultColors.put("8", "#800000");
|
||||
defaultColors.put("9", "#008000");
|
||||
defaultColors.put("10", "#000080");
|
||||
defaultColors.put("11", "#808000");
|
||||
defaultColors.put("12", "#800080");
|
||||
defaultColors.put("13", "#008080");
|
||||
defaultColors.put("14", "#C0C0C0");
|
||||
defaultColors.put("15", "#E6E6E6");
|
||||
defaultColors.put("16", "#CDCDCD");
|
||||
defaultColors.put("17", "#B3B3B3");
|
||||
defaultColors.put("18", "#9A9A9A");
|
||||
defaultColors.put("19", "#808080");
|
||||
defaultColors.put("20", "#666666");
|
||||
defaultColors.put("21", "#4D4D4D");
|
||||
defaultColors.put("22", "#333333");
|
||||
defaultColors.put("23", "#1A1A1A");
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the properties of the document.
|
||||
* @param doc Document with the properties.
|
||||
*/
|
||||
public void initialise(Element elem, mxVsdxModel model)
|
||||
{
|
||||
//Loads the colors
|
||||
if (elem != null)
|
||||
{
|
||||
NodeList vdxColors = elem.getElementsByTagName(mxVsdxConstants.COLORS);
|
||||
|
||||
if (vdxColors.getLength() > 0)
|
||||
{
|
||||
Element colors = (Element) vdxColors.item(0);
|
||||
NodeList colorList = colors.getElementsByTagName(mxVsdxConstants.COLOR_ENTRY);
|
||||
int colorLength = colorList.getLength();
|
||||
|
||||
for (int i = 0; i < colorLength; i++)
|
||||
{
|
||||
Element color = (Element) colorList.item(i);
|
||||
String colorId = color.getAttribute(mxVsdxConstants.INDEX);
|
||||
String colorValue = color.getAttribute(mxVsdxConstants.RGB);
|
||||
colorElementMap.put(colorId, colorValue);
|
||||
}
|
||||
}
|
||||
|
||||
//Loads the fonts
|
||||
NodeList vdxFonts = elem.getElementsByTagName(mxVsdxConstants.FACE_NAMES);
|
||||
|
||||
if (vdxFonts.getLength() > 0)
|
||||
{
|
||||
Element fonts = (Element) vdxFonts.item(0);
|
||||
NodeList fontList = fonts.getElementsByTagName(mxVsdxConstants.FACE_NAME);
|
||||
int fontLength = fontList.getLength();
|
||||
|
||||
for (int i = 0; i < fontLength; i++)
|
||||
{
|
||||
Element font = (Element) fontList.item(i);
|
||||
String fontId = font.getAttribute(mxVsdxConstants.ID);
|
||||
String fontValue = font.getAttribute(mxVsdxConstants.FONT_NAME);
|
||||
fontElementMap.put(fontId, fontValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the color of index indicated in 'ix'.
|
||||
* @param ix Index of the color.
|
||||
* @return Hexadecimal representation of the color.
|
||||
*/
|
||||
public String getColor(String ix)
|
||||
{
|
||||
String color = colorElementMap.get(ix);
|
||||
|
||||
if (color == null)
|
||||
{
|
||||
color = mxPropertiesManager.defaultColors.get(ix);
|
||||
|
||||
if (color == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the font of id indicated in 'id'
|
||||
* @param id font's ID
|
||||
* @return Name of the font.
|
||||
*/
|
||||
public String getFont(String id)
|
||||
{
|
||||
String font = fontElementMap.get(id);
|
||||
|
||||
if (font == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return font;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2006-2016, JGraph Ltd
|
||||
* Copyright (c) 2006-2016, Gaudenz Alder
|
||||
*/
|
||||
package com.mxgraph.io.vsdx;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Wrapper for connect element
|
||||
* See https://msdn.microsoft.com/en-us/library/office/ff768299%28v=office.14%29.aspx
|
||||
*
|
||||
*/
|
||||
public class mxVsdxConnect
|
||||
{
|
||||
protected Element endShape;
|
||||
|
||||
/**
|
||||
* ID of edge
|
||||
*/
|
||||
protected Integer fromSheet = null;
|
||||
|
||||
/**
|
||||
* ID of source
|
||||
*/
|
||||
protected Integer sourceToSheet = null;
|
||||
|
||||
/**
|
||||
* Where connection is made to source
|
||||
*/
|
||||
protected Integer sourceToPart = -1;
|
||||
|
||||
/**
|
||||
* ID of target
|
||||
*/
|
||||
protected Integer targetToSheet = null;
|
||||
|
||||
/**
|
||||
* Where connection is made to target
|
||||
*/
|
||||
protected Integer targetToPart = -1;
|
||||
|
||||
protected String fromCell = null;
|
||||
|
||||
public mxVsdxConnect(Element connectElem)
|
||||
{
|
||||
String fromSheet = connectElem.getAttribute(mxVsdxConstants.FROM_SHEET);
|
||||
this.fromSheet = (fromSheet != null && !fromSheet.isEmpty()) ? Integer.valueOf(fromSheet) : -1;
|
||||
|
||||
String fromCell = connectElem.getAttribute(mxVsdxConstants.FROM_CELL);
|
||||
addFromCell(connectElem, fromCell);
|
||||
}
|
||||
|
||||
protected void addFromCell(Element connectElem, String fromCell)
|
||||
{
|
||||
String toSheet = connectElem.getAttribute(mxVsdxConstants.TO_SHEET);
|
||||
boolean source = true;
|
||||
|
||||
if (fromCell != null && fromCell.equals(mxVsdxConstants.BEGIN_X))
|
||||
{
|
||||
this.sourceToSheet = (toSheet != null && !toSheet.isEmpty()) ? Integer.valueOf(toSheet) : -1;
|
||||
source = true;
|
||||
}
|
||||
else if (fromCell != null && fromCell.equals(mxVsdxConstants.END_X))
|
||||
{
|
||||
this.targetToSheet = (toSheet != null && !toSheet.isEmpty()) ? Integer.valueOf(toSheet) : -1;
|
||||
source = false;
|
||||
}
|
||||
else if (this.sourceToSheet == null)
|
||||
{
|
||||
this.sourceToSheet = (toSheet != null && !toSheet.isEmpty()) ? Integer.valueOf(toSheet) : -1;
|
||||
source = true;
|
||||
}
|
||||
else if (this.targetToSheet == null)
|
||||
{
|
||||
this.targetToSheet = (toSheet != null && !toSheet.isEmpty()) ? Integer.valueOf(toSheet) : -1;
|
||||
source = false;
|
||||
}
|
||||
|
||||
findToPart(connectElem, source);
|
||||
}
|
||||
|
||||
protected void findToPart(Element connectElem, boolean source)
|
||||
{
|
||||
String toPartString = connectElem.getAttribute(mxVsdxConstants.TO_PART);
|
||||
Integer toPart = (toPartString != null && !toPartString.isEmpty()) ? Integer.valueOf(toPartString) : -1;
|
||||
|
||||
if (source)
|
||||
{
|
||||
sourceToPart = toPart;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetToPart = toPart;
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getFromSheet()
|
||||
{
|
||||
return this.fromSheet;
|
||||
}
|
||||
|
||||
public Integer getSourceToSheet()
|
||||
{
|
||||
return this.sourceToSheet;
|
||||
}
|
||||
|
||||
public Integer getTargetToSheet()
|
||||
{
|
||||
return this.targetToSheet;
|
||||
}
|
||||
|
||||
public Integer getSourceToPart()
|
||||
{
|
||||
return this.sourceToPart;
|
||||
}
|
||||
|
||||
public Integer getTargetToPart()
|
||||
{
|
||||
return this.targetToPart;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param connectElem
|
||||
*/
|
||||
public void addConnect(Element connectElem)
|
||||
{
|
||||
this.endShape = connectElem;
|
||||
String fromCell = connectElem.getAttribute(mxVsdxConstants.FROM_CELL);
|
||||
addFromCell(connectElem, fromCell);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,152 +0,0 @@
|
|||
package com.mxgraph.io.vsdx;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* This class contains constants used in the Import of .vdx documents.
|
||||
*/
|
||||
public class mxVsdxConstants
|
||||
{
|
||||
public static String ANGLE = "Angle";
|
||||
public static String ARC_TO = "ArcTo";
|
||||
public static String BACKGROUND = "Background";
|
||||
public static String BACK_PAGE = "BackPage";
|
||||
public static String BEGIN_ARROW = "BeginArrow";
|
||||
public static String BEGIN_ARROW_SIZE = "BeginArrowSize";
|
||||
public static String BEGIN_X = "BeginX";
|
||||
public static String BEGIN_Y = "BeginY";
|
||||
public static String BOTTOM_MARGIN = "BottomMargin";
|
||||
public static String BULLET = "Bullet";
|
||||
public static String CASE = "Case";
|
||||
public static String CHARACTER = "Character";
|
||||
public static String COLOR = "Color";
|
||||
public static String COLOR_ENTRY = "ColorEntry";
|
||||
public static String COLORS = "Colors";
|
||||
|
||||
/**
|
||||
* Specifies the color transparency used for characters in a text run.
|
||||
* The value is normalized such that a value of 1 corresponds to 100 percent.
|
||||
* A value of zero specifies that the color is completely opaque;
|
||||
* a value of one specifies that the color is completely transparent.
|
||||
*/
|
||||
public static String COLOR_TRANS = "ColorTrans";
|
||||
public static String CONNECT = "Connect";
|
||||
public static String CONNECTS = "Connects";
|
||||
public static String CONNECTION = "Connection";
|
||||
public static String CONTROL = "Control";
|
||||
public static String DELETED = "Del";
|
||||
public static String DOCUMENT_SHEET = "DocumentSheet";
|
||||
public static String ELLIPSE = "Ellipse";
|
||||
public static String ELLIPTICAL_ARC_TO = "EllipticalArcTo";
|
||||
public static String END_ARROW = "EndArrow";
|
||||
public static String END_ARROW_SIZE = "EndArrowSize";
|
||||
public static String END_X = "EndX";
|
||||
public static String END_Y = "EndY";
|
||||
public static String FACE_NAME = "FaceName";
|
||||
public static String FACE_NAMES = "FaceNames";
|
||||
public static String FALSE = "0";
|
||||
public static String FILL = "Fill";
|
||||
public static String FILL_BKGND = "FillBkgnd";
|
||||
public static String FILL_BKGND_TRANS = "FillBkgndTrans";
|
||||
public static String FILL_FOREGND = "FillForegnd";
|
||||
public static String FILL_FOREGND_TRANS = "FillForegndTrans";
|
||||
public static String FILL_PATTERN = "FillPattern";
|
||||
public static String FILL_STYLE = "FillStyle";
|
||||
public static String FILL_GRADIENT_ENABLED = "FillGradientEnabled";
|
||||
public static String FLAGS = "Flags";
|
||||
public static String FLIP_X = "FlipX";
|
||||
public static String FLIP_Y = "FlipY";
|
||||
public static String FONT = "Font";
|
||||
public static String FONT_NAME = "Name";
|
||||
public static String FOREIGN = "Foreign";
|
||||
public static String FROM_CELL = "FromCell";
|
||||
public static String FROM_SHEET = "FromSheet";
|
||||
public static String GEOM = "Geom";
|
||||
public static String HEIGHT = "Height";
|
||||
public static String HORIZONTAL_ALIGN = "HorzAlign";
|
||||
public static String ID = "ID";
|
||||
public static String INDENT_FIRST = "IndFirst";
|
||||
public static String INDENT_LEFT = "IndLeft";
|
||||
public static String INDENT_RIGHT = "IndRight";
|
||||
public static String INDEX = "IX";
|
||||
public static String LEFT_MARGIN = "LeftMargin";
|
||||
public static String LETTER_SPACE = "Letterspace";
|
||||
public static String LINE = "Line";
|
||||
public static String LINE_COLOR = "LineColor";
|
||||
public static String LINE_COLOR_TRANS = "LineColorTrans";
|
||||
public static String LINE_PATTERN = "LinePattern";
|
||||
public static String LINE_STYLE = "LineStyle";
|
||||
public static String LINE_TO = "LineTo";
|
||||
public static String LINE_WEIGHT = "LineWeight";
|
||||
public static String LOC_PIN_X = "LocPinX";
|
||||
public static String LOC_PIN_Y = "LocPinY";
|
||||
public static String MASTER = "Master";
|
||||
public static String MASTER_SHAPE = "MasterShape";
|
||||
public static String MASTERS = "Masters";
|
||||
public static String MOVE_TO = "MoveTo";
|
||||
public static String NAME = "Name";
|
||||
public static String NAME_U = "NameU";
|
||||
public static String NO_LINE = "NoLine";
|
||||
public static String NURBS_TO = "NURBSTo";
|
||||
public static String PAGE = "Page";
|
||||
public static String PAGE_HEIGHT = "PageHeight";
|
||||
public static String PAGE_WIDTH = "PageWidth";
|
||||
public static String PAGES = "Pages";
|
||||
public static String PARAGRAPH = "Paragraph";
|
||||
public static String PIN_X = "PinX";
|
||||
public static String PIN_Y = "PinY";
|
||||
public static String POS = "Pos";
|
||||
public static String RGB = "RGB";
|
||||
public static String RIGHT_MARGIN = "RightMargin";
|
||||
public static String ROUNDING = "Rounding";
|
||||
public static String RTL_TEXT = "RTLText";
|
||||
public static String SIZE = "Size";
|
||||
public static String SHAPE = "Shape";
|
||||
public static String SHAPES = "Shapes";
|
||||
public static String SHAPE_SHDW_SHOW = "ShapeShdwShow";
|
||||
public static String SHDW_PATTERN = "ShdwPattern";
|
||||
public static String SPACE_AFTER = "SpAfter";
|
||||
public static String SPACE_BEFORE = "SpBefore";
|
||||
public static String SPACE_LINE = "SpLine";
|
||||
public static String STRIKETHRU = "Strikethru";
|
||||
public static String STYLE = "Style";
|
||||
public static String STYLE_SHEET = "StyleSheet";
|
||||
public static String STYLE_SHEETS = "StyleSheets";
|
||||
public static String TEXT = "Text";
|
||||
public static String TEXT_BKGND = "TextBkgnd";
|
||||
public static String TEXT_BLOCK = "TextBlock";
|
||||
public static String TEXT_STYLE = "TextStyle";
|
||||
public static String TO_PART = "ToPart";
|
||||
public static String TO_SHEET = "ToSheet";
|
||||
public static String TOP_MARGIN = "TopMargin";
|
||||
public static String TRUE = "1";
|
||||
public static String TXT_ANGLE = "TxtAngle";
|
||||
public static String TXT_HEIGHT = "TxtHeight";
|
||||
public static String TXT_LOC_PIN_X = "TxtLocPinX";
|
||||
public static String TXT_LOC_PIN_Y = "TxtLocPinY";
|
||||
public static String TXT_PIN_X = "TxtPinX";
|
||||
public static String TXT_PIN_Y = "TxtPinY";
|
||||
public static String TXT_WIDTH = "TxtWidth";
|
||||
public static String TYPE = "Type";
|
||||
public static String TYPE_GROUP = "Group";
|
||||
public static String TYPE_SHAPE = "Shape";
|
||||
public static String UNIQUE_ID = "UniqueID";
|
||||
public static String VERTICAL_ALIGN = "VerticalAlign";
|
||||
public static String WIDTH = "Width";
|
||||
public static String X_CON = "XCon";
|
||||
public static String X_DYN = "XDyn";
|
||||
public static String X = "X";
|
||||
public static String Y_CON = "YCon";
|
||||
public static String Y_DYN = "YDyn";
|
||||
public static String Y = "Y";
|
||||
public static String HIDE_TEXT = "HideText";
|
||||
|
||||
public static String VSDX_ID = "vsdxID";
|
||||
|
||||
public static int CONNECT_TO_PART_WHOLE_SHAPE = 3;
|
||||
|
||||
public static final String[] SET_VALUES = new String[] { "a", "b" };
|
||||
public static final Set<String> MY_SET = new HashSet<String>(Arrays.asList(SET_VALUES));
|
||||
}
|
|
@ -1,194 +0,0 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.mxgraph.io.vsdx;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.mxgraph.io.mxVsdxCodec;
|
||||
|
||||
/**
|
||||
* This class is a wrapper for a Master element.<br/>
|
||||
* Contains a map with the shapes contained in the Master element
|
||||
* and allows access these by ID.
|
||||
*/
|
||||
public class mxVsdxMaster
|
||||
{
|
||||
protected Element master;
|
||||
|
||||
/**
|
||||
* Unique ID of the element within its parent element
|
||||
*/
|
||||
protected String Id = null;
|
||||
|
||||
protected Shape masterShape = null;
|
||||
|
||||
/*
|
||||
* Map that contains the shapes in Master element wrapped for instances of mxDelegateShape.
|
||||
* The key is the shape's ID.
|
||||
*/
|
||||
protected HashMap<String, Shape> childShapes = new HashMap<String, Shape>();
|
||||
|
||||
/**
|
||||
* Create a new instance of mxMasterElement and retrieves all the shapes contained
|
||||
* in the Master element.
|
||||
* @param m Master Element to be wrapped.
|
||||
*/
|
||||
public mxVsdxMaster(Element m, mxVsdxModel model)
|
||||
{
|
||||
this.master = m;
|
||||
this.Id = m.getAttribute(mxVsdxConstants.ID);
|
||||
processMasterShapes(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves and wraps all the shapes contained in the 'shape' param.<br/>
|
||||
* This method is recursive, it retrieves the subshapes of the shapes too.
|
||||
* @param shape Shape from which the subshapes are retrieved.
|
||||
* @return Map with the shapes wrapped in instances of mxMasterShape.
|
||||
*/
|
||||
protected void processMasterShapes(mxVsdxModel model)
|
||||
{
|
||||
Node child = this.master.getFirstChild();
|
||||
|
||||
while (child != null)
|
||||
{
|
||||
if (child instanceof Element && ((Element)child).getNodeName().equals("Rel"))
|
||||
{
|
||||
Element relElem = model.getRelationship(((Element) child).getAttribute("r:id"), mxVsdxCodec.vsdxPlaceholder + "/masters/" + "_rels/masters.xml.rels");
|
||||
String target = relElem.getAttribute("Target");
|
||||
String type = relElem.getAttribute("Type");
|
||||
Document masterDoc = null;
|
||||
|
||||
if (type != null && type.endsWith("master"))
|
||||
{
|
||||
masterDoc = model.getXmlDoc(mxVsdxCodec.vsdxPlaceholder + "/masters/" + target);
|
||||
}
|
||||
|
||||
if (masterDoc != null)
|
||||
{
|
||||
Node masterChild = masterDoc.getFirstChild();
|
||||
|
||||
while (masterChild != null)
|
||||
{
|
||||
if (masterChild instanceof Element && ((Element)masterChild).getNodeName().equals("MasterContents"))
|
||||
{
|
||||
processMasterShape((Element)masterChild, model);
|
||||
break;
|
||||
}
|
||||
|
||||
masterChild = masterChild.getNextSibling();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves and wraps all the shapes contained in the 'shape' param.<br/>
|
||||
* This method is recursive, it retrieves the subshapes of the shapes too.
|
||||
* @param shape Shape from which the subshapes are retrieved.
|
||||
* @return Map with the shapes wrapped in instances of mxMasterShape.
|
||||
*/
|
||||
protected void processMasterShape(Element shapeElem, mxVsdxModel model)
|
||||
{
|
||||
Node shapeChild = shapeElem.getFirstChild();
|
||||
|
||||
while (shapeChild != null)
|
||||
{
|
||||
if (shapeChild instanceof Element && ((Element)shapeChild).getNodeName().equals("Shapes"))
|
||||
{
|
||||
Node shapesChild = shapeChild.getFirstChild();
|
||||
|
||||
while (shapesChild != null)
|
||||
{
|
||||
if (shapesChild instanceof Element && ((Element)shapesChild).getNodeName().equals("Shape"))
|
||||
{
|
||||
Element shape = (Element)shapesChild;
|
||||
String shapeId = shape.getAttribute("ID");
|
||||
Shape masterShape = new Shape(shape, model);
|
||||
this.masterShape = (this.masterShape == null) ? masterShape : this.masterShape;
|
||||
childShapes.put(shapeId, masterShape);
|
||||
processMasterShape(shape, model);
|
||||
}
|
||||
|
||||
shapesChild = shapesChild.getNextSibling();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
shapeChild = shapeChild.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first shape in the Master
|
||||
* @return First shape in the Master wrapped in a instance of mxMasterShape
|
||||
*/
|
||||
public Shape getMasterShape()
|
||||
{
|
||||
return this.masterShape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shape in the master element with ID = 'id'.
|
||||
* @param id Shape's ID
|
||||
* @return The shape in the master element with ID = 'id' wrapped in a instance of mxMasterShape
|
||||
*/
|
||||
public Shape getSubShape(String id)
|
||||
{
|
||||
return childShapes.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the NameU attribute.
|
||||
* @return Value of the NameU attribute.
|
||||
*/
|
||||
public String getNameU()
|
||||
{
|
||||
return master.getAttribute("NameU");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the NameU attribute.
|
||||
* @return Value of the NameU attribute.
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return master.getAttribute("Name");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the UniqueID attribute.
|
||||
* @return Value of the UniqueID attribute.
|
||||
*/
|
||||
public String getUniqueID()
|
||||
{
|
||||
String uniqueID = "";
|
||||
|
||||
if (master.hasAttribute("UniqueID"))
|
||||
{
|
||||
uniqueID = master.getAttribute("UniqueID");
|
||||
}
|
||||
|
||||
return uniqueID;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return this.Id;
|
||||
}
|
||||
|
||||
public Element getMasterElement()
|
||||
{
|
||||
return master;
|
||||
}
|
||||
}
|
|
@ -1,378 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2006-2016, JGraph Ltd
|
||||
* Copyright (c) 2006-2016, Gaudenz Alder
|
||||
*/
|
||||
package com.mxgraph.io.vsdx;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import com.mxgraph.io.mxVsdxCodec;
|
||||
|
||||
/**
|
||||
*
|
||||
* A model representing vsdx files. As well as being a programmatic model, the XML DOMs of the unzipped
|
||||
* files are held to enable round-tripping
|
||||
*
|
||||
*/
|
||||
public class mxVsdxModel {
|
||||
|
||||
/**
|
||||
* A map of Documents created by reading the XML files, indexed by the path to those files
|
||||
*/
|
||||
protected Map<String, Document> xmlDocs = null;
|
||||
|
||||
/**
|
||||
* Collection of media files encoded in Base64, indexed by the path to those files
|
||||
*/
|
||||
protected Map<String, String> media = null;
|
||||
|
||||
/**
|
||||
* The document from .../document.xml
|
||||
*/
|
||||
protected Element rootElement;
|
||||
|
||||
/**
|
||||
* Map of page objects indexed by their ID.
|
||||
*/
|
||||
protected Map<Integer, mxVsdxPage> pages = null;
|
||||
|
||||
/**
|
||||
* Map of master objects indexed by their ID. Before you think you're being clever by making
|
||||
* the index an Integer as for pages, don't, there are reasons.
|
||||
*/
|
||||
protected Map<String, mxVsdxMaster> masters = new HashMap<String, mxVsdxMaster>();
|
||||
|
||||
/**
|
||||
* Map stylesheets indexed by their ID
|
||||
*/
|
||||
protected Map<String, Style> stylesheets = new HashMap<String, Style>();
|
||||
|
||||
/**
|
||||
* Map themes indexed by their index
|
||||
*/
|
||||
protected Map<Integer, mxVsdxTheme> themes = new HashMap<>();
|
||||
|
||||
mxPropertiesManager pm;
|
||||
|
||||
public mxVsdxModel(Document doc, Map<String, Document> docData, Map<String, String> mediaData)
|
||||
{
|
||||
this.xmlDocs = docData;
|
||||
this.media = mediaData;
|
||||
|
||||
Node childNode = doc.getFirstChild();
|
||||
|
||||
while (childNode != null)
|
||||
{
|
||||
if (childNode instanceof Element && ((Element)childNode).getTagName().toLowerCase().equals(mxVsdxCodec.vsdxPlaceholder + "document"))
|
||||
{
|
||||
this.rootElement = (Element)childNode;
|
||||
break;
|
||||
}
|
||||
|
||||
childNode = childNode.getNextSibling();
|
||||
}
|
||||
|
||||
this.pm = new mxPropertiesManager();
|
||||
this.pm.initialise(rootElement, this);
|
||||
initStylesheets();
|
||||
initThemes();
|
||||
initMasters();
|
||||
initPages();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize theme objects from the XML files
|
||||
*/
|
||||
private void initThemes()
|
||||
{
|
||||
// Lazy build up the master structure
|
||||
if (this.xmlDocs != null)
|
||||
{
|
||||
boolean more = true;
|
||||
int index = 1;
|
||||
|
||||
while (more)
|
||||
{
|
||||
String path = mxVsdxCodec.vsdxPlaceholder + "/theme/theme"+ index +".xml";
|
||||
Document themeDoc = this.xmlDocs.get(path);
|
||||
|
||||
if (themeDoc != null)
|
||||
{
|
||||
Node child = themeDoc.getFirstChild();
|
||||
|
||||
while (child != null)
|
||||
{
|
||||
if (child instanceof Element && ((Element)child).getTagName().equals("a:theme"))
|
||||
{
|
||||
mxVsdxTheme theme = new mxVsdxTheme((Element) child);
|
||||
|
||||
|
||||
if (theme.getThemeIndex() < 0)
|
||||
{
|
||||
//theme index cannot be determined unless the theme is parsed
|
||||
theme.processTheme();
|
||||
}
|
||||
|
||||
//TODO having two theme files with the same id still requires more handling
|
||||
// probably we need to merge the similar parts (has same theme name)
|
||||
mxVsdxTheme existingTheme = themes.get(theme.getThemeIndex());
|
||||
if (existingTheme == null || !existingTheme.isPure())
|
||||
{
|
||||
themes.put(theme.getThemeIndex(), theme);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
index++;
|
||||
}
|
||||
else
|
||||
{
|
||||
more = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the map with the stylesheets elements in the document.<br/>
|
||||
* The masters are wrapped for instances of mxStyleSheet.
|
||||
* @param doc Document with the stylesheets.
|
||||
*/
|
||||
public void initStylesheets()
|
||||
{
|
||||
NodeList vdxSheets = rootElement.getElementsByTagName(mxVsdxConstants.STYLE_SHEETS);
|
||||
|
||||
if (vdxSheets.getLength() > 0)
|
||||
{
|
||||
Element sheets = (Element) vdxSheets.item(0);
|
||||
NodeList sheetList = sheets.getElementsByTagName(mxVsdxConstants.STYLE_SHEET);
|
||||
int sheetLength = sheetList.getLength();
|
||||
|
||||
for (int i = 0; i < sheetLength; i++)
|
||||
{
|
||||
Element sheet = (Element) sheetList.item(i);
|
||||
String sheetId = sheet.getAttribute(mxVsdxConstants.ID);
|
||||
Style sheetElement = new Style(sheet, this);
|
||||
stylesheets.put(sheetId, sheetElement);
|
||||
}
|
||||
}
|
||||
|
||||
Collection <Style> sheets = stylesheets.values();
|
||||
Iterator<Style> iter = sheets.iterator();
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
Style sheet = iter.next();
|
||||
sheet.stylesheetRefs(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize master objects from the XML files
|
||||
*/
|
||||
public void initMasters()
|
||||
{
|
||||
// Lazy build up the master structure
|
||||
if (this.xmlDocs != null)
|
||||
{
|
||||
String path = mxVsdxCodec.vsdxPlaceholder + "/masters/masters.xml";
|
||||
Document masterDoc = this.xmlDocs.get(path);
|
||||
|
||||
if (masterDoc != null)
|
||||
{
|
||||
Node child = masterDoc.getFirstChild();
|
||||
|
||||
while (child != null)
|
||||
{
|
||||
if (child instanceof Element && ((Element)child).getTagName().equals(mxVsdxConstants.MASTERS))
|
||||
{
|
||||
Node grandChild = child.getFirstChild();
|
||||
|
||||
while (grandChild != null)
|
||||
{
|
||||
if (grandChild instanceof Element && ((Element)grandChild).getTagName().equals("Master"))
|
||||
{
|
||||
Element masterElement = (Element)grandChild;
|
||||
mxVsdxMaster master = new mxVsdxMaster(masterElement, this);
|
||||
this.masters.put(master.getId(), master);
|
||||
}
|
||||
|
||||
grandChild = grandChild.getNextSibling();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize page objects from the XML files
|
||||
*/
|
||||
public void initPages()
|
||||
{
|
||||
// Lazy build up the pages structure
|
||||
if (this.xmlDocs != null)
|
||||
{
|
||||
String path = mxVsdxCodec.vsdxPlaceholder + "/pages/pages.xml";
|
||||
Document pageDoc = this.xmlDocs.get(path);
|
||||
|
||||
if (pageDoc != null)
|
||||
{
|
||||
Node child = pageDoc.getFirstChild();
|
||||
|
||||
while (child != null)
|
||||
{
|
||||
if (child instanceof Element && ((Element)child).getTagName().equals(mxVsdxConstants.PAGES))
|
||||
{
|
||||
Element pages = (Element)child;
|
||||
|
||||
NodeList pageList = pages.getElementsByTagName(mxVsdxConstants.PAGE);
|
||||
|
||||
if (pageList != null && pageList.getLength() > 0)
|
||||
{
|
||||
this.pages = new LinkedHashMap<Integer, mxVsdxPage>();
|
||||
|
||||
HashMap<Integer, mxVsdxPage> backgroundMap = new HashMap<Integer, mxVsdxPage>();
|
||||
int pageListLen = pageList.getLength();
|
||||
|
||||
//Find the background pages while creating all the pages
|
||||
for (int i = 0; i < pageListLen; i++)
|
||||
{
|
||||
Element pageEle = (Element) pageList.item(i);
|
||||
mxVsdxPage page = createPage(pageEle);
|
||||
|
||||
if (page.isBackground())
|
||||
{
|
||||
backgroundMap.put(page.getId(), page);
|
||||
}
|
||||
|
||||
this.pages.put(page.getId(), page);
|
||||
}
|
||||
|
||||
// Iterate again, assigning background pages
|
||||
for (Map.Entry<Integer, mxVsdxPage> entry : this.pages.entrySet())
|
||||
{
|
||||
mxVsdxPage page = entry.getValue();
|
||||
|
||||
if (!page.isBackground())
|
||||
{
|
||||
Integer backId = page.getBackPageId();
|
||||
|
||||
if (backId != null)
|
||||
{
|
||||
//Import the background.
|
||||
mxVsdxPage background = backgroundMap.get(backId);
|
||||
page.setBackPage(background);;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break; // MS defines there can only be 0 or 1 PAGES element, don't process second
|
||||
}
|
||||
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, mxVsdxPage> getPages()
|
||||
{
|
||||
return this.pages;
|
||||
}
|
||||
|
||||
public Map<Integer, mxVsdxTheme> getThemes()
|
||||
{
|
||||
return this.themes;
|
||||
}
|
||||
|
||||
protected Element getRelationship(String rid, String path)
|
||||
{
|
||||
Document relsDoc = this.xmlDocs.get(path);
|
||||
|
||||
if (relsDoc == null || rid == null || rid.isEmpty())
|
||||
{
|
||||
// Valid to not have a rels for an XML file
|
||||
return null;
|
||||
}
|
||||
|
||||
NodeList rels = relsDoc.getElementsByTagName("Relationship");
|
||||
|
||||
for (int i = 0; i < rels.getLength(); i++)
|
||||
{
|
||||
Element currElem = (Element) rels.item(i);
|
||||
String id = currElem.getAttribute("Id");
|
||||
|
||||
if (id.equals(rid))
|
||||
{
|
||||
return currElem;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public mxVsdxMaster getMaster(String masterId)
|
||||
{
|
||||
return this.masters.get(masterId);
|
||||
}
|
||||
|
||||
protected mxVsdxPage createPage(Element pageEle)
|
||||
{
|
||||
return new mxVsdxPage(pageEle, this);
|
||||
}
|
||||
|
||||
public mxPropertiesManager getPropertiesManager() {
|
||||
return pm;
|
||||
}
|
||||
|
||||
public void setPropertiesManager(mxPropertiesManager pm) {
|
||||
this.pm = pm;
|
||||
}
|
||||
|
||||
public Map<String, mxVsdxMaster> getMasterShapes() {
|
||||
return masters;
|
||||
}
|
||||
|
||||
public void setMasterShapes(Map<String, mxVsdxMaster> mm) {
|
||||
this.masters = mm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the wrapper of the stylesheet element with id indicated by 'id'
|
||||
* @param id StyleSheet's ID.
|
||||
* @return StyleSheet element with id = 'id' wrapped in an instance of mxStyleSheet.
|
||||
*/
|
||||
public Style getStylesheet(String id)
|
||||
{
|
||||
return stylesheets.get(id);
|
||||
}
|
||||
|
||||
public Document getXmlDoc(String path)
|
||||
{
|
||||
return this.xmlDocs.get(path);
|
||||
}
|
||||
|
||||
public String getMedia(String path)
|
||||
{
|
||||
return this.media.get(path);
|
||||
}
|
||||
}
|
|
@ -1,973 +0,0 @@
|
|||
package com.mxgraph.io.vsdx;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.mxgraph.io.vsdx.theme.Color;
|
||||
import com.mxgraph.io.vsdx.theme.FillStyle;
|
||||
import com.mxgraph.io.vsdx.theme.FillStyleFactory;
|
||||
import com.mxgraph.io.vsdx.theme.GradFill;
|
||||
import com.mxgraph.io.vsdx.theme.HSLColor;
|
||||
import com.mxgraph.io.vsdx.theme.LineStyle;
|
||||
import com.mxgraph.io.vsdx.theme.LineStyleExt;
|
||||
import com.mxgraph.io.vsdx.theme.OoxmlColor;
|
||||
import com.mxgraph.io.vsdx.theme.OoxmlColorFactory;
|
||||
import com.mxgraph.io.vsdx.theme.QuickStyleVals;
|
||||
|
||||
//Holds office 2013 theme data which applies to all office file formats
|
||||
public class mxVsdxTheme
|
||||
{
|
||||
//Theme names to ID mapping
|
||||
private static Map<String, Integer> themesIds = new HashMap<>();
|
||||
|
||||
//Theme index can be found deep inside the theme file, so this is faster for standard 2013 format
|
||||
static
|
||||
{
|
||||
themesIds.put("Office", 33);
|
||||
themesIds.put("Linear", 34);
|
||||
themesIds.put("Zephyr", 35);
|
||||
themesIds.put("Integral", 36);
|
||||
themesIds.put("Simple", 37);
|
||||
themesIds.put("Whisp", 38);
|
||||
themesIds.put("Daybreak", 39);
|
||||
themesIds.put("Parallel", 40);
|
||||
themesIds.put("Sequence", 41);
|
||||
themesIds.put("Slice", 42);
|
||||
themesIds.put("Ion", 43);
|
||||
themesIds.put("Retrospect", 44);
|
||||
themesIds.put("Organic", 45);
|
||||
themesIds.put("Bubble", 46);
|
||||
themesIds.put("Clouds", 47);
|
||||
themesIds.put("Gemstone", 48);
|
||||
themesIds.put("Lines", 49);
|
||||
themesIds.put("Facet", 50);
|
||||
themesIds.put("Prominence", 51);
|
||||
themesIds.put("Smoke", 52);
|
||||
themesIds.put("Radiance", 53);
|
||||
themesIds.put("Shade", 54);
|
||||
themesIds.put("Pencil", 55);
|
||||
themesIds.put("Pen", 56);
|
||||
themesIds.put("Marker", 57);
|
||||
themesIds.put("Whiteboard", 58);
|
||||
}
|
||||
|
||||
//color id to color name
|
||||
private static Map<Integer, String> colorIds = new HashMap<>();
|
||||
|
||||
//https://msdn.microsoft.com/en-us/library/hh661351%28v=office.12%29.aspx
|
||||
//There are non standard values of 200 -> 206 also which are handled the same as 100 -> 106
|
||||
static
|
||||
{
|
||||
colorIds.put(0, "dk1");
|
||||
colorIds.put(1, "lt1");
|
||||
colorIds.put(2, "accent1");
|
||||
colorIds.put(3, "accent2");
|
||||
colorIds.put(4, "accent3");
|
||||
colorIds.put(5, "accent4");
|
||||
colorIds.put(6, "accent5");
|
||||
colorIds.put(7, "accent6");
|
||||
}
|
||||
|
||||
private Element theme;
|
||||
|
||||
private int themeIndex = -1;
|
||||
|
||||
private int themeVariant = 0;
|
||||
|
||||
//colors handling
|
||||
private Map<String, OoxmlColor> baseColors = new HashMap<>();
|
||||
|
||||
//Dynamic background color (index 8)
|
||||
private OoxmlColor bkgndColor;
|
||||
|
||||
//Variant colors
|
||||
private OoxmlColor[][] variantsColors = new OoxmlColor[4][7];
|
||||
|
||||
private boolean[] isMonotoneVariant = new boolean[4];
|
||||
|
||||
private Color defaultClr = new Color(255, 255, 255);
|
||||
private Color defaultLineClr = new Color(0, 0, 0);
|
||||
|
||||
private LineStyle defaultLineStyle = new LineStyle();
|
||||
|
||||
//fill styles
|
||||
private ArrayList<FillStyle> fillStyles = new ArrayList<>(6);
|
||||
|
||||
//connector fill styles
|
||||
//TODO what is the use of it?
|
||||
private ArrayList<FillStyle> connFillStyles = new ArrayList<>(6);
|
||||
|
||||
//line styles
|
||||
private ArrayList<LineStyle> lineStyles = new ArrayList<>(6);
|
||||
|
||||
//cpnector line styles
|
||||
private ArrayList<LineStyle> connLineStyles = new ArrayList<>(6);
|
||||
|
||||
//line styles extensions
|
||||
private ArrayList<LineStyleExt> lineStylesExt = new ArrayList<>(7);
|
||||
|
||||
//connector line styles extensions
|
||||
private ArrayList<LineStyleExt> connLineStylesExt = new ArrayList<>(7);
|
||||
|
||||
//connector font color & styles
|
||||
private ArrayList<OoxmlColor> connFontColors = new ArrayList<>(6);
|
||||
private ArrayList<Integer> connFontStyles = new ArrayList<>(6);
|
||||
|
||||
//font color & styles
|
||||
private ArrayList<OoxmlColor> fontColors = new ArrayList<>(6);
|
||||
private ArrayList<Integer> fontStyles = new ArrayList<>(6);
|
||||
|
||||
private int[] variantEmbellishment = new int[4];
|
||||
private int[][] variantFillIdx = new int[4][4];
|
||||
private int[][] variantLineIdx = new int[4][4];
|
||||
private int[][] variantEffectIdx = new int[4][4];
|
||||
private int[][] variantFontIdx = new int[4][4];
|
||||
|
||||
private boolean isProcessed = false;
|
||||
|
||||
//flag to indicate that some parts of the theme has different name
|
||||
private boolean isPure = true;
|
||||
private String name;
|
||||
|
||||
public mxVsdxTheme(Element theme)
|
||||
{
|
||||
this.theme = theme;
|
||||
this.name = theme.getAttribute("name");
|
||||
|
||||
Integer themeId = themesIds.get(this.name);
|
||||
|
||||
if (themeId != null)
|
||||
{
|
||||
themeIndex = themeId;
|
||||
}
|
||||
}
|
||||
|
||||
public int getThemeIndex()
|
||||
{
|
||||
return themeIndex;
|
||||
}
|
||||
|
||||
public void setVariant(int variant)
|
||||
{
|
||||
themeVariant = variant;
|
||||
}
|
||||
|
||||
public boolean isPure()
|
||||
{
|
||||
return isPure;
|
||||
}
|
||||
|
||||
public void processTheme()
|
||||
{
|
||||
if (isProcessed) return;
|
||||
|
||||
try
|
||||
{
|
||||
Node child = theme.getFirstChild();
|
||||
|
||||
while (child != null)
|
||||
{
|
||||
if (child instanceof Element && ((Element)child).getNodeName().equals("a:themeElements"))
|
||||
{
|
||||
Node child2 = child.getFirstChild();
|
||||
while (child2 != null)
|
||||
{
|
||||
if (child2 instanceof Element)
|
||||
{
|
||||
Element elem = (Element)child2;
|
||||
String nodeName = elem.getNodeName();
|
||||
if (nodeName.equals("a:clrScheme"))
|
||||
{
|
||||
if (!this.name.equals(elem.getAttribute("name")))
|
||||
{
|
||||
isPure = false;
|
||||
}
|
||||
//Process the color scheme
|
||||
processColors(elem);
|
||||
}
|
||||
else if (nodeName.equals("a:fontScheme"))
|
||||
{
|
||||
if (!this.name.equals(elem.getAttribute("name")))
|
||||
{
|
||||
isPure = false;
|
||||
}
|
||||
//Process the font scheme
|
||||
processFonts(elem);
|
||||
}
|
||||
else if (nodeName.equals("a:fmtScheme"))
|
||||
{
|
||||
if (!this.name.equals(elem.getAttribute("name")))
|
||||
{
|
||||
isPure = false;
|
||||
}
|
||||
//Process the format scheme
|
||||
processFormats(elem);
|
||||
}
|
||||
else if (nodeName.equals("a:extLst"))
|
||||
{
|
||||
//Process the extra list
|
||||
processExtras(elem);
|
||||
}
|
||||
}
|
||||
child2 = child2.getNextSibling();
|
||||
}
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//cannot parse the theme format, probably it has non-standard format
|
||||
e.printStackTrace();
|
||||
}
|
||||
isProcessed = true;
|
||||
}
|
||||
|
||||
private void processExtras(Element element)
|
||||
{
|
||||
ArrayList<Element> exts = mxVsdxUtils.getDirectChildElements(element);
|
||||
|
||||
for (Element ext : exts)
|
||||
{
|
||||
Element vt = mxVsdxUtils.getDirectFirstChildElement(ext);
|
||||
switch (vt.getNodeName())
|
||||
{
|
||||
case "vt:fmtConnectorScheme":
|
||||
if (!this.name.equals(vt.getAttribute("name")))
|
||||
{
|
||||
isPure = false;
|
||||
}
|
||||
ArrayList<Element> connSchemes = mxVsdxUtils.getDirectChildElements(vt);
|
||||
|
||||
for (Element scheme : connSchemes)
|
||||
{
|
||||
String name = scheme.getNodeName();
|
||||
|
||||
switch (name)
|
||||
{
|
||||
case "a:fillStyleLst":
|
||||
ArrayList<Element> fillStyleElems = mxVsdxUtils.getDirectChildElements(scheme);
|
||||
for (Element fillStyle : fillStyleElems)
|
||||
{
|
||||
connFillStyles.add(FillStyleFactory.getFillStyle(fillStyle));
|
||||
}
|
||||
break;
|
||||
case "a:lnStyleLst":
|
||||
ArrayList<Element> lineStyleElems = mxVsdxUtils.getDirectChildElements(scheme);
|
||||
for (Element lineStyle : lineStyleElems)
|
||||
{
|
||||
connLineStyles.add(new LineStyle(lineStyle));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "vt:lineStyles":
|
||||
ArrayList<Element> styles = mxVsdxUtils.getDirectChildElements(vt);
|
||||
|
||||
for (Element style : styles)
|
||||
{
|
||||
String name = style.getNodeName();
|
||||
|
||||
switch (name)
|
||||
{
|
||||
case "vt:fmtConnectorSchemeLineStyles":
|
||||
ArrayList<Element> connStylesElems = mxVsdxUtils.getDirectChildElements(style);
|
||||
for (Element connStyle : connStylesElems)
|
||||
{
|
||||
connLineStylesExt.add(new LineStyleExt(connStyle));
|
||||
}
|
||||
break;
|
||||
case "vt:fmtSchemeLineStyles":
|
||||
ArrayList<Element> schemeStyleElems = mxVsdxUtils.getDirectChildElements(style);
|
||||
for (Element schemeStyle : schemeStyleElems)
|
||||
{
|
||||
lineStylesExt.add(new LineStyleExt(schemeStyle));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "vt:fontStylesGroup":
|
||||
ArrayList<Element> fontStyleElems = mxVsdxUtils.getDirectChildElements(vt);
|
||||
|
||||
for (Element fontStyle : fontStyleElems)
|
||||
{
|
||||
String name = fontStyle.getNodeName();
|
||||
|
||||
switch (name)
|
||||
{
|
||||
case "vt:connectorFontStyles":
|
||||
fillFontStyles(fontStyle, connFontColors, connFontStyles);
|
||||
break;
|
||||
case "vt:fontStyles":
|
||||
fillFontStyles(fontStyle, fontColors, fontStyles);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "vt:variationStyleSchemeLst":
|
||||
ArrayList<Element> varStyleSchemes = mxVsdxUtils.getDirectChildElements(vt);
|
||||
|
||||
int i=0;
|
||||
for (Element varStyleScheme : varStyleSchemes)
|
||||
{
|
||||
variantEmbellishment[i] = mxVsdxUtils.getIntAttr(varStyleScheme, "embellishment");
|
||||
|
||||
ArrayList<Element> varStyles = mxVsdxUtils.getDirectChildElements(varStyleScheme);
|
||||
int j = 0;
|
||||
for (Element varStyle : varStyles)
|
||||
{
|
||||
variantFillIdx[i][j] = mxVsdxUtils.getIntAttr(varStyle, "fillIdx");
|
||||
variantLineIdx[i][j] = mxVsdxUtils.getIntAttr(varStyle, "lineIdx");
|
||||
variantEffectIdx[i][j] = mxVsdxUtils.getIntAttr(varStyle, "effectIdx");
|
||||
variantFontIdx[i][j] = mxVsdxUtils.getIntAttr(varStyle, "fontIdx");
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fillFontStyles(Element fontStyle, ArrayList<OoxmlColor> fontColors, ArrayList<Integer> fontStyles) {
|
||||
ArrayList<Element> fontProps = mxVsdxUtils.getDirectChildElements(fontStyle);
|
||||
|
||||
for (Element fontProp : fontProps)
|
||||
{
|
||||
fontStyles.add(mxVsdxUtils.getIntAttr(fontProp, "style"));
|
||||
|
||||
Element color = mxVsdxUtils.getDirectFirstChildElement(fontProp);
|
||||
if (color != null)
|
||||
fontColors.add(
|
||||
OoxmlColorFactory.getOoxmlColor(
|
||||
mxVsdxUtils.getDirectFirstChildElement(color)));
|
||||
}
|
||||
}
|
||||
|
||||
private void processFormats(Element element)
|
||||
{
|
||||
ArrayList<Element> styles = mxVsdxUtils.getDirectChildElements(element);
|
||||
for (Element style : styles)
|
||||
{
|
||||
String name = style.getNodeName();
|
||||
switch (name)
|
||||
{
|
||||
case "a:fillStyleLst":
|
||||
ArrayList<Element> fillStyleElems = mxVsdxUtils.getDirectChildElements(style);
|
||||
for (Element fillStyle : fillStyleElems)
|
||||
{
|
||||
fillStyles.add(FillStyleFactory.getFillStyle(fillStyle));
|
||||
}
|
||||
break;
|
||||
case "a:lnStyleLst":
|
||||
ArrayList<Element> lineStyleElems = mxVsdxUtils.getDirectChildElements(style);
|
||||
for (Element lineStyle : lineStyleElems)
|
||||
{
|
||||
lineStyles.add(new LineStyle(lineStyle));
|
||||
}
|
||||
break;
|
||||
case "a:effectStyleLst":
|
||||
//TODO effects most probably are not used by vsdx
|
||||
break;
|
||||
case "a:bgFillStyleLst":
|
||||
//TODO background effects most probably are not used by vsdx
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processFonts(Element element) {
|
||||
// TODO Fonts has only the name of the font for each language. It looks not important
|
||||
}
|
||||
|
||||
private void processColors(Element element)
|
||||
{
|
||||
Node child = element.getFirstChild();
|
||||
|
||||
while (child != null)
|
||||
{
|
||||
if (child instanceof Element)
|
||||
{
|
||||
Element elem = (Element)child;
|
||||
String nodeName = elem.getNodeName();
|
||||
ArrayList<Element> children = mxVsdxUtils.getDirectChildElements(elem);
|
||||
if (nodeName.equals("a:extLst"))
|
||||
{
|
||||
if (children.size() == 3) //the format has three a:ext nodes
|
||||
{
|
||||
if (themeIndex < 0)
|
||||
{
|
||||
extractThemeIndex(children.get(0));
|
||||
}
|
||||
addBkgndColor(children.get(1));
|
||||
addVariantColors(children.get(2));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
String clrName = nodeName.substring(2);
|
||||
|
||||
if (children.size() > 0)
|
||||
{
|
||||
addBasicColor(clrName, children.get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
private void addVariantColors(Element element)
|
||||
{
|
||||
Element parent = mxVsdxUtils.getDirectFirstChildElement(element);
|
||||
|
||||
if (parent != null)
|
||||
{
|
||||
ArrayList<Element> variants = mxVsdxUtils.getDirectChildElements(parent);
|
||||
int i = 0;
|
||||
for (Element variant : variants)
|
||||
{
|
||||
addVariantColorsSet(i++, variant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addVariantColorsSet(int index, Element variant)
|
||||
{
|
||||
ArrayList<Element> colors = mxVsdxUtils.getDirectChildElements(variant);
|
||||
|
||||
isMonotoneVariant[index] = variant.hasAttribute("monotone");
|
||||
|
||||
for (Element color : colors)
|
||||
{
|
||||
String name = color.getNodeName();
|
||||
switch (name)
|
||||
{
|
||||
case "vt:varColor1":
|
||||
variantsColors[index][0] = OoxmlColorFactory.getOoxmlColor(
|
||||
mxVsdxUtils.getDirectFirstChildElement(color));
|
||||
break;
|
||||
case "vt:varColor2":
|
||||
variantsColors[index][1] = OoxmlColorFactory.getOoxmlColor(
|
||||
mxVsdxUtils.getDirectFirstChildElement(color));
|
||||
break;
|
||||
case "vt:varColor3":
|
||||
variantsColors[index][2] = OoxmlColorFactory.getOoxmlColor(
|
||||
mxVsdxUtils.getDirectFirstChildElement(color));
|
||||
break;
|
||||
case "vt:varColor4":
|
||||
variantsColors[index][3] = OoxmlColorFactory.getOoxmlColor(
|
||||
mxVsdxUtils.getDirectFirstChildElement(color));
|
||||
break;
|
||||
case "vt:varColor5":
|
||||
variantsColors[index][4] = OoxmlColorFactory.getOoxmlColor(
|
||||
mxVsdxUtils.getDirectFirstChildElement(color));
|
||||
break;
|
||||
case "vt:varColor6":
|
||||
variantsColors[index][5] = OoxmlColorFactory.getOoxmlColor(
|
||||
mxVsdxUtils.getDirectFirstChildElement(color));
|
||||
break;
|
||||
case "vt:varColor7":
|
||||
variantsColors[index][6] = OoxmlColorFactory.getOoxmlColor(
|
||||
mxVsdxUtils.getDirectFirstChildElement(color));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addBkgndColor(Element element)
|
||||
{
|
||||
Element elem = mxVsdxUtils.getDirectFirstChildElement(element);
|
||||
|
||||
if (elem != null)
|
||||
{
|
||||
bkgndColor = OoxmlColorFactory.getOoxmlColor(mxVsdxUtils.getDirectFirstChildElement(elem));
|
||||
}
|
||||
}
|
||||
|
||||
private void extractThemeIndex(Element element)
|
||||
{
|
||||
Element elem = mxVsdxUtils.getDirectFirstChildElement(element);
|
||||
|
||||
if (elem != null)
|
||||
{
|
||||
themeIndex = Integer.parseInt(elem.getAttribute("schemeEnum"));
|
||||
}
|
||||
}
|
||||
|
||||
private void addBasicColor(String clrName, Element element)
|
||||
{
|
||||
baseColors.put(clrName, OoxmlColorFactory.getOoxmlColor(element));
|
||||
}
|
||||
|
||||
public Color getSchemeColor(String val)
|
||||
{
|
||||
processTheme();
|
||||
|
||||
OoxmlColor color = baseColors.get(val);
|
||||
|
||||
return color != null? color.getColor(this) : defaultClr;
|
||||
}
|
||||
|
||||
// QuickStyleFillColor
|
||||
public Color getStyleColor(int styleColor)
|
||||
{
|
||||
processTheme();
|
||||
|
||||
if (styleColor < 8)
|
||||
{
|
||||
OoxmlColor color = baseColors.get(colorIds.get(styleColor));
|
||||
if (color != null)
|
||||
{
|
||||
return color.getColor(this);
|
||||
}
|
||||
}
|
||||
else if (styleColor == 8)
|
||||
{
|
||||
if (bkgndColor != null)
|
||||
{
|
||||
return bkgndColor.getColor(this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OoxmlColor color = null;
|
||||
int clrIndex = 0;
|
||||
|
||||
if (styleColor >= 200) //200-206
|
||||
{
|
||||
clrIndex = styleColor - 200;
|
||||
}
|
||||
else if (styleColor >= 100) //100-106
|
||||
{
|
||||
clrIndex = styleColor - 100;
|
||||
}
|
||||
if (clrIndex >= 0 && clrIndex <= 6) //0 - 6
|
||||
{
|
||||
color = variantsColors[themeVariant][clrIndex];
|
||||
}
|
||||
|
||||
if (color != null)
|
||||
{
|
||||
return color.getColor(this);
|
||||
}
|
||||
}
|
||||
return defaultClr;
|
||||
}
|
||||
|
||||
|
||||
public Color getFillGraientColor(QuickStyleVals quickStyleVals)
|
||||
{
|
||||
return getFillColor(quickStyleVals, true);
|
||||
}
|
||||
|
||||
public Color getFillColor(QuickStyleVals quickStyleVals)
|
||||
{
|
||||
return getFillColor(quickStyleVals, false);
|
||||
}
|
||||
|
||||
//Get fill color based on QuickStyleFillColor & QuickStyleFillMatrix
|
||||
private Color getFillColor(QuickStyleVals quickStyleVals, boolean getGradient)
|
||||
{
|
||||
processTheme();
|
||||
|
||||
int fillColorStyle = quickStyleVals.getQuickStyleFillColor();
|
||||
FillStyle fillStyle = null;
|
||||
switch (quickStyleVals.getQuickStyleFillMatrix())
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
fillStyle = fillStyles.get(quickStyleVals.getQuickStyleFillMatrix() - 1);
|
||||
break;
|
||||
case 100:
|
||||
case 101:
|
||||
case 102:
|
||||
case 103:
|
||||
if (isMonotoneVariant[themeVariant]) fillColorStyle = 100;
|
||||
|
||||
int index = quickStyleVals.getQuickStyleFillMatrix() - 100;
|
||||
//get style index of variants
|
||||
fillStyle = fillStyles.get(variantFillIdx[themeVariant][index] - 1);
|
||||
break;
|
||||
}
|
||||
|
||||
Color retColor;
|
||||
if (fillStyle != null)
|
||||
{
|
||||
if (getGradient)
|
||||
{
|
||||
retColor = (fillStyle instanceof GradFill)? fillStyle.applyStyle(fillColorStyle, this).getGradientClr() : null;
|
||||
}
|
||||
else
|
||||
{
|
||||
retColor = fillStyle.applyStyle(fillColorStyle, this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getGradient)
|
||||
{
|
||||
retColor = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
retColor = getStyleColor(fillColorStyle);
|
||||
}
|
||||
}
|
||||
|
||||
int styleVariation = quickStyleVals.getQuickStyleVariation();
|
||||
|
||||
//TODO using the line color does not cover all the cases but works with most of the sample files
|
||||
if (retColor != null && (styleVariation & 8) > 0)
|
||||
{
|
||||
retColor = getLineColor(quickStyleVals);
|
||||
}
|
||||
|
||||
return retColor;
|
||||
}
|
||||
|
||||
//Get line style based on QuickStyleLineMatrix
|
||||
private LineStyle getLineStyle(int quickStyleLineMatrix, ArrayList<LineStyle> lineStyles)
|
||||
{
|
||||
processTheme();
|
||||
|
||||
LineStyle lineStyle = null;
|
||||
switch (quickStyleLineMatrix)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
lineStyle = lineStyles.get(quickStyleLineMatrix - 1);
|
||||
break;
|
||||
case 100:
|
||||
case 101:
|
||||
case 102:
|
||||
case 103:
|
||||
int index = quickStyleLineMatrix - 100;
|
||||
//get style index of variants
|
||||
//Edges should not has these values
|
||||
if (lineStyles == this.lineStyles)
|
||||
{
|
||||
lineStyle = this.lineStyles.get(variantLineIdx[themeVariant][index] - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
lineStyle = defaultLineStyle;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return lineStyle;
|
||||
}
|
||||
|
||||
private LineStyleExt getLineStyleExt(int quickStyleLineMatrix, ArrayList<LineStyleExt> lineStylesExt)
|
||||
{
|
||||
processTheme();
|
||||
|
||||
LineStyleExt lineStyleExt = null;
|
||||
switch (quickStyleLineMatrix)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
lineStyleExt = lineStylesExt.get(quickStyleLineMatrix);
|
||||
break;
|
||||
}
|
||||
|
||||
return lineStyleExt;
|
||||
}
|
||||
|
||||
//Get line color based on QuickStyleLineColor & QuickStyleLineMatrix
|
||||
private Color getLineColor(QuickStyleVals quickStyleVals, ArrayList<LineStyle> lineStyles)
|
||||
{
|
||||
processTheme();
|
||||
|
||||
int lineColorStyle = quickStyleVals.getQuickStyleLineColor();
|
||||
LineStyle lineStyle = getLineStyle(quickStyleVals.getQuickStyleLineMatrix(), lineStyles);
|
||||
switch (quickStyleVals.getQuickStyleLineMatrix())
|
||||
{
|
||||
case 100:
|
||||
case 101:
|
||||
case 102:
|
||||
case 103:
|
||||
if (isMonotoneVariant[themeVariant]) lineColorStyle = 100;
|
||||
break;
|
||||
}
|
||||
|
||||
Color lineClr;
|
||||
|
||||
if (lineStyle != null)
|
||||
{
|
||||
lineClr = lineStyle.getLineColor(lineColorStyle, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
lineClr = getStyleColor(lineColorStyle);
|
||||
}
|
||||
|
||||
int styleVariation = quickStyleVals.getQuickStyleVariation();
|
||||
|
||||
//TODO using the fill color does not cover all the cases but works with most of the sample files
|
||||
if ((styleVariation & 4) > 0)
|
||||
{
|
||||
lineClr = getFillColor(quickStyleVals);
|
||||
}
|
||||
return lineClr;
|
||||
}
|
||||
|
||||
//Get line color based on QuickStyleLineColor & QuickStyleLineMatrix
|
||||
public Color getLineColor(QuickStyleVals quickStyleVals)
|
||||
{
|
||||
return getLineColor(quickStyleVals, lineStyles);
|
||||
}
|
||||
|
||||
//Get connection line color based on QuickStyleLineColor & QuickStyleLineMatrix
|
||||
public Color getConnLineColor(QuickStyleVals quickStyleVals)
|
||||
{
|
||||
return getLineColor(quickStyleVals, connLineStyles);
|
||||
}
|
||||
|
||||
|
||||
public Color getDefaultLineClr()
|
||||
{
|
||||
return defaultLineClr;
|
||||
}
|
||||
|
||||
private boolean isLineDashed(QuickStyleVals quickStyleVals, ArrayList<LineStyleExt> lineStylesExt, ArrayList<LineStyle> lineStyles)
|
||||
{
|
||||
LineStyleExt lineStyleExt = getLineStyleExt(quickStyleVals.getQuickStyleLineMatrix(), lineStylesExt);
|
||||
|
||||
if (lineStyleExt != null)
|
||||
{
|
||||
return lineStyleExt.isDashed();
|
||||
}
|
||||
else
|
||||
{
|
||||
LineStyle lineStyle = getLineStyle(quickStyleVals.getQuickStyleLineMatrix(), lineStyles);
|
||||
return lineStyle != null? lineStyle.isDashed() : false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLineDashed(QuickStyleVals quickStyleVals)
|
||||
{
|
||||
return isLineDashed(quickStyleVals, lineStylesExt, lineStyles);
|
||||
}
|
||||
|
||||
public boolean isConnLineDashed(QuickStyleVals quickStyleVals)
|
||||
{
|
||||
return isLineDashed(quickStyleVals, connLineStylesExt, connLineStyles);
|
||||
}
|
||||
|
||||
private ArrayList<Double> getLineDashPattern(QuickStyleVals quickStyleVals, ArrayList<LineStyleExt> lineStylesExt, ArrayList<LineStyle> lineStyles)
|
||||
{
|
||||
LineStyleExt lineStyleExt = getLineStyleExt(quickStyleVals.getQuickStyleLineMatrix(), lineStylesExt);
|
||||
|
||||
if (lineStyleExt != null)
|
||||
{
|
||||
return lineStyleExt.getLineDashPattern();
|
||||
}
|
||||
else
|
||||
{
|
||||
LineStyle lineStyle = getLineStyle(quickStyleVals.getQuickStyleLineMatrix(), lineStyles);
|
||||
return lineStyle != null? lineStyle.getLineDashPattern() : null;
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<Double> getLineDashPattern(QuickStyleVals quickStyleVals)
|
||||
{
|
||||
return getLineDashPattern(quickStyleVals, lineStylesExt, lineStyles);
|
||||
}
|
||||
|
||||
public ArrayList<Double> getConnLineDashPattern(QuickStyleVals quickStyleVals)
|
||||
{
|
||||
return getLineDashPattern(quickStyleVals, connLineStylesExt, connLineStyles);
|
||||
}
|
||||
|
||||
private int getArrowSize(QuickStyleVals quickStyleVals, boolean isStart, ArrayList<LineStyleExt> lineStylesExt, ArrayList<LineStyle> lineStyles)
|
||||
{
|
||||
LineStyleExt lineStyleExt = getLineStyleExt(quickStyleVals.getQuickStyleLineMatrix(), lineStylesExt);
|
||||
|
||||
if (lineStyleExt != null)
|
||||
{
|
||||
return isStart? lineStyleExt.getStartSize() : lineStyleExt.getEndSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
LineStyle lineStyle = getLineStyle(quickStyleVals.getQuickStyleLineMatrix(), lineStyles);
|
||||
return lineStyle != null? (isStart? lineStyle.getStartSize() : lineStyle.getEndSize()) : 4;
|
||||
}
|
||||
}
|
||||
|
||||
public int getStartSize(QuickStyleVals quickStyleVals)
|
||||
{
|
||||
return getArrowSize(quickStyleVals, true, lineStylesExt, lineStyles);
|
||||
}
|
||||
|
||||
public int getConnStartSize(QuickStyleVals quickStyleVals)
|
||||
{
|
||||
return getArrowSize(quickStyleVals, true, connLineStylesExt, connLineStyles);
|
||||
}
|
||||
|
||||
public int getEndSize(QuickStyleVals quickStyleVals)
|
||||
{
|
||||
return getArrowSize(quickStyleVals, false, lineStylesExt, lineStyles);
|
||||
}
|
||||
|
||||
public int getConnEndSize(QuickStyleVals quickStyleVals)
|
||||
{
|
||||
return getArrowSize(quickStyleVals, false, connLineStylesExt, connLineStyles);
|
||||
}
|
||||
|
||||
//Get font color based on QuickStyleFontColor & QuickStyleFontMatrix
|
||||
private Color getFontColor(QuickStyleVals quickStyleVals, ArrayList<OoxmlColor> fontColors)
|
||||
{
|
||||
processTheme();
|
||||
|
||||
int fontColorStyle = quickStyleVals.getQuickStyleFontColor();
|
||||
OoxmlColor fontColor = null;
|
||||
switch (quickStyleVals.getQuickStyleFontMatrix())
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
fontColor = fontColors.get(quickStyleVals.getQuickStyleFontMatrix() - 1);
|
||||
break;
|
||||
case 100:
|
||||
case 101:
|
||||
case 102:
|
||||
case 103:
|
||||
if (isMonotoneVariant[themeVariant]) fontColorStyle = 100;
|
||||
|
||||
int index = quickStyleVals.getQuickStyleFontMatrix() - 100;
|
||||
//get style index of variants
|
||||
//If an edge has a non-standard value, use the dark color
|
||||
if (fontColors != this.fontColors)
|
||||
{
|
||||
fontColor = this.baseColors.get("dk1");
|
||||
}
|
||||
else
|
||||
{
|
||||
fontColor = fontColors.get(variantFontIdx[themeVariant][index] - 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Color txtColor;
|
||||
|
||||
if (fontColor != null)
|
||||
{
|
||||
txtColor = fontColor.getColor(fontColorStyle, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
txtColor = getStyleColor(fontColorStyle);
|
||||
}
|
||||
|
||||
int styleVariation = quickStyleVals.getQuickStyleVariation();
|
||||
|
||||
//TODO The formula in the documentation doesn't match how vsdx viewer works. Simply using the fill/line color works!
|
||||
// Note: Using the fill/line color does not cover all the cases but works with most of the sample files
|
||||
if ((styleVariation & 2) > 0)
|
||||
{
|
||||
Color fillColor = getFillColor(quickStyleVals);
|
||||
HSLColor fillHSLClr = fillColor.toHsl();
|
||||
// HSLColor txtColorHSL = txtColor.toHsl();
|
||||
// if (Math.abs(fillHSLClr.getLum() - txtColorHSL.getLum()) < 0.1616)
|
||||
// {
|
||||
// if (fillHSLClr.getLum() < 0.7292)
|
||||
// {
|
||||
// txtColor = new Color(255, 255, 255);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
Color lineClr = getLineColor(quickStyleVals);
|
||||
HSLColor lineHSLClr = lineClr.toHsl();
|
||||
if (fillHSLClr.getLum() < lineHSLClr.getLum())
|
||||
{
|
||||
txtColor = fillColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
txtColor = lineClr;
|
||||
}
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
return txtColor;
|
||||
}
|
||||
|
||||
//Get font color based on QuickStyleFontColor & QuickStyleFontMatrix
|
||||
public Color getFontColor(QuickStyleVals quickStyleVals)
|
||||
{
|
||||
return getFontColor(quickStyleVals, fontColors);
|
||||
}
|
||||
|
||||
//Get connection font color based on QuickStyleFontColor & QuickStyleFontMatrix
|
||||
public Color getConnFontColor(QuickStyleVals quickStyleVals)
|
||||
{
|
||||
return getFontColor(quickStyleVals, connFontColors);
|
||||
}
|
||||
|
||||
private int getArrowType(QuickStyleVals quickStyleVals, boolean isStart, ArrayList<LineStyleExt> lineStylesExt, ArrayList<LineStyle> lineStyles)
|
||||
{
|
||||
LineStyleExt lineStyleExt = getLineStyleExt(quickStyleVals.getQuickStyleLineMatrix(), lineStylesExt);
|
||||
|
||||
if (lineStyleExt != null)
|
||||
{
|
||||
return isStart? lineStyleExt.getStart() : lineStyleExt.getEnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
LineStyle lineStyle = getLineStyle(quickStyleVals.getQuickStyleLineMatrix(), lineStyles);
|
||||
return lineStyle != null? (isStart? lineStyle.getStart() : lineStyle.getEnd()) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int getEdgeMarker(boolean isStart, QuickStyleVals quickStyleVals)
|
||||
{
|
||||
return getArrowType(quickStyleVals, isStart, lineStylesExt, lineStyles);
|
||||
}
|
||||
|
||||
public int getConnEdgeMarker(boolean isStart, QuickStyleVals quickStyleVals)
|
||||
{
|
||||
return getArrowType(quickStyleVals, isStart, connLineStylesExt, connLineStyles);
|
||||
}
|
||||
|
||||
|
||||
private int getLineWidth(QuickStyleVals quickStyleVals, ArrayList<LineStyle> lineStyles)
|
||||
{
|
||||
LineStyle lineStyle = getLineStyle(quickStyleVals.getQuickStyleLineMatrix(), lineStyles);
|
||||
return lineStyle != null? lineStyle.getLineWidth() : 0;
|
||||
}
|
||||
|
||||
public int getLineWidth(QuickStyleVals quickStyleVals)
|
||||
{
|
||||
return getLineWidth(quickStyleVals, lineStyles);
|
||||
}
|
||||
|
||||
public int getConnLineWidth(QuickStyleVals quickStyleVals)
|
||||
{
|
||||
return getLineWidth(quickStyleVals, connLineStyles);
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
Comm-link=mxgraph.lean_mapping.comm_link_edge
|
||||
Comm-link\ 1=mxgraph.lean_mapping.comm_link_edge
|
||||
Comm-link\ 2=mxgraph.lean_mapping.comm_link_edge
|
||||
Electronic\ information=mxgraph.lean_mapping.electronic_info_flow_edge
|
||||
Generalization=connector;endArrow\=block;endSize\=16;endFill\=0
|
|
@ -1 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns='http://schemas.openxmlformats.org/package/2006/content-types'><Default Extension='emf' ContentType='image/x-emf' /><Default Extension='rels' ContentType='application/vnd.openxmlformats-package.relationships+xml' /><Default Extension='xml' ContentType='application/xml' /><Override PartName='/docProps/app.xml' ContentType='application/vnd.openxmlformats-officedocument.extended-properties+xml' /><Override PartName='/docProps/core.xml' ContentType='application/vnd.openxmlformats-package.core-properties+xml' /><Override PartName='/docProps/custom.xml' ContentType='application/vnd.openxmlformats-officedocument.custom-properties+xml' /><Override PartName='/visio/document.xml' ContentType='application/vnd.ms-visio.drawing.main+xml' /><Override PartName='/visio/masters/masters.xml' ContentType='application/vnd.ms-visio.masters+xml' /><Override PartName='/visio/pages/page1.xml' ContentType='application/vnd.ms-visio.page+xml' /><Override PartName='/visio/pages/pages.xml' ContentType='application/vnd.ms-visio.pages+xml' /><Override PartName='/visio/windows.xml' ContentType='application/vnd.ms-visio.windows+xml' /></Types>
|
|
@ -1 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns='http://schemas.openxmlformats.org/package/2006/relationships'><Relationship Id='rId1' Type='http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties' Target='docProps/core.xml' /><Relationship Id='rId2' Type='http://schemas.microsoft.com/visio/2010/relationships/document' Target='visio/document.xml' /><Relationship Id='rId3' Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties' Target='docProps/custom.xml' /><Relationship Id='rId4' Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties' Target='docProps/app.xml' /></Relationships>
|
|
@ -1 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Properties xmlns='http://schemas.openxmlformats.org/officeDocument/2006/extended-properties' xmlns:vt='http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'><Application>Microsoft Visio</Application><AppVersion>15.0000</AppVersion><Template /><Manager /><Company /><HyperlinkBase /></Properties>
|
|
@ -1 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cp:coreProperties xmlns:cp='http://schemas.openxmlformats.org/package/2006/metadata/core-properties' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:dcterms='http://purl.org/dc/terms/' xmlns:dcmitype='http://purl.org/dc/dcmitype/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><dc:title /><dc:subject /><dc:creator /><cp:keywords /><dc:description /><cp:category /><dc:language>en-US</dc:language></cp:coreProperties>
|
|
@ -1 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Properties xmlns='http://schemas.openxmlformats.org/officeDocument/2006/custom-properties' xmlns:vt='http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes' />
|
|
@ -1 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns='http://schemas.openxmlformats.org/package/2006/relationships'><Relationship Id='rId1' Type='http://schemas.microsoft.com/visio/2010/relationships/masters' Target='masters/masters.xml' /><Relationship Id='rId2' Type='http://schemas.microsoft.com/visio/2010/relationships/pages' Target='pages/pages.xml' /><Relationship Id='rId3' Type='http://schemas.microsoft.com/visio/2010/relationships/windows' Target='windows.xml' /></Relationships>
|
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns='http://schemas.openxmlformats.org/package/2006/relationships' />
|
|
@ -1 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><Masters xmlns='http://schemas.microsoft.com/office/visio/2012/main' xmlns:r='http://schemas.openxmlformats.org/officeDocument/2006/relationships' xml:space='preserve' />
|
|
@ -1,2 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<Relationships xmlns='http://schemas.openxmlformats.org/package/2006/relationships' />
|
|
@ -1 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Windows ClientWidth='0' ClientHeight='0' xmlns='http://schemas.microsoft.com/office/visio/2012/main' xmlns:r='http://schemas.openxmlformats.org/officeDocument/2006/relationships' xml:space='preserve' />
|
|
@ -1,207 +0,0 @@
|
|||
Swimlane=swimlane;horizontal\=0;
|
||||
#new additions for custom Electrical set from here
|
||||
#Fundamental Items
|
||||
Resistor=mxgraph.electrical.resistors.resistor_1
|
||||
Capacitor=mxgraph.electrical.capacitors.capacitor_1
|
||||
AC source=mxgraph.electrical.signal_sources.ac_source
|
||||
DC source=mxgraph.electrical.signal_sources.dc_source_3
|
||||
Equipotentiality=mxgraph.electrical.signal_sources.signal_ground
|
||||
Ground=mxgraph.electrical.signal_sources.protective_earth
|
||||
Inductor=mxgraph.electrical.inductors.inductor
|
||||
Crystal=mxgraph.electrical.miscellaneous.crystal_1;direction=south
|
||||
Antenna=mxgraph.electrical.radio.aerial_-_antenna_2
|
||||
Chassis=mxgraph.electrical.miscellaneous.chassis
|
||||
Circuit breaker=mxgraph.electrical.miscellaneous.circuit_breaker;direction=south
|
||||
Ideal source=mxgraph.electrical.signal_sources.ideal_source
|
||||
Generic component=mxgraph.electrical.miscellaneous.generic_component
|
||||
Accumulator=mxgraph.electrical.miscellaneous.monocell_battery
|
||||
Alternating pulse=mxgraph.electrical.waveforms.sine_wave
|
||||
Half inductor=mxgraph.electrical.inductors.half_inductor
|
||||
Explosive squib=mxgraph.electrical.signal_sources.explosive_squib
|
||||
Ferrite core=mxgraph.electrical.inductors.ferrite_core
|
||||
Fuse=mxgraph.electrical.miscellaneous.fuse_4;direction=south
|
||||
Permanent magnet=mxgraph.electrical.miscellaneous.permanent_magnet
|
||||
Bell=mxgraph.electrical.electro-mechanical.bell
|
||||
Magnet core=mxgraph.electrical.inductors.magnetic_core;direction=south
|
||||
Thermal element=mxgraph.electrical.miscellaneous.thermal_element
|
||||
Saw tooth=mxgraph.electrical.waveforms.sawtooth
|
||||
Igniter plug=mxgraph.electrical.miscellaneous.igniter_plug
|
||||
Loop antenna=mxgraph.electrical.miscellaneous.loop_antenna
|
||||
Microphone 2=mxgraph.electrical.radio.microphone_2
|
||||
Oscillator=mxgraph.electrical.signal_sources.ac_source
|
||||
Pickup head=mxgraph.electrical.abstract.dac;flipH=1
|
||||
Squib ignitor=mxgraph.electrical.miscellaneous.squib_ignitor
|
||||
Battery=mxgraph.electrical.miscellaneous.monocell_battery;flipH=1
|
||||
Pulse=mxgraph.electrical.waveforms.pulse_1
|
||||
Speaker=mxgraph.electrical.electro-mechanical.loudspeaker
|
||||
Transducer=mxgraph.electrical.miscellaneous.transducer
|
||||
Transducer 2=mxgraph.electrical.miscellaneous.transducer_2
|
||||
Thermocouple=mxgraph.electrical.miscellaneous.thermocouple
|
||||
Thermopile=mxgraph.electrical.miscellaneous.thermopile
|
||||
Lamp=mxgraph.electrical.opto_electronics.lamp
|
||||
Lamp 2=mxgraph.electrical.miscellaneous.light_bulb
|
||||
Indicator=mxgraph.electrical.miscellaneous.indicator
|
||||
Surge protectors=mxgraph.electrical.miscellaneous.surge_protector
|
||||
Surge protectors 2=mxgraph.electrical.miscellaneous.surge_protector_2
|
||||
Material=rect
|
||||
Sensing link squib=mxgraph.electrical.miscellaneous.sensing_link_squib
|
||||
Fluorescent lamp=mxgraph.electrical.miscellaneous.flourescent_lamp
|
||||
Delay element=mxgraph.electrical.miscellaneous.delay_element
|
||||
Microphone=mxgraph.electrical.radio.microphone_1;flipH=1
|
||||
Step function=mxgraph.electrical.waveforms.step_1
|
||||
Buzzer=mxgraph.electrical.radio.buzzer
|
||||
Current controlled current source=mxgraph.electrical.signal_sources.dependent_source_2;flipV=1
|
||||
Voltage controlled current source=mxgraph.electrical.signal_sources.dependent_source_2;flipV=1
|
||||
Current controlled voltage source=mxgraph.electrical.signal_sources.dependent_source_3
|
||||
Voltage controlled voltage source=mxgraph.electrical.signal_sources.dependent_source_3
|
||||
Multicell battery=mxgraph.electrical.miscellaneous.multicell_battery;flipV=1
|
||||
Multicell battery with taps=mxgraph.electrical.miscellaneous.multicell_battery_tapped;flipV=1
|
||||
Attenuator=mxgraph.electrical.resistors.attenuator
|
||||
#Rotating Equipment and Mech. Functions
|
||||
Rotating machine=ellipse
|
||||
Armature=mxgraph.electrical.rot_mech.armature
|
||||
#Brush=
|
||||
Field=mxgraph.electrical.rot_mech.field
|
||||
Permanent magnet=mxgraph.electrical.miscellaneous.permanent_magnet
|
||||
Winding connection=mxgraph.electrical.rot_mech.winding_connection
|
||||
Synchro=mxgraph.electrical.rot_mech.synchro
|
||||
Brake=trapezoid
|
||||
Gearing=mxgraph.electrical.rot_mech.gearing
|
||||
Rotation=mxgraph.electrical.rot_mech.rotation
|
||||
Clutch=mxgraph.electrical.rot_mech.clutch
|
||||
Clutch 2=mxgraph.electrical.rot_mech.clutch_2
|
||||
Delayed action=mxgraph.electrical.rot_mech.delayed_action
|
||||
Manual control=mxgraph.electrical.rot_mech.manual_control
|
||||
Blocking device=mxgraph.electrical.rot_mech.blocking_device
|
||||
Latching device=mxgraph.electrical.rot_mech.latching_device
|
||||
Mechanical interlock=mxgraph.electrical.rot_mech.mechanical_interlock
|
||||
Automatic return=mxgraph.electrical.rot_mech.automatic_return
|
||||
Detent=mxgraph.electrical.rot_mech.detent
|
||||
#Switches and Relays
|
||||
Relay=mxgraph.electrical.electro-mechanical.relay
|
||||
Relay contacts=mxgraph.electrical.electro-mechanical.relay_contacts
|
||||
Switch disconnector=mxgraph.electrical.electro-mechanical.switch_disconnector;direction=north
|
||||
Fuse=mxgraph.electrical.electro-mechanical.fuse;direction=north
|
||||
Pilot light=mxgraph.electrical.electro-mechanical.pilot_light
|
||||
Relay coil=mxgraph.electrical.electro-mechanical.relay_coil_2
|
||||
Mercury switch=mxgraph.electrical.electro-mechanical.mercury_switch
|
||||
Mercury switch 2=mxgraph.electrical.electro-mechanical.mercury_switch_2
|
||||
Liquid level actuated=mxgraph.electrical.electro-mechanical.liquid_level_actuated
|
||||
Liquid level actuated 2=mxgraph.electrical.electro-mechanical.liquid_level_actuated_2
|
||||
Gas flow actuated=mxgraph.electrical.electro-mechanical.gas_flow_actuated
|
||||
Flow actuated=mxgraph.electrical.electro-mechanical.flow_actuated
|
||||
Pressure actuated=mxgraph.electrical.electro-mechanical.pressure_actuated
|
||||
Temperature actuated=mxgraph.electrical.electro-mechanical.temperature_actuated
|
||||
Safety interlock=mxgraph.electrical.electro-mechanical.safety_interlock
|
||||
Temperature switch=mxgraph.electrical.electro-mechanical.temperature_switch
|
||||
Thermostat=mxgraph.electrical.electro-mechanical.thermostat
|
||||
Limit switch=mxgraph.electrical.electro-mechanical.limit_switch;direction=north
|
||||
Circuit breaker=mxgraph.electrical.electro-mechanical.circuit_breaker;direction=north
|
||||
Selector switch=mxgraph.electrical.electro-mechanical.selector_switch
|
||||
Shorting selector=mxgraph.electrical.electro-mechanical.shorting_selector
|
||||
Proximity limit switch=mxgraph.electrical.electro-mechanical.proximity_limit_switch
|
||||
Inertia switch=mxgraph.electrical.electro-mechanical.inertia_switch
|
||||
Pushbutton break=mxgraph.electrical.electro-mechanical.pushbutton_break
|
||||
Manual switch=mxgraph.electrical.electro-mechanical.manual_switch;direction=north
|
||||
Make contact=mxgraph.electrical.electro-mechanical.make_contact;direction=north
|
||||
SPST=mxgraph.electrical.electro-mechanical.simple_switch
|
||||
SPDT=mxgraph.electrical.electro-mechanical.2-way_switch
|
||||
Break contact=mxgraph.electrical.electro-mechanical.break_contact
|
||||
Two way contact=mxgraph.electrical.electro-mechanical.two_way_contact;direction=north
|
||||
Passing make-contact=mxgraph.electrical.electro-mechanical.passing_make_contact;direction=north
|
||||
Stay put=mxgraph.electrical.electro-mechanical.stay_put;direction=north
|
||||
DPST=mxgraph.electrical.electro-mechanical.dpst
|
||||
Spring return=mxgraph.electrical.electro-mechanical.spring_return;direction=north
|
||||
Spring return 2=mxgraph.electrical.electro-mechanical.spring_return_2
|
||||
Spring return 3=mxgraph.electrical.electro-mechanical.spring_return_2;flipV=1
|
||||
Limit switch n/o=mxgraph.electrical.electro-mechanical.limit_switch_no
|
||||
Limit switch n/c=mxgraph.electrical.electro-mechanical.limit_switch_nc
|
||||
DPDT=mxgraph.electrical.electro-mechanical.dpdt
|
||||
2 position switch=mxgraph.electrical.electro-mechanical.2_position_switch
|
||||
3 position switch=mxgraph.electrical.electro-mechanical.3_position_switch
|
||||
4 position switch=mxgraph.electrical.electro-mechanical.4_position_switch
|
||||
Pushbutton make=mxgraph.electrical.electro-mechanical.pushbutton_make
|
||||
Pushbutton 2-circuit=mxgraph.electrical.electro-mechanical.pushbutton_2_circuit
|
||||
Time delay make=mxgraph.electrical.electro-mechanical.time_delay_make
|
||||
Time delay break=mxgraph.electrical.electro-mechanical.time_delay_break
|
||||
Time delay make 2=mxgraph.electrical.electro-mechanical.time_delay_make_2;direction=north
|
||||
Time delay break 2=mxgraph.electrical.electro-mechanical.time_delay_break_2;direction=north
|
||||
Isolator=mxgraph.electrical.electro-mechanical.isolator;direction=north
|
||||
Change-over contact=mxgraph.electrical.electro-mechanical.changeover_contact;direction=north
|
||||
#Terminals and Connectors
|
||||
Adapter=mxgraph.electrical.miscellaneous.adapter
|
||||
Circuit terminal=ellipse;perimeter=ellipsePerimeter
|
||||
#M/F contact=
|
||||
M/F contact 2=mxgraph.electrical.miscellaneous.mf_contact_2
|
||||
Terminal board=mxgraph.electrical.miscellaneous.terminal_board
|
||||
Cable termination=mxgraph.electrical.miscellaneous.cable_termination
|
||||
2-conductor jack=mxgraph.electrical.miscellaneous.2_conductor_jack
|
||||
3-conductor jack=mxgraph.electrical.miscellaneous.3_conductor_jack
|
||||
2-conductor plug=mxgraph.electrical.miscellaneous.2_conductor_plug
|
||||
3-conductor plug=mxgraph.electrical.miscellaneous.3_conductor_plug
|
||||
Normalled jacks=mxgraph.electrical.miscellaneous.normalled_jacks
|
||||
Normalled jack=mxgraph.electrical.miscellaneous.normalled_jack
|
||||
Coaxial outside conductor=mxgraph.electrical.miscellaneous.coaxial_outside_conductor
|
||||
Coaxial center conductor=mxgraph.electrical.miscellaneous.coaxial_center_conductor
|
||||
Large D connector=mxgraph.electrical.miscellaneous.large_d_connector
|
||||
Small D connector=mxgraph.electrical.miscellaneous.small_d_connector
|
||||
C header connector=mxgraph.electrical.miscellaneous.c_header_connector
|
||||
AC out=mxgraph.electrical.miscellaneous.ac_out
|
||||
Shielded jack/plug=mxgraph.electrical.miscellaneous.shielded_jack_plug
|
||||
Coaxial jack/plug=mxgraph.electrical.miscellaneous.coaxial_jack_plug
|
||||
F/M 2-conductor 1=mxgraph.electrical.miscellaneous.f_m_2_conductor_1
|
||||
F/M 2-conductor 2=mxgraph.electrical.miscellaneous.f_m_2_conductor_2
|
||||
F/M 2-conductor 3=mxgraph.electrical.miscellaneous.f_m_2_conductor_3
|
||||
F/M 3-conductor 1=mxgraph.electrical.miscellaneous.f_m_3_conductor_1
|
||||
F/M 3-conductor 2=mxgraph.electrical.miscellaneous.f_m_3_conductor_2
|
||||
F/M 3-conductor 3=mxgraph.electrical.miscellaneous.f_m_3_conductor_3
|
||||
F/M 3-conductor 4=mxgraph.electrical.miscellaneous.f_m_3_conductor_4
|
||||
F/M 3-conductor 5=mxgraph.electrical.miscellaneous.f_m_3_conductor_5
|
||||
#Transformers and Windings
|
||||
Transformer=mxgraph.electrical.inductors.transformer;direction=north
|
||||
Magnetic core=mxgraph.electrical.inductors.magnetic_core
|
||||
Inductor=mxgraph.electrical.inductors.inductor
|
||||
Choke=mxgraph.electrical.inductors.choke
|
||||
Variometer=mxgraph.electrical.inductors.variometer
|
||||
Coaxial choke=mxgraph.electrical.inductors.coaxial_choke
|
||||
Transductor=mxgraph.electrical.inductors.transductor
|
||||
Saturating transformer=mxgraph.electrical.inductors.saturating_transformer
|
||||
Transformer 2=mxgraph.electrical.signal_sources.current_source
|
||||
Adjustable transformer=mxgraph.electrical.inductors.adjustable_transformer
|
||||
1-phase induction volt. reg.=mxgraph.electrical.inductors.1_phase_induction_volt_reg
|
||||
Triplex induction volt. reg.=mxgraph.electrical.inductors.triplex_induction_volt_reg
|
||||
Induction voltage regulator=mxgraph.electrical.inductors.induction_voltage_regulator
|
||||
Current transformer 1=mxgraph.electrical.inductors.current_transformer_1
|
||||
Current transformer 2=mxgraph.electrical.inductors.current_transformer_2
|
||||
Current transformer 3=mxgraph.electrical.inductors.current_transformer_3
|
||||
Potential transformer=mxgraph.electrical.inductors.potential_transformer
|
||||
Potential transformer 2=mxgraph.electrical.signal_sources.current_source;direction=north
|
||||
Pot. trans. 3 windings=mxgraph.electrical.inductors.pot_trans_3_windings
|
||||
Outdoor metering device=mxgraph.electrical.inductors.outdoor_metering_device
|
||||
Linear coupler=mxgraph.electrical.inductors.linear_coupler
|
||||
#Transmission paths
|
||||
Bus width=mxgraph.electrical.transmission.bus_width
|
||||
Straight bus=mxgraph.electrical.transmission.straightBus
|
||||
Line concentrator=mxgraph.electrical.transmission.line_concentrator
|
||||
Cable group=mxgraph.electrical.transmission.cable_group
|
||||
#Lead group=
|
||||
Overground enclosure=mxgraph.electrical.transmission.overground_enclosure
|
||||
Optical fiber=mxgraph.electrical.transmission.optical_fiber
|
||||
Terminal=ellipse
|
||||
Terminal 3-phase=mxgraph.electrical.transmission.terminal_3_phase
|
||||
Test point=mxgraph.electrical.transmission.testPoint
|
||||
Label=ellipse;perimeter=ellipsePerimeter
|
||||
Line/cable=mxgraph.electrical.transmission.line_cable
|
||||
Anticreepage device=mxgraph.electrical.transmission.anticreepage_device
|
||||
#Transmission path=
|
||||
#Direction of flow=
|
||||
Elbow bus 1=mxgraph.arrows2.bendArrow;dy=15;dx=38;notch=0;arrowHead=55;direction=south
|
||||
Elbow bus 2=mxgraph.arrows2.bendArrow;dy=15;dx=38;notch=0;arrowHead=55;direction=south;flipV=1
|
||||
2-line bus=mxgraph.electrical.transmission.2_line_bus
|
||||
3-line bus=mxgraph.electrical.transmission.3_line_bus
|
||||
4-line bus=mxgraph.electrical.transmission.4_line_bus
|
||||
8-line bus=mxgraph.electrical.transmission.8_line_bus
|
||||
2-line bus elbow=mxgraph.electrical.transmission.twoLineBusElbow;notch=25
|
||||
3-line bus elbow=mxgraph.electrical.transmission.threeLineBusElbow;notch=25
|
||||
4-line bus elbow=mxgraph.electrical.transmission.fourLineBusElbow;notch=25
|
||||
8-line bus elbow=mxgraph.electrical.transmission.eightLineBusElbow;notch=25
|
File diff suppressed because it is too large
Load diff
|
@ -1,124 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.theme;
|
||||
|
||||
public class Color {
|
||||
//Special none color
|
||||
public static final Color NONE = new Color(-1, -1, -1);
|
||||
|
||||
private int red, green, blue;
|
||||
private Color gradientClr;
|
||||
|
||||
public Color(int red, int green, int blue) {
|
||||
this.red = red;
|
||||
this.green = green;
|
||||
this.blue = blue;
|
||||
}
|
||||
|
||||
public int getRed() {
|
||||
return red;
|
||||
}
|
||||
|
||||
public void setRed(int red) {
|
||||
this.red = red;
|
||||
}
|
||||
|
||||
public int getGreen() {
|
||||
return green;
|
||||
}
|
||||
|
||||
public void setGreen(int green) {
|
||||
this.green = green;
|
||||
}
|
||||
|
||||
public int getBlue() {
|
||||
return blue;
|
||||
}
|
||||
|
||||
public void setBlue(int blue) {
|
||||
this.blue = blue;
|
||||
}
|
||||
|
||||
public HSLColor toHsl()
|
||||
{
|
||||
double r = this.getRed()/255.0, g = this.getGreen()/255.0, b = this.getBlue()/255.0;
|
||||
double max = Math.max(r, Math.max(g, b));
|
||||
double min = Math.min(r, Math.min(g, b));
|
||||
double l = (max + min) / 2.0;
|
||||
double h, s;
|
||||
|
||||
if(max == min)
|
||||
{
|
||||
h = s = 0; // achromatic
|
||||
}
|
||||
else
|
||||
{
|
||||
double d = max - min;
|
||||
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
||||
if (max == r)
|
||||
{
|
||||
h = (g - b) / d + (g < b ? 6 : 0);
|
||||
}
|
||||
else if (max == g)
|
||||
{
|
||||
h = (b - r) / d + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
h = (r - g) / d + 4;
|
||||
}
|
||||
|
||||
h /= 6;
|
||||
}
|
||||
return new HSLColor(h, s, l);
|
||||
}
|
||||
|
||||
public HSVColor toHsv()
|
||||
{
|
||||
double r = this.getRed()/255.0, g = this.getGreen()/255.0, b = this.getBlue()/255.0;
|
||||
double max = Math.max(r, Math.max(g, b));
|
||||
double min = Math.min(r, Math.min(g, b));
|
||||
double h, s, v = max;
|
||||
|
||||
double d = max - min;
|
||||
s = max == 0 ? 0 : d / max;
|
||||
|
||||
if(max == min)
|
||||
{
|
||||
h = 0; // achromatic
|
||||
}
|
||||
else
|
||||
{
|
||||
if (max == r)
|
||||
{
|
||||
h = (g - b) / d + (g < b ? 6 : 0);
|
||||
}
|
||||
else if (max == g)
|
||||
{
|
||||
h = (b - r) / d + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
h = (r - g) / d + 4;
|
||||
}
|
||||
h /= 6;
|
||||
}
|
||||
return new HSVColor(h, s, v);
|
||||
}
|
||||
|
||||
public static Color decodeColorHex(String hex)
|
||||
{
|
||||
int color = Integer.parseInt(hex, 16);
|
||||
return new Color((color >> 16) & 0xff , (color >> 8) & 0xff, color & 0xff);
|
||||
}
|
||||
|
||||
public String toHexStr() {
|
||||
return String.format("#%02x%02x%02x", red, green, blue);
|
||||
}
|
||||
|
||||
public Color getGradientClr() {
|
||||
return gradientClr;
|
||||
}
|
||||
|
||||
public void setGradientClr(Color gradientClr) {
|
||||
this.gradientClr = gradientClr;
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.theme;
|
||||
|
||||
import com.mxgraph.io.vsdx.mxVsdxTheme;
|
||||
|
||||
public interface FillStyle {
|
||||
public Color applyStyle(int styleValue, mxVsdxTheme theme);
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.theme;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import com.mxgraph.io.vsdx.mxVsdxUtils;
|
||||
|
||||
public class FillStyleFactory
|
||||
{
|
||||
public static FillStyle getFillStyle(Element fillStyle)
|
||||
{
|
||||
FillStyle fillObj = null;
|
||||
switch (fillStyle.getNodeName())
|
||||
{
|
||||
case "a:solidFill":
|
||||
fillObj = new SolidFillStyle(OoxmlColorFactory.getOoxmlColor(
|
||||
mxVsdxUtils.getDirectFirstChildElement(fillStyle)));
|
||||
break;
|
||||
case "a:noFill":
|
||||
fillObj = new NoFillStyle();
|
||||
break;
|
||||
case "a:gradFill":
|
||||
fillObj = new GradFill(fillStyle);
|
||||
break;
|
||||
case "a:blipFill":
|
||||
//TODO implement Picture Fill if it can be approximated in mxGraph
|
||||
break;
|
||||
case "a:pattFill":
|
||||
//TODO implement Pattern Fill if it can be approximated in mxGraph
|
||||
break;
|
||||
case "a:grpFill":
|
||||
//TODO implement Group Fill if it can be approximated in mxGraph
|
||||
break;
|
||||
}
|
||||
return fillObj;
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.theme;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import com.mxgraph.io.vsdx.mxVsdxTheme;
|
||||
import com.mxgraph.io.vsdx.mxVsdxUtils;
|
||||
|
||||
//mxGraph doesn't support such a complex gradient fill style. So, we will approximate the gradient by the first two colors only
|
||||
public class GradFill implements FillStyle
|
||||
{
|
||||
private OoxmlColor color1 = null, color2 = null;
|
||||
|
||||
public GradFill(Element elem)
|
||||
{
|
||||
ArrayList<Element> gsLst = mxVsdxUtils.getDirectChildNamedElements(elem, "a:gsLst");
|
||||
|
||||
if (gsLst.size() > 0)
|
||||
{
|
||||
ArrayList<Element> gs = mxVsdxUtils.getDirectChildElements(gsLst.get(0));
|
||||
|
||||
//approximate gradient by first and last color in the list
|
||||
if (gs.size() >= 2)
|
||||
{
|
||||
color2 = OoxmlColorFactory.getOoxmlColor(
|
||||
mxVsdxUtils.getDirectFirstChildElement(gs.get(0)));
|
||||
color1 = OoxmlColorFactory.getOoxmlColor(
|
||||
mxVsdxUtils.getDirectFirstChildElement(gs.get(gs.size()-1)));
|
||||
}
|
||||
}
|
||||
|
||||
if (color1 == null)
|
||||
{
|
||||
color1 = color2 = new SrgbClr("FFFFFF");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color applyStyle(int styleValue, mxVsdxTheme theme)
|
||||
{
|
||||
Color color = color1.getColor(styleValue, theme);
|
||||
color.setGradientClr(color2.getColor(styleValue, theme));
|
||||
return color;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.theme;
|
||||
|
||||
public class HSLColor
|
||||
{
|
||||
private double hue, sat, lum;
|
||||
|
||||
public HSLColor(double hue, double sat, double lum)
|
||||
{
|
||||
this.hue = hue;
|
||||
this.sat = sat;
|
||||
this.lum = lum;
|
||||
}
|
||||
|
||||
public double getHue() {
|
||||
return hue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setHue(double hue) {
|
||||
this.hue = hue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public double getSat() {
|
||||
return sat;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setSat(double sat) {
|
||||
this.sat = sat;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public double getLum() {
|
||||
return lum;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setLum(double lum) {
|
||||
this.lum = lum;
|
||||
}
|
||||
|
||||
private double hue2rgb(double p, double q, double t)
|
||||
{
|
||||
if (t < 0) t += 1;
|
||||
if (t > 1) t -= 1;
|
||||
if (t < 1/6.0) return p + (q - p) * 6 * t;
|
||||
if (t < 0.5) return q;
|
||||
if (t < 2/3.0) return p + (q - p) * (2/3.0 - t) * 6;
|
||||
return p;
|
||||
}
|
||||
|
||||
public Color toRgb()
|
||||
{
|
||||
double r, g, b;
|
||||
|
||||
double h = this.hue;
|
||||
double s = this.sat;
|
||||
double l = this.lum;
|
||||
|
||||
|
||||
if(s == 0)
|
||||
{
|
||||
r = g = b = l; // achromatic
|
||||
}
|
||||
else
|
||||
{
|
||||
double q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
||||
double p = 2 * l - q;
|
||||
r = hue2rgb(p, q, h + 1/3.0);
|
||||
g = hue2rgb(p, q, h);
|
||||
b = hue2rgb(p, q, h - 1/3.0);
|
||||
}
|
||||
|
||||
return new Color((int) (r * 255), (int) (g * 255), (int) (b * 255));
|
||||
}
|
||||
|
||||
// Force a number between 0 and 1
|
||||
private double clamp01(double val)
|
||||
{
|
||||
return Math.min(1, Math.max(0, val));
|
||||
}
|
||||
|
||||
//lighten or tint
|
||||
public HSLColor tint (int amount)
|
||||
{
|
||||
// HSLColor hsl = color.toHsl();
|
||||
this.lum *= (1 + (amount / 100.0));
|
||||
this.lum = clamp01(this.lum);
|
||||
return this;
|
||||
}
|
||||
|
||||
//darken or shade
|
||||
public HSLColor shade(int amount)
|
||||
{
|
||||
this.lum *= amount / 100.0;
|
||||
this.lum = clamp01(this.lum);
|
||||
return this;
|
||||
}
|
||||
|
||||
public HSLColor satMod(int amount)
|
||||
{
|
||||
this.sat *= amount / 100.0;
|
||||
this.sat = clamp01(this.sat);
|
||||
return this;
|
||||
}
|
||||
|
||||
public HSLColor lumMod(int amount)
|
||||
{
|
||||
this.lum *= amount / 100.0;
|
||||
this.lum = clamp01(this.lum);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.theme;
|
||||
|
||||
public class HSVColor {
|
||||
private double h, s, v;
|
||||
|
||||
public HSVColor(double h, double s, double v) {
|
||||
this.h = h;
|
||||
this.s = s;
|
||||
this.v = v;
|
||||
}
|
||||
|
||||
public Color toRgb()
|
||||
{
|
||||
double h = this.h * 6;
|
||||
double s = this.s;
|
||||
double l = this.v;
|
||||
|
||||
double i = Math.floor(h);
|
||||
double f = h - i, p = v * (1 - s);
|
||||
double q = v * (1 - f * s), t = v * (1 - (1 - f) * s);
|
||||
int mod = (int)i % 6;
|
||||
|
||||
double[] rArr = {v, q, p, p, t, v};
|
||||
double[] gArr = {t, v, v, q, p, p};
|
||||
double[] bArr = {p, p, t, v, v, q};
|
||||
double r = rArr[mod], g = gArr[mod], b = bArr[mod];
|
||||
|
||||
return new Color((int) (r * 255), (int) (g * 255), (int) (b * 255));
|
||||
}
|
||||
|
||||
// Force a number between 0 and 1
|
||||
private double clamp01(double val)
|
||||
{
|
||||
return Math.min(1, Math.max(0, val));
|
||||
}
|
||||
|
||||
//lighten or tint
|
||||
public HSVColor tint (int amount)
|
||||
{
|
||||
this.v *= (1 + (amount / 100.0));
|
||||
this.v = clamp01(this.v);
|
||||
return this;
|
||||
}
|
||||
|
||||
//darken or shade
|
||||
public HSVColor shade(int amount)
|
||||
{
|
||||
this.v *= amount / 100.0;
|
||||
this.v = clamp01(this.v);
|
||||
return this;
|
||||
}
|
||||
|
||||
public HSVColor satMod(int amount)
|
||||
{
|
||||
this.s *= amount / 100.0;
|
||||
this.s = clamp01(this.s);
|
||||
return this;
|
||||
}
|
||||
|
||||
public HSVColor lumMod(int amount)
|
||||
{
|
||||
this.v *= amount / 100.0;
|
||||
this.v = clamp01(this.v);
|
||||
return this;
|
||||
}
|
||||
|
||||
public HSVColor hueMod(int amount)
|
||||
{
|
||||
this.h *= amount / 100.0;
|
||||
this.h = clamp01(this.h);
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.theme;
|
||||
|
||||
public class HslClr extends OoxmlColor {
|
||||
private double hue, sat, lum;
|
||||
|
||||
public HslClr(int hue, int sat, int lum) {
|
||||
this.hue = hue / 360.0;
|
||||
this.sat = sat / 100.0;
|
||||
this.lum = lum / 100.0;
|
||||
color = new HSLColor(hue, sat, lum).toRgb();
|
||||
}
|
||||
}
|
|
@ -1,263 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.theme;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import com.mxgraph.io.vsdx.mxVsdxTheme;
|
||||
import com.mxgraph.io.vsdx.mxVsdxUtils;
|
||||
|
||||
public class LineStyle {
|
||||
|
||||
public enum LineCapType
|
||||
{
|
||||
ROUND, SQUARE, FLAT
|
||||
}
|
||||
|
||||
public enum CompoundLineType
|
||||
{
|
||||
SINGLE, DOUBLE, THICK_THIN_DOUBLE, THIN_THICK_DOUBLE, THIN_THICK_THIN_TRIPLE
|
||||
}
|
||||
|
||||
public enum LineEndType
|
||||
{
|
||||
NONE, TRIANGLE, STEALTH, DIAMOND, OVAL, ARROW
|
||||
}
|
||||
|
||||
private int lineWidth;
|
||||
private LineCapType lineCap;
|
||||
private CompoundLineType lineComp;
|
||||
private FillStyle fillStyle;
|
||||
|
||||
private boolean isLineDashed = false;
|
||||
private ArrayList<Double> lineDashPattern = new ArrayList<>();
|
||||
|
||||
private boolean isRoundJoin = false, isBevelJoin = false, isMiterJoin = false;
|
||||
|
||||
private LineEndType headEndType;
|
||||
private int headEndWidth, headEndLen;
|
||||
|
||||
private LineEndType tailEndType;
|
||||
private int tailEndWidth, tailEndLen;
|
||||
|
||||
public LineStyle()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public LineStyle(Element elem)
|
||||
{
|
||||
//parse the line style xml
|
||||
lineWidth = mxVsdxUtils.getIntAttr(elem, "w");
|
||||
|
||||
String lineCapAtt = elem.getAttribute("cap");
|
||||
|
||||
if (lineCapAtt != null)
|
||||
{
|
||||
switch (lineCapAtt)
|
||||
{
|
||||
case "rnd":
|
||||
lineCap = LineCapType.ROUND;
|
||||
break;
|
||||
case "sq":
|
||||
lineCap = LineCapType.SQUARE;
|
||||
break;
|
||||
case "flat":
|
||||
lineCap = LineCapType.FLAT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
String lineCompAtt = elem.getAttribute("cmpd");
|
||||
|
||||
if (lineCompAtt != null)
|
||||
{
|
||||
switch (lineCompAtt)
|
||||
{
|
||||
case "sng":
|
||||
lineComp = CompoundLineType.SINGLE;
|
||||
break;
|
||||
case "dbl":
|
||||
lineComp = CompoundLineType.DOUBLE;
|
||||
break;
|
||||
case "thickThin":
|
||||
lineComp = CompoundLineType.THICK_THIN_DOUBLE;
|
||||
break;
|
||||
case "thinThick":
|
||||
lineComp = CompoundLineType.THIN_THICK_DOUBLE;
|
||||
break;
|
||||
case "tri":
|
||||
lineComp = CompoundLineType.THIN_THICK_THIN_TRIPLE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO add algn (Stroke Alignment) attrinbute support [http://www.datypic.com/sc/ooxml/a-algn-4.html]
|
||||
|
||||
ArrayList<Element> subElems = mxVsdxUtils.getDirectChildElements(elem);
|
||||
|
||||
for (Element subElem : subElems)
|
||||
{
|
||||
String name = subElem.getNodeName();
|
||||
|
||||
switch(name)
|
||||
{
|
||||
case "a:noFill":
|
||||
case "a:solidFill":
|
||||
case "a:gradFill":
|
||||
case "a:pattFill":
|
||||
fillStyle = FillStyleFactory.getFillStyle(subElem);
|
||||
break;
|
||||
case "a:prstDash":
|
||||
String val = subElem.getAttribute("val");
|
||||
|
||||
isLineDashed = true;
|
||||
switch (val)
|
||||
{
|
||||
case "solid":
|
||||
isLineDashed = false;
|
||||
break;
|
||||
case "sysDot":
|
||||
case "dot":
|
||||
lineDashPattern.add(1.0);
|
||||
lineDashPattern.add(4.0);
|
||||
break;
|
||||
case "sysDash":
|
||||
case "dash":
|
||||
//use the default dashed pattern
|
||||
break;
|
||||
case "lgDash":
|
||||
lineDashPattern.add(12.0);
|
||||
lineDashPattern.add(4.0);
|
||||
break;
|
||||
case "sysDashDot":
|
||||
case "dashDot":
|
||||
lineDashPattern.add(8.0);
|
||||
lineDashPattern.add(4.0);
|
||||
lineDashPattern.add(1.0);
|
||||
lineDashPattern.add(4.0);
|
||||
break;
|
||||
case "lgDashDot":
|
||||
lineDashPattern.add(12.0);
|
||||
lineDashPattern.add(4.0);
|
||||
lineDashPattern.add(1.0);
|
||||
lineDashPattern.add(4.0);
|
||||
break;
|
||||
case "sysDashDotDot":
|
||||
case "lgDashDotDot":
|
||||
lineDashPattern.add(12.0);
|
||||
lineDashPattern.add(4.0);
|
||||
lineDashPattern.add(1.0);
|
||||
lineDashPattern.add(4.0);
|
||||
lineDashPattern.add(1.0);
|
||||
lineDashPattern.add(4.0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "a:custDash":
|
||||
isLineDashed = true;
|
||||
ArrayList<Element> dsElems = mxVsdxUtils.getDirectChildNamedElements(subElem, "a:ds");
|
||||
for (Element dsElem : dsElems)
|
||||
{
|
||||
int dashLen = mxVsdxUtils.getIntAttr(dsElem, "d");
|
||||
int spaceLen = mxVsdxUtils.getIntAttr(dsElem, "sp");
|
||||
//TODO find the correct conversion ratio from vsdx to mxGraph
|
||||
lineDashPattern.add(dashLen/10000.0);
|
||||
lineDashPattern.add(spaceLen/10000.0);
|
||||
}
|
||||
break;
|
||||
//https://www.w3schools.com/tags/playcanvas.asp?filename=playcanvas_lineJoin
|
||||
case "a:round": //Round Line Join
|
||||
isRoundJoin = true;
|
||||
break;
|
||||
case "a:bevel": //Bevel Line Join
|
||||
isBevelJoin = true;
|
||||
break;
|
||||
case "a:miter": //Miter Line Join
|
||||
// Miter Join Limit
|
||||
int limit = mxVsdxUtils.getIntAttr(subElem, "lim"); //?
|
||||
isMiterJoin = true;
|
||||
break;
|
||||
case "a:headEnd": //Line Head/End Style
|
||||
headEndType = getLineEndType(subElem);
|
||||
headEndWidth = mxVsdxUtils.getIntAttr(subElem, "w");
|
||||
headEndLen = mxVsdxUtils.getIntAttr(subElem, "len");
|
||||
break;
|
||||
case "a:tailEnd": //Tail line end style
|
||||
tailEndType = getLineEndType(subElem);
|
||||
tailEndWidth = mxVsdxUtils.getIntAttr(subElem, "w");
|
||||
tailEndLen = mxVsdxUtils.getIntAttr(subElem, "len");
|
||||
break;
|
||||
case "a:extLst": //Extension List!
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private LineEndType getLineEndType(Element subElem) {
|
||||
String type = subElem.getAttribute("type");
|
||||
LineEndType endType = null;
|
||||
switch (type)
|
||||
{
|
||||
case "none":
|
||||
endType = LineEndType.NONE;
|
||||
break;
|
||||
case "triangle":
|
||||
endType = LineEndType.TRIANGLE;
|
||||
break;
|
||||
case "stealth":
|
||||
endType = LineEndType.STEALTH;
|
||||
break;
|
||||
case "diamond":
|
||||
endType = LineEndType.DIAMOND;
|
||||
break;
|
||||
case "oval":
|
||||
endType = LineEndType.OVAL;
|
||||
break;
|
||||
case "arrow":
|
||||
endType = LineEndType.ARROW;
|
||||
break;
|
||||
}
|
||||
return endType;
|
||||
}
|
||||
|
||||
public Color getLineColor(int lineColorStyle, mxVsdxTheme theme) {
|
||||
if (fillStyle != null)
|
||||
return fillStyle.applyStyle(lineColorStyle, theme);
|
||||
else
|
||||
return theme.getDefaultLineClr();
|
||||
}
|
||||
|
||||
public boolean isDashed() {
|
||||
return isLineDashed;
|
||||
}
|
||||
|
||||
public ArrayList<Double> getLineDashPattern()
|
||||
{
|
||||
return lineDashPattern;
|
||||
}
|
||||
|
||||
public int getStartSize() {
|
||||
// TODO Implement this if it is needed
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int getEndSize() {
|
||||
// TODO Implement this if it is needed
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int getStart() {
|
||||
// TODO Implement this if it is needed
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getEnd() {
|
||||
// TODO Implement this if it is needed
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getLineWidth() {
|
||||
return lineWidth;
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.theme;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import com.mxgraph.io.vsdx.Style;
|
||||
import com.mxgraph.io.vsdx.mxVsdxUtils;
|
||||
|
||||
public class LineStyleExt {
|
||||
|
||||
private int rndg = 0, start = 0, startSize = 0, end = 0, endSize = 0, pattern = 0;
|
||||
private ArrayList<Double> lineDashPattern;
|
||||
|
||||
public LineStyleExt(Element elem)
|
||||
{
|
||||
Element lineEx = mxVsdxUtils.getDirectFirstChildElement(elem); //vt:lineEx element of vt:lineStyle
|
||||
|
||||
//parse the line style ext xml
|
||||
rndg = mxVsdxUtils.getIntAttr(lineEx, "rndg");
|
||||
start = mxVsdxUtils.getIntAttr(lineEx, "start");
|
||||
startSize = mxVsdxUtils.getIntAttr(lineEx, "startSize");
|
||||
end = mxVsdxUtils.getIntAttr(lineEx, "end");
|
||||
endSize = mxVsdxUtils.getIntAttr(lineEx, "endSize");
|
||||
pattern = mxVsdxUtils.getIntAttr(lineEx, "pattern");
|
||||
lineDashPattern = Style.getLineDashPattern(pattern);
|
||||
}
|
||||
|
||||
public int getRndg()
|
||||
{
|
||||
return rndg;
|
||||
}
|
||||
|
||||
public int getStart()
|
||||
{
|
||||
return start;
|
||||
}
|
||||
|
||||
public int getStartSize()
|
||||
{
|
||||
return startSize;
|
||||
}
|
||||
|
||||
public int getEnd()
|
||||
{
|
||||
return end;
|
||||
}
|
||||
|
||||
public int getEndSize()
|
||||
{
|
||||
return endSize;
|
||||
}
|
||||
|
||||
public boolean isDashed()
|
||||
{
|
||||
return pattern > 1;
|
||||
}
|
||||
|
||||
public ArrayList<Double> getLineDashPattern()
|
||||
{
|
||||
return lineDashPattern;
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package com.mxgraph.io.vsdx.theme;
|
||||
|
||||
import com.mxgraph.io.vsdx.mxVsdxTheme;
|
||||
|
||||
public class NoFillStyle implements FillStyle
|
||||
{
|
||||
|
||||
@Override
|
||||
public Color applyStyle(int styleValue, mxVsdxTheme theme)
|
||||
{
|
||||
return Color.NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue