Examples of OMGraphicList


Examples of com.bbn.openmap.omGraphics.OMGraphicList

            return null;
        }
        Projection projection = getProjection();
        if (projection == null) {
            Debug.error("ETOPO Layer needs to be added to the MapBean before it can draw images!");
            return new OMGraphicList();
        }

        // load the buffer
        if (dataBuffer == null || spacingReset) {
            loadBuffer();
            spacingReset = false;
            slopeReset = true;
        }

        // re-do the slope map
        if (slopeReset) {
            buildSlopeMap();
            slopeReset = false;
        }

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

        // Setting the OMGraphicsList for this layer. Remember, the
        // 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();
        if (Debug.debugging("etopo")) {
            Debug.output(getName() + "|ETOPOLayer.prepare(): "
                    + "calling getRectangle " + " with projection: "
                    + projection + " ul = " + projection.getUpperLeft()
                    + " lr = " + projection.getLowerRight());
        }

        // build graphics list
        OMGraphicList omGraphicList = new OMGraphicList();
        omGraphicList.addOMGraphic(buildRaster());

        // ///////////////////
        // safe quit
        int size = 0;
        if (omGraphicList != null) {
            size = omGraphicList.size();
            Debug.message("basic", getName()
                    + "|ETOPOLayer.prepare(): finished with " + size
                    + " graphics");
        } else {
            Debug.message("basic", getName()
                    + "|ETOPOLayer.prepare(): finished with null graphics list");
            omGraphicList = 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.
        omGraphicList.project(projection, true);
        return omGraphicList;
    }
View Full Code Here

Examples of com.bbn.openmap.omGraphics.OMGraphicList

     *
     * @return OMGraphicList
     */
    public synchronized OMGraphicList prepare() {

        OMGraphicList list = getList();
        Projection projection = getProjection();

        if (projection == null) {
            Debug.message("basic", "ShapeLayer|" + getName()
                    + ": prepare called with null projection");
            return new OMGraphicList();
        }

        if (spatialIndex == null) {
            Debug.message("shape", "ShapeLayer: spatialIndex is null!");

            if (list != null) {
                list.generate(projection, true);// all new graphics
                return list;
            } else {
                // What we'd really like to do is make this a buffered layer at
                // this point, if we can't find an ssx file and can't create
                // one.
                return new OMGraphicList();
            }
        }

        LatLonPoint ul = projection.getUpperLeft();
        LatLonPoint lr = projection.getLowerRight();
        float ulLat = ul.getLatitude();
        float ulLon = ul.getLongitude();
        float lrLat = lr.getLatitude();
        float lrLon = lr.getLongitude();

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

        // check for dateline anomaly on the screen. we check for
        // ulLon >= lrLon, but we need to be careful of the check for
        // equality because of floating point arguments...
View Full Code Here

Examples of com.bbn.openmap.omGraphics.OMGraphicList

        if (shadowX == 0 && shadowY == 0) {
            // Enabling buffer...
            super.paint(g);
        } else {
            // grab local for thread safety
            OMGraphicList omg = getList();

            if (omg != null) {
                if (Debug.debugging("shape"))
                    Debug.output("ShapeLayer.paint(): " + omg.size() + " omg"
                            + " shadow=" + shadowX + "," + shadowY);

                if (shadowX != 0 || shadowY != 0) {
                    Graphics shadowG = g.create();
                    shadowG.translate(shadowX, shadowY);
                    omg.render(shadowG);
                } else {
                    omg.render(g);
                }

                if (Debug.debugging("shape")) {
                    Debug.output("ShapeLayer.paint(): done");
                }
View Full Code Here

Examples of com.bbn.openmap.omGraphics.OMGraphicList

    /**
     * Called when the Layer is removed from the MapBean, giving an opportunity
     * to clean up.
     */
    public void removed(Container cont) {
        OMGraphicList list = getList();
        if (list != null) {
            list.clear();
            list = null;
        }

    }
View Full Code Here

Examples of com.bbn.openmap.omGraphics.OMGraphicList

        }
    }

    public void paint(Graphics g) {
        if (layer != null) {
            OMGraphicList list = layer.getList();
            Projection proj = layer.getProjection();
            if (list != null && layer.isProjectionOK(proj)) {
                if (proj != null) {
                    g.setClip(0, 0, proj.getWidth(), proj.getHeight());
                }

                setCompositeOnGraphics((Graphics2D) g);

                list.render(g);
            } else if (DEBUG) {
                Debug.output(layer.getName()
                        + ".paint(): "
                        + (list == null ? "NULL list, skipping..."
                                : " skipping due to projection."));
View Full Code Here

Examples of com.bbn.openmap.omGraphics.OMGraphicList

     */
    public synchronized OMGraphicList prepare() {

        if (spatialIndexes == null || spatialIndexes.size() == 0) {
            Debug.message("shape", "MultiShapeLayer: spatialIndexes is empty!");
            return new OMGraphicList();
        }

        Projection projection = getProjection();

        if (projection == null) {
            // This can happen if the layer is part of a
            // ScaleFilterLayer, and the redraw button for this layer
            // is pressed before the ScaleFilterLayer gives it a
            // projection (which only happens if the layer is the
            // active one).
            Debug.message("basic", "MultiShapeLayer|" + getName()
                    + ": prepare called with null projection");
            return new OMGraphicList();
        }

        LatLonPoint ul = projection.getUpperLeft();
        LatLonPoint lr = projection.getLowerRight();
        float ulLat = ul.getLatitude();
        float ulLon = ul.getLongitude();
        float lrLat = lr.getLatitude();
        float lrLon = lr.getLongitude();

        OMGraphicList masterList = new OMGraphicList();
        OMGraphicList list = null;
        SpatialIndexHandler sih;
        Iterator sii;

        // check for dateline anomaly on the screen. we check for
        // ulLon >= lrLon, but we need to be careful of the check for
View Full Code Here

Examples of com.bbn.openmap.omGraphics.OMGraphicList

        OMLine oml = null;
        MIFPoint ompoint = null;
        OMText omtext = null;
        boolean ismultiple = false;

        OMGraphicList aList = new OMGraphicList();

        // a vector of omgraphics for regions that allows adding and
        // deleting
        Vector omgs = new Vector();

        MAIN_LOOP: while (true) {

            if (!pushback) {
                // if it's null then there's no more
                if ((st = getTokens(br)) == null)
                    break MAIN_LOOP;

                tok = st.nextToken();
            } else {
                pushback = false; // pushback was true so make it
                // false so it doesn't happen twice
            }

            SWITCH: switch (action) {

            case PROCESS_HEADER:
                if (isSame(tok, DATA_WORD)) {
                    action = PROCESS_DATA;
                } else if (isSame(tok, VERSION_WORD)) {
                } else if (isSame(tok, DELIMITER_WORD)) {
                } else if (isSame(tok, COORDSYS_WORD)) {
                    // check the CoordSys header, OpenMap only
                    // directly
                    // supports LatLong type of coordsys
                    String coordSysLine = COORDSYS_WORD;
                    while (st.hasMoreElements()) {
                        coordSysLine += " " + st.nextElement();
                    }

                    String goodCoordSys = COORDSYS_WORD + " "
                            + LATLONG_COORDSYS_DEF;
                    if (goodCoordSys.length() < coordSysLine.length()) {
                        coordSysLine = coordSysLine.substring(0,
                                goodCoordSys.length());
                    } else {
                        goodCoordSys = goodCoordSys.substring(0,
                                coordSysLine.length());
                    }

                    // check that the CoordSys header matches the MIF
                    // specification for LatLong type
                    if (!isSame(coordSysLine, goodCoordSys)) {
                        Debug.error("MIFLoader file has coordinate system: "
                                + coordSysLine + ", requires " + goodCoordSys);
                        // raise error, as the coordsys header was
                        // invalid
                        throw new MIFException("File appears to contain objects with an incompatible coordinate system (Must be Lat/Lon).");
                    }

                }
                break SWITCH;

            case PROCESS_DATA:
                omgs.clear();
                if (isSame(tok, PLINE_WORD)) {
                    tok = st.nextToken();
                    if (isSame(tok, MULTIPLE_WORD)) {
                        multiple = Integer.parseInt(st.nextToken());
                        multicnt = 0;
                        action = PROCESS_MULTIPLE;
                        ismultiple = true;
                    } else {
                        number = Integer.parseInt(tok);
                        ptarray = new float[number + number];
                        count = 0;
                        action = PROCESS_PLINE;
                    }
                } else if (isSame(tok, REGION_WORD)) {
                    multiple = Integer.parseInt(st.nextToken());
                    multicnt = 0;
                    action = PROCESS_REGION_HEADER;
                } else if (isSame(tok, LINE_WORD)) {
                    float lon1 = Float.parseFloat(st.nextToken());
                    float lat1 = Float.parseFloat(st.nextToken());
                    float lon2 = Float.parseFloat(st.nextToken());
                    float lat2 = Float.parseFloat(st.nextToken());

                    oml = new OMLine(lat1, lon1, lat2, lon2, OMGraphicConstants.LINETYPE_STRAIGHT);

                    action = PROCESS_POST_LINE;
                } else if (isSame(tok, POINT_WORD)) // handle a MIF
                // POINT primitive
                {
                    // get the coordinates
                    float lon1 = Float.parseFloat(st.nextToken());
                    float lat1 = Float.parseFloat(st.nextToken());

                    // construct the OM graphic
                    ompoint = new MIFPoint(lat1, lon1, pointVisible);
                    st = getTokens(br);

                    // set the graphics attributes
                    this.processSymbolWord(st, ompoint);

                    // add to the graphic list for this layer
                    aList.add(ompoint);
                    action = PROCESS_DATA;
                } else if (isSame(tok, TEXT_WORD)) // handle a MIF
                // TEXT primitive
                {
                    String textString = "";

                    // if the actual text is not on the same line as
                    // the primitive declaration
                    if (st.countTokens() < 1) {
                        // get the next line
                        st = getTokens(br);
                    }
                    // build up the display text string,
                    while (st.hasMoreTokens()) {
                        textString += st.nextToken();
                    }

                    if (textString.length() >= 1) {
                        // remove any surrounding " characters
                        textString = textString.substring(1,
                                textString.length() - 1);
                    }
                    // get the next line, it contains the coordinates
                    st = getTokens(br);

                    float lon1 = Float.parseFloat(st.nextToken());
                    float lat1 = Float.parseFloat(st.nextToken());
                    /* float lon2 = */Float.parseFloat(st.nextToken());
                    /* float lat2 = */Float.parseFloat(st.nextToken());
                    // create the OMGraphic for the text object
                    omtext = new MIFText(lat1, lon1, textString, OMText.JUSTIFY_CENTER, textVisible);

                    // the next line contains the text attributes
                    st = getTokens(br);
                    // set the attributes agains the omgraphic
                    this.processFontWord(st, omtext);
                    // add to the layers graphic list
                    aList.add(omtext);

                    action = PROCESS_DATA;
                }
                break SWITCH;

            // We have a line, tok is the first coord and the next
            // token is the second
            case PROCESS_PLINE:
                idx = count + count;
                ptarray[idx + 1] = Float.parseFloat(tok);
                ptarray[idx] = Float.parseFloat(st.nextToken());
                count++;
                if (count == number) {
                    omp = new OMPoly(ptarray, OMGraphic.DECIMAL_DEGREES, OMGraphic.LINETYPE_STRAIGHT);

                    aList.add(omp);
                    if (!ismultiple) {
                        action = PROCESS_POST_PLINE;
                    } else {
                        omgs.add(omp);
                        action = PROCESS_MULTIPLE;
                    }
                }
                break SWITCH;

            case PROCESS_MULTIPLE:
                multicnt++;
                if (multicnt > multiple) { // No more multiples so we
                    // can pushback
                    pushback = true;
                    multiple = 0;
                    action = PROCESS_POST_PLINE;
                    break SWITCH;
                }
                number = Integer.parseInt(tok);
                count = 0;
                ptarray = new float[number + number];
                action = PROCESS_PLINE;
                break SWITCH;

            case PROCESS_POST_PLINE:
                if (isSame(tok, PEN_WORD)) {
                    if (ismultiple) {
                        processPenWord(st, omgs);
                    } else {
                        processPenWord(st, omp);
                    }
                } else if (isSame(tok, SMOOTH_WORD)) {
                    // Smooth unimplemented
                } else {
                    ismultiple = false;
                    pushback = true;
                    action = PROCESS_DATA;
                }
                break SWITCH;

            // SCN to support lines
            case PROCESS_POST_LINE:
                if (isSame(tok, PEN_WORD)) {
                    processPenWord(st, oml);
                    aList.add(oml);
                } else {
                    ismultiple = false;
                    pushback = true;
                    action = PROCESS_DATA;
                }
                break SWITCH;

            case PROCESS_REGION_HEADER: // This processes the number
                // at the top of each region
                // sub-block
                multicnt++;
                if (multicnt > multiple) {
                    multiple = 0;
                    action = PROCESS_POST_REGION;

                    // Add this point the region is finished so add
                    // the
                    // vector contents to list
                    int len = omgs.size();
                    for (int i = 0; i < len; i++) {
                        aList.add((OMGraphic) omgs.elementAt(i));
                    }
                    break SWITCH;
                }
                number = Integer.parseInt(tok);
                count = 0;
View Full Code Here

Examples of com.bbn.openmap.omGraphics.OMGraphicList

    /**
     * OMGraphicHandlerLayer method for gathering data.
     */
    public synchronized OMGraphicList prepare() {
        if (mifl != null) {
            OMGraphicList list = mifl.getList();
            if (list != null) {
                list.generate(getProjection());
            }
            return list;
        } else {
            return new OMGraphicList();
        }
    }
View Full Code Here

Examples of com.bbn.openmap.omGraphics.OMGraphicList

    }

    public OMGraphicList prepare() {
        if (layer != null) {
            setBuffer(null);
            OMGraphicList list = layer.prepare();
            if (isUseImageBuffer()) {
                setBuffer(createAndPaintImageBuffer(list));
            }
            return list;
        } else {
View Full Code Here

Examples of com.bbn.openmap.omGraphics.OMGraphicList

        if (layer == null) {
            Debug.error("BufferedImageRenderPolicy.paint():  NULL layer, skipping...");
            return;
        }

        OMGraphicList list = layer.getList();
        Projection proj = layer.getProjection();

        if (list != null && layer.isProjectionOK(proj)) {

            if (isUseImageBuffer() && getBuffer() == null) {
                setBuffer(createAndPaintImageBuffer(list));
            }

            BufferedImage bufferedImage = getBuffer();

            if (composite != null) {
                ((Graphics2D) g).setComposite(composite);
            }
           
            setCompositeOnGraphics((Graphics2D)g);
           
            if (bufferedImage != null) {

                if (proj != null) {
                    // Gets reset by JComponent
                    g.setClip(0, 0, proj.getWidth(), proj.getHeight());
                }

                ((Graphics2D) g).drawRenderedImage((BufferedImage) bufferedImage,
                        new AffineTransform());
                if (DEBUG) {
                    Debug.output("RenderingPolicy:" + layer.getName()
                            + ": rendering buffer");
                }

                if (!isUseImageBuffer()) {
                    setBuffer(null);
                }
            } else {
                super.setRenderingHints(g);
                long startPaint = System.currentTimeMillis();
                list.render(g);
                long endPaint = System.currentTimeMillis();

                if (endPaint - startPaint > bufferTriggerDelay) {
                    setUseImageBuffer(true);
                }
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.