Ejemplo n.º 1
0
  @SuppressWarnings("rawtypes")
  public void createText(
      final CoverageTable c,
      final TextTable texttable,
      final Vector textvec,
      final float latitude,
      final float longitude,
      final String text,
      final String featureType) {
    counter++;

    // get the colour
    final java.awt.Color res = getColor(featureType);

    // set the colour
    _myCanvas.setColor(res);

    // find the screen location
    _workingLocation.setLat(latitude);
    _workingLocation.setLong(longitude);
    final java.awt.Point pt = _myCanvas.toScreen(_workingLocation);

    // and plot it
    _myCanvas.drawText(text, pt.x, pt.y);
  }
Ejemplo n.º 2
0
  @SuppressWarnings("rawtypes")
  public void createText(
      final CoverageTable c,
      final TextTable texttable,
      final Vector textvec,
      final float latitude,
      final float longitude,
      final String text) {

    // is the current painter interested in text?
    if (_drawText != null) {
      final boolean res = _drawText.booleanValue();
      if (!res) return;
    } else {
      // hey the client hasn't set a preference, so lets just paint anyway
    }

    // set the colour
    _myCanvas.setColor(getColor(null));

    // find the screen location
    _workingLocation.setLat(latitude);
    _workingLocation.setLong(longitude);

    counter++;

    // convert to screen coordinates
    final java.awt.Point pt = _myCanvas.toScreen(_workingLocation);

    // and plot it
    _myCanvas.drawText(text, pt.x, pt.y);
  }
Ejemplo n.º 3
0
  /**
   * Edge painter. In this implementation we build the edges up into a polygon which we then plot -
   * this works much more quickly and is an option because we get the edges in the correctly tiled
   * order.
   *
   * @param c parameter for createEdge
   * @param edgevec parameter for createEdge
   * @param ll2 parameter for createEdge
   * @param dpplon parameter for createEdge
   * @param coords list of coordinates which make up this edge
   * @param featureType the type for this feature
   */
  @SuppressWarnings("rawtypes")
  public void createEdge(
      final CoverageTable c,
      final EdgeTable edgetable,
      final Vector edgevec,
      final LatLonPoint ll1,
      final LatLonPoint ll2,
      final float dpplat,
      final float dpplon,
      final CoordFloatString coords,
      final String featureType) {

    // get this feature painter
    final FeaturePainter fp = _currentFeatures.get(featureType);

    // is this feature currently visible?
    if (!fp.getVisible()) return;

    // is this line currently visible?
    if (!isVisible(ll1, ll2, coords)) return;

    // get the colour
    final java.awt.Color res = fp.getColor();

    if (res == null) {
      System.out.println(" not painting!");
      return;
    }

    // set the colour
    _myCanvas.setColor(res);

    // now plot the polygon
    final int len = coords.maxIndex();
    final int[] points = new int[len * 2];

    counter++;

    try {
      for (int i = 0; i < len; i++) {
        final float x = coords.getXasFloat(i);
        final float y = coords.getYasFloat(i);

        _workingLocation.setLat(y);
        _workingLocation.setLong(x);
        final java.awt.Point pt = _myCanvas.toScreen(_workingLocation);

        points[i * 2] = pt.x;
        points[i * 2 + 1] = pt.y;
      }

      // finally plot the polygon
      _myCanvas.drawPolyline(points);
    } catch (final Exception E) {
      E.printStackTrace();
    }
  }
Ejemplo n.º 4
0
  /**
   * edge plotter for when we're not plotting by features this is really only used for coastlines -
   * which aren't tiled. We can't build up the coastline into a single large polyline, since it
   * jumps around a little!
   */
  @SuppressWarnings("rawtypes")
  public void createEdge(
      final CoverageTable c,
      final EdgeTable edgetable,
      final Vector edgevec,
      final LatLonPoint ll1,
      final LatLonPoint ll2,
      final float dpplat,
      final float dpplon,
      final CoordFloatString coords) {

    // is the current painter interested in text?
    if (_drawLines != null) {
      final boolean res = _drawLines.booleanValue();
      if (!res) return;
    } else {
      // hey the client hasn't set a preference, so lets just paint anyway
    }

    // is this line currently visible?
    if (!isVisible(ll1, ll2, coords)) return;

    // get the colour
    final java.awt.Color res = getColor(null);

    // set the colour
    _myCanvas.setColor(res);

    // now plot the polygon
    final int len = coords.maxIndex();
    java.awt.Point _lastPoint = null;

    // create working location
    try {
      for (int i = 0; i < len; i++) {
        final float x = coords.getXasFloat(i);
        final float y = coords.getYasFloat(i);

        _workingLocation.setLat(y);
        _workingLocation.setLong(x);
        final java.awt.Point pt = _myCanvas.toScreen(_workingLocation);

        // xpoints[i] = pt.x;
        // ypoints[i] = pt.y;
        if (_lastPoint != null) {
          _myCanvas.drawLine(_lastPoint.x, _lastPoint.y, pt.x, pt.y);
        }

        _lastPoint = new java.awt.Point(pt);
      }

      // finally plot the polygon
      // _myCanvas.drawPolygon(xpoints, ypoints, len);
    } catch (final Exception E) {
      E.printStackTrace();
    }
  }
Ejemplo n.º 5
0
  /**
   * createArea
   *
   * @param covtable parameter for createArea
   * @param facevec parameter for createArea
   * @param ll2 parameter for createArea
   * @param dpplon parameter for createArea
   * @param featureType the type of feature we are plotting
   */
  @SuppressWarnings({"rawtypes"})
  public void createArea(
      final CoverageTable covtable,
      final AreaTable areatable,
      final Vector facevec,
      final LatLonPoint ll1,
      final LatLonPoint ll2,
      final float dpplat,
      final float dpplon,
      final boolean doAntarcticaWorkaround,
      final String featureType) {

    final Vector ipts = new Vector();

    // get the algorithm to collate the edge points for the polygon
    int totalSize = 0;
    try {
      totalSize = areatable.computeEdgePoints(facevec, ipts);
    } catch (final com.bbn.openmap.io.FormatException f) {
      f.printStackTrace();
      return;
    }

    // find out if any of the edges are in our area
    boolean worth_it = false;

    // area any of these shapes within our area?
    final Enumeration theEdges = ipts.elements();

    //
    while (theEdges.hasMoreElements()) {
      final CoordFloatString cfs = (CoordFloatString) theEdges.nextElement();

      if (overlaps(ll1, ll2, cfs)) {
        worth_it = true;
        continue;
      }
    }

    // do we have any valid data?
    if (!worth_it) {
      // no, so drop out
      return;
    }

    // get the colour
    final java.awt.Color res = getColor(featureType);

    // set the colour
    _myCanvas.setColor(res);

    // convert the group of lines into a single polygon
    final java.awt.Polygon poly =
        extendArea(ipts, totalSize, ll1, ll2, dpplat, dpplon, false, _myCanvas.getProjection());

    // increment the shape counter
    counter++;

    // end of stepping through the areas
    _myCanvas.fillPolygon(poly.xpoints, poly.ypoints, poly.xpoints.length);
  }