imageeditor.java

来自「world wind java sdk 源码」· Java 代码 · 共 582 行 · 第 1/2 页

JAVA
582
字号
                sw = sw.add(delta);                se = se.add(delta);            }            else if (side == GeoQuad.EAST)            {                se = se.add(delta);                ne = ne.add(delta);            }            else if (side == GeoQuad.WEST)            {                sw = sw.add(delta);                nw = nw.add(delta);            }            else if (side == GeoQuad.NORTHWEST)            {                nw = nw.add(delta);            }            else if (side == GeoQuad.NORTHEAST)            {                ne = ne.add(delta);            }            else if (side == GeoQuad.SOUTHWEST)            {                sw = sw.add(delta);            }            else if (side == GeoQuad.SOUTHEAST)            {                se = se.add(delta);            }            return Arrays.asList(sw, se, ne, nw);        }        return null;    }    @SuppressWarnings({"UnusedDeclaration"})    private static double minAbs(double a, double b, double c, double d)    {        double m = a;        if (abs(b) < abs(m))            m = b;        if (abs(c) < abs(m))            m = c;        if (abs(d) < abs(m))            m = d;        return m;    }    private static double abs(double a)    {        return a >= 0 ? a : -a;    }    private void dragWholeShape(DragSelectEvent dragEvent, Movable dragObject)    {        View view = wwd.getView();        EllipsoidalGlobe globe = (EllipsoidalGlobe) wwd.getModel().getGlobe();        // Compute ref-point position in screen coordinates.        Position refPos = dragObject.getReferencePosition();        Vec4 refPoint = globe.computePointFromPosition(refPos);        Vec4 screenRefPoint = view.project(refPoint);        // Compute screen-coord delta since last event.        int dx = dragEvent.getPickPoint().x - dragEvent.getPreviousPickPoint().x;        int dy = dragEvent.getPickPoint().y - dragEvent.getPreviousPickPoint().y;        // Find intersection of screen coord ref-point with globe.        double x = screenRefPoint.x + dx;        double y = dragEvent.getMouseEvent().getComponent().getSize().height - screenRefPoint.y + dy - 1;        Line ray = view.computeRayFromScreenPoint(x, y);        Intersection inters[] = globe.intersect(ray, refPos.getElevation());        if (inters != null)        {            // Intersection with globe. Move reference point to the intersection point.            Position p = globe.computePositionFromPoint(inters[0].getIntersectionPoint());            dragObject.moveTo(p);        }    }    public static class RegionShape implements Renderable    {        private SurfaceImage image;        private boolean armed = false;        private boolean resizeable = false;        private Position startPosition;        private Position endPosition;        private int highlightSide = NONE;        private Polyline handle;        public RegionShape(SurfaceImage image)        {            this.image = image;            this.handle = new Polyline();            this.handle.setFollowTerrain(true);            this.handle.setPathType(Polyline.LINEAR);            this.handle.setClosed(false);            this.handle.setColor(new Color(1f, 0f, 0f, 0.5f));            this.handle.setLineWidth(3);        }        public Sector getBoundingSector()        {            return this.image.getSector();        }        public boolean hasSelection()        {            return startPosition != null && endPosition != null;        }        private void clear()        {            this.startPosition = this.endPosition = null;        }        public void setHighlight(int highlightPlace)        {            this.highlightSide = highlightPlace;        }        public void render(DrawContext dc)        {            if (dc.isPickingMode() && resizeable)                return;            if (!resizeable)            {                if (startPosition != null && endPosition != null)                {                    this.image.render(dc);                }            }            List<LatLon> corners = this.image.getCorners();            List<LatLon> handlePositions = new ArrayList<LatLon>();            switch (this.highlightSide)            {                case GeoQuad.NORTH:                {                    handlePositions.addAll(Arrays.asList(corners.get(2), corners.get(3)));                    break;                }                case GeoQuad.SOUTH:                {                    handlePositions.addAll(Arrays.asList(corners.get(0), corners.get(1)));                    break;                }                case GeoQuad.EAST:                {                    handlePositions.addAll(Arrays.asList(corners.get(1), corners.get(2)));                    break;                }                case GeoQuad.WEST:                {                    handlePositions.addAll(Arrays.asList(corners.get(3), corners.get(0)));                    break;                }                case GeoQuad.NORTHWEST:                {                    break;                }                case GeoQuad.NORTHEAST:                {                    break;                }                case GeoQuad.SOUTHWEST:                {                    break;                }                case GeoQuad.SOUTHEAST:                {                    break;                }                default:                {                    break;                }//                if (handlePositions.size() > 1)            }            {                this.handle.setPositions(handlePositions, 0);                this.handle.render(dc);            }            return;//            PickedObjectList pos = dc.getPickedObjects();//            PickedObject terrainObject = pos != null ? pos.getTerrainObject() : null;////            if (terrainObject == null)//                return;////            if (this.startPosition != null)//            {//                Position end = terrainObject.getPosition();//                if (!this.startPosition.equals(end))//                {//                    this.endPosition = end;//                    this.setSector(Sector.boundingSector(this.startPosition, this.endPosition));//                    super.render(dc);//                    this.border.setPositions(this.getBoundingSector(), 0);//                    this.border.render(dc);//                }//            }//            else//            {//                this.startPosition = pos.getTerrainObject().getPosition();//            }        }    }////    public static class RegionShape2 extends SurfaceSector//    {//        private boolean armed = false;//        private boolean resizeable = false;//        private Position startPosition;//        private Position endPosition;//        private Polyline border;////        public RegionShape(Sector sector, Color color, Color borderColor, Dimension textureSize)//        {//            super(sector, color, borderColor, textureSize);//            this.setDrawBorder(false);//            this.border = new Polyline();//            this.border.setFollowTerrain(true);//            this.border.setPathType(Polyline.LINEAR);//            this.border.setClosed(true);//            this.border.setColor(new Color(1f, 0f, 0f, 0.5f));//            this.border.setLineWidth(3);//        }////        public boolean hasSelection()//        {//            return startPosition != null && endPosition != null;//        }////        private void clear()//        {//            this.startPosition = this.endPosition = null;//        }////        @Override//        public void render(DrawContext dc)//        {//            if (dc.isPickingMode() && resizeable)//                return;////            if (!resizeable)//            {//                if (startPosition != null && endPosition != null)//                {//                    super.render(dc);//                    this.border.setPositions(this.getBoundingSector(), 0);//                    this.border.render(dc);//                }//                return;//            }////            PickedObjectList pos = dc.getPickedObjects();//            PickedObject terrainObject = pos != null ? pos.getTerrainObject() : null;////            if (terrainObject == null)//                return;////            if (this.startPosition != null)//            {//                Position end = terrainObject.getPosition();//                if (!this.startPosition.equals(end))//                {//                    this.endPosition = end;//                    this.setSector(Sector.boundingSector(this.startPosition, this.endPosition));//                    super.render(dc);//                    this.border.setPositions(this.getBoundingSector(), 0);//                    this.border.render(dc);//                }//            }//            else//            {//                this.startPosition = pos.getTerrainObject().getPosition();//            }//        }//    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?