GrxCollisionPairView.java
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * General Robotix Inc.
8  * National Institute of Advanced Industrial Science and Technology (AIST)
9  */
17 package com.generalrobotix.ui.view;
18 
19 import java.util.ArrayList;
20 import java.util.Iterator;
21 import java.util.List;
22 
23 import org.eclipse.swt.SWT;
24 import org.eclipse.swt.widgets.Composite;
25 
34 
35 @SuppressWarnings("serial")
36 public class GrxCollisionPairView extends GrxBaseView {
37 
39  private List<GrxModelItem> currentModels_ = new ArrayList<GrxModelItem>();
40  private List<GrxCollisionPairItem> currentCollisionPairs_ = new ArrayList<GrxCollisionPairItem>();;
41 
42  public GrxCollisionPairView(String name, GrxPluginManager manager, GrxBaseViewPart vp, Composite parent) {
43  super(name, manager, vp, parent);
44  collisionPane_ = new CollisionPairPanel(composite_, SWT.NONE, manager_);
45 
46  setUp();
47  collisionPane_.setEnabled(true);
48 
49  manager_.registerItemChangeListener(this, GrxModelItem.class);
50  manager_.registerItemChangeListener(this, GrxCollisionPairItem.class);
51  }
52 
53  public void setUp(){
54  Iterator<GrxCollisionPairItem> it = currentCollisionPairs_.iterator();
55  while(it.hasNext()) {
56  it.next().deleteObserver(this);
57  }
58  currentModels_ = manager_.<GrxModelItem>getSelectedItemList(GrxModelItem.class);
59  currentCollisionPairs_ = manager_.<GrxCollisionPairItem>getSelectedItemList(GrxCollisionPairItem.class);
60  collisionPane_.updateCollisionPairs(currentCollisionPairs_, currentModels_);
61  it = currentCollisionPairs_.iterator();
62  while(it.hasNext()) {
63  it.next().addObserver(this);
64  }
65  }
66 
67  public void registerItemChange(GrxBaseItem item, int event){
68  if(item instanceof GrxModelItem){
69  GrxModelItem mitem = (GrxModelItem)item;
70  switch(event){
72  if(!currentModels_.contains(mitem)){
73  currentModels_.add(mitem);
74  collisionPane_.updateCollisionPairs(currentCollisionPairs_, currentModels_);
75  }
76  break;
79  if(currentModels_.contains(mitem)){
80  currentModels_.remove(mitem);
81  collisionPane_.updateCollisionPairs(currentCollisionPairs_, currentModels_);
82  }
83  break;
84  default:
85  break;
86  }
87  }else if(item instanceof GrxCollisionPairItem){
88  GrxCollisionPairItem citem = (GrxCollisionPairItem)item;
89  switch(event){
92  if(!currentCollisionPairs_.contains(citem)){
93  currentCollisionPairs_.add(citem);
94  collisionPane_.updateCollisionPairs(currentCollisionPairs_, currentModels_);
95  citem.addObserver(this);
96  }
97  break;
100  if(currentCollisionPairs_.contains(citem)){
101  currentCollisionPairs_.remove(citem);
102  collisionPane_.updateCollisionPairs(currentCollisionPairs_, currentModels_);
103  citem.deleteObserver(this);
104  }
105  break;
106  default:
107  break;
108  }
109  }
110  }
111 
112  public void update(GrxBasePlugin plugin, Object... arg) {
113  if(currentCollisionPairs_.contains(plugin)){
114  if((String)arg[0]=="PropertyChange"){
115  collisionPane_.updateCollisionPairs(currentCollisionPairs_, currentModels_);
116  }
117  }
118  }
119 
120  public void shutdown() {
121  Iterator<GrxCollisionPairItem> it = currentCollisionPairs_.iterator();
122  while(it.hasNext()) {
123  it.next().deleteObserver(this);
124  }
125 
126  manager_.removeItemChangeListener(this, GrxModelItem.class);
127  manager_.removeItemChangeListener(this, GrxCollisionPairItem.class);
128  }
129 
130  public void updateTableFont(){
131  collisionPane_.updateTableFont();
132  }
133 }
png_infop png_charpp name
Definition: png.h:2382
item corresponds to a robot model
void registerItemChange(GrxBaseItem item, int event)
void updateCollisionPairs(List< GrxCollisionPairItem > clist, List< GrxModelItem > mlist)
GrxCollisionPairView(String name, GrxPluginManager manager, GrxBaseViewPart vp, Composite parent)
プラグイン管理クラス GrxUIの核になるクラス。プラグインのロード等の、初期化を実行する。 プラグインとそ...
org
char * arg
Definition: cdjpeg.h:136
void update(GrxBasePlugin plugin, Object... arg)


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Sep 8 2022 02:24:03