Package com.bbn.openmap.omGraphics

Examples of com.bbn.openmap.omGraphics.OMGraphic


     */
    protected GraphicUpdate readGraphic(int graphicAction, LinkProperties graphicProperties, Projection proj,
                                        OMGridGenerator generator)
            throws IOException {

        OMGraphic graphic = null;
        String header = link.readDelimiter(false);

        // Sanity check
        if (header == Link.END_TOTAL || header == Link.END_SECTION) {
            return null;
        }

        int graphicType = link.dis.readByte();

        switch (graphicType) {
        case LinkGraphicList.GRAPHICTYPE_LINE:
            graphic = LinkLine.read(link.dis, graphicProperties);
            break;
        case LinkGraphicList.GRAPHICTYPE_POLY:
            graphic = LinkPoly.read(link.dis, graphicProperties);
            break;
        case LinkGraphicList.GRAPHICTYPE_RECTANGLE:
            graphic = LinkRectangle.read(link.dis, graphicProperties);
            break;
        case LinkGraphicList.GRAPHICTYPE_POINT:
            graphic = LinkPoint.read(link.dis, graphicProperties);
            break;
        case LinkGraphicList.GRAPHICTYPE_CIRCLE:
            graphic = LinkCircle.read(link.dis, graphicProperties);
            break;
        case LinkGraphicList.GRAPHICTYPE_ELLIPSE:
            graphic = LinkEllipse.read(link.dis, graphicProperties);
            break;
        case LinkGraphicList.GRAPHICTYPE_RASTER:
            graphic = LinkRaster.read(link.dis, graphicProperties);
            break;
        case LinkGraphicList.GRAPHICTYPE_BITMAP:
            graphic = LinkBitmap.read(link.dis, graphicProperties);
            break;
        case LinkGraphicList.GRAPHICTYPE_TEXT:
            graphic = LinkText.read(link.dis, graphicProperties);
            break;
        case LinkGraphicList.GRAPHICTYPE_GRID:
            graphic = LinkGrid.read(link.dis, graphicProperties);
            break;
        case LinkGraphicList.GRAPHICTYPE_ARC:
            graphic = LinkArc.read(link.dis, graphicProperties);
            break;
        default:
            System.err.println("LinkActionList: received unknown graphic type.");
        }

        if (graphic != null && proj != null) {
            if (graphic instanceof OMGrid) {
                ((OMGrid) graphic).setGenerator(generator);
            }
            graphic.generate(proj);
        }

        return (new GraphicUpdate(graphicAction, graphic));
    }
View Full Code Here


                for (int n = 0; n < numParts; n++) {
                    offsets[n] = _leis.readLEInt();
                }

                float[] points;
                OMGraphic poly = null;
                EsriGraphicList sublist = null;

                if (numParts > 1) {
                    if (shapeType == SHAPE_TYPE_POLYLINE) {
                        sublist = new EsriPolylineList();
                    } else if (shapeType == SHAPE_TYPE_POLYGON) {
                        sublist = new EsriPolygonList();
                    }

                    sublist.setVague(true); // Treat sublist as one
                    // OMGraphic.
                    sublist.putAttribute(SHAPE_INDEX_ATTRIBUTE,
                            shpRecordIndex);
                }

                for (int j = 0; j < numParts; j++) {
                    int i = 0;
                    if (j != numParts - 1) {
                        numVertices = (offsets[j + 1]) - offsets[j];
                        points = new float[numVertices * 2];
                    } else {
                        numVertices = (numPoints - offsets[j]);
                        points = new float[numVertices * 2];
                    }
                    for (int n = 0; n < numVertices; n++) {
                        double lambda = _leis.readLEDouble();
                        double phi = _leis.readLEDouble();

                        points[i++] = (float) Math.toRadians(phi);
                        points[i++] = (float) Math.toRadians(lambda);
                    }

                    if (shapeType == SHAPE_TYPE_POLYLINE) {
                        poly = new EsriPolyline(points, OMGraphic.RADIANS, OMGraphic.LINETYPE_GREATCIRCLE);
                    } else if (shapeType == SHAPE_TYPE_POLYGON) {
                        poly = new EsriPolygon(points, OMGraphic.RADIANS, OMGraphic.LINETYPE_GREATCIRCLE);
                    }

                    if (drawingAttributes != null) {
                        drawingAttributes.setTo(poly);
                    } else {
                        DrawingAttributes.DEFAULT.setTo(poly);
                    }

                    if (poly instanceof EsriPolyline) {
                        // Just to make sure it gets rendered as a
                        // polyline. The OMPoly code will render it as a
                        // polygon if the fill color is not clear.
                        poly.setFillPaint(OMColor.clear);
                    }

                    // sublist is null for non multi-part geometries.
                    if (sublist != null) {
                        sublist.addOMGraphic(poly);
                    } else {
                        poly.putAttribute(SHAPE_INDEX_ATTRIBUTE,
                                shpRecordIndex);
                    }
                }

                // sublist is null for non multi-part geometries.
View Full Code Here

        if (list != null && infoRecords != null) {
            int numgraphics = list.size();

            for (int i = 0; i < numgraphics; i++) {
                try {
                    OMGraphic omg = list.getOMGraphicAt(i);
                    Integer recnum = (Integer) (omg.getAppObject());
                    // OFF BY ONE!!! The shape record numbers
                    // assigned to the records start with 1, while
                    // everything else we do starts with 0...
                    Object inforec = getRecord(recnum.intValue() - 1);
                    omg.putAttribute(ShapeConstants.SHAPE_DBF_INFO_ATTRIBUTE,
                            inforec);
                } catch (ClassCastException cce) {
                    if (Debug.debugging("shape")) {
                        cce.printStackTrace();
                    }
View Full Code Here

     *
     * @param gid graphic ID of the wanted graphic.
     * @return OMGraphic index or Link.UNKNOWN if not found
     */
    public int getOMGraphicIndexWithId(String gid) {
        OMGraphic graphic = getOMGraphicWithId(gid);
        if (graphic != null) {
            return super._indexOf(graphic);
        } else {
            return Link.UNKNOWN;
        }
View Full Code Here

     * rendered.
     *
     * @param gr the AWT Graphics context
     */
    public synchronized void render(Graphics gr) {
        OMGraphic graphic;
        ListIterator iterator;

        if (traverseMode == FIRST_ADDED_ON_TOP) {
            iterator = graphics.listIterator(graphics.size());
            while (iterator.hasPrevious()) {
                graphic = (OMGraphic) iterator.previous();
                if (graphic.isVisible()) {
                    Object obj = graphic.getAppObject();
                    if (Debug.debugging("linkdetail")
                            && obj instanceof LinkProperties) {
                        String id = ((LinkProperties) obj).getProperty(LPC_GRAPHICID);
                        Debug.output("LinkOMGraphicList: Rendering graphic "
                                + id);
                    }
                    graphic.render(gr);
                }
            }

        } else {
            iterator = graphics.listIterator();

            while (iterator.hasNext()) {
                graphic = (OMGraphic) iterator.next();
                if (graphic.isVisible()) {
                    Object obj = graphic.getAppObject();
                    if (Debug.debugging("linkdetail")
                            && obj instanceof LinkProperties) {
                        String id = ((LinkProperties) obj).getProperty(LPC_GRAPHICID);
                        Debug.output("LinkOMGraphicList: Rendering graphic "
                                + id);
                    }
                    graphic.render(gr);
                }
            }
        }
    }
View Full Code Here

    public void paint(Graphics g) {

        Collection values = graphics.values();
        Iterator iter = values.iterator();
        while (iter.hasNext()) {
            OMGraphic graphic = (OMGraphic) iter.next();
            graphic.render(g);
        }
    }
View Full Code Here

            Long id = (Long) iter.next();

            SimpleBeanObject bean = (SimpleBeanObject) beans.get(id);

            OMGraphic graphic = (OMGraphic) graphics.get(id);

            if ((graphic instanceof CustomGraphic)) {
                ((CustomGraphic) graphic).updateGraphic(bean);
            } else if (graphic instanceof OMRasterObject) {
                ((OMRasterObject) graphic).setLat(bean.getLatitude());
                ((OMRasterObject) graphic).setLon(bean.getLongitude());
                ((OMRasterObject) graphic).setRotationAngle(bean.getBearingInDeg()
                        * Math.PI / 180);

            }

            graphic.setNeedToRegenerate(true);

            if (projection != null)
                graphic.generate(projection);

        }

        repaint();

View Full Code Here

    public void addObject(SimpleBeanObject object) {

        beans.put(new Long(object.getId()), object);
        String customGraphicClassName = object.getCustomGraphicClassName();

        OMGraphic graphic = null;

        if (customGraphicClassName == null) {

            ImageIcon icon = new ImageIcon(object.getGraphicImage());
            int width = icon.getIconWidth();
            int height = icon.getIconHeight();
            graphic = new OMRaster(object.getLatitude(), object.getLongitude(), -width / 2, -height / 2, icon);

            ((OMRaster) graphic).setRotationAngle(object.getBearingInDeg()
                    * Math.PI / 180);

            graphic.setRenderType(OMGraphicConstants.RENDERTYPE_OFFSET);

            graphic.setAppObject(new Long(object.getId()));

        } else {

            try {

                Class graphicClass = Class.forName(customGraphicClassName);

                Class parentClass = graphicClass;
                while (parentClass != null) {
                    if (parentClass == CustomGraphic.class) {
                        break;
                    } else
                        parentClass = parentClass.getSuperclass();
                }

                if (parentClass != null) {
                    Constructor constructor = graphicClass.getConstructor(new Class[] { SimpleBeanObject.class });
                    graphic = (CustomGraphic) constructor.newInstance(new Object[] { object });
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        if (graphic != null) {

            graphic.setNeedToRegenerate(true);

            graphics.put(new Long(object.getId()), graphic);

            if (projection != null)
                graphic.generate(projection);

            repaint();
        }

    }
View Full Code Here

            // being recalled if the projection hase changed, then
            // we need to force a reprojection of all of them
            // because the screen position has changed.
            Enumeration things = omGraphicList.elements();
            while (things.hasMoreElements()) {
                OMGraphic thingy = (OMGraphic) things.nextElement();

                if (useDeclutterMatrix && thingy instanceof Location) {
                    Location loc = (Location) thingy;
                    loc.generate(projection, declutterMatrix);
                } else {
                    thingy.generate(projection);
                }
            }
        } else if (Debug.debugging("basic")) {
            Debug.output(getName()
                    + "|LocationLayer.prepare(): finished with null graphics list");
View Full Code Here

        if (vlist != null)
            list = vlist.toArray();

        if (list != null) {
            int i;
            OMGraphic loc;
            // Draw from the bottom up, so it matches the palette, and
            // the order in which the handlers were loaded - the first
            // in the list is on top.

            // We need to go through list twice. The first time, draw
            // all the regular OMGraphics, and also draw all of the
            // graphics for the locations. The second time through,
            // draw the labels. This way, the labels won't be covered
            // up by graphics.
            for (int j = 0; j < 2; j++) {
                for (i = list.length - 1; i >= 0; i--) {
                    loc = (OMGraphic) list[i];
                    if (j == 0) {
                        if (loc instanceof Location) {
                            ((Location) loc).renderLocation(g);
                        } else {
                            loc.render(g);
                        }
                    } else if (loc instanceof Location) {
                        ((Location) loc).renderName(g);
                    }
                }
View Full Code Here

TOP

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

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.