例: RichTextParagraphStyle class

次のエージェントは、2 つのリッチテキスト段落スタイルを定義し、それぞれを適用します。

import lotus.domino.*;
import java.util.Vector;
public class JavaAgent extends AgentBase {
  public void NotesMain() {
    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();
      // (Your code goes here) 
      Database db = agentContext.getCurrentDatabase();
      Document doc = db.createDocument();
      Item subject = doc.replaceItemValue
      ("Subject", "Rich text paragraph style");
      RichTextItem body = doc.createRichTextItem("Body");
      RichTextParagraphStyle h = headerStyle(session);
      RichTextParagraphStyle b = bodyStyle(session);
      body.appendParagraphStyle(h);
      body.appendText("Header");
      body.appendParagraphStyle(b);
      for (int i=0; i<16; i++)
        body.appendText("Line one of body. ");
      body.addNewLine();
      for (int i=0; i<16; i++)
        body.appendText("Line two of body. ");
      // Save the document
      doc.save(true, true);
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
  
  RichTextParagraphStyle headerStyle(Session s) {
    RichTextParagraphStyle r=null;
    try {
      r = s.createRichTextParagraphStyle();
      r.setAlignment(RichTextParagraphStyle.ALIGN_CENTER);
      r.setPagination
       (RichTextParagraphStyle.PAGINATE_KEEP_WITH_NEXT);
      r.setSpacingAbove
        (RichTextParagraphStyle.SPACING_SINGLE);
      r.setSpacingBelow(
        RichTextParagraphStyle.SPACING_DOUBLE);
      
    } catch(Exception e) {
      e.printStackTrace();
    }
    
    return r;
  }
  
  RichTextParagraphStyle bodyStyle(Session s) {
    RichTextParagraphStyle r=null;
    try {
      r = s.createRichTextParagraphStyle();
      r.setAlignment(RichTextParagraphStyle.ALIGN_LEFT);
      r.setSpacingAbove(RichTextParagraphStyle.SPACING_SINGLE);
      r.setSpacingBelow
      (RichTextParagraphStyle.SPACING_ONE_POINT_50);
      r.setInterLineSpacing(RichTextParagraphStyle.SPACING_SINGLE);
      r.setLeftMargin(RichTextParagraphStyle.RULER_ONE_INCH);
      r.setFirstLineLeftMargin
      ((int)(RichTextParagraphStyle.RULER_ONE_INCH * 1.5));
      r.setRightMargin(0);
      
    } catch(Exception e) {
      e.printStackTrace();
    }
    
    return r;
  }
}