Package cz.vutbr.fit.layout.impl
Class AreaListGridTopology
- java.lang.Object
-
- cz.vutbr.fit.layout.impl.AreaListGridTopology
-
- All Implemented Interfaces:
AreaTopology
- Direct Known Subclasses:
DefaultGridTopology
public class AreaListGridTopology extends Object implements AreaTopology
A grid topology on a generic list of areas.- Author:
- burgetr
-
-
Constructor Summary
Constructors Constructor Description AreaListGridTopology(Collection<ContentRect> areas)AreaListGridTopology(Collection<ContentRect> areas, boolean doInit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected RectangularcomputeAreaBounds()Obtains the absolute bounds of the parent area where the child areas are positioned.voiddrawLayout(OutputDisplay disp)Graphically displays the topology on a graphical output device.Collection<ContentRect>findAllAreasAt(int x, int y)Finds all the areas at the specified position in the grid.Collection<ContentRect>findAllAreasIntersecting(Rectangular r)Finds all the areas that intersect with the specified rectangle in the grid.ContentRectfindAreaAt(int x, int y)Finds an area at the specified position in the grid.Collection<ContentRect>getAreas()Gets the list of areas that are being managed by this topology.RectangulargetPosition(ContentRect area)Obtains the position of the given area within this topology.Map<ContentRect,Rectangular>getPositionMap()Obtains a map assigning a position to each area.intgetTopologyHeight()Obtains the total height of the topology used for placing the child areas within this area.RectangulargetTopologyPosition()Obtains the absolute position of the whole topology within the page.intgetTopologyWidth()Obtains the total width of the topology used for placing the child areas within this area.voidsetAreas(List<ContentRect> areas)voidsetPosition(ContentRect area, Rectangular gp)Sets the position of the given area in this topology.RectangulartoPixelPosition(Rectangular gp)Translates the bounds in the topology to pixel bounds.RectangulartoPixelPositionAbsolute(Rectangular gp)Translates the bounds in the topology to absolute pixel bounds.inttoTopologyX(int pixelX)Translates the X coordinate from pixels to topology positioninttoTopologyY(int pixelY)Translates the Y coordinate from pixels to topology positionvoidupdate()Recomputes the topology.
-
-
-
Constructor Detail
-
AreaListGridTopology
public AreaListGridTopology(Collection<ContentRect> areas)
-
AreaListGridTopology
public AreaListGridTopology(Collection<ContentRect> areas, boolean doInit)
-
-
Method Detail
-
getAreas
public Collection<ContentRect> getAreas()
Description copied from interface:AreaTopologyGets the list of areas that are being managed by this topology.- Specified by:
getAreasin interfaceAreaTopology- Returns:
- the list of areas
-
setAreas
public void setAreas(List<ContentRect> areas)
-
getTopologyWidth
public int getTopologyWidth()
Description copied from interface:AreaTopologyObtains the total width of the topology used for placing the child areas within this area.- Specified by:
getTopologyWidthin interfaceAreaTopology- Returns:
- the topology width; the units depend on the used topology
-
getTopologyHeight
public int getTopologyHeight()
Description copied from interface:AreaTopologyObtains the total height of the topology used for placing the child areas within this area.- Specified by:
getTopologyHeightin interfaceAreaTopology- Returns:
- the topology height; the units depend on the topology
-
getTopologyPosition
public Rectangular getTopologyPosition()
Description copied from interface:AreaTopologyObtains the absolute position of the whole topology within the page.- Specified by:
getTopologyPositionin interfaceAreaTopology- Returns:
- the absolute position of this topology
-
getPosition
public Rectangular getPosition(ContentRect area)
Description copied from interface:AreaTopologyObtains the position of the given area within this topology.- Specified by:
getPositionin interfaceAreaTopology- Parameters:
area- The area whose position we want to obtain.- Returns:
- The area position in this topology or
nullwhen the area position is not described by this topology.
-
setPosition
public void setPosition(ContentRect area, Rectangular gp)
Description copied from interface:AreaTopologySets the position of the given area in this topology.- Specified by:
setPositionin interfaceAreaTopology- Parameters:
area- The area whose position we want to set.gp- The new position.
-
getPositionMap
public Map<ContentRect,Rectangular> getPositionMap()
Description copied from interface:AreaTopologyObtains a map assigning a position to each area. Note that the efficiency of this method greatly depends on the topology implementation.- Specified by:
getPositionMapin interfaceAreaTopology- Returns:
- A map assigning a position to the individual areas. The key set contains all the areas in the topology.
-
findAreaAt
public ContentRect findAreaAt(int x, int y)
Description copied from interface:AreaTopologyFinds an area at the specified position in the grid. If there are multiple areas sharing the same position, the first of them is returned in a non-deterministic way. Therefore, this method should be used for topologies that do not allow overlapping areas.- Specified by:
findAreaAtin interfaceAreaTopology- Parameters:
x- the x coordinate of the grid celly- the y coordinate of the grid cell- Returns:
- the area at the specified position or
nullwhen there is no such area
-
findAllAreasAt
public Collection<ContentRect> findAllAreasAt(int x, int y)
Description copied from interface:AreaTopologyFinds all the areas at the specified position in the grid.- Specified by:
findAllAreasAtin interfaceAreaTopology- Parameters:
x- the x coordinate of the grid celly- the y coordinate of the grid cell- Returns:
- the collection of areas at the specified position or an empty collection when there is no such area
-
findAllAreasIntersecting
public Collection<ContentRect> findAllAreasIntersecting(Rectangular r)
Description copied from interface:AreaTopologyFinds all the areas that intersect with the specified rectangle in the grid.- Specified by:
findAllAreasIntersectingin interfaceAreaTopology- Parameters:
r- the the rectangle to intersect with- Returns:
- the collection of areas at the specified position or an empty collection when there is no such area
-
toPixelPosition
public Rectangular toPixelPosition(Rectangular gp)
Description copied from interface:AreaTopologyTranslates the bounds in the topology to pixel bounds.- Specified by:
toPixelPositionin interfaceAreaTopology- Parameters:
gp- the position within the topology- Returns:
- the pixle position
-
toPixelPositionAbsolute
public Rectangular toPixelPositionAbsolute(Rectangular gp)
Description copied from interface:AreaTopologyTranslates the bounds in the topology to absolute pixel bounds.- Specified by:
toPixelPositionAbsolutein interfaceAreaTopology- Parameters:
gp- the position within the topology- Returns:
- the pixle position
-
toTopologyX
public int toTopologyX(int pixelX)
Description copied from interface:AreaTopologyTranslates the X coordinate from pixels to topology position- Specified by:
toTopologyXin interfaceAreaTopology- Parameters:
pixelX- the pixel X coordinate- Returns:
- the topology X coordinate
-
toTopologyY
public int toTopologyY(int pixelY)
Description copied from interface:AreaTopologyTranslates the Y coordinate from pixels to topology position- Specified by:
toTopologyYin interfaceAreaTopology- Parameters:
pixelY- the pixel Y coordinate- Returns:
- the topology Y coordinate
-
update
public void update()
Description copied from interface:AreaTopologyRecomputes the topology. This should be used when the underlying areas have changed (some areas have been added, removed or resized).- Specified by:
updatein interfaceAreaTopology
-
drawLayout
public void drawLayout(OutputDisplay disp)
Description copied from interface:AreaTopologyGraphically displays the topology on a graphical output device.- Specified by:
drawLayoutin interfaceAreaTopology- Parameters:
disp- the ouptut display to be used
-
computeAreaBounds
protected Rectangular computeAreaBounds()
Obtains the absolute bounds of the parent area where the child areas are positioned.- Returns:
- The absloute area bounds in pixels.
-
-