SRect.java
上传用户:art_006
上传日期:2015-08-18
资源大小:18969k
文件大小:5k
源码类别:

Java编程

开发平台:

Unix_Linux

  1. // **********************************************************************
  2. // 
  3. // <copyright>
  4. // 
  5. //  BBN Technologies
  6. //  10 Moulton Street
  7. //  Cambridge, MA 02138
  8. //  (617) 873-8000
  9. // 
  10. //  Copyright (C) BBNT Solutions LLC. All rights reserved.
  11. // 
  12. // </copyright>
  13. // **********************************************************************
  14. // 
  15. // $Source: /cvs/distapps/openmap/src/corba/com/bbn/openmap/layer/specialist/SRect.java,v $
  16. // $RCSfile: SRect.java,v $
  17. // $Revision: 1.2.2.1 $
  18. // $Date: 2004/10/14 18:26:32 $
  19. // $Author: dietrick $
  20. // 
  21. // **********************************************************************
  22. package com.bbn.openmap.layer.specialist;
  23. import com.bbn.openmap.CSpecialist.*;
  24. import com.bbn.openmap.CSpecialist.GraphicPackage.*;
  25. import com.bbn.openmap.CSpecialist.RectanglePackage.*;
  26. /**
  27.  * SRect is a specialist rectangle graphic object
  28.  * 
  29.  * <h4>ASSUMPTIONS</h4>
  30.  * 
  31.  * OpenMap assumes the following about rects:
  32.  * 
  33.  * <ul>
  34.  * 
  35.  * <li>The edges of a LatLon rect must be less than 180 degrees of
  36.  * arc, (one hemisphere). We draw lines the short way around the
  37.  * world.
  38.  * <p>
  39.  * 
  40.  * <li>The vertices of the LatLon rect should be specified in
  41.  * clockwise order, we suggest `llNW' then `llSE' (Northwest LatLon,
  42.  * Southeast LatLon box). <br>
  43.  * 
  44.  * </ul>
  45.  * 
  46.  * Not following these assumptions may result in unpredictable
  47.  * behavior!
  48.  * <p>
  49.  * 
  50.  * These assumptions are virtually the same as those on the more
  51.  * generic Poly and Line graphic types.
  52.  * <p>
  53.  * 
  54.  * @see SPoly
  55.  * @see SLine
  56.  */
  57. public class SRect extends SGraphic /* used to be _RectangleImplBase */{
  58.     /** Upper left corner xy screen point, or upper left corner offset. */
  59.     protected XYPoint p1_;
  60.     /**
  61.      * Lower right corner xy screen point, or lower right corner
  62.      * offset.
  63.      */
  64.     protected XYPoint p2_;
  65.     /** Upper left corner coordinate, or coordinate for offset */
  66.     protected LLPoint ll1_;
  67.     /** Lower right corner coordinate */
  68.     protected LLPoint ll2_;
  69.     // Need several constructors
  70.     public SRect() {
  71.         super(GraphicType.GT_Rectangle,
  72.               RenderType.RT_Unknown,
  73.               LineType.LT_Unknown,
  74.               DeclutterType.DC_None);
  75.         ll1_ = new LLPoint(0f, 0f);
  76.         p1_ = new XYPoint((short) 0, (short) 0);
  77.         ll2_ = new LLPoint(0f, 0f);
  78.         p2_ = new XYPoint((short) 0, (short) 0);
  79.     }
  80.     public SRect(LLPoint ll1, LLPoint ll2, LineType lType) {
  81.         super(GraphicType.GT_Rectangle,
  82.               RenderType.RT_LatLon,
  83.               lType,
  84.               DeclutterType.DC_None);
  85.         ll1_ = ll1;
  86.         ll2_ = ll2;
  87.         p1_ = new XYPoint((short) 0, (short) 0);
  88.         p2_ = new XYPoint((short) 0, (short) 0);
  89.     }
  90.     public SRect(short x1, short y1, short x2, short y2) {
  91.         super(GraphicType.GT_Rectangle,
  92.               RenderType.RT_XY,
  93.               LineType.LT_Unknown,
  94.               DeclutterType.DC_None);
  95.         ll1_ = new LLPoint(0f, 0f);
  96.         ll2_ = new LLPoint(0f, 0f);
  97.         p1_ = new XYPoint(x1, y1);
  98.         p2_ = new XYPoint(x2, y2);
  99.     }
  100.     public SRect(LLPoint ll1, short x1, short y1, short x2, short y2) {
  101.         super(GraphicType.GT_Rectangle,
  102.               RenderType.RT_Offset,
  103.               LineType.LT_Unknown,
  104.               DeclutterType.DC_None);
  105.         ll1_ = ll1;
  106.         ll2_ = new LLPoint(0f, 0f);
  107.         p1_ = new XYPoint(x1, y1);
  108.         p2_ = new XYPoint(x2, y2);
  109.     }
  110.     // The SRect methods
  111.     public void p1(XYPoint p1) {
  112.         p1_ = p1;
  113.     }
  114.     public XYPoint p1() {
  115.         return p1_;
  116.     }
  117.     public void p2(XYPoint p2) {
  118.         p2_ = p2;
  119.     }
  120.     public XYPoint p2() {
  121.         return p2_;
  122.     }
  123.     public void ll1(LLPoint ll1) {
  124.         ll1_ = ll1;
  125.     }
  126.     public LLPoint ll1() {
  127.         return ll1_;
  128.     }
  129.     public void ll2(LLPoint ll2) {
  130.         ll2_ = ll2;
  131.     }
  132.     public LLPoint ll2() {
  133.         return ll2_;
  134.     }
  135.     public ERectangle fill() {
  136.         return new ERectangle(eg, p1_, p2_, ll1_, ll2_);
  137.     }
  138.     public UGraphic ufill() {
  139.         UGraphic ugraphic = new UGraphic();
  140.         ugraphic.erect(fill());
  141.         return ugraphic;
  142.     }
  143.     //  Update methods as a result of gesture impulses...
  144.     public void changeLl1(com.bbn.openmap.CSpecialist.LLPoint ll1) {
  145.         ll1_ = ll1;
  146.         RF_update gupdate = new RF_update();
  147.         gupdate.ll1(ll1);
  148.         UpdateGraphic ug = new UpdateGraphic();
  149.         ug.rf_update(gupdate);
  150.         addGraphicChange(ug);
  151.     }
  152.     public void changeLl2(com.bbn.openmap.CSpecialist.LLPoint ll2) {
  153.         ll2_ = ll2;
  154.         RF_update gupdate = new RF_update();
  155.         gupdate.ll2(ll2);
  156.         UpdateGraphic ug = new UpdateGraphic();
  157.         ug.rf_update(gupdate);
  158.         addGraphicChange(ug);
  159.     }
  160.     public void changeP1(com.bbn.openmap.CSpecialist.XYPoint p1) {
  161.         p1_ = p1;
  162.         RF_update gupdate = new RF_update();
  163.         gupdate.p1(p1);
  164.         UpdateGraphic ug = new UpdateGraphic();
  165.         ug.rf_update(gupdate);
  166.         addGraphicChange(ug);
  167.     }
  168.     public void changeP2(com.bbn.openmap.CSpecialist.XYPoint p2) {
  169.         p2_ = p2;
  170.         RF_update gupdate = new RF_update();
  171.         gupdate.p2(p2);
  172.         UpdateGraphic ug = new UpdateGraphic();
  173.         ug.rf_update(gupdate);
  174.         addGraphicChange(ug);
  175.     }
  176. }