Package org.jwildfire.create.tina.io

Source Code of org.jwildfire.create.tina.io.Flam3Reader

/*
  JWildfire - an image and animation processor written in Java
  Copyright (C) 1995-2014 Andreas Maschke

  This is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser
  General Public License as published by the Free Software Foundation; either version 2.1 of the
  License, or (at your option) any later version.
  This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public License along with this software;
  if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jwildfire.create.tina.io;

import java.util.ArrayList;
import java.util.List;

import org.jwildfire.base.Prefs;
import org.jwildfire.base.Tools.XMLAttributes;
import org.jwildfire.create.tina.base.Flame;
import org.jwildfire.create.tina.base.Layer;

public class Flam3Reader extends AbstractFlameReader {

  protected Flam3Reader(Prefs pPrefs) {
    super(pPrefs);
  }

  public List<Flame> readFlamesfromXML(String pXML) {
    List<Flame> res = new ArrayList<Flame>();
    int pFlames = 0;
    while (true) {
      String flameXML;
      {
        int ps = pXML.indexOf("<flame ", pFlames);
        if (ps < 0)
          break;
        int pe = pXML.indexOf("</flame>", ps + 1);
        if (pe < 0)
          break;
        pFlames = pe + 8;
        flameXML = pXML.substring(ps, pFlames);
      }

      Flame flame = new Flame();
      res.add(flame);
      // Flame attributes
      XMLAttributes atts;
      {
        int ps = flameXML.indexOf("<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 + 7, pe);
        atts = parseFlameAttributes(flame, hs);
      }
      Layer layer = flame.getFirstLayer();
      readXForms(flameXML, flame, layer);
      readFinalXForms(flameXML, flame, layer);
      readColors(flameXML, layer);
      readMotionCurves(layer.getPalette(), atts, "palette_");
    }
    return res;
  }

}
TOP

Related Classes of org.jwildfire.create.tina.io.Flam3Reader

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.