Archive for December, 2007

Web hosting reviews - Java Swing - O Reilly public FieldView(Element elem) Creates

Thursday, December 27th, 2007

Java Swing - O Reilly public FieldView(Element elem) Creates a new View for the Element. 23.2.7.3 Public Methods The following methods override the implementations provided by PlainView. They all use the PlainView implementations, but first use the protected adjustAllocation() method to modify the given Shape. public void insertUpdate(DocumentEvent changes, Shape a, ViewFactory f ) Calls super.insertUpdate() (modifying the given shape by a call to adjustAllocation()) and updates the horizontal visibility model of the JTextField rendered by this view (if there is one). public void removeUpdate(DocumentEvent changes, Shape a, ViewFactory f ) Calls super.removeUpdate(), modifying the given shape by a call to adjustAllocation(), and updates the horizontal visibility model of the JTextField rendered by this view (if there is one). public void paint(Graphics g, Shape a) public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException public int viewToModel(float fx, float fy, Shape a, Position.Bias[] bias) Call the appropriate super method after modifying the given Shape by calling adjustAllocation(). See Figure 23.7. 23.2.7.4 Protected Methods protected Shape adjustAllocation(Shape a) Enables the single line of text to be centered vertically within the bounds of the given Shape. It returns a Rectangle that is centered vertically within the Shape and that has a height equal to the View’s preferred span along y-axis. Horizontal adjustments are made according to the horizontalAlignment property of the JTextField using this view. Figure 23.7 shows what this method does. The larger rectangle represents the full size of the JTextField. In this case, the field’s horizontal alignment is set to SwingConstants.RIGHT, indicating that the text should be right justified. This method returns the inner rectangle, indicating the exact region into which the text should be painted. Figure 23.7. FieldView.adjustAllocation() - 765
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

Java Swing - O Reilly protected (Make web site) void drawLine(int lineIndex,

Wednesday, December 26th, 2007

Java Swing - O Reilly protected void drawLine(int lineIndex, Graphics g, int x, int y) Uses drawSelectedText() and drawUnselectedText() to render the specified line of text at the given location. protected int drawSelectedText(Graphics g, int x, int y, int p0, int p1)throws BadLocationException Uses the component’s selected text color to draw the specified range of text at the given location. protected int drawUnselectedText(Graphics g, int x, int y, int p0, int p1)throws BadLocationException Uses the component’s foreground color (or disabled text color, if disabled) to draw the specified range of text at the given location. 23.2.6.8 Other Protected Methods protected Segment getLineBuffer() Provides access to the buffer used to retrieve text from the Document. protected int getTabSize() Returns the size (in characters) of a tab. It checks the Document’s properties for the size (PlainDocument.tabSizeAttribute) and returns it if available. Otherwise, it returns the default value of 8. 23.2.7 The FieldView Class FieldView is an extension of PlainView used for single-line editors (such as JTextField). The main thing this subclass provides is the ability to center the single line of text if the View is expanded vertically. 23.2.7.1 Properties The FieldView class modifies the implementation of the View properties shown in Table 23.5. See the description of View properties for details on these properties. The preferredSpan for the X_AXIS is based on the width of the entire contents of the document. The preferredSpan for the Y_AXIS is defined by the superclass. resizeWeight is 1 for the X_AXIS and for the Y_AXIS, indicating that the view should only be resized horizontally. As usual, the element property is set in the constructor. Table 23.5, FieldView Properties Property Data Type get is set bound Default Value element* Element From constructor preferredSpan (indexed)* float See below resizeWeight (indexed)* int X_AXIS: 1, Y_AXIS: 0 See also properties from the PlainView class (Table 23.4). 23.2.7.2 Constructors - 764
We recommend high quality webhost to host and run your jsp application: christian web host services.

Java Swing - O Reilly 23.2.6.5 TabExpander Method public (Photo web hosting)

Tuesday, December 25th, 2007

Java Swing - O Reilly 23.2.6.5 TabExpander Method public float nextTabStop( float x, int tabOffset) Returns the next tab-stop position after the given position, ignoring the second parameter. Figure 23.6 shows how this might work for a simple line of text with 8-space tabs and a fixed-width (7 pixels wide) font. An input value of 357 (the location of the end of the line of text) would result in a value of 392, the next tab stop, being returned. Figure 23.6. Finding the next tab stop in a PlainView 23.2.6.6 Other Public Methods public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException Converts the given model position to a Rectangle containing that position. The width of the rectangle is always 1, and the height is always the height of the component’s font. The b parameter is currently ignored. public void paint(Graphics g, Shape a) Gets the font and colors from the View’s JTextComponent and then paints the lines that are currently visible, using the protected drawLine() method. public void preferenceChanged(View child, boolean width, boolean height) Indicates that the size of the view has changed. This method clears the PlainDocument.lineLimitAttribute from the View’s Document and calls super.preferenceChanged(). public int viewToModel( float fx, float fy, Shape a, Position.Bias[] bias) Converts the given point in the View’s coordinate system to an offset into the View’s Document. Currently, the output bias parameter is always populated with Position.Bias.Forward. In the future, this should be changed to actually calculate the correct value. 23.2.6.7 Protected Drawing Methods These protected methods are responsible for drawing the view’s text. The x and y parameters indicate the location in the view where the text is to be painted. The p0 and p1 parameters define the portion of the Element to be drawn. - 763
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

Make my own web site - Java Swing - O Reilly 23.2.6.1 Properties The PlainView

Tuesday, December 25th, 2007

Java Swing - O Reilly 23.2.6.1 Properties The PlainView class modifies the implementation of the View properties shown in Table 23.4. See the description of View properties for details on these properties. Setting the parent causes the container (the JTextComponent) to be retrieved and cached for use in determining things such as the component’s font. The preferredSpan for the X_AXIS is based on the width of the text, while the preferredSpan for the Y_AXIS is determined by multiplying the height of the containing component’s font by the number of child Elements (lines) contained by element. The element property must be specified in the constructor. Table 23.4, PlainView Properties Property Data Type get is set bound Default Value element* Element From constructor preferredSpan (indexed)* float Described later See also properties from the View class (Table 23.2). 23.2.6.2 Field There is one protected field in the PlainView class: protected FontMetrics metrics Contains the FontMetrics for the font currently in use. 23.2.6.3 Constructor public PlainView(Element elem) Creates a View for the input Element. 23.2.6.4 Document Event Methods The following methods override the empty implementations provided by View for the methods called when changes are made to the Element for which this View is responsible: public void changedUpdate(DocumentEvent changes, Shape a, ViewFactory f ) public void insertUpdate(DocumentEvent changes, Shape a, ViewFactory f ) public void removeUpdate(DocumentEvent changes, Shape a, ViewFactory f ) Call a package private method (updateDamage()), which calls repaint() on the View’s JTextComponent if lines have been added or removed. If not, only the area covering the modified line is repainted. - 762
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.

Top ten web hosting - Java Swing - O Reilly Returns the document offset

Monday, December 24th, 2007

Java Swing - O Reilly Returns the document offset of the beginning of the word that comes before the given document offset. public static final int getRowEnd(JTextComponent c, int offs) throws BadLocationException Returns the document offset at the end of the row containing offs. public static final int getRowStart(JTextComponent c, int offs) throws BadLocationException Returns the document offset at the start of the row containing offs. public static final int getTabbedTextOffset(Segment s, FontMetrics metrics, int x0, int x, TabExpander e, int startOffset) Returns an offset into the given Segment. The x0 parameter specifies the view location of the start of the text, while x specifies the view location to be mapped to an offset into the Segment. Tabs will be expanded using the specified TabExpander, based on the given startOffset. public static final int getTabbedTextWidth(Segment s, FontMetrics metrics, int x, TabExpander e, int startOffset) Returns the width, in points, of the given Segment of text with tabs expanded. The x argument is the starting point of the text. Tabs will be expanded using the specified TabExpander, based on the given startOffset. public static final int getWordEnd(JTextComponent c, int offs) throws BadLocationException Returns the document offset of the character after the last character in the word containing offs. public static final int getWordStart(JTextComponent c, int offs) throws BadLocationException Returns the document offset of the first character in the word containing offs. 23.2.6 The PlainView Class This View class is used for simple text components rendered in a single font and color. Components that use this type of view include JTextField, JPasswordField, and JTextArea (with line wrap turned off). The first two will actually use subclasses of PlainView, defined next, but most of the work of those subclasses is done here. Figure 23.5 shows three components using variations of the PlainView class. Note that the JTextArea uses a single view to represent multiple lines of unwrapped text. Figure 23.5. Text components using PlainView (and subclasses) - 761
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.

Java Swing - O Reilly public abstract float getPartialSpan(int (Best web site)

Monday, December 24th, 2007

Java Swing - O Reilly public abstract float getPartialSpan(int p0, int p1) Returns a value indicating the span needed to cover the range defined by the given document offsets. Implementations may assume that there are no tabs in the given range. 23.2.5 The Utilities Class This class defines a set of convenient static methods used by the text package. We introduce this class here because several of these methods are used by the View subclasses. 23.2.5.1 Public Static Methods public static final int drawTabbedText(Segment s, int x, int y, Graphics g, TabExpander e, int startOffset) Draws the specified text Segment on the given Graphics at the desired location. Tabs will be expanded using the specified TabExpander, based on startOffset. The return value is the x-coordinate following the drawn text. public static final int getBreakLocation(Segment s, FontMetrics metrics, int x0, int x, TabExpander e, int startOffset) Tries to find a suitable line-break location by looking for whitespace in the given Segment. public static final int getNextWord(JTextComponent c, int offs)throws BadLocationException Returns the document offset of the beginning of the word that follows the given document offset. public static final Element getParagraphElement(JTextComponent c, int offs) Returns the paragraph element in use at the given document offset. If the component’s model is a StyledDocument, the StyledDocument.getParagraphElement() method is used. Otherwise, the document’s root element is queried for the child containing the given offset. public static final int getPositionAbove(JTextComponent c, int offs, int x)throws BadLocationException Returns the document position closest to the given x view coordinate in the row above the row containing the document offset offs. public static final int getPositionBelow(JTextComponent c, int offs, int x) throws BadLocationException Returns the document position closest to the given x view coordinate in the row below the row containing the document offset offs. public static final int getPreviousWord(JTextComponent c, int offs)throws BadLocationException - 760
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.

Web site template - Java Swing - O Reilly Indicates that something was

Sunday, December 23rd, 2007

Java Swing - O Reilly Indicates that something was removed from the portion of the Document this View is responsible for. The default implementation does nothing. 23.2.1.6 Abstract Method This method must be implemented by all concrete subclasses of View: public abstract void paint(Graphics g, Shape allocation) Renders the View within the bounds of the given Shape on the given Graphics. 23.2.2 The ViewFactory Interface ViewFactory specifies an interface for the creation of View objects used to render some portion of a Document. Classes that implement this interface must determine the type of View object to be created based on the type of Element passed in to the factory. We’ll see a lot more about the ViewFactory interface, and classes that implement it, in the next chapter. 23.2.2.1 Factory Method public abstract View create(Element elem) Creates a View for the specified Element. The type of View created is typically based on the name of the Element. 23.2.3 The TabExpander Interface TabExpander is a simple interface implemented by certain View classes (ParagraphView, PlainView, and WrappedPlainView), to define tab expansion. 23.2.3.1 Methods public abstract float nextTabStop( float x, int tabOffset) Returns the next tab stop position after the given position. Values are expressed in points. For example, a view with tab stops every 80 points, starting at zero, would return 240.0 for an input of 227.0. The second parameter is a document offset at which a tab is to be inserted. This offset may be used by implementations of this method that support different types of alignment and may need to know more than just the pixel position. For example, the view may handle tab expansion for centered text differently than for left-justified text. 23.2.4 The TabableView Interface This interface is used by view classes whose size is dependent on tabs. It declares two methods used to obtain the size of some portion of the View. 23.2.4.1 Methods public abstract float getTabbedSpan( float x, TabExpander e) Returns a value indicating the span for the View, starting at the specified point and using the given TabExpander to expand tabs. - 759
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

Java Swing - O Reilly public void preferenceChanged(View child, (Affordable web hosting)

Sunday, December 23rd, 2007

Java Swing - O Reilly public void preferenceChanged(View child, boolean width, boolean height) Indicates that a child View’s size has changed. The boolean parameters indicate which dimensions have been modified. The default implementation just passes the call up to the View’s parent. public void setSize( float width, float height) Sets the size of the View, causing appropriate layout. The default implementation does nothing. public abstract int viewToModel( float x, float y, Shape a, Position.Bias[] biasReturn) Converts the specified view location to the closest corresponding model offset. It is up to the concrete implementations of this method to determine how to handle Shapes that encompass multiple model positions. biasReturn is an output parameter; on exit, it should be populated with a single value (Bias.Forward or Bias.Backward), indicating whether the given point was closer to the next character or the previous one. Before looking at the subclasses of View, we’ll take a quick detour to examine a few other view- related interfaces and classes. 23.2.1.5 Update Methods These methods are variations on the methods defined in the DocumentListener interface. They are called in response to DocumentEvents being sent to the DefaultTextUI. public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f ) Indicates that attributes were changed that affect the portion of the Document this View is responsible for. This default implementation does nothing. public void insertUpdate(DocumentEvent e, Shape a, ViewFactory f ) Indicates that something was inserted into the portion of the Document this View is responsible for. The default implementation does nothing. public void removeUpdate(DocumentEvent e, Shape a, ViewFactory f ) - 758
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

Web proxy server - Java Swing - O Reilly Creates a View to

Sunday, December 23rd, 2007

Java Swing - O Reilly Creates a View to render some portion of the Element represented by the View the method is called on. The parameters define a character range which must be a subrange of the characters covered by this View’s Element. The range can be used to determine the size of different possible fragments of a View, when trying to determine where to break it. This default implementation returns this, since View does not support breaking by default. public int getBreakWeight(int axis, float pos, float len) Returns a “score,” indicating how good a break would be in this view. The pos and len parameters indicate the potential starting point of the broken view, and the length (from pos) where a break is being considered. The return value may be one of the constants listed in Table 23.3, or any other integer value. The higher the number, the higher the desirability of the break. Any value less than or equal to BadBreakWeight indicates that the View should definitely not be broken. A value of ForcedBreakWeight or higher should always cause the View to be broken. This implementation returns BadBreakWeight, unless the specified length is greater than the preferredSpan for this View, in which case GoodBreakWeight is returned (meaning that the entire View would be the fragment). public Shape getChildAllocation(int index, Shape a) Returns the allocated shape for the contained View at the specified index. This implementation returns null, since it does not directly support child Views. getNextVisualPositionFrom(int pos, PositionBias b, Shape a, int direction, PositionBias.Bias[] biasRet) throws BadLocationException This method allows the view to specify the next location the cursor should be placed. The direction parameter should be one of NORTH, SOUTH, EAST, or WEST as defined in SwingConstants. For NORTH and SOUTH, this method uses Utilities.getPostionAbove() and getPositionBelow(). For EAST and WEST, it just returns the next or previous position, respectively. The b and biasRet parameters are currently unused. public abstract Shape modelToView(int pos, Shape a, Position.Bias b)throws BadLocationException Returns an output rectangle (aShape) that gives the location of the given position pos within the model, using the view coordinates. The input rectangle a shows the area occupied by this view. If not supplied, the bias defaults to Position.Bias.Forward. Figure 23.4 shows how this method might work. It shows the input and output rectangles for a view for which a mapping from position 9 (the “n” in “never”) was requested. The output rectangle reflects the height of the font, but typically has zero width. Figure 23.4. Model to view - 757
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Java Swing - O Reilly The remaining properties are (Web hosting company)

Saturday, December 22nd, 2007

Java Swing - O Reilly The remaining properties are technically indexed properties, but their index values must be X_AXIS or Y_AXIS. In other words, each property is really two properties one for the x axis and one for the y axis. The first such property is alignment . It describes the desired alignment for the view, where indicates origin alignment, 1 indicates alignment to the full span away from the origin, and 0.5 (the default) indicates centered alignment. The other four properties help determine the minimum, maximum, and preferred size of the component using the view. preferredSpan reflects the View’s preferred size along a particular axis. resizeWeight is used to determine the minimum and maximum size of the view. A value of (or less) indicates that the view should not be resized. The minimumSpan and maximumSpan of a view with a resizeWeight of zero are equal to the preferredSpan. Otherwise (if resizeWeight > 0), the minimumSpan is considered to be 0, while the maximumSpan is Integer.MAX_VALUE. 23.2.1.2 Constructor public View(Element elem) Creates a View to represent the given Element. 23.2.1.3 Constants View defines the constants shown in Table 23.3. The first four are used in the getBreakWeight() method, described later. The others apply to the three properties that are indexed based on an axis. Table 23.3, View Constants Name Data Type Description BadBreakWeight int The View should not be broken in fragments for formatting purposes GoodBreakWeight int The View supports splitting, but that there is probably a better place to break the view ExcellentBreakWeight int The View supports splitting and this is a very good place to break ForcedBreakWeight int The View supports splitting and it must be broken to be displayed properly X_AXIS int Used to specify the x-axis (same as SwingConstants.HORIZONTAL) Y_AXIS int Used to specify the y-axis (same as SwingConstants.VERTICAL) 23.2.1.4 Miscellaneous Public Methods public View breakView(int axis, int offset, float pos, float len) Requests a break in the current view along the specified axis. The offset indicates the document model position at which the break should begin, while pos and len give the view position along the specified axis that the broken view should occupy. The default implementation does not support breaking, so it returns this. Subclasses that override this method and support breaking should return a new view object, representing the requested subsection of this View. For text views like LabelView, breaking along the x-axis allows support for wrapping text to cover multiple lines. Views such as ParagraphView, which span multiple lines with a single view, may need to support y-axis breaking as well. public View createFragment(int p0, int p1) - 756
We recommend high quality webhost to host and run your jsp application: christian web host services.