コード例 #1
0
  /**
   * @param SymbolID
   * @param symbologyStandard
   * @return
   */
  public UnitFontLookupInfo getLookupInfo(String SymbolID, int symbologyStandard) {
    try {
      String code = SymbolUtilities.getBasicSymbolID(SymbolID);
      //        if(SymbolUtilities.isSIGINT(SymbolID))
      //            code = code.substring(0, 10) + "--***";
      //        else
      //            code = code.substring(0, 10) + "*****";

      if (code.length() >= 10) {
        code = code.substring(0, 10) + "*****";
      }

      UnitFontLookupInfo data = null;
      if (symbologyStandard == RendererSettings.Symbology_2525Bch2_USAS_13_14) {
        data = hashMapB.get(code);
      } else {
        data = hashMapC.get(code);
      }
      return data;
    } catch (Exception exc) {
      ErrorLogger.LogException(
          "UnitFontLookup", "getLookupInfo(" + String.valueOf(SymbolID) + ")", exc, Level.WARNING);
      return null;
    }
  }
コード例 #2
0
  private static int getSubSurfaceFrame(String SymbolID, int fillCode, int symStd) {
    int returnVal = 0;

    returnVal = 831;

    try {
      // Special check for sea mine graphics
      // 2525C///////////////////////////////////////////////////////////////
      if (RendererSettings.getInstance().getSymbologyStandard()
          == RendererSettings.Symbology_2525C) {
        if (SymbolID.indexOf("WM") == 4
            || // Sea Mine
            SymbolID.indexOf("WDM") == 4
            || // Sea Mine Decoy
            SymbolUtilities.getBasicSymbolID(SymbolID).equalsIgnoreCase("S*U*E-----*****")
            || SymbolUtilities.getBasicSymbolID(SymbolID).equalsIgnoreCase("S*U*V-----*****")
            || SymbolUtilities.getBasicSymbolID(SymbolID).equalsIgnoreCase("S*U*X-----*****")) {
          returnVal = -1;
        } else if (SymbolUtilities.getBasicSymbolID(SymbolID).equalsIgnoreCase("S*U*ND----*****")) {
          returnVal = -1;
        } else {
          if (SymbolID.charAt(3) == 'A' || SymbolID.charAt(3) == 'a') return fillCode + 2;
          else return fillCode + 1;
        } //
      } else // 2525Bch2////////////////////////////////////////////////////////
      {
        if (SymbolID.indexOf("WM") == 4) // Sea Mine
        {
          returnVal = -1;

        } else if (SymbolID.indexOf("WDM") == 4) // Sea Mine Decoy
        {
          returnVal = -1;
        } else if (SymbolUtilities.getBasicSymbolID(SymbolID).equalsIgnoreCase("S*U*ND----*****")) {
          returnVal = -1;
        } //
        else if (SymbolUtilities.getBasicSymbolID(SymbolID).equalsIgnoreCase("S*U*X-----*****")) {
          returnVal = -1;
        } else {
          if (SymbolID.charAt(3) == 'A' || SymbolID.charAt(3) == 'a') return fillCode + 2;
          else return fillCode + 1;
        }
      }
    } catch (Exception exc) {
      ErrorLogger.LogException("UnitFontLookupC", "getSubSurfaceFrame", exc);
      return fillCode;
    }

    return returnVal;
  }
コード例 #3
0
  /**
   * Creates an outline of a text shape for better readability
   *
   * @param originalText
   * @param outlineSize desired width of the outline. Overrides the value in the RendererSettings
   *     object.
   * @return
   */
  public static ShapeInfo createTextOutline(ShapeInfo originalText, int outlineSize) {
    Shape outline = null;
    ShapeInfo siOutline = null;

    // int outlineSize = RendererSettings.getInstance().getTextOutlineWidth();

    outlineSize = Math.abs(outlineSize);

    Color textColor = null;

    try {
      if (originalText.getShape() != null) outline = new GeneralPath(originalText.getShape());
      else if (originalText.getTextLayout() != null) {
        outline =
            originalText
                .getTextLayout()
                .getOutline(
                    AffineTransform.getTranslateInstance(
                        originalText.getGlyphPosition().getX(),
                        originalText.getGlyphPosition().getY()));
      }
      siOutline = new ShapeInfo(outline);

      if (originalText.getFillColor() != null) textColor = originalText.getFillColor(); // shape
      else if (originalText.getLineColor() != null) // vs
      textColor = originalText.getLineColor(); // textlayout

      //            if(textColor.getRed() == 255 &&
      //                    textColor.getGreen() == 255 &&
      //                    textColor.getBlue() == 255)
      //                siOutline.setLineColor(Color.BLACK);
      //            else
      //                siOutline.setLineColor(Color.WHITE);

      if (originalText.getAffineTransform() != null)
        siOutline.setAffineTransform(new AffineTransform(originalText.getAffineTransform()));

      if (originalText.getTextBackgroundColor() != null) {
        siOutline.setLineColor(originalText.getTextBackgroundColor());
      } else siOutline.setLineColor(getIdealTextBackgroundColor(textColor));

      // siOutline.setStroke(new BasicStroke(2));
      siOutline.setStroke(
          new BasicStroke(outlineSize, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 3));
    } catch (Exception exc) {
      ErrorLogger.LogException("SymbolDraw", "createTextOuline", exc);
    }
    return siOutline;
  }
コード例 #4
0
  /**
   * @param text
   * @param modifierValue
   * @param x
   * @param y
   * @param textColor Null == Black
   * @param textBackgroundColor null == renderer decides
   * @return
   */
  public static ShapeInfo CreateModifierShapeInfo(
      TextLayout text,
      String modifierValue,
      double x,
      double y,
      Color textColor,
      Color textBackgroundColor) {
    try {
      ShapeInfo si = new ShapeInfo(text, new Point((int) x, (int) y));
      // returnVal.setLineColor(textColor);

      if (textColor == null) textColor = Color.BLACK;

      int textRenderMethod = RendererSettings.getInstance().getTextRenderMethod();

      AffineTransform at = null; // new AffineTransform();

      if (textRenderMethod == RendererSettings.RenderMethod_SHAPES) {
        at = new AffineTransform();
        at.translate(x, y);
        Shape label = text.getOutline(at);
        si = new ShapeInfo(label);
        si.setFillColor(textColor);
      } else if (textRenderMethod == RendererSettings.RenderMethod_NATIVE) {
        si = new ShapeInfo(text, new Point((int) x, (int) y));
        si.setLineColor(textColor);
      }

      // for World Wind which just takes a string and x,y.
      si.setModifierString(modifierValue);
      si.setModifierStringPosition(new Point((int) x, (int) y));

      si.setStroke(new BasicStroke(0, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 3));
      si.setShapeType(ShapeInfo.SHAPE_TYPE_UNIT_DISPLAY_MODIFIER);

      if (textBackgroundColor != null) si.setTextBackgroundColor(textBackgroundColor);

      return si;
    } catch (Exception exc) {
      ErrorLogger.LogException("JavaRenderer", "CreateModifierShapeInfo", exc);
      return null;
    }
  }
コード例 #5
0
  /**
   * @param fgColor
   * @return
   */
  public static Color getIdealTextBackgroundColor(Color fgColor) {
    // ErrorLogger.LogMessage("SymbolDraw","getIdealtextBGColor", "in function", Level.SEVERE);
    try {
      // an array of three elements containing the
      // hue, saturation, and brightness (in that order),
      // of the color with the indicated red, green, and blue components/
      float hsbvals[] = new float[3];

      if (fgColor != null) {
          /*
          Color.RGBtoHSB(fgColor.getRed(), fgColor.getGreen(), fgColor.getBlue(), hsbvals);

          if(hsbvals != null)
          {
              //ErrorLogger.LogMessage("SymbolDraw","getIdealtextBGColor", "length: " + String.valueOf(hsbvals.length));
              //ErrorLogger.LogMessage("SymbolDraw","getIdealtextBGColor", "H: " + String.valueOf(hsbvals[0]) + " S: " + String.valueOf(hsbvals[1]) + " B: " + String.valueOf(hsbvals[2]),Level.SEVERE);
              if(hsbvals[2] > 0.6)
                  return Color.BLACK;
              else
                  return Color.WHITE;
          }*/

        int nThreshold =
            RendererSettings.getInstance().getTextBackgroundAutoColorThreshold(); // 160;
        int bgDelta =
            (int)
                ((fgColor.getRed() * 0.299)
                    + (fgColor.getGreen() * 0.587)
                    + (fgColor.getBlue() * 0.114));
        // ErrorLogger.LogMessage("bgDelta: " + String.valueOf(255-bgDelta));
        // if less than threshold, black, otherwise white.
        // return (255 - bgDelta < nThreshold) ? Color.BLACK : Color.WHITE;//new Color(0, 0, 0,
        // fgColor.getAlpha())
        return (255 - bgDelta < nThreshold)
            ? new Color(0, 0, 0, fgColor.getAlpha())
            : new Color(255, 255, 255, fgColor.getAlpha());
      }
    } catch (Exception exc) {
      ErrorLogger.LogException("SymbolDraw", "getIdealtextBGColor", exc);
    }
    return Color.WHITE;
  }
コード例 #6
0
  /**
   * Creates a filled rectangle backdrop for the text
   *
   * @param originalText
   * @return
   */
  public static ShapeInfo createTextBackgroundFill(ShapeInfo originalText) {
    Rectangle tempRect = null;
    ShapeInfo background = null;
    ShapeInfo returnVal = null;
    try {
      // tempRect = temp.getBounds();
      tempRect =
          originalText
              .getTextLayout()
              .getPixelBounds(
                  null,
                  (float) originalText.getGlyphPosition().getX(),
                  (float) originalText.getGlyphPosition().getY());
      // tempRect.setRect(temp.getTextLayout().getBounds());
      background =
          new ShapeInfo(
              new Rectangle(
                  tempRect.x - 2, tempRect.y - 2, tempRect.width + 4, tempRect.height + 4));
      if (originalText.getTextBackgroundColor() != null) {
        background.setFillColor(originalText.getTextBackgroundColor());
      } else if (RendererSettings.getInstance().getLabelBackgroundColor() != null) {
        background.setFillColor(RendererSettings.getInstance().getLabelBackgroundColor());
      } else {
        Color bgColor = null;
        if (originalText.getLineColor() != null)
          bgColor = getIdealTextBackgroundColor(originalText.getLineColor());
        else if (originalText.getFillColor() != null)
          bgColor = getIdealTextBackgroundColor(originalText.getFillColor());
        else bgColor = Color.white;

        background.setFillColor(bgColor);
      }

      if (originalText.getAffineTransform() != null)
        background.setAffineTransform(new AffineTransform(originalText.getAffineTransform()));
      returnVal = background;
    } catch (Exception exc) {
      ErrorLogger.LogException("SymbolDraw", "CreateTextBackgroundFill", exc);
    }
    return returnVal;
  }
コード例 #7
0
  private static int getSeaSurfaceFill(String SymbolID) {
    char affiliation = 0;
    char status = 0;
    int returnVal = 0;

    try {
      affiliation = SymbolID.charAt(1); // F,H,N,U,etc...
      status = SymbolID.charAt(3); // A,P,C,D,X,F

      if (SymbolUtilities.getBasicSymbolID(SymbolID).equalsIgnoreCase("S*S*O-----*****")) {
        return 2016;
      } else {
        if (affiliation == 'F'
            || affiliation == 'A'
            || affiliation == 'D'
            || affiliation == 'M'
            || affiliation == 'J'
            || affiliation == 'K') {
          return FillIndexFS;
        } else if (affiliation == 'H' || affiliation == 'S') // hostile,suspect
        {
          return FillIndexHS;
        } else if (affiliation == 'N' || affiliation == 'L') // neutral,exercise neutral
        {
          return FillIndexNS;
        } else if (affiliation == 'P'
            || affiliation == 'U'
            || affiliation == 'G'
            || affiliation == 'W') {
          return FillIndexUS;
        }
      }
    } catch (Exception exc) {
      ErrorLogger.LogException("UnitFontLookupC", "getSeaSurfaceFill", exc);
      return FillIndexUG;
    }
    return FillIndexUG;
  }
コード例 #8
0
  private static int getSubSurfaceFill(String SymbolID, int symStd) {
    char affiliation = 0;
    char status = 0;
    int returnVal = 0;

    returnVal = 831;

    try {
      affiliation = SymbolID.charAt(1); // F,H,N,U,etc...
      status = SymbolID.charAt(3); // A,P,C,D,X,F

      if (affiliation == 'F'
          || affiliation == 'A'
          || affiliation == 'D'
          || affiliation == 'M'
          || affiliation == 'J'
          || affiliation == 'K') {
        returnVal = 831; //
      } else if (affiliation == 'H' || affiliation == 'S') // hostile,suspect
      {
        returnVal = 828; // index in font file

      } else if (affiliation == 'N' || affiliation == 'L') // neutral,exercise neutral
      {
        returnVal = 834;
      } else if (affiliation == 'P'
          || affiliation == 'U'
          || affiliation == 'G'
          || affiliation == 'W') {
        returnVal = 837; // index in font file
      }

      // appears in USAS so we check in both standards
      if (SymbolUtilities.getBasicSymbolID(SymbolID).equalsIgnoreCase("S*U*X-----*****")) {
        if (status == 'A') returnVal = returnVal + 2;
        else returnVal++;
      }

      // Special check for sea mine graphics
      // 2525C///////////////////////////////////////////////////////////////
      if (symStd == RendererSettings.Symbology_2525C) {
        if (SymbolID.indexOf("WM") == 4
            || // Sea Mine
            SymbolID.indexOf("WDM") == 4
            || // Sea Mine Decoy
            SymbolUtilities.getBasicSymbolID(SymbolID).equalsIgnoreCase("S*U*E-----*****")
            || SymbolUtilities.getBasicSymbolID(SymbolID).equalsIgnoreCase("S*U*V-----*****")) {
          returnVal++;

          if (status == 'A') returnVal++;

        } else if (SymbolUtilities.getBasicSymbolID(SymbolID).equalsIgnoreCase("S*U*ND----*****")) {
          returnVal = 2121;
        }
      } else // 2525Bch2////////////////////////////////////////////////////////
      {
        if (SymbolID.indexOf("WM") == 4) // Sea Mine
        {
          if (SymbolID.indexOf("----", 6) == 6 || SymbolID.indexOf("D---", 6) == 6)
            returnVal = 2059; //
          else if (SymbolID.indexOf("G---", 6) == 6) returnVal = 2062;
          else if (SymbolID.indexOf("GD--", 6) == 6) returnVal = 2064;
          else if (SymbolID.indexOf("M---", 6) == 6) returnVal = 2073;
          else if (SymbolID.indexOf("MD--", 6) == 6) returnVal = 2075;
          else if (SymbolID.indexOf("F---", 6) == 6) returnVal = 2084;
          else if (SymbolID.indexOf("FD--", 6) == 6) returnVal = 2086;
          else if (SymbolID.indexOf("O---", 6) == 6 || SymbolID.indexOf("OD--", 6) == 6)
            returnVal = 2094;

        } else if (SymbolID.indexOf("WDM") == 4) // Sea Mine Decoy
        {
          returnVal = 2115;
        } else if (SymbolUtilities.getBasicSymbolID(SymbolID).equalsIgnoreCase("S*U*ND----*****")) {
          returnVal = 2121;
        } //
      }
    } catch (Exception exc) {
      ErrorLogger.LogException("UnitFontLookupC", "getSubSurfaceFill", exc);
      return FillIndexUU;
    }

    return returnVal;
  }
コード例 #9
0
  /**
   * 2525C returns the character index for the fill frame based on the symbol code.
   *
   * @param SymbolID 15 character symbol ID
   * @return fill character index
   */
  public static int getFillCode(String SymbolID, int symStd) {
    int returnVal = -1;

    char scheme = 0;
    char battleDimension = 0;
    char status = 0;
    char affiliation = 0;
    char grdtrkSubset = 0;
    // char foo = 'a';

    try {
      // to upper
      if (SymbolID != null && SymbolID.length() >= 10) {
        scheme = SymbolID.charAt(0); // S,O,E,I,etc...
        affiliation = SymbolID.charAt(1); // F,H,N,U,etc...
        battleDimension = SymbolID.charAt(2); // P,A,G,S,U,F,X,Z
        status = SymbolID.charAt(3); // A,P,C,D,X,F
        grdtrkSubset = SymbolID.charAt(4);

        if (scheme == 'S') // Warfighting symbols
        {
          if (affiliation == 'F'
              || affiliation == 'A'
              || affiliation == 'D'
              || affiliation == 'M'
              || affiliation == 'J'
              || affiliation == 'K') {

            if (battleDimension == 'F' || battleDimension == 'G') // ground & SOF
            {
              if (battleDimension == 'F'
                  || (battleDimension == 'G'
                      && (grdtrkSubset == 'U'
                          || grdtrkSubset == 'I'
                          || grdtrkSubset == '0'
                          || grdtrkSubset == '-'))) {
                returnVal = 803;
              } else if (battleDimension == 'G' && grdtrkSubset == 'E') {
                returnVal = 812;
              } else returnVal = 803;
            } else if (battleDimension == 'A') // Air
            {
              returnVal = 819;
            } else if (battleDimension == 'S') // SeaSurface
            {
              returnVal = getSeaSurfaceFill(SymbolID);
            } else if (battleDimension == 'U') // Subsurface
            {
              returnVal = getSubSurfaceFill(SymbolID, symStd);
            } else if (battleDimension == 'P') // space
            {
              returnVal = 843;
            } else // if(battleDimension=='Z')//unknown
            {
              returnVal = 812; // index in font file
            }
          } else if (affiliation == 'H' || affiliation == 'S') // hostile,suspect
          {
            if (battleDimension == 'F' || battleDimension == 'G') // ground & SOF
            {
              returnVal = 806;
            } else if (battleDimension == 'A') // Air
            {
              returnVal = 816;
            } else if (battleDimension == 'S') // SeaSurface
            {
              returnVal = getSeaSurfaceFill(SymbolID);
            } else if (battleDimension == 'U') // Subsurface
            {
              returnVal = getSubSurfaceFill(SymbolID, symStd);
            } else if (battleDimension == 'P') // space
            {
              returnVal = 840;
            } else // if(battleDimension=='Z')//unknown
            {
              returnVal = 806; // index in font file
            }
          } else if (affiliation == 'N' || affiliation == 'L') // neutral,exercise neutral
          {
            if (battleDimension == 'F' || battleDimension == 'G') // ground & SOF
            {
              returnVal = 809;
            } else if (battleDimension == 'A') // Air
            {
              returnVal = 822;
            } else if (battleDimension == 'S') // SeaSurface
            {
              returnVal = getSeaSurfaceFill(SymbolID);
            } else if (battleDimension == 'U') // Subsurface
            {
              returnVal = getSubSurfaceFill(SymbolID, symStd);
            } else if (battleDimension == 'P') // space
            {
              returnVal = 846;
            } else // if(battleDimension=='Z')//unknown
            {
              returnVal = 809; // index in font file
            }
          } else if (affiliation == 'P'
              || affiliation == 'U'
              || affiliation == 'G'
              || affiliation == 'W') {

            if (battleDimension == 'Z'
                || // unknown
                battleDimension == 'G'
                || // ground
                battleDimension == 'F') // SOF
            {
              returnVal = 800; // index in font file
            } else if (battleDimension == 'A') // Air
            {
              returnVal = 825;
            } else if (battleDimension == 'S') // SeaSurface
            {
              returnVal = getSeaSurfaceFill(SymbolID);
            } else if (battleDimension == 'U') // Subsurface
            {
              returnVal = getSubSurfaceFill(SymbolID, symStd);
            } else if (battleDimension == 'P') // space
            {
              returnVal = 849;
            } else returnVal = 800;
          } else returnVal = FillIndexUG;
        } // end if scheme == 's'
        else if (scheme == 'E') // Emergency Management Symbols
        {
          if (battleDimension != 'N') // if not EMS natural event
          {
            if (affiliation == 'F'
                || affiliation == 'A'
                || affiliation == 'D'
                || affiliation == 'M'
                || affiliation == 'J'
                || affiliation == 'K') {

              // EMS symbols break some rules about symbol codes
              if (SymbolUtilities.isEMSEquipment(SymbolID)) returnVal = 812;
              else returnVal = 803;
            } else if (affiliation == 'H' || affiliation == 'S') // hostile,suspect
            {
              returnVal = 806; // index in font file

            } else if (affiliation == 'N' || affiliation == 'L') // neutral,exercise neutral
            {
              returnVal = 809;
            } else /*if(affiliation == 'P' ||
                   affiliation == 'U' ||
                   affiliation == 'G' ||
                   affiliation == 'W')*/ {
              returnVal = 800; // index in font file
            }
          } else // natural events do not have a fill/frame
          {
            returnVal = -1;
          }
        } // end if scheme == 'E'
        else if (scheme == 'I') // Also default behavior
        {
          if (affiliation == 'F'
              || affiliation == 'A'
              || affiliation == 'D'
              || affiliation == 'M'
              || affiliation == 'J'
              || affiliation == 'K') {
            if (battleDimension == 'Z') // unknown
            {
              returnVal = 812; // index in font file
            } else if (battleDimension == 'F'
                || battleDimension == 'G'
                || battleDimension == 'S') // ground & SOF & sea surface
            {
              if (scheme == 'I') returnVal = 812;
              else returnVal = 803;
            } else if (battleDimension == 'A') // Air
            {
              returnVal = 819;
            } else if (battleDimension == 'U') // Subsurface
            {
              returnVal = 831;
            } else if (battleDimension == 'P') // space
            {
              returnVal = 843;
            } else {
              if (scheme == 'I') returnVal = 812;
              else returnVal = 803;
            }
          }
          if (affiliation == 'H' || affiliation == 'S') // hostile,suspect
          {
            if (battleDimension == 'Z') // unknown
            {
              returnVal = 806; // index in font file
            } else if (battleDimension == 'F'
                || battleDimension == 'G'
                || battleDimension == 'S') // ground & SOF & sea surface
            {
              returnVal = 806;
            } else if (battleDimension == 'A') // Air
            {
              returnVal = 816;
            } else if (battleDimension == 'U') // Subsurface
            {
              returnVal = 828;
            } else if (battleDimension == 'P') // space
            {
              returnVal = 840;
            } else {
              returnVal = 806;
            }
          }
          if (affiliation == 'N' || affiliation == 'L') // neutral,exercise neutral
          {
            if (battleDimension == 'Z') // unknown
            {
              returnVal = 809; // index in font file
            } else if (battleDimension == 'F'
                || battleDimension == 'G'
                || battleDimension == 'S') // ground & SOF & sea surface
            {
              returnVal = 809;
            } else if (battleDimension == 'A') // Air
            {
              returnVal = 822;
            } else if (battleDimension == 'U') // Subsurface
            {
              returnVal = 834;
            } else if (battleDimension == 'P') // space
            {
              returnVal = 846;
            } else {
              returnVal = 809;
            }
          } else if (affiliation == 'P'
              || affiliation == 'U'
              || affiliation == 'G'
              || affiliation == 'W') {

            if (battleDimension == 'Z'
                || // unknown
                battleDimension == 'G'
                || // ground
                battleDimension == 'S'
                || // sea surface
                battleDimension == 'F') // SOF
            {
              returnVal = 800; // index in font file
            } else if (battleDimension == 'A') // Air
            {
              returnVal = 825;
            } else if (battleDimension == 'U') // Subsurface
            {
              returnVal = 837;
            } else if (battleDimension == 'P') // Subsurface
            {
              returnVal = 849;
            } else {
              returnVal = 800;
            }
          }
        } // end if scheme == 'I'
        else // scheme = 'O' and anything else
        {
          if (affiliation == 'F'
              || affiliation == 'A'
              || affiliation == 'D'
              || affiliation == 'M'
              || affiliation == 'J'
              || affiliation == 'K') {
            if (SymbolID.startsWith("OFI") && SymbolID.substring(4, 10).equals("T-----")) {
              // friendly tent is the ONE STBOPS that draws like equipment.
              returnVal = FillIndexFGE;
            } else {
              returnVal = 803;
            }
          } else if (affiliation == 'H' || affiliation == 'S') // hostile,suspect
          {
            returnVal = 806; // index in font file
          } else if (affiliation == 'N' || affiliation == 'L') // neutral,exercise neutral
          {
            returnVal = 809;
          } else /*if(affiliation == 'P' ||
                 affiliation == 'U' ||
                 affiliation == 'G' ||
                 affiliation == 'W')*/ {
            returnVal = 800; // index in font file
          }
        } // end default

      } else {
        returnVal = 800;
      }

    } catch (Exception exc) {
      ErrorLogger.LogException("UnitFontLookup", "getFillCode", exc, Level.SEVERE);
    }

    return returnVal + 57000;
  }
コード例 #10
0
  /**
   * Creates an outline for single point graphics
   *
   * @param symbolFrame
   * @param thickness
   * @return
   */
  public static ArrayList<ShapeInfo> createSinglePointOutline(
      ShapeInfo symbolFrame, int thickness, Color outlineColor) {
    ShapeInfo siOutline1 = null;
    ShapeInfo siOutline2 = null;
    ShapeInfo siOutline3 = null;
    ShapeInfo siOutline4 = null;
    ShapeInfo siOutline5 = null;
    ShapeInfo siOutline6 = null;
    ShapeInfo siOutline7 = null;
    ShapeInfo siOutline8 = null;
    AffineTransform afx1 = null;
    AffineTransform afx2 = null;
    AffineTransform afx3 = null;
    AffineTransform afx4 = null;
    AffineTransform afx5 = null;
    AffineTransform afx6 = null;
    AffineTransform afx7 = null;
    AffineTransform afx8 = null;
    ArrayList<ShapeInfo> outlineShapes = null;
    // int outlineSize = RendererSettings.getInstance().getTextOutlineWidth();

    Color lineColor = null;
    Color backgroundColor = null;

    try {
      int offset = 0;

      if (outlineColor == null) {
        backgroundColor = getIdealTextBackgroundColor(lineColor);
      } else {
        backgroundColor = outlineColor;
      }
      outlineShapes = new ArrayList<ShapeInfo>();

      if (symbolFrame.getTextLayout() != null) {
        outlineShapes = new ArrayList<ShapeInfo>();

        for (int i = 1; i <= thickness; i++) {

          offset = i;

          Point2D textPosition = null;
          if (symbolFrame.getModifierStringPosition() != null)
            textPosition =
                new Point2D.Double(
                    symbolFrame.getModifierStringPosition().getX(),
                    symbolFrame.getModifierStringPosition().getY());
          else textPosition = new Point2D.Double(0, 0);

          siOutline1 =
              new ShapeInfo(
                  symbolFrame.getTextLayout(),
                  new Point2D.Double(textPosition.getX() - offset, textPosition.getY() - offset));
          siOutline2 =
              new ShapeInfo(
                  symbolFrame.getTextLayout(),
                  new Point2D.Double(textPosition.getX() + offset, textPosition.getY() - offset));
          siOutline3 =
              new ShapeInfo(
                  symbolFrame.getTextLayout(),
                  new Point2D.Double(textPosition.getX() - offset, textPosition.getY() + offset));
          siOutline4 =
              new ShapeInfo(
                  symbolFrame.getTextLayout(),
                  new Point2D.Double(textPosition.getX() + offset, textPosition.getY() + offset));
          siOutline5 =
              new ShapeInfo(
                  symbolFrame.getTextLayout(),
                  new Point2D.Double(textPosition.getX() - offset, textPosition.getY()));
          siOutline6 =
              new ShapeInfo(
                  symbolFrame.getTextLayout(),
                  new Point2D.Double(textPosition.getX() + offset, textPosition.getY()));
          siOutline7 =
              new ShapeInfo(
                  symbolFrame.getTextLayout(),
                  new Point2D.Double(textPosition.getX(), textPosition.getY() + offset));
          siOutline8 =
              new ShapeInfo(
                  symbolFrame.getTextLayout(),
                  new Point2D.Double(textPosition.getX(), textPosition.getY() - offset));

          siOutline1.setLineColor(backgroundColor);
          siOutline2.setLineColor(backgroundColor);
          siOutline3.setLineColor(backgroundColor);
          siOutline4.setLineColor(backgroundColor);
          siOutline5.setLineColor(backgroundColor);
          siOutline6.setLineColor(backgroundColor);
          siOutline7.setLineColor(backgroundColor);
          siOutline8.setLineColor(backgroundColor);

          Stroke tempStroke = new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 3);
          siOutline1.setStroke(tempStroke);
          siOutline2.setStroke(tempStroke);
          siOutline3.setStroke(tempStroke);
          siOutline4.setStroke(tempStroke);
          siOutline5.setStroke(tempStroke);
          siOutline6.setStroke(tempStroke);
          siOutline7.setStroke(tempStroke);
          siOutline8.setStroke(tempStroke);

          if (symbolFrame.getAffineTransform() != null) {
            siOutline1.setAffineTransform(new AffineTransform(symbolFrame.getAffineTransform()));
            siOutline2.setAffineTransform(new AffineTransform(symbolFrame.getAffineTransform()));
            siOutline3.setAffineTransform(new AffineTransform(symbolFrame.getAffineTransform()));
            siOutline4.setAffineTransform(new AffineTransform(symbolFrame.getAffineTransform()));
            siOutline5.setAffineTransform(new AffineTransform(symbolFrame.getAffineTransform()));
            siOutline6.setAffineTransform(new AffineTransform(symbolFrame.getAffineTransform()));
            siOutline7.setAffineTransform(new AffineTransform(symbolFrame.getAffineTransform()));
            siOutline8.setAffineTransform(new AffineTransform(symbolFrame.getAffineTransform()));
          }

          outlineShapes.add(siOutline1);
          outlineShapes.add(siOutline2);
          outlineShapes.add(siOutline3);
          outlineShapes.add(siOutline4);
          outlineShapes.add(siOutline5);
          outlineShapes.add(siOutline6);
          outlineShapes.add(siOutline7);
          outlineShapes.add(siOutline8);
        } // end for
      } // end if
      else if (symbolFrame.getGlyphVector() != null) {
        outlineShapes = new ArrayList<ShapeInfo>();

        for (int j = 1; j <= thickness; j++) {

          offset = j;

          Point2D textPosition =
              new Point2D.Double(
                  symbolFrame.getGlyphPosition().getX(), symbolFrame.getGlyphPosition().getY());

          siOutline1 =
              new ShapeInfo(
                  symbolFrame.getGlyphVector(),
                  new Point2D.Double(textPosition.getX() - offset, textPosition.getY() - offset));
          siOutline2 =
              new ShapeInfo(
                  symbolFrame.getGlyphVector(),
                  new Point2D.Double(textPosition.getX() + offset, textPosition.getY() - offset));
          siOutline3 =
              new ShapeInfo(
                  symbolFrame.getGlyphVector(),
                  new Point2D.Double(textPosition.getX() - offset, textPosition.getY() + offset));
          siOutline4 =
              new ShapeInfo(
                  symbolFrame.getGlyphVector(),
                  new Point2D.Double(textPosition.getX() + offset, textPosition.getY() + offset));
          siOutline5 =
              new ShapeInfo(
                  symbolFrame.getGlyphVector(),
                  new Point2D.Double(textPosition.getX() - offset, textPosition.getY()));
          siOutline6 =
              new ShapeInfo(
                  symbolFrame.getGlyphVector(),
                  new Point2D.Double(textPosition.getX() + offset, textPosition.getY()));
          siOutline7 =
              new ShapeInfo(
                  symbolFrame.getGlyphVector(),
                  new Point2D.Double(textPosition.getX(), textPosition.getY() + offset));
          siOutline8 =
              new ShapeInfo(
                  symbolFrame.getGlyphVector(),
                  new Point2D.Double(textPosition.getX(), textPosition.getY() - offset));

          if (symbolFrame.getShapeType() == ShapeInfo.SHAPE_TYPE_TG_SP_FRAME) {
            siOutline1.setShapeType(ShapeInfo.SHAPE_TYPE_TG_SP_OUTLINE);
            siOutline2.setShapeType(ShapeInfo.SHAPE_TYPE_TG_SP_OUTLINE);
            siOutline3.setShapeType(ShapeInfo.SHAPE_TYPE_TG_SP_OUTLINE);
            siOutline4.setShapeType(ShapeInfo.SHAPE_TYPE_TG_SP_OUTLINE);
            siOutline5.setShapeType(ShapeInfo.SHAPE_TYPE_TG_SP_OUTLINE);
            siOutline6.setShapeType(ShapeInfo.SHAPE_TYPE_TG_SP_OUTLINE);
            siOutline7.setShapeType(ShapeInfo.SHAPE_TYPE_TG_SP_OUTLINE);
            siOutline8.setShapeType(ShapeInfo.SHAPE_TYPE_TG_SP_OUTLINE);
          }

          siOutline1.setLineColor(backgroundColor);
          siOutline2.setLineColor(backgroundColor);
          siOutline3.setLineColor(backgroundColor);
          siOutline4.setLineColor(backgroundColor);
          siOutline5.setLineColor(backgroundColor);
          siOutline6.setLineColor(backgroundColor);
          siOutline7.setLineColor(backgroundColor);
          siOutline8.setLineColor(backgroundColor);

          Stroke tempStroke = new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 3);
          siOutline1.setStroke(tempStroke);
          siOutline2.setStroke(tempStroke);
          siOutline3.setStroke(tempStroke);
          siOutline4.setStroke(tempStroke);
          siOutline5.setStroke(tempStroke);
          siOutline6.setStroke(tempStroke);
          siOutline7.setStroke(tempStroke);
          siOutline8.setStroke(tempStroke);

          if (symbolFrame.getAffineTransform() != null) {
            siOutline1.setAffineTransform(new AffineTransform(symbolFrame.getAffineTransform()));
            siOutline2.setAffineTransform(new AffineTransform(symbolFrame.getAffineTransform()));
            siOutline3.setAffineTransform(new AffineTransform(symbolFrame.getAffineTransform()));
            siOutline4.setAffineTransform(new AffineTransform(symbolFrame.getAffineTransform()));
            siOutline5.setAffineTransform(new AffineTransform(symbolFrame.getAffineTransform()));
            siOutline6.setAffineTransform(new AffineTransform(symbolFrame.getAffineTransform()));
            siOutline7.setAffineTransform(new AffineTransform(symbolFrame.getAffineTransform()));
            siOutline8.setAffineTransform(new AffineTransform(symbolFrame.getAffineTransform()));
          }

          outlineShapes.add(siOutline1);
          outlineShapes.add(siOutline2);
          outlineShapes.add(siOutline3);
          outlineShapes.add(siOutline4);
          outlineShapes.add(siOutline5);
          outlineShapes.add(siOutline6);
          outlineShapes.add(siOutline7);
          outlineShapes.add(siOutline8);
        } // end for

      } else if (symbolFrame.getShape() != null) {
        outlineShapes = new ArrayList<ShapeInfo>();

        for (int k = 1; k <= thickness; k++) {

          offset = k;

          siOutline1 =
              new ShapeInfo(symbolFrame.getShape(), ShapeInfo.SHAPE_TYPE_SINGLE_POINT_OUTLINE);
          siOutline2 =
              new ShapeInfo(symbolFrame.getShape(), ShapeInfo.SHAPE_TYPE_SINGLE_POINT_OUTLINE);
          siOutline3 =
              new ShapeInfo(symbolFrame.getShape(), ShapeInfo.SHAPE_TYPE_SINGLE_POINT_OUTLINE);
          siOutline4 =
              new ShapeInfo(symbolFrame.getShape(), ShapeInfo.SHAPE_TYPE_SINGLE_POINT_OUTLINE);
          siOutline5 =
              new ShapeInfo(symbolFrame.getShape(), ShapeInfo.SHAPE_TYPE_SINGLE_POINT_OUTLINE);
          siOutline6 =
              new ShapeInfo(symbolFrame.getShape(), ShapeInfo.SHAPE_TYPE_SINGLE_POINT_OUTLINE);
          siOutline7 =
              new ShapeInfo(symbolFrame.getShape(), ShapeInfo.SHAPE_TYPE_SINGLE_POINT_OUTLINE);
          siOutline8 =
              new ShapeInfo(symbolFrame.getShape(), ShapeInfo.SHAPE_TYPE_SINGLE_POINT_OUTLINE);

          siOutline1.setLineColor(backgroundColor);
          siOutline2.setLineColor(backgroundColor);
          siOutline3.setLineColor(backgroundColor);
          siOutline4.setLineColor(backgroundColor);
          siOutline5.setLineColor(backgroundColor);
          siOutline6.setLineColor(backgroundColor);
          siOutline7.setLineColor(backgroundColor);
          siOutline8.setLineColor(backgroundColor);

          Stroke tempStroke = new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 3);
          siOutline1.setStroke(tempStroke);
          siOutline2.setStroke(tempStroke);
          siOutline3.setStroke(tempStroke);
          siOutline4.setStroke(tempStroke);
          siOutline5.setStroke(tempStroke);
          siOutline6.setStroke(tempStroke);
          siOutline7.setStroke(tempStroke);
          siOutline8.setStroke(tempStroke);

          if (symbolFrame.getAffineTransform() == null) {
            afx1 = new AffineTransform();
            afx2 = new AffineTransform();
            afx3 = new AffineTransform();
            afx4 = new AffineTransform();
            afx5 = new AffineTransform();
            afx6 = new AffineTransform();
            afx7 = new AffineTransform();
            afx8 = new AffineTransform();
          } else {
            afx1 = new AffineTransform(symbolFrame.getAffineTransform());
            afx2 = new AffineTransform(symbolFrame.getAffineTransform());
            afx3 = new AffineTransform(symbolFrame.getAffineTransform());
            afx4 = new AffineTransform(symbolFrame.getAffineTransform());
            afx5 = new AffineTransform(symbolFrame.getAffineTransform());
            afx6 = new AffineTransform(symbolFrame.getAffineTransform());
            afx7 = new AffineTransform(symbolFrame.getAffineTransform());
            afx8 = new AffineTransform(symbolFrame.getAffineTransform());
          }

          afx1.translate(-offset, -offset);
          afx2.translate(+offset, -offset);
          afx3.translate(-offset, +offset);
          afx4.translate(+offset, +offset);
          afx5.translate(-offset, 0);
          afx6.translate(+offset, 0);
          afx7.translate(0, +offset);
          afx8.translate(0, -offset);

          siOutline1.setAffineTransform(afx1);
          siOutline2.setAffineTransform(afx2);
          siOutline3.setAffineTransform(afx3);
          siOutline4.setAffineTransform(afx4);
          siOutline5.setAffineTransform(afx5);
          siOutline6.setAffineTransform(afx6);
          siOutline7.setAffineTransform(afx7);
          siOutline8.setAffineTransform(afx8);

          outlineShapes.add(siOutline1);
          outlineShapes.add(siOutline2);
          outlineShapes.add(siOutline3);
          outlineShapes.add(siOutline4);
          outlineShapes.add(siOutline5);
          outlineShapes.add(siOutline6);
          outlineShapes.add(siOutline7);
          outlineShapes.add(siOutline8);
        } // end for

      } else {
        String message = "ShapeInfo wasn't a TextLayout or a GlyphVector, returning null";
        ErrorLogger.LogMessage("SymbolDraw", "createTextOutlineQuick()", message, Level.FINEST);
        return null;
      }

      return outlineShapes;
    } catch (Exception exc) {
      ErrorLogger.LogException("SymbolDraw", "createTextOuline", exc);
    }
    return null;
  }