1 /* 2 * PlanView.java 28 oct 2008 3 * 4 * Sweet Home 3D, Copyright (c) 2008 Emmanuel PUYBARET / eTeks <info@eteks.com> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 */ 20 package com.eteks.sweethome3d.viewcontroller; 21 22 import java.util.List; 23 24 import com.eteks.sweethome3d.model.DimensionLine; 25 import com.eteks.sweethome3d.model.HomePieceOfFurniture; 26 import com.eteks.sweethome3d.model.Selectable; 27 import com.eteks.sweethome3d.model.TextStyle; 28 29 /** 30 * The view that displays the plan of a home. 31 * @author Emmanuel Puybaret 32 */ 33 public interface PlanView extends TransferableView, ExportableView { 34 /** 35 * The cursor types available in plan view. 36 */ 37 public enum CursorType {SELECTION, PANNING, DRAW, ROTATION, ELEVATION, HEIGHT, POWER, RESIZE, DUPLICATION, MOVE} 38 39 /** 40 * Sets rectangle selection feedback coordinates. 41 */ setRectangleFeedback(float x0, float y0, float x1, float y1)42 public abstract void setRectangleFeedback(float x0, float y0, 43 float x1, float y1); 44 45 /** 46 * Ensures selected items are visible at screen and moves 47 * scroll bars if needed. 48 */ makeSelectionVisible()49 public abstract void makeSelectionVisible(); 50 51 /** 52 * Ensures the point at (<code>x</code>, <code>y</code>) is visible, 53 * moving scroll bars if needed. 54 */ makePointVisible(float x, float y)55 public abstract void makePointVisible(float x, float y); 56 57 /** 58 * Returns the scale used to display the plan. 59 */ getScale()60 public abstract float getScale(); 61 62 /** 63 * Sets the scale used to display the plan. 64 */ setScale(float scale)65 public abstract void setScale(float scale); 66 67 /** 68 * Returns the preferred scale to ensure it can be fully printed on the given print zone. 69 * @param preferredWidth width of the zone in cm 70 * @param preferredHeight height of the zone in cm 71 * @since 6.0 72 */ getPrintPreferredScale(float preferredWidth, float preferredHeight)73 public float getPrintPreferredScale(float preferredWidth, float preferredHeight); 74 75 /** 76 * Moves the view from (dx, dy) unit in the scrolling zone it belongs to. 77 */ moveView(float dx, float dy)78 public abstract void moveView(float dx, float dy); 79 80 /** 81 * Returns <code>x</code> converted in model coordinates space. 82 */ convertXPixelToModel(int x)83 public abstract float convertXPixelToModel(int x); 84 85 /** 86 * Returns <code>y</code> converted in model coordinates space. 87 */ convertYPixelToModel(int y)88 public abstract float convertYPixelToModel(int y); 89 90 /** 91 * Returns <code>x</code> converted in screen coordinates space. 92 */ convertXModelToScreen(float x)93 public abstract int convertXModelToScreen(float x); 94 95 /** 96 * Returns <code>y</code> converted in screen coordinates space. 97 */ convertYModelToScreen(float y)98 public abstract int convertYModelToScreen(float y); 99 100 /** 101 * Returns the length in centimeters of a pixel with the current scale. 102 */ getPixelLength()103 public abstract float getPixelLength(); 104 105 /** 106 * Returns the coordinates of the bounding rectangle of the <code>text</code> displayed at 107 * the point (<code>x</code>,<code>y</code>). 108 */ getTextBounds(String text, TextStyle style, float x, float y, float angle)109 public abstract float [][] getTextBounds(String text, TextStyle style, 110 float x, float y, float angle); 111 112 /** 113 * Sets the cursor of this component as rotation cursor. 114 */ setCursor(CursorType cursorType)115 public abstract void setCursor(CursorType cursorType); 116 117 /** 118 * Sets tool tip text displayed as feedback. 119 * @param toolTipFeedback the text displayed in the tool tip 120 * or <code>null</code> to make tool tip disappear. 121 */ setToolTipFeedback(String toolTipFeedback, float x, float y)122 public abstract void setToolTipFeedback(String toolTipFeedback, 123 float x, float y); 124 125 /** 126 * Set properties edited in tool tip. 127 */ setToolTipEditedProperties(PlanController.EditableProperty [] toolTipEditedProperties, Object [] toolTipPropertyValues, float x, float y)128 public abstract void setToolTipEditedProperties(PlanController.EditableProperty [] toolTipEditedProperties, 129 Object [] toolTipPropertyValues, 130 float x, float y); 131 132 /** 133 * Deletes tool tip text from screen. 134 */ deleteToolTipFeedback()135 public abstract void deleteToolTipFeedback(); 136 137 /** 138 * Sets whether the resize indicator of selected wall or piece of furniture 139 * should be visible or not. 140 */ setResizeIndicatorVisible(boolean resizeIndicatorVisible)141 public abstract void setResizeIndicatorVisible(boolean resizeIndicatorVisible); 142 143 /** 144 * Sets the location point for alignment feedback. 145 */ setAlignmentFeedback(Class<? extends Selectable> alignedObjectClass, Selectable alignedObject, float x, float y, boolean showPoint)146 public abstract void setAlignmentFeedback(Class<? extends Selectable> alignedObjectClass, 147 Selectable alignedObject, 148 float x, 149 float y, 150 boolean showPoint); 151 152 153 /** 154 * Sets the points used to draw an angle in plan view. 155 */ setAngleFeedback(float xCenter, float yCenter, float x1, float y1, float x2, float y2)156 public abstract void setAngleFeedback(float xCenter, float yCenter, 157 float x1, float y1, 158 float x2, float y2); 159 160 /** 161 * Sets the feedback of dragged items drawn during a drag and drop operation, 162 * initiated from outside of plan view. 163 */ setDraggedItemsFeedback(List<Selectable> draggedItems)164 public abstract void setDraggedItemsFeedback(List<Selectable> draggedItems); 165 166 /** 167 * Sets the given dimension lines to be drawn as feedback. 168 */ setDimensionLinesFeedback(List<DimensionLine> dimensionLines)169 public abstract void setDimensionLinesFeedback(List<DimensionLine> dimensionLines); 170 171 /** 172 * Deletes all elements shown as feedback. 173 */ deleteFeedback()174 public abstract void deleteFeedback(); 175 176 177 /** 178 * Returns the component used as an horizontal ruler for this plan. 179 */ getHorizontalRuler()180 public abstract View getHorizontalRuler(); 181 182 /** 183 * Returns the component used as a vertical ruler for this plan. 184 */ getVerticalRuler()185 public abstract View getVerticalRuler(); 186 187 /** 188 * Returns <code>true</code> if this plan accepts to import dragged items at the given coordinates. 189 */ canImportDraggedItems(List<Selectable> items, int x, int y)190 public abstract boolean canImportDraggedItems(List<Selectable> items, int x, int y); 191 192 /** 193 * Returns the size of the given piece of furniture in the horizontal plan. 194 */ getPieceOfFurnitureSizeInPlan(HomePieceOfFurniture piece)195 public abstract float [] getPieceOfFurnitureSizeInPlan(HomePieceOfFurniture piece); 196 197 /** 198 * Returns <code>true</code> if the view is able to compute the size of horizontally rotated furniture. 199 */ isFurnitureSizeInPlanSupported()200 public abstract boolean isFurnitureSizeInPlanSupported(); 201 }