style update
This commit is contained in:
parent
efa86f02e5
commit
d46577f3d4
@ -3,6 +3,7 @@ package org.atriasoft.esvg;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.atriasoft.aknot.exception.AknotException;
|
||||||
import org.atriasoft.egami.ImageFloatRGBA;
|
import org.atriasoft.egami.ImageFloatRGBA;
|
||||||
import org.atriasoft.esvg.internal.Log;
|
import org.atriasoft.esvg.internal.Log;
|
||||||
import org.atriasoft.etk.Uri;
|
import org.atriasoft.etk.Uri;
|
||||||
@ -42,17 +43,17 @@ public class EsvgDocument extends Base {
|
|||||||
*/
|
*/
|
||||||
public boolean cleanStyleProperty(final XmlElement root) {
|
public boolean cleanStyleProperty(final XmlElement root) {
|
||||||
// for each nodes:
|
// for each nodes:
|
||||||
for (XmlNode it : root.getNodes()) {
|
for (final XmlNode it : root.getNodes()) {
|
||||||
if (!(it instanceof XmlElement child)) {
|
if (!(it instanceof final XmlElement child)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// get attribute style:
|
// get attribute style:
|
||||||
if (child.existAttribute("style")) {
|
if (child.existAttribute("style")) {
|
||||||
String content = child.getAttribute("style", "");
|
final String content = child.getAttribute("style", "");
|
||||||
if (content.length() != 0) {
|
if (content.length() != 0) {
|
||||||
String[] listStyle = content.split(";");
|
final String[] listStyle = content.split(";");
|
||||||
for (String it1 : listStyle) {
|
for (final String it1 : listStyle) {
|
||||||
String[] value = it1.split(":");
|
final String[] value = it1.split(":");
|
||||||
if (value.length != 2) {
|
if (value.length != 2) {
|
||||||
Log.error("parsing style with a wrong patern : " + it1 + " missing ':'");
|
Log.error("parsing style with a wrong patern : " + it1 + " missing ':'");
|
||||||
continue;
|
continue;
|
||||||
@ -109,7 +110,7 @@ public class EsvgDocument extends Base {
|
|||||||
@Override
|
@Override
|
||||||
protected void drawShapePoints(final List<List<Vector2f>> out, final int recurtionMax, final float threshold, final Matrix2x3f basicTrans, final int level) {
|
protected void drawShapePoints(final List<List<Vector2f>> out, final int recurtionMax, final float threshold, final Matrix2x3f basicTrans, final int level) {
|
||||||
Log.verbose(spacingDist(level) + "DRAW shape EsvgDocument");
|
Log.verbose(spacingDist(level) + "DRAW shape EsvgDocument");
|
||||||
for (Base it : this.subElementList) {
|
for (final Base it : this.subElementList) {
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
it.drawShapePoints(out, recurtionMax, threshold, basicTrans, level + 1);
|
it.drawShapePoints(out, recurtionMax, threshold, basicTrans, level + 1);
|
||||||
}
|
}
|
||||||
@ -126,7 +127,7 @@ public class EsvgDocument extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<List<Vector2f>> getLines(Vector2f size) {
|
public List<List<Vector2f>> getLines(Vector2f size) {
|
||||||
List<List<Vector2f>> out = new ArrayList<>();
|
final List<List<Vector2f>> out = new ArrayList<>();
|
||||||
if (size.x() <= 0) {
|
if (size.x() <= 0) {
|
||||||
size = size.withX(this.size.x());
|
size = size.withX(this.size.x());
|
||||||
}
|
}
|
||||||
@ -135,7 +136,7 @@ public class EsvgDocument extends Base {
|
|||||||
}
|
}
|
||||||
Log.debug("lineification size " + size);
|
Log.debug("lineification size " + size);
|
||||||
// create the first element matrix modification ...
|
// create the first element matrix modification ...
|
||||||
Matrix2x3f basicTrans = Matrix2x3f.IDENTITY.multiply(Matrix2x3f.createScale(new Vector2f(size.x() / this.size.x(), size.y() / this.size.y())));
|
final Matrix2x3f basicTrans = Matrix2x3f.IDENTITY.multiply(Matrix2x3f.createScale(new Vector2f(size.x() / this.size.x(), size.y() / this.size.y())));
|
||||||
drawShapePoints(out, 10, 0.25f, basicTrans);
|
drawShapePoints(out, 10, 0.25f, basicTrans);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@ -145,7 +146,7 @@ public class EsvgDocument extends Base {
|
|||||||
Log.error("request a reference with no name ... ");
|
Log.error("request a reference with no name ... ");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
for (Base it : this.refList) {
|
for (final Base it : this.refList) {
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -210,18 +211,18 @@ public class EsvgDocument extends Base {
|
|||||||
XmlNode doc = null;
|
XmlNode doc = null;
|
||||||
try {
|
try {
|
||||||
doc = Exml.parse(uri);
|
doc = Exml.parse(uri);
|
||||||
} catch (ExmlException e) {
|
} catch (final ExmlException | AknotException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (doc instanceof XmlElement elem && elem.existNode("svg")) {
|
if (doc instanceof final XmlElement elem && elem.existNode("svg")) {
|
||||||
try {
|
try {
|
||||||
if (elem.getNode("svg") instanceof XmlElement rootElement) {
|
if (elem.getNode("svg") instanceof final XmlElement rootElement) {
|
||||||
cleanStyleProperty(rootElement);
|
cleanStyleProperty(rootElement);
|
||||||
this.loadOK = parseXMLData(rootElement);
|
this.loadOK = parseXMLData(rootElement);
|
||||||
}
|
}
|
||||||
} catch (ExmlNodeDoesNotExist e) {
|
} catch (final ExmlNodeDoesNotExist e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
@ -242,18 +243,18 @@ public class EsvgDocument extends Base {
|
|||||||
XmlNode doc = null;
|
XmlNode doc = null;
|
||||||
try {
|
try {
|
||||||
doc = Exml.parse(data);
|
doc = Exml.parse(data);
|
||||||
} catch (ExmlException e) {
|
} catch (final ExmlException | AknotException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (doc instanceof XmlElement elem && elem.existNode("svg")) {
|
if (doc instanceof final XmlElement elem && elem.existNode("svg")) {
|
||||||
try {
|
try {
|
||||||
if (elem.getNode("svg") instanceof XmlElement rootElement) {
|
if (elem.getNode("svg") instanceof final XmlElement rootElement) {
|
||||||
cleanStyleProperty(rootElement);
|
cleanStyleProperty(rootElement);
|
||||||
this.loadOK = parseXMLData(rootElement);
|
this.loadOK = parseXMLData(rootElement);
|
||||||
}
|
}
|
||||||
} catch (ExmlNodeDoesNotExist e) {
|
} catch (final ExmlNodeDoesNotExist e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
@ -282,10 +283,10 @@ public class EsvgDocument extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector2f maxSize = Vector2f.ZERO;
|
Vector2f maxSize = Vector2f.ZERO;
|
||||||
Dynamic<Vector2f> size = new Dynamic<>(Vector2f.ZERO);
|
final Dynamic<Vector2f> size = new Dynamic<>(Vector2f.ZERO);
|
||||||
// parse all sub node:
|
// parse all sub node:
|
||||||
for (XmlNode it : root.getNodes()) {
|
for (final XmlNode it : root.getNodes()) {
|
||||||
if (!(it instanceof XmlElement child)) {
|
if (!(it instanceof final XmlElement child)) {
|
||||||
// comment can be here...
|
// comment can be here...
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -331,7 +332,7 @@ public class EsvgDocument extends Base {
|
|||||||
Log.error("'" + child.getValue() + "' node must not be defined in a defs Section");
|
Log.error("'" + child.getValue() + "' node must not be defined in a defs Section");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean retRefs = parseXMLData(child, true);
|
final boolean retRefs = parseXMLData(child, true);
|
||||||
// TODO Use retRefs ...
|
// TODO Use retRefs ...
|
||||||
continue;
|
continue;
|
||||||
} else if (child.getValue().equals("sodipodi:namedview")) {
|
} else if (child.getValue().equals("sodipodi:namedview")) {
|
||||||
@ -429,9 +430,9 @@ public class EsvgDocument extends Base {
|
|||||||
Log.error("Generate size " + size);
|
Log.error("Generate size " + size);
|
||||||
}
|
}
|
||||||
Log.verbose("Generate size " + size);
|
Log.verbose("Generate size " + size);
|
||||||
Renderer renderedElement = new Renderer(size, this, visualDebug);
|
final Renderer renderedElement = new Renderer(size, this, visualDebug);
|
||||||
// create the first element matrix modification ...
|
// create the first element matrix modification ...
|
||||||
Matrix2x3f basicTrans = Matrix2x3f.IDENTITY.multiply(Matrix2x3f.createScale(new Vector2f(size.x() / this.size.x(), size.y() / this.size.y())));
|
final Matrix2x3f basicTrans = Matrix2x3f.IDENTITY.multiply(Matrix2x3f.createScale(new Vector2f(size.x() / this.size.x(), size.y() / this.size.y())));
|
||||||
draw(renderedElement, basicTrans);
|
draw(renderedElement, basicTrans);
|
||||||
|
|
||||||
// direct return the generated data ...
|
// direct return the generated data ...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user