Examples of Projection


Examples of com.bbn.openmap.proj.Projection

        super(layer);
    }

    public void paint(Graphics g) {
        if (layer != null && layer.isProjectionOK(layer.getProjection())) {
            Projection proj = layer.getProjection();
            // The proj shouldn't be null, because isProjectionOK
            // checks for that, but that method may be overridden
            if (proj != null) {
                g.setClip(0, 0, proj.getWidth(), proj.getHeight());
            }
        }
        super.paint(g);
    }
View Full Code Here

Examples of com.bbn.openmap.proj.Projection

        OMText currentText;

        // For calculating text locations
        java.awt.Point point;
        LatLonPoint llpoint;
        Projection projection = getProjection();

        if (doLats) {

            // generate other parallels of latitude be creating series
            // of labels
            for (int i = south; i < north; i += stepSize) {
                float lat = (float) i;

                if ((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(), (int) 2, (int) -2, // Move
                            // them
                            // up a
                            // little
                            Integer.toString((int) lat), font, OMText.JUSTIFY_LEFT);
                    currentText.setLinePaint(textColor);
                    labels.addOMGraphic(currentText);
                }
            }
        }

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

            if ((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

Examples of com.bbn.openmap.proj.Projection

     * @param projEvent the ProjectionEvent from the 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

Examples of com.bbn.openmap.proj.Projection

        if (!(obj instanceof MapBean) || point1 == null)
            return;
       
        MapBean map = (MapBean) obj;
        Projection projection = map.getProjection();
        Proj p = (Proj) projection;
       
        LatLonPoint llp = projection.inverse(e.getPoint());
       
        boolean shift = e.isShiftDown();
        boolean control = e.isControlDown();

        if (control) {
View Full Code Here

Examples of com.bbn.openmap.proj.Projection

        if (!(obj instanceof MapBean) || !autoZoom || point1 == null
                || point2 == null)
            return;

        MapBean map = (MapBean) obj;
        Projection projection = map.getProjection();
        Proj p = (Proj) projection;

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

            // Don't 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());

                    boolean shift = e.isShiftDown();
                    boolean control = e.isControlDown();

                    if (control) {
                        if (shift) {
                            p.setScale(p.getScale() * 2.0f);
                        } else {
                            p.setScale(p.getScale() / 2.0f);
                        }
                    }

                    // reset the points here so the point doesn't get
                    // rendered on the repaint.
                    point1 = null;
                    point2 = null;

                    p.setCenter(llp);
                    map.setProjection(p);
                }
                return;
            }

            // Figure out the new scale
            float newScale = com.bbn.openmap.proj.ProjMath.getScale(point1,
                    point2,
                    projection);

            // Figure out the center of the rectangle
            int centerx = Math.min(point1.x, point2.x) + dx / 2;
            int centery = Math.min(point1.y, point2.y) + dy / 2;
            com.bbn.openmap.LatLonPoint center = projection.inverse(centerx,
                    centery);

            // Fire events on main map to change view to match rect1
            // Debug.output("point1: " +point1);
            // Debug.output("point2: " +point2);
View Full Code Here

Examples of com.bbn.openmap.proj.Projection

     * Given a MapBean, which provides the projection, and the starting point of
     * a box (pt1), look at pt2 to see if it represents the ratio of the
     * projection map size. If it doesn't, provide a point that does.
     */
    protected Point getRatioPoint(MapBean map, Point pt1, Point pt2) {
        Projection proj = map.getProjection();
        float mapRatio = (float) proj.getHeight() / (float) proj.getWidth();

        float boxHeight = (float) (pt1.y - pt2.y);
        float boxWidth = (float) (pt1.x - pt2.x);
        float boxRatio = Math.abs(boxHeight / boxWidth);
        int isNegative = -1;
View Full Code Here

Examples of com.bbn.openmap.proj.Projection

            tp.drawBackground((Graphics2D) graphics, map.getBckgrnd());

            if (layers != null) {
                for (int i = layers.length - 1; i >= 0; i--) {
                    Projection oldProj = layers[i].getProjection();
                    layers[i].renderDataForProjection(tp, graphics);
                    if (Debug.debugging("formatter")) {
                        Debug.output("AbstractImageFormatter: rendering "
                                + layers[i].getName());
                    }
                    // Need to set the old Projection object on the
                    // Layer, not the current MapBean Proj object. If
                    // you set the MapBean Proj object, make sure you
                    // clone it first. The Layer will do a check on
                    // the Projection object it has against any new
                    // ones it receives. If it has the original from
                    // the MapBean, the check it does will return a
                    // false negative, and the layer will think it
                    // doesn't have to do anything.

                    if (oldProj != null && oldProj == map.getProjection()) {
                        // Seems like a lot of users are getting
                        // burned by manually setting the same
                        // projection on the MapBean as they are on
                        // the layers, and the layers are freezing up
                        // after they are used to create an image.

                        // I don't see how this problem is manifesting
                        // itself, but this code section is an attempt
                        // to help.
                        oldProj = oldProj.makeClone();
                    }

                    layers[i].setProjection(oldProj);
                }
View Full Code Here

Examples of com.bbn.openmap.proj.Projection

            this.addActionListener(this);
        }

        public void actionPerformed(ActionEvent ae) {
            if (map != null) {
                Projection proj = map.getProjection();
                LatLonPoint llp = proj.getCenter();
                new GoToButton(llp.getLatitude(), llp.getLongitude(), proj.getScale(), proj.getName());
            }
        }
View Full Code Here

Examples of com.bbn.openmap.proj.Projection

            GoToMenu.this.addView(this);
        }

        public void actionPerformed(ActionEvent ae) {
            if (map != null) {
                Projection oldProj = map.getProjection();
                Class projClass = ProjectionFactory.getProjClassForName(projectionID);

                if (projClass == null) {
                    projClass = com.bbn.openmap.proj.Mercator.class;
                }

                Projection newProj = ProjectionFactory.makeProjection(projClass,
                        latitude,
                        longitude,
                        scale,
                        oldProj.getWidth(),
                        oldProj.getHeight());
View Full Code Here

Examples of com.bbn.openmap.proj.Projection

            Debug.message("dted", getName()
                    + "|TerrainLayer.prepare(): aborted.");
            return null;
        }

        Projection projection = getProjection();

        if (projection == null) {
            System.err.println("Terrain Layer needs to be added to the MapBean before it can be used!");
            return new OMGraphicList();
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.