Java Code Examples for org.scijava.Context#inject()
The following examples show how to use
org.scijava.Context#inject() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: REPLPane.java From sciview with BSD 2-Clause "Simplified" License | 5 votes |
/** * Constructs an interpreter UI pane for a SciJava scripting REPL. * * @param context The SciJava application context to use */ public REPLPane(final Context context) { context.inject(this); output = new OutputPane(log); final JScrollPane outputScroll = new JScrollPane(output); outputScroll.setPreferredSize(new Dimension(440, 400)); repl = new ScriptREPL(context, output.getOutputStream()); repl.initialize(); final Writer writer = output.getOutputWriter(); final ScriptContext ctx = repl.getInterpreter().getEngine().getContext(); ctx.setErrorWriter(writer); ctx.setWriter(writer); vars = new VarsPane(context, repl); vars.setBorder(new EmptyBorder(0, 0, 8, 0)); prompt = new REPLEditor(repl, vars, output); context.inject(prompt); prompt.setREPLLanguage("Python"); final JScrollPane promptScroll = new JScrollPane(prompt); final JPanel bottomPane = new JPanel(); bottomPane.setLayout(new MigLayout("ins 0", "[grow,fill][pref]", "[grow,fill,align top]")); bottomPane.add(promptScroll, "spany 2"); final JSplitPane outputAndPromptPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, outputScroll, bottomPane); outputAndPromptPane.setResizeWeight(1); // outputAndPromptPane.setDividerSize(2); mainPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, vars, outputAndPromptPane); mainPane.setDividerSize(1); mainPane.setDividerLocation(0); }
Example 2
Source File: JPEGTileDecoder.java From scifio with BSD 2-Clause "Simplified" License | 5 votes |
public TileCache(final Context ctx, final int yy, final int hh) { ctx.inject(this); options.interleaved = true; options.littleEndian = false; this.yy = yy; this.hh = hh; codec = codecService.getCodec(JPEGCodec.class); }
Example 3
Source File: Worker.java From scijava-jupyter-kernel with Apache License 2.0 | 4 votes |
Worker(Context context, Map<String, ScriptEngine> scriptEngines, Map<String, ScriptLanguage> scriptLanguages) { context.inject(this); this.scriptEngines = scriptEngines; this.scriptLanguages = scriptLanguages; }
Example 4
Source File: ScijavaKernelConfigurationFile.java From scijava-jupyter-kernel with Apache License 2.0 | 4 votes |
public ScijavaKernelConfigurationFile(Context context, String logLevel, Path connectionFile) { context.inject(this); this.configFile = connectionFile.toFile(); this.logLevel = logLevel; }
Example 5
Source File: SciView.java From sciview with BSD 2-Clause "Simplified" License | 4 votes |
public SciView( Context context ) { super( "SciView", 1280, 720, false, context ); context.inject( this ); }
Example 6
Source File: PreviewPane.java From scifio with BSD 2-Clause "Simplified" License | 4 votes |
/** Constructs a preview pane for the given file chooser. */ public PreviewPane(final Context context, final JFileChooser jc) { super(); context.inject(this); // create view setBorder(new EmptyBorder(0, 10, 0, 10)); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); iconLabel = new JLabel(); iconLabel.setMinimumSize(new java.awt.Dimension(128, -1)); iconLabel.setAlignmentX(Component.CENTER_ALIGNMENT); add(iconLabel); add(Box.createVerticalStrut(7)); formatLabel = new JLabel(); formatLabel.setAlignmentX(Component.CENTER_ALIGNMENT); add(formatLabel); add(Box.createVerticalStrut(5)); resLabel = new JLabel(); resLabel.setAlignmentX(Component.CENTER_ALIGNMENT); add(resLabel); zctLabel = new JLabel(); zctLabel.setAlignmentX(Component.CENTER_ALIGNMENT); add(zctLabel); typeLabel = new JLabel(); typeLabel.setAlignmentX(Component.CENTER_ALIGNMENT); add(typeLabel); // smaller font for most labels Font font = formatLabel.getFont(); font = font.deriveFont(font.getSize2D() - 3); formatLabel.setFont(font); resLabel.setFont(font); zctLabel.setFont(font); typeLabel.setFont(font); // populate model icon = null; iconText = formatText = resText = npText = typeText = ""; iconTip = formatTip = resTip = zctTip = typeTip = null; if (jc != null) { jc.setAccessory(this); jc.addPropertyChangeListener(this); refresher = new Runnable() { @Override public void run() { iconLabel.setIcon(icon); iconLabel.setText(iconText); iconLabel.setToolTipText(iconTip); formatLabel.setText(formatText); formatLabel.setToolTipText(formatTip); resLabel.setText(resText); resLabel.setToolTipText(resTip); zctLabel.setText(npText); zctLabel.setToolTipText(zctTip); typeLabel.setText(typeText); typeLabel.setToolTipText(typeTip); } }; // start separate loader thread loaderAlive = true; loader = new Thread(this, "Preview"); loader.start(); } }
Example 7
Source File: ImageViewer.java From scifio with BSD 2-Clause "Simplified" License | 4 votes |
/** Constructs an image viewer. */ public ImageViewer(final Context context) { super(TITLE); context.inject(this); setDefaultCloseOperation(DISPOSE_ON_CLOSE); addWindowListener(this); // content pane pane = new JPanel(); pane.setLayout(new BorderLayout()); setContentPane(pane); setSize(350, 350); // default size // navigation sliders sliderPanel = new JPanel(); sliderPanel.setVisible(false); sliderPanel.setBorder(new EmptyBorder(5, 3, 5, 3)); sliderPanel.setLayout(new BoxLayout(sliderPanel, BoxLayout.Y_AXIS)); pane.add(BorderLayout.SOUTH, sliderPanel); final JPanel nPanel = new JPanel(); nPanel.setLayout(new BoxLayout(nPanel, BoxLayout.X_AXIS)); sliderPanel.add(nPanel); sliderPanel.add(Box.createVerticalStrut(2)); nSlider = new JSlider(1, 1); nSlider.setEnabled(false); nSlider.addChangeListener(this); nPanel.add(new JLabel("N")); nPanel.add(Box.createHorizontalStrut(3)); nPanel.add(nSlider); final JPanel ztcPanel = new JPanel(); ztcPanel.setLayout(new BoxLayout(ztcPanel, BoxLayout.X_AXIS)); sliderPanel.add(ztcPanel); // image icon final BufferedImage dummy = AWTImageTools.makeImage(new byte[1][1], 1, 1, false); icon = new ImageIcon(dummy); iconLabel = new JLabel(icon, SwingConstants.LEFT); iconLabel.setVerticalAlignment(SwingConstants.TOP); pane.add(new JScrollPane(iconLabel)); // cursor probe probeLabel = new JLabel(" "); probeLabel.setHorizontalAlignment(SwingConstants.CENTER); probeLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); pane.add(BorderLayout.NORTH, probeLabel); iconLabel.addMouseMotionListener(this); // menu bar final JMenuBar menubar = new JMenuBar(); // FIXME: currently the menu bar is disabled to restrict the use of // ImageViewer to the Show command. We could attempt to get this // implementation working nicely, or just convert to an IJ2 // implementation. // setJMenuBar(menubar); final JMenu file = new JMenu("File"); file.setMnemonic('f'); menubar.add(file); final JMenuItem fileOpen = new JMenuItem("Open..."); fileOpen.setMnemonic('o'); fileOpen.setActionCommand("open"); fileOpen.addActionListener(this); file.add(fileOpen); fileSave = new JMenuItem("Save..."); fileSave.setMnemonic('s'); fileSave.setEnabled(false); fileSave.setActionCommand("save"); fileSave.addActionListener(this); file.add(fileSave); fileView = new JMenuItem("View Metadata..."); final JMenuItem fileExit = new JMenuItem("Exit"); fileExit.setMnemonic('x'); fileExit.setActionCommand("exit"); fileExit.addActionListener(this); file.add(fileExit); final JMenu options = new JMenu("Options"); options.setMnemonic('p'); menubar.add(options); final JMenuItem optionsFPS = new JMenuItem("Frames per Second..."); optionsFPS.setMnemonic('f'); optionsFPS.setActionCommand("fps"); optionsFPS.addActionListener(this); options.add(optionsFPS); final JMenu help = new JMenu("Help"); help.setMnemonic('h'); menubar.add(help); final JMenuItem helpAbout = new JMenuItem("About..."); helpAbout.setMnemonic('a'); helpAbout.setActionCommand("about"); helpAbout.addActionListener(this); help.add(helpAbout); // add key listener to focusable components nSlider.addKeyListener(this); }
Example 8
Source File: Runner.java From Scripts with GNU General Public License v3.0 | 4 votes |
/** Default constructor-based dependency injection */ public Runner(final Context context) { context.inject(this); setSilent(false); }
Example 9
Source File: ModulesResource.java From imagej-server with Apache License 2.0 | 4 votes |
/** * Initialize resource by injection. Should not be called directly. * * @param ctx */ @Inject public void initialize(final Context ctx) { ctx.inject(this); updateModuleCache(); }
Example 10
Source File: ScijavaEvaluator.java From scijava-jupyter-kernel with Apache License 2.0 | 3 votes |
public ScijavaEvaluator(Context context, String shellId, String sessionId) { context.inject(this); this.shellId = shellId; this.sessionId = sessionId; this.scriptEngines = new HashMap<>(); this.scriptLanguages = new HashMap<>(); this.completers = new HashMap<>(); this.languageName = DEFAULT_LANGUAGE; }