当前位置: 首页>>代码示例>>Java>>正文


Java Observable类代码示例

本文整理汇总了Java中java.util.Observable的典型用法代码示例。如果您正苦于以下问题:Java Observable类的具体用法?Java Observable怎么用?Java Observable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Observable类属于java.util包,在下文中一共展示了Observable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: update

import java.util.Observable; //导入依赖的package包/类
@Override
public void update(Observable o, Object arg) {
	if (arg.getClass().equals(Notification.class)){
		Notification ret = (Notification) arg;
		
		//SPU processing ended
		logger.debug( "SPU "+ret.getSPUID()+" proccesing ended");
		subscriptionProcessingEnded(ret.getSPUID());
					
		//Send notification if required
		if (!ret.toBeNotified()) return;
		else {
			logger.debug( "Notify observers");
			setChanged();
			notifyObservers(ret);
		}
	}
	else {
		logger.debug( "Notify observers");
		setChanged();
		notifyObservers(arg);
	}
}
 
开发者ID:vaimee,项目名称:sepatools,代码行数:24,代码来源:SPUManager.java

示例2: update

import java.util.Observable; //导入依赖的package包/类
@Override
public void update(Observable arg0, Object arg1)
{
	if(arg1 instanceof IndicatorCandle)
	{
		IndicatorCandle candle = (IndicatorCandle)arg1;
		System.out.println(candle.toString());
		System.out.println(candle.getTimeFrame());
		for(AIndicator indi: candle.getIndicators().values())
		{
			System.out.print("Indicator: " + indi.getClass().getSimpleName() + " Plotables: ");
			for(Plotable p: indi.getPlotables())
			{
				try {
					System.out.print(p.getMethodToPlot().invoke(indi, null)+"; ");
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			System.out.println();
		}
		System.out.println();
	}
}
 
开发者ID:lead4good,项目名称:open-java-trade-manager,代码行数:25,代码来源:TradingSystemStarter.java

示例3: update

import java.util.Observable; //导入依赖的package包/类
/** The central point for communication with HW from biasgen. All objects in Biasgen are Observables
        and add Biasgen.this as Observer. They then call notifyObservers when their state changes.
         * @param observable IPot, Scanner, etc
         * @param object not used at present
         */
        @Override
        synchronized public void update(Observable observable, Object object) {  // thread safe to ensure gui cannot retrigger this while it is sending something
//            log.info(observable + " sent " + object);
            if (this.hardwareInterface == null) {
                return;
            }

            // "economised" BufferIPot (what's that for anyway??)
            if ((observable instanceof VPot) || (observable instanceof IPot)) {
                try {
                    hardwareInterface.sendConfiguration(this);
                } catch (HardwareInterfaceException ex) {
                    log.warning("could not send configuration : " + ex);
                }
            } else {
                super.update(observable, object);  // super (Biasgen) handles others, e.g. maasterbias
            }
        }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:24,代码来源:MDC2D.java

示例4: update

import java.util.Observable; //导入依赖的package包/类
/** called when Observable changes (pot changes) */
    @Override
    public void update(Observable observable, Object obj) {
        if (observable instanceof ConfigurableIPotRev0) {
//            log.info("observable="+observable);
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    // don't do the following - it sometimes prevents display updates or results in double updates
//                        slider.setValueIsAdjusting(true); // try to prevent a new event from the slider
                    updateAppearance();
                }
            });
        }
    }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:17,代码来源:ConfigurableIPotGUIControl.java

示例5: testImportExcelMultipleError

import java.util.Observable; //导入依赖的package包/类
@Test
public void testImportExcelMultipleError() {

    ResetTestValue.reset();

    ImportHandler handler = new ImportHandler(
            new RowRecordPersistencorHibernateImpl(factory), TransactionMode.MULTIPLE);
    List<RowRecord> list = handler.importExcel(
            ExcelFactory.newExcel(new File("D:/test/schoolman_error.xlsx")),
            new Observer() {
                @Override
                public void update(Observable o, Object arg) {
                    Process process = (Process) arg;
                    System.out.println("进度:" + process.getProcess() + ",当前阶段:" + process.getNode());
                }
            },
            SchoolMan.class);
    for (RowRecord rr : list) {
        System.out.println("行号:" + rr.getRowNo() + ", 错误信息:" + rr.getResult().getMsg());
    }
}
 
开发者ID:Strangeen,项目名称:excel-util4j,代码行数:22,代码来源:TestImportHandler.java

示例6: update

import java.util.Observable; //导入依赖的package包/类
/** called when Observable changes (pot changes) */
@Override
public void update(final Observable observable, final Object obj) {
	if (observable instanceof IPot) {
		// log.info("observable="+observable);
		SwingUtilities.invokeLater(new Runnable() {

			@Override
			public void run() {
				// don't do the following - it sometimes prevents display updates or results in double updates
				// slider.setValueIsAdjusting(true); // try to prevent a new event from the slider
				updateAppearance();
			}
		});
	}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:17,代码来源:SimpleIPotSliderTextControl.java

示例7: update

import java.util.Observable; //导入依赖的package包/类
@Override
public void update(Observable obs, Object obj) {
	if (obs instanceof V2GCommunicationSessionEVCC && 
		(obj instanceof PauseSession || obj instanceof TerminateSession)) {
		// In case of pausing or terminating a session the transport layer client must be stopped
		getTransportLayerClient().stop();
		getTransportLayerThread().interrupt();
		
		if (obj instanceof PauseSession) {
			/*
			 * If some action is needed by the sessionHandler when pausing, it can be done here.
			 * If TCP/TLS client sends notification, it should always be a TerminateSession instance
			 * (because a failure of the connection to the TCP/TLS server is its only reason for 
			 * notification).
			 */
		} else if (obj instanceof TerminateSession) {
			terminate((TerminateSession) obj);
		}
	} else if (obs instanceof TCPClient || obs instanceof TLSClient) {
		// TCP- and TLSClient already stop themselves and interrupt their threads before notifying
		terminate((TerminateSession) obj);
	} else {
		getLogger().warn("Notification coming from " + obs.getClass().getSimpleName() + 
				 " unknown: " + obj.getClass().getSimpleName());
	}
}
 
开发者ID:V2GClarity,项目名称:RISE-V2G,代码行数:27,代码来源:V2GCommunicationSessionHandlerEVCC.java

示例8: update

import java.util.Observable; //导入依赖的package包/类
@Override
public void update(Observable observable, Object o) {
    mBooks.clear();
    if (o instanceof IBookProvider && ((IBookProvider)o).getBooks() != null) {
        mBooks.addAll(((IBookProvider)o).getBooks());
        mAdapter.notifyDataSetChanged();

        if (CurrentSelected.getBook() != null) {
            for (IBook book : mBooks) {
                if (book.getId().equalsIgnoreCase(CurrentSelected.getBook().getId())) {
                    ((LinearLayoutManager)mRecyclerView.getLayoutManager()).scrollToPositionWithOffset(mBooks.indexOf(book), mRecyclerView.getHeight()/2);
                }
            }
        }
    }
}
 
开发者ID:barnhill,项目名称:SimpleBible,代码行数:17,代码来源:BookSelectionFragment.java

示例9: update

import java.util.Observable; //导入依赖的package包/类
/**
 * called when Observable changes (pot changes)
 */
@Override
public void update(final Observable observable, final Object obj) {
    if (observable instanceof TowerOnChip6BitVDAC) {
        // log.info("observable="+observable);
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                // don't do the following - it sometimes prevents display updates or results in double updates
                // slider.setValueIsAdjusting(true); // try to prevent a new event from the slider
                updateAppearance();
            }
        });
    }
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:19,代码来源:TowerOnChip6BitVDACControl.java

示例10: update

import java.util.Observable; //导入依赖的package包/类
/**
 * 
 * @param o
 * @param arg argomenti dell'evento
 */
@Override
public void update(Observable o, Object arg) {
    String messaggio = arg.toString();
    String dati[] = messaggio.split("\t");

    if (dati[0].equals("evento")) {
        gestisciEvento(dati);
    } else if (dati[0].equals("setta")) {
        gestisciSettaggio(dati);
    } else if (dati[0].equals("cambia")) {
        gestisciCambiamento(dati);
    } else if(dati[0].equals("partitaPiena")){
        this.setChanged();
        this.notifyObservers(new PartitaPiena());
    }

}
 
开发者ID:IngSW-unipv,项目名称:Progetto-A,代码行数:23,代码来源:PartitaOnlineController.java

示例11: startSpeak

import java.util.Observable; //导入依赖的package包/类
/**
 * 调用本方法时务必保证当前没有处于合成状态
 *
 * @param msg
 * @return
 */
protected io.reactivex.Observable<SpeechMsg> startSpeak(SpeechMsg msg) {
    Log.w(TAG, "startSpeak text:" + msg.text());
    if (mContext != null) {
        if (!mediator.allowSynthersize(msg)) {//TODO 此处判断需挪到前面
            Log.e(TAG, "msg.priority can not be synthesize!");
            return io.reactivex.Observable.empty();
        }
    }
    currentMessage = msg;
    if (msg.text().length() == 0) {
        Log.e(TAG, "msg.length==0");
        return createEmptySuccessCallback(msg);
    }
    if (mediator.isBlueToothHeadSet()) {
        Log.e(TAG, "setAudioManager mode to MODE_IN_CALL");
        mediator.startBluetoothSco();
    }
    if (msg.forceLocalEngine()) {
        //msg.forceLocalEngine=true;
    } else {
        //forceSwitchEngine(RobotApplication.online);
    }
    return synthesize(msg);
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:31,代码来源:SynthesizerBase.java

示例12: testError

import java.util.Observable; //导入依赖的package包/类
private void testError(TransactionMode mode, Function<List<RowRecord>, Object> function) {

        ResetTestValue.reset();

        ImportHandler handler = new ImportHandler(
                new RowRecordHandlerImpl(),
                new RowRecordPersistencorHibernateImpl(factory), mode);
        List<RowRecord> list = handler.importExcel(
                ExcelFactory.newExcel(new File("D:/test/userinfo_error.xlsx")),
                1,
                (Observable o, Object arg) -> {
                    Process process = (Process) arg;
                    System.out.println("进度:" + process.getProcess() + ",当前阶段:" + process.getNode());
                },
                User.class);

        list.forEach(rr -> {
            System.out.println("行号:" + rr.getRowNo() + ", 错误信息:" + rr.getResult().getMsg());
            System.out.println(rr);
        });

        function.apply(list);
    }
 
开发者ID:Strangeen,项目名称:excel-util4j,代码行数:24,代码来源:TestImportHandlerForCascadePojo.java

示例13: update

import java.util.Observable; //导入依赖的package包/类
@Override
public void update(Observable o, Object arg) {
    if(arg instanceof GiocatoreDisconnessoException){
        System.out.println("disconnesso");
        disconnesso=true;
    }
    else{
        String messaggio = String.valueOf(arg);
        String dati[] = messaggio.split(" ");
        if(dati[0].equals("evento")){
            if (dati[1].equals("SetPuntata")) {
                puntataInserita(dati[2]);
            } else if (dati[1].equals("SetGiocata")) {
                GiocataInserita(dati[2]);
            }else if(dati[1].equals("Esce"))
                esce=true;
        }
    }
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-A,代码行数:20,代码来源:Giocatore.java

示例14: Binder

import java.util.Observable; //导入依赖的package包/类
/**
 * Bind a model to a view.
 * @param modelReader a getter on the observable for the field, so that the binder can set the target to start with. 
 * @param applicator code to run when the observable changes. something like (a)->view.setText(a) 
 * @param o the observable to observe.
 */
public Binder(Supplier<T> modelReader,Consumer<T> applicator,Observable o) {
	this.applicator=applicator;
	this.modelReader = modelReader;
	o.addObserver(this);
	if( modelReader.get()!=null){
		applicator.accept(modelReader.get());
	}
	
}
 
开发者ID:williscroft,项目名称:binder,代码行数:16,代码来源:Binder.java

示例15: updateCodeArea

import java.util.Observable; //导入依赖的package包/类
private void updateCodeArea(final Observable o, final Object arg) {
   	try {
   		ByteArrayEditableData data = treeObservable.getBinarySource().getBinaryData();
   		codeArea.setData(data);
   	} catch (IOException|TreeModelLoadException ex) {
   		// todo
   	}
}
 
开发者ID:kiwiwings,项目名称:poi-visualizer,代码行数:9,代码来源:POIMainFrame.java


注:本文中的java.util.Observable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。