Search in sources :

Example 1 with LazyPlugin

use of blue.ui.nbutilities.lazyplugin.LazyPlugin in project blue by kunstmusik.

the class AddSoundObjectActionsPresenter method getPopupPresenter.

@Override
public JMenuItem getPopupPresenter() {
    if (menu == null) {
        menu = new JMenu("Add SoundObject");
        List<LazyPlugin<SoundObject>> plugins = LazyPluginFactory.loadPlugins("blue/score/soundObjects", SoundObject.class);
        for (LazyPlugin<SoundObject> plugin : plugins) {
            JMenuItem temp = new JMenuItem();
            temp.setText(BlueSystem.getString("soundLayerPopup.addNew") + " " + plugin.getDisplayName());
            temp.putClientProperty("plugin", plugin);
            temp.setActionCommand(plugin.getDisplayName());
            temp.addActionListener(this);
            menu.add(temp);
        }
    }
    return menu;
}
Also used : SoundObject(blue.soundObject.SoundObject) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) LazyPlugin(blue.ui.nbutilities.lazyplugin.LazyPlugin)

Example 2 with LazyPlugin

use of blue.ui.nbutilities.lazyplugin.LazyPlugin in project blue by kunstmusik.

the class BarRendererCache method getInstance.

public static BarRendererCache getInstance() {
    if (instance == null) {
        instance = new BarRendererCache();
        List<LazyPlugin<BarRenderer>> plugins = LazyPluginFactory.loadPlugins("blue/score/barRenderers", BarRenderer.class, new ClassAssociationProcessor("scoreObjectType"));
        for (LazyPlugin<BarRenderer> plugin : plugins) {
            instance.barRenderersMap.put((Class) plugin.getMetaData("association"), plugin);
        }
    }
    return instance;
}
Also used : LazyPlugin(blue.ui.nbutilities.lazyplugin.LazyPlugin) ClassAssociationProcessor(blue.ui.nbutilities.lazyplugin.ClassAssociationProcessor)

Example 3 with LazyPlugin

use of blue.ui.nbutilities.lazyplugin.LazyPlugin in project blue by kunstmusik.

the class UserInstrumentTreePopup method getAddInstrumentMenu.

private JMenu getAddInstrumentMenu() {
    JMenu instrumentMenu = new JMenu("Add Instrument");
    List<LazyPlugin<Instrument>> plugins = LazyPluginFactory.loadPlugins("blue/instruments", Instrument.class);
    JMenuItem temp;
    this.setLabel("Add Instrument");
    ActionListener al = (ActionEvent e) -> {
        LazyPlugin<Instrument> plugin = (LazyPlugin<Instrument>) ((JMenuItem) e.getSource()).getClientProperty("plugin");
        Instrument instrTemplate = plugin.getInstance();
        try {
            Instrument newInstrument = instrTemplate.getClass().newInstance();
            addInstrument(newInstrument);
        } catch (InstantiationException | IllegalAccessException ex) {
            Exceptions.printStackTrace(ex);
        }
    };
    for (LazyPlugin<Instrument> plugin : plugins) {
        temp = new JMenuItem();
        temp.setText(plugin.getDisplayName());
        temp.putClientProperty("plugin", plugin);
        temp.addActionListener(al);
        instrumentMenu.add(temp);
    }
    return instrumentMenu;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) Instrument(blue.orchestra.Instrument) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) LazyPlugin(blue.ui.nbutilities.lazyplugin.LazyPlugin)

Example 4 with LazyPlugin

use of blue.ui.nbutilities.lazyplugin.LazyPlugin in project blue by kunstmusik.

the class ProjectPropertiesTopComponent method setupProjectPluginEditors.

private void setupProjectPluginEditors() {
    List<LazyPlugin<ProjectPluginEditor>> plugins = LazyPluginFactory.loadPlugins("blue/project/plugins/editors", ProjectPluginEditor.class);
    for (LazyPlugin<ProjectPluginEditor> plugin : plugins) {
        ProjectPluginEditor editor = plugin.getInstance();
        String displayname = plugin.getDisplayName();
        tabs.add(displayname, editor);
        pluginEditors.put(displayname, editor);
    }
}
Also used : ProjectPluginEditor(blue.project.ProjectPluginEditor) LazyPlugin(blue.ui.nbutilities.lazyplugin.LazyPlugin)

Example 5 with LazyPlugin

use of blue.ui.nbutilities.lazyplugin.LazyPlugin in project blue by kunstmusik.

the class AddSoundObjectActionsPresenter method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (pRef == null || sTimeCanvasRef == null) {
        return;
    }
    ScoreTimeCanvas sTimeCanvas = sTimeCanvasRef.get();
    Point p = pRef.get();
    int sLayerIndex = sTimeCanvas.getPolyObject().getLayerNumForY((int) p.getY());
    ScoreTopComponent stc = (ScoreTopComponent) WindowManager.getDefault().findTopComponent("ScoreTopComponent");
    LazyPlugin<SoundObject> plugin = (LazyPlugin<SoundObject>) ((JMenuItem) e.getSource()).getClientProperty("plugin");
    try {
        SoundObject sObj = (SoundObject) plugin.getInstance().getClass().newInstance();
        if (sObj instanceof PolyObject) {
            ((PolyObject) sObj).newLayerAt(0);
        }
        TimeState timeState = stc.getTimeState();
        double start = (double) p.getX() / timeState.getPixelSecond();
        if (timeState.isSnapEnabled()) {
            start = ScoreUtilities.getSnapValueStart(start, timeState.getSnapValue());
        }
        sObj.setStartTime(start);
        sTimeCanvas.getPolyObject().addSoundObject(sLayerIndex, sObj);
        BlueUndoManager.setUndoManager("score");
        BlueUndoManager.addEdit(new AddScoreObjectEdit(sTimeCanvas.getPolyObject().get(sLayerIndex), sObj));
    } catch (InstantiationException | IllegalAccessException ex) {
        Exceptions.printStackTrace(ex);
    }
}
Also used : Point(java.awt.Point) Point(java.awt.Point) LazyPlugin(blue.ui.nbutilities.lazyplugin.LazyPlugin) ScoreTopComponent(blue.ui.core.score.ScoreTopComponent) SoundObject(blue.soundObject.SoundObject) AddScoreObjectEdit(blue.ui.core.score.undo.AddScoreObjectEdit) ScoreTimeCanvas(blue.ui.core.score.layers.soundObject.ScoreTimeCanvas) TimeState(blue.score.TimeState) PolyObject(blue.soundObject.PolyObject)

Aggregations

LazyPlugin (blue.ui.nbutilities.lazyplugin.LazyPlugin)5 SoundObject (blue.soundObject.SoundObject)2 JMenu (javax.swing.JMenu)2 JMenuItem (javax.swing.JMenuItem)2 Instrument (blue.orchestra.Instrument)1 ProjectPluginEditor (blue.project.ProjectPluginEditor)1 TimeState (blue.score.TimeState)1 PolyObject (blue.soundObject.PolyObject)1 ScoreTopComponent (blue.ui.core.score.ScoreTopComponent)1 ScoreTimeCanvas (blue.ui.core.score.layers.soundObject.ScoreTimeCanvas)1 AddScoreObjectEdit (blue.ui.core.score.undo.AddScoreObjectEdit)1 ClassAssociationProcessor (blue.ui.nbutilities.lazyplugin.ClassAssociationProcessor)1 Point (java.awt.Point)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1