Package com.bbn.openmap.omGraphics

Examples of com.bbn.openmap.omGraphics.OMGraphicList


     * @param utm the UTMPoint of the center of the area to create lines for.
     */
    protected OMGraphicList createEquiDistanceLines(UTMPoint utm,
                                                    int gridLineInterval) {

        OMGraphicList list = new OMGraphicList();

        // Used to calculate the endpoints of the horizontal lines.
        UTMPoint utm1 = new UTMPoint(utm);
        UTMPoint utm2 = new UTMPoint(utm);
        LatLonPoint point1 = new LatLonPoint();
        LatLonPoint point2 = new LatLonPoint();

        // Used to calculate the pieces of the vertical lines.
        UTMPoint utmp = new UTMPoint(utm);
        LatLonPoint llp = new LatLonPoint();

        int i;
        OMLine line;
        BasicGeometry poly;

        float lat2;
        int endNorthing = (int) Math.floor(utm.northing / INTERVAL_100K) + 10;
        int startNorthing = (int) Math.floor(utm.northing / INTERVAL_100K) - 10;

        int numVertLines = 9;
        int numHorLines = endNorthing - startNorthing;

        float[][] vertPoints = new float[numVertLines][numHorLines * 2];

        if (UTM_DEBUG_VERBOSE) {
            Debug.output("Array is [" + vertPoints.length + "]["
                    + vertPoints[0].length + "]");
        }

        int coordCount = 0;
        boolean doPolys = true;

        utm1.easting = INTERVAL_100K;
        utm2.easting = 9 * INTERVAL_100K;

        // Horizontal lines
        for (i = startNorthing; i < endNorthing; i++) {
            utm1.northing = (float) i * gridLineInterval;
            utm2.northing = utm1.northing;
            utmp.northing = utm1.northing;

            if (doPolys) {
                for (int j = 0; j < numVertLines; j++) {
                    utmp.easting = (float) (j + 1) * gridLineInterval;
                    llp = utmp.toLatLonPoint(Ellipsoid.WGS_84, llp);

                    vertPoints[j][coordCount] = llp.getLatitude();
                    vertPoints[j][coordCount + 1] = llp.getLongitude();

                    if (UTM_DEBUG_VERBOSE) {
                        Debug.output("for vline " + j + ", point " + i
                                + ", easting: " + utmp.easting + ", northing: "
                                + utmp.northing + ", lat:"
                                + vertPoints[j][coordCount] + ", lon:"
                                + vertPoints[j][coordCount + 1]);
                    }
                }
                coordCount += 2;
            }

            point1 = utm1.toLatLonPoint(Ellipsoid.WGS_84, point1);
            point2 = utm2.toLatLonPoint(Ellipsoid.WGS_84, point2);

            lat2 = point1.getLatitude();

            if (lat2 < 84f) {
                line = new OMLine(point1.getLatitude(), point1.getLongitude(), point2.getLatitude(), point2.getLongitude(), OMGraphic.LINETYPE_GREATCIRCLE);
                line.setLinePaint(distanceGridPaint);
                list.add(line);
            }
        }

        if (doPolys) {
            OMGeometryList polys = new OMGeometryList();
            for (i = 0; i < vertPoints.length; i++) {
                if (UTM_DEBUG_VERBOSE) {
                    for (int k = 0; k < vertPoints[i].length; k += 2) {
                        System.out.println(" for poly " + i + ": lat = "
                                + vertPoints[i][k] + ", lon = "
                                + vertPoints[i][k + 1]);
                    }
                }
                poly = new PolylineGeometry.LL(vertPoints[i], OMGraphic.DECIMAL_DEGREES, OMGraphic.LINETYPE_GREATCIRCLE);
                polys.add(poly);
            }
            polys.setLinePaint(distanceGridPaint);
            list.add(polys);
        } else {

            // This doesn't seem to calculate the right
            // lines, although it looks like it should.

            if (UTM_DEBUG) {
                Debug.output("Doing vertical lines");
            }

            utm1.northing = startNorthing;
            utm2.northing = endNorthing;

            // Vertical lines
            for (i = 1; i <= 9; i++) {
                utm1.easting = i * 100000f;
                utm2.easting = i * 100000f;

                point1 = utm1.toLatLonPoint(Ellipsoid.WGS_84, point1);
                point2 = utm2.toLatLonPoint(Ellipsoid.WGS_84, point2);

                line = new OMLine(point1.getLatitude(), point1.getLongitude(), point2.getLatitude(), point2.getLongitude(), OMGraphic.LINETYPE_GREATCIRCLE);
                line.setLinePaint(distanceGridPaint);
                list.add(line);
            }
        }

        return list;
    }
View Full Code Here


     * @param p projection of the screen, holding scale, center coords, height,
     *        width.
     */
    public OMGraphicList getRectangle(Projection p) {

        OMGraphicList list = getList();

        if (verticalList == null) {
            verticalList = createUTMZoneVerticalLines();
            horizontalList = createUTMZoneHorizontalLines();
            if (labelsAsMGRS) {
                labelTree = createMGRSZoneLabels();
            } else {
                labelTree = createUTMZoneLabels();
            }
        }

        list.clear();

        if (showZones) {
            list.add(verticalList);
            list.add(horizontalList);
        }

        LatLonPoint center = p.getCenter();
        UTMPoint utm = new UTMPoint(center);

        if (show100kGrid) {
            Debug.message("utmgrid", "Creating 100k distance lines...");

            OMGraphicList hunKLines = createEquiDistanceLines(utm, 100000);
            list.add(hunKLines);
        }

        if (distanceGridResolution > 0) {
            Debug.message("utmgrid", "Creating distance lines...");

            float decisionAid = 100000f / (float) Math.pow(10,
                    distanceGridResolution);
            float dglc = 30f * decisionAid; // distance grid label
            // cutoff
            // Debug.output("Basing decision to display labels on " +
            // dglc);

            int numberBasedForScale = (int) (p.getScale() / (2 * decisionAid));
            if (numberBasedForScale > 10) {
                numberBasedForScale = 10;
            }
            // Debug.output(numberBasedForScale + "");

            OMGeometryList geoList = createMGRSRectangles(center,
                    distanceGridResolution,
                    numberBasedForScale);

            if (showLabels && p.getScale() <= dglc) {
                Debug.message("utmgrid",
                        "Creating labels for distance lines ...");

                OMGraphicList textList = new OMGraphicList();
                LatLonPoint llp = new LatLonPoint();
                Point point = new Point();
                Iterator it = geoList.iterator();
                while (it.hasNext()) {
                    PolygonGeometry.LL pll = (PolygonGeometry.LL) it.next();
                    String labelString = (String) (pll).getAppObject();
                    if (labelString == null) {
                        continue;
                    }
                    float[] ll = pll.getLatLonArray();
                    llp.setLatLon(ll[0], ll[1], true);

                    p.forward(llp, point);

                    double x = point.getX();
                    double y = point.getY();
                    int buffer = 20;

                    // Lame attempt of testing whether the label is
                    // on-screen
                    if ((x > -buffer || x < p.getWidth() + buffer)
                            && (y > -buffer || y < p.getHeight() + buffer)) {

                        OMText label = new OMText(llp.getLatitude(), llp.getLongitude(), 4, -4, labelString, OMText.JUSTIFY_LEFT);
                        label.setLinePaint(distanceGridPaint);
                        textList.add(label);
                    }
                }
                list.add(textList);
            }

            geoList.setLinePaint(distanceGridPaint);
            list.add(geoList);
        }

        if (labelList != null) {
            labelList.clear();
        } else {
            labelList = new OMGraphicList();
        }

        if (showLabels && p.getScale() <= labelCutoffScale) {
            Debug.message("utmgrid", "Creating labels for map...");
            LatLonPoint ul = p.getUpperLeft();
View Full Code Here

     * OMGraphicList is not null, then it is reprojected and redrawn.
     *
     * @return OMGraphicList of images and text.
     */
    public OMGraphicList prepare() {
        OMGraphicList oldList = getGraphicList();
        if (oldList != null) {
            oldList.generate(getProjection());
            if (getCoverage() != null) {
                getCoverage().generate(getProjection());
            }
            repaint();
        }
View Full Code Here

        } else
            Debug.message("basic",
                    getName()
                            + "|DTEDCoverageLayer.prepare(): finished with null graphics list");

        OMGraphicList mainList = new OMGraphicList();

        // Don't forget to project them. Since they are only being
        // recalled if the projection hase changed, then we need to
        // force a reprojection of all of them because the screen
        // position has changed.
        for (int k = 0; k < omGraphicLists.length; k++) {
            omGraphicLists[k].project(projection, true);
            mainList.add(omGraphicLists[k]);
        }

        return mainList;
    }
View Full Code Here

        // This layer uses the StandardPCPolicy for new
        // projections, which keeps the list intact and simply calls
        // generate() on it with the new projection, and repaint()
        // which calls paint().

        OMGraphicList omList = new OMGraphicList();

        // Location loc = new
        // URLRasterLocation(42.3583f,-71.06f,"Boston,Massachusetts,USA","http://javamap.bbn.com:4711/appletimages/city.gif");
        // //loc.setLocationColor(Color.blue);
        // loc.setShowLocation(true);
        // loc.setShowName(true);
        // //loc.setDetails("Details");
        // omList.add(loc);

        int bytearrsize = (16 * 16) / 8;
        byte[] bytearr = new byte[bytearrsize];

        for (int i = 0; i < bytearr.length; i++) {
            bytearr[i] = (byte) 0xffffffff;
        }

        OMBitmap omb = new OMBitmap(45.3583f, -71.06f, 16, 16, bytearr);
        omb.setLinePaint(Color.red);
        omb.setFillPaint(null);
        omb.setSelectPaint(Color.blue);
        omb.setRotationAngle(Math.PI / 2);
        omList.add(omb);

        OMPoint point = new OMPoint(42f, -72f, 14);
        point.setFillPaint(Color.green);
        point.setOval(true);
        omList.add(point);

        OMCircle circle = new OMCircle(40f, -70f, 50, 200);
        circle.setRotationAngle(com.bbn.openmap.MoreMath.HALF_PI / 2f);
        circle.putAttribute(OMGraphicConstants.LABEL,
                new OMTextLabeler("Circle Label", OMText.JUSTIFY_CENTER));
        omList.add(circle);

        int[] llPointsx = new int[5];
        int[] llPointsy = new int[5];
        llPointsy[0] = 10;
        llPointsx[0] = 170;
        llPointsy[1] = 42;
        llPointsx[1] = 273;
        llPointsy[2] = 38;
        llPointsx[2] = 374;
        llPointsy[3] = 78;
        llPointsx[3] = 468;
        llPointsy[4] = 84;
        llPointsx[4] = 369;

        LabeledOMSpline spline = new LabeledOMSpline(40f, -72, llPointsx, llPointsy, OMPoly.COORDMODE_ORIGIN);
        spline.setText("Testing");
        spline.setLocateAtCenter(true);
        // spline.setIndex(2);
        omList.add(spline);

        OMSpline spline2 = new OMSpline(llPointsx, llPointsy);
        spline2.putAttribute(OMGraphicConstants.LABEL,
                new OMTextLabeler("Spline Label"));
        spline2.setLinePaint(Color.green);
        omList.add(spline2);

        float[] llPoints = { 55.0f, -10.0f, 50.0f, -5.0f, 45.0f, -7.0f, 43.0f,
                -12.0f, 55.0f, -10.0f };
        OMDecoratedSpline omds = new OMDecoratedSpline(llPoints, OMSpline.DECIMAL_DEGREES, OMSpline.LINETYPE_STRAIGHT);
        ShapeDecorator sd = new ShapeDecorator();
        sd.addDecoration(new LineShapeDecoration(5, com.bbn.openmap.omGraphics.OMColor.clear));
        sd.addDecoration(new IceAreaShapeDecoration(7, 7, IceAreaShapeDecoration.RIGHT));
        omds.setDecorator(sd);
        omList.add(omds);

        llPoints = new float[] { 56.0f, -11.0f, 51.0f, -6.0f, 46.0f, -8.0f,
                44.0f, -13.0f, 56.0f, -11.0f };
        omds = new OMDecoratedSpline(llPoints, OMSpline.DECIMAL_DEGREES, OMSpline.LINETYPE_STRAIGHT);
        sd = new ShapeDecorator();
        sd.addDecoration(new LineShapeDecoration(3, com.bbn.openmap.omGraphics.OMColor.clear));
        sd.addDecoration(new CircleShapeDecoration(5, 5, Color.blue));
        omds.setDecorator(sd);
        omList.add(omds);

        llPoints = new float[] { 57.0f, -12.0f, 52.0f, -7.0f, 47.0f, -9.0f,
                45.0f, -14.0f, 57.0f, -12.0f };
        omds = new OMDecoratedSpline(llPoints, OMSpline.DECIMAL_DEGREES, OMSpline.LINETYPE_STRAIGHT);
        sd = new ShapeDecorator();
        sd.addDecoration(new LineShapeDecoration(2, com.bbn.openmap.omGraphics.OMColor.clear));
        sd.addDecoration(new CircleShapeDecoration(5, 5, Color.red));
        sd.addDecoration(new LineShapeDecoration(2, com.bbn.openmap.omGraphics.OMColor.clear));
        sd.addDecoration(new LineShapeDecoration(15, Color.red));
        omds.setDecorator(sd);
        omList.add(omds);

        float[] llPoints2 = { 55.0f, -12.0f, 50.0f, -7.0f, 45.0f, -9.0f, 43.0f,
                -14.0f };
        OMHotSurfaceFront hf = new OMHotSurfaceFront(llPoints2, OMSpline.DECIMAL_DEGREES, OMSpline.LINETYPE_STRAIGHT);
        omList.add(hf);
        float[] llPoints3 = { 55.0f, -14.0f, 50.0f, -9.0f, 45.0f, -11.0f,
                43.0f, -16.0f };
        OMOcclusion oc = new OMOcclusion(llPoints3, OMSpline.DECIMAL_DEGREES, OMSpline.LINETYPE_STRAIGHT);
        omList.add(oc);

        // float[] llPoints4 = { 55.0f, -16.0f, 50.0f, -11.0f, 45.0f,
        // -13.0f,
        // 43.0f, -18.0f };
        // OMSpline spline3 = new OMDecoratedSpline(llPoints4,
        // OMSpline.DECIMAL_DEGREES, OMSpline.LINETYPE_STRAIGHT) {
        // protected void initDecorations() {
        //
        // getDecorator().addDecoration(new TextShapeDecoration(" This
        // one has a text ", new Font("arial", Font.PLAIN, 10),
        // TextShapeDecoration.LEFT_TO_RIGHT
        // + TextShapeDecoration.FOLLOW_POLY,
        // TextShapeDecoration.CENTER));
        // }
        // };
        // omList.add(spline3);

        OMLine line = new OMLine(40f, -75f, 42f, -70f, OMGraphic.LINETYPE_GREATCIRCLE);
        // line.addArrowHead(true);
        line.addArrowHead(OMArrowHead.ARROWHEAD_DIRECTION_BOTH);
        line.setStroke(new BasicStroke(2));
        line.putAttribute(OMGraphicConstants.LABEL,
                new OMTextLabeler("Line Label"));

        omList.add(line);

        OMGraphicList pointList = new OMGraphicList();
        for (int i = 0; i < 100; i++) {
            point = new OMPoint((float) (Math.random() * 89f), (float) (Math.random() * -179f), 3);
            point.setSelectPaint(Color.yellow);
            pointList.add(point);
        }
        omList.add(pointList);

        OMEllipse ell = new OMEllipse(new LatLonPoint(60f, -110), 1000, 300, Length.NM, com.bbn.openmap.MoreMath.HALF_PI / 2.0);

View Full Code Here

                lat[ya - lat_minus],
                lon[xa - lon_minus],
                lat[ya],
                lon[xa]);

        OMGraphicList list = loadListFromHandler(null);

        // Dateline split
        if (lon_minus == 1) {
            setProjection(proj, lat[ya - lat_minus], lon[0], lat[ya], -1f
                    * lon[1]); // -1 to make it 180
View Full Code Here

     * graphics list if the one passed in is null, otherwise it
     * returns the one passed in.
     */
    protected OMGraphicList loadListFromHandler(OMGraphicList graphics) {
        if (graphics == null) {
            graphics = new OMGraphicList();
        }

        OMGraphic image = getNextImage();

        while (image != null) {
View Full Code Here

     * change it's OMGraphics for different projections, if your layer does, you
     * need to clear out the OMGraphicList and add the OMGraphics you want for
     * the current projection.
     */
    public OMGraphicList prepare() {
        OMGraphicList list = getList();
        if (list == null) {
            list = init();
        }
        list.generate(getProjection());
        return list;
    }
View Full Code Here

        if (obj != null && (obj == internalKey || obj == externalKey)
                && !action.isMask(OMGraphicConstants.DELETE_GRAPHIC_MASK)) {

            java.awt.Shape filterShape = omg.getShape();
            OMGraphicList filteredList = filter(filterShape,
                    (omg.getAppObject() == internalKey));
            if (Debug.debugging("demo")) {
                Debug.output("DemoLayer filter: "
                        + filteredList.getDescription());
            }
        } else {
            if (!doAction(omg, action)) {
                // null OMGraphicList on failure, should only occur if
                // OMGraphic is added to layer before it's ever been
                // on the map.
                setList(new OMGraphicList());
                doAction(omg, action);
            }
        }

        repaint();
View Full Code Here

        currentLineType = OMGraphic.LINETYPE_RHUMB;
        //      if (proj instanceof Cylindrical) {
        //          currentLineType = OMGraphic.LINETYPE_STRAIGHT;
        //      }

        OMGraphicList cgs = new OMGraphicList();
        OMGraphicList tlms = new OMGraphicList();
        OMGraphicList jogs = new OMGraphicList();
        OMGraphicList tpcs = new OMGraphicList();
        OMGraphicList oncs = new OMGraphicList();
        OMGraphicList jncs = new OMGraphicList();
        OMGraphicList gncs = new OMGraphicList();
        OMGraphicList cib10s = new OMGraphicList();
        OMGraphicList cib5s = new OMGraphicList();
        OMGraphicList miscs = new OMGraphicList();

        omGraphics.addElement(cgs);
        omGraphics.addElement(cib5s);
        omGraphics.addElement(tlms);
        omGraphics.addElement(cib10s);
        omGraphics.addElement(jogs);
        omGraphics.addElement(miscs);
        omGraphics.addElement(tpcs);
        omGraphics.addElement(oncs);
        omGraphics.addElement(jncs);
        omGraphics.addElement(gncs);

        OMRect rect;

        for (int j = 0; j < hemisphereData.length; j++) {
            if (hemisphereData[j] == null) {
                Debug.message("rpfcov", "RpfCoverageManager. vector " + j
                        + " is null");
                continue;
            }

            int size = hemisphereData[j].size();
            for (int i = 0; i < size; i++) {
                RpfCoverageBox box = (RpfCoverageBox) hemisphereData[j].elementAt(i);

                rect = new OMRect((float) box.nw_lat, (float) box.nw_lon, (float) box.se_lat, (float) box.se_lon, currentLineType);

                float scale = RpfProductInfo.get(box.chartCode).scale;

                if (scale < 15000f) {
                    if (colors != null && colors.length >= 1) {
                        rect.setLinePaint(colors[0]);
                        if (fillRects)
                            rect.setFillPaint(colors[0]);
                    }
                    cgs.add(rect);
                } else if (scale == 50000f) {
                    if (colors != null && colors.length >= 2) {
                        rect.setLinePaint(colors[1]);
                        if (fillRects)
                            rect.setFillPaint(colors[1]);
                    }
                    tlms.add(rect);
                } else if (scale == 250000f) {
                    if (colors != null && colors.length >= 3) {
                        rect.setLinePaint(colors[2]);
                        if (fillRects)
                            rect.setFillPaint(colors[2]);
                    }
                    jogs.add(rect);
                } else if (scale == 500000f) {
                    if (colors != null && colors.length >= 4) {
                        rect.setLinePaint(colors[3]);
                        if (fillRects)
                            rect.setFillPaint(colors[3]);
                    }
                    tpcs.add(rect);
                } else if (scale == 1000000f) {
                    if (colors != null && colors.length >= 5) {
                        rect.setLinePaint(colors[4]);
                        if (fillRects)
                            rect.setFillPaint(colors[4]);
                    }
                    oncs.add(rect);
                } else if (scale == 2000000f) {
                    if (colors != null && colors.length >= 6) {
                        rect.setLinePaint(colors[5]);
                        if (fillRects)
                            rect.setFillPaint(colors[5]);
                    }
                    jncs.add(rect);
                } else if (scale == 5000000f) {
                    if (colors != null && colors.length >= 7) {
                        rect.setLinePaint(colors[6]);
                        if (fillRects)
                            rect.setFillPaint(colors[6]);
                    }
                    gncs.add(rect);
                } else if (scale == 66666f) {
                    if (colors != null && colors.length >= 8) {
                        rect.setLinePaint(colors[7]);
                        if (fillRects)
                            rect.setFillPaint(colors[7]);
                    }
                    cib10s.add(rect);
                } else if (scale == 33333f) {
                    if (colors != null && colors.length >= 9) {
                        rect.setLinePaint(colors[8]);
                        if (fillRects)
                            rect.setFillPaint(colors[8]);
                    }
                    cib5s.add(rect);
                } else if (scale == RpfConstants.Various) {
                    // Don't show it, because we don't know how to
                    // display it anyway. Don't bother projecting it.
                    continue;
                } else {
                    if (colors != null && colors.length >= 10) {
                        rect.setLinePaint(colors[9]);
                        if (fillRects)
                            rect.setFillPaint(colors[9]);
                    }
                    miscs.add(rect);
                }
                rect.generate(proj);
            }
        }
        return omGraphics;
View Full Code Here

TOP

Related Classes of com.bbn.openmap.omGraphics.OMGraphicList

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.