public BrowserOptionsWindow(String title, Cache cache, String[] axes) { super(title); CacheComponent panel = new CacheComponent(cache, axes); panel.setBorder(new EmptyBorder(15, 15, 15, 15)); panel.setMinimumSize(new Dimension(300, 500)); setContentPane(panel); setDefaultCloseOperation(DISPOSE_ON_CLOSE); pack(); }
/** Updates cache order to match the state of the GUI. */ private void updateOrder(int index) { int ord = orderValue(order[index].getSelectedIndex()); ICacheStrategy strategy = cache.getStrategy(); int[] orders = strategy.getOrder(); if (ord != orders[index]) strategy.setOrder(ord, index); }
/** Updates cache priority to match the state of the GUI. */ private void updatePriority(int index) { int prio = priorityValue(priority[index].getSelectedIndex()); ICacheStrategy strategy = cache.getStrategy(); int[] priorities = strategy.getPriorities(); if (prio != priorities[index]) strategy.setPriority(prio, index); }
lengths = cache.getStrategy().getLengths(); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JLabel label = new JLabel("Objects to cache: "); sourceChooser = new JComboBox(SOURCES); sourceChooser.setSelectedIndex(sourceIndex(cache.getSource())); sourceChooser.setActionCommand("source"); sourceChooser.addActionListener(this); strategyChooser.setSelectedIndex(strategyIndex(strategy)); strategyChooser.setActionCommand("strategy"); strategyChooser.addActionListener(this); range[i] = new JSpinner(new SpinnerNumberModel(rng[i], 0, lengths[i], 1)); priority[i] = new JComboBox(PRIORITIES); priority[i].setSelectedIndex(priorityIndex(prio[i])); order[i] = new JComboBox(ORDERS); order[i].setSelectedIndex(orderIndex(ord[i])); add(top); add(Box.createVerticalStrut(9)); add(bottom);
case CacheEvent.SOURCE_CHANGED: sourceChooser.removeActionListener(this); sourceChooser.setSelectedIndex(sourceIndex(cache.getSource())); sourceChooser.addActionListener(this); break; case CacheEvent.STRATEGY_CHANGED: strategyChooser.removeActionListener(this); strategyChooser.setSelectedIndex(strategyIndex(strategy)); strategyChooser.addActionListener(this); break; for (int i=0; i<prio.length; i++) { priority[i].removeActionListener(this); priority[i].setSelectedIndex(priorityIndex(prio[i])); priority[i].addActionListener(this); for (int i=0; i<ord.length; i++) { order[i].removeActionListener(this); order[i].setSelectedIndex(orderIndex(ord[i])); order[i].addActionListener(this);
else if (cmd.startsWith("g")) { // gui String[] axes = {"Z", "C", "T"}; CacheComponent widget = new CacheComponent(cache, axes, id); widget.setBorder(new EmptyBorder(15, 15, 15, 15)); JFrame frame = new JFrame("Cache controls"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
lengths = cache.getStrategy().getLengths(); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JLabel label = new JLabel("Objects to cache: "); sourceChooser = new JComboBox(SOURCES); sourceChooser.setSelectedIndex(sourceIndex(cache.getSource())); sourceChooser.setActionCommand("source"); sourceChooser.addActionListener(this); strategyChooser.setSelectedIndex(strategyIndex(strategy)); strategyChooser.setActionCommand("strategy"); strategyChooser.addActionListener(this); range[i] = new JSpinner(new SpinnerNumberModel(rng[i], 0, lengths[i], 1)); priority[i] = new JComboBox(PRIORITIES); priority[i].setSelectedIndex(priorityIndex(prio[i])); order[i] = new JComboBox(ORDERS); order[i].setSelectedIndex(orderIndex(ord[i])); add(top); add(Box.createVerticalStrut(9)); add(bottom);
case CacheEvent.SOURCE_CHANGED: sourceChooser.removeActionListener(this); sourceChooser.setSelectedIndex(sourceIndex(cache.getSource())); sourceChooser.addActionListener(this); break; case CacheEvent.STRATEGY_CHANGED: strategyChooser.removeActionListener(this); strategyChooser.setSelectedIndex(strategyIndex(strategy)); strategyChooser.addActionListener(this); break; for (int i=0; i<prio.length; i++) { priority[i].removeActionListener(this); priority[i].setSelectedIndex(priorityIndex(prio[i])); priority[i].addActionListener(this); for (int i=0; i<ord.length; i++) { order[i].removeActionListener(this); order[i].setSelectedIndex(orderIndex(ord[i])); order[i].addActionListener(this);
else if (cmd.startsWith("g")) { // gui String[] axes = {"Z", "C", "T"}; CacheComponent widget = new CacheComponent(cache, axes, id); widget.setBorder(new EmptyBorder(15, 15, 15, 15)); JFrame frame = new JFrame("Cache controls"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
public BrowserOptionsWindow(String title, Cache cache, String[] axes) { super(title); CacheComponent panel = new CacheComponent(cache, axes); panel.setBorder(new EmptyBorder(15, 15, 15, 15)); panel.setMinimumSize(new Dimension(300, 500)); setContentPane(panel); setDefaultCloseOperation(DISPOSE_ON_CLOSE); pack(); }
/** Updates cache order to match the state of the GUI. */ private void updateOrder(int index) { int ord = orderValue(order[index].getSelectedIndex()); ICacheStrategy strategy = cache.getStrategy(); int[] orders = strategy.getOrder(); if (ord != orders[index]) strategy.setOrder(ord, index); }
/** Updates cache priority to match the state of the GUI. */ private void updatePriority(int index) { int prio = priorityValue(priority[index].getSelectedIndex()); ICacheStrategy strategy = cache.getStrategy(); int[] priorities = strategy.getPriorities(); if (prio != priorities[index]) strategy.setPriority(prio, index); }