Package org.jwildfire.base.Tools

Examples of org.jwildfire.base.Tools.XMLAttributes


      }

      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++) {
View Full Code Here


        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);
View Full Code Here

    }
    return res;
  }

  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);
    }
    readMotionCurves(pLayer, atts, "");
    return atts;
  }
View Full Code Here

  protected AbstractFlameReader(Prefs pPrefs) {
    prefs = pPrefs;
  }

  protected XMLAttributes parseFlameAttributes(Flame pFlame, String pXML) {
    XMLAttributes atts = Tools.parseAttributes(pXML);
    String hs;
    if ((hs = atts.get(ATTR_NAME)) != null) {
      pFlame.setName(hs);
    }
    if ((hs = atts.get(ATTR_LAYER_NAME)) != null && pFlame.getLayers().size() == 1) {
      pFlame.getFirstLayer().setName(hs);
    }
    if ((hs = atts.get(ATTR_SIZE)) != null) {
      String s[] = hs.split(" ");
      pFlame.setWidth(Integer.parseInt(s[0]));
      pFlame.setHeight(Integer.parseInt(s[1]));
    }
    if ((hs = atts.get(ATTR_CENTER)) != null) {
      String s[] = hs.split(" ");
      pFlame.setCentreX(Double.parseDouble(s[0]));
      pFlame.setCentreY(Double.parseDouble(s[1]));
    }
    if ((hs = atts.get(ATTR_SCALE)) != null) {
      pFlame.setPixelsPerUnit(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_ROTATE)) != null) {
      //      pFlame.setCamRoll(-Double.parseDouble(hs) * 180.0 / Math.PI);
      pFlame.setCamRoll(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_FILTER)) != null) {
      pFlame.setSpatialFilterRadius(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_FILTER_KERNEL)) != null) {
      try {
        FilterKernelType kernel = FilterKernelType.valueOf(hs);
        pFlame.setSpatialFilterKernel(kernel);
      }
      catch (Exception ex) {
        ex.printStackTrace();
      }
    }
    if ((hs = atts.get(ATTR_QUALITY)) != null) {
      pFlame.setSampleDensity(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_BACKGROUND)) != null) {
      String s[] = hs.split(" ");
      pFlame.setBGColorRed(Tools.roundColor(255.0 * Double.parseDouble(s[0])));
      pFlame.setBGColorGreen(Tools.roundColor(255.0 * Double.parseDouble(s[1])));
      pFlame.setBGColorBlue(Tools.roundColor(255.0 * Double.parseDouble(s[2])));
    }
    if ((hs = atts.get(ATTR_BRIGHTNESS)) != null) {
      pFlame.setBrightness(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SATURATION)) != null) {
      pFlame.setSaturation(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_BG_TRANSPARENCY)) != null) {
      pFlame.setBGTransparency(Integer.parseInt(hs) == 1);
    }
    else {
      pFlame.setBGTransparency(prefs.isTinaDefaultBGTransparency());
    }
    if ((hs = atts.get(ATTR_GAMMA)) != null) {
      pFlame.setGamma(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_GAMMA_THRESHOLD)) != null) {
      pFlame.setGammaThreshold(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_VIBRANCY)) != null) {
      pFlame.setVibrancy(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CONTRAST)) != null) {
      pFlame.setContrast(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_WHITE_LEVEL)) != null) {
      pFlame.setWhiteLevel(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_PERSP)) != null) {
      pFlame.setCamPerspective(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_PERSPECTIVE)) != null) {
      pFlame.setCamPerspective(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_ZPOS)) != null) {
      pFlame.setCamZ(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_POS_X)) != null) {
      pFlame.setCamPosX(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_POS_Y)) != null) {
      pFlame.setCamPosY(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_POS_Z)) != null) {
      pFlame.setCamPosZ(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_XFOCUS)) != null) {
      pFlame.setFocusX(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_YFOCUS)) != null) {
      pFlame.setFocusY(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_ZFOCUS)) != null) {
      pFlame.setFocusZ(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_ZDIMISH)) != null) {
      pFlame.setDimishZ(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_DOF)) != null) {
      pFlame.setCamDOF(Double.parseDouble(hs));
    }

    if ((hs = atts.get(ATTR_CAM_DOF_SHAPE)) != null) {
      try {
        pFlame.setCamDOFShape(DOFBlurShapeType.valueOf(hs));
      }
      catch (Exception ex) {
        pFlame.setCamDOFShape(DOFBlurShapeType.BUBBLE);
        ex.printStackTrace();
      }
    }
    if ((hs = atts.get(ATTR_CAM_DOF_SCALE)) != null) {
      pFlame.setCamDOFScale(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_DOF_ROTATE)) != null) {
      pFlame.setCamDOFAngle(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_DOF_FADE)) != null) {
      pFlame.setCamDOFFade(Double.parseDouble(hs));
    }
    {
      DOFBlurShape shape = pFlame.getCamDOFShape().getDOFBlurShape();
      List<String> paramNames = shape.getParamNames();
      if (paramNames.size() > 0 && (hs = atts.get(ATTR_CAM_DOF_PARAM1)) != null) {
        pFlame.setCamDOFParam1(Double.parseDouble(hs));
      }
      if (paramNames.size() > 1 && (hs = atts.get(ATTR_CAM_DOF_PARAM2)) != null) {
        pFlame.setCamDOFParam2(Double.parseDouble(hs));
      }
      if (paramNames.size() > 2 && (hs = atts.get(ATTR_CAM_DOF_PARAM3)) != null) {
        pFlame.setCamDOFParam3(Double.parseDouble(hs));
      }
      if (paramNames.size() > 3 && (hs = atts.get(ATTR_CAM_DOF_PARAM4)) != null) {
        pFlame.setCamDOFParam4(Double.parseDouble(hs));
      }
      if (paramNames.size() > 4 && (hs = atts.get(ATTR_CAM_DOF_PARAM5)) != null) {
        pFlame.setCamDOFParam5(Double.parseDouble(hs));
      }
      if (paramNames.size() > 5 && (hs = atts.get(ATTR_CAM_DOF_PARAM6)) != null) {
        pFlame.setCamDOFParam6(Double.parseDouble(hs));
      }
    }

    if ((hs = atts.get(ATTR_CAM_DOF_AREA)) != null) {
      pFlame.setCamDOFArea(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_DOF_EXPONENT)) != null) {
      pFlame.setCamDOFExponent(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_PITCH)) != null) {
      pFlame.setCamPitch(Double.parseDouble(hs) * 180.0 / Math.PI);
    }
    if ((hs = atts.get(ATTR_CAM_YAW)) != null) {
      pFlame.setCamYaw(Double.parseDouble(hs) * 180.0 / Math.PI);
    }
    if ((hs = atts.get(ATTR_CAM_ZOOM)) != null) {
      pFlame.setCamZoom(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_NEW_DOF)) != null) {
      pFlame.setNewCamDOF("1".equals(hs));
    }
    // preserve-z
    if ((hs = atts.get(ATTR_PRESERVE_Z)) != null) {
      pFlame.setPreserveZ("1".equals(hs));
    }
    // profiles
    if ((hs = atts.get(ATTR_RESOLUTION_PROFILE)) != null) {
      pFlame.setResolutionProfile(hs);
    }
    if ((hs = atts.get(ATTR_QUALITY_PROFILE)) != null) {
      pFlame.setQualityProfile(hs);
    }
    // Shading   
    if ((hs = atts.get(ATTR_SHADING_SHADING)) != null) {
      try {
        pFlame.getShadingInfo().setShading(Shading.valueOf(hs));
      }
      catch (Exception ex) {
        pFlame.getShadingInfo().setShading(Shading.FLAT);
        ex.printStackTrace();
      }
    }
    if ((hs = atts.get(ATTR_SHADING_AMBIENT)) != null) {
      pFlame.getShadingInfo().setAmbient(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_DIFFUSE)) != null) {
      pFlame.getShadingInfo().setDiffuse(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_PHONG)) != null) {
      pFlame.getShadingInfo().setPhong(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_PHONGSIZE)) != null) {
      pFlame.getShadingInfo().setPhongSize(Double.parseDouble(hs));
    }
    int lightCount;
    if ((hs = atts.get(ATTR_SHADING_LIGHTCOUNT)) != null) {
      lightCount = Integer.parseInt(hs);
    }
    else {
      lightCount = 0;
    }
    for (int i = 0; i < lightCount; i++) {
      if ((hs = atts.get(ATTR_SHADING_LIGHTPOSX_ + i)) != null) {
        pFlame.getShadingInfo().setLightPosX(i, Double.parseDouble(hs));
      }
      if ((hs = atts.get(ATTR_SHADING_LIGHTPOSY_ + i)) != null) {
        pFlame.getShadingInfo().setLightPosY(i, Double.parseDouble(hs));
      }
      if ((hs = atts.get(ATTR_SHADING_LIGHTPOSZ_ + i)) != null) {
        pFlame.getShadingInfo().setLightPosZ(i, Double.parseDouble(hs));
      }
      if ((hs = atts.get(ATTR_SHADING_LIGHTRED_ + i)) != null) {
        pFlame.getShadingInfo().setLightRed(i, Integer.parseInt(hs));
      }
      if ((hs = atts.get(ATTR_SHADING_LIGHTGREEN_ + i)) != null) {
        pFlame.getShadingInfo().setLightGreen(i, Integer.parseInt(hs));
      }
      if ((hs = atts.get(ATTR_SHADING_LIGHTBLUE_ + i)) != null) {
        pFlame.getShadingInfo().setLightBlue(i, Integer.parseInt(hs));
      }
    }
    if ((hs = atts.get(ATTR_SHADING_BLUR_RADIUS)) != null) {
      pFlame.getShadingInfo().setBlurRadius(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_BLUR_FADE)) != null) {
      pFlame.getShadingInfo().setBlurFade(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_BLUR_FALLOFF)) != null) {
      pFlame.getShadingInfo().setBlurFallOff(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_NEW_LINEAR)) != null) {
      pFlame.setPreserveZ(hs.length() > 0 && Integer.parseInt(hs) == 1);
    }

    if ((hs = atts.get(ATTR_ANTIALIAS_AMOUNT)) != null) {
      pFlame.setAntialiasAmount(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_ANTIALIAS_RADIUS)) != null) {
      pFlame.setAntialiasRadius(Double.parseDouble(hs));
    }

    if ((hs = atts.get(ATTR_MOTIONBLUR_LENGTH)) != null) {
      pFlame.setMotionBlurLength(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_MOTIONBLUR_TIMESTEP)) != null) {
      pFlame.setMotionBlurTimeStep(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_MOTIONBLUR_DECAY)) != null) {
      pFlame.setMotionBlurDecay(Double.parseDouble(hs));
    }

    if ((hs = atts.get(ATTR_SHADING_DISTANCE_COLOR_RADIUS)) != null) {
      pFlame.getShadingInfo().setDistanceColorRadius(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_DISTANCE_COLOR_SCALE)) != null) {
      pFlame.getShadingInfo().setDistanceColorScale(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_DISTANCE_COLOR_EXPONENT)) != null) {
      pFlame.getShadingInfo().setDistanceColorExponent(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_DISTANCE_COLOR_OFFSETX)) != null) {
      pFlame.getShadingInfo().setDistanceColorOffsetX(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_DISTANCE_COLOR_OFFSETY)) != null) {
      pFlame.getShadingInfo().setDistanceColorOffsetY(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_DISTANCE_COLOR_OFFSETZ)) != null) {
      pFlame.getShadingInfo().setDistanceColorOffsetZ(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_DISTANCE_COLOR_STYLE)) != null) {
      pFlame.getShadingInfo().setDistanceColorStyle(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_DISTANCE_COLOR_COORDINATE)) != null) {
      pFlame.getShadingInfo().setDistanceColorCoordinate(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_DISTANCE_COLOR_SHIFT)) != null) {
      pFlame.getShadingInfo().setDistanceColorShift(Double.parseDouble(hs));
    }

    if ((hs = atts.get(ATTR_POST_SYMMETRY_TYPE)) != null) {
      try {
        pFlame.setPostSymmetryType(PostSymmetryType.valueOf(hs));
      }
      catch (Exception ex) {
        ex.printStackTrace();
      }
    }
    if ((hs = atts.get(ATTR_POST_SYMMETRY_ORDER)) != null) {
      pFlame.setPostSymmetryOrder(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_POST_SYMMETRY_CENTREX)) != null) {
      pFlame.setPostSymmetryCentreX(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_POST_SYMMETRY_CENTREY)) != null) {
      pFlame.setPostSymmetryCentreY(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_POST_SYMMETRY_DISTANCE)) != null) {
      pFlame.setPostSymmetryDistance(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_POST_SYMMETRY_ROTATION)) != null) {
      pFlame.setPostSymmetryRotation(Double.parseDouble(hs));
    }

    if ((hs = atts.get(ATTR_STEREO3D_MODE)) != null) {
      try {
        pFlame.setStereo3dMode(Stereo3dMode.valueOf(hs));
      }
      catch (Exception ex) {
        ex.printStackTrace();
      }
    }
    if ((hs = atts.get(ATTR_STEREO3D_ANGLE)) != null) {
      pFlame.setStereo3dAngle(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_STEREO3D_EYE_DIST)) != null) {
      pFlame.setStereo3dEyeDist(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_STEREO3D_FOCAL_OFFSET)) != null) {
      pFlame.setStereo3dFocalOffset(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_STEREO3D_LEFT_EYE_COLOR)) != null) {
      try {
        pFlame.setStereo3dLeftEyeColor(Stereo3dColor.valueOf(hs));
      }
      catch (Exception ex) {
        ex.printStackTrace();
      }
    }
    if ((hs = atts.get(ATTR_STEREO3D_RIGHT_EYE_COLOR)) != null) {
      try {
        pFlame.setStereo3dRightEyeColor(Stereo3dColor.valueOf(hs));
      }
      catch (Exception ex) {
        ex.printStackTrace();
      }
    }
    if ((hs = atts.get(ATTR_STEREO3D_INTERPOLATED_IMAGE_COUNT)) != null) {
      pFlame.setStereo3dInterpolatedImageCount(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_STEREO3D_PREVIEW)) != null) {
      try {
        pFlame.setStereo3dPreview(Stereo3dPreview.valueOf(hs));
      }
      catch (Exception ex) {
        ex.printStackTrace();
      }
    }
    if ((hs = atts.get(ATTR_STEREO3D_SWAP_SIDES)) != null) {
      pFlame.setStereo3dSwapSides(Integer.parseInt(hs) == 1);
    }

    if ((hs = atts.get(ATTR_FRAME)) != null) {
      pFlame.setFrame(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_FRAME_COUNT)) != null) {
      pFlame.setFrameCount(Integer.parseInt(hs));
    }
    readMotionCurves(pFlame, atts, null);

    if ((hs = atts.get(ATTR_CHANNEL_MIXER_MODE)) != null) {
      try {
        pFlame.setChannelMixerMode(ChannelMixerMode.valueOf(hs));
      }
      catch (Exception ex) {
        ex.printStackTrace();
View Full Code Here

  public static final String ATTR_CHANNEL_MIXER_BR_CURVE = "mixer_br_curve";
  public static final String ATTR_CHANNEL_MIXER_BG_CURVE = "mixer_bg_curve";
  public static final String ATTR_CHANNEL_MIXER_BB_CURVE = "mixer_bb_curve";

  protected void parseXFormAttributes(Flame pFlame, XForm pXForm, String pXML) {
    XMLAttributes atts = Tools.parseAttributes(pXML);
    String hs;
    if ((hs = atts.get(ATTR_NAME)) != null) {
      pXForm.setName(hs);
    }
    if ((hs = atts.get(ATTR_WEIGHT)) != null) {
      pXForm.setWeight(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_COLOR)) != null) {
      pXForm.setColor(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_MOD_GAMMA)) != null) {
      pXForm.setModGamma(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_MOD_GAMMA_SPEED)) != null) {
      pXForm.setModGammaSpeed(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_MOD_CONTRAST)) != null) {
      pXForm.setModContrast(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_MOD_CONTRAST_SPEED)) != null) {
      pXForm.setModContrastSpeed(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_MOD_SATURATION)) != null) {
      pXForm.setModSaturation(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_MOD_SATURATION_SPEED)) != null) {
      pXForm.setModSaturationSpeed(Double.parseDouble(hs));
    }
    // legacy
    if ((hs = atts.get(ATTR_ANTIALIAS_AMOUNT)) != null) {
      double value = Double.parseDouble(hs);
      if (value > 0)
        pFlame.setAntialiasAmount(value);
    }
    // legacy
    if ((hs = atts.get(ATTR_ANTIALIAS_RADIUS)) != null) {
      double value = Double.parseDouble(hs);
      if (value > 0)
        pFlame.setAntialiasRadius(value);
    }
    if ((hs = atts.get(ATTR_OPACITY)) != null) {
      double opacity = Double.parseDouble(hs);
      pXForm.setOpacity(opacity);
      if (Math.abs(opacity) <= MathLib.EPSILON) {
        pXForm.setDrawMode(DrawMode.HIDDEN);
      }
      else if (Math.abs(opacity - 1.0) > MathLib.EPSILON) {
        pXForm.setDrawMode(DrawMode.OPAQUE);
      }
      else {
        pXForm.setDrawMode(DrawMode.NORMAL);
      }
    }
    if ((hs = atts.get(ATTR_SYMMETRY)) != null) {
      pXForm.setColorSymmetry(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_COEFS)) != null) {
      String s[] = hs.split(" ");
      pXForm.setCoeff00(Double.parseDouble(s[0]));
      pXForm.setCoeff01(Double.parseDouble(s[1]));
      pXForm.setCoeff10(Double.parseDouble(s[2]));
      pXForm.setCoeff11(Double.parseDouble(s[3]));
      pXForm.setCoeff20(Double.parseDouble(s[4]));
      pXForm.setCoeff21(Double.parseDouble(s[5]));
    }
    if ((hs = atts.get(ATTR_POST)) != null) {
      String s[] = hs.split(" ");
      pXForm.setPostCoeff00(Double.parseDouble(s[0]));
      pXForm.setPostCoeff01(Double.parseDouble(s[1]));
      pXForm.setPostCoeff10(Double.parseDouble(s[2]));
      pXForm.setPostCoeff11(Double.parseDouble(s[3]));
      pXForm.setPostCoeff20(Double.parseDouble(s[4]));
      pXForm.setPostCoeff21(Double.parseDouble(s[5]));
    }
    if ((hs = atts.get(ATTR_CHAOS)) != null) {
      String s[] = hs.split(" ");
      for (int i = 0; i < s.length; i++) {
        pXForm.getModifiedWeights()[i] = Double.parseDouble(s[i]);
      }
    }
    readMotionCurves(pXForm, atts, null);
    // variations
    {
      List<String> variationNameList = VariationFuncList.getNameList();
      Map<String, String> aliasMap = VariationFuncList.getAliasMap();

      for (XMLAttribute attr : atts.getAttributes()) {
        String rawName = attr.getName();
        String name = removeIndexFromAttr(rawName);
        String varName = name;
        boolean hasVariation = variationNameList.indexOf(varName) >= 0;
        if (!hasVariation) {
          String aliasName = aliasMap.get(name);
          if (aliasName != null) {
            varName = aliasName;
            hasVariation = variationNameList.indexOf(varName) >= 0;
          }
        }
        if (hasVariation) {
          VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(varName);
          Variation variation = pXForm.addVariation(Double.parseDouble(atts.get(rawName)), varFunc);
          // params
          {
            String paramNames[] = variation.getFunc().getParameterNames();
            String paramAltNames[] = variation.getFunc().getParameterAlternativeNames();
            if (paramNames != null) {
              if (paramAltNames != null && paramAltNames.length != paramNames.length) {
                paramAltNames = null;
              }
              for (int i = 0; i < paramNames.length; i++) {
                String pName = paramNames[i];
                String pHs;
                if ((pHs = atts.get(rawName + "_" + pName)) != null) {
                  variation.getFunc().setParameter(pName, Double.parseDouble(pHs));
                }
                // altNames can only be come from flames which were not created by JWF, so no need to handle index here
                else if (paramAltNames != null && ((pHs = atts.get(paramAltNames[i])) != null)) {
                  variation.getFunc().setParameter(pName, Double.parseDouble(pHs));
                }
                // curve
                {
                  String namePrefix = rawName + "_" + pName + "_";
                  if (atts.get(namePrefix + AbstractFlameReader.CURVE_ATTR_POINT_COUNT) != null) {
                    MotionCurve curve = variation.getMotionCurve(pName);
                    if (curve == null) {
                      curve = variation.createMotionCurve(pName);
                    }
                    readMotionCurveAttributes(atts, curve, namePrefix);
                  }
                }
              }
            }
          }
          // curves
          readMotionCurves(variation, atts, rawName + "_");
          // ressources
          {
            String ressNames[] = variation.getFunc().getRessourceNames();
            if (ressNames != null) {
              for (String pName : ressNames) {
                String pHs;
                if ((pHs = atts.get(name + "_" + pName)) != null) {
                  variation.getFunc().setRessource(pName, Tools.hexStringToByteArray(pHs));
                }
              }
            }
          }
View Full Code Here

        int pe = flameXML.indexOf("/>", ps + 1);
        String hs = flameXML.substring(ps + 7, pe);
        {
          int index = 0;
          int r = 0, g = 0, b = 0;
          XMLAttributes atts = Tools.parseAttributes(hs);
          String attr;
          if ((attr = atts.get(ATTR_INDEX)) != null) {
            index = Integer.parseInt(attr);
          }
          if ((attr = atts.get(ATTR_RGB)) != null) {
            String s[] = attr.split(" ");
            r = Tools.FTOI(Double.parseDouble(s[0]));
            g = Tools.FTOI(Double.parseDouble(s[1]));
            b = Tools.FTOI(Double.parseDouble(s[2]));
          }
View Full Code Here

    return movie;
  }

  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));
    }
  }
View Full Code Here

      pPart.setFrameMorphCount(Integer.parseInt(hs));
    }
  }

  private void parseMovieAttributes(FlameMovie pMovie, String pXML) {
    XMLAttributes atts = Tools.parseAttributes(pXML);
    String hs;
    if ((hs = atts.get(ATTR_NAME)) != null) {
      pMovie.setName(hs);
    }
    if ((hs = atts.get(ATTR_SCRIPT_GLOBAL)) != null) { // legacy
      pMovie.getGlobalScripts()[0] = new GlobalScript(GlobalScriptType.valueOf(hs), 1.0);
    }
    for (int i = 0; i < FlameMovie.SCRIPT_COUNT; i++) {
      String idxStr = String.valueOf(i + 1);
      if ((hs = atts.get(ATTR_SCRIPT_GLOBAL + idxStr)) != null) {
        pMovie.getGlobalScripts()[i] = readGlobalScript(ATTR_SCRIPT_GLOBAL + idxStr, ATTR_SCRIPT_GLOBAL + idxStr + AMPLITUDE_POSTFIX, ATTR_SCRIPT_GLOBAL + idxStr + AMPLITUDE_CURVE_POSTFIX, atts);
      }
    }

    if ((hs = atts.get(ATTR_SCRIPT_XFORM)) != null) { // legacy
      pMovie.getxFormScripts()[0] = new XFormScript(XFormScriptType.valueOf(hs), 1.0);
    }
    for (int i = 0; i < FlameMovie.SCRIPT_COUNT; i++) {
      String idxStr = String.valueOf(i + 1);
      if ((hs = atts.get(ATTR_SCRIPT_XFORM + idxStr)) != null) {
        pMovie.getxFormScripts()[i] = readXFormScript(ATTR_SCRIPT_XFORM + idxStr, ATTR_SCRIPT_XFORM + idxStr + AMPLITUDE_POSTFIX, ATTR_SCRIPT_XFORM + idxStr + AMPLITUDE_CURVE_POSTFIX, atts);
      }
    }

    if ((hs = atts.get(ATTR_FRAME_WIDTH)) != null) {
      pMovie.setFrameWidth(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_FRAME_HEIGHT)) != null) {
      pMovie.setFrameHeight(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_FPS)) != null) {
      pMovie.setFramesPerSecond(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_MOTIONBLUR_LENGTH)) != null) {
      pMovie.setMotionBlurLength(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_MOTIONBLUR_TIMESTEP)) != null) {
      pMovie.setMotionBlurTimeStep(Double.parseDouble(hs));
    }
  }
View Full Code Here

TOP

Related Classes of org.jwildfire.base.Tools.XMLAttributes

Copyright © 2018 www.massapicom. 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.