/**
   * Split a long line into several lines.
   *
   * @param origLine the original line
   * @return a string with new-line characters at the line-split locations.
   */
  protected String splitLine(String origLine) {
    StringBuilder newLines = new StringBuilder();

    // Determine the line's current indent. Any indent added below must be added to it.
    String currentIndent = "";
    for (int i = 0; i < origLine.length(); i++) {
      if (origLine.charAt(i) == '\u00a0') currentIndent += HARD_SPACE;
      else break;
    }

    // Add the words of the line to a line builder until adding a word would exceed the max allowed
    // length.
    StringBuilder line = new StringBuilder(currentIndent);
    String[] words = Util.splitWords(origLine, "[\u00a0 ]"); // either hard or soft space
    for (String word : words) {
      if (line.length() + 1 + word.length() + currentIndent.length() > this.maxLineLength) {
        if (newLines.length() == 0) currentIndent += INDENT; // indent continuation lines
        newLines.append(line.toString());
        line = new StringBuilder("\n").append(currentIndent);
      }

      // Add a space in front of the word if it's not the first word.
      if (!line.toString().endsWith(HARD_SPACE)) line.append(HARD_SPACE);
      line.append(word);
    }

    // Add the final words to the split lines.
    if (line.length() > 1) newLines.append(line.toString());

    return newLines.toString();
  }
 @Override
 protected String getGraphicLabel() {
   StringBuilder sb = new StringBuilder();
   if (this.mustShowHostileIndicator()) {
     sb.append(SymbologyConstants.HOSTILE_ENEMY);
     sb.append("\n");
   }
   return sb.toString();
 }
Пример #3
0
  /**
   * Indicates the text of this label.
   *
   * @return The label's text.
   */
  public String getText() {
    if (this.lines != null) {
      StringBuilder sb = new StringBuilder();

      for (int i = 0; i < this.lines.length - 1; i++) {
        sb.append(this.lines[i]).append("\n");
      }
      sb.append(this.lines[this.lines.length - 1]);

      return sb.toString();
    }

    return null;
  }
    @Override
    protected ByteBuffer handleXMLContent() throws IOException {
      // Check for an exception report
      String s = WWIO.byteBufferToString(this.getRetriever().getBuffer(), 1024, null);
      if (s.contains("<ExceptionReport>")) {
        // TODO: Parse the xml and include only the message text in the log message.

        StringBuilder sb = new StringBuilder(this.getRetriever().getName());

        sb.append("\n");
        sb.append(WWIO.byteBufferToString(this.getRetriever().getBuffer(), 2048, null));
        Logging.logger().warning(sb.toString());

        return null;
      }

      this.saveBuffer();

      return this.getRetriever().getBuffer();
    }
  /**
   * Split a collection of lines into a new collection whose lines are all less than the maximum
   * allowed line length.
   *
   * @param origText the original lines.
   * @return the new lines.
   */
  protected String splitLines(String origText) {
    StringBuilder newText = new StringBuilder();

    String[] lines = Util.splitLines(origText);
    for (String line : lines) {
      // Append the line to the output buffer if it's within size, other wise split it and append
      // the result.
      newText
          .append(line.length() <= this.maxLineLength ? line : this.splitLine(line))
          .append("\n");
    }

    return newText.toString();
  }
    @SuppressWarnings({"StringEquality"})
    public void characters(char ch[], int start, int length) {
      if (!this.inBeginEndPair) return;

      // Top of QName stack is an interned string,
      // so we can use pointer comparison.
      String internedTopQName = this.internedQNameStack.getFirst();

      StringBuilder sb = null;
      if (TOPP_LATITUDE == internedTopQName) sb = this.latBuffer;
      else if (TOPP_LONGITUDE == internedTopQName) sb = this.lonBuffer;
      else if (TOPP_FULL_NAME_ND == internedTopQName) sb = this.textArray;

      if (sb != null) sb.append(ch, start, length);
    }
Пример #7
0
  protected String formatMeasurements(Position pos) {
    StringBuilder sb = new StringBuilder();

    /*
     //sb.append(this.unitsFormat.areaNL(this.getLabel(AREA_LABEL), this.getArea()));
     sb.append(this.unitsFormat.lengthNL(this.getLabel(PERIMETER_LABEL), this.getLength()));
    */

    // sb.append(this.unitsFormat.lengthNL(this.getLabel(WIDTH_LABEL),
    // this.shape.getEastWestRadius() * 2));
    // sb.append(this.unitsFormat.lengthNL(this.getLabel(LENGTH_LABEL),
    // this.shape.getNorthSouthRadius() * 2));
    // sb.append(this.unitsFormat.lengthNL(this.getLabel(HEIGHT_LABEL),
    // this.shape.getVerticalRadius() * 2));

    // sb.append(this.unitsFormat.angleNL(this.getLabel(HEADING_LABEL), this.shape.getHeading()));

    // if "activeControlPoint" is in fact one of the control points
    if (!this.arePositionsRedundant(pos, this.polygon.getReferencePosition())) {
      sb.append(this.unitsFormat.angleNL(this.getLabel(LATITUDE_LABEL), pos.getLatitude()));
      sb.append(this.unitsFormat.angleNL(this.getLabel(LONGITUDE_LABEL), pos.getLongitude()));
      sb.append(this.unitsFormat.lengthNL(this.getLabel(ALTITUDE_LABEL), pos.getAltitude()));
    }

    // if "activeControlPoint" is the shape itself
    if (this.polygon.getReferencePosition() != null) {
      sb.append(
          this.unitsFormat.angleNL(
              this.getLabel(CENTER_LATITUDE_LABEL),
              this.polygon.getReferencePosition().getLatitude()));
      sb.append(
          this.unitsFormat.angleNL(
              this.getLabel(CENTER_LONGITUDE_LABEL),
              this.polygon.getReferencePosition().getLongitude()));
      sb.append(
          this.unitsFormat.lengthNL(
              this.getLabel(CENTER_ALTITUDE_LABEL),
              this.polygon.getReferencePosition().getAltitude()));
    }

    return sb.toString();
  }
 public String toString() {
   StringBuilder sb = new StringBuilder();
   for (int i = 0; i < 5; i++) {
     sb.append("level ");
     sb.append(String.valueOf(i));
     sb.append(" : ");
     UTMExtremes levelExtremes = this.extremes[i];
     if (levelExtremes.minX < levelExtremes.maxX
         || !(levelExtremes.maxYHemisphere.equals(AVKey.SOUTH) && levelExtremes.maxY == 0)) {
       sb.append(levelExtremes.minX);
       sb.append(", ");
       sb.append(levelExtremes.maxX);
       sb.append(" - ");
       sb.append(levelExtremes.minY);
       sb.append(AVKey.NORTH.equals(levelExtremes.minYHemisphere) ? "N" : "S");
       sb.append(", ");
       sb.append(levelExtremes.maxY);
       sb.append(AVKey.NORTH.equals(levelExtremes.maxYHemisphere) ? "N" : "S");
     } else {
       sb.append("empty");
     }
     sb.append("\n");
   }
   return sb.toString();
 }