Search in sources :

Example 6 with XMLAttributes

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));
    }
}
Also used : XMLAttributes(org.jwildfire.base.Tools.XMLAttributes)

Example 7 with XMLAttributes

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;
}
Also used : XMLAttributes(org.jwildfire.base.Tools.XMLAttributes)

Example 8 with XMLAttributes

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;
}
Also used : XMLAttributes(org.jwildfire.base.Tools.XMLAttributes) ArrayList(java.util.ArrayList) Layer(org.jwildfire.create.tina.base.Layer) Flame(org.jwildfire.create.tina.base.Flame)

Aggregations

XMLAttributes (org.jwildfire.base.Tools.XMLAttributes)8 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Flame (org.jwildfire.create.tina.base.Flame)2 Layer (org.jwildfire.create.tina.base.Layer)2 MotionCurve (org.jwildfire.create.tina.base.motion.MotionCurve)2 VariationFuncList (org.jwildfire.create.tina.variation.VariationFuncList)2 Map (java.util.Map)1 XMLAttribute (org.jwildfire.base.Tools.XMLAttribute)1 GlobalScript (org.jwildfire.create.tina.animate.GlobalScript)1 XFormScript (org.jwildfire.create.tina.animate.XFormScript)1 DistantLight (org.jwildfire.create.tina.base.solidrender.DistantLight)1 MaterialSettings (org.jwildfire.create.tina.base.solidrender.MaterialSettings)1 DOFBlurShape (org.jwildfire.create.tina.render.dof.DOFBlurShape)1 FilterKernelType (org.jwildfire.create.tina.render.filter.FilterKernelType)1 FilteringType (org.jwildfire.create.tina.render.filter.FilteringType)1 Variation (org.jwildfire.create.tina.variation.Variation)1 VariationFunc (org.jwildfire.create.tina.variation.VariationFunc)1