Examples of Savable


Examples of com.ardor3d.util.export.Savable

        return ret;
    }

    private Savable readSavableFromCurrentElem(final Savable defVal) throws InstantiationException,
            ClassNotFoundException, IOException, IllegalAccessException {
        Savable ret = defVal;
        Savable tmp = null;

        if (_currentElem == null || _currentElem.getNodeName().equals("null")) {
            return null;
        }
        final String reference = _currentElem.getAttribute("ref");
        if (reference.length() > 0) {
            ret = _referencedSavables.get(reference);
        } else {
            String className = _currentElem.getNodeName();
            if (defVal != null) {
                className = defVal.getClass().getName();
            } else if (_currentElem.hasAttribute("class")) {
                className = _currentElem.getAttribute("class");
            }

            try {
                @SuppressWarnings("unchecked")
                final Class<? extends Savable> clazz = (Class<? extends Savable>) Class.forName(className);
                final SavableFactory ann = clazz.getAnnotation(SavableFactory.class);
                if (ann == null) {
                    tmp = clazz.newInstance();
                } else {
                    tmp = (Savable) clazz.getMethod(ann.factoryMethod(), (Class<?>[]) null).invoke(null,
                            (Object[]) null);
                }
            } catch (final InstantiationException e) {
                Logger.getLogger(getClass().getName()).logp(
                        Level.SEVERE,
                        this.getClass().toString(),
                        "readSavableFromCurrentElem(Savable)",
                        "Could not access constructor of class '" + className + "'! \n"
                                + "Some types may require the annotation SavableFactory.  Please double check.");
                throw new Ardor3dException(e);
            } catch (final NoSuchMethodException e) {
                Logger.getLogger(getClass().getName())
                        .logp(Level.SEVERE,
                                this.getClass().toString(),
                                "readSavableFromCurrentElem(Savable)",
                                e.getMessage()
                                        + " \n"
                                        + "Method specified in annotation does not appear to exist or has an invalid method signature.");
                throw new Ardor3dException(e);
            } catch (final Exception e) {
                Logger.getLogger(getClass().getName()).logp(Level.SEVERE, this.getClass().toString(),
                        "readSavableFromCurrentElem(Savable)", "Exception", e);
                return null;
            }

            final String refID = _currentElem.getAttribute("reference_ID");
            if (refID.length() > 0) {
                _referencedSavables.put(refID, tmp);
            }
            if (tmp != null) {
                tmp.read(this);
                ret = tmp;
            }
        }
        return ret;
    }
View Full Code Here

Examples of com.ardor3d.util.export.Savable

        _geomShader = capsule.readByteBuffer("geomShader", null);
        _tessControlShader = capsule.readByteBuffer("tessControlShader", null);
        _tessEvalShader = capsule.readByteBuffer("tessEvalShader", null);
        _useAttributeVBO = capsule.readBoolean("useAttributeVBO", false);

        final Savable shaderDataLogic = capsule.readSavable("shaderDataLogic", null);
        // only override set _shaderDataLogic if we have something in the capsule.
        if (shaderDataLogic != null) {
            if (shaderDataLogic instanceof GLSLShaderDataLogic) {
                _shaderDataLogic = (GLSLShaderDataLogic) shaderDataLogic;
            } else {
                logger.warning("Deserialized shaderDataLogic is not of type GLSLShaderDataLogic. "
                        + shaderDataLogic.getClass().getName());
            }
        }
    }
View Full Code Here

Examples of com.ardor3d.util.export.Savable

        }

        _localTransform.set((Transform) capsule.readSavable("localTransform", new Transform(Transform.IDENTITY)));
        _worldTransform.set((Transform) capsule.readSavable("worldTransform", new Transform(Transform.IDENTITY)));

        final Savable userData = capsule.readSavable("userData", null);
        // only override set userdata if we have something in the capsule.
        if (userData != null) {
            _userData = userData;
        }
View Full Code Here

Examples of com.ardor3d.util.export.Savable

        final BinaryExporter exporter = new BinaryExporter();
        exporter.save(meshData, bos);
        bos.flush();
        final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
        final BinaryImporter importer = new BinaryImporter();
        final Savable sav = importer.load(bis);
        return (MeshData) sav;
    }
View Full Code Here

Examples of com.jme3.export.Savable

  }

  protected void onMeshAdded(File selectedFile) {
    //check if the file is a jme OgreMesh file by trying to load it
    try {
      Savable load = BinaryImporter.getInstance().load(selectedFile);
     
      if(load instanceof Geometry)
      {
        Geometry m = (Geometry) load;
        assembler.addMesh(m.getName(),m, true);
        meshModel.addElement(m.getName());
        updateJME();
      } else {
        JOptionPane.showMessageDialog(null, "The jme file is not an OgreMesh but a "+(load != null?load.getClass().getSimpleName():"Null file"),"Error",JOptionPane.ERROR_MESSAGE);
      }
    } catch (Exception e) {
      JOptionPane.showMessageDialog(null, "Failed to load the file, perhaps not a JME file?","Error",JOptionPane.ERROR_MESSAGE);
    }
  }
View Full Code Here

Examples of com.jme3.export.Savable

  }

  private void onSkeletonChanged(File newFile){
    //check if the file is a jme skeleton file by trying to load it
    try {
      Savable load = BinaryImporter.getInstance().load(newFile);
     
      if(load instanceof Skeleton)
      {
        Skeleton skel = (Skeleton)load;
        assembler.setSkeleton(skel);
        this.jTextField1.setText(newFile.getPath().substring(0,8)+"..."+newFile.getName());
        String[] names = new String[skel.getBoneCount()];
        for(int i=0;i<skel.getBoneCount();i++){
          names[i]= skel.getBone(i).getName();
        }
        bones.setModel(new DefaultComboBoxModel(names));
        updateJME();
      } else {

        JOptionPane.showMessageDialog(null, "The jme file is not a Skeleton but a "+(load != null?load.getClass().getSimpleName():"Null file"),"Error",JOptionPane.ERROR_MESSAGE);
      }
    } catch (Exception e) {
      JOptionPane.showMessageDialog(null, "Failed to load the file, perhaps not a JME file?","Error",JOptionPane.ERROR_MESSAGE);
    }
  }
View Full Code Here

Examples of com.jme3.export.Savable

            Logger.getLogger(SaveGame.class.getName()).log(Level.SEVERE, "Base Storage Folder Type is null, using External!");
            storageType = JmeSystem.StorageFolderType.External;
        }

        InputStream is = null;
        Savable sav = null;
        try {
            File baseFolder = JmeSystem.getStorageFolder(storageType);
            if (baseFolder == null) {
                Logger.getLogger(SaveGame.class.getName()).log(Level.SEVERE, "Error reading base storage folder!");
                return null;
View Full Code Here

Examples of org.netbeans.api.actions.Savable

    }

    @Override
    public void run () {
        try {
            Savable save = context.getLookup().lookup( Savable.class );
            if (save != null) {
                save.save();
            }
            NodeJSExecutable.getDefault().run( context.getPrimaryFile(), null );
        } catch ( IOException ex ) {
            Exceptions.printStackTrace( ex );
        }
View Full Code Here
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.