public SpeedPanel(final ApplicationEngine applicationEngine, final MessageSource messageSource) { this.applicationEngine = applicationEngine; speedSelector = createSpeedSelector(); setupLayout(messageSource); applicationEngine.addListener(this, ApplicationEngineEvent.SPEED); setMaximumSize(getPreferredSize()); }
/** Convert non-linear mapping : engine to selector. */ @Override public void propertyHasChanged() { speedSelector.setValue((int) Math.sqrt(applicationEngine.getSimulationSpeed())); }
/** Convert non-linear mapping : selector to engine. */ private void updateEngineSpeed() { applicationEngine.setSimulationSpeed((short) Math.pow(speedSelector.getValue(), 2)); }