示例#1
0
  /**
   * Checks whether the position is located on the inner board (the playing area). Returns false for
   * positions on the outer positions, as well as positions that are not on the board.
   *
   * <p>By Leroy
   *
   * @param p position of which is to be determined whether the position is located on the inner
   *     board
   */
  private boolean isOnInnerBoard(Position p) {
    int col = p.getColName() - 'a' + 1;
    int row = p.getRowNumber();

    // See google doc for explanation of the formula
    return !(row <= 1 || col >= 9 || row + col >= 14 || col - row <= -4 || col <= 1);
  }
    /**
     * Performs one line of sight calculation between the reference position and a specified grid
     * position.
     *
     * @param gridPosition the grid position.
     * @throws InterruptedException if the operation is interrupted.
     */
    protected void performIntersection(Position gridPosition) throws InterruptedException {
      // Intersect the line between this grid point and the selected position.
      Intersection[] intersections = this.terrain.intersect(this.referencePosition, gridPosition);
      if (intersections == null || intersections.length == 0) {
        // No intersection, so the line goes from the center to the grid point.
        this.sightLines.add(new Position[] {this.referencePosition, gridPosition});
        return;
      }

      // Only the first intersection is shown.
      Vec4 iPoint = intersections[0].getIntersectionPoint();
      Vec4 gPoint =
          terrain.getSurfacePoint(
              gridPosition.getLatitude(), gridPosition.getLongitude(), gridPosition.getAltitude());

      // Check to see whether the intersection is beyond the grid point.
      if (iPoint.distanceTo3(this.referencePoint) >= gPoint.distanceTo3(this.referencePoint)) {
        // Intersection is beyond the grid point; the line goes from the center to the grid point.
        this.addSightLine(this.referencePosition, gridPosition);
        return;
      }

      // Compute the position corresponding to the intersection.
      Position iPosition = this.terrain.getGlobe().computePositionFromPoint(iPoint);

      // The sight line goes from the user-selected position to the intersection position.
      this.addSightLine(this.referencePosition, new Position(iPosition, 0));

      // Keep track of the intersection positions.
      this.addIntersectionPosition(iPosition);

      this.updateProgress();
    }
 FollowPath(String name) {
   super(name);
   path.add(Position.fromDegrees(0, 0, 1e5));
   path.add(Position.fromDegrees(1, 3, 1e5));
   path.add(Position.fromDegrees(2, 4, 1e5));
   path.add(Position.fromDegrees(3, 5, 1e5));
 }
示例#4
0
  /**
   * Checks whether the position is located on the playing area or the outer dots.
   *
   * @param p the position of which should be determined whether it is on the board
   */
  public boolean isPositionOnPlayAreaOrOuterDots(Position p) {
    int col = p.getColName() - 'a' + 1;
    int row = p.getRowNumber();

    // See google doc for explanation of the formula
    return !(row <= 0 || col >= 10 || row + col >= 15 || col - row <= -5 || col <= 0);
  }
示例#5
0
  /** By Dingding */
  private Set<Line.Segment> getRemovableLineSegments(
      Map<Position, Piece> pieceMap, PieceColor pieceColor) {
    Set<Line.Segment> removableLines = new HashSet<>();
    Set<Line> linesOnTheBoard =
        Line.getLinesOnTheBoard(
            this); // Get all the possible lines on the board. Positions don't need to be occupied.

    for (Line line : linesOnTheBoard) {
      Position currentPosition = line.getStartPosition();
      Position startOfSegment = null;
      Position endOfSegment = null;
      Direction direction = line.getDirection();
      int consecutivePieces =
          0; // We start at a dot position, so we can assume that we don't start in a set of
             // consecutive pieces
      boolean isInLineSegment = false;

      // Break the for-loop if an endOfSegment has been found (because the largest lines only have 7
      // positions on the board, there
      // can't be more than one set of four pieces of the same color (requiring at least 9
      // positions) on the board.
      for (;
          endOfSegment == null && isPositionOnPlayAreaOrOuterDots(currentPosition);
          currentPosition = currentPosition.next(direction)) {
        PieceColor currentPieceColor =
            pieceMap.containsKey(currentPosition)
                ? pieceMap.get(currentPosition).getPieceColor()
                : null;

        // Update the consecutivePieces
        if (currentPieceColor == pieceColor) consecutivePieces++;
        if (consecutivePieces == 4) isInLineSegment = true;
        if (currentPieceColor != pieceColor) consecutivePieces = 0;

        if (isInLineSegment) {
          if (isDotPosition(currentPosition) || currentPieceColor == null) {
            endOfSegment = currentPosition.previous(direction);
          }
        }

        // Update the startOfSegment if necessary
        if (startOfSegment == null) {
          if (currentPieceColor != null) {
            startOfSegment = currentPosition;
          }
        }
        if (currentPieceColor == null && endOfSegment == null) {
          startOfSegment = null;
        }

        // Add a line segment to the list if we have found one
        if (endOfSegment != null) {
          removableLines.add(new Line.Segment(this, startOfSegment, endOfSegment, direction));
        }
      }
    }

    return removableLines;
  }
 void removeText() {
   if ((p0 != null) && (p1 != null) && (p0.getOffset() != p1.getOffset())) {
     try {
       Document doc = c.getDocument();
       doc.remove(p0.getOffset(), p1.getOffset() - p0.getOffset());
     } catch (BadLocationException e) {
     }
   }
 }
示例#7
0
    private void populate() {
      // set up for a new population
      Vector oldPop = this.positions;
      this.positions = new Vector(50, 50);

      // first browse the old population and make changes
      for (int i = 0; i < oldPop.size(); i++) {
        Position a = (Position) oldPop.get(i);
        if (a.symPosNo < this.symPos.length) {
          Point3d sPos = this.symPos[a.symPosNo];
          if (sPos != null) {
            Point3d newPos = new Point3d(sPos);
            newPos.add(a.expandTranslation);
            if (this.isPosInBounds(newPos)
                && Model3d.this.getAtomHere(this.positions, newPos) == null) {
              a.changePos(newPos);
              this.positions.add(a);
              // System.out.println("move "+a);
              continue;
            }
          }
        }
        // invalid, duplicate or out of bounds, remove
        // System.out.println("del "+a);
        a.del();
      }

      // now add potentially new appeared atoms
      for (double i = -Math.ceil(Model3d.this.exm - 1);
          i <= Math.floor(Model3d.this.exp + 1) + 1;
          i++)
        for (double j = -Math.ceil(Model3d.this.eym - 1);
            j <= Math.floor(Model3d.this.eyp + 1) + 1;
            j++)
          for (double k = -Math.ceil(Model3d.this.ezm - 1);
              k <= Math.floor(Model3d.this.ezp + 1) + 1;
              k++) {
            Vector3d v = new Vector3d(i, j, k);
            for (int l = 0; l < this.symPos.length; l++) {
              if (this.symPos[l] == null) continue;
              Point3d p = new Point3d(this.symPos[l]);
              p.add(v);
              // TODO
              if (this.isPosInBounds(p) && Model3d.this.getAtomHere(this.positions, p) == null) {
                // if (isPosInBounds(round(p)) &&
                // getAtomHere(positions, p)==null) {
                Position a =
                    new Position(this.root, this, p, v, this.radius, this.color, l, !this.hidden);
                this.positions.add(a);
                // if (!isPosInBounds(p))System.out.println("xx
                // "+p);
              }
            }
          }
    }
 public void onSuccess(Position[] positions) {
   for (Position p : positions) {
     Logging.logger()
         .info(
             p.getLatitude().degrees
                 + ","
                 + p.getLongitude().degrees
                 + " --> "
                 + p.getElevation());
   }
 }
    private void fillPointsPanel() {
      int i = 0;
      for (Position pos : lineBuilder.getLine().getPositions()) {
        if (i == this.pointLabels.length) break;

        String las = String.format("Lat %7.4f\u00B0", pos.getLatitude().getDegrees());
        String los = String.format("Lon %7.4f\u00B0", pos.getLongitude().getDegrees());
        pointLabels[i++].setText(las + "  " + los);
      }
      for (; i < this.pointLabels.length; i++) pointLabels[i++].setText("");
    }
    protected void showIntersections(List<Position> intersections) {
      this.intersectionsLayer.removeAllRenderables();

      // Display the intersections as CYAN points.
      PointPlacemarkAttributes intersectionPointAttributes;
      intersectionPointAttributes = new PointPlacemarkAttributes();
      intersectionPointAttributes.setLineMaterial(Material.CYAN);
      intersectionPointAttributes.setScale(6d);
      intersectionPointAttributes.setUsePointAsDefaultImage(true);

      for (Position p : intersections) {
        PointPlacemark pm = new PointPlacemark(p);
        pm.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
        pm.setAttributes(intersectionPointAttributes);
        pm.setValue(AVKey.DISPLAY_NAME, p.toString());
        this.intersectionsLayer.addRenderable(pm);
      }
    }
 static {
   path = new ArrayList<Position>();
   path.add(Position.fromDegrees(0, 0, 1e5));
   path.add(Position.fromDegrees(0, 10, 1e5));
   path.add(Position.fromDegrees(0, 20, 1e5));
   path.add(Position.fromDegrees(0, 30, 1e5));
   path.add(Position.fromDegrees(0, 40, 1e5));
   path.add(Position.fromDegrees(0, 50, 1e5));
   path.add(Position.fromDegrees(0, 60, 1e5));
   path.add(Position.fromDegrees(0, 70, 1e5));
 }
    protected void performIntersectionTests(final Position curPos) throws InterruptedException {
      // Clear the results lists when the user selects a new location.
      this.firstIntersectionPositions.clear();
      this.sightLines.clear();

      // Raise the selected location and the grid points a little above ground just to show we can.
      final double height = 5; // meters

      // Form the grid.
      double gridRadius = GRID_RADIUS.degrees;
      Sector sector =
          Sector.fromDegrees(
              curPos.getLatitude().degrees - gridRadius, curPos.getLatitude().degrees + gridRadius,
              curPos.getLongitude().degrees - gridRadius,
                  curPos.getLongitude().degrees + gridRadius);

      this.grid = buildGrid(sector, height, GRID_DIMENSION, GRID_DIMENSION);
      this.numGridPoints = grid.size();

      // Compute the position of the selected location (incorporate its height).
      this.referencePosition = new Position(curPos.getLatitude(), curPos.getLongitude(), height);
      this.referencePoint =
          terrain.getSurfacePoint(curPos.getLatitude(), curPos.getLongitude(), height);

      //            // Pre-caching is unnecessary and is useful only when it occurs before the
      // intersection
      //            // calculations. It will incur extra overhead otherwise. The normal intersection
      // calculations
      //            // cause the same caching, making subsequent calculations on the same area
      // faster.
      //            this.preCache(grid, this.referencePosition);

      // On the EDT, show the grid.
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              progressBar.setValue(0);
              progressBar.setString(null);
              clearLayers();
              showGrid(grid, referencePosition);
              getWwd().redraw();
            }
          });

      // Perform the intersection calculations.
      this.startTime = System.currentTimeMillis();
      for (Position gridPos : this.grid) // for each grid point.
      {
        //noinspection ConstantConditions
        if (NUM_THREADS > 0) this.threadPool.execute(new Intersector(gridPos));
        else performIntersection(gridPos);
      }
    }
    protected void showGrid(List<Position> grid, Position cPos) {
      this.gridLayer.removeAllRenderables();

      // Display the grid points in yellow.
      PointPlacemarkAttributes gridPointAttributes;
      gridPointAttributes = new PointPlacemarkAttributes();
      gridPointAttributes.setLineMaterial(Material.YELLOW);
      gridPointAttributes.setScale(6d);
      gridPointAttributes.setUsePointAsDefaultImage(true);

      for (Position p : grid) {
        PointPlacemark pm = new PointPlacemark(p);
        pm.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
        pm.setAttributes(gridPointAttributes);
        pm.setLineEnabled(true);
        pm.setValue(AVKey.DISPLAY_NAME, p.toString());
        this.gridLayer.addRenderable(pm);
      }

      showCenterPoint(cPos);
    }
 // Remove the old text if the action is a MOVE.
 // However, we do not allow dropping on top of the selected text, so in that case do nothing.
 protected void exportDone(JComponent c, Transferable data, int action) {
   if (c != textComponent) { // ###
     System.out.println("*** exportDone(): c=" + c);
   }
   System.out.println(
       ">>> exportDone(): action="
           + action
           + ", MOVE="
           + MOVE
           + ", shouldRemove="
           + shouldRemove);
   if (shouldRemove && (action == MOVE)) {
     if ((p0 != null) && (p1 != null) && (p0.getOffset() != p1.getOffset())) {
       try {
         textComponent.getDocument().remove(p0.getOffset(), p1.getOffset() - p0.getOffset());
       } catch (BadLocationException e) {
         System.out.println("*** exportDone(): Can't remove text from source.");
       }
     }
   }
   source = null;
 }
    protected void showGridSightLines(List<Position> grid, Position cPos) {
      this.sightLinesLayer.removeAllRenderables();

      // Display lines from the center to each grid point.
      ShapeAttributes lineAttributes;
      lineAttributes = new BasicShapeAttributes();
      lineAttributes.setDrawOutline(true);
      lineAttributes.setDrawInterior(false);
      lineAttributes.setOutlineMaterial(Material.GREEN);
      lineAttributes.setOutlineOpacity(0.6);

      for (Position p : grid) {
        List<Position> endPoints = new ArrayList<Position>();
        endPoints.add(cPos);
        endPoints.add(new Position(p.getLatitude(), p.getLongitude(), 0));

        Path path = new Path(endPoints);
        path.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
        path.setAttributes(lineAttributes);
        this.sightLinesLayer.addRenderable(path);
      }
    }
示例#16
0
 /**
  * Calculates distance from this position to given position.
  *
  * @param pos Compared position
  * @return Distance
  */
 public double getDistanceTo(Position pos) {
   return Math.sqrt(
       Math.abs(coords[0] - pos.getXCoordinate()) * Math.abs(coords[0] - pos.getXCoordinate())
           + Math.abs(coords[1] - pos.getYCoordinate())
               * Math.abs(coords[1] - pos.getYCoordinate())
           + Math.abs(coords[2] - pos.getZCoordinate())
               * Math.abs(coords[2] - pos.getZCoordinate()));
 }
    protected void showCenterPoint(Position cPos) {
      // Display the center point in red.
      PointPlacemarkAttributes selectedLocationAttributes;
      selectedLocationAttributes = new PointPlacemarkAttributes();
      selectedLocationAttributes.setLineMaterial(Material.RED);
      selectedLocationAttributes.setScale(8d);
      selectedLocationAttributes.setUsePointAsDefaultImage(true);

      PointPlacemark pm = new PointPlacemark(cPos);
      pm.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      pm.setAttributes(selectedLocationAttributes);
      pm.setValue(AVKey.DISPLAY_NAME, cPos.toString());
      pm.setLineEnabled(true);
      this.gridLayer.addRenderable(pm);
    }
示例#18
0
    private Info[] buildFreeShapes() {
      double elevation = 10e3;
      ArrayList<Position> positions = new ArrayList<Position>();
      positions.add(
          new Position(Angle.fromDegrees(37.8484), Angle.fromDegrees(-119.9754), elevation));
      positions.add(
          new Position(Angle.fromDegrees(39.3540), Angle.fromDegrees(-110.1526), elevation));
      positions.add(
          new Position(Angle.fromDegrees(38.3540), Angle.fromDegrees(-100.1526), elevation));

      ArrayList<Position> positions2 = new ArrayList<Position>();
      positions2.add(new Position(Angle.fromDegrees(0), Angle.fromDegrees(-150), elevation));
      positions2.add(new Position(Angle.fromDegrees(25), Angle.fromDegrees(-75), elevation));
      positions2.add(new Position(Angle.fromDegrees(50), Angle.fromDegrees(0), elevation));

      ArrayList<Position> positions3 = new ArrayList<Position>();
      for (double lat = 42, lon = -100; lat <= 45; lat += .1, lon += .1) {
        positions3.add(new Position(Angle.fromDegrees(lat), Angle.fromDegrees(lon), elevation));
      }

      ArrayList<Position> positions4 = new ArrayList<Position>();
      positions4.add(new Position(Angle.fromDegrees(90), Angle.fromDegrees(-110), elevation));
      positions4.add(new Position(Angle.fromDegrees(-90), Angle.fromDegrees(-110), elevation));

      ArrayList<Position> positions5 = new ArrayList<Position>();
      for (int i = 0; i < 100; i++) {
        positions5.add(
            Position.fromDegrees(38.0 + i * 0.0001, 30.0 + i * 0.0001, 1000.0 + i * 5.0));
      }

      @SuppressWarnings({"UnnecessaryLocalVariable"})
      Info[] infos =
          new Info[] {
            new Info("Short Path", new Polyline(positions)),
            new Info("Long Path", new Polyline(positions2)),
            new Info("Incremental Path", new Polyline(positions3)),
            new Info("Vertical Path", new Polyline(positions4)),
            new Info("Small-segment Path", new Polyline(positions5)),
            new Info("Quad", new Quadrilateral(Sector.fromDegrees(38, 40, -104, -105), elevation)),
            new Info("None", null)
          };

      return infos;
    }
    protected List<Position> buildGrid(Sector sector, double height, int nLatCells, int nLonCells) {
      List<Position> grid = new ArrayList<Position>((nLatCells + 1) * (nLonCells + 1));

      double dLat = sector.getDeltaLatDegrees() / nLatCells;
      double dLon = sector.getDeltaLonDegrees() / nLonCells;

      for (int j = 0; j <= nLatCells; j++) {
        double lat =
            j == nLatCells
                ? sector.getMaxLatitude().degrees
                : sector.getMinLatitude().degrees + j * dLat;

        for (int i = 0; i <= nLonCells; i++) {
          double lon =
              i == nLonCells
                  ? sector.getMaxLongitude().degrees
                  : sector.getMinLongitude().degrees + i * dLon;

          grid.add(Position.fromDegrees(lat, lon, height));
        }
      }

      return grid;
    }
  private void findEdges(int startRow, int endRow) {
    int gridSize = grid.size();
    int sizeOfArrays = grid.get(0).size();
    for (int i = startRow; i < endRow; i++) {

      for (int j = 0; j < sizeOfArrays; j++) {

        Position currentPosition = grid.get(i).get(j);
        int current = currentPosition.value;
        int min = current;
        Position minP = currentPosition;

        if (i - 1 >= 0) {
          Position north = grid.get(i - 1).get(j);
          if (north.value < min) {
            min = north.value;
            minP = north;
          }
        }

        if (i - 1 >= 0 && j - 1 >= 0) {
          Position northWest = grid.get(i - 1).get(j - 1);
          if (northWest.value < min) {
            min = northWest.value;
            minP = northWest;
          }
        }

        if (j - 1 >= 0) {
          Position west = grid.get(i).get(j - 1);
          if (west.value < min) {
            min = west.value;
            minP = west;
          }
        }
        if (i + 1 < gridSize && j - 1 >= 0) {
          Position southWest = grid.get(i + 1).get(j - 1);
          if (southWest.value < min) {
            min = southWest.value;
            minP = southWest;
          }
        }
        if (i + 1 < gridSize) {
          Position south = grid.get(i + 1).get(j);
          if (south.value < min) {
            min = south.value;
            minP = south;
          }
        }
        if (i + 1 < gridSize && j + 1 < sizeOfArrays) {
          Position southEast = grid.get(i + 1).get(j + 1);
          if (southEast.value < min) {
            min = southEast.value;
            minP = southEast;
          }
        }
        if (j + 1 < sizeOfArrays) {
          Position east = grid.get(i).get(j + 1);

          if (east.value < min) {
            min = east.value;
            minP = east;
          }
        }

        if (i - 1 >= 0 && j + 1 < sizeOfArrays) {
          Position northEast = grid.get(i - 1).get(j + 1);
          if (northEast.value < min) {
            min = northEast.value;
            minP = northEast;
          }
        }

        if (currentPosition.equals(minP)) {
        } else {
          synchronized (graph) {
            graph.addEdge(currentPosition, minP);
          }
        }
      }
    }
  }
示例#21
0
    public AppFrame() {
      super(true, true, false);

      // Add detail hint slider panel
      this.getLayerPanel().add(makeDetailHintControlPanel(), BorderLayout.SOUTH);

      RenderableLayer layer = new RenderableLayer();

      // Create and set an attribute bundle.
      ShapeAttributes attrs = new BasicShapeAttributes();
      attrs.setInteriorMaterial(Material.YELLOW);
      attrs.setInteriorOpacity(0.7);
      attrs.setEnableLighting(true);
      attrs.setOutlineMaterial(Material.RED);
      attrs.setOutlineWidth(2d);
      attrs.setDrawInterior(true);
      attrs.setDrawOutline(false);

      // Create and set an attribute bundle.
      ShapeAttributes attrs2 = new BasicShapeAttributes();
      attrs2.setInteriorMaterial(Material.PINK);
      attrs2.setInteriorOpacity(1);
      attrs2.setEnableLighting(true);
      attrs2.setOutlineMaterial(Material.WHITE);
      attrs2.setOutlineWidth(2d);
      attrs2.setDrawOutline(false);

      // ********* sample  Wedges  *******************

      // Wedge with equal axes, ABSOLUTE altitude mode
      Wedge wedge3 =
          new Wedge(Position.fromDegrees(40, -120, 80000), Angle.POS90, 50000, 50000, 50000);
      wedge3.setAltitudeMode(WorldWind.ABSOLUTE);
      wedge3.setAttributes(attrs);
      wedge3.setVisible(true);
      wedge3.setValue(AVKey.DISPLAY_NAME, "Wedge with equal axes, ABSOLUTE altitude mode");
      layer.addRenderable(wedge3);

      // Wedge with equal axes, RELATIVE_TO_GROUND
      Wedge wedge4 =
          new Wedge(Position.fromDegrees(37.5, -115, 50000), Angle.POS90, 50000, 50000, 50000);
      wedge4.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      wedge4.setAttributes(attrs);
      wedge4.setVisible(true);
      wedge4.setValue(
          AVKey.DISPLAY_NAME, "Wedge with equal axes, RELATIVE_TO_GROUND altitude mode");
      layer.addRenderable(wedge4);

      // Wedge with equal axes, CLAMP_TO_GROUND
      Wedge wedge5 =
          new Wedge(Position.fromDegrees(35, -110, 50000), Angle.POS90, 50000, 50000, 50000);
      wedge5.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
      wedge5.setAttributes(attrs);
      wedge5.setVisible(true);
      wedge5.setValue(AVKey.DISPLAY_NAME, "Wedge with equal axes, CLAMP_TO_GROUND altitude mode");
      layer.addRenderable(wedge5);

      // Wedge with a texture, using Wedge(position, angle, height, radius) constructor
      Wedge wedge9 =
          new Wedge(Position.fromDegrees(0, -90, 600000), Angle.fromDegrees(225), 1200000, 600000);
      wedge9.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      wedge9.setImageSources("gov/nasa/worldwindx/examples/images/500px-Checkerboard_pattern.png");
      wedge9.setAttributes(attrs);
      wedge9.setVisible(true);
      wedge9.setValue(AVKey.DISPLAY_NAME, "Wedge with a texture");
      layer.addRenderable(wedge9);

      // Scaled Wedge with default orientation
      Wedge wedge = new Wedge(Position.ZERO, Angle.fromDegrees(125), 500000, 500000, 500000);
      wedge.setAltitudeMode(WorldWind.ABSOLUTE);
      wedge.setAttributes(attrs);
      wedge.setVisible(true);
      wedge.setValue(AVKey.DISPLAY_NAME, "Scaled Wedge with default orientation");
      layer.addRenderable(wedge);

      // Scaled Wedge with a pre-set orientation
      Wedge wedge2 =
          new Wedge(
              Position.fromDegrees(0, 30, 750000),
              Angle.POS90,
              500000,
              500000,
              500000,
              Angle.fromDegrees(90),
              Angle.fromDegrees(45),
              Angle.fromDegrees(30));
      wedge2.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      wedge2.setAttributes(attrs2);
      wedge2.setVisible(true);
      wedge2.setValue(AVKey.DISPLAY_NAME, "Scaled Wedge with a pre-set orientation");
      layer.addRenderable(wedge2);

      // Scaled Wedge with a pre-set orientation
      Wedge wedge6 =
          new Wedge(
              Position.fromDegrees(30, 30, 750000),
              Angle.POS90,
              500000,
              500000,
              500000,
              Angle.fromDegrees(90),
              Angle.fromDegrees(45),
              Angle.fromDegrees(30));
      wedge6.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      wedge6.setImageSources("gov/nasa/worldwindx/examples/images/500px-Checkerboard_pattern.png");
      wedge6.setAttributes(attrs2);
      wedge6.setVisible(true);
      wedge6.setValue(AVKey.DISPLAY_NAME, "Scaled Wedge with a pre-set orientation");
      layer.addRenderable(wedge6);

      // Scaled Wedge with a pre-set orientation
      Wedge wedge7 =
          new Wedge(
              Position.fromDegrees(60, 30, 750000),
              Angle.POS90,
              500000,
              500000,
              500000,
              Angle.fromDegrees(90),
              Angle.fromDegrees(45),
              Angle.fromDegrees(30));
      wedge7.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      wedge7.setAttributes(attrs2);
      wedge7.setVisible(true);
      wedge7.setValue(AVKey.DISPLAY_NAME, "Scaled Wedge with a pre-set orientation");
      layer.addRenderable(wedge7);

      // Scaled, oriented Wedge in 3rd "quadrant" (-X, -Y, -Z)
      Wedge wedge8 =
          new Wedge(
              Position.fromDegrees(-45, -180, 750000),
              Angle.POS90,
              500000,
              1000000,
              500000,
              Angle.fromDegrees(90),
              Angle.fromDegrees(45),
              Angle.fromDegrees(30));
      wedge8.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      wedge8.setAttributes(attrs2);
      wedge8.setVisible(true);
      wedge8.setValue(
          AVKey.DISPLAY_NAME, "Scaled, oriented Wedge with in the 3rd 'quadrant' (-X, -Y, -Z)");
      layer.addRenderable(wedge8);

      // Add the layer to the model.
      insertBeforeCompass(getWwd(), layer);

      // Update layer panel
      this.getLayerPanel().update(this.getWwd());
    }
 public boolean importData(JComponent c, Transferable t) {
   if (c != textComponent) { // ### never happens, we dont share transfer handlers
     System.out.println("*** importData(): c=" + c);
   }
   try {
     DataFlavor[] flavors = t.getTransferDataFlavors();
     boolean hasStringFlavor = t.isDataFlavorSupported(DataFlavor.stringFlavor);
     boolean hasImageFlavor = t.isDataFlavorSupported(DataFlavor.imageFlavor);
     boolean hasFilelistFlavor = t.isDataFlavorSupported(DataFlavor.javaFileListFlavor);
     //
     System.out.println(">>> import data to text panel (" + flavors.length + " flavors)");
     // ### for (int i = 0; i < flavors.length; i++) {
     // ###	System.out.println(flavors[i]);
     // ###}
     System.out.println("  >   string flavor supported: " + hasStringFlavor);
     System.out.println("  >    image flavor supported: " + hasImageFlavor);
     System.out.println("  > filelist flavor supported: " + hasFilelistFlavor);
     //
     // We do not allow dropping on top of the selected text
     if ((source == textComponent)
         && (textComponent.getCaretPosition() >= p0.getOffset())
         && (textComponent.getCaretPosition() <= p1.getOffset())) {
       shouldRemove = false;
       System.out.println(
           ">>> dropping on top of the selected text is not allowed -- import canceled");
       return true;
     }
     //
     if (hasStringFlavor) {
       String data = (String) t.getTransferData(DataFlavor.stringFlavor);
       int pos = textComponent.getCaretPosition();
       if (DeepaMehtaUtils.isImage(data)) {
         HTMLEditorKit kit = (HTMLEditorKit) ((JEditorPane) textComponent).getEditorKit();
         HTMLDocument doc = (HTMLDocument) textComponent.getDocument();
         String html = "<img src=\"" + data + "\"></img>";
         kit.insertHTML(doc, pos, html, 0, 0, HTML.Tag.IMG); // ### <img> not XML conform
         // ### doc.insertBeforeStart(doc.getParagraphElement(pos), html);
         System.out.println(">>> IMG tag inserted: \"" + html + "\"");
       } else {
         textComponent.getDocument().insertString(pos, data, null);
         System.out.println(">>> regular text inserted: \"" + data + "\"");
       }
     } else if (hasFilelistFlavor) {
       java.util.List files = (java.util.List) t.getTransferData(DataFlavor.javaFileListFlavor);
       System.out.println("    " + files.size() + " files:");
       for (int i = 0; i < files.size(); i++) {
         File file = (File) files.get(i);
         String filename = file.getName();
         System.out.println("    " + file);
         if (DeepaMehtaUtils.isHTML(filename)) {
           String html = DeepaMehtaUtils.readFile(file);
           textComponent.setText(html); // ### replace instead insert
           textComponent.setCaretPosition(0);
           // ### ((JEditorPane) textComponent).setPage("file://" + file);	// ### replace instead
           // insert
           // ### setDirty("dropping HTML file");
           System.out.println(">>> HTML inserted (read from file)");
           break; // ### max one file is inserted
         } else if (DeepaMehtaUtils.isImage(filename)) {
           HTMLEditorKit kit = (HTMLEditorKit) ((JEditorPane) textComponent).getEditorKit();
           HTMLDocument doc = (HTMLDocument) textComponent.getDocument();
           int pos = textComponent.getCaretPosition();
           String imagefile = file.getPath().replace('\\', '/'); // ###
           String html = "<img src=\"" + imagefile + "\"></img>";
           kit.insertHTML(doc, pos, html, 0, 0, HTML.Tag.IMG); // ### <img> not XML conform
           // ### doc.insertBeforeStart(doc.getParagraphElement(pos), html);
           System.out.println(">>> IMG tag inserted: \"" + html + "\"");
         } else {
           System.out.println(
               "### importData(): only implemented for HTML files -- import canceled");
         }
       }
     } else {
       System.out.println("*** importData(): no supported flavor " + c);
     }
     return true;
   } catch (UnsupportedFlavorException ufe) {
     System.out.println("*** while dropping to text panel: " + ufe);
   } catch (BadLocationException ble) {
     System.out.println("*** while dropping to text panel: " + ble);
   } catch (IOException ioe) {
     System.out.println("*** while dropping to text panel: " + ioe);
   }
   //
   return super.importData(c, t);
 }