Search in sources :

Example 1 with ICacheStrategy

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);
}
Also used : ICacheStrategy(loci.formats.cache.ICacheStrategy)

Example 2 with ICacheStrategy

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);
}
Also used : ICacheStrategy(loci.formats.cache.ICacheStrategy)

Example 3 with ICacheStrategy

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;
    }
}
Also used : ICacheStrategy(loci.formats.cache.ICacheStrategy)

Example 4 with ICacheStrategy

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);
}
Also used : ICacheStrategy(loci.formats.cache.ICacheStrategy)

Example 5 with ICacheStrategy

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();
}
Also used : ICacheStrategy(loci.formats.cache.ICacheStrategy)

Aggregations

ICacheStrategy (loci.formats.cache.ICacheStrategy)7 RectangleStrategy (loci.formats.cache.RectangleStrategy)2 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 JFrame (javax.swing.JFrame)1 EmptyBorder (javax.swing.border.EmptyBorder)1 ImageReader (loci.formats.ImageReader)1 ByteArraySource (loci.formats.cache.ByteArraySource)1 Cache (loci.formats.cache.Cache)1 CacheEvent (loci.formats.cache.CacheEvent)1 CacheListener (loci.formats.cache.CacheListener)1 CrosshairStrategy (loci.formats.cache.CrosshairStrategy)1 ICacheSource (loci.formats.cache.ICacheSource)1 BufferedImageSource (loci.formats.gui.BufferedImageSource)1 CacheComponent (loci.formats.gui.CacheComponent)1