public class PlanComponent extends javax.swing.JComponent implements PlanView, javax.swing.Scrollable, java.awt.print.Printable
Modifier and Type | Class and Description |
---|---|
static class |
PlanComponent.IndicatorType
Indicator types that may be displayed on selected items.
|
protected static class |
PlanComponent.PaintMode
The circumstances under which the home items displayed by this component will be painted.
|
class |
PlanComponent.PlanRulerComponent
A component displaying the plan horizontal or vertical ruler associated to this plan.
|
javax.swing.JComponent.AccessibleJComponent
java.awt.Container.AccessibleAWTContainer
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
PlanView.CursorType
TransferableView.DataType, TransferableView.TransferObserver
ExportableView.FormatType
View.PointerType
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
PlanComponent(Home home,
UserPreferences preferences,
Object3DFactory object3dFactory,
PlanController controller)
Creates a new plan that displays
home . |
PlanComponent(Home home,
UserPreferences preferences,
PlanController controller)
Creates a new plan that displays
home . |
Modifier and Type | Method and Description |
---|---|
boolean |
canImportDraggedItems(java.util.List<Selectable> items,
int x,
int y)
Returns
true . |
int |
convertXModelToScreen(float x)
Returns
x converted in screen coordinates space. |
float |
convertXPixelToModel(int x)
Returns
x converted in model coordinates space. |
int |
convertYModelToScreen(float y)
Returns
y converted in screen coordinates space. |
float |
convertYPixelToModel(int y)
Returns
y converted in model coordinates space. |
protected java.awt.Cursor |
createCustomCursor(java.net.URL smallCursorImageUrl,
java.net.URL largeCursorImageUrl,
float xCursorHotSpot,
float yCursorHotSpot,
java.lang.String cursorName,
java.awt.Cursor defaultCursor)
Returns a custom cursor created from images in parameters.
|
java.lang.Object |
createTransferData(TransferableView.DataType dataType)
Returns an image of selected items in plan for transfer purpose.
|
void |
deleteFeedback()
Deletes all elements shown as feedback.
|
void |
deleteToolTipFeedback()
Deletes tool tip text from screen.
|
void |
exportData(java.io.OutputStream out,
ExportableView.FormatType formatType,
java.util.Properties settings)
Writes this plan in the given output stream at SVG (Scalable Vector Graphics) format if this is the requested format.
|
void |
exportToSVG(java.io.OutputStream out)
Writes this plan in the given output stream at SVG (Scalable Vector Graphics) format.
|
protected java.awt.Color |
getBackgroundColor(PlanComponent.PaintMode mode)
Returns the background color used to draw content.
|
java.awt.image.BufferedImage |
getClipboardImage()
Returns an image of the selected items displayed by this component
(camera excepted) with no outline at scale 1/1 (1 pixel = 1cm)
or at a smaller scale if image is larger than 100m x 100m
or if free memory is missing.
|
protected java.awt.Font |
getFont(java.awt.Font defaultFont,
TextStyle textStyle)
Returns the AWT font matching a given text style.
|
protected java.awt.FontMetrics |
getFontMetrics(java.awt.Font defaultFont,
TextStyle textStyle)
Returns the font metrics matching a given text style.
|
protected java.awt.Color |
getForegroundColor(PlanComponent.PaintMode mode)
Returns the foreground color used to draw content.
|
protected java.awt.Color |
getFurnitureOutlineColor()
Returns the color used to draw furniture outline of
the shape where a user can click to select a piece of furniture.
|
View |
getHorizontalRuler()
Returns the component used as an horizontal ruler for this plan.
|
protected java.awt.Shape |
getIndicator(Selectable item,
PlanComponent.IndicatorType indicatorType)
Returns the shape of the given indicator type.
|
protected java.awt.geom.Rectangle2D |
getItemBounds(java.awt.Graphics g,
Selectable item)
Returns the bounds of the given
item . |
protected java.util.List<Selectable> |
getPaintedItems()
Returns the collection of walls, furniture, rooms and dimension lines of the home
painted by this component wherever the level they belong to is selected or not.
|
float[] |
getPieceOfFurnitureSizeInPlan(HomePieceOfFurniture piece)
Returns the size of the given piece of furniture in the horizontal plan,
or
null if the view isn't able to compute such a value. |
float |
getPixelLength()
Returns the length in centimeters of a pixel with the current scale.
|
java.awt.Dimension |
getPreferredScrollableViewportSize() |
java.awt.Dimension |
getPreferredSize()
Returns the preferred size of this component.
|
float |
getPrintPreferredScale(float preferredWidth,
float preferredHeight)
Returns the preferred scale to ensure it can be fully printed on the given print zone.
|
float |
getPrintPreferredScale(java.awt.Graphics g,
java.awt.print.PageFormat pageFormat)
Returns the print preferred scale of the plan drawn in this component
to make it fill
pageFormat imageable size. |
float |
getScale()
Returns the scale used to display the plan.
|
int |
getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction) |
boolean |
getScrollableTracksViewportHeight() |
boolean |
getScrollableTracksViewportWidth() |
int |
getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction) |
protected java.awt.Color |
getSelectionColor()
Returns the color used to draw selection outlines.
|
float[][] |
getTextBounds(java.lang.String text,
TextStyle style,
float x,
float y,
float angle)
Returns the coordinates of the bounding rectangle of the
text centered at
the point (x ,y ). |
View |
getVerticalRuler()
Returns the component used as a vertical ruler for this plan.
|
void |
invalidate() |
boolean |
isBackgroundPainted()
Returns
true if plan's background should be painted. |
boolean |
isFormatTypeSupported(ExportableView.FormatType formatType)
Returns
true if the given format is SVG. |
boolean |
isFurnitureSizeInPlanSupported()
Returns
true if this component is able to compute the size of horizontally rotated furniture. |
boolean |
isSelectedItemsOutlinePainted()
Returns
true if the outline of home selected items should be painted. |
protected boolean |
isViewableAtLevel(Elevatable item,
Level level)
Returns
true if the given item can be viewed in the plan at a level. |
protected boolean |
isViewableAtSelectedLevel(Elevatable item)
Deprecated.
Override
isViewableAtLevel(Elevatable, Level) if you want to print different levels |
void |
makePointVisible(float x,
float y)
Ensures the point at (
x , y ) is visible,
moving scroll bars if needed. |
void |
makeSelectionVisible()
Ensures selected items are visible at screen and moves
scroll bars if needed.
|
void |
moveView(float dx,
float dy)
Moves the view from (dx, dy) unit in the scrolling zone it belongs to.
|
protected void |
paintComponent(java.awt.Graphics g)
Paints this component.
|
protected void |
paintHomeItems(java.awt.Graphics g,
float planScale,
java.awt.Color backgroundColor,
java.awt.Color foregroundColor,
PlanComponent.PaintMode paintMode)
Deprecated.
Override
paintHomeItems(Graphics, Level, float, Color, Color, PaintMode) if you want to print different levels |
protected void |
paintHomeItems(java.awt.Graphics g,
Level level,
float planScale,
java.awt.Color backgroundColor,
java.awt.Color foregroundColor,
PlanComponent.PaintMode paintMode)
Paints home items at the given scale, and with background and foreground colors.
|
int |
print(java.awt.Graphics g,
java.awt.print.PageFormat pageFormat,
int pageIndex)
Prints this component plan at the scale given in the home print attributes or at a scale
that makes it fill
pageFormat imageable size if this attribute is null . |
void |
revalidate()
Revalidates and repaints this component and its rulers.
|
void |
setAlignmentFeedback(java.lang.Class<? extends Selectable> alignedObjectClass,
Selectable alignedObject,
float x,
float y,
boolean showPointFeedback)
Sets the location point for alignment feedback.
|
void |
setAngleFeedback(float xCenter,
float yCenter,
float x1,
float y1,
float x2,
float y2)
Sets the points used to draw an angle in plan view.
|
void |
setBackgroundPainted(boolean backgroundPainted)
Sets whether plan's background should be painted or not.
|
void |
setCursor(PlanView.CursorType cursorType)
Sets the cursor of this component.
|
void |
setDimensionLinesFeedback(java.util.List<DimensionLine> dimensionLines)
Sets the given dimension lines to be drawn as feedback.
|
void |
setDraggedItemsFeedback(java.util.List<Selectable> draggedItems)
Sets the feedback of dragged items drawn during a drag and drop operation,
initiated from outside of plan view.
|
void |
setRectangleFeedback(float x0,
float y0,
float x1,
float y1)
Sets rectangle selection feedback coordinates.
|
void |
setResizeIndicatorVisible(boolean resizeIndicatorVisible)
Sets whether the resize indicator of selected wall or piece of furniture
should be visible or not.
|
void |
setScale(float scale)
Sets the scale used to display the plan.
|
void |
setSelectedItemsOutlinePainted(boolean selectedItemsOutlinePainted)
Sets whether the outline of home selected items should be painted or not.
|
void |
setToolTipEditedProperties(PlanController.EditableProperty[] toolTipEditedProperties,
java.lang.Object[] toolTipPropertyValues,
float x,
float y)
Set tool tip edition.
|
void |
setToolTipEditedPropertyValue(PlanController.EditableProperty toolTipEditedProperty,
java.lang.Object toolTipPropertyValue)
Sets the value of a property edited in tool tip.
|
void |
setToolTipFeedback(java.lang.String toolTipFeedback,
float x,
float y)
Sets tool tip text displayed as feedback.
|
void |
validate()
Validates this component and updates viewport position if it's displayed in a scrolled pane.
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public PlanComponent(Home home, UserPreferences preferences, PlanController controller)
home
.home
- the home to displaypreferences
- user preferences to retrieve used unit, grid visibility...controller
- the optional controller used to manage home items modificationpublic PlanComponent(Home home, UserPreferences preferences, Object3DFactory object3dFactory, PlanController controller)
home
.home
- the home to displaypreferences
- user preferences to retrieve used unit, grid visibility...object3dFactory
- a factory able to create 3D objects from home
furniture.
The createObject3D
of
this factory is expected to return an instance of Object3DBranch
in current implementation.controller
- the optional controller used to manage home items modificationpublic void revalidate()
revalidate
in class javax.swing.JComponent
public void invalidate()
invalidate
in class java.awt.Container
public void validate()
validate
in class java.awt.Container
protected java.awt.Cursor createCustomCursor(java.net.URL smallCursorImageUrl, java.net.URL largeCursorImageUrl, float xCursorHotSpot, float yCursorHotSpot, java.lang.String cursorName, java.awt.Cursor defaultCursor)
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
protected java.util.List<Selectable> getPaintedItems()
protected java.awt.geom.Rectangle2D getItemBounds(java.awt.Graphics g, Selectable item)
item
.public float[][] getTextBounds(java.lang.String text, TextStyle style, float x, float y, float angle)
text
centered at
the point (x
,y
).getTextBounds
in interface PlanView
protected java.awt.Font getFont(java.awt.Font defaultFont, TextStyle textStyle)
protected java.awt.FontMetrics getFontMetrics(java.awt.Font defaultFont, TextStyle textStyle)
public void setBackgroundPainted(boolean backgroundPainted)
public boolean isBackgroundPainted()
true
if plan's background should be painted.public void setSelectedItemsOutlinePainted(boolean selectedItemsOutlinePainted)
public boolean isSelectedItemsOutlinePainted()
true
if the outline of home selected items should be painted.protected void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
public float getPrintPreferredScale(java.awt.Graphics g, java.awt.print.PageFormat pageFormat)
pageFormat
imageable size.public float getPrintPreferredScale(float preferredWidth, float preferredHeight)
getPrintPreferredScale
in interface PlanView
preferredWidth
- width of the zone in cmpreferredHeight
- height of the zone in cmpublic int print(java.awt.Graphics g, java.awt.print.PageFormat pageFormat, int pageIndex)
pageFormat
imageable size if this attribute is null
.print
in interface java.awt.print.Printable
public java.lang.Object createTransferData(TransferableView.DataType dataType)
createTransferData
in interface TransferableView
public java.awt.image.BufferedImage getClipboardImage()
public boolean isFormatTypeSupported(ExportableView.FormatType formatType)
true
if the given format is SVG.isFormatTypeSupported
in interface ExportableView
public void exportData(java.io.OutputStream out, ExportableView.FormatType formatType, java.util.Properties settings) throws java.io.IOException
exportData
in interface ExportableView
java.io.IOException
public void exportToSVG(java.io.OutputStream out) throws java.io.IOException
java.io.IOException
protected java.awt.Color getForegroundColor(PlanComponent.PaintMode mode)
protected java.awt.Color getBackgroundColor(PlanComponent.PaintMode mode)
protected void paintHomeItems(java.awt.Graphics g, float planScale, java.awt.Color backgroundColor, java.awt.Color foregroundColor, PlanComponent.PaintMode paintMode) throws java.io.InterruptedIOException
paintHomeItems(Graphics, Level, float, Color, Color, PaintMode)
if you want to print different levelsPAINT
mode.java.io.InterruptedIOException
protected void paintHomeItems(java.awt.Graphics g, Level level, float planScale, java.awt.Color backgroundColor, java.awt.Color foregroundColor, PlanComponent.PaintMode paintMode) throws java.io.InterruptedIOException
PAINT
mode.java.io.InterruptedIOException
protected java.awt.Color getSelectionColor()
protected java.awt.Color getFurnitureOutlineColor()
protected java.awt.Shape getIndicator(Selectable item, PlanComponent.IndicatorType indicatorType)
protected boolean isViewableAtLevel(Elevatable item, Level level)
true
if the given item can be viewed in the plan at a level.protected boolean isViewableAtSelectedLevel(Elevatable item)
isViewableAtLevel(Elevatable, Level)
if you want to print different levelstrue
if the given item can be viewed in the plan at the selected level.public void setRectangleFeedback(float x0, float y0, float x1, float y1)
setRectangleFeedback
in interface PlanView
public void makeSelectionVisible()
makeSelectionVisible
in interface PlanView
public void makePointVisible(float x, float y)
x
, y
) is visible,
moving scroll bars if needed.makePointVisible
in interface PlanView
public void moveView(float dx, float dy)
public float getScale()
public void setScale(float scale)
public float convertXPixelToModel(int x)
x
converted in model coordinates space.convertXPixelToModel
in interface PlanView
public float convertYPixelToModel(int y)
y
converted in model coordinates space.convertYPixelToModel
in interface PlanView
public int convertXModelToScreen(float x)
x
converted in screen coordinates space.convertXModelToScreen
in interface PlanView
public int convertYModelToScreen(float y)
y
converted in screen coordinates space.convertYModelToScreen
in interface PlanView
public float getPixelLength()
getPixelLength
in interface PlanView
public void setCursor(PlanView.CursorType cursorType)
public void setToolTipFeedback(java.lang.String toolTipFeedback, float x, float y)
setToolTipFeedback
in interface PlanView
toolTipFeedback
- the text displayed in the tool tip
or null
to make tool tip disappear.public void setToolTipEditedProperties(PlanController.EditableProperty[] toolTipEditedProperties, java.lang.Object[] toolTipPropertyValues, float x, float y)
setToolTipEditedProperties
in interface PlanView
public void setToolTipEditedPropertyValue(PlanController.EditableProperty toolTipEditedProperty, java.lang.Object toolTipPropertyValue)
setToolTipEditedPropertyValue
in interface PlanView
public void deleteToolTipFeedback()
deleteToolTipFeedback
in interface PlanView
public void setResizeIndicatorVisible(boolean resizeIndicatorVisible)
setResizeIndicatorVisible
in interface PlanView
public void setAlignmentFeedback(java.lang.Class<? extends Selectable> alignedObjectClass, Selectable alignedObject, float x, float y, boolean showPointFeedback)
setAlignmentFeedback
in interface PlanView
public void setAngleFeedback(float xCenter, float yCenter, float x1, float y1, float x2, float y2)
setAngleFeedback
in interface PlanView
public void setDraggedItemsFeedback(java.util.List<Selectable> draggedItems)
setDraggedItemsFeedback
in interface PlanView
public void setDimensionLinesFeedback(java.util.List<DimensionLine> dimensionLines)
setDimensionLinesFeedback
in interface PlanView
public void deleteFeedback()
deleteFeedback
in interface PlanView
public boolean canImportDraggedItems(java.util.List<Selectable> items, int x, int y)
true
.canImportDraggedItems
in interface PlanView
public float[] getPieceOfFurnitureSizeInPlan(HomePieceOfFurniture piece)
null
if the view isn't able to compute such a value.getPieceOfFurnitureSizeInPlan
in interface PlanView
public boolean isFurnitureSizeInPlanSupported()
true
if this component is able to compute the size of horizontally rotated furniture.isFurnitureSizeInPlanSupported
in interface PlanView
public java.awt.Dimension getPreferredScrollableViewportSize()
getPreferredScrollableViewportSize
in interface javax.swing.Scrollable
public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
getScrollableBlockIncrement
in interface javax.swing.Scrollable
public boolean getScrollableTracksViewportHeight()
getScrollableTracksViewportHeight
in interface javax.swing.Scrollable
public boolean getScrollableTracksViewportWidth()
getScrollableTracksViewportWidth
in interface javax.swing.Scrollable
public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
getScrollableUnitIncrement
in interface javax.swing.Scrollable
public View getHorizontalRuler()
getHorizontalRuler
in interface PlanView
public View getVerticalRuler()
getVerticalRuler
in interface PlanView
© Copyright 2024 Space Mushrooms
Distributed under GNU General Public License