27
27
import org .w3c .dom .Node ;
28
28
import org .w3c .dom .NodeList ;
29
29
30
- import com .mxgraph .io .vsdx .geometry .LineTo ;
31
- import com .mxgraph .io .vsdx .geometry .MoveTo ;
32
- import com .mxgraph .io .vsdx .geometry .Row ;
33
30
import com .mxgraph .io .vsdx .theme .Color ;
34
31
import com .mxgraph .model .mxCell ;
35
32
import com .mxgraph .model .mxGeometry ;
@@ -213,6 +210,11 @@ public VsdxShape(mxVsdxPage page, Element shape, boolean vertex, Map<String, mxV
213
210
{
214
211
masterShape .processGeomList (null );
215
212
processGeomList (masterShape .getGeomList ());
213
+
214
+ //recalculate width and height using master data
215
+ if (this .width == 0 ) this .width = getScreenNumericalValue (getCellElement (mxVsdxConstants .WIDTH ), 0 );
216
+
217
+ if (this .height == 0 ) this .height = getScreenNumericalValue (getCellElement (mxVsdxConstants .HEIGHT ), 0 );
216
218
}
217
219
else
218
220
{
@@ -1003,6 +1005,12 @@ else if (!(linePattern.equals("0") || linePattern.equals("1")))
1003
1005
*/
1004
1006
public double getLineWidth ()
1005
1007
{
1008
+ //if an edge has a fill geometry, then the line width matches the min of the shape width & height
1009
+ if (!isVertex () && geomList != null && !geomList .isNoFill ())
1010
+ {
1011
+ return Math .min (height , width );
1012
+ }
1013
+
1006
1014
String lineWeight = getValue (this .getCellElement (mxVsdxConstants .LINE_WEIGHT ), "0" );
1007
1015
1008
1016
double lWeight = 0 ;
@@ -1445,7 +1453,7 @@ public Map<String, String> getForm()
1445
1453
this .styleDebug ("shape type = " + type );
1446
1454
1447
1455
//The master may contain the foreign object data
1448
- if (this .imageData != null || (mxVsdxConstants .FOREIGN .equals (type ) && masterShape .imageData != null ))
1456
+ if (this .imageData != null || (mxVsdxConstants .FOREIGN .equals (type ) && masterShape != null && masterShape .imageData != null ))
1449
1457
{
1450
1458
Map <String , String > imageData = this .imageData != null ? this .imageData : masterShape .imageData ;
1451
1459
@@ -2072,8 +2080,8 @@ public mxCell createLabelSubShape(mxGraph graph, mxCell parent)
2072
2080
double txtHV = getScreenNumericalValue (getShapeNode (mxVsdxConstants .TXT_HEIGHT ), getHeight ());
2073
2081
double txtLocPinXV = getScreenNumericalValue (getShapeNode (mxVsdxConstants .TXT_LOC_PIN_X ), txtWV / 2.0 );
2074
2082
double txtLocPinYV = getScreenNumericalValue (getShapeNode (mxVsdxConstants .TXT_LOC_PIN_Y ), txtHV / 2.0 );
2075
- double txtPinXV =getScreenNumericalValue (getShapeNode (mxVsdxConstants .TXT_PIN_X ), 0 );
2076
- double txtPinYV = getScreenNumericalValue (getShapeNode (mxVsdxConstants .TXT_PIN_Y ), txtHV );
2083
+ double txtPinXV =getScreenNumericalValue (getShapeNode (mxVsdxConstants .TXT_PIN_X ), txtLocPinXV );
2084
+ double txtPinYV = getScreenNumericalValue (getShapeNode (mxVsdxConstants .TXT_PIN_Y ), txtLocPinYV );
2077
2085
double txtAngleV = getValueAsDouble (getShapeNode (mxVsdxConstants .TXT_ANGLE ), 0 );
2078
2086
2079
2087
String textLabel = getTextLabel ();
@@ -2084,9 +2092,11 @@ public mxCell createLabelSubShape(mxGraph graph, mxCell parent)
2084
2092
styleMap .put (mxConstants .STYLE_FILLCOLOR , mxConstants .NONE );
2085
2093
styleMap .put (mxConstants .STYLE_STROKECOLOR , mxConstants .NONE );
2086
2094
styleMap .put (mxConstants .STYLE_GRADIENTCOLOR , mxConstants .NONE );
2087
- styleMap .put ("align" , "center" );
2088
- styleMap .put ("verticalAlign" , "middle" );
2089
- styleMap .put ("whiteSpace" , "wrap" );
2095
+
2096
+ //We don't need to override these attributes in order to properly align the text
2097
+ if (!styleMap .containsKey ("align" )) styleMap .put ("align" , "center" );
2098
+ if (!styleMap .containsKey ("verticalAlign" )) styleMap .put ("verticalAlign" , "middle" );
2099
+ if (!styleMap .containsKey ("whiteSpace" )) styleMap .put ("whiteSpace" , "wrap" );
2090
2100
2091
2101
// Doesn't make sense to set a shape, it's not rendered and doesn't affect the text perimeter
2092
2102
styleMap .remove ("shape" );
0 commit comments