ViewModeChangeMulticaster.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
00003  * All rights reserved. This program is made available under the terms of the
00004  * Eclipse Public License v1.0 which accompanies this distribution, and is
00005  * available at http://www.eclipse.org/legal/epl-v10.html
00006  * Contributors:
00007  * General Robotix Inc.
00008  * National Institute of Advanced Industrial Science and Technology (AIST) 
00009  */
00010 package com.generalrobotix.ui.view.tdview;
00011 
00012 public class ViewModeChangeMulticaster implements ViewModeChangeListener {
00013     protected ViewModeChangeListener listener1_, listener2_;
00014 
00015     protected ViewModeChangeMulticaster(
00016         ViewModeChangeListener listener1,
00017         ViewModeChangeListener listener2
00018     ) {
00019         listener1_ = listener1;
00020         listener2_ = listener2;
00021     }
00022 
00023     public void viewModeChanged(int mode) {
00024         listener1_.viewModeChanged(mode);
00025         listener2_.viewModeChanged(mode);
00026     }
00027 
00028     public static ViewModeChangeListener add(
00029         ViewModeChangeListener listener1,
00030         ViewModeChangeListener listener2
00031     ) {
00032         if (listener1 == null) return listener2;
00033         if (listener2 == null) return listener1;
00034         return new ViewModeChangeMulticaster(listener1, listener2);
00035     }
00036 
00037     public static ViewModeChangeListener remove(
00038         ViewModeChangeListener listener,
00039         ViewModeChangeListener old
00040     ) {
00041         if (listener == old || listener == null) {
00042             return null;
00043         } else if (listener instanceof ViewModeChangeMulticaster) {
00044             return ((ViewModeChangeMulticaster)listener).remove(old);
00045         } else {
00046             return listener;
00047         }
00048     }
00049 
00050     protected ViewModeChangeListener remove(ViewModeChangeListener listener) {
00051         if (listener == listener1_) return listener2_;
00052         if (listener == listener2_) return listener1_;
00053         ViewModeChangeListener listener1 = remove(listener1_, listener);
00054         ViewModeChangeListener listener2 = remove(listener2_, listener);
00055         if (listener1 == listener1_ && listener2 == listener2_) {
00056             return this;
00057         }
00058         return add(listener1, listener2);
00059     }
00060 }


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:57