public PerformanceScenario getChangeTextScenario()

in src/org/pushingpixels/lightbeam/panels/ButtonsPanel.java [440:491]


	public PerformanceScenario getChangeTextScenario() {
		return new BasePerformanceScenario<AbstractButton>(
				ButtonsPanel.this, AbstractButton.class, false) {
			Map<AbstractButton, String> origText;

			int[] perms;

			@Override
			public String getName() {
				return "Changing text on buttons";
			}

			@Override
			public int getIterationCount() {
				return 10;
			}

			@Override
			public void setup() {
				super.setup();
				this.perms = LightBeamUtils.getPermutation(
						LightBeamUtils.dictionary.length, getIterationCount()
								* this.controls.size()
								* this.getIterationCount());
				this.origText = new HashMap<AbstractButton, String>();
				for (AbstractButton button : this.controls) {
					this.origText.put(button, button.getText());
				}
			}

			@Override
			public void tearDown() {
				for (AbstractButton button : this.controls) {
					button.setText(this.origText.get(button));
				}
				this.origText.clear();
				super.tearDown();
			}

			@Override
			public void runSingleIteration(int iterationNumber) {
				int count = 0;
				for (AbstractButton button : this.controls) {
					int index = this.controls.size() * iterationNumber + count;
					button
							.setText(LightBeamUtils.dictionary[this.perms[index]]);
					count++;
				}
				paintImmediately(new Rectangle(0, 0, getWidth(), getHeight()));
			}
		};
	}