Search in sources :

Example 71 with Location

use of loci.common.Location in project bioformats by openmicroscopy.

the class ImageFaker method fakeScreen.

public boolean fakeScreen(String[] args) {
    DebugTools.enableLogging("INFO");
    boolean validArgs = parseArgs(args);
    if (!validArgs || targetDirectoryPath == null) {
        printUsage();
        return false;
    }
    // make sure that we don't end up with just a ".fake" directory
    if (new Location(targetDirectoryPath).exists()) {
        Location p = new Location(targetDirectoryPath, "screen.fake");
        int index = 1;
        while (p.exists()) {
            p = new Location(targetDirectoryPath, "screen" + index + ".fake");
            index++;
        }
        targetDirectoryPath = p.getAbsolutePath();
    }
    Location directoryRoot;
    if (!FormatHandler.checkSuffix(targetDirectoryPath, ResourceNamer.FAKE_EXT)) {
        directoryRoot = new Location(targetDirectoryPath + ResourceNamer.DOT + ResourceNamer.FAKE_EXT);
    } else {
        directoryRoot = new Location(targetDirectoryPath);
    }
    FakeImage fake = new FakeImage(directoryRoot);
    fake.generateScreen(plates, plateAcquisitions, rows, columns, fields);
    return true;
}
Also used : Location(loci.common.Location)

Example 72 with Location

use of loci.common.Location in project bioformats by openmicroscopy.

the class FormatReaderTest method writeConfigFile.

@Test(groups = { "config" })
public void writeConfigFile() {
    setupReader();
    if (!initFile(false))
        return;
    String file = reader.getCurrentFile();
    try {
        String parent = new Location(file).getParent();
        String configDir = configTree.getConfigDirectory();
        String rootDir = configTree.getRootDirectory();
        if (configDir != null) {
            parent = parent.replaceAll(rootDir, configDir);
            File parentDir = new File(parent);
            if (!parentDir.exists()) {
                parentDir.mkdirs();
            }
        }
        File f = new File(parent, ".bioformats");
        LOGGER.info("Generating configuration: {}", f);
        Configuration newConfig = new Configuration(reader, f.getAbsolutePath());
        newConfig.saveToFile();
        reader.close();
    } catch (Throwable t) {
        LOGGER.info("", t);
        assert false;
    }
}
Also used : File(java.io.File) Location(loci.common.Location) Test(org.testng.annotations.Test)

Example 73 with Location

use of loci.common.Location in project bioformats by openmicroscopy.

the class TestTools method getExternalSymlinkConfigFile.

/**
 * Retrieve an external symlinked configuration file given a root directory
 * and a test configuration.
 * @deprecated No replacement.
 */
@Deprecated
public static String getExternalSymlinkConfigFile(String root, final ConfigurationTree config) {
    // Look for a configuration file under the configuration directory
    try {
        String canonicalRoot = new Location(root).getCanonicalPath();
        if (!root.equals(canonicalRoot)) {
            String configCanonicalRoot = config.relocateToConfig(canonicalRoot);
            Location configFile = new Location(configCanonicalRoot, baseConfigName);
            if (configFile.exists()) {
                return configFile.getAbsolutePath();
            }
        }
    } catch (IOException e) {
    }
    ;
    return null;
}
Also used : IOException(java.io.IOException) Location(loci.common.Location)

Example 74 with Location

use of loci.common.Location in project bioformats by openmicroscopy.

the class Configuration method putTableName.

private void putTableName(IniTable table, IFormatReader reader, String suffix) {
    Location file = new Location(reader.getCurrentFile());
    table.put(IniTable.HEADER_KEY, file.getName() + suffix);
}
Also used : Location(loci.common.Location)

Example 75 with Location

use of loci.common.Location in project bioformats by openmicroscopy.

the class Configuration method setSeries.

public void setSeries(int series) {
    Location file = new Location(dataFile);
    currentTable = ini.getTable(file.getName() + SERIES + series);
}
Also used : Location(loci.common.Location)

Aggregations

Location (loci.common.Location)185 CoreMetadata (loci.formats.CoreMetadata)55 MetadataStore (loci.formats.meta.MetadataStore)51 FormatException (loci.formats.FormatException)49 ArrayList (java.util.ArrayList)47 RandomAccessInputStream (loci.common.RandomAccessInputStream)47 Length (ome.units.quantity.Length)34 IOException (java.io.IOException)28 Timestamp (ome.xml.model.primitives.Timestamp)28 Time (ome.units.quantity.Time)20 IFD (loci.formats.tiff.IFD)15 TiffParser (loci.formats.tiff.TiffParser)15 NonNegativeInteger (ome.xml.model.primitives.NonNegativeInteger)15 PositiveInteger (ome.xml.model.primitives.PositiveInteger)15 DependencyException (loci.common.services.DependencyException)13 ServiceException (loci.common.services.ServiceException)12 File (java.io.File)11 ServiceFactory (loci.common.services.ServiceFactory)11 IniList (loci.common.IniList)10 FilePattern (loci.formats.FilePattern)10