Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(final String... args) throws DSOutOfServiceException,
- ExecutionException, DSAccessException
- {
- final LoginCredentials cred = new LoginCredentials(username, password, host,
- port);
- final Logger simpleLogger = new SimpleLogger();
- final Gateway gateway = new Gateway(simpleLogger);
- final ExperimenterData user = gateway.connect(cred);
- final SecurityContext ctx = new SecurityContext(user.getGroupId());
- final ROIFacility roiFac = gateway.getFacility(ROIFacility.class);
- final Collection<ROIResult> rois = roiFac.loadROIs(ctx, 701);
- for (final ROIResult result : rois) {
- final Collection<ROIData> roiDatas = result.getROIs();
- for (final ROIData roiData : roiDatas) {
- System.out.println("------------------------------");
- modifyAndSaveROI(roiData, roiFac, ctx);
- }
- }
- gateway.disconnect();
- }
- private static void modifyAndSaveROI(final ROIData roi,
- final ROIFacility roiFac, final SecurityContext ctx)
- throws DSOutOfServiceException, DSAccessException
- {
- final RectangleData rd = (RectangleData) roi.getIterator().next().get(0);
- System.out.println("Downloaded state");
- System.out.println("ROIData ID: " + roi.getId());
- printRectangleInfo(rd);
- rd.setX(18);
- rd.setY(105);
- System.out.println("Modified state");
- System.out.println("ROIData ID: " + roi.getId());
- printRectangleInfo(rd);
- final Collection<ROIData> saved = roiFac.saveROIs(ctx, 701, Collections
- .singletonList(roi));
- System.out.println("Returned state");
- for (final ROIData r : saved) {
- System.out.println("ROIData ID: " + r.getId());
- final Iterator<List<ShapeData>> itr = r.getIterator();
- while (itr.hasNext()) {
- final List<ShapeData> shapes = itr.next();
- for (final ShapeData shape : shapes) {
- if (shape instanceof RectangleData) printRectangleInfo(
- (RectangleData) shape);
- else System.out.println("Not a rectangle!?");
- }
- }
- }
- }
- private static void printRectangleInfo(final RectangleData rd) {
- System.out.println("ID: " + rd.getId() + " Z: " + rd.getZ() + " T: " + rd
- .getT() + " C: " + rd.getC() + " X: " + rd.getX() + " Y: " + rd.getY() +
- " Width: " + rd.getWidth() + " Height: " + rd.getHeight());
- System.out.println();
- }
Add Comment
Please, Sign In to add comment