org.diylc.presenter
Class InstantiationManager

java.lang.Object
  extended by org.diylc.presenter.InstantiationManager

public class InstantiationManager
extends java.lang.Object

Manages component instantiation.

Author:
Branislav Stojkovic

Field Summary
static int MAX_RECENT_COMPONENTS
           
 
Constructor Summary
InstantiationManager()
           
 
Method Summary
 java.lang.String createUniqueName(ComponentType componentType, Project currentProject)
           
 void fillWithDefaultProperties(java.lang.Object object, Template template)
          Finds any properties that have default values and injects default values.
 java.util.List<IDIYComponent<?>> getComponentSlot()
           
 ComponentType getComponentTypeSlot()
           
 java.awt.Point getFirstControlPoint()
           
 java.awt.Point getPotentialControlPoint()
           
 Template getTemplate()
           
 java.util.List<IDIYComponent<?>> instantiateComponent(ComponentType componentType, Template template, java.awt.Point point, Project currentProject)
           
 void instatiatePointByPoint(java.awt.Point scaledPoint, Project currentProject)
           
 void loadComponentShapeFromTemplate(IDIYComponent<?> component, Template template)
          Uses stored control points from the template to shape component.
 void pasteComponents(java.util.List<IDIYComponent<?>> components, java.awt.Point scaledPoint, boolean snapToGrid, Size gridSpacing)
           
 void setComponentTypeSlot(ComponentType componentTypeSlot, Template template, Project currentProject)
           
 void tryToRotateComponentSlot()
           
 boolean updatePointByPoint(java.awt.Point scaledPoint)
          Updates component in the slot with the new second control point.
 boolean updateSingleClick(java.awt.Point scaledPoint, boolean snapToGrid, Size gridSpacing)
          Updates location of component slot based on the new mouse location.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_RECENT_COMPONENTS

public static int MAX_RECENT_COMPONENTS
Constructor Detail

InstantiationManager

public InstantiationManager()
Method Detail

getComponentTypeSlot

public ComponentType getComponentTypeSlot()

getTemplate

public Template getTemplate()

getComponentSlot

public java.util.List<IDIYComponent<?>> getComponentSlot()

getFirstControlPoint

public java.awt.Point getFirstControlPoint()

getPotentialControlPoint

public java.awt.Point getPotentialControlPoint()

setComponentTypeSlot

public void setComponentTypeSlot(ComponentType componentTypeSlot,
                                 Template template,
                                 Project currentProject)
                          throws java.lang.Exception
Throws:
java.lang.Exception

instatiatePointByPoint

public void instatiatePointByPoint(java.awt.Point scaledPoint,
                                   Project currentProject)
                            throws java.lang.Exception
Throws:
java.lang.Exception

updatePointByPoint

public boolean updatePointByPoint(java.awt.Point scaledPoint)
Updates component in the slot with the new second control point.

Parameters:
scaledPoint -
Returns:
true, if any change is made

pasteComponents

public void pasteComponents(java.util.List<IDIYComponent<?>> components,
                            java.awt.Point scaledPoint,
                            boolean snapToGrid,
                            Size gridSpacing)

updateSingleClick

public boolean updateSingleClick(java.awt.Point scaledPoint,
                                 boolean snapToGrid,
                                 Size gridSpacing)
Updates location of component slot based on the new mouse location.

Parameters:
scaledPoint -
snapToGrid -
gridSpacing -
Returns:
true if we need to refresh the canvas

instantiateComponent

public java.util.List<IDIYComponent<?>> instantiateComponent(ComponentType componentType,
                                                             Template template,
                                                             java.awt.Point point,
                                                             Project currentProject)
                                                      throws java.lang.Exception
Throws:
java.lang.Exception

createUniqueName

public java.lang.String createUniqueName(ComponentType componentType,
                                         Project currentProject)

fillWithDefaultProperties

public void fillWithDefaultProperties(java.lang.Object object,
                                      Template template)
                               throws java.lang.IllegalArgumentException,
                                      java.lang.IllegalAccessException,
                                      java.lang.reflect.InvocationTargetException,
                                      java.lang.SecurityException,
                                      java.lang.NoSuchMethodException
Finds any properties that have default values and injects default values. Typically it should be used for IDIYComponent and Project objects.

Parameters:
object -
template -
Throws:
java.lang.IllegalArgumentException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
java.lang.SecurityException

loadComponentShapeFromTemplate

public void loadComponentShapeFromTemplate(IDIYComponent<?> component,
                                           Template template)
Uses stored control points from the template to shape component.

Parameters:
component -
template -

tryToRotateComponentSlot

public void tryToRotateComponentSlot()