Package org.openpnp.model
Class Panel
- java.lang.Object
-
- org.openpnp.model.AbstractModelObject
-
- org.openpnp.model.PlacementsHolder<Panel>
-
- org.openpnp.model.Panel
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.util.EventListener
,Definable<Panel>
public class Panel extends PlacementsHolder<Panel> implements java.beans.PropertyChangeListener
A Panel is a PlacementsHolder whose main purpose is to hold multiple Board and/or Panel Locations
-
-
Field Summary
Fields Modifier and Type Field Description protected IdentifiableList<PlacementsHolderLocation<?>>
children
The list of children contained by this Paneljava.lang.Integer
columns
Deprecated.Panels are no longer define by rows and columns but rather by the location of their childrenprotected IdentifiableList<Placement>
fiducials
Deprecated.Fiducials are now held in the placements List inherited fromPlacementsHolder
java.lang.String
id
Deprecated.The Id is now carried by thePanelLocation
static java.lang.Double
LATEST_VERSION
protected java.util.ArrayList<java.lang.String>
pseudoPlacementIds
A list of Ids that point to placements (fiducials) on the Panel's children that are to be used for panel alignmentprotected IdentifiableList<Placement>
pseudoPlacements
A list of Placements corresponding to those identified inpseudoPlacementIds
.java.lang.Integer
rows
Deprecated.Panels are no longer define by rows and columns but rather by the location of their childrenLength
xGap
Deprecated.Panels are no longer define by rows and columns but rather by the location of their childrenLength
yGap
Deprecated.Panels are no longer define by rows and columns but rather by the location of their children-
Fields inherited from class org.openpnp.model.PlacementsHolder
definition, dimensions, dirty, file, name, placements, profile
-
Fields inherited from class org.openpnp.model.AbstractModelObject
propertyChangeSupport
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChild(PlacementsHolderLocation<?> child)
Adds a child to this panelvoid
addPseudoPlacement(Placement pseudoPlacement)
Adds a pseudo-placement to the panel.protected void
commit()
Runs just after de-serializationPlacement
createPseudoPlacement(java.lang.String pseudoPlacementId)
Creates a pseudo-placement given the pseudo-placement's id.void
dispose()
Removes all the property change listeners associated with this panel.PlacementsHolderLocation<?>
getChild(int index)
Gets the specified child of this paneljava.util.List<PlacementsHolderLocation<?>>
getChildren()
java.util.List<BoardLocation>
getDescendantBoardLocations()
Returns a flattened list of all BoardLocations that are descendants of this paneljava.util.List<PanelLocation>
getDescendantPanelLocations()
Returns a flattened list of all PanelLocations that are descendants of this panelPair<java.util.List<PlacementsHolderLocation<?>>,Placement>
getDescendantPlacement(java.lang.String placementUniqueId)
Gets a placement's parent PlacementsHolderLocation and the placement itself given the placement's unique Id.java.lang.String
getDescendantPlacementUniqueId(PlacementsHolderLocation<?> placementsParentLocation, Placement placement)
Gets a unique Id for a placement based on its location in the panel's family hierarchyjava.util.List<PlacementsHolderLocation<?>>
getDescendants()
Returns a flattened list of all descendants of this panelint
getInstanceCount(PlacementsHolder<?> placementsHolder)
Counts the number of instances of a specified PlacementsHolder that occur within the panel's family hierarchyPlacement
getPseudoPlacement(int index)
Gets the specified pseudo-placement.java.util.List<java.lang.String>
getPseudoPlacementIds()
Gets the list of pseudo-placement ids for this panel.java.util.List<Placement>
getPseudoPlacements()
Gets the list of pseudo-placements for this panel.java.lang.Double
getVersion()
boolean
isCheckFiducials()
boolean
isDefinitionUsed(PlacementsHolder<?> placementsHolder)
Checks to see if the definition of a placementsHolder is the definition of this panel or or any of its descendantsboolean
isMember(PlacementsHolder<?> placementsHolder)
Checks whether the specified PlacementsHolder is a member of this Panel's family hierarchyvoid
removeAllChildren()
Removes all children from this panelvoid
removeChild(PlacementsHolderLocation<?> child)
Removes a child from this panel.void
removePseudoPlacement(Placement pseudoPlacement)
Removes a pseudo-placement from the panel.void
replaceChild(PlacementsHolderLocation<?> originalChild, PlacementsHolderLocation<?> newChild)
Replaces a child of this panel with another.void
setChild(int index, PlacementsHolderLocation<?> child)
Sets the child at the specified index.void
setChildren(IdentifiableList<PlacementsHolderLocation<?>> children)
Sets the children of this panelvoid
setPseudoPlacement(int index, Placement pseudoPlacement)
Sets the pseudo-placement at the specified index.void
setPseudoPlacementIds(java.util.ArrayList<java.lang.String> pseudoPlacementIds)
Sets the list of pseudo-placement ids for this panel.void
setPseudoPlacements(IdentifiableList<Placement> pseudoPlacements)
Sets the list of pseudo-placements for this panel.java.lang.String
toString()
-
Methods inherited from class org.openpnp.model.PlacementsHolder
addPlacement, getDefinition, getDimensions, getFile, getName, getPlacement, getPlacements, getProfile, isDefinition, isDirty, removeAllPlacements, removePlacement, removePlacement, setDefinition, setDimensions, setDirty, setFile, setName, setPlacement, setPlacements, setProfile
-
Methods inherited from class org.openpnp.model.AbstractModelObject
addPropertyChangeListener, addPropertyChangeListener, dumpListeners, fireIndexedPropertyChange, firePropertyChange, isListener, isListener, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.openpnp.spi.Definable
propertyChange
-
-
-
-
Field Detail
-
LATEST_VERSION
public static final java.lang.Double LATEST_VERSION
-
id
@Deprecated public java.lang.String id
Deprecated.The Id is now carried by thePanelLocation
-
columns
@Deprecated public java.lang.Integer columns
Deprecated.Panels are no longer define by rows and columns but rather by the location of their children
-
rows
@Deprecated public java.lang.Integer rows
Deprecated.Panels are no longer define by rows and columns but rather by the location of their children
-
xGap
@Deprecated public Length xGap
Deprecated.Panels are no longer define by rows and columns but rather by the location of their children
-
yGap
@Deprecated public Length yGap
Deprecated.Panels are no longer define by rows and columns but rather by the location of their children
-
fiducials
@Deprecated protected IdentifiableList<Placement> fiducials
Deprecated.Fiducials are now held in the placements List inherited fromPlacementsHolder
-
children
protected IdentifiableList<PlacementsHolderLocation<?>> children
The list of children contained by this Panel
-
pseudoPlacementIds
protected java.util.ArrayList<java.lang.String> pseudoPlacementIds
A list of Ids that point to placements (fiducials) on the Panel's children that are to be used for panel alignment
-
pseudoPlacements
protected transient IdentifiableList<Placement> pseudoPlacements
A list of Placements corresponding to those identified inpseudoPlacementIds
. These placements are copies of those on the Panel's children and are only used for panel alignment, i.e, they will never actually be placed.
-
-
Constructor Detail
-
Panel
public Panel()
Default constructor
-
Panel
public Panel(java.io.File file)
Constructs a new Panel- Parameters:
file
- - the file where this Panel will be stored
-
Panel
public Panel(Panel panel)
Constructs a deep copy of the specified panel- Parameters:
panel
- - the Panel to copy
-
-
Method Detail
-
commit
protected void commit()
Runs just after de-serialization- Overrides:
commit
in classPlacementsHolder<Panel>
-
dispose
public void dispose()
Removes all the property change listeners associated with this panel. Should be called if this panel instance is no longer needed.- Overrides:
dispose
in classPlacementsHolder<Panel>
-
getChildren
public java.util.List<PlacementsHolderLocation<?>> getChildren()
- Returns:
- a list of all the panel's children
-
setChildren
public void setChildren(IdentifiableList<PlacementsHolderLocation<?>> children)
Sets the children of this panel- Parameters:
children
- - a list of PlacementsHolderLocations that are the children of this panel
-
getChild
public PlacementsHolderLocation<?> getChild(int index)
Gets the specified child of this panel- Parameters:
index
- - the index of the child- Returns:
- the child
-
setChild
public void setChild(int index, PlacementsHolderLocation<?> child)
Sets the child at the specified index. This method should only be called from a panel definition's property change listener when an indexed property change event has been fired that adds, modifies, or deletes a child- Parameters:
index
- - the index of the child to setchild
- - the child to add or modify, set to null to delete the child- Throws:
java.lang.UnsupportedOperationException
- if called on a panel definition or if the specified child is neither a BoardLocation nor a PanelLocation
-
addChild
public void addChild(PlacementsHolderLocation<?> child)
Adds a child to this panel- Parameters:
child
- - the child to add- Throws:
java.lang.UnsupportedOperationException
- if the specified child is neither a BoardLocation nor a PanelLocation
-
removeChild
public void removeChild(PlacementsHolderLocation<?> child)
Removes a child from this panel. This method should only be called on panel definitions.- Parameters:
child
- - the child to remove- Throws:
java.lang.UnsupportedOperationException
- if called on a non-panel definition
-
replaceChild
public void replaceChild(PlacementsHolderLocation<?> originalChild, PlacementsHolderLocation<?> newChild)
Replaces a child of this panel with another. This method should only be called on panel definitions.- Parameters:
originalChild
- - the child to removenewChild
- - the child that will replace the original- Throws:
java.lang.UnsupportedOperationException
- if called on a non-panel definition
-
removeAllChildren
public void removeAllChildren()
Removes all children from this panel
-
getPseudoPlacementIds
public java.util.List<java.lang.String> getPseudoPlacementIds()
Gets the list of pseudo-placement ids for this panel. A pseudo-placement is a copy of a placement or fiducial located on one of the panel's descendants that is only used for panel alignment.- Returns:
- - the list of pseudo-placement ids
-
setPseudoPlacementIds
public void setPseudoPlacementIds(java.util.ArrayList<java.lang.String> pseudoPlacementIds)
Sets the list of pseudo-placement ids for this panel. A pseudo-placement is a copy of a placement or fiducial located on one of the panel's descendants that is only used for panel alignment.- Parameters:
pseudoPlacementIds
- - the list of pseudo-placement ids
-
getPseudoPlacements
public java.util.List<Placement> getPseudoPlacements()
Gets the list of pseudo-placements for this panel. A pseudo-placement is a copy of a placement or fiducial located on one of the panel's descendants that is only used for panel alignment.- Returns:
- - the list of pseudo-placements
-
setPseudoPlacements
public void setPseudoPlacements(IdentifiableList<Placement> pseudoPlacements)
Sets the list of pseudo-placements for this panel. A pseudo-placement is a copy of a placement or fiducial located on one of the panel's descendants that is only used for panel alignment.- Parameters:
pseudoPlacements
- - the list of pseudo-placements
-
getPseudoPlacement
public Placement getPseudoPlacement(int index)
Gets the specified pseudo-placement. A pseudo-placement is a copy of a placement or fiducial located on one of the panel's descendants that is only used for panel alignment.- Parameters:
index
- - specifies the pseudo-placement to get- Returns:
- the pseudo-placement
-
setPseudoPlacement
public void setPseudoPlacement(int index, Placement pseudoPlacement)
Sets the pseudo-placement at the specified index. A pseudo-placement is a copy of a placement or fiducial located on one of the panel's descendants that is only used for panel alignment. This method should only be called from a panel definition's property change listener when an indexed property change event has been fired that adds, modifies, or deletes a pseudo-placement.- Parameters:
index
- - the index of the pseudo-placement to setpseudoPlacement
- - the pseudo-placement to add or modify, set to null to delete the pseudo-placement- Throws:
java.lang.UnsupportedOperationException
- if called on a panel definition
-
addPseudoPlacement
public void addPseudoPlacement(Placement pseudoPlacement)
Adds a pseudo-placement to the panel. A pseudo-placement is a copy of a placement or fiducial located on one of the panel's descendants that is only used for panel alignment. This method should only be called on panel definitions.- Parameters:
pseudoPlacement
- - the pseudo-placement to add- Throws:
java.lang.UnsupportedOperationException
- if called on a non-panel definition
-
removePseudoPlacement
public void removePseudoPlacement(Placement pseudoPlacement)
Removes a pseudo-placement from the panel. A pseudo-placement is a copy of a placement or fiducial located on one of the panel's descendants that is only used for panel alignment. This method should only be called on panel definitions.- Parameters:
pseudoPlacement
- - the pseudo-placement to remove- Throws:
java.lang.UnsupportedOperationException
- if called on a non-panel definition
-
createPseudoPlacement
public Placement createPseudoPlacement(java.lang.String pseudoPlacementId) throws java.lang.Exception
Creates a pseudo-placement given the pseudo-placement's id. A pseudo-placement is a copy of a placement or fiducial located on one of the panel's descendants that is only used for panel alignment. This method should only be called on panel definitions.- Parameters:
pseudoPlacementId
- - the id of the pseudo-placement to create- Returns:
- - the pseudo-placement
- Throws:
java.lang.Exception
- if pseudoPlacementId is invalidjava.lang.UnsupportedOperationException
- if called on a non-panel definition
-
getDescendantPlacementUniqueId
public java.lang.String getDescendantPlacementUniqueId(PlacementsHolderLocation<?> placementsParentLocation, Placement placement)
Gets a unique Id for a placement based on its location in the panel's family hierarchy- Parameters:
placementsParentLocation
- - the placement's parent PlacementsHolderLocationplacement
- - the placement- Returns:
- - the unique Id
-
getDescendantPlacement
public Pair<java.util.List<PlacementsHolderLocation<?>>,Placement> getDescendantPlacement(java.lang.String placementUniqueId)
Gets a placement's parent PlacementsHolderLocation and the placement itself given the placement's unique Id. Essentially the inverse of getDescendantPlacementUniqueId- Parameters:
placementUniqueId
- - the placement's unique Id- Returns:
- - the placement's parent along with the actual placement
-
isDefinitionUsed
public boolean isDefinitionUsed(PlacementsHolder<?> placementsHolder)
Checks to see if the definition of a placementsHolder is the definition of this panel or or any of its descendants- Parameters:
placementsHolder
- - the placementsHolder to check- Returns:
- - true if the definition of placementsHolder is the definition of this panel or or any of its descendants
-
getDescendants
public java.util.List<PlacementsHolderLocation<?>> getDescendants()
Returns a flattened list of all descendants of this panel- Returns:
- - the list of all descendants
-
getDescendantBoardLocations
public java.util.List<BoardLocation> getDescendantBoardLocations()
Returns a flattened list of all BoardLocations that are descendants of this panel- Returns:
- - the list of all BoardLocations
-
getDescendantPanelLocations
public java.util.List<PanelLocation> getDescendantPanelLocations()
Returns a flattened list of all PanelLocations that are descendants of this panel- Returns:
- - the list of all PanelLocations
-
isCheckFiducials
public boolean isCheckFiducials()
- Returns:
- true if fiducials should be used to align this panel during a job
-
getVersion
public java.lang.Double getVersion()
- Returns:
- the version number of this panel
-
getInstanceCount
public int getInstanceCount(PlacementsHolder<?> placementsHolder)
Counts the number of instances of a specified PlacementsHolder that occur within the panel's family hierarchy- Parameters:
placementsHolder
- - the PlacementsHolder to count- Returns:
- the count
-
isMember
public boolean isMember(PlacementsHolder<?> placementsHolder)
Checks whether the specified PlacementsHolder is a member of this Panel's family hierarchy- Parameters:
placementsHolder
- - the PlacementsHolder to check- Returns:
- true if it is a member
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-