protected internal override TextBlock createLabel(IComparable category, float width, RectangleEdge edge, Graphics2D g2)
 {
   TextBlock label = base.createLabel(category, width, edge, g2);
   string text = (string) this.sublabels.get((object) category);
   if (text != null)
   {
     if (edge == RectangleEdge.__\u003C\u003ETOP || edge == RectangleEdge.__\u003C\u003EBOTTOM)
     {
       TextLine line = new TextLine(text, this.sublabelFont, this.sublabelPaint);
       label.addLine(line);
     }
     else if (edge == RectangleEdge.__\u003C\u003ELEFT || edge == RectangleEdge.__\u003C\u003ERIGHT)
     {
       TextLine lastLine = label.getLastLine();
       if (lastLine != null)
       {
         TextLine textLine = lastLine;
         TextFragment.__\u003Cclinit\u003E();
         TextFragment fragment = new TextFragment(new StringBuffer().append("  ").append(text).toString(), this.sublabelFont, this.sublabelPaint);
         textLine.addFragment(fragment);
       }
     }
   }
   return label;
 }
Ejemplo n.º 2
0
    public static TextBlock createTextBlock(string text, Font font, Paint paint, float maxWidth, int maxLines, TextMeasurer measurer)
    {
      TextBlock textBlock = new TextBlock();
      BreakIterator lineInstance = BreakIterator.getLineInstance();
      lineInstance.setText(text);
      int num1 = 0;
      int num2 = 0;
      int num3 = String.instancehelper_length(text);
label_1:
      while (num1 < num3 && num2 < maxLines)
      {
        int num4 = TextUtilities.nextLineBreak(text, num1, maxWidth, lineInstance, measurer);
        if (num4 == -1)
        {
          textBlock.addLine(String.instancehelper_substring(text, num1), font, paint);
          return textBlock;
        }
        else
        {
          textBlock.addLine(String.instancehelper_substring(text, num1, num4), font, paint);
          ++num2;
          num1 = num4;
          while (true)
          {
            if (num1 < String.instancehelper_length(text) && (int) String.instancehelper_charAt(text, num1) == 10)
              ++num1;
            else
              goto label_1;
          }
        }
      }
      if (num1 < num3)
      {
        TextLine lastLine = textBlock.getLastLine();
        TextFragment lastTextFragment = lastLine.getLastTextFragment();
        string text1 = lastTextFragment.getText();
        string text2 = "...";
        if (String.instancehelper_length(text1) > 3)
          text2 = new StringBuffer().append(String.instancehelper_substring(text1, 0, String.instancehelper_length(text1) - 3)).append("...").toString();
        lastLine.removeFragment(lastTextFragment);
        TextFragment.__\u003Cclinit\u003E();
        TextFragment fragment = new TextFragment(text2, lastTextFragment.getFont(), lastTextFragment.getPaint());
        lastLine.addFragment(fragment);
      }
      return textBlock;
    }