Package jpicedt.graphic.view
Class DefaultViewFactory
- java.lang.Object
-
- jpicedt.graphic.view.DefaultViewFactory
-
- All Implemented Interfaces:
PicObjectConstants,ViewFactory
- Direct Known Subclasses:
EepicViewFactory,PstricksViewFactory
public class DefaultViewFactory extends java.lang.Object implements ViewFactory, PicObjectConstants
This is the default factory used to create a View for a given Element ; should be used when one wants to render all Element's attributes ; otherwise subclass with your own ViewFactory and override :- createView : simply return your own View for some or all Element's (then call super.createView)
- factory methods, e.g. createStroke, createPaintForInterior, createPaintForOutline, ... : these methods are called by various View's to extract rendering information from PicAttributeSet's when common behaviour is expected, whatever the particular Element being actually rendered.
- Since:
- jPicEdt 1.3.2
- Version:
- $Id: DefaultViewFactory.java,v 1.47.2.2 2007/09/02 11:56:29 reynal Exp $
- Author:
- Sylvain Reynal
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classDefaultViewFactory.AbstractCurveViewa View for rendering any concrete implementation of jpicedt.graphic.model.AbstractCurveclassDefaultViewFactory.EllipseViewa View for rendering ellipses defined by a parallelogramprotected classDefaultViewFactory.LeafElementViewa View for rendering leaf-elements ; implements attributes caching, and shape rendering.classDefaultViewFactory.ParallelogramViewa View for rendering parallelogramsclassDefaultViewFactory.PicNodeConnectionViewa View for rendering any concrete implementation of jpicedt.graphic.model.PicNodeConnection This view is responsible for painting the edge only! Nodes are rendered with their own view (provided they were added to the drawing at some early point...)classDefaultViewFactory.TextViewa View for rendering Text's from TextLayout'sclassDefaultViewFactory.TextViewHybrida View for rendering Text's based on bitmaps (when available) or TextLayout (when image not available)
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringKEY_TEXT_FONTkey used to fetch the font family value from a Properties objectstatic java.awt.FontTEXT_FONT_DEFAULTdefault font used to display text with TextViewprotected static floatTEXT_FONT_SCALEscaling factor to be applied to the default font before rendering, so as to compensate for zoom factorprotected static java.awt.FonttextFontfont used to display text strings with TextView-
Fields inherited from interface jpicedt.graphic.model.PicObjectConstants
ARROW_GLOBAL_SCALE_LENGTH, ARROW_GLOBAL_SCALE_WIDTH, ARROW_INSET_SCALE, ARROW_LENGTH_SCALE, ARROW_WIDTH_LINEWIDTH_SCALE, ARROW_WIDTH_MINIMUM_MM, BRACKET_LENGTH_SCALE, CROSSHATCH, CROSSHATCH_FILLED, DASH_OPAQUE, DASH_TRANSPARENT, DASH1, DASH2, DASH3, DASHED, DIMEN, DOT_SEP, DOT_SEP1, DOT_SEP2, DOT_SEP3, DOTTED, DOUBLE_COLOR, DOUBLE_LINE, DOUBLE_SEP, FILL_COLOR, FILL_STYLE, HATCH_ANGLE, HATCH_COLOR, HATCH_SEP, HATCH_WIDTH, HLINES, HLINES_FILLED, INNER, LEFT_ARROW, LINE_COLOR, LINE_STYLE, LINE_WIDTH, MIDDLE, NONE, OUTER, OVER_STRIKE, OVER_STRIKE_COLOR, OVER_STRIKE_WIDTH, POLYDOTS_ANGLE, POLYDOTS_CIRCLE, POLYDOTS_DISK, POLYDOTS_PENTAGON, POLYDOTS_PENTAGON_FILLED, POLYDOTS_PLUS, POLYDOTS_SCALE_H, POLYDOTS_SCALE_V, POLYDOTS_SIZE_LINEWIDTH_SCALE, POLYDOTS_SIZE_MINIMUM_MM, POLYDOTS_SQUARE, POLYDOTS_SQUARE_FILLED, POLYDOTS_STYLE, POLYDOTS_SUPERIMPOSE, POLYDOTS_TRIANGLE, POLYDOTS_TRIANGLE_FILLED, PS_POINT, PST_CUSTOM, RBRACKET_LENGTH_SCALE, RIGHT_ARROW, SHADOW, SHADOW_ANGLE, SHADOW_COLOR, SHADOW_SIZE, SOLID, TBAR_WIDTH_LINEWIDTH_SCALE, TBAR_WIDTH_MINIMUM_MM, TEXT_BOX_CIRCLE, TEXT_BOX_NO_FRAME, TEXT_BOX_OVAL, TEXT_BOX_RECTANGLE, TEXT_FRAME, TEXT_HALIGN_CENTER, TEXT_HALIGN_LEFT, TEXT_HALIGN_RIGHT, TEXT_HOR_ALIGN, TEXT_ROTATION, TEXT_VALIGN_BASELINE, TEXT_VALIGN_BOTTOM, TEXT_VALIGN_CENTER, TEXT_VALIGN_TOP, TEXT_VERT_ALIGN, VLINES, VLINES_FILLED
-
-
Constructor Summary
Constructors Constructor Description DefaultViewFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidconfigure(java.util.Properties preferences)Configure static fields using the given Properties objectprotected ArrowcreateArrow(PicAttributeSet set, PicAttributeName direction)protected java.awt.PaintcreatePaintForInterior(PicAttributeSet set)Returns a Paint object from the given attributes, that is suited for painting the interior of a shape.protected java.awt.PaintcreatePaintForOutline(PicAttributeSet set)Returns a Paint object from the given attributes, that is suited for painting an outline, or null if LINE_STYLE is NONE.protected java.awt.StrokecreateStroke(PicAttributeSet set)ViewcreateView(Element element)static voidmain(java.lang.String[] arg)for debugging purposeprotected voidpaintHatches(java.awt.Graphics2D g, PicAttributeSet set, java.awt.Shape shape)paint hatches (vlines,...) depending on the FILL_STYLE attributes of the given set.protected voidpaintOverStrike(java.awt.Graphics2D g, PicAttributeSet set, java.awt.Shape shape)paint overstrike depending on the OVER_STRIKE attribute and rel.protected voidpaintShadow(java.awt.Graphics2D g, PicAttributeSet set, java.awt.Shape shape)paint shadow depending on the SHADOW attribute and rel.
-
-
-
Field Detail
-
TEXT_FONT_DEFAULT
public static java.awt.Font TEXT_FONT_DEFAULT
default font used to display text with TextView
-
KEY_TEXT_FONT
public static java.lang.String KEY_TEXT_FONT
key used to fetch the font family value from a Properties object
-
TEXT_FONT_SCALE
protected static final float TEXT_FONT_SCALE
scaling factor to be applied to the default font before rendering, so as to compensate for zoom factor- See Also:
- Constant Field Values
-
textFont
protected static java.awt.Font textFont
font used to display text strings with TextView
-
-
Method Detail
-
main
public static void main(java.lang.String[] arg)
for debugging purpose
-
configure
public static void configure(java.util.Properties preferences)
Configure static fields using the given Properties object- Parameters:
properties- used to read shared parameters If null, default values are used.
-
createView
public View createView(Element element)
- Specified by:
createViewin interfaceViewFactory- Returns:
- a View for the given Element
Current implementation returns a View appropriate for the following elements :
- PicEllipse and any subclass -> EllipseView ;
- BranchElement -> CompositeView ;
- PicParallelogram -> ParallelogramView ;
- PicEllipse / PicCircleFrom3Points -> EllipseView ;
- PicText -> TextView ;
- other -> null (this give a change for the receiver to provide its own View)
-
createStroke
protected java.awt.Stroke createStroke(PicAttributeSet set)
- Returns:
- a Stroke built from the given attributes ; null if LINE_STYLE=NONE. All currently supported attributes for stroke are rendered.
-
createPaintForOutline
protected java.awt.Paint createPaintForOutline(PicAttributeSet set)
Returns a Paint object from the given attributes, that is suited for painting an outline, or null if LINE_STYLE is NONE.All currently supported attributes for painting an outline are rendered. It's up to subclassers to adapt this behavior to their need (probably by restricting it).
-
createPaintForInterior
protected java.awt.Paint createPaintForInterior(PicAttributeSet set)
Returns a Paint object from the given attributes, that is suited for painting the interior of a shape.The returned object depends on the FILL_STYLE and FILL_COLOR attributes of the given set:
- FILL_STYLE = NONE: returns null
- FILL_STYLE = SOLID, VLINES, VLINES_FILLED, HLINES, HLINES_FILLED, CROSSHATCH and CROSSHATCH_FILLED: returns a Color object created from FILL_COLOR.
jpicedt.graphic.model.PicObjectConstants) for painting the interior of shapes are rendered. [pending] gradient (need to add some attributes).
-
paintHatches
protected void paintHatches(java.awt.Graphics2D g, PicAttributeSet set, java.awt.Shape shape)paint hatches (vlines,...) depending on the FILL_STYLE attributes of the given set. Factories that don't paint hatches should override this method to do nothing.- Parameters:
shape- used to clip the hatch (ie the shape the calling view must render)
-
paintShadow
protected void paintShadow(java.awt.Graphics2D g, PicAttributeSet set, java.awt.Shape shape)paint shadow depending on the SHADOW attribute and rel. Factory that don't paint shadow should override to do nothing.- Parameters:
shape- the Shape under which to drop a shadowset- used to fetch the shadow attributes
-
paintOverStrike
protected void paintOverStrike(java.awt.Graphics2D g, PicAttributeSet set, java.awt.Shape shape)paint overstrike depending on the OVER_STRIKE attribute and rel. Factory that don't overstrike should override to do nothing.- Parameters:
shape- the Shape to overstrikeset- used to fetch the overstrike attributes
-
createArrow
protected Arrow createArrow(PicAttributeSet set, PicAttributeName direction)
- Parameters:
direction- LEFT_ARROW or RIGHT_ARROW- Returns:
- an Arrow from the given attribute set, or null if Arrow.NONE.
-
-