Example usage for java.awt.geom Rectangle2D getX

List of usage examples for java.awt.geom Rectangle2D getX

Introduction

In this page you can find the example usage for java.awt.geom Rectangle2D getX.

Prototype

public abstract double getX();

Source Link

Document

Returns the X coordinate of the upper-left corner of the framing rectangle in double precision.

Usage

From source file:org.gumtree.vis.mask.ChartMaskingUtilities.java

public static void drawText(Graphics2D g2, Rectangle2D imageArea,
        LinkedHashMap<Rectangle2D, String> textContentMap, JFreeChart chart) {
    if (textContentMap == null || textContentMap.size() == 0) {
        return;//ww w  .  ja v  a  2 s  .  c  o m
    }
    //      for (Entry<Rectangle2D, String> textEntry : textMap.entrySet()) {
    //         Rectangle2D rect = textEntry.getKey();
    //         String text = textEntry.getValue();
    //         drawText(g2, imageArea, rect, text, chart);
    //      }
    Color oldColor = g2.getColor();
    g2.setColor(Color.BLACK);
    for (Entry<Rectangle2D, String> entry : textContentMap.entrySet()) {
        Rectangle2D rect = entry.getKey();
        Point2D screenPoint = ChartMaskingUtilities
                .translateChartPoint(new Point2D.Double(rect.getX(), rect.getY()), imageArea, chart);
        String text = entry.getValue();
        if (text == null) {
            continue;
        }
        String[] lines = text.split("\n");
        g2.setColor(Color.BLACK);
        for (int i = 0; i < lines.length; i++) {
            g2.drawString(lines[i], (int) screenPoint.getX() + 3, (int) screenPoint.getY() - 3 + i * 15);
        }
        //         if (rect == selectedTextWrapper) {
        //            FontMetrics fm = g2.getFontMetrics();
        //            int maxWidth = 0;
        //            int maxHeight = 0;
        //            for (int i = 0; i < lines.length; i++) {
        //               int lineWidth = fm.stringWidth(lines[i]);
        //               if (lineWidth > maxWidth) {
        //                  maxWidth = lineWidth;
        //               }
        //            }
        //            maxHeight = 15 * lines.length;
        //            if (maxWidth < 100) {
        //               maxWidth = 100;
        //            }
        //            Rectangle2D inputBox = new Rectangle2D.Double(screenPoint.getX(), screenPoint.getY() - 15, maxWidth + 8, maxHeight);
        //              Color fillColor = new Color(250, 250, 50, 30);
        //              g2.setPaint(fillColor);
        //              g2.fill(inputBox);
        //            g2.setColor(Color.ORANGE);
        //            g2.drawRect((int) screenPoint.getX(), (int) screenPoint.getY() - 15, maxWidth + 8, maxHeight);
        //
        //         }
        //         g2.drawString(text == null ? "" : text, (int) screenPoint.getX() + 3, (int) screenPoint.getY() - 3);
    }
    g2.setColor(oldColor);
}

From source file:ec.util.chart.swing.JTimeSeriesRendererSupport.java

private static Shape createShape(double x, double y, Rectangle2D hotspot) {
    Area result = new Area(new RoundRectangle2D.Double(hotspot.getX(), hotspot.getY(), hotspot.getWidth(),
            hotspot.getHeight(), 8, 8));

    boolean right = hotspot.getMinX() > x;

    Polygon po = new Polygon();
    po.addPoint(0, 0);/*from w  w  w  .j  a  v a  2 s  .  c  o  m*/
    po.addPoint(0, 10);
    po.addPoint(10, 0);
    AffineTransform af = new AffineTransform();
    if (right) {
        af.translate(hotspot.getX() - 7, hotspot.getY() + hotspot.getHeight() / 2);
        af.rotate(-Math.PI / 4);
    } else {
        af.translate(hotspot.getMaxX() + 7, hotspot.getY() + hotspot.getHeight() / 2);
        af.rotate(Math.PI * 3 / 4);
    }

    Shape shape = af.createTransformedShape(po);
    result.add(new Area(shape));
    return result;
}

From source file:org.apache.xmlgraphics.ps.PSImageUtils.java

/**
 * Generates commands to modify the current transformation matrix so an image fits
 * into a given rectangle./*from  w  w  w. j  ava 2  s . c om*/
 * @param gen the PostScript generator
 * @param imageDimensions the image's dimensions
 * @param targetRect the target rectangle
 * @throws IOException if an I/O error occurs
 */
public static void translateAndScale(PSGenerator gen, Dimension2D imageDimensions, Rectangle2D targetRect)
        throws IOException {
    gen.writeln(gen.formatDouble(targetRect.getX()) + " " + gen.formatDouble(targetRect.getY()) + " translate");
    if (imageDimensions == null) {
        imageDimensions = new Dimension(1, 1);
    }
    double sx = targetRect.getWidth() / imageDimensions.getWidth();
    double sy = targetRect.getHeight() / imageDimensions.getHeight();
    if (sx != 1 || sy != 1) {
        gen.writeln(gen.formatDouble(sx) + " " + gen.formatDouble(sy) + " scale");
    }
}

From source file:org.logisticPlanning.utils.graphics.chart.impl.jfree._JFCLineChart2D.java

/**
 * Creates a rectangle that is aligned to the frame.
 *
 * @param dimensions/* w w  w .j a  v  a 2  s  . com*/
 *          the dimensions for the rectangle.
 * @param frame
 *          the frame to align to.
 * @param hAlign
 *          the horizontal alignment.
 * @param vAlign
 *          the vertical alignment.
 * @return A rectangle.
 */
private static final Rectangle2D __createAlignedRectangle2D(final Size2D dimensions, final Rectangle2D frame,
        final HorizontalAlignment hAlign, final VerticalAlignment vAlign) {
    double x, y;

    x = y = Double.NaN;

    if (hAlign == HorizontalAlignment.LEFT) {
        x = frame.getX();
    } else if (hAlign == HorizontalAlignment.CENTER) {
        x = frame.getCenterX() - (dimensions.width / 2.0);
    } else if (hAlign == HorizontalAlignment.RIGHT) {
        x = frame.getMaxX() - dimensions.width;
    }
    if (vAlign == VerticalAlignment.TOP) {
        y = frame.getY();
    } else if (vAlign == VerticalAlignment.CENTER) {
        y = frame.getCenterY() - (dimensions.height / 2.0);
    } else if (vAlign == VerticalAlignment.BOTTOM) {
        y = frame.getMaxY() - dimensions.height;
    }

    return new Rectangle2D.Double(x, y, dimensions.width, dimensions.height);
}

From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.charts.JFreeChartConn.java

/**
 * Updates the point-related properties of a plot.
 * /*ww  w.java 2  s  .c  o m*/
 * @param aPlot
 *            Plot to be updated.
 * @param aScatter
 *            Visual settings to be applied.
 */
private static void updateScatter(XYPlot aPlot, ScatterSettings aScatter) {
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) aPlot.getRenderer();
    renderer.setSeriesPaint(0, aScatter.getPointColor());
    final Rectangle2D ds = AbstractRenderer.DEFAULT_SHAPE.getBounds2D();
    final double x = ds.getX();
    final double y = ds.getY();
    final double w = ds.getWidth();
    final double h = ds.getHeight();
    Shape shape = null;
    switch (aScatter.getPointShape()) {
    case POINT:
        shape = new Rectangle2D.Double(x + w / 2, y + h / 2, 1, 1);
        renderer.setBaseShapesFilled(true);
        break;
    case CIRCLE:
        shape = new Ellipse2D.Double(x, y, w, h);
        renderer.setBaseShapesFilled(false);
        break;
    case FILLED_CIRCLE:
        shape = new Ellipse2D.Double(x, y, w, h);
        renderer.setBaseShapesFilled(true);
        break;
    case SQUARE:
        shape = new Rectangle2D.Double(x, y, w, h);
        renderer.setBaseShapesFilled(false);
        break;
    case FILLED_SQUARE:
        shape = new Rectangle2D.Double(x, y, w, h);
        renderer.setBaseShapesFilled(true);
        break;
    case CROSS:
        shape = new Cross(x, y, w, h);
        renderer.setBaseShapesFilled(false);
    }
    renderer.setSeriesShape(0, shape);
}

From source file:com.t_oster.visicut.misc.Helper.java

public static Rectangle toRect(Rectangle2D src) {
    if (src == null) {
        return new Rectangle(0, 0, 0, 0);
    }// w  w  w.  j a va  2 s.  c o  m
    return new Rectangle((int) src.getX(), (int) src.getY(), (int) src.getWidth(), (int) src.getHeight());
}

From source file:ShapeTransform.java

/**
 * Scales a given shape. The shape is first normalized, then scaled and
 * finally brought back into its original position.
 * /*from   ww w  .  j a  v  a 2  s  .c  o m*/
 * @param shape
 *          the shape to be scaled
 * @param scaleX
 *          the horizontal scaling factor
 * @param scaleY
 *          the vertical scaling factor
 * @return the scaled shape
 */
private static Shape performDefaultTransformation(final Shape shape, final double scaleX, final double scaleY) {
    /**
     * Apply the normalisation shape transform ... bring the shape to pos (0,0)
     */
    final Rectangle2D bounds = shape.getBounds2D();
    AffineTransform af = AffineTransform.getTranslateInstance(0 - bounds.getX(), 0 - bounds.getY());
    // apply normalisation translation ...
    Shape s = af.createTransformedShape(shape);

    af = AffineTransform.getScaleInstance(scaleX, scaleY);
    // apply scaling ...
    s = af.createTransformedShape(s);

    // now retranslate the shape to its original position ...
    af = AffineTransform.getTranslateInstance(bounds.getX(), bounds.getY());
    return af.createTransformedShape(s);
}

From source file:ro.cs.products.Executor.java

private static int execute(CommandLine commandLine) throws Exception {
    int retCode = ReturnCode.OK;
    CommandLineParser parser = new DefaultParser();
    String logFile = props.getProperty("master.log.file");
    String folder;//  www  .ja v  a2 s  . c om
    boolean debugMode = commandLine.hasOption(Constants.PARAM_VERBOSE);
    Logger.CustomLogger logger;
    SensorType sensorType = commandLine.hasOption(Constants.SENSOR)
            ? Enum.valueOf(SensorType.class, commandLine.getOptionValue(Constants.SENSOR))
            : SensorType.S2;
    if (commandLine.hasOption(Constants.PARAM_INPUT_FOLDER)) {
        folder = commandLine.getOptionValue(Constants.PARAM_INPUT_FOLDER);
        Utilities.ensureExists(Paths.get(folder));
        Logger.initialize(Paths.get(folder, logFile).toAbsolutePath().toString(), debugMode);
        logger = Logger.getRootLogger();
        if (commandLine.hasOption(Constants.PARAM_VERBOSE)) {
            printCommandLine(commandLine);
        }
        if (sensorType == SensorType.L8) {
            logger.warn("Argument --input will be ignored for Landsat8");
        } else {
            String rootFolder = commandLine.getOptionValue(Constants.PARAM_INPUT_FOLDER);
            FillAnglesMethod fillAnglesMethod = Enum.valueOf(FillAnglesMethod.class,
                    commandLine.hasOption(Constants.PARAM_FILL_ANGLES)
                            ? commandLine.getOptionValue(Constants.PARAM_FILL_ANGLES).toUpperCase()
                            : FillAnglesMethod.NONE.name());
            if (!FillAnglesMethod.NONE.equals(fillAnglesMethod)) {
                try {
                    Set<String> products = null;
                    if (commandLine.hasOption(Constants.PARAM_PRODUCT_LIST)) {
                        products = new HashSet<>();
                        for (String product : commandLine.getOptionValues(Constants.PARAM_PRODUCT_LIST)) {
                            if (!product.endsWith(".SAFE")) {
                                products.add(product + ".SAFE");
                            } else {
                                products.add(product);
                            }
                        }
                    }
                    ProductInspector inspector = new ProductInspector(rootFolder, fillAnglesMethod, products);
                    inspector.traverse();
                } catch (IOException e) {
                    logger.error(e.getMessage());
                    retCode = ReturnCode.DOWNLOAD_ERROR;
                }
            }
        }
    } else {
        folder = commandLine.getOptionValue(Constants.PARAM_OUT_FOLDER);
        Utilities.ensureExists(Paths.get(folder));
        Logger.initialize(Paths.get(folder, logFile).toAbsolutePath().toString(), debugMode);
        logger = Logger.getRootLogger();
        printCommandLine(commandLine);

        String proxyType = commandLine.hasOption(Constants.PARAM_PROXY_TYPE)
                ? commandLine.getOptionValue(Constants.PARAM_PROXY_TYPE)
                : nullIfEmpty(props.getProperty("proxy.type", null));
        String proxyHost = commandLine.hasOption(Constants.PARAM_PROXY_HOST)
                ? commandLine.getOptionValue(Constants.PARAM_PROXY_HOST)
                : nullIfEmpty(props.getProperty("proxy.host", null));
        String proxyPort = commandLine.hasOption(Constants.PARAM_PROXY_PORT)
                ? commandLine.getOptionValue(Constants.PARAM_PROXY_PORT)
                : nullIfEmpty(props.getProperty("proxy.port", null));
        String proxyUser = commandLine.hasOption(Constants.PARAM_PROXY_USER)
                ? commandLine.getOptionValue(Constants.PARAM_PROXY_USER)
                : nullIfEmpty(props.getProperty("proxy.user", null));
        String proxyPwd = commandLine.hasOption(Constants.PARAM_PROXY_PASSWORD)
                ? commandLine.getOptionValue(Constants.PARAM_PROXY_PASSWORD)
                : nullIfEmpty(props.getProperty("proxy.pwd", null));
        NetUtils.setProxy(proxyType, proxyHost, proxyPort == null ? 0 : Integer.parseInt(proxyPort), proxyUser,
                proxyPwd);

        List<ProductDescriptor> products = new ArrayList<>();
        Set<String> tiles = new HashSet<>();
        Polygon2D areaOfInterest = new Polygon2D();

        ProductStore source = Enum.valueOf(ProductStore.class,
                commandLine.getOptionValue(Constants.PARAM_DOWNLOAD_STORE, ProductStore.SCIHUB.toString()));

        if (sensorType == SensorType.S2 && !commandLine.hasOption(Constants.PARAM_FLAG_SEARCH_AWS)
                && !commandLine.hasOption(Constants.PARAM_USER)) {
            throw new MissingOptionException("Missing SciHub credentials");
        }

        String user = commandLine.getOptionValue(Constants.PARAM_USER);
        String pwd = commandLine.getOptionValue(Constants.PARAM_PASSWORD);
        if (user != null && pwd != null && !user.isEmpty() && !pwd.isEmpty()) {
            String authToken = "Basic " + new String(Base64.getEncoder().encode((user + ":" + pwd).getBytes()));
            NetUtils.setAuthToken(authToken);
        }

        ProductDownloader downloader = sensorType.equals(SensorType.S2)
                ? new SentinelProductDownloader(source, commandLine.getOptionValue(Constants.PARAM_OUT_FOLDER),
                        props)
                : new LandsatProductDownloader(commandLine.getOptionValue(Constants.PARAM_OUT_FOLDER), props);

        TileMap tileMap = sensorType == SensorType.S2 ? SentinelTilesMap.getInstance()
                : LandsatTilesMap.getInstance();

        if (commandLine.hasOption(Constants.PARAM_AREA)) {
            String[] points = commandLine.getOptionValues(Constants.PARAM_AREA);
            for (String point : points) {
                areaOfInterest.append(Double.parseDouble(point.substring(0, point.indexOf(","))),
                        Double.parseDouble(point.substring(point.indexOf(",") + 1)));
            }
        } else if (commandLine.hasOption(Constants.PARAM_AREA_FILE)) {
            areaOfInterest = Polygon2D.fromWKT(new String(
                    Files.readAllBytes(Paths.get(commandLine.getOptionValue(Constants.PARAM_AREA_FILE))),
                    StandardCharsets.UTF_8));
        } else if (commandLine.hasOption(Constants.PARAM_TILE_SHAPE_FILE)) {
            String tileShapeFile = commandLine.getOptionValue(Constants.PARAM_TILE_SHAPE_FILE);
            if (Files.exists(Paths.get(tileShapeFile))) {
                logger.info(String.format("Reading %s tiles extents", sensorType));
                tileMap.fromKmlFile(tileShapeFile);
                logger.info(String.valueOf(tileMap.getCount() + " tiles found"));
            }
        } else {
            if (tileMap.getCount() == 0) {
                logger.info(String.format("Loading %s tiles extents", sensorType));
                tileMap.read(Executor.class.getResourceAsStream(sensorType + "tilemap.dat"));
                logger.info(String.valueOf(tileMap.getCount() + " tile extents loaded"));
            }
        }

        if (commandLine.hasOption(Constants.PARAM_TILE_LIST)) {
            Collections.addAll(tiles, commandLine.getOptionValues(Constants.PARAM_TILE_LIST));
        } else if (commandLine.hasOption(Constants.PARAM_TILE_LIST_FILE)) {
            tiles.addAll(
                    Files.readAllLines(Paths.get(commandLine.getOptionValue(Constants.PARAM_TILE_LIST_FILE))));
        }

        if (commandLine.hasOption(Constants.PARAM_PRODUCT_LIST)) {
            String[] uuids = commandLine.getOptionValues(Constants.PARAM_PRODUCT_UUID_LIST);
            String[] productNames = commandLine.getOptionValues(Constants.PARAM_PRODUCT_LIST);
            if (sensorType == SensorType.S2
                    && (!commandLine.hasOption(Constants.PARAM_DOWNLOAD_STORE) || ProductStore.SCIHUB.toString()
                            .equals(commandLine.getOptionValue(Constants.PARAM_DOWNLOAD_STORE)))
                    && (uuids == null || uuids.length != productNames.length)) {
                logger.error("For the list of product names a corresponding list of UUIDs has to be given!");
                return -1;
            }
            for (int i = 0; i < productNames.length; i++) {
                ProductDescriptor productDescriptor = sensorType == SensorType.S2
                        ? new SentinelProductDescriptor(productNames[i])
                        : new LandsatProductDescriptor(productNames[i]);
                if (uuids != null) {
                    productDescriptor.setId(uuids[i]);
                }
                products.add(productDescriptor);
            }
        } else if (commandLine.hasOption(Constants.PARAM_PRODUCT_LIST_FILE)) {
            for (String line : Files
                    .readAllLines(Paths.get(commandLine.getOptionValue(Constants.PARAM_PRODUCT_LIST_FILE)))) {
                products.add(sensorType == SensorType.S2 ? new SentinelProductDescriptor(line)
                        : new LandsatProductDescriptor(line));
            }
        }

        double clouds;
        if (commandLine.hasOption(Constants.PARAM_CLOUD_PERCENTAGE)) {
            clouds = Double.parseDouble(commandLine.getOptionValue(Constants.PARAM_CLOUD_PERCENTAGE));
        } else {
            clouds = Constants.DEFAULT_CLOUD_PERCENTAGE;
        }
        String sensingStart;
        if (commandLine.hasOption(Constants.PARAM_START_DATE)) {
            String dateString = commandLine.getOptionValue(Constants.PARAM_START_DATE);
            LocalDate startDate = LocalDate.parse(dateString, DateTimeFormatter.ISO_DATE);
            long days = ChronoUnit.DAYS.between(startDate, LocalDate.now());
            sensingStart = String.format(Constants.PATTERN_START_DATE, days);
        } else {
            sensingStart = Constants.DEFAULT_START_DATE;
        }

        String sensingEnd;
        if (commandLine.hasOption(Constants.PARAM_END_DATE)) {
            String dateString = commandLine.getOptionValue(Constants.PARAM_END_DATE);
            LocalDate endDate = LocalDate.parse(dateString, DateTimeFormatter.ISO_DATE);
            long days = ChronoUnit.DAYS.between(endDate, LocalDate.now());
            sensingEnd = String.format(Constants.PATTERN_START_DATE, days);
        } else {
            sensingEnd = Constants.DEFAULT_END_DATE;
        }

        int limit;
        if (commandLine.hasOption(Constants.PARAM_RESULTS_LIMIT)) {
            limit = Integer.parseInt(commandLine.getOptionValue(Constants.PARAM_RESULTS_LIMIT));
        } else {
            limit = Constants.DEFAULT_RESULTS_LIMIT;
        }

        if (commandLine.hasOption(Constants.PARAM_DOWNLOAD_STORE)) {
            String value = commandLine.getOptionValue(Constants.PARAM_DOWNLOAD_STORE);
            if (downloader instanceof SentinelProductDownloader) {
                ((SentinelProductDownloader) downloader)
                        .setDownloadStore(Enum.valueOf(ProductStore.class, value));
                logger.info("Products will be downloaded from %s", value);
            } else {
                logger.warn("Argument --store will be ignored for Landsat8");
            }
        }

        downloader.shouldCompress(commandLine.hasOption(Constants.PARAM_FLAG_COMPRESS));
        downloader.shouldDeleteAfterCompression(commandLine.hasOption(Constants.PARAM_FLAG_DELETE));
        if (commandLine.hasOption(Constants.PARAM_FILL_ANGLES)) {
            if (downloader instanceof SentinelProductDownloader) {
                ((SentinelProductDownloader) downloader)
                        .setFillMissingAnglesMethod(Enum.valueOf(FillAnglesMethod.class,
                                commandLine.hasOption(Constants.PARAM_FILL_ANGLES)
                                        ? commandLine.getOptionValue(Constants.PARAM_FILL_ANGLES).toUpperCase()
                                        : FillAnglesMethod.NONE.name()));
            } else {
                logger.warn("Argument --ma will be ignored for Landsat8");
            }
        }

        int numPoints = areaOfInterest.getNumPoints();
        tiles = tiles.stream().map(t -> t.startsWith("T") ? t.substring(1) : t).collect(Collectors.toSet());
        if (products.size() == 0 && numPoints == 0 && tileMap.getCount() > 0) {
            Rectangle2D rectangle2D = tileMap.boundingBox(tiles);
            areaOfInterest.append(rectangle2D.getX(), rectangle2D.getY());
            areaOfInterest.append(rectangle2D.getMaxX(), rectangle2D.getY());
            areaOfInterest.append(rectangle2D.getMaxX(), rectangle2D.getMaxY());
            areaOfInterest.append(rectangle2D.getX(), rectangle2D.getMaxY());
            areaOfInterest.append(rectangle2D.getX(), rectangle2D.getY());
        }

        numPoints = areaOfInterest.getNumPoints();
        if (products.size() == 0 && numPoints > 0) {
            String searchUrl;
            AbstractSearch searchProvider;
            logger.debug("No product provided, searching on the AOI");
            if (sensorType == SensorType.L8) {
                logger.debug("Search will be done for Landsat");
                searchUrl = props.getProperty(Constants.PROPERTY_NAME_LANDSAT_SEARCH_URL,
                        Constants.PROPERTY_NAME_DEFAULT_LANDSAT_SEARCH_URL);
                if (!NetUtils.isAvailable(searchUrl)) {
                    logger.warn(searchUrl + " is not available!");
                }
                searchProvider = new LandsatSearch(searchUrl);
                if (commandLine.hasOption(Constants.PARAM_START_DATE)) {
                    searchProvider.setSensingStart(commandLine.getOptionValue(Constants.PARAM_START_DATE));
                }
                if (commandLine.hasOption(Constants.PARAM_END_DATE)) {
                    searchProvider.setSensingEnd(commandLine.getOptionValue(Constants.PARAM_END_DATE));
                }
                if (commandLine.hasOption(Constants.PARAM_TILE_LIST)) {
                    searchProvider.setTiles(tiles);
                }
                ((LandsatSearch) searchProvider).limit(limit);
            } else if (!commandLine.hasOption(Constants.PARAM_FLAG_SEARCH_AWS)) {
                logger.debug("Search will be done on SciHub");
                searchUrl = props.getProperty(Constants.PROPERTY_NAME_SEARCH_URL,
                        Constants.PROPERTY_DEFAULT_SEARCH_URL);
                if (!NetUtils.isAvailable(searchUrl)) {
                    logger.warn(searchUrl + " is not available!");
                    searchUrl = props.getProperty(Constants.PROPERTY_NAME_SEARCH_URL_SECONDARY,
                            Constants.PROPERTY_DEFAULT_SEARCH_URL_SECONDARY);
                }
                searchProvider = new SciHubSearch(searchUrl);
                SciHubSearch search = (SciHubSearch) searchProvider;
                if (user != null && !user.isEmpty() && pwd != null && !pwd.isEmpty()) {
                    search = search.auth(user, pwd);
                }
                String interval = "[" + sensingStart + " TO " + sensingEnd + "]";
                search.filter(Constants.SEARCH_PARAM_INTERVAL, interval).limit(limit);
                if (commandLine.hasOption(Constants.PARAM_RELATIVE_ORBIT)) {
                    search.filter(Constants.SEARCH_PARAM_RELATIVE_ORBIT_NUMBER,
                            commandLine.getOptionValue(Constants.PARAM_RELATIVE_ORBIT));
                }
            } else {
                logger.debug("Search will be done on AWS");
                searchUrl = props.getProperty(Constants.PROPERTY_NAME_AWS_SEARCH_URL,
                        Constants.PROPERTY_DEFAULT_AWS_SEARCH_URL);
                searchProvider = new AmazonSearch(searchUrl);
                searchProvider.setTiles(tiles);
                Calendar calendar = Calendar.getInstance();
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
                calendar.add(Calendar.DAY_OF_MONTH,
                        Integer.parseInt(sensingStart.replace("NOW", "").replace("DAY", "")));
                searchProvider.setSensingStart(dateFormat.format(calendar.getTime()));
                calendar = Calendar.getInstance();
                String endOffset = sensingEnd.replace("NOW", "").replace("DAY", "");
                int offset = endOffset.isEmpty() ? 0 : Integer.parseInt(endOffset);
                calendar.add(Calendar.DAY_OF_MONTH, offset);
                searchProvider.setSensingEnd(dateFormat.format(calendar.getTime()));
                if (commandLine.hasOption(Constants.PARAM_RELATIVE_ORBIT)) {
                    searchProvider.setOrbit(
                            Integer.parseInt(commandLine.getOptionValue(Constants.PARAM_RELATIVE_ORBIT)));
                }
            }
            if (searchProvider.getTiles() == null || searchProvider.getTiles().size() == 0) {
                searchProvider.setAreaOfInterest(areaOfInterest);
            }
            searchProvider.setClouds(clouds);
            products = searchProvider.execute();
        } else {
            logger.debug("Product name(s) present, no additional search will be performed.");
        }
        if (downloader instanceof SentinelProductDownloader) {
            ((SentinelProductDownloader) downloader).setFilteredTiles(tiles,
                    commandLine.hasOption(Constants.PARAM_FLAG_UNPACKED));
        }
        downloader.setProgressListener(batchProgressListener);
        downloader.setFileProgressListener(fileProgressListener);
        retCode = downloader.downloadProducts(products);
    }
    return retCode;
}

From source file:com.t_oster.visicut.misc.Helper.java

/**
 * Returns a rectangle (parralel to x and y axis), which contains
 * the given rectangle after the given transform. If the transform
 * contains a rotation, the resulting rectangle is the smallest bounding-box
 * @param src//from ww  w  .  j a v a2 s .com
 * @param at
 * @return
 */
public static Rectangle2D transform(Rectangle2D src, AffineTransform at) {
    if (at == null) {
        return src;
    } else {
        java.awt.Point.Double[] points = new java.awt.Point.Double[4];
        points[0] = new java.awt.Point.Double(src.getX(), src.getY());
        points[1] = new java.awt.Point.Double(src.getX(), src.getY() + src.getHeight());
        points[2] = new java.awt.Point.Double(src.getX() + src.getWidth(), src.getY());
        points[3] = new java.awt.Point.Double(src.getX() + src.getWidth(), src.getY() + src.getHeight());
        for (int i = 0; i < 4; i++) {
            at.transform(points[i], points[i]);
        }
        return smallestBoundingBox(points);
    }
}

From source file:com.t_oster.visicut.misc.Helper.java

/**
 * Returns an AffineTransform, which transformes src to dest
 * and constists of a scale and translate component
 * @param src/*from   w ww . ja va  2 s  .  co  m*/
 * @param dest
 * @return
 */
public static AffineTransform getTransform(Rectangle2D src, Rectangle2D dest) {
    AffineTransform scale = AffineTransform.getScaleInstance(dest.getWidth() / src.getWidth(),
            dest.getHeight() / src.getHeight());
    Point2D scaled = scale.transform(new Point.Double(src.getX(), src.getY()), null);
    AffineTransform result = AffineTransform.getTranslateInstance(dest.getX() - scaled.getX(),
            dest.getY() - scaled.getY());
    result.concatenate(scale);
    return result;
}