Package com.bbn.openmap.proj

Examples of com.bbn.openmap.proj.Projection


        // extract the projection and check to see if it's really
        // different.
        // if it isn't then we don't need to do all the work again,
        // just
        // repaint.
        Projection proj = setProjection(e);
        if (proj == null) {
            repaint();
            return;
        }
View Full Code Here


     */
    protected OMGraphicList constructGraticuleLines() {

        OMGraphicList newgraphics = new OMGraphicList(20);
        // Lets figure out which lines should be painted...
        Projection projection = getProjection();

        if (projection == null) {
            return newgraphics;
        }
        tenDegreeLines = null;

        if (showOneAndFiveLines || showRuler || showBelowOneLines) {

            float left = projection.getUpperLeft().getLongitude();
            float right = projection.getLowerRight().getLongitude();
            float up = projection.getUpperLeft().getLatitude();
            float down = projection.getLowerRight().getLatitude();

            if (up > 80.0f)
                up = 80.0f;
            if (down > 80.0f)
                down = 80f; // unlikely
View Full Code Here

        // For calculating text locations
        java.awt.Point point;
        LatLonPoint llpoint;

        Projection projection = getProjection();

        // generate other parallels of latitude be creating series
        // of polylines
        for (int i = south; i < north; i += stepSize) {
            float lat = (float) i;
            // generate parallel of latitude North/South of the
            // equator
            if (west < 0 && east > 0) {
                llp = new float[6];
                llp[2] = lat;
                llp[3] = 0f;
                llp[4] = lat;
                llp[5] = east;
            } else {
                llp = new float[4];
                llp[2] = lat;
                llp[3] = east;
            }
            llp[0] = lat;
            llp[1] = west;

            // Do not duplicate the 10 degree line.
            if ((lat % 10) != 0) {
                currentLine = new OMPoly(llp, OMGraphic.DECIMAL_DEGREES, boxy ? OMGraphic.LINETYPE_STRAIGHT
                        : OMGraphic.LINETYPE_RHUMB);
                if ((lat % 5) == 0) {
                    currentLine.setLinePaint(fiveDegreeColor);
                } else {
                    currentLine.setLinePaint(oneDegreeColor);
                }
                lines.addOMGraphic(currentLine);
            }

            if (showRuler && (lat % 2) == 0) {
                if (boxy) {
                    point = projection.forward(lat, west);
                    point.x = 0;
                    llpoint = projection.inverse(point);
                } else {
                    llpoint = new LatLonPoint(lat, west);
                    while (projection.forward(llpoint).x < 0) {
                        llpoint.setLongitude(llpoint.getLongitude() + stepSize);
                    }
                }

                currentText = new OMText(llpoint.getLatitude(), llpoint.getLongitude(),
                // Move them up a little
                        (int) 2, (int) -2, Integer.toString((int) lat), font, OMText.JUSTIFY_LEFT);
                currentText.setLinePaint(textColor);
                lines.addOMGraphic(currentText);
            }
        }

        // generate lines of longitude
        for (int i = west; i < east; i += stepSize) {
            float lon = (float) i;

            if (north < 0 && south > 0) {
                llp = new float[6];
                llp[2] = 0f;
                llp[3] = lon;
                llp[4] = south;
                llp[5] = lon;
            } else {
                llp = new float[4];
                llp[2] = south;
                llp[3] = lon;
            }
            llp[0] = north;
            llp[1] = lon;

            if ((lon % 10) != 0) {
                currentLine = new OMPoly(llp, OMGraphic.DECIMAL_DEGREES, boxy ? OMGraphic.LINETYPE_STRAIGHT
                        : OMGraphic.LINETYPE_GREATCIRCLE);
                if ((lon % 5) == 0) {
                    currentLine.setLinePaint(fiveDegreeColor);
                } else {
                    currentLine.setLinePaint(oneDegreeColor);
                }
                lines.addOMGraphic(currentLine);
            }

            if (showRuler && (lon % 2) == 0) {
                if (boxy) {
                    point = projection.forward(south, lon);
                    point.y = projection.getHeight();
                    llpoint = projection.inverse(point);
                } else {
                    llpoint = new LatLonPoint(south, lon);
                    while (projection.forward(llpoint).y > projection.getHeight()) {
                        llpoint.setLatitude(llpoint.getLatitude() + stepSize);
                    }
                }

                currentText = new OMText(llpoint.getLatitude(), llpoint.getLongitude(),
View Full Code Here

     *        ProjectionListener method.
     * @return The new Projection if it is different from the one we
     *         already have, null if is the same as the current one.
     */
    public Projection setProjection(ProjectionEvent projEvent) {
        Projection newProjection = projEvent.getProjection();

        if (!newProjection.equals(getProjection())) {
            Projection clone = newProjection.makeClone();
            setProjection(clone);
            return clone;
        } else {
            return null;
        }
View Full Code Here

        // OMGraphicList is made up of OMGraphics, which are generated
        // (projected) when the graphics are added to the list. So,
        // after this call, the list is ready for painting.

        // call getRectangle();
        Projection proj = getProjection();
        if (Debug.debugging("plugin") && proj != null) {
            System.out.println(getName() + "|PlugInLayer.prepare(): "
                    + "calling getRectangle " + " with projection: " + proj
                    + " ul = " + proj.getUpperLeft() + " lr = "
                    + proj.getLowerRight());
        }

        OMGraphicList omGraphicList = null;

        if (plugin != null && proj != null) {
View Full Code Here

                        squareCenterY = (int)(squareUpperLeftY + squareHeight/2);
                    }else if(squareUpperLeftY + squareHeight >= theMap.getHeight()){
                        squareUpperLeftY = (int)(theMap.getHeight() - squareHeight - 1);
                        squareCenterY = (int)(squareUpperLeftY + squareHeight/2);
                    }
                    Projection proj = theMap.getProjection();
                    LatLonPoint upperLeft = proj.inverse(squareUpperLeftX,
                            squareUpperLeftY);
                    LatLonPoint lowerRight = proj.inverse(squareUpperLeftX + (int)squareWidth,
                            squareUpperLeftY + (int)squareHeight);
                    LatLonPoint center = proj.inverse(squareCenterX, squareCenterY);
                    double necessaryScale = proj.getScale(upperLeft, lowerRight,
                            proj.forward(upperLeft),
                            proj.forward(lowerRight));
                    final Projection newProj = ProjectionFactory.makeProjection(Mercator.class,
                            (float) center.getLatitude(),
                            (float) center.getLongitude(),
                            (float) necessaryScale,
                            theMap.getWidth(),
                            theMap.getHeight());
View Full Code Here

        if (isCancelled()) {
            Debug.message("link", getName() + "|LinkLayer.prepare(): aborted.");
            return currentList;
        }

        Projection projection = getProjection();
        if (projection == null) {
            Debug.error("Link Layer needs to be added to the MapBean before it can get graphics!");
            return currentList;
        } else if (currentList != null) {
            // If the list isn't empty, it isn't being cleared when a
            // new projection is received, as dictated by the policy
            // of the layer. Should regenerate it here. If it's
            // understood that a new list will be sent by the server,
            // then a different ProjectionChangePolicy should be used.
            currentList.generate(projection);
        }

        Debug.message("basic", getName() + "|LinkLayer.prepare(): doing it");

        // Setting the OMGraphicsList for this layer. Remember, the
        // LinkOMGraphicList is made up of OMGraphics, which are
        // generated
        // (projected) when the graphics are added to the list. So,
        // after this call, the list is ready for painting.

        // call getRectangle();
        if (Debug.debugging("link")) {
            System.out.println(getName() + "|LinkLayer.prepare(): "
                    + "calling getRectangle " + " with projection: "
                    + projection + " ul = " + projection.getUpperLeft()
                    + " lr = " + projection.getLowerRight());
        }

        // LinkOMGraphicList omGraphicList;

        // //////////// Call getRectangle for server....
View Full Code Here

            // Deal with all the messaging....
            handleMessages(lgl.getProperties());
            LinkOMGraphicList lomgl = lgl.getGraphics();
            setGraphicList(lomgl);
            // Do we need to regenerate?
            Projection proj = getProjection();
            if (lomgl.getNeedToRegenerate(proj)) {
                // set to false in LinkGraphicList.readGraphics if the
                // projection was there when the LinkGraphicList was
                // created. If it wasn't there, we need to try to
                // project them before calling repaint(). Projection
View Full Code Here

        Vector updates = lal.getGraphicUpdates();
        Enumeration items = updates.elements();
        boolean needRepaint = false;
        LinkOMGraphicList graphics = getGraphicList();

        Projection proj = getProjection();

        if (graphics == null) {
            Debug.message("link",
                    "LinkLayer.handleLinkActionList: null LinkOMGraphicList, making new one...");
            // Why ignore what the server has to say, set the new
View Full Code Here

        Object obj = e.getSource();
        if (!mouseSupport.fireMapMouseReleased(e)) {
            if (!(obj instanceof MapBean) || !autoZoom || point1 == null)
                return;
            MapBean map = (MapBean) obj;
            Projection projection = map.getProjection();

            synchronized (this) {
                point2 = e.getPoint();
                int dx = Math.abs(point2.x - point1.x);
                int dy = Math.abs(point2.y - point1.y);

                // Dont bother redrawing if the rectangle is too small
                if ((dx < 5) || (dy < 5)) {
                    // clean up the rectangle, since point2 has the
                    // old value.
                    paintRectangle(map, point1, point2);

                    // If rectangle is too small in both x and y then
                    // recenter the map
                    if ((dx < 5) && (dy < 5)) {
                        LatLonPoint llp = projection.inverse(e.getPoint());
                        overviewMapHandler.getControlledMapListeners()
                                .setCenter(llp);
                    }
                    return;
                }

                // Figure out the new scale
                com.bbn.openmap.LatLonPoint ll1 = projection.inverse(point1);
                com.bbn.openmap.LatLonPoint ll2 = projection.inverse(point2);

                float deltaDegrees;
                int deltaPix;
                dx = Math.abs(point2.x - point1.x);
                dy = Math.abs(point2.y - point1.y);

                if (dx < dy) {
                    float dlat = Math.abs(ll1.getLatitude() - ll2.getLatitude());
                    deltaDegrees = dlat * 2;
                    deltaPix = overviewMapHandler.getSourceMap()
                            .getProjection()
                            .getHeight();
                } else {
                    float dlon;
                    float lat1, lon1, lon2;

                    // point1 is to the right of point2. switch the
                    // LatLonPoints so that ll1 is west (left) of ll2.
                    if (point1.x > point2.x) {
                        lat1 = ll1.getLatitude();
                        lon1 = ll1.getLongitude();
                        ll1.setLatLon(ll2);
                        ll2.setLatLon(lat1, lon1);
                    }

                    lon1 = ll1.getLongitude();
                    lon2 = ll2.getLongitude();

                    // allow for crossing dateline
                    if (lon1 > lon2) {
                        dlon = (180 - lon1) + (180 + lon2);
                    } else {
                        dlon = lon2 - lon1;
                    }

                    deltaDegrees = dlon * 2;
                    deltaPix = overviewMapHandler.getSourceMap()
                            .getProjection()
                            .getWidth();
                }

                float pixPerDegree = ((Proj) projection).getPlanetPixelCircumference() / 360;
                float newScale = pixPerDegree / (deltaPix / deltaDegrees);

                // Figure out the center of the rectangle
                com.bbn.openmap.LatLonPoint center = projection.inverse(point1.x,
                        point1.y);

                // Set the parameters of the projection and then set
                // the projection of the map. This way we save having
                // the MapBean fire two ProjectionEvents.
View Full Code Here

TOP

Related Classes of com.bbn.openmap.proj.Projection

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.