Search in sources :

Example 6 with Document

use of electric.xml.Document in project blue by kunstmusik.

the class ImportSoundObjectAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    ScoreTimeCanvas sCanvas = (ScoreTimeCanvas) lGroupPanel;
    List<File> retVal = FileChooserManager.getDefault().showOpenDialog(IMPORT_DIALOG, WindowManager.getDefault().getMainWindow());
    if (!retVal.isEmpty()) {
        File f = retVal.get(0);
        Document doc;
        try {
            doc = new Document(f);
            Element root = doc.getRoot();
            if (root.getName().equals("soundObject")) {
                SoundObject tempSobj = (SoundObject) ObjectUtilities.loadFromXML(root, null);
                int start = p.x;
                Layer layer = scorePath.getGlobalLayerForY(p.y);
                if (timeState.isSnapEnabled()) {
                    int snapPixels = (int) (timeState.getSnapValue() * timeState.getPixelSecond());
                    start = start - (start % snapPixels);
                }
                float startTime = (float) start / timeState.getPixelSecond();
                tempSobj.setStartTime(startTime);
                ((SoundLayer) layer).add(tempSobj);
                AddScoreObjectEdit edit = new AddScoreObjectEdit((ScoreObjectLayer) layer, tempSobj);
                BlueUndoManager.setUndoManager("score");
                BlueUndoManager.addEdit(edit);
            } else {
                JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Error: File did not contain Sound Object", "Error", JOptionPane.ERROR_MESSAGE);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Error: Could not read Sound Object from file", "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
}
Also used : SoundObject(blue.soundObject.SoundObject) AddScoreObjectEdit(blue.ui.core.score.undo.AddScoreObjectEdit) SoundLayer(blue.SoundLayer) Element(electric.xml.Element) ScoreTimeCanvas(blue.ui.core.score.layers.soundObject.ScoreTimeCanvas) Document(electric.xml.Document) File(java.io.File) SoundLayer(blue.SoundLayer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Layer(blue.score.layers.Layer) Point(java.awt.Point)

Example 7 with Document

use of electric.xml.Document in project blue by kunstmusik.

the class BlueShare method selectServer.

private static String selectServer() {
    String retVal = null;
    // get server list from disk
    try {
        Document doc = new Document(new File(BlueSystem.getConfDir() + File.separator + "blueShare.xml"));
        Element root = doc.getRoot();
        Elements servers = root.getElements("server");
        Object[] serverOptions = new Object[servers.size()];
        int i = 0;
        while (servers.hasMoreElements()) {
            serverOptions[i] = servers.next().getTextString();
            i++;
        }
        Object serverObj = JOptionPane.showInputDialog(null, BlueSystem.getString("blueShare.selectServer.message"), BlueSystem.getString("blueShare.selectServer.title"), JOptionPane.PLAIN_MESSAGE, null, serverOptions, serverOptions[0]);
        if (serverObj != null) {
            retVal = serverObj.toString();
        }
    } catch (ParseException | HeadlessException e) {
        e.printStackTrace();
    }
    return retVal;
}
Also used : HeadlessException(java.awt.HeadlessException) Element(electric.xml.Element) ParseException(electric.xml.ParseException) Document(electric.xml.Document) Elements(electric.xml.Elements) File(java.io.File)

Example 8 with Document

use of electric.xml.Document in project blue by kunstmusik.

the class BlueShareRemoteCaller method getLatestTenInstruments.

public static InstrumentOption[] getLatestTenInstruments() throws XmlRpcException, IOException, ParseException {
    String result = (String) xrpc.execute("blueShare.getLatestTen", new Vector());
    Document doc = new Document(result);
    Element root = doc.getRoot();
    Elements instruments = root.getElements("instrument");
    InstrumentOption[] iOptions = new InstrumentOption[instruments.size()];
    int i = 0;
    int instrumentId;
    String screenName, name, type, description, category;
    Element temp;
    while (instruments.hasMoreElements()) {
        temp = instruments.next();
        instrumentId = Integer.parseInt(temp.getAttribute("instrumentId").getValue());
        screenName = temp.getElement("screenName").getTextString();
        name = temp.getElement("name").getTextString();
        type = temp.getElement("type").getTextString();
        description = temp.getElement("description").getTextString();
        category = temp.getElement("category").getTextString();
        iOptions[i] = new InstrumentOption(instrumentId, checkNullString(screenName), checkNullString(name), checkNullString(type), checkNullString(description), checkNullString(category));
        i++;
    }
    return iOptions;
}
Also used : InstrumentOption(blue.tools.blueShare.instruments.InstrumentOption) Element(electric.xml.Element) Document(electric.xml.Document) Elements(electric.xml.Elements) Vector(java.util.Vector)

Example 9 with Document

use of electric.xml.Document in project blue by kunstmusik.

the class BlueShareRemoteCaller method getEffectOptionsForUser.

public static EffectOption[] getEffectOptionsForUser(String username, String password) throws IOException, XmlRpcException, ParseException {
    Vector v = new Vector();
    String result;
    Document doc;
    v.add(username);
    v.add(password);
    result = (String) xrpc.execute("blueShare.getEffectListForUser", v);
    doc = new Document(result);
    Element root = doc.getRoot();
    Elements instruments = root.getElements("effect");
    EffectOption[] iOptions = new EffectOption[instruments.size()];
    int i = 0;
    int effectId;
    String screenName, name, description, category;
    Element temp;
    while (instruments.hasMoreElements()) {
        temp = instruments.next();
        effectId = Integer.parseInt(temp.getAttribute("effectId").getValue());
        screenName = temp.getElement("screenName").getTextString();
        name = temp.getElement("name").getTextString();
        description = temp.getElement("description").getTextString();
        category = temp.getElement("category").getTextString();
        iOptions[i] = new EffectOption(effectId, checkNullString(screenName), checkNullString(name), checkNullString(description), checkNullString(category));
        i++;
    }
    return iOptions;
}
Also used : Element(electric.xml.Element) Document(electric.xml.Document) Elements(electric.xml.Elements) EffectOption(blue.tools.blueShare.effects.EffectOption) Vector(java.util.Vector)

Example 10 with Document

use of electric.xml.Document in project blue by kunstmusik.

the class BlueShareRemoteCaller method getInstrument.

public static Instrument getInstrument(InstrumentOption iOption) throws IOException, XmlRpcException, ParseException {
    Vector v = new Vector();
    String result;
    v.add(new Integer(iOption.getInstrumentId()));
    result = (String) xrpc.execute("blueShare.getInstrument", v);
    Instrument instrument = null;
    try {
        Document d = new Document(result);
        instrument = (Instrument) ObjectUtilities.loadFromXML(d.getRoot());
    } catch (Exception e) {
    }
    return instrument;
}
Also used : Instrument(blue.orchestra.Instrument) Document(electric.xml.Document) Vector(java.util.Vector) IOException(java.io.IOException) XmlRpcException(org.apache.xmlrpc.XmlRpcException) ParseException(electric.xml.ParseException)

Aggregations

Document (electric.xml.Document)35 Element (electric.xml.Element)22 ParseException (electric.xml.ParseException)17 Vector (java.util.Vector)17 IOException (java.io.IOException)13 Elements (electric.xml.Elements)12 File (java.io.File)12 XmlRpcException (org.apache.xmlrpc.XmlRpcException)6 SoundObject (blue.soundObject.SoundObject)4 EffectOption (blue.tools.blueShare.effects.EffectOption)3 InstrumentOption (blue.tools.blueShare.instruments.InstrumentOption)3 SoundObjectOption (blue.tools.blueShare.soundObjects.SoundObjectOption)3 MissingResourceException (java.util.MissingResourceException)3 BlueData (blue.BlueData)2 UDOLibrary (blue.udo.UDOLibrary)2 FileOutputStream (java.io.FileOutputStream)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 SoundLayer (blue.SoundLayer)1 Library (blue.library.Library)1 Effect (blue.mixer.Effect)1