例: FontStyle property (ViewColumn - Java™)

  1. 次のエージェントは、太字と斜体が設定されているかどうかを示します。
    import lotus.domino.*;
    
    public class JavaAgent extends AgentBase {
    
      public void NotesMain() {
    
        try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
    
          // (Your code goes here) 
          Database db = agentContext.getCurrentDatabase();
          View view = db.getView("By category");
          ViewColumn vc = view.getColumn(1);
          if ((vc.getFontStyle() & ViewColumn.FONT_BOLD) != 0)
            System.out.println("Bold is set");
          else
            System.out.println("Bold is not set");
          if ((vc.getFontStyle() & ViewColumn.FONT_ITALIC) != 0)
            System.out.println("Italic is set");
          else
            System.out.println("Italic is not set");
            
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  2. 次のエージェントは、文字スタイルを太字から斜体 (斜体から太字) に切り替えます。
    import lotus.domino.*;
    
    public class JavaAgent extends AgentBase {
    
      public void NotesMain() {
    
        try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
    
          // (Your code goes here) 
          Database db = agentContext.getCurrentDatabase();
          View view = db.getView("By category");
          ViewColumn vc = view.getColumn(1);
          if (vc.getFontStyle() == ViewColumn.FONT_BOLD) {
            vc.setFontStyle(ViewColumn.FONT_ITALIC);
            System.out.println("Italic is set");
          }
          else {
            vc.setFontStyle(ViewColumn.FONT_BOLD);
            System.out.println("Bold is set");
          }
            
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  3. 他の属性に影響を与えずに 1 つのスタイルを設定するには、次の形式の論理構成を使用します。
    vc.getFontStyle() | ViewColumn.FONT_BOLD

    他の属性に影響を与えずに 2 つのスタイルを設定するには、次の形式の論理構成を使用します。

    vc.getFontStyle() | ViewColumn.FONT_BOLD |
    ViewColumn.FONT_ITALIC

    他の属性に影響を与えずに 1 つのスタイルの設定を解除するには、次の形式の論理構成を使用します。

    vc.getFontStyle() & ~ViewColumn.FONT_BOLD

    他の属性に影響を与えずに 2 つのスタイルの設定を解除するには、次の形式の論理構成を使用します。

    vc.getFontStyle() & (~(ViewColumn.FONT_BOLD | ViewColumn.FONT_ITALIC))