Ejemplo n.º 1
0
 /**
  * Describe <code>toArrowString</code> method here.
  *
  * @since jPicEdt 1.6
  * @param arrow
  * @param dir
  * @param tikzCustomProperties
  * @return a <code>String</code> representation of
  * @since jPicEdt 1.6
  */
 public static String toArrowString(
     ArrowStyle arrow, Direction dir, TikzCustomization tikzCustomProperties) {
   boolean hasArrowTipPackage = tikzCustomProperties.getHasArrowTipPackage();
   TZArrow aa = toTZArrow(arrow);
   if (aa != null) return aa.getTZArrow(hasArrowTipPackage).getString(dir);
   else Log.warning("TZZArrow manquant certains ArrowStyle.");
   return null;
 }
Ejemplo n.º 2
0
 /**
  * Convertit un style de pointe de flèche <code>ArrowStyle</code> en l'énumérer <code>TZArrow
  * </code> correspondant décrivant son codage en TikZ.
  *
  * @param arrow une valeur <code>ArrowStyle</code> ) convertit en <code>TZArrow</code>.
  * @return le <code>TZArrow</code> correspondant à <code>arrow</code>.
  * @since jPicEdt 1.6
  */
 public static TZArrow toTZArrow(ArrowStyle arrow) {
   for (TZArrow aa : TZArrow.values()) {
     if (aa.getArrowStyle() == arrow) {
       return aa;
     }
   }
   return null;
 }
Ejemplo n.º 3
0
  /**
   * @return spécificateur TikZ de flèche (e.g. "stealth-stealth") pour le <code>PicAttributeSet
   *     </code> passé en argument.
   */
  public static StringBuffer createArrowStringFromArrows(
      PicAttributeSet attributes, TikzCustomization tikzCustomProperties, boolean swapArrows) {

    StringBuffer buf = new StringBuffer(15);
    ArrowStyle leftArrow = attributes.getAttribute(LEFT_ARROW);
    ArrowStyle rightArrow = attributes.getAttribute(RIGHT_ARROW);
    if (swapArrows) {
      ArrowStyle temp = rightArrow;
      rightArrow = leftArrow;
      leftArrow = temp;
    }
    boolean hasArrowTipPackage = tikzCustomProperties.getHasArrowTipPackage();

    if (leftArrow == ArrowStyle.NONE && rightArrow == ArrowStyle.NONE) return buf;
    else {
      TZArrow leftTZArrow = toTZArrow(leftArrow).getTZArrow(hasArrowTipPackage);
      TZArrow rightTZArrow = toTZArrow(rightArrow).getTZArrow(hasArrowTipPackage);
      ArrowStyle leftElement = leftTZArrow.getElementArrowStyle();
      ArrowStyle rightElement = rightTZArrow.getElementArrowStyle();
      TZArrow tZArrow = null;
      ArrowStyle arrow = ArrowStyle.NONE;
      ArrowStyle elementArrow;

      if (leftArrow == ArrowStyle.NONE
          || rightArrow == ArrowStyle.NONE
          || leftElement == rightElement) {
        for (int direction = 0; direction < 2; ++direction) {
          char arrowSpec = 0;
          if (direction == 0) {
            if (leftArrow != ArrowStyle.NONE) {
              arrowSpec = '<';
              arrow = leftArrow;
              tZArrow = leftTZArrow;
            }

          } else {
            if (rightArrow != ArrowStyle.NONE) {
              arrow = rightArrow;
              arrowSpec = '>';
              tZArrow = rightTZArrow;
            }
          }
          if (arrowSpec != 0) {
            int i = tZArrow.getCount();
            if (i < 0) {
              arrowSpec = arrowSpec == '>' ? '<' : '>';
              for (int j = 0; j > i; --j) buf.append(arrowSpec);
            } else if (i > 0) {
              for (int j = 0; j < i; ++j) buf.append(arrowSpec);
            }
          }
          if (direction == 0) buf.append("-");
        }
        elementArrow = tZArrow.getElementArrowStyle();
        if (elementArrow != arrow) tZArrow = toTZArrow(elementArrow);
        buf.append(",>=");
        buf.append(tZArrow.getString(Direction.LEFT));
        for (int direction = 0; direction < 2; ++direction) {
          tZArrow = direction == 0 ? leftTZArrow : rightTZArrow;
          String shorten = tZArrow.getShorten(direction == 0 ? Direction.LEFT : Direction.RIGHT);
          if (shorten != null) {
            buf.append(",shorten ");
            buf.append(direction == 0 ? '<' : '>');
            buf.append('=');
            buf.append(shorten);
          }
        }
      } else {
      }
    }
    return buf;
  }