use of loci.formats.cache.ICacheStrategy in project bioformats by openmicroscopy.
the class CacheComponent method updatePriority.
/**
* 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);
}
use of loci.formats.cache.ICacheStrategy in project bioformats by openmicroscopy.
the class CacheComponent method updateOrder.
/**
* 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);
}
use of loci.formats.cache.ICacheStrategy in project bioformats by openmicroscopy.
the class CacheComponent method cacheUpdated.
// -- CacheListener API methods --
/**
* Updates GUI to match latest cache state.
*/
@Override
public void cacheUpdated(CacheEvent e) {
int type = e.getType();
ICacheStrategy strategy = cache.getStrategy();
switch(type) {
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;
case CacheEvent.PRIORITIES_CHANGED:
int[] prio = strategy.getPriorities();
for (int i = 0; i < prio.length; i++) {
priority[i].removeActionListener(this);
priority[i].setSelectedIndex(priorityIndex(prio[i]));
priority[i].addActionListener(this);
}
break;
case CacheEvent.ORDER_CHANGED:
int[] ord = strategy.getOrder();
for (int i = 0; i < ord.length; i++) {
order[i].removeActionListener(this);
order[i].setSelectedIndex(orderIndex(ord[i]));
order[i].addActionListener(this);
}
break;
case CacheEvent.RANGE_CHANGED:
int[] rng = strategy.getRange();
for (int i = 0; i < rng.length; i++) {
range[i].removeChangeListener(this);
range[i].setValue(new Integer(rng[i]));
range[i].addChangeListener(this);
}
break;
}
}
use of loci.formats.cache.ICacheStrategy in project bioformats by openmicroscopy.
the class CacheComponent method updateRange.
/**
* Updates cache range to match the state of the GUI.
*/
private void updateRange(int index) {
int rng = ((Integer) range[index].getValue()).intValue();
ICacheStrategy strategy = cache.getStrategy();
int[] ranges = strategy.getRange();
if (rng != ranges[index])
strategy.setRange(rng, index);
}
use of loci.formats.cache.ICacheStrategy in project bioformats by openmicroscopy.
the class CacheConsole method printOrder.
/**
* Helper utility for outputing cache strategy's order, used by main.
*/
private static final void printOrder(String prefix, Cache cache) {
ICacheStrategy strategy = cache.getStrategy();
int[] order = strategy.getOrder();
System.out.print(prefix);
for (int i = 0; i < order.length; i++) {
switch(order[i]) {
case ICacheStrategy.CENTERED_ORDER:
System.out.print(" C");
break;
case ICacheStrategy.FORWARD_ORDER:
System.out.print(" F");
break;
case ICacheStrategy.BACKWARD_ORDER:
System.out.print(" B");
break;
default:
System.out.print(" ?");
}
}
System.out.println();
}
Aggregations