Java Doc for GridDataFactory.java in  » IDE-Eclipse » jface » org » eclipse » jface » layout » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » jface » org.eclipse.jface.layout 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.eclipse.jface.layout.GridDataFactory

GridDataFactory
final public class GridDataFactory (Code)
This class provides a convienient shorthand for creating and initializing GridData. This offers several benefits over creating GridData normal way:
  • The same factory can be used many times to create several GridData instances
  • The setters on GridDataFactory all return "this", allowing them to be chained
  • GridDataFactory uses vector setters (it accepts Points), making it easy to set X and Y values together

GridDataFactory instances are created using one of the static methods on this class.

Example usage:

 ////////////////////////////////////////////////////////////
 // Example 1: Typical grid data for a non-wrapping label
 // GridDataFactory version
 GridDataFactory.fillDefaults().applyTo(myLabel);
 // Equivalent SWT version
 GridData labelData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
 myLabel.setLayoutData(labelData);
 ///////////////////////////////////////////////////////////
 // Example 2: Typical grid data for a wrapping label
 // GridDataFactory version
 GridDataFactory.fillDefaults()
 .align(SWT.FILL, SWT.CENTER)
 .hint(150, SWT.DEFAULT)
 .grab(true, false)
 .applyTo(wrappingLabel);
 // Equivalent SWT version
 GridData wrappingLabelData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
 wrappingLabelData.minimumWidth = 1;
 wrappingLabelData.widthHint = 150;
 wrappingLabel.setLayoutData(wrappingLabelData);
 //////////////////////////////////////////////////////////////
 // Example 3: Typical grid data for a scrollable control (a list box, tree, table, etc.)
 // GridDataFactory version
 GridDataFactory.fillDefaults().grab(true, true).hint(150, 150).applyTo(listBox);
 // Equivalent SWT version
 GridData listBoxData = new GridData(GridData.FILL_BOTH);
 listBoxData.widthHint = 150;
 listBoxData.heightHint = 150;
 listBoxData.minimumWidth = 1;
 listBoxData.minimumHeight = 1;
 listBox.setLayoutData(listBoxData);
 /////////////////////////////////////////////////////////////
 // Example 4: Typical grid data for a button
 // GridDataFactory version
 Point preferredSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
 Point hint = Geometry.max(LayoutConstants.getMinButtonSize(), preferredSize);
 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).hint(hint).applyTo(button);
 // Equivalent SWT version
 Point preferredSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
 Point hint = Geometry.max(LayoutConstants.getMinButtonSize(), preferredSize);
 GridData buttonData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
 buttonData.widthHint = hint.x;
 buttonData.heightHint = hint.y;
 button.setLayoutData(buttonData);
 /////////////////////////////////////////////////////////////
 // Example 5: Generated GridData
 // Generates GridData a wrapping label that spans 2 columns
 GridDataFactory.generate(wrappingLabel, 2, 1);
 // Generates GridData for a listbox. and adjusts the preferred size to 300x400 pixels
 GridDataFactory.defaultsFor(listBox).hint(300, 400).applyTo(listBox);
 // Generates GridData equivalent to example 4
 GridDataFactory.generate(button, 1, 1);
 

since:
   3.2




Method Summary
public  GridDataFactoryalign(int hAlign, int vAlign)
     Sets the alignment of the control within its cell.
Parameters:
  hAlign - horizontal alignment.
public  voidapplyTo(Control control)
     Sets the layout data on the given control.
public  GridDataFactorycopy()
     Creates a copy of the reciever.
public static  GridDatacopyData(GridData data)
    
public  GridDatacreate()
     Creates a new GridData instance.
public static  GridDataFactorycreateFrom(GridData data)
     Creates a new GridDataFactory that creates copies of the given GridData by default.
public static  GridDataFactorydefaultsFor(Control theControl)
     Returns a GridDataFactory initialized with heuristicly generated defaults for the given control. To be precise, this method picks the default values that GridLayoutFactory.generateLayout would have assigned to the control.
public  GridDataFactoryexclude(boolean shouldExclude)
     Instructs the GridLayout to ignore this control when performing layouts.
public static  GridDataFactoryfillDefaults()
     Creates a GridDataFactory initialized with defaults that will cause the control to fill its cell.
public static  voidgenerate(Control theControl, int hSpan, int vSpan)
     Generates layout data to the given control, given the number of cells spanned by the control.
public static  voidgenerate(Control theControl, Point span)
     Generates layout data to the given control, given the number of cells spanned by the control.
public  GridDataFactorygrab(boolean horizontal, boolean vertical)
     Determines whether extra horizontal or vertical space should be allocated to this control's column when the layout resizes.
public  GridDataFactoryhint(int xHint, int yHint)
     Sets the width and height hints.
public  GridDataFactoryhint(Point hint)
     Sets the width and height hints.
public  GridDataFactoryindent(int hIndent, int vIndent)
     Sets the indent of the control within the cell.
public  GridDataFactoryindent(Point indent)
     Sets the indent of the control within the cell.
public  GridDataFactoryminSize(int minX, int minY)
     Sets the minimum size for the control.
public  GridDataFactoryminSize(Point min)
     Sets the minimum size for the control.
public  GridDataFactoryspan(int hSpan, int vSpan)
     Sets the GridData span.
public  GridDataFactoryspan(Point span)
     Sets the GridData span.
public static  GridDataFactoryswtDefaults()
     Creates a new GridDataFactory initialized with the SWT defaults.



Method Detail
align
public GridDataFactory align(int hAlign, int vAlign)(Code)
Sets the alignment of the control within its cell.
Parameters:
  hAlign - horizontal alignment. One of SWT.BEGINNING, SWT.CENTER, SWT.END, or SWT.FILL.
Parameters:
  vAlign - vertical alignment. One of SWT.BEGINNING, SWT.CENTER, SWT.END, or SWT.FILL. this



applyTo
public void applyTo(Control control)(Code)
Sets the layout data on the given control. Creates a new GridData instance and assigns it to the control by calling control.setLayoutData.
Parameters:
  control - control whose layout data will be initialized



copy
public GridDataFactory copy()(Code)
Creates a copy of the reciever. a copy of the reciever



copyData
public static GridData copyData(GridData data)(Code)
Returns a copy of the given GridData
Parameters:
  data - GridData to copy a copy of the argument



create
public GridData create()(Code)
Creates a new GridData instance. All attributes of the GridData instance will be initialized by the factory. a new GridData instance



createFrom
public static GridDataFactory createFrom(GridData data)(Code)
Creates a new GridDataFactory that creates copies of the given GridData by default.
Parameters:
  data - GridData to copy a new GridDataFactory that creates copies of the argument by default



defaultsFor
public static GridDataFactory defaultsFor(Control theControl)(Code)
Returns a GridDataFactory initialized with heuristicly generated defaults for the given control. To be precise, this method picks the default values that GridLayoutFactory.generateLayout would have assigned to the control. Does not attach GridData to the control. Callers must additionally call applyTo(theControl) if they wish to use the generated values.

This method is intended for situations where generateLayout is generating layout data for a particular control that is not quite right for the desired layout. This allows callers to start with the generated values and tweak one or two settings before applying the GridData to the control.


See Also:   GridLayoutFactory.generateLayout(org.eclipse.swt.widgets.Composite)
Parameters:
  theControl - a GridLayoutFactory initialized with defaults that GridLayoutFactory would have
since:
   3.3



exclude
public GridDataFactory exclude(boolean shouldExclude)(Code)
Instructs the GridLayout to ignore this control when performing layouts.
Parameters:
  shouldExclude - true iff the control should be excluded from layouts this



fillDefaults
public static GridDataFactory fillDefaults()(Code)
Creates a GridDataFactory initialized with defaults that will cause the control to fill its cell. The minimum size is set to the smallest possible minimum size supported by SWT. Currently, the smallest supported minimum size is (1,1) so this is the default. If GridLayout ever adds support for grid data with no minimum size, this will be changed to 0,0 in the future.

Initial values are:

  • align(SWT.FILL, SWT.FILL)
  • exclude(false)
  • grab(false, false)
  • hint(SWT.DEFAULT, SWT.DEFAULT)
  • indent(0,0)
  • minSize(1,1)
  • span(1,1)
a GridDataFactory that makes controls fill their grid by default
See Also:   GridDataFactory.swtDefaults()



generate
public static void generate(Control theControl, int hSpan, int vSpan)(Code)
Generates layout data to the given control, given the number of cells spanned by the control. Attaches a GridData to the control. This method allows generated layout data to be used with controls that span multiple cells.

The generated layout data is the same as what would be generated by GridLayoutFactory.generateLayout, except that the span is configurable


See Also:   GridLayoutFactory.generateLayout(org.eclipse.swt.widgets.Composite)
Parameters:
  theControl -
Parameters:
  hSpan - number of columns spanned by the control
Parameters:
  vSpan - number of rows spanned by the control
since:
   3.3



generate
public static void generate(Control theControl, Point span)(Code)
Generates layout data to the given control, given the number of cells spanned by the control. Attaches GridData to the control. This method allows generated layout data to be used with controls that span multiple cells.

The generated layout data is the same as what would be generated by GridLayoutFactory.generateLayout, except that the span is configurable


See Also:   GridLayoutFactory.generateLayout(org.eclipse.swt.widgets.Composite)
Parameters:
  theControl -
Parameters:
  span - The x coordinate indicates the number ofcolumns spanned, and the y coordinate indicates the number of rows.
since:
   3.3



grab
public GridDataFactory grab(boolean horizontal, boolean vertical)(Code)
Determines whether extra horizontal or vertical space should be allocated to this control's column when the layout resizes. If any control in the column is set to grab horizontal then the whole column will grab horizontal space. If any control in the row is set to grab vertical then the whole row will grab vertical space.
Parameters:
  horizontal - true if the control's column should grow horizontally
Parameters:
  vertical - true if the control's row should grow vertically this



hint
public GridDataFactory hint(int xHint, int yHint)(Code)
Sets the width and height hints. The width and height hints override the control's preferred size. If either hint is set to SWT.DEFAULT, the control's preferred size is used.
Parameters:
  xHint - horizontal hint (pixels), or SWT.DEFAULT to use the control's preferred size
Parameters:
  yHint - vertical hint (pixels), or SWT.DEFAULT to use the control's preferred size this



hint
public GridDataFactory hint(Point hint)(Code)
Sets the width and height hints. The width and height hints override the control's preferred size. If either hint is set to SWT.DEFAULT, the control's preferred size is used.
Parameters:
  hint - size (pixels) to be used instead of the control's preferred size. Ifthe x or y values are set to SWT.DEFAULT, the control's computeSize() method willbe used to obtain that dimension of the preferred size. this



indent
public GridDataFactory indent(int hIndent, int vIndent)(Code)
Sets the indent of the control within the cell. Moves the position of the control by the given number of pixels. Positive values move toward the lower-right, negative values move toward the upper-left.
Parameters:
  hIndent - distance to move to the right (negative values move left)
Parameters:
  vIndent - distance to move down (negative values move up) this



indent
public GridDataFactory indent(Point indent)(Code)
Sets the indent of the control within the cell. Moves the position of the control by the given number of pixels. Positive values move toward the lower-right, negative values move toward the upper-left.
Parameters:
  indent - offset to move the control this



minSize
public GridDataFactory minSize(int minX, int minY)(Code)
Sets the minimum size for the control. The control will not be permitted to shrink below this size. Note: GridLayout treats a minimum size of 0 as an undocumented special value, so the smallest possible minimum size is a size of 1. A minimum size of SWT.DEFAULT indicates that the result of computeSize(int, int, boolean) should be used as the control's minimum size.
Parameters:
  minX - minimum a value of 1 or more is a horizontal size of the control (pixels). SWT.DEFAULT indicates that the control's preferred size should be used. A sizeof 0 has special semantics defined by GridLayout.
Parameters:
  minY - minimum a value of 1 or more is a vertical size of the control (pixels). SWT.DEFAULTindicates that the control's preferred size should be used. A sizeof 0 has special semantics defined by GridLayout. this



minSize
public GridDataFactory minSize(Point min)(Code)
Sets the minimum size for the control. The control will not be permitted to shrink below this size. Note: GridLayout treats a minimum size of 0 as an undocumented special value, so the smallest possible minimum size is a size of 1. A minimum size of SWT.DEFAULT indicates that the result of computeSize(int, int, boolean) should be used as the control's minimum size.
Parameters:
  min - minimum size of the control this



span
public GridDataFactory span(int hSpan, int vSpan)(Code)
Sets the GridData span. The span controls how many cells are filled by the control.
Parameters:
  hSpan - number of columns spanned by the control
Parameters:
  vSpan - number of rows spanned by the control this



span
public GridDataFactory span(Point span)(Code)
Sets the GridData span. The span controls how many cells are filled by the control.
Parameters:
  span - the new span. The x coordinate indicates the number ofcolumns spanned, and the y coordinate indicates the number of rows. this



swtDefaults
public static GridDataFactory swtDefaults()(Code)
Creates a new GridDataFactory initialized with the SWT defaults. This factory will generate GridData that is equivalent to "new GridData()".

Initial values are:

  • align(SWT.BEGINNING, SWT.CENTER)
  • exclude(false)
  • grab(false, false)
  • hint(SWT.DEFAULT, SWT.DEFAULT)
  • indent(0,0)
  • minSize(0,0)
  • span(1,1)
a new GridDataFactory instance
See Also:   GridDataFactory.fillDefaults()



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.