Class: Miyako::Diagram::Processor

Inherits:
Object
  • Object
show all
Includes:
Animation, Layout, SpriteBase
Defined in:
lib/Miyako/API/diagram.rb

Overview

遷移図操作クラス

遷移図形式の処理を制御するクラス

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Layout

#add_snap_child, #bottom, #bottom!, #broad_rect, #center, #center!, #centering, #centering!, #copy_layout, #delete_snap_child, #get_snap_children, #get_snap_sprite, #h, #include_snap_child?, #init_layout, #layout_dispose, #left, #left!, #middle, #middle!, #move, #move!, #move_to, #move_to!, #on_move, #outside_bottom, #outside_bottom!, #outside_left, #outside_left!, #outside_right, #outside_right!, #outside_top, #outside_top!, #pos, #rect, #relative_move_to, #relative_move_to!, #reset_snap, #right, #right!, #segment, #set_layout_size, #set_snap_children, #set_snap_sprite, #size, #snap, #top, #top!, #update_layout, #update_layout_position, #w, #x, #y

Methods included from Animation

[], []=, anim_hash, reset, #reset, start, stop, update, update_animation, #update_animation

Methods included from SpriteBase

#bitmap, #hide, #image_rect, #image_size, #oh, #oh=, #ow, #ow=, #ox, #ox=, #oy, #oy=, #part_rect, #rect, #render_d, #render_to, #render_xy, #render_xy_to, #show, #to_sprite, #to_unit

Constructor Details

#initialize {|@diagram| ... } ⇒ Processor

インスタンスを生成する

遷移図形式のインスタンス群を生成する ブロックを必ず取り(取らないとエラー)、ブロック内では、遷移図の構成を実装する (Manager#add, Manager#add_arrow の各メソッドを参照)

返却値

生成されたインスタンス

Yields:



484
485
486
487
488
489
490
491
# File 'lib/Miyako/API/diagram.rb', line 484

def initialize
  init_layout
  set_layout_size(1,1)
  @states = {:execute => false, :pause => false, :type1 => false }
  @diagram = Miyako::Diagram::Manager.new
  @visible = true
  yield @diagram if block_given?
end

Instance Attribute Details

#diagramObject (readonly)

遷移図本体。Manager クラスのインスタンス



476
477
478
# File 'lib/Miyako/API/diagram.rb', line 476

def diagram
  @diagram
end

#visibleObject

レンダリングの可否(true->描画 false->非描画)



477
478
479
# File 'lib/Miyako/API/diagram.rb', line 477

def visible
  @visible
end

Instance Method Details

#[](name) ⇒ Object

指定した名前のノードを取得する

name

ノード名(文字列・シンボル)

返却値

ノード名に対応したノードのインスタンス



573
574
575
# File 'lib/Miyako/API/diagram.rb', line 573

def [](name)
  return @diagram[name]
end

#disposeObject

各ノードに格納されているインスタンスを解放する



559
560
561
# File 'lib/Miyako/API/diagram.rb', line 559

def dispose
  @diagram.dispose
end

#finish?Boolean

遷移図形式の処理が終了しているかどうかを取得する

遷移図処理が終了したときと停止(Diagram::Processor#stop メソッドを実行)した時に finish? メソッドは true を返す

返却値

処理が終了していれば(開始前ならば) true を返す

Returns:

  • (Boolean)


554
555
556
# File 'lib/Miyako/API/diagram.rb', line 554

def finish?
  @diagram.finish?
end

#initialize_copy(obj) ⇒ Object

:nodocs:



493
494
495
496
# File 'lib/Miyako/API/diagram.rb', line 493

def initialize_copy(obj) #:nodocs:
  @states = @states.dup
  @diagram = @diagram.dup
end

#nodesObject

登録しているノード名のリストを取得する

返却値

ノード名リスト



591
592
593
# File 'lib/Miyako/API/diagram.rb', line 591

def nodes
  return @diagram.nodes
end

#nowObject

現在実行しているノード名を取得する

返却値

ノード名(文字列・シンボル)



579
580
581
# File 'lib/Miyako/API/diagram.rb', line 579

def now
  return @diagram.now
end

#now_nodeObject

現在実行しているノードを取得する

返却値

ノードのインスタンス



585
586
587
# File 'lib/Miyako/API/diagram.rb', line 585

def now_node
  return @diagram.now_node
end

#pauseObject

実行中の処理を停止させる

resume メソッドが呼び出されるまで停止は復帰されない



514
515
516
517
# File 'lib/Miyako/API/diagram.rb', line 514

def pause
  return unless @states[:execute]
  @states[:pause] = true
end

#renderObject

レンダリング処理を行う

現在処理中のノードのrenderメソッドを呼び出す。 visibleメソッドの値がfalseのときは描画されない。



546
547
548
549
# File 'lib/Miyako/API/diagram.rb', line 546

def render
  return unless @visible
  @diagram.render
end

#rendererObject

レンダリングのみのインスタンスを生成する

MVCを推し進めるため、別の場所でレンダリングを行いたい場合に生成する。

返却値

DiagramRenderer クラスのインスタンス



566
567
568
# File 'lib/Miyako/API/diagram.rb', line 566

def renderer
  return Miyako::Diagram::Renderer.new(self.method(:render))
end

#resumeObject

停止状態から復帰する

このメソッドを呼び出すまで停止状態を保つ



521
522
523
524
# File 'lib/Miyako/API/diagram.rb', line 521

def resume
  return unless @states[:execute]
  @states[:pause] = false
end

#startObject

遷移図形式の処理を開始する



499
500
501
502
503
# File 'lib/Miyako/API/diagram.rb', line 499

def start
  return if @states[:execute]
  @diagram.start
  @states[:execute] = true
end

#stopObject

実行中の処理を中断させる



506
507
508
509
510
# File 'lib/Miyako/API/diagram.rb', line 506

def stop
  return unless @states[:execute]
  @diagram.stop
  @states[:execute] = false
end

#update(*params) ⇒ Object

処理の更新を行う

現在処理中のノードupdateメソッドを呼び出す。

params

パラメータ群。省略可能



537
538
539
540
541
# File 'lib/Miyako/API/diagram.rb', line 537

def update(*params)
  return if @states[:pause]
  @diagram.update(*params)
  @states[:execute] = false if @diagram.finish?
end

#update_input(*params) ⇒ Object

入力デバイスに関わる処理を行う

現在処理中のノードのupdate_inputメソッドを呼び出す。

params

パラメータ群。省略可能



529
530
531
532
# File 'lib/Miyako/API/diagram.rb', line 529

def update_input(*params)
  return if @states[:pause]
  @diagram.update_input(*params)
end