Search in sources :

Example 61 with Project

use of ini.trakem2.Project in project TrakEM2 by trakem2.

the class Project method adjustProperties.

public void adjustProperties() {
    // should be more generic, but for now it'll do
    GenericDialog gd = new GenericDialog("Properties");
    gd.addMessage("Ignore image linking for:");
    boolean link_labels = addBox(gd, DLabel.class);
    boolean nolink_segmentations = "true".equals(ht_props.get("segmentations_nolinks"));
    gd.addCheckbox("Segmentations", nolink_segmentations);
    gd.addMessage("Currently linked objects will remain so\nunless explicitly unlinked.");
    boolean dissector_zoom = "true".equals(ht_props.get("dissector_zoom"));
    gd.addCheckbox("Zoom-invariant markers for Dissector", dissector_zoom);
    gd.addChoice("Image_resizing_mode: ", Loader.MIPMAP_MODES.values().toArray(new String[Loader.MIPMAP_MODES.size()]), Loader.getMipMapModeName(mipmaps_mode));
    gd.addChoice("mipmaps format:", FSLoader.MIPMAP_FORMATS, FSLoader.MIPMAP_FORMATS[loader.getMipMapFormat()]);
    gd.addNumericField("Save mipmap images from level", this.first_mipmap_level_saved, 0);
    boolean layer_mipmaps = "true".equals(ht_props.get("layer_mipmaps"));
    gd.addCheckbox("Layer_mipmaps", layer_mipmaps);
    boolean keep_mipmaps = "true".equals(ht_props.get("keep_mipmaps"));
    // coping with the fact that thee is no Action context ... there should be one in the Worker thread.
    gd.addCheckbox("Keep_mipmaps_when_deleting_images", keep_mipmaps);
    int bucket_side = (int) getProperty("bucket_side", Bucket.MIN_BUCKET_SIZE);
    gd.addNumericField("Bucket side length: ", bucket_side, 0, 6, "pixels");
    boolean no_shutdown_hook = "true".equals(ht_props.get("no_shutdown_hook"));
    gd.addCheckbox("No_shutdown_hook to save the project", no_shutdown_hook);
    int n_undo_steps = getProperty("n_undo_steps", 32);
    gd.addSlider("Undo steps", 32, 200, n_undo_steps);
    boolean flood_fill_to_image_edge = "true".equals(ht_props.get("flood_fill_to_image_edge"));
    gd.addCheckbox("AreaList_flood_fill_to_image_edges", flood_fill_to_image_edge);
    int look_ahead_cache = (int) getProperty("look_ahead_cache", 0);
    gd.addNumericField("Look_ahead_cache:", look_ahead_cache, 0, 6, "layers");
    // default: every 10 minutes
    int autosaving_interval = getProperty("autosaving_interval", 10);
    gd.addNumericField("Autosave every:", autosaving_interval, 0, 6, "minutes");
    int n_mipmap_threads = getProperty("n_mipmap_threads", 1);
    gd.addSlider("Number of threads for mipmaps", 1, n_mipmap_threads, n_mipmap_threads);
    int meshResolution = getProperty("mesh_resolution", 32);
    gd.addSlider("Default mesh resolution for images", 1, 512, meshResolution);
    // 
    gd.showDialog();
    // 
    if (gd.wasCanceled())
        return;
    setLinkProp(link_labels, gd.getNextBoolean(), DLabel.class);
    boolean nolink_segmentations2 = gd.getNextBoolean();
    if (nolink_segmentations) {
        if (!nolink_segmentations2)
            ht_props.remove("segmentations_nolinks");
    } else if (nolink_segmentations2)
        ht_props.put("segmentations_nolinks", "true");
    if (adjustProp("dissector_zoom", dissector_zoom, gd.getNextBoolean())) {
        // TODO: should repaint nested LayerSets as well
        Display.repaint(layer_set);
    }
    this.mipmaps_mode = Loader.getMipMapModeIndex(gd.getNextChoice());
    final int new_mipmap_format = gd.getNextChoiceIndex();
    final int old_mipmap_format = loader.getMipMapFormat();
    if (new_mipmap_format != old_mipmap_format) {
        YesNoDialog yn = new YesNoDialog("MipMaps format", "Changing mipmaps format to '" + FSLoader.MIPMAP_FORMATS[new_mipmap_format] + "'requires regenerating all mipmaps. Proceed?");
        if (yn.yesPressed()) {
            if (loader.setMipMapFormat(new_mipmap_format)) {
                loader.updateMipMapsFormat(old_mipmap_format, new_mipmap_format);
            }
        }
    }
    setFirstMipMapLevelSaved(gd.getNextNumber());
    boolean layer_mipmaps2 = gd.getNextBoolean();
    if (adjustProp("layer_mipmaps", layer_mipmaps, layer_mipmaps2)) {
        if (layer_mipmaps && !layer_mipmaps2) {
        // TODO
        // 1 - ask first
        // 2 - remove all existing images from layer.mipmaps folder
        } else if (!layer_mipmaps && layer_mipmaps2) {
        // TODO
        // 1 - ask first
        // 2 - create de novo all layer mipmaps in a background task
        }
    }
    adjustProp("keep_mipmaps", keep_mipmaps, gd.getNextBoolean());
    Utils.log2("keep_mipmaps: " + getBooleanProperty("keep_mipmaps"));
    // 
    bucket_side = (int) gd.getNextNumber();
    if (bucket_side > Bucket.MIN_BUCKET_SIZE) {
        setProperty("bucket_side", Integer.toString(bucket_side));
        layer_set.recreateBuckets(true);
    }
    adjustProp("no_shutdown_hook", no_shutdown_hook, gd.getNextBoolean());
    n_undo_steps = (int) gd.getNextNumber();
    if (n_undo_steps < 0)
        n_undo_steps = 0;
    setProperty("n_undo_steps", Integer.toString(n_undo_steps));
    adjustProp("flood_fill_to_image_edge", flood_fill_to_image_edge, gd.getNextBoolean());
    double d_look_ahead_cache = gd.getNextNumber();
    if (!Double.isNaN(d_look_ahead_cache) && d_look_ahead_cache >= 0) {
        setProperty("look_ahead_cache", Integer.toString((int) d_look_ahead_cache));
        if (0 == d_look_ahead_cache) {
            Display.clearColumnScreenshots(this.layer_set);
        } else {
            Utils.logAll("WARNING: look-ahead cache is incomplete.\n  Expect issues when editing objects, adding new ones, and the like.\n  Use \"Project - Flush image cache\" to fix any lack of refreshing issues you encounter.");
        }
    } else {
        Utils.log2("Ignoring invalid 'look ahead cache' value " + d_look_ahead_cache);
    }
    double autosaving_interval2 = gd.getNextNumber();
    if (((int) (autosaving_interval2)) == autosaving_interval) {
    // do nothing
    } else if (autosaving_interval2 < 0 || Double.isNaN(autosaving_interval)) {
        Utils.log("IGNORING invalid autosaving interval: " + autosaving_interval2);
    } else {
        setProperty("autosaving_interval", Integer.toString((int) autosaving_interval2));
        restartAutosaving();
    }
    int n_mipmap_threads2 = (int) Math.max(1, gd.getNextNumber());
    if (n_mipmap_threads != n_mipmap_threads2) {
        setProperty("n_mipmap_threads", Integer.toString(n_mipmap_threads2));
        // WARNING: this does it for a static service, affecting all projects!
        FSLoader.restartMipMapThreads(n_mipmap_threads2);
    }
    int meshResolution2 = (int) gd.getNextNumber();
    if (meshResolution != meshResolution2) {
        if (meshResolution2 > 0) {
            setProperty("mesh_resolution", Integer.toString(meshResolution2));
        } else {
            Utils.log("WARNING: ignoring invalid mesh resolution value " + meshResolution2);
        }
    }
}
Also used : GenericDialog(ij.gui.GenericDialog) YesNoDialog(ini.trakem2.display.YesNoDialog)

Example 62 with Project

use of ini.trakem2.Project in project TrakEM2 by trakem2.

the class Project method saveTask.

public Bureaucrat saveTask(final String command) {
    return Bureaucrat.createAndStart(new Worker.Task("Saving") {

        public void exec() {
            if (command.equals("Save")) {
                save();
            } else if (command.equals("Save as...")) {
                XMLOptions options = new XMLOptions();
                options.overwriteXMLFile = false;
                options.export_images = false;
                options.include_coordinate_transform = true;
                options.patches_dir = null;
                // Will open a file dialog
                loader.saveAs(project, options);
                restartAutosaving();
            // 
            } else if (command.equals("Save as... without coordinate transforms")) {
                YesNoDialog yn = new YesNoDialog("WARNING", "You are about to save an XML file that lacks the information for the coordinate transforms of each image.\n" + "These transforms are referred to with the attribute 'ct_id' of each 't2_patch' entry in the XML document,\n" + "and the data for the transform is stored in an individual file under the folder 'trakem2.cts/'.\n" + " \n" + "It is advised to keep a complete XML file with all coordinate transforms included along with this new copy.\n" + "Please check NOW that you have such a complete XML copy.\n" + " \n" + "Proceed?");
                if (!yn.yesPressed())
                    return;
                saveWithoutCoordinateTransforms();
            // 
            } else if (command.equals("Delete stale files...")) {
                setTaskName("Deleting stale files");
                GenericDialog gd = new GenericDialog("Delete stale files");
                gd.addMessage("You are about to remove all files under the folder 'trakem2.cts/' which are not referred to from the\n" + "currently loaded project. If you have sibling XML files whose 't2_patch' entries (the images) refer,\n" + "via 'ct_id' attributes, to coordinate transforms in 'trakem2.cts/' that this current XML doesn't,\n" + "they may be LOST FOREVER. Unless you have a version of the XML file with the coordinate transforms\n" + "written in it, as can be obtained by using the 'Project - Save' command.\n" + " \n" + "The same is true for the .zip files that store alpha masks, under folder 'trakem2.masks/'\n" + "and which are referred to from the 'alpha_mask_id' attribute of 't2_patch' entries.\n" + " \n" + "Do you have such complete XML file? Check *NOW*.\n" + " \n" + "Proceed with deleting:");
                gd.addCheckbox("Delete stale coordinate transform files", true);
                gd.addCheckbox("Delete stale alpha mask files", true);
                gd.showDialog();
                if (gd.wasCanceled())
                    return;
                project.getLoader().deleteStaleFiles(gd.getNextBoolean(), gd.getNextBoolean());
            }
        }
    }, project);
}
Also used : YesNoDialog(ini.trakem2.display.YesNoDialog) GenericDialog(ij.gui.GenericDialog) Worker(ini.trakem2.utils.Worker) XMLOptions(ini.trakem2.persistence.XMLOptions)

Example 63 with Project

use of ini.trakem2.Project in project openstack4j by ContainX.

the class KeystoneProjectServiceTests method projects_getByName_not_exist_test.

public void projects_getByName_not_exist_test() throws Exception {
    respondWith(JSON_PROJECTS_GET_BY_NAME_EMPTY);
    Project project = osv3().identity().projects().getByName(PROJECT_NAME, PROJECT_DOMAIN_ID);
    assertNull(project);
}
Also used : Project(org.openstack4j.model.identity.v3.Project)

Example 64 with Project

use of ini.trakem2.Project in project openstack4j by ContainX.

the class KeystoneProjectServiceTests method projects_crud_test.

public void projects_crud_test() throws Exception {
    Project project = Builders.project().name(PROJECT_NAME).description(PROJECT_DESCRIPTION).domainId(PROJECT_DOMAIN_ID).setExtra(PROJECT_EXTRA_KEY_1, PROJECT_EXTRA_VALUE_1).enabled(true).build();
    respondWith(JSON_PROJECTS_CREATE);
    Project newProject = osv3().identity().projects().create(project);
    assertEquals(newProject.getName(), PROJECT_NAME);
    assertEquals(newProject.getDomainId(), PROJECT_DOMAIN_ID);
    assertEquals(newProject.getDescription(), PROJECT_DESCRIPTION);
    assertEquals(newProject.getExtra(PROJECT_EXTRA_KEY_1), PROJECT_EXTRA_VALUE_1);
    PROJECT_ID = newProject.getId();
    respondWith(JSON_PROJECTS_GET_BYID);
    Project project_setToUpdate = osv3().identity().projects().get(PROJECT_ID);
    respondWith(JSON_PROJECTS_UPDATE);
    Project updatedProject = osv3().identity().projects().update(project_setToUpdate.toBuilder().description(PROJECT_DESCRIPTION_UPDATE).setExtra(PROJECT_EXTRA_KEY_2, PROJECT_EXTRA_VALUE_2).build());
    assertEquals(updatedProject.getId(), PROJECT_ID);
    assertEquals(updatedProject.getName(), PROJECT_NAME);
    assertEquals(updatedProject.getDomainId(), PROJECT_DOMAIN_ID);
    assertEquals(updatedProject.getDescription(), PROJECT_DESCRIPTION_UPDATE);
    assertEquals(updatedProject.getExtra(PROJECT_EXTRA_KEY_1), PROJECT_EXTRA_VALUE_1);
    assertEquals(updatedProject.getExtra(PROJECT_EXTRA_KEY_2), PROJECT_EXTRA_VALUE_2);
}
Also used : Project(org.openstack4j.model.identity.v3.Project)

Example 65 with Project

use of ini.trakem2.Project in project camel by apache.

the class ProjectProducer method doCreate.

private void doCreate(Exchange exchange) {
    final Project in = messageToProject(exchange.getIn());
    final Project out = osV3Client.identity().projects().create(in);
    exchange.getIn().setBody(out);
}
Also used : Project(org.openstack4j.model.identity.v3.Project)

Aggregations

ArrayList (java.util.ArrayList)33 Project (ini.trakem2.Project)26 HashMap (java.util.HashMap)25 Layer (ini.trakem2.display.Layer)21 Displayable (ini.trakem2.display.Displayable)19 Patch (ini.trakem2.display.Patch)18 File (java.io.File)18 HashSet (java.util.HashSet)18 ZDisplayable (ini.trakem2.display.ZDisplayable)17 ImagePlus (ij.ImagePlus)16 ProjectThing (ini.trakem2.tree.ProjectThing)16 Worker (ini.trakem2.utils.Worker)16 TemplateThing (ini.trakem2.tree.TemplateThing)15 Map (java.util.Map)15 LayerSet (ini.trakem2.display.LayerSet)14 ResultSet (java.sql.ResultSet)13 DBObject (ini.trakem2.persistence.DBObject)12 AffineTransform (java.awt.geom.AffineTransform)11 TreeMap (java.util.TreeMap)11 FSLoader (ini.trakem2.persistence.FSLoader)10