com.inet.html.views
Class ContentPainter

java.lang.Object
  extended by com.inet.html.views.ContentPainter
Direct Known Subclasses:
RotationPainter

public class ContentPainter
extends java.lang.Object

This class is similar to the JRE GlyphView.GlyphPainter. But since HTML does not support tabs and has no predefined Break length, these parts of the functions are removed.


Constructor Summary
ContentPainter(ContentView view)
          Creates the painter
 
Method Summary
 ContentPainter copy(ContentView target)
          Returns a copy of this painter
 int getAscent()
          Fetches the ascent above the baseline.
 float[] getCharOffsets()
          Returns the char offsets buffer of this painter.
 int getDescent()
          Fetches the descent below the baseline.
 int getHeight()
          Fetches the height of the font in PX
 float getSpan()
          Determines the span the glyphs given a start location (for tab expansion).
 boolean isCharOffsetsSet()
          If this returns true, the char offsets were set.
 boolean isReversed()
          Returns true if this painter paints an RTL content
 java.awt.Shape modelToView(int pos, javax.swing.text.Position.Bias bias, java.awt.Shape a)
          Returns the display shape for a model position
 void paint(java.awt.Graphics g, java.awt.Shape a, int start, int length, int baseline)
          Paints the glyphs representing the given range.
 void reset()
          Causes this painter to recalculate on the next run;
 void setCharOffsets(float[] charOffsets)
          Sets the char offset buffer of this painter
 void setReversed()
          Marks this painter als RTL.
 void setView(ContentView view)
          Sets the view this painter is bound to
 void sync()
          This method has to be called whenever there are changes to the render environment of the painted view.
 int viewToModel(float x, float y, java.awt.Shape a, javax.swing.text.Position.Bias[] biasReturn)
          Provides a mapping from the view coordinate space to the logical coordinate space of the model.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentPainter

public ContentPainter(ContentView view)
Creates the painter

Parameters:
view - the view, whose content will be painted by this painter, can be null
Method Detail

setView

public void setView(ContentView view)
Sets the view this painter is bound to

Parameters:
view - the view, whose content will be painted by this painter

getSpan

public float getSpan()
Determines the span the glyphs given a start location (for tab expansion).

Returns:
the span in PX

getAscent

public int getAscent()
Fetches the ascent above the baseline.

Returns:
the ascend in PX

getDescent

public int getDescent()
Fetches the descent below the baseline.

Returns:
the descent in PX

getHeight

public int getHeight()
Fetches the height of the font in PX

Returns:
the height in PX

paint

public void paint(java.awt.Graphics g,
                  java.awt.Shape a,
                  int start,
                  int length,
                  int baseline)
Paints the glyphs representing the given range.

Parameters:
g - the graphics to paint to
a - the allocation to paint to
start - the start index within the text of the view
length - the end index within the text of the view
baseline - the offset from the top of the shape to the baseline of the current line

modelToView

public java.awt.Shape modelToView(int pos,
                                  javax.swing.text.Position.Bias bias,
                                  java.awt.Shape a)
                           throws javax.swing.text.BadLocationException
Returns the display shape for a model position

Parameters:
pos - the model position
bias - forward or backward search bias
a - the shape of the parent view
Returns:
the modified shape to represent the selected model position
Throws:
javax.swing.text.BadLocationException - thrown on location errors

viewToModel

public int viewToModel(float x,
                       float y,
                       java.awt.Shape a,
                       javax.swing.text.Position.Bias[] biasReturn)
Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Parameters:
x - the X coordinate
y - the Y coordinate
a - the allocated region to render into
biasReturn - always returns Position.Bias.Forward as the zero-th element of this array
Returns:
the location within the model that best represents the given point in the view

sync

public void sync()
This method has to be called whenever there are changes to the render environment of the painted view. Otherwise the text positions can become inaccurate


getCharOffsets

public float[] getCharOffsets()
Returns the char offsets buffer of this painter. If the buffer is not yet set, this calls will force a fill of this buffer.

Returns:
the char offsets buffer of this painter, may be null

setCharOffsets

public void setCharOffsets(float[] charOffsets)
Sets the char offset buffer of this painter

Parameters:
charOffsets - the char offset buffer of this painter

isCharOffsetsSet

public boolean isCharOffsetsSet()
If this returns true, the char offsets were set.

Returns:
if true, the char offsets were set.

copy

public ContentPainter copy(ContentView target)
Returns a copy of this painter

Parameters:
target - the view to bind to
Returns:
the copy of this painter

setReversed

public void setReversed()
Marks this painter als RTL. This will invert the caret positions


isReversed

public boolean isReversed()
Returns true if this painter paints an RTL content

Returns:
true if this painter paints an RTL content

reset

public void reset()
Causes this painter to recalculate on the next run;