Package jpicedt.graphic.view
Class DefaultViewFactory.TextViewHybrid
- java.lang.Object
-
- jpicedt.graphic.view.AbstractView
-
- jpicedt.graphic.view.DefaultViewFactory.LeafElementView
-
- jpicedt.graphic.view.DefaultViewFactory.TextViewHybrid
-
- All Implemented Interfaces:
java.lang.Runnable,View,ViewConstants
- Enclosing class:
- DefaultViewFactory
public class DefaultViewFactory.TextViewHybrid extends DefaultViewFactory.LeafElementView implements java.lang.Runnable
a View for rendering Text's based on bitmaps (when available) or TextLayout (when image not available)
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanareDimensionsComputedprotected intfileDPIprotected java.awt.image.BufferedImageimageprotected doublestrxprotected doublestryprotected java.awt.geom.AffineTransformtext2ModelTrprotected java.awt.font.TextLayouttextLayout-
Fields inherited from class jpicedt.graphic.view.DefaultViewFactory.LeafElementView
interiorPaint, lineWidth, outlinePaint, outlineStroke, overStrikeWidth, shadowBounds, shape
-
Fields inherited from class jpicedt.graphic.view.AbstractView
bounds, element, highlighter
-
Fields inherited from interface jpicedt.graphic.view.ViewConstants
BARBELL_SIZE, CLICK_DISTANCE
-
-
Constructor Summary
Constructors Constructor Description TextViewHybrid(PicText te)construct a new View for the given PicRectangle
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchangedUpdate(DrawingEvent.EventType eventType)Give notification from the model that a change occured to the text this view is responsible for rendering.protected voidgetDimensionsFromLogFile(java.io.BufferedReader reader, PicText text)protected doublegetRotation()Returns the text rotation in radians : subclassers that don't support rotating text may return 0 here.java.awt.font.TextLayoutgetTextLayout()[SR:pending] make this view implement aka TextEditableView interface (or something like it), where TextEditableView is a subinterface of View with text-editing specific capabilities.java.awt.geom.AffineTransformgetTextToModelTransform()Return an affine transform which translat b/w the TextLayout coordinate system and the jpicedt.graphic.model coordinate system.HitInfohitTest(PEMouseEvent e)This implementation callssuper.hitTestand returns the result if non-null (this should be a HitInfo.Point), then returns a HitInfo.Interior if the mouse-click occured inside the text bound (as defined by text layout)voidpaint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D a)Render the View to the given graphic context.voidrun()protected voidsyncBounds()Synchronizes bounding box with the model ;protected voidsyncFrame()synchronize frame shape and location (TextLayout only) ; this is called by syncShape(), so that subclasser might override easily when only rectangular shapes are availables.protected voidsyncShape()Synchronize the textLayout and the shape (=frame box, by calling syncFrame) with the model When TextLayout is used, this delegates to getRotation() where computing rotation angle is concerned, and updates the AffineTransform returned by getTextToModelTransform().protected voidsyncStringLocation()update strx stry = location of TextLayout's bottom-Left corner with respect to PicText's anchor-point-
Methods inherited from class jpicedt.graphic.view.DefaultViewFactory.LeafElementView
getViewFactory, syncAttributes
-
Methods inherited from class jpicedt.graphic.view.AbstractView
getBounds, getContainer, getDrawing, getElement, getGraphics, getHighlighter, getParentView, hitTest, paintHighlighter, repaint, setElement, setHighlighter
-
-
-
-
Field Detail
-
strx
protected double strx
-
stry
protected double stry
-
textLayout
protected java.awt.font.TextLayout textLayout
-
text2ModelTr
protected java.awt.geom.AffineTransform text2ModelTr
-
image
protected java.awt.image.BufferedImage image
-
areDimensionsComputed
protected boolean areDimensionsComputed
-
fileDPI
protected int fileDPI
-
-
Constructor Detail
-
TextViewHybrid
public TextViewHybrid(PicText te)
construct a new View for the given PicRectangle
-
-
Method Detail
-
getRotation
protected double getRotation()
Returns the text rotation in radians : subclassers that don't support rotating text may return 0 here. Used by TextLayout only.
-
changedUpdate
public void changedUpdate(DrawingEvent.EventType eventType)
Give notification from the model that a change occured to the text this view is responsible for rendering.- Specified by:
changedUpdatein interfaceView- Overrides:
changedUpdatein classDefaultViewFactory.LeafElementView
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
syncStringLocation
protected void syncStringLocation()
update strx stry = location of TextLayout's bottom-Left corner with respect to PicText's anchor-point
-
syncShape
protected void syncShape()
Synchronize the textLayout and the shape (=frame box, by calling syncFrame) with the model When TextLayout is used, this delegates to getRotation() where computing rotation angle is concerned, and updates the AffineTransform returned by getTextToModelTransform().- Overrides:
syncShapein classDefaultViewFactory.LeafElementView
-
syncFrame
protected void syncFrame()
synchronize frame shape and location (TextLayout only) ; this is called by syncShape(), so that subclasser might override easily when only rectangular shapes are availables.
-
getDimensionsFromLogFile
protected void getDimensionsFromLogFile(java.io.BufferedReader reader, PicText text)
-
syncBounds
protected void syncBounds()
Synchronizes bounding box with the model ;- Overrides:
syncBoundsin classDefaultViewFactory.LeafElementView
-
paint
public void paint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D a)Render the View to the given graphic context. This implementation render the interior first, then the outline.- Specified by:
paintin interfaceView- Overrides:
paintin classDefaultViewFactory.LeafElementViewa- the current graphic clip
-
hitTest
public HitInfo hitTest(PEMouseEvent e)
This implementation callssuper.hitTestand returns the result if non-null (this should be a HitInfo.Point), then returns a HitInfo.Interior if the mouse-click occured inside the text bound (as defined by text layout)- Overrides:
hitTestin classDefaultViewFactory.LeafElementView- Returns:
- a HitInfo corresponding to the given mouse-event
-
getTextLayout
public java.awt.font.TextLayout getTextLayout()
[SR:pending] make this view implement aka TextEditableView interface (or something like it), where TextEditableView is a subinterface of View with text-editing specific capabilities. Returns the TextLayout which is responsible for painting the textual content of this element
-
getTextToModelTransform
public java.awt.geom.AffineTransform getTextToModelTransform()
Return an affine transform which translat b/w the TextLayout coordinate system and the jpicedt.graphic.model coordinate system. [SR:pending] refactor method name to something more explanatory
-
-