Package jsky.coords

Examples of jsky.coords.CoordinateConverter


     * @param offset the index in the coords array of of the first value to convert
     * @param length the number of values to convert and include in the result
     * @return screen coordinate array of size "length"
     */
    protected double[] imageToScreenCoords(double[] coords, int offset, int length) {
        CoordinateConverter coordinateConverter = imageDisplay.getCoordinateConverter();
        double[] c = new double[length];
        Point2D.Double p = new Point2D.Double();

        for (int i = 0; i < length; i += 2) {
            p.x = coords[i + offset];
            p.y = coords[i + offset + 1];
            coordinateConverter.imageToScreenCoords(p, false);
            c[i] = p.x;
            c[i + 1] = p.y;
        }
        return c;
    }
View Full Code Here


     * @param coords an array x,y of coordinate pairs in screen coordinates
     * @param length the number of coordinate values to process (the rest are ignored)
     * @return a string containing the coordinates separated by spaces
     */
    protected String convertCoords(double[] coords, int length) {
        CoordinateConverter coordinateConverter = imageDisplay.getCoordinateConverter();
        Point2D.Double p = new Point2D.Double();
        for (int i = 0; i < length; i += 2) {
            p.x = coords[i];
            p.y = coords[i + 1];
            coordinateConverter.screenToImageCoords(p, false);
            coords[i] = p.x;
            coords[i + 1] = p.y;
        }

        // convert to Tcl list format
View Full Code Here

    /**
     * Return a Tcl formatted (space separated) list of two image coordinate values
     * for the given screen coordinate point.
     */
    protected String getCoords(Point2D.Double p) {
        CoordinateConverter coordinateConverter = imageDisplay.getCoordinateConverter();
        coordinateConverter.screenToImageCoords(p, false);
        return Double.toString(p.getX()) + " " + Double.toString(p.getY());
    }
View Full Code Here

     * @param lat
     * @param lonLevels
     * @param latLevels
     */
    private void calcCoords(double[][] lon, double[][] lat, List<Double> lonLevels, List<Double> latLevels) {
        CoordinateConverter converter = imageDisplay.getCoordinateConverter();
        Point2D.Double p;
        double plon, plat;
        Point2D size = getCanvasPane().getSize();
        int nx = lon[0].length;
        int ny = lon.length;
        int x, y;
        for (int iy = 0; iy < ny; iy++) {
            for (int ix = 0; ix < nx; ix++) {
                x = (int) size.getX() * ix / (nx - 1);
                y = (int) size.getY() * iy / (ny - 1);
                p = new Point2D.Double(x, y);
                converter.screenToWorldCoords(p, false);
                plon = p.getX();
                plat = p.getY();
                lon[iy][ix] = plon;
                lat[iy][ix] = plat;
            }
View Full Code Here

     *
     * @param g
     */
    private void drawRadial(Graphics g) {
        double levels[] = {0.0, 45, 90.0, 135, 180.0, 215, 270.0, 305};
        CoordinateConverter converter = imageDisplay.getCoordinateConverter();
        Point2D size = getCanvasPane().getSize();
        int nx = (int) size.getX();
        int ny = (int) size.getY();
        double lon[][] = new double[ny][nx];
        double lat[][] = new double[ny][nx];
        Point2D.Double p;
        for (int iy = 0; iy < ny; iy++) {
            for (int ix = 0; ix < nx; ix++) {
                p = new Point2D.Double(ix, iy);
                converter.screenToWorldCoords(p, false);
                lon[iy][ix] = p.x;
                lat[iy][ix] = p.y;
            }
        }

View Full Code Here

     */
    public void setSelectedArea(Rectangle2D r) {
        _selectedArea = r;
        if (_imageDisplay == null || r == null)
            return;
        CoordinateConverter wcs = _imageDisplay.getCoordinateConverter();
        if (!wcs.isWCS()) {
            //DialogUtil.error("The image does not support world coordinates.");
            return;
        }

        // get the center position
        Point2D.Double center = new Point2D.Double(r.getX() + r.getWidth() / 2.,
                                                   r.getY() + r.getHeight() / 2.);
        wcs.screenToWorldCoords(center, false);
        double equinox = wcs.getEquinox();
        WorldCoords centerPos = new WorldCoords(center, equinox);

        // get the radius in arcmin
        Point2D.Double p = new Point2D.Double(r.getX(), r.getY());
        wcs.screenToWorldCoords(p, false);
        WorldCoords origin = new WorldCoords(p, equinox);
        double radius = centerPos.dist(origin);

        // get the image width and height in arcmin
        Point2D.Double dims = new Point2D.Double(r.getWidth(), r.getHeight());
        wcs.screenToWorldCoords(dims, true);
        double width = dims.x * 60; // convert deg to arcmin
        double height = dims.y * 60;

        // set the values in the query panel
        CatalogQueryPanel catalogQueryPanel = getCatalogQueryPanel();
View Full Code Here

        _zoomWidth = (int) (w / zoomScale);


        if (_stats != null) {
            Point2D.Double p = new Point2D.Double(_stats.getImageX(), _stats.getImageY());
            CoordinateConverter cc = _mainImageDisplay.getCoordinateConverter();
            cc.imageToScreenCoords(p, false);
            _imageZoom.zoom((int) p.x, (int) p.y, true);
        }

        _updating = true;
        try {
View Full Code Here

        double dxY = Math.cos(rad) * y / 2.0;
        double dyY = Math.sin(rad) * y / 2.0;

        // compute end points for X-axis and convert them to canvas coordinates
        double xc = _stats.getImageX(), yc = _stats.getImageY();
        CoordinateConverter cc = imgDisp.getCoordinateConverter();
        Point2D.Double px1 = new Point2D.Double(xc + dxX, yc + dyX);
        Point2D.Double px2 = new Point2D.Double(xc - dxX, yc - dyX);
        cc.imageToScreenCoords(px1, false);
        cc.imageToScreenCoords(px2, false);

        // the Y-axis is rotated "by hand" so that it appears perpendicular to the X-axis
        Point2D.Double py1 = new Point2D.Double(xc + dyY, yc - dxY);
        Point2D.Double py2 = new Point2D.Double(xc - dyY, yc + dxY);
        cc.imageToScreenCoords(py1, false);
        cc.imageToScreenCoords(py2, false);

        // draw X and Y axis lines with an outer thick black line
        // and inner thin white line
        Line2D.Double lx = new Line2D.Double(px1, px2);
        Line2D.Double ly = new Line2D.Double(py1, py2);
View Full Code Here

        }

        _rect = _mainImageDisplay.getVisibleArea();
        Point2D.Double p = new Point2D.Double(_rect.getX(), _rect.getY());
        Point2D.Double d = new Point2D.Double(_rect.getWidth(), _rect.getHeight());
        CoordinateConverter cc = _imageDisplay.getCoordinateConverter();
        cc.userToScreenCoords(p, false);
        cc.userToScreenCoords(d, true);
        _rect.setRect(p.getX(), p.getY(), d.getX(), d.getY());
    }
View Full Code Here

        _north.y = center.y + sizeInDeg;
        if (_north.y >= 90.)
            _north.y = 180. - _north.y;

        CoordinateConverter cc = _imageDisplay.getCoordinateConverter();
        cc.worldToScreenCoords(center, false);
        cc.worldToScreenCoords(_north, false);
        cc.worldToScreenCoords(_east, false);

        GeneralPath path = new GeneralPath();
        ShapeUtil.addArrowLine(path, center, _north);
        ShapeUtil.addArrowLine(path, center, _east);
        _compass = path;
View Full Code Here

TOP

Related Classes of jsky.coords.CoordinateConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.