use of org.jwildfire.base.Tools.XMLAttributes in project JWildfire by thargor6.
the class FlameMovieReader method parseMoviePartAttributes.
private void parseMoviePartAttributes(FlameMoviePart pPart, String pXML) {
XMLAttributes atts = Tools.parseAttributes(pXML);
String hs;
if ((hs = atts.get(ATTR_FRAME_COUNT)) != null) {
pPart.setFrameCount(Integer.parseInt(hs));
}
if ((hs = atts.get(ATTR_MORPH_TYPE)) != null) {
try {
pPart.setFlameMorphType(FlameMorphType.valueOf(hs));
} catch (Exception ex) {
ex.printStackTrace();
}
}
if ((hs = atts.get(ATTR_FRAME_MORPH_COUNT)) != null) {
pPart.setFrameMorphCount(Integer.parseInt(hs));
}
}
use of org.jwildfire.base.Tools.XMLAttributes in project JWildfire by thargor6.
the class JWFFlameReader method parseLayerAttributes.
protected XMLAttributes parseLayerAttributes(Layer pLayer, String pXML) {
XMLAttributes atts = Tools.parseAttributes(pXML);
String hs;
if ((hs = atts.get(ATTR_WEIGHT)) != null) {
pLayer.setWeight(Double.parseDouble(hs));
}
if ((hs = atts.get(ATTR_VISIBLE)) != null) {
pLayer.setVisible(Integer.parseInt(hs) == 1);
}
if ((hs = atts.get(ATTR_NAME)) != null) {
pLayer.setName(hs);
}
if ((hs = atts.get(ATTR_GRADIENT_MAP)) != null) {
pLayer.setGradientMapFilename(hs);
}
if ((hs = atts.get(ATTR_GRADIENT_MAP_HOFFSET)) != null) {
pLayer.setGradientMapHorizOffset(Double.parseDouble(hs));
}
if ((hs = atts.get(ATTR_GRADIENT_MAP_HSCALE)) != null) {
pLayer.setGradientMapHorizScale(Double.parseDouble(hs));
}
if ((hs = atts.get(ATTR_GRADIENT_MAP_VOFFSET)) != null) {
pLayer.setGradientMapVertOffset(Double.parseDouble(hs));
}
if ((hs = atts.get(ATTR_GRADIENT_MAP_VSCALE)) != null) {
pLayer.setGradientMapVertScale(Double.parseDouble(hs));
}
if ((hs = atts.get(ATTR_GRADIENT_MAP_LCOLOR_ADD)) != null) {
pLayer.setGradientMapLocalColorAdd(Double.parseDouble(hs));
}
if ((hs = atts.get(ATTR_GRADIENT_MAP_LCOLOR_SCALE)) != null) {
pLayer.setGradientMapLocalColorScale(Double.parseDouble(hs));
}
if ((hs = atts.get(ATTR_SMOOTH_GRADIENT)) != null) {
pLayer.setSmoothGradient("1".equals(hs));
}
readMotionCurves(pLayer, atts, "");
return atts;
}
use of org.jwildfire.base.Tools.XMLAttributes in project JWildfire by thargor6.
the class JWFFlameReader method readFlamesfromXML.
public List<Flame> readFlamesfromXML(String pXML) {
List<Flame> res = new ArrayList<Flame>();
int pFlames = 0;
while (true) {
String flameXML;
{
int ps = pXML.indexOf("<" + ATTR_JWF_FLAME + " ", pFlames);
if (ps < 0)
break;
int pe = pXML.indexOf("</" + ATTR_JWF_FLAME + ">", ps + 1);
if (pe < 0)
break;
pFlames = pe + ATTR_JWF_FLAME.length() + 3;
flameXML = pXML.substring(ps, pFlames);
}
Flame flame = new Flame();
res.add(flame);
// Flame attributes
{
int ps = flameXML.indexOf("<" + ATTR_JWF_FLAME + " ");
int pe = -1;
boolean qt = false;
for (int i = ps + 1; i < flameXML.length(); i++) {
if (flameXML.charAt(i) == '\"') {
qt = !qt;
} else if (!qt && flameXML.charAt(i) == '>') {
pe = i;
break;
}
}
String hs = flameXML.substring(ps + 11, pe);
parseFlameAttributes(flame, hs);
}
flame.getLayers().clear();
// Layers
int pLayers = 0;
while (true) {
int layerStart = flameXML.indexOf("<" + ATTR_LAYER + " ", pLayers);
if (layerStart < 0)
break;
int layerEnd = flameXML.indexOf("</" + ATTR_LAYER + ">", layerStart + 1);
if (layerEnd < 0)
break;
pLayers = layerEnd + ATTR_LAYER.length() + 3;
String layerXML = flameXML.substring(layerStart, pLayers);
Layer layer = new Layer();
flame.getLayers().add(layer);
XMLAttributes atts;
// Layer attributes
{
int ps = layerXML.indexOf("<" + ATTR_LAYER + " ");
int pe = layerXML.indexOf(">", ps);
String hs = layerXML.substring(ps + 7, pe);
atts = parseLayerAttributes(layer, hs);
}
readXForms(layerXML, flame, layer);
readFinalXForms(layerXML, flame, layer);
readColors(layerXML, layer);
readMotionCurves(layer.getPalette(), atts, "palette_");
}
}
return res;
}
Aggregations