1. Shape format dialog 
ポップアップメニューの"shape format"メニューアイテムを選ぶと、次のダイアログが表示される。 
 =>
ポップアップメニューの種類, 
操作説明書: 属性(property)タブ 
 
  
    
      
            
          図 1.1 (a) 直線に対する位置, サイズ(position, size)タブ
       | 
      
				  
          図 1.1 (b)その他図形に対する位置, サイズ(position, size)タブ
       | 
     
  
 
 
  
    
      | 
         
            
      図 1.2(a) 線種、色などを設定するスタイルタブ 
       | 
        
             
      図 1.2 (b) 線種(line stroke)ボタンを押したときのプルダウンメニュー 
       | 
     
  
 
 
  
    
      
				  
				図 1.3 属性(property)タブ
       | 
       
				  
				図 1.4 図形データタブ
			 | 
     
  
 
 
  
    
      
				  
				図 1.5 テキストボックスタブ
       | 
      
				  
				図 1.6 テキストタブ
       | 
     
  
 
 
 図1. 図形フォーマットダイアログ 
  
1.1 DialogOfShapeFormatクラス
戻る=>page top 
public class DialogOfShapeFormat extends JDialog 
  
  
    
      | 
       フィールド 
       | 
      
       説明 
       | 
     
    
      | 
       action 
       | 
      
       ShapeFormatAction action 
      ボタン等に設定するActionListenerオブジェクト(ShapeFormatAction)。 
       | 
     
    
      | 
       dataScrollPane 
       | 
      
       JScrollPane dataScrollPane 
      The ScrollPane in the data tab (図 1.4). 
       | 
     
    
      | 
       textScrollPane 
       | 
      
       JScrollPane textScrollPane 
      テキストパネルに設定するスクロールペイン (図 1.5)。 
       | 
     
    
      | 
       shapeContainer 
       | 
      
       ShapeContainer shapeContainer 
      showDialogメソッドの引数で渡される図形データ(ShapeContainer)。
				グループ図形でも良い。 
       | 
     
    
      | 
       pixelButton 
       | 
      
       JRadioButton pixelButton 
      長さの単位をピクセルで表示することを指示する位置、サイズタブ (図 1.1) のボタン。 
       | 
     
    
      | 
       mmButton 
       | 
      
       JRadioButton mmButton 
      長さの単位をミリメータで表示することを指示する位置、サイズタブ (図 1.1) のボタン。 
       | 
     
    
      | unresizableBox | 
      
       JCheckBox unresizableBox 
      "unresizable" 属性を設定するチェックボックス(図 1.3). 
       | 
     
    
      | ratioBox | 
      
       JCheckBox ratioBox 
      "keep aspect ratio"属性を設定するチェックボックス (図 1.3). 
       | 
     
    
      | directionBox | 
      
       JCheckBox directionBox 
      "keep line direction" 属性を設定するチェックボックス (図 1.3). 
       | 
     
    
      | unableConnectorBox | 
      
       JCheckBox unableConnectorBox 
      "unable to drag connectors"属性を設定するチェックボックス (図 1.3). 
       | 
     
    
      | ungroupBox | 
      
       JCheckBox ungroupBox 
      "unable ungrouping" 属性を設定するチェックボックス (図 1.3). 
       | 
     
    
      | 
       dialogDimension 
       | 
      
       Dimension dialogDimension=new Dimension(400,330); 
      ダイアログの初期サイズ。 
       | 
     
    
      | buttonSize | 
      
       Dimension buttonSize=new Dimension(80,22) 
       | 
     
    
      | 
       positionSpinners 
       | 
      
       JSpinner[] positionSpinners=new JSpinner[4] 
      x-min, x-max, y-min, y-maxの表示および値の変更をするスピナー (図 1.1 (b))。 
       | 
     
    
      | 
       positionSpinnerModels 
       | 
      
       SpinnerNumberModel[] positionSpinnerModels=new SpinnerNumberModel[4] 
      positionSpinnersのモデル。 
       | 
     
    
      | 
       centerSpinners 
       | 
      
       JSpinner[] centerSpinners=new JSpinner[2]; 
      center pointの表示および値の変更をするスピナー (図 1.1 (b))。 
       | 
     
    
      | 
       centerSpinnerModels 
       | 
      
       SpinnerNumberModel[] centerSpinnerModels=new SpinnerNumberModel[2]; 
      centerSpinnersのモデル。 
       | 
     
    
      | 
       sizeSpinners 
       | 
      
       JSpinner[] sizeSpinners=new JSpinner[2] 
      width, heightの表示および値の変更をするスピナー (図 1.1 (b))。 
       | 
     
    
      | 
       sizeSpinnerModels 
       | 
      
       SpinnerNumberModel[] sizeSpinnerModels=new SpinnerNumberModel[2] 
      sizeSpinnersのモデル。 
       | 
     
    
      | startSpinners | 
      
       JSpinner[] startSpinners=new JSpinner[2] 
      始点(start point) の表示および値の変更をするスピナー (図 1.1 (a)). 
       | 
     
    
      | startSpinnerModels | 
      
       SpinnerNumberModel[] startSpinnerModels=new SpinnerNumberModel[2] 
      startSpinnersのモデル。 
       | 
     
    
      | endSpinners | 
      
       JSpinner[] endSpinners=new JSpinner[2] 
      終点(end point) の表示および値の変更をするスピナー (図 1.1 (a))。 
       | 
     
    
      | endSpinnerModels | 
      SpinnerNumberModel[] endSpinnerModels=new SpinnerNumberModel[2] 
      endSpinnersのモデル。 | 
     
    
      | lineSpinners | 
      
       JSpinner[] lineSpinners=new JSpinner[2] 
      角度(angle)と直線の長さ(length) の表示および値の変更をするスピナー (図 1.1 (a))。 
       | 
     
    
      | lineSpinnerModels | 
      SpinnerNumberModel[] lineSpinnerModels=new SpinnerNumberModel[2] 
      lineSpinnerSのモデル。 | 
     
    
      | 
       marginSpinners 
       | 
      
       JSpinner[] marginSpinners=new JSpinner[4] 
      TextBoxの内側のマージンの表示および値の変更をするスピナー (図 1.5)。 
       | 
     
    
      | 
       marginSpinnerModels 
       | 
      
       SpinnerNumberModel[] marginSpinnerModels=new SpinnerNumberModel[4] 
      marginSpinnersのモデル。 
       | 
     
    
      | 
       lineSpaceSpinner 
       | 
      
       JSpinner lineSpaceSpinner=null 
      TextBoxの行間隔の表示および値の変更をするスピナー (図 1.5)。 
       | 
     
    
      | 
       lineSpaceSpinnerModel 
       | 
      
       SpinnerNumberModel lineSpaceSpinnerModel=null 
      lineSpaceSpinnersのモデル。 
       | 
     
  
 
 
  
    
      | 
       メソッド 
       | 
      
       説明 
       | 
     
    
      | 
       コンストラクタ 
       | 
      
       public DialogOfShapeFormat() 
      次の設定をする。 
      super(ObjectTable.getDrawMain(), "Shape Format"); 
      this.setName("DialogOfShapeFormat");  
      this.action=new ShapeFormatAction(this); 
      this.addWindowListener(action); 
       | 
     
    
      | 
       showDialog 
       | 
      
       public void showDialog(ShapeContainer container) 
      引数: 
      container - 図形データ表示するShapeContainer。 
      処理: 
      ∙ containerをフィールド変数shapeContainerにセット。 
      ∙ ShapeFormatListenerをこのダイアログに設定。 
      ∙ ダイアログ表示位置決定 
      containerを囲む矩形データから表示位置を決める。 
      ∙ JTabbedPane作成、パネルをタブに設定 
      7個のパネルをcreateLinePanel, 
				createRectangularPanel, createPaintStylePanel, createPropertyPanel, createDataPanel,  createTextBoxPanel, createTextInfoPanel メソッドで作成し、タブに設定する。
				位置, サイズ(position,size)タブには、選択図形が直線ならばcreateLinePanelで作成したパネルを、直線以外であればcreateRectangularPanelで作成したパネルを設定する。 
      ∙ このオブジェクトのsetVisibleメソッドを呼んでダイアログを表示する。 
      ∙ もし他のDialogOfShapeFormatが画面に表示されていたら、それを次の removeDialogメソッド削除する。 
       | 
     
    
      | removeDialog | 
      protected void removeDialog() 
      このオブジェクトをsetVisible(false)メソッドで不可視にする。さらにこのオブジェクトをmenuUtilオブジェクトのremoveMenuComponentメソッドでmenuComponentList から削除する。 | 
     
    
      | setScrollViewPosition | 
      
       protected void setScrollViewPosition() 
      ビューポジションを dataScrollPane と textScrollPaneに設定する。 
      this.dataScrollPane.getViewport().setViewPosition(new Point(0,0)); 
      if(this.textScrollPane!=null) this.textScrollPane.getViewport().setViewPosition(new
      Point(0,0)); 
       : このメソッドはShapeFormatListenerオブジェクトのcomponentShownメソッドから呼ばれる。 
       | 
     
    
      | 
       createRectangularPanel 
       | 
      
       private JPanel createRectangularPanel() 
      処理: 
      図 1.1 (b)のパネルを作成して返す。 
      showRectangular メソッドを呼んで、スピナーに値を設定する。 
       | 
     
    
      | showRectangular | 
      protected void showRectangular(int unitOfLength) 
      引数: 
      unitOfLength - 0: 長さの単位はピクセル, 1: 長さの単位はミリメータ 
      処理: 
      ∙ shapeContainerを参照して値を positionSpinners, centerSpinners, sizeSpinnersに設定する。. 
      ∙ もし"unresizable" 属性がshapeContainer設定されていたら, sizeSpinnersを無効にする。 
       | 
     
    
      | 
       createLinePanel 
       | 
      
       private JPanel createLinePanel() 
      処理: 
      図 1.1 (a)のパネルを作成して返す。 
      showLine メソッドを呼んで、スピナーに値を設定する。 
       | 
     
    
      | showLine | 
      protected void showLine(int unitOfLength) 
      引数: 
      unitOfLength - 0: pixels, 1: milimeters  
      処理: 
      ∙ shapeContainerを参照して値を startSpinners, endSpinners, lineSpinnersに設定する。 
      ∙ もし"unresizable" 属性がshapeContainer設定されていたら, lineSpinnersを無効にする。 
      ∙ もし"keep line direction" 属性がshapeContainer設定されていたら, lineSpinners[0] (angle spinner)を無効にする。 
       | 
     
    
      | 
       createPaintStylePanel 
       | 
      
       private JPanel createPaintStylePanel() 
      図1.1のパネルを作成する。 
       | 
     
    
      | 
       createPropertyPanel 
       | 
      
       private JPanel createPropertyPanel() 
      処理: 
      図 1.3のパネルを作成して返す。 
      ∙ unresizableBox, ratioBox, directionBox, unableConnectorBox, ungroupBox チェックボックスをパネルに加える。 
       | 
     
    
      | 
       showProperty 
       | 
      
       protected void showProperty() 
      処理: 
      ∙ 属性をShapeContainer.getBooleanPropertyメソッドで取得。 
      ∙ 取得したブーリアン値を unresizableBox, ratioBox, directionBox, unableConnectorBox, ungroupBox チェックボックスに設定する。 
       | 
     
    
      | 
       createDataPanel 
       | 
      
       private JPanel createPropertyPanel() 
      図1.4のパネルを作成する。 
      ∙ 下段のInformationパネルにはJScrollPaneとJTextAreaを配置し、JTextAreaオブジェクトをJScrollPaneのViewに設定する。 
       | 
     
    
      | 
       createTextBoxPanel 
       | 
      
       private JPanel createTextBoxPanel() 
      図1.5のパネルを作成する。 
       | 
     
    
      | 
       createTextInfoPanel 
       | 
      
       private JPanel createTextInfoPanel() 
      図1.6のパネルを作成する。 
       | 
     
    
      | 
       getShapeContainer 
       | 
      
       public ShapeContainer getShapeContainer() 
      フィールド変数 shapeContainerを返す。 
       | 
     
    
      | 
       getDataScrollPane 
       | 
      
       public JScrollPane getDataScrollPane() 
      フィールド変数 dataScrollPaneを返す。 
       | 
     
    
      | 
       getTextScrollPane 
       | 
      
       public JScrollPane getTextScrollPane() 
      フィールド変数 textScrollPane を返す。 
       | 
     
    
      | 
       getPositionSpinners 
       | 
      
       public JSpinner[] getPositionSpinners() 
      フィールド変数 positionSpinnersを返す。 
       | 
     
    
      | 
       getPositionSpinner 
      Models 
       | 
      
       public SpinnerNumberModel[] getPositionSpinnerModels() 
      フィールド変数 positionSpinnerModels. 
       | 
     
    
      | 
       getSizeSpinners 
       | 
      
       public JSpinner[] getSizeSpinners() 
      フィールド変数 sizeSpinners. 
       | 
     
    
      | 
       getSizeSpinner 
      Models 
       | 
      
       public SpinnerNumberModel[] getSizeSpinnerModels() 
      フィールド変数 sizeSpinnerModels. 
       | 
     
    
      | 
       getCenterSpinners 
       | 
      
       public JSpinner[] getCenterSpinners() 
      フィールド変数 centerSpinnersを返す。 
       | 
     
    
      | 
       getCenterSpinner 
      Models 
       | 
      
       public SpinnerNumberModel[] getCenterSpinnerModels() 
      フィールド変数 centerSpinnerModels. 
       | 
     
    
      | 
       getStartSpinners 
       | 
      
       public JSpinner[] getStartSpinners() 
      フィールド変数 startSpinnersを返す。 
       | 
     
    
      | 
       getStartSpinner 
      Models 
       | 
      
       public SpinnerNumberModel[] getStartSpinnerModels() 
      フィールド変数 startSpinnerModelsを返す。 
       | 
     
    
      | 
       getEndSpinners 
       | 
      
       public JSpinner[] getEndSpinners() 
      フィールド変数 endSpinnersを返す。 
       | 
     
    
      | 
       getEndSpinner 
      Models 
       | 
      
       public SpinnerNumberModel[] getEndSpinnerModels() 
      フィールド変数 endSpinnerModels. 
       | 
     
    
      | 
       getLineSpinners 
       | 
      
       public JSpinner[] getLineSpinners() 
      フィールド変数 lineSpinners. 
       | 
     
    
      | 
       getLineSpinner 
      Models 
       | 
      
       public SpinnerNumberModel[] getLineSpinnerModels() 
      フィールド変数 lineSpinnerModels. 
       | 
     
    
      | 
       getMarginSpinners 
       | 
      
       public JSpinner[] getMarginSpinners() 
      フィールド変数 marginSpinnersを返す。 
       | 
     
    
      | 
       getMarginSpinner 
      Models 
       | 
      
       public SpinnerNumberModel[] getMarginSpinnerModels() 
      フィールド変数 marginSpinnerModelsを返す。 
       | 
     
    
      | 
       getLineSpaceSpinner 
       | 
      
       public JSpinner getLineSpaceSpinner() 
      フィールド変数 lineSpaceSpinnerを返す。 
       | 
     
    
      | 
       getLineSpaceSpinner 
      Models 
       | 
      
       public SpinnerNumberModel getLineSpaceSpinnerModels() 
      フィールド変数 lineSpaceSpinnerModelを返す。 
       | 
     
    
      | 
       getUnResizableBox 
       | 
      
       public JCheckBox getUnResizableBox() 
      フィールド変数 unresizableBoxを返す。 
       | 
     
    
      | 
       getRatioBox 
       | 
      
       public JCheckBox getRatioBox() 
      フィールド変数 ratioBoxを返す。 
       | 
     
    
      | 
       getDirectionBox 
       | 
      
       public JCheckBox getDirectionBox() 
      フィールド変数 directionBoxを返す。 
       | 
     
    
      | 
       getUnableConnectorBox 
       | 
      
       public JCheckBox getUnableConnectorBox() 
      フィールド変数 unableConnectorBoxを返す。 
       | 
     
    
      | 
       getUngroupBox 
       | 
      
       public JCheckBox getUngroupBox() 
      フィールド変数 ungroupBoxを返す。 
       | 
     
  
 
 
  
 
1.2 ShapeFormatListener
戻る=>page top 
class ShapeFormatListener implements ComponentListener 
 
 
  
1.3 Class SpinnersChangeListener
戻る=>page top 
class SpinnersChangeListener implements ChangeListener 
  
 
  
    
      | 
       Method 
       | 
      
       Description 
       | 
     
    
      | コンストラクター | 
      SpinnersChangeListener(DialogOfShapeFormat dialog) 
      引数をフィールド変数に設定。 | 
     
    
      | 
       stateChanged 
       | 
      
       public void stateChanged(ChangeEvent e) 
      positionSpinners, sizeSpinners, centerSpinnersのどれかが書き換えられたときデータの一貫性を保障するため、他のスピナーに値を設定しなおす。 
       | 
     
    
      | 
       rectangularChanged 
       | 
      
       public void rectangularChanged(ChangeEvent e) 
      位置, サイズ(position, size)タブでスピナー値が変更されたら、関連するスピナーの値を変更し、shapeContainer を再表示する。このメソッドはshapeContainerに設定されている属性を考慮して動作する。 
       => 操作説明書 位置, サイズ(position, size)タブ,  属性(property)タブ, 図形の属性(property)とスピナーの値 
      ∙ ConnectionUtil.moveResize メソッドを使ってshapeContainerを移動/リサイズする。 
       | 
     
    
      | 
       lineChanged 
       | 
      
       public void lineChanged(ChangeEvent e) 
      位置, サイズ(position, size)タブでスピナー値が変更されたら、関連するスピナーの値を変更し、shapeContainer を再表示する。このメソッドはshapeContainer(直線)に設定されている属性を考慮して動作する。 
       => 操作説明書 位置, サイズ(position, size)タブ,  属性(property)タブ, 図形の属性(property)とスピナーの値 
      ∙ ConnectionUtil.moveResize, moveEndPointメソッドを使って直線の移動、端点の移動を実行する。 
       | 
     
    
      | 
       getMoveVector 
       | 
      
       private Vector2D getMoveVector(Vector2D Tvec, Vector2D move) 
      lineChanged メソッドから呼ばれ、directionBox が選択されているときに端点の移動先を計算する。 
       | 
     
    
      | 
       removeChangeListener 
       | 
      
       private void removeChangeListener() 
      positionSpinners - lineSpinners からChangeListenerを削除する。 
       | 
     
    
      | 
       addChangeListener 
       | 
      
       private void addChangeListener() 
      positionSpinners - lineSpinnersにChangeListenerを設定する。 
       | 
     
  
 
  
1.4 ShapeFormatActionクラス
戻る=>page top 
class DialogOfDrawPanelAction extends AbstractAction 
  
 
  
2. 表示画面の情報ダイアログ
戻る=>page top 
 
  
    
      | 
         
        
      図 2.1 Display the list of the shape objects 
       | 
      
         
        
      図 2.2 Display the list of the MouseListeners 
       | 
     
  
 
  
2.1 DialogOfDrawPanelクラス
戻る=>page top 
このクラスはExecCommand.execメソッドから呼ばれる。
  
public class DialogOfShapeFormat extends JDialog 
 
  
    
      | 
       メソッド 
       | 
      
       説明 
       | 
     
    
      | 
       コンストラクタ 
       | 
      
       public DialogOfDrawPanel() 
      次の設定を行う。 
      super(ObjectTable.getDrawMain(),"Draw Panel Information"); 
      this.setName("DialogOfDrawPanel");  
      this.action=new DialogOfDrawPanelAction(this); 
      this.addWindowListener(action); 
       | 
     
    
      | 
       showDialog 
       | 
      
       public static void showDialog(Point mousePosition) 
      引数: 
      mousePosition - マウス位置 
      処理: 
      ∙ ”shape information”タブで表示するshapeInformationPanel(JPanel)と” listener information”タブで表示するlistenerInformationPanel(JPanel)しJTabbedPaneに設定。 
      ∙ dialog.pack()、dialog.setVisible(true)でダイアログを表示。 
      ∙ もし他のDialogOfDrawPanelオブジェクトがすでに画面に表示されていたら、removeDialogメソッドで消去する。 
       | 
     
    
      | removeDialog | 
      protected void removeDialog() 
      このオブジェクトのsetVisible(false)メソッドを呼び。不可視にする。さらにmenuComponentList からremoveMenuComponentメソッドで削除する。 | 
     
    
      | setScrollViewPosition | 
      
       protected void setScrollViewPosition() 
      ビュー位置をshapeScrollPane とlistenerScrollPaneに設定する。 
      this.shapescrollPane.getViewport().setViewPosition(new Point(0,0)); 
      this.listenerScrollPane.getViewport().setViewPosition(new Point(0,0)); 
       : このメソッドは、DialogOfDrawPanelListenerのcomponentShownメソッドから呼ばれる。 . 
       | 
     
    
      | 
       createShapeInfoPanel 
       | 
      
				private static JPanel createShapeInfoPanel() 
      図 2.1のパネルを作成しJTabbedPaneに貼り付ける。 
      ∙ 図形一覧を表示するJTextAreaを作成し、図形一覧の文字列を設定する。 
      ∙ 新しいJScrollPaneオブジェクトを作成しshapeScrollPaneに設定。 
      ∙ JTextAreaをJScrollPaneのviewに設定。 
      ∙ JScrollPaneをshapeInformationPanelに加える。 
			∙ Text領域に図形情報(Shapes Information)を表示する。 
			ContainerListから図形を読み出し、
				ShapeContainer.toStringメソッドで図形情報の文字列を得る。 
       | 
     
    
      | 
       createListenerInfoPanel 
       | 
      
       private static JPanel createListenerInfoPanel() 
      図 2.2のパネルを作成しJTabbedPaneに貼り付ける。 
      ∙ マウスリスナーを表示するJTextAreaを作成し、マウスリスナー一覧の文字列を設定する。 
      ∙ 新しいJScrollPaneオブジェクトを作成しlistenerScrollPaneに設定。 
      ∙ JTextAreaをJScrollPaneのviewに設定。 
      ∙ ListenerScrollをlistenerInformationPanelに加える。 
       | 
     
    
      | getShapeScrollPane | 
      public JScrollPane getShapeScrollPane() 
      shapeScrollPaneを返す。 | 
     
    
      | getListenerScrollPane | 
      public JScrollPane getListenerScrollPane() 
      listenerScrollPaneを返す。 | 
     
  
 
 
  
2.2 DialogOfDrawPanelListenerクラス
戻る=>page top 
class DialogOfDrawPanelListener implements ComponentListener 
 
 
  
2.3 DialogOfDrawPanelActionクラス
戻る=>page top 
class DialogOfDrawPanelAction extends AbstractAction 
 
 
 |