java.lang.Object
org.jhotdraw8.fxbase.beans.AbstractPropertyBean
org.jhotdraw8.draw.AbstractDrawingView
org.jhotdraw8.draw.SimpleDrawingView
- All Implemented Interfaces:
DrawingView,RenderContext,WritableRenderContext,PropertyBean,ReadOnlyPropertyBean
A simple implementation of
DrawingView.
The SimpleDrawingView has the following scene structure:
- "jhotdraw8-drawing-view" –
BorderPane
-
Property Summary
PropertiesTypePropertyDescriptionjavafx.beans.property.ObjectProperty<Figure> The active layer of the drawing.The constrainer.javafx.beans.property.ReadOnlyObjectProperty<Drawing> The drawing model.javafx.beans.property.ReadOnlyBooleanPropertyThe focused property is set to true, when the DrawingView has input focus.javafx.beans.property.ReadOnlySetProperty<Handle> The handles.The drawing model.javafx.beans.property.DoublePropertyThe scale factor of the drawing view.Properties inherited from class org.jhotdraw8.draw.AbstractDrawingView
activeHandle, clipboardInputFormat, clipboardOutputFormat, editor, selectedFigures, tool -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe style class of the canvas pane is "jhotdraw8-drawing-view-canvas-region".static final StringThe style class of the drawing view is "jhotdraw8-drawing-view".Fields inherited from class org.jhotdraw8.fxbase.beans.AbstractPropertyBean
propertiesFields inherited from interface org.jhotdraw8.draw.DrawingView
ACTIVE_HANDLE_PROPERTY, ACTIVE_PARENT_PROPERTY, CLIPBOARD_INPUT_FORMAT_PROPERTY, CLIPBOARD_OUTPUT_FORMAT_PROPERTY, CONSTRAINER_PROPERTY, DRAWING_PROPERTY, EDITOR_PROPERTY, FOCUSED_PROPERTY, MODEL_PROPERTY, SELECTED_FIGURES_PROPERTY, TOOL_PROPERTY, ZOOM_FACTOR_PROPERTYFields inherited from interface org.jhotdraw8.draw.render.RenderContext
CLIP_BOUNDS, DPI, MAX_NODES_PER_LAYER, RENDER_NUMBER_OF_PAGES, RENDER_PAGE, RENDER_PAGE_INTERNAL_NUMBER, RENDER_PAGE_NUMBER, RENDER_TIMESTAMP, RENDERING_INTENT, SYSTEM_COLOR_CONVERTER_KEY, UNIT_CONVERTER_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjavafx.beans.property.ObjectProperty<Figure> The active layer of the drawing.voidThe constrainer.voidjavafx.beans.property.ReadOnlyObjectProperty<Drawing> The drawing model.void@Nullable javafx.scene.NodefindFigureNode(Figure figure, double vx, double vy) Finds the front-most node of the specified figure that contains the specified view coordinates.findFigures(double vx, double vy, boolean decompose, Predicate<Figure> predicate) Finds the figure at the given view coordinates behind the given figure.findFiguresInside(double vx, double vy, double vwidth, double vheight, boolean decompose) Returns all figures that lie within the specified bounds given in view coordinates.findFiguresIntersecting(double vx, double vy, double vwidth, double vheight, boolean decompose, Predicate<Figure> predicate) Returns all figures that intersect the specified bounds given in view coordinates.@Nullable HandlefindHandle(double vx, double vy) Finds the handle at the given view coordinates.javafx.beans.property.ReadOnlyBooleanPropertyThe focused property is set to true, when the DrawingView has input focus.getFiguresWithCompatibleHandle(Collection<Figure> figures, Handle handle) Gets selected figures with the same handle.javafx.scene.NodegetNode()Returns thejavafx.scene.Nodeof the DrawingView.@Nullable javafx.scene.NodeGets the node which is used to render the specified figure by the drawing view.javafx.scene.transform.TransformReturns the view to world transformation.javafx.geometry.BoundsReturns the visible rectangle of the drawing view in view coordinates.javafx.scene.transform.TransformReturns the world to view transformation.javafx.beans.property.ReadOnlySetProperty<Handle> The handles.protected voidprotected voidprotected voidvoidPlays a short animation on the handles to make them easier discoverable.The drawing model.protected voidonToolChanged(javafx.beans.Observable observable, @Nullable Tool oldValue, @Nullable Tool newValue) voidFor testing: paints the drawing immediately.voidprotected voidrepaint()voidscrollRectToVisible(javafx.geometry.Bounds boundsInView) Scrolls the specified rectangle to visible.voidSelects all enabled and selectable figures in all enabled layers.javafx.beans.property.DoublePropertyThe scale factor of the drawing view.Methods inherited from class org.jhotdraw8.draw.AbstractDrawingView
activeHandleProperty, clipboardInputFormatProperty, clipboardOutputFormatProperty, copy, cut, editorProperty, paste, selectedFiguresProperty, set, toolPropertyMethods inherited from class org.jhotdraw8.fxbase.beans.AbstractPropertyBean
get, getNonNull, getPropertiesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jhotdraw8.draw.DrawingView
findFigure, findFigure, findFigure, findFigure, findFigures, findFigures, findFiguresInside, findFiguresIntersecting, findFiguresIntersecting, getActiveHandle, getActiveParent, getClipboardInputFormat, getClipboardOutputFormat, getClosestFigure, getConstrainer, getDrawing, getEditor, getHandles, getModel, getSelectedFigures, getSelectionAnchor, getSelectionLead, getTool, getZoomFactor, scrollFigureToVisible, scrollSelectedFiguresToVisible, setActiveHandle, setActiveParent, setClipboardInputFormat, setClipboardOutputFormat, setConstrainer, setDrawing, setEditor, setModel, setTool, setZoomFactor, viewToWorld, viewToWorld, viewToWorld, worldToView, worldToView, worldToViewMethods inherited from interface org.jhotdraw8.fxbase.beans.PropertyBean
getProperty, put, remove, setNonNull, valueAtMethods inherited from interface org.jhotdraw8.fxbase.beans.ReadOnlyPropertyBean
get, getNonNull
-
Property Details
-
activeParent
- Returns:
- the active layer of the drawing. Returns null if the drawing has no layers or no layer has been activated.
- See Also:
-
constrainer
- Returns:
- the constrainer property, with
getBean()returning this drawing view, andgetName()returningCONSTRAINER_PROPERTY. - See Also:
-
drawing
- Returns:
- the drawing model property
- See Also:
-
focused
public javafx.beans.property.ReadOnlyBooleanProperty focusedProperty- Returns:
- the focused property, with
getBean()returning this drawing view, andgetName()returningFOCUSED_PROPERTY. - See Also:
-
handles
- Returns:
- the handles that are currently being displayed on this drawing view.
- See Also:
-
model
- Returns:
- the drawing model property, with
getBean()returning this drawing view, andgetName()returningDRAWING_PROPERTY. - See Also:
-
zoomFactor
public javafx.beans.property.DoubleProperty zoomFactorProperty- Returns:
- The zoom factor. The value is always greater than 0. Values larger than 1 cause a magnification. Values between 0 and 1 causes a minification.
- See Also:
-
-
Field Details
-
CANVAS_REGION_STYLE_CLASS
The style class of the canvas pane is "jhotdraw8-drawing-view-canvas-region".- See Also:
-
DRAWING_VIEW_STYLE_CLASS
The style class of the drawing view is "jhotdraw8-drawing-view".- See Also:
-
-
Constructor Details
-
SimpleDrawingView
public SimpleDrawingView()
-
-
Method Details
-
activeParentProperty
Description copied from interface:DrawingViewThe active layer of the drawing.- Returns:
- the
activeParentproperty - See Also:
-
clearSelection
public void clearSelection() -
constrainerProperty
Description copied from interface:DrawingViewThe constrainer.- Returns:
- the
constrainerproperty - See Also:
-
deleteSelection
public void deleteSelection() -
drawingProperty
Description copied from interface:DrawingViewThe drawing model.- Returns:
- the
drawingproperty - See Also:
-
duplicateSelection
public void duplicateSelection() -
findFigureNode
Description copied from interface:DrawingViewFinds the front-most node of the specified figure that contains the specified view coordinates.- Parameters:
figure- the figurevx- x in view coordinatesvy- y in view coordinates- Returns:
- A node or null
-
findFigures
public List<Map.Entry<Figure,Double>> findFigures(double vx, double vy, boolean decompose, Predicate<Figure> predicate) Description copied from interface:DrawingViewFinds the figure at the given view coordinates behind the given figure. Figures are searched in Z-order from front to back.- Parameters:
vx- x in view coordinatesvy- y in view coordinatesdecompose- whether to decompose the figures- Returns:
- A list of figures from front to back. Each entry contains the figure and the distance of the figure to vx,vy. Distance 0 means that vx,vy is inside the figure.
-
findFiguresInside
public List<Map.Entry<Figure,Double>> findFiguresInside(double vx, double vy, double vwidth, double vheight, boolean decompose) Description copied from interface:DrawingViewReturns all figures that lie within the specified bounds given in view coordinates. The figures are returned in Z-order from back to front. Skips disabled figures.- Parameters:
vx- x in view coordinatesvy- y in view coordinatesvwidth- width in view coordinatesvheight- height in view coordinatesdecompose- whether to decompose the figures- Returns:
- A list of figures from front to back. Each entry contains the figure and the distance of the figure to vx,vy. Distance 0 means that vx,vy is inside the figure.
-
findFiguresIntersecting
public List<Map.Entry<Figure,Double>> findFiguresIntersecting(double vx, double vy, double vwidth, double vheight, boolean decompose, Predicate<Figure> predicate) Description copied from interface:DrawingViewReturns all figures that intersect the specified bounds given in view coordinates. The figures are returned in Z-order from front to back. Skips disabled figures.- Parameters:
vx- x in view coordinatesvy- y in view coordinatesvwidth- width in view coordinatesvheight- height in view coordinatesdecompose- whether to decompose the figurespredicate- predicate for filtering figures- Returns:
- A list of figures from front to back
-
findHandle
Description copied from interface:DrawingViewFinds the handle at the given view coordinates. Handles are searched in Z-order from front to back. Skips handles which are not selectable.- Parameters:
vx- x in view coordinatesvy- y in view coordinates- Returns:
- A handle or null
-
focusedProperty
public javafx.beans.property.ReadOnlyBooleanProperty focusedProperty()Description copied from interface:DrawingViewThe focused property is set to true, when the DrawingView has input focus.- Returns:
- the
focusedproperty
-
getFiguresWithCompatibleHandle
Description copied from interface:DrawingViewGets selected figures with the same handle.- Parameters:
figures- selected figureshandle- a handle- Returns:
- A collection containing the figures with compatible handles.
-
getNode
public javafx.scene.Node getNode()Description copied from interface:DrawingViewReturns thejavafx.scene.Nodeof the DrawingView.- Returns:
- a node
-
getNode
Description copied from interface:DrawingViewGets the node which is used to render the specified figure by the drawing view.- Parameters:
f- The figure- Returns:
- The node associated to the figure
-
getViewToWorld
public javafx.scene.transform.Transform getViewToWorld()Description copied from interface:DrawingViewReturns the view to world transformation.- Returns:
- the transformation;
-
getVisibleRect
public javafx.geometry.Bounds getVisibleRect()Description copied from interface:DrawingViewReturns the visible rectangle of the drawing view in view coordinates.- Returns:
- the portion of the DrawingView that is visible on screen.
-
getWorldToView
public javafx.scene.transform.Transform getWorldToView()Description copied from interface:DrawingViewReturns the world to view transformation.- Returns:
- the transformation
-
handlesProperty
Description copied from interface:DrawingViewThe handles.Note: The handles are represented by a
SequencedSetbecause the sequence of the handles is important.- Returns:
- the
handlesproperty - See Also:
-
initBehavior
protected void initBehavior() -
initStyle
protected void initStyle() -
invalidateHandles
protected void invalidateHandles()- Specified by:
invalidateHandlesin classAbstractDrawingView
-
jiggleHandles
public void jiggleHandles()Description copied from interface:DrawingViewPlays a short animation on the handles to make them easier discoverable. -
modelProperty
Description copied from interface:DrawingViewThe drawing model.- Returns:
- the
modelproperty - See Also:
-
onToolChanged
protected void onToolChanged(javafx.beans.Observable observable, @Nullable Tool oldValue, @Nullable Tool newValue) - Specified by:
onToolChangedin classAbstractDrawingView
-
paintImmediately
public void paintImmediately()For testing: paints the drawing immediately. -
recreateHandles
public void recreateHandles() -
repaint
protected void repaint()- Specified by:
repaintin classAbstractDrawingView
-
scrollRectToVisible
public void scrollRectToVisible(javafx.geometry.Bounds boundsInView) Description copied from interface:DrawingViewScrolls the specified rectangle to visible.- Parameters:
boundsInView- A rectangle in view coordinates.
-
selectAll
public void selectAll()Selects all enabled and selectable figures in all enabled layers. -
zoomFactorProperty
public javafx.beans.property.DoubleProperty zoomFactorProperty()Description copied from interface:DrawingViewThe scale factor of the drawing view.- Returns:
- the
zoomFactorproperty - See Also:
-