diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/.classpath b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/.classpath new file mode 100644 index 00000000..2f309b0f --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/.classpath @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/.project b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/.project new file mode 100644 index 00000000..c76f779e --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/.project @@ -0,0 +1,17 @@ + + + diylc-core + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/.settings/org.eclipse.jdt.ui.prefs b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..b00bc72a --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,4 @@ +#Sun Nov 08 15:11:18 CET 2009 +eclipse.preferences.version=1 +org.eclipse.jdt.ui.javadoc=false +org.eclipse.jdt.ui.text.custom_code_templates= diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/build.xml b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/build.xml new file mode 100644 index 00000000..659dac8a --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/build.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + Compile with JDK ${java.runtime.version} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/config.properties b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/config.properties new file mode 100644 index 00000000..c6abd215 --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/config.properties @@ -0,0 +1,2 @@ +#org.diylc.utils.Constants.CANVAS_COLOR=#005D96 +#org.diylc.utils.Constants.GRID_COLOR=#FFFFFF \ No newline at end of file diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/lib/app-framework.jar b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/lib/app-framework.jar new file mode 100644 index 00000000..f7ae5f54 Binary files /dev/null and b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/lib/app-framework.jar differ diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/lib/jettison-1.0.1.jar b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/lib/jettison-1.0.1.jar new file mode 100644 index 00000000..fed929fd Binary files /dev/null and b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/lib/jettison-1.0.1.jar differ diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/lib/junit-4.7.jar b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/lib/junit-4.7.jar new file mode 100644 index 00000000..700ad695 Binary files /dev/null and b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/lib/junit-4.7.jar differ diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/lib/log4j-1.2.15.jar b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/lib/log4j-1.2.15.jar new file mode 100644 index 00000000..c930a6ab Binary files /dev/null and b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/lib/log4j-1.2.15.jar differ diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/lib/xstream-1.3.1.jar b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/lib/xstream-1.3.1.jar new file mode 100644 index 00000000..4ef4219c Binary files /dev/null and b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/lib/xstream-1.3.1.jar differ diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/library/main.jar b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/library/main.jar new file mode 100644 index 00000000..ad37f99a Binary files /dev/null and b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/library/main.jar differ diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/BadPositionException.java b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/BadPositionException.java new file mode 100644 index 00000000..52dcfe95 --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/BadPositionException.java @@ -0,0 +1,7 @@ +package org.diylc.common; + +public class BadPositionException extends Exception { + + private static final long serialVersionUID = 1L; + +} diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/ComponentType.java b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/ComponentType.java new file mode 100644 index 00000000..a20fd58c --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/ComponentType.java @@ -0,0 +1,114 @@ +package org.diylc.common; + +import javax.swing.Icon; + +import org.diylc.core.CreationMethod; +import org.diylc.core.IDIYComponent; +import org.diylc.core.annotations.BomPolicy; + +/** + * Entity class used to describe a component type. + * + * @author Branislav Stojkovic + * + * @see IDIYComponent + */ +public class ComponentType { + + private String name; + private String description; + private CreationMethod creationMethod; + private String category; + private String namePrefix; + private String author; + private Icon icon; + private Class> instanceClass; + private double zOrder; + private boolean flexibleZOrder; + private boolean stretchable; + private BomPolicy bomPolicy; + private boolean autoEdit; + private boolean rotatable; + + public ComponentType(String name, String description, CreationMethod creationMethod, + String category, String namePrefix, String author, Icon icon, + Class> instanceClass, double zOrder, boolean flexibleZOrder, + boolean stretchable, BomPolicy bomPolicy, boolean autoEdit, boolean rotatable) { + super(); + this.name = name; + this.description = description; + this.creationMethod = creationMethod; + this.category = category; + this.namePrefix = namePrefix; + this.author = author; + this.icon = icon; + this.instanceClass = instanceClass; + this.zOrder = zOrder; + this.flexibleZOrder = flexibleZOrder; + this.stretchable = stretchable; + this.bomPolicy = bomPolicy; + this.autoEdit = autoEdit; + this.rotatable = rotatable; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public CreationMethod getCreationMethod() { + return creationMethod; + } + + public String getCategory() { + return category; + } + + public String getNamePrefix() { + return namePrefix; + } + + public String getAuthor() { + return author; + } + + public Icon getIcon() { + return icon; + } + + public Class> getInstanceClass() { + return instanceClass; + } + + public double getZOrder() { + return zOrder; + } + + public boolean isFlexibleZOrder() { + return flexibleZOrder; + } + + public boolean isStretchable() { + return stretchable; + } + + public BomPolicy getBomPolicy() { + return bomPolicy; + } + + public boolean isAutoEdit() { + return autoEdit; + } + + public boolean isRotatable() { + return rotatable; + } + + @Override + public String toString() { + return name; + } +} diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/Display.java b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/Display.java new file mode 100644 index 00000000..ed3404ac --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/Display.java @@ -0,0 +1,11 @@ +package org.diylc.common; + +public enum Display { + + NAME, VALUE; + + @Override + public String toString() { + return name().substring(0, 1) + name().substring(1).toLowerCase(); + } +} diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/DrawOption.java b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/DrawOption.java new file mode 100644 index 00000000..b36ac993 --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/DrawOption.java @@ -0,0 +1,40 @@ +package org.diylc.common; + +import java.awt.Graphics; + +/** + * Enumerates all options that can be used when drawing a project. + * + * @see IPlugInPort#draw(java.awt.Graphics2D, java.util.Set, IComponentFiler) + * + * @author Branislav Stojkovic + */ +public enum DrawOption { + + /** + * Selection rectangle will be drawn when needed and selected components may + * be rendered differently. + */ + SELECTION, + /** + * Selected zoom level will be applied to scale the {@link Graphics} before + * drawing. + */ + ZOOM, + /** + * Grid lines are drawn. + */ + GRID, + /** + * Control points are drawn. + */ + CONTROL_POINTS, + /** + * Anti-aliasing is used when drawing. + */ + ANTIALIASING, + /** + * Draw components in outline mode. + */ + OUTLINE_MODE; +} diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/EventType.java b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/EventType.java new file mode 100644 index 00000000..fd1d8838 --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/EventType.java @@ -0,0 +1,83 @@ +package org.diylc.common; + +import java.awt.Rectangle; +import java.awt.geom.Point2D; + +import org.diylc.core.Project; + +/** + * Enumerates all possible events between {@link IPlugInPort} and + * {@link IPlugIn}. Some events overlap so be careful which ones you subscribe + * for and how you process them. + * + * @author Branislav Stojkovic + */ +public enum EventType { + + /** + * Called when zoom level changes. Typically only one parameter of type + * {@link Double} is passed with new zoom level. + */ + ZOOM_CHANGED, + /** + * Called when a new project is loaded. New {@link Project} is the first + * parameter. Boolean flag is the second parameter and it's true when new + * project is loaded, false when the same project has been either reloaded + * or loaded with undo/redo operations. + */ + PROJECT_LOADED, + /** + * Called when either current file name or modified flag are changed. The + * first parameter is the current file name, the second one is a boolean + * modified flag. + */ + FILE_STATUS_CHANGED, + /** + * Called when selection rectangle is changed. Object of type + * {@link Rectangle} is the only parameter and it contains the new selection + * rectangle. + */ + SELECTION_RECT_CHANGED, + /** + * Called when component selection is changed. New + * {@link ComponentSelection} is attached as a parameter. + */ + SELECTION_CHANGED, + /** + * Called when selection size changes, together with a {@link Point2D} + * object containing selection size (x = width, y = height). Size is + * expressed in the default measure (cm for metric, inches for imperial). + */ + REPAINT, + /** + * Called when new component slot has been changed. The only parameter is + * {@link ComponentType} and may be null. + */ + SLOT_CHANGED, + /** + * Called when the current project has been modified. Two instances of + * {@link Project} are passed as parameters, one before and one after the + * change. The third parameter is a string containing change description. + */ + PROJECT_MODIFIED, + /** + * Called when control points under the cursor are changed. A single + * parameter is passed, an instance of + * Map, Set> containing all the + * components and indices of their control points that are under the cursor. + */ + AVAILABLE_CTRL_POINTS_CHANGED, + /** + * Called when mouse cursor is moved. Point object is passed, containing the + * current cursor location (not taking zoom into account). + */ + MOUSE_MOVED, + /** + * Called when a layer status is changed. The first parameter is a set of indices of locked layers. All layers not included are considered unlocked. + */ + LAYER_STATE_CHANGED, + /** + * Called to update the status message. New status message is passed as a first parameter. + */ + STATUS_MESSAGE_CHANGED; +} diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/GridType.java b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/GridType.java new file mode 100644 index 00000000..5d960ce3 --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/GridType.java @@ -0,0 +1,6 @@ +package org.diylc.common; + +public enum GridType { + + LINES, CROSSHAIR, DOT, NONE; +} diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/HorizontalAlignment.java b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/HorizontalAlignment.java new file mode 100644 index 00000000..e8ef10f4 --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/HorizontalAlignment.java @@ -0,0 +1,9 @@ +package org.diylc.common; + +public enum HorizontalAlignment { + LEFT, CENTER, RIGHT; + + public String toString() { + return name().substring(0, 1) + name().substring(1).toLowerCase(); + } +} diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/IComponentFiler.java b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/IComponentFiler.java new file mode 100644 index 00000000..c1647cdb --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/IComponentFiler.java @@ -0,0 +1,8 @@ +package org.diylc.common; + +import org.diylc.core.IDIYComponent; + +public interface IComponentFiler { + + boolean testComponent(IDIYComponent component); +} diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/IKeyProcessor.java b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/IKeyProcessor.java new file mode 100644 index 00000000..86cf6a5d --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/IKeyProcessor.java @@ -0,0 +1,22 @@ +package org.diylc.common; + +public interface IKeyProcessor { + + public static final int VK_LEFT = 0x25; + public static final int VK_UP = 0x26; + public static final int VK_RIGHT = 0x27; + public static final int VK_DOWN = 0x28; + + /** + * Notifies the presenter that a key hes been pressed on the canvas. + * + * @param key + * @param ctrlDown + * @param shiftDown + * @param altDown + * + * @return true if the event should be consumed + */ + boolean keyPressed(int key, boolean ctrlDown, boolean shiftDown, + boolean altDown); +} diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/IMouseProcessor.java b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/IMouseProcessor.java new file mode 100644 index 00000000..95963440 --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/IMouseProcessor.java @@ -0,0 +1,69 @@ +package org.diylc.common; + +import java.awt.Point; + +public interface IMouseProcessor { + + /** + * Notifies the presenter that mouse is clicked. + * + * Note: point coordinates are display based, i.e. scaled for zoom factor. + * + * @param point + * @param button + * @param ctrlDown + * @param shiftDown + * @param altDown + * @param clickCount + */ + void mouseClicked(Point point, int button, boolean ctrlDown, boolean shiftDown, boolean altDown, + int clickCount); + + /** + * Notifies the presenter that mouse is moved. + * + * Note: point coordinates are display based, i.e. scaled for zoom factor. + * + * @param point + * @param ctrlDown + * @param shiftDown + * @param altDown + */ + void mouseMoved(Point point, boolean ctrlDown, boolean shiftDown, boolean altDown); + + /** + * Notification that drag has been started from the specified point. + * + * Note: point coordinates are scaled for zoom factor. + * + * @param point + * @param dragAction + */ + void dragStarted(Point point, int dragAction); + + /** + * Checks if it's possible to drop over the specified point. + * + * Note: point coordinates are scaled for zoom factor. + * + * @param point + * @return + */ + boolean dragOver(Point point); + + /** + * Changes the current drag action during the dragging. + * + * @param dragAction + */ + void dragActionChanged(int dragAction); + + /** + * Notification that drag has been ended in the specified point. + * + * Note: point coordinates are scaled for zoom factor. + * + * @param point + */ + void dragEnded(Point point); +} diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/IPlugIn.java b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/IPlugIn.java new file mode 100644 index 00000000..cbfee46a --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/IPlugIn.java @@ -0,0 +1,19 @@ +package org.diylc.common; + +import org.diylc.appframework.simplemq.IMessageListener; + +/** + * Interface for plug-ins. + * + * @author Branislav Stojkovic + */ +public interface IPlugIn extends IMessageListener { + + /** + * Method that connects the plug-in with {@link IPlugInPort}. Called by the + * application when plug-in is installed. + * + * @param plugInPort + */ + void connect(IPlugInPort plugInPort); +} diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/IPlugInPort.java b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/IPlugInPort.java new file mode 100644 index 00000000..8624cbc7 --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/IPlugInPort.java @@ -0,0 +1,320 @@ +package org.diylc.common; + +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.Point; +import java.awt.geom.Point2D; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.diylc.appframework.simplemq.IMessageListener; +import org.diylc.appframework.simplemq.MessageDispatcher; +import org.diylc.appframework.update.VersionNumber; +import org.diylc.core.IDIYComponent; +import org.diylc.core.Project; +import org.diylc.core.Template; +import org.diylc.core.Theme; + +/** + * Interface for communication between plug-ins and the application. Plug-ins + * may acquire information or make changes through this interface. Application + * events are dispatched to plug-ins through {@link MessageDispatcher} + * + * @author Branislav Stojkovic + * + * @see IPlugIn + * @see MessageDispatcher + * @see IMessageListener + * @see EventType + */ +public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyProcessor, ITemplateProcessor { + + public static final String ANTI_ALIASING_KEY = "antiAliasing"; + public static final String HI_QUALITY_RENDER_KEY = "hiQualityRender"; + public static final String EXPORT_GRID_KEY = "exportGrid"; + public static final String STICKY_POINTS_KEY = "stickyPoints"; + public static final String METRIC_KEY = "metric"; + public static final String SNAP_TO_GRID_KEY = "snapToGrid"; + public static final String AUTO_PADS_KEY = "autoCreatePads"; + public static final String CONTINUOUS_CREATION_KEY = "continuousCreation"; + public static final String AUTO_EDIT_KEY = "autoEdit"; + public static final String ABNORMAL_EXIT_KEY = "abnormalExit"; + public static final String WHEEL_ZOOM_KEY = "wheelZoom"; + public static final String OUTLINE_KEY = "outline"; + public static final String THEME_KEY = "theme"; + public static final String RECENT_COMPONENTS_KEY = "recentComponents"; + + public static final int DND_TOGGLE_STICKY = 0x1; + public static final int DND_TOGGLE_SNAP = 0x40000000; + + /** + * Mouse button constants. + */ + public static final int NOBUTTON = 0; + public static final int BUTTON1 = 1; + public static final int BUTTON2 = 2; + public static final int BUTTON3 = 3; + + /** + * Returns size of the canvas that takes project dimensions into account as + * well as zoom level. Each dimension is calculated as the product of the + * actual size and the number of pixels per unit. If useZoom is + * set to true, the result is scaled by zoom factor. + * + * @param useZoom + * + * @return canvas dimensions + */ + Dimension getCanvasDimensions(boolean useZoom); + + /** + * Returns an instance of {@link Cursor} that should be used at the + * specified location. + * + * Note: point coordinates are scaled for zoom factor. + * + * @param point + * @return cursor + */ + Cursor getCursorAt(Point point); + + /** + * Returns an instance of currently loaded project. + * + * @return + */ + Project getCurrentProject(); + + /** + * Loads specified {@link Project}. + * + * @param project + * @param freshStart + */ + void loadProject(Project project, boolean freshStart); + + /** + * Creates a new project. + */ + void createNewProject(); + + /** + * Loads a project from the specified file. + * + * @param fileName + */ + void loadProjectFromFile(String fileName); + + /** + * Saves the current project into the specified file. + * + * @param fileName + * @param isBackup + */ + void saveProjectToFile(String fileName, boolean isBackup); + + /** + * @return the current file name. + */ + String getCurrentFileName(); + + /** + * @return true if the current project is modified. + */ + boolean isProjectModified(); + + /** + * Shows a user dialog if there are changes to confirm that it's safe to + * proceed. + * + * @return true, if file actions (new, open, close) can be taken + */ + boolean allowFileAction(); + + /** + * Returns all available {@link ComponentType}s classified by category. + * Result is a {@link Map} between category name to a {@link List} of all + * {@link ComponentType}s that share that category name. + * + * @return + */ + Map> getComponentTypes(); + + /** + * Draws project on the provided {@link Graphics2D}. If the provided filter + * is not null, it will be used to filter the components that are shown. + * + * @param g2d + * @param drawOptions + * specific drawing options + * @param filter + */ + void draw(Graphics2D g2d, Set drawOptions, IComponentFiler filter); + + Double[] getAvailableZoomLevels(); + + /** + * Returns current zoom level where zoomLevel = 1.0d means + * 100%. + * + * @return current zoom level + */ + double getZoomLevel(); + + /** + * Changes current zoom level where zoomLevel = 1.0d means 100% + * + * @param zoomLevel + * new zoom leve + */ + void setZoomLevel(double zoomLevel); + + /** + * Returns current version number. + * + * @return + */ + VersionNumber getCurrentVersionNumber(); + + /** + * Adds a list of components to the project. + * + * @param components + */ + void pasteComponents(List> components); + + /** + * Deletes all the selected components from the project. + */ + void deleteSelectedComponents(); + + /** + * Sets default value for the specified property name for currently selected + * component types. + * + * @param propertyName + * display name for property + * @param value + * new default value, must not be null + */ + void setSelectionDefaultPropertyValue(String propertyName, Object value); + + /** + * Sets default value for the specified property name for projects. + * + * @param propertyName + * display name for property + * @param value + * new default value, must not be null + */ + void setProjectDefaultPropertyValue(String propertyName, Object value); + + /** + * @return a list of properties that are mutual for all the selected + * components. Resulting list may be empty if selected components do + * not have mutual properties or can be null if the selection is + * empty. + */ + List getMutualSelectionProperties(); + + void editSelection(); + + /** + * @return a list of editable properties of the current project. + */ + List getProjectProperties(); + + /** + * Applies specified properties to the current project. + * + * @param properties + */ + void applyPropertiesToProject(List properties); + + /** + * Gets the current new component slot. + */ + ComponentType getNewComponentTypeSlot(); + + /** + * Sets the new component slot. Specified component type will be used to + * instantiate new component. + * + * @param componentType + * @param template + */ + void setNewComponentTypeSlot(ComponentType componentType, Template template); + + /** + * Changes default size notation, true for metric, false for imperial. + * + * @param isMetric + */ + void setMetric(boolean isMetric); + + /** + * Groups all selected components. + */ + void groupSelectedComponents(); + + /** + * Ungroups all selected components. + */ + void ungroupSelectedComponents(); + + /** + * Locks or unlocks the specified layer. All components within +- 0.5 range + * will be affected by the change as well. + * + * @param layerZOrder + * @param locked + */ + void setLayerLocked(int layerZOrder, boolean locked); + + /** + * @return selection size expressed in either inches or centimeters, based + * on the user preference. + */ + Point2D calculateSelectionDimension(); + +// /** +// * @return the smallest rectangle that encloses the selection +// */ +// Rectangle2D getSelectedAreaRect(); + + /** + * Sends each of the selected components one step back. + */ + void sendSelectionToBack(); + + /** + * Brings each of the selected components one step to front. + */ + void bringSelectionToFront(); + + /** + * Causes the display to refresh. + */ + void refresh(); + + /** + * @return currently selected theme. + */ + Theme getSelectedTheme(); + + /** + * Changes the current theme. + * + * @param theme + */ + void setSelectedTheme(Theme theme); + + /** + * Renumbers all the selected components. + * + * @param xAxisFirst + */ + void renumberSelectedComponents(boolean xAxisFirst); +} diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/ISelectionProcessor.java b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/ISelectionProcessor.java new file mode 100644 index 00000000..1659e873 --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/ISelectionProcessor.java @@ -0,0 +1,59 @@ +package org.diylc.common; + +import java.awt.Point; +import java.util.List; + +import org.diylc.core.ExpansionMode; +import org.diylc.core.IDIYComponent; + +public interface ISelectionProcessor { + + /** + * Returns the current {@link ComponentTransferable}. + * + * @return + */ + List> getSelectedComponents(); + + /** + * Updates the selection with the specified list of component. Also, updates + * control point map with all components that are stuck to the newly + * selected components. + * + * @param newSelection + */ + void updateSelection(List> newSelection); + + /** + * Finds all components at the specified location, sorted by z-index from + * top to bottom. + * + * @param point + * @return + */ + List> findComponentsAt(Point point); + + /** + * Expands the current selection to include surrounding components. Options + * are controlled with expansionMode flag. + * + * @param expansionMode + */ + void expandSelection(ExpansionMode expansionMode); + + /** + * Selects all components in the project. + * + * @param int layer if > 0, designates which layer to select. If <= 0 we + * should select all regardless of layer + */ + void selectAll(int layer); + + /** + * Rotates selection for 90 degrees. + * + * @param direction + * 1 for clockwise, -1 for counter-clockwise + */ + void rotateSelection(int direction); +} diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/ITask.java b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/ITask.java new file mode 100644 index 00000000..eb7ad07a --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/ITask.java @@ -0,0 +1,34 @@ +package org.diylc.common; + +/** + * Abstract layer between the app and platform worker thread implementation. + * + * @author Branislav Stojkovic + * + * @param + */ +public interface ITask { + + /** + * Runs in background thread. + * + * @return + * @throws Exception + */ + T doInBackground() throws Exception; + + /** + * Called if background thread fails. + * + * @param e + */ + void failed(Exception e); + + /** + * Called if background thread is executed correctly, the result is passed + * as a parameter. + * + * @param result + */ + void complete(T result); +} diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/ITemplateProcessor.java b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/ITemplateProcessor.java new file mode 100644 index 00000000..1cf825a6 --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/diylc-core/src/org/diylc/common/ITemplateProcessor.java @@ -0,0 +1,26 @@ +package org.diylc.common; + +import java.util.List; + +import org.diylc.core.Template; + +public interface ITemplateProcessor { + + public static final String TEMPLATES_KEY = "templates"; + + void saveSelectedComponentAsTemplate(String templateName); + + List