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;
}
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;
}
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;
}
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);
}
}
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);
}
}
Aggregations