Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 2910 Details for
Bug 24451
Reading JPEG images slow in SWT
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Simple benchmark UI main class
BenchmarkUI.java (text/plain), 6.46 KB, created by
Christophe Cornu
on 2003-01-07 10:04:44 EST
(
hide
)
Description:
Simple benchmark UI main class
Filename:
MIME Type:
Creator:
Christophe Cornu
Created:
2003-01-07 10:04:44 EST
Size:
6.46 KB
patch
obsolete
>package org.eclipse.swt.image.benchmark; > >import java.io.*; > >import org.eclipse.swt.*; >import org.eclipse.swt.graphics.*; >import org.eclipse.swt.layout.*; >import org.eclipse.swt.widgets.*; > >/* > * (c) Copyright IBM Corp. 2000, 2002. > * This file is made available under the terms of the Common Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/cpl-v10.html > */ >public class BenchmarkUI { > > private final String NEWLINE = "\n"; > private Text infoText = null; > private static Shell shell; > > public BenchmarkUI(Composite parent){ > final TabFolder tabFolder = new TabFolder(parent, SWT.NONE); > createGeneratePage(tabFolder); > createViewPage(tabFolder); > } > /** > * Method createGeneratePage. > * @param tabFolder > */ > void createGeneratePage(final TabFolder tabFolder) { > Composite run = new Composite(tabFolder, SWT.NONE); > run.setLayout(new GridLayout()); > > new Label(run, SWT.NONE).setText("Number of runs:"); > GridData gData = new GridData(); > gData.widthHint = 30; > final Text runAmount = new Text(run, SWT.BORDER); > runAmount.setText("5"); > runAmount.setLayoutData(gData); > runAmount.setToolTipText("Number of runs"); > runAmount.addListener(SWT.Verify, new Listener() { > public void handleEvent(Event e) { > String text = e.text; > char [] chars = new char [text.length ()]; > text.getChars (0, chars.length, chars, 0); > for (int i=0; i<chars.length; i++) { > if (!('0' <= chars [i] && chars [i] <= '9')) { > e.doit = false; > return; > } > } > } > }); > > Composite doubleComp = new Composite(run, SWT.NONE); > doubleComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); > GridLayout gridLayout = new GridLayout(2,false); > gridLayout.marginWidth = 0; > gridLayout.marginHeight = 0; > doubleComp.setLayout(gridLayout); > Label imageLabel = new Label(doubleComp, SWT.NONE); > imageLabel.setText("Image directory:"); > gData = new GridData(); > gData.horizontalSpan = 2; > imageLabel.setLayoutData(gData); > final Text imageDirectory = new Text(doubleComp, SWT.BORDER); > gData = new GridData( GridData.FILL_HORIZONTAL); > imageDirectory.setLayoutData(gData); > imageDirectory.setToolTipText("Double click to open Directory Dialog"); > imageDirectory.addListener(SWT.MouseDoubleClick, new Listener() { > public void handleEvent(Event e) { > setDirectoryPath(imageDirectory); > } > }); > Button imageDir = new Button(doubleComp, SWT.PUSH); > imageDir.setText("Choose Dir"); > imageDir.setToolTipText("Choose Dir"); > imageDir.addListener(SWT.Selection, new Listener(){ > public void handleEvent(Event e) { > setDirectoryPath(imageDirectory); > } > }); > > Label outputLabel = new Label(doubleComp, SWT.NONE); > outputLabel.setText("Output directory:"); > gData = new GridData(); > gData.horizontalSpan = 2; > outputLabel.setLayoutData(gData); > final Text outputDirectory = new Text(doubleComp, SWT.BORDER); > gData = new GridData( GridData.FILL_HORIZONTAL); > outputDirectory.setLayoutData(gData); > outputDirectory.setToolTipText("Double click to open Directory Dialog"); > outputDirectory.addListener(SWT.MouseDoubleClick, new Listener() { > public void handleEvent(Event e) { > setDirectoryPath(outputDirectory); > } > }); > Button outputDir = new Button(doubleComp, SWT.PUSH); > outputDir.setText("Choose Dir"); > outputDir.setToolTipText("Choose Dir"); > outputDir.addListener(SWT.Selection, new Listener(){ > public void handleEvent(Event e) { > setDirectoryPath(outputDirectory); > } > }); > > final Button showImageResults = new Button(run, SWT.CHECK); > showImageResults.setText("Record individual image results"); > showImageResults.setSelection(true); > showImageResults.setToolTipText("Record individual image results"); > > Button runTest = new Button(run, SWT.NONE); > runTest.setText("Run"); > runTest.setToolTipText("Run Test"); > runTest.addListener(SWT.Selection, new Listener() { > public void handleEvent(Event e) { > if (outputDirectory.getText().equals("") || imageDirectory.getText().equals("") || runAmount.getText().equals("")) return; > int num = Integer.parseInt(runAmount.getText()); > if (num == 0) return; > Benchmark tester = new Benchmark(); > Cursor waitCursor = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT); > shell.setCursor(waitCursor); > String fileName = ""; > try { > fileName = tester.runTests(imageDirectory.getText(),outputDirectory.getText(),num,showImageResults.getSelection()); > } catch (IOException error) { > System.out.println(error); > } > displayLogFile(fileName); > shell.setCursor(null); > if (waitCursor != null) > waitCursor.dispose(); > } > }); > > TabItem generatePage = new TabItem(tabFolder, SWT.NONE); > generatePage.setText("Run Benchmark"); > generatePage.setControl(run); > } > void displayLogFile(String name){ > BufferedReader reader = null; > try { > reader = new BufferedReader(new FileReader(new File(name))); > infoText.setText(""); > while(reader.ready()) { > infoText.append(reader.readLine()+NEWLINE); > } > reader.close(); > } catch (IOException error){ > System.out.println(error); > } > } > /** > * Method createViewPage. > * @param tabFolder > */ > void createViewPage(final TabFolder tabFolder) { > Composite view = new Composite(tabFolder, SWT.NONE); > view.setLayout(new GridLayout()); > > //create multi-line Text to display the log file > infoText = new Text(view, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); > GridData gData = new GridData(GridData.FILL_BOTH); > infoText.setLayoutData(gData); > infoText.setEditable(false); > infoText.setToolTipText("Log file information"); > > TabItem viewPage = new TabItem(tabFolder, SWT.NONE); > viewPage.setText("View Results"); > viewPage.setControl(view); > } > > public static void main(String[] args) { > final Display display = new Display(); > shell = new Shell(display); > shell.setLayout(new FillLayout()); > > BenchmarkUI bench = new BenchmarkUI(shell); > > shell.setText("Image Benchmark"); > shell.setSize(500,500); > shell.open(); > while (!shell.isDisposed()) > if (!display.readAndDispatch()) display.sleep(); > } > void setDirectoryPath(Text text) { > DirectoryDialog dialog = new DirectoryDialog(text.getShell()); > dialog.setMessage("Choose the appropriate directory"); > dialog.setFilterPath(text.getText()); > String path = dialog.open(); > if (path != null) { > text.setText(path); > } > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 24451
:
2115
|
2909
| 2910 |
26063
|
27626
|
27636
|
29365