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 Rectangular
computeAreaBounds()
Obtains the absolute bounds of the parent area where the child areas are positioned.void
drawLayout(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.ContentRect
findAreaAt(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.Rectangular
getPosition(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.int
getTopologyHeight()
Obtains the total height of the topology used for placing the child areas within this area.Rectangular
getTopologyPosition()
Obtains the absolute position of the whole topology within the page.int
getTopologyWidth()
Obtains the total width of the topology used for placing the child areas within this area.void
setAreas(List<ContentRect> areas)
void
setPosition(ContentRect area, Rectangular gp)
Sets the position of the given area in this topology.Rectangular
toPixelPosition(Rectangular gp)
Translates the bounds in the topology to pixel bounds.Rectangular
toPixelPositionAbsolute(Rectangular gp)
Translates the bounds in the topology to absolute pixel bounds.int
toTopologyX(int pixelX)
Translates the X coordinate from pixels to topology positionint
toTopologyY(int pixelY)
Translates the Y coordinate from pixels to topology positionvoid
update()
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:AreaTopology
Gets the list of areas that are being managed by this topology.- Specified by:
getAreas
in interfaceAreaTopology
- Returns:
- the list of areas
-
setAreas
public void setAreas(List<ContentRect> areas)
-
getTopologyWidth
public int getTopologyWidth()
Description copied from interface:AreaTopology
Obtains the total width of the topology used for placing the child areas within this area.- Specified by:
getTopologyWidth
in interfaceAreaTopology
- Returns:
- the topology width; the units depend on the used topology
-
getTopologyHeight
public int getTopologyHeight()
Description copied from interface:AreaTopology
Obtains the total height of the topology used for placing the child areas within this area.- Specified by:
getTopologyHeight
in interfaceAreaTopology
- Returns:
- the topology height; the units depend on the topology
-
getTopologyPosition
public Rectangular getTopologyPosition()
Description copied from interface:AreaTopology
Obtains the absolute position of the whole topology within the page.- Specified by:
getTopologyPosition
in interfaceAreaTopology
- Returns:
- the absolute position of this topology
-
getPosition
public Rectangular getPosition(ContentRect area)
Description copied from interface:AreaTopology
Obtains the position of the given area within this topology.- Specified by:
getPosition
in interfaceAreaTopology
- Parameters:
area
- The area whose position we want to obtain.- Returns:
- The area position in this topology or
null
when the area position is not described by this topology.
-
setPosition
public void setPosition(ContentRect area, Rectangular gp)
Description copied from interface:AreaTopology
Sets the position of the given area in this topology.- Specified by:
setPosition
in 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:AreaTopology
Obtains a map assigning a position to each area. Note that the efficiency of this method greatly depends on the topology implementation.- Specified by:
getPositionMap
in 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:AreaTopology
Finds 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:
findAreaAt
in 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
null
when there is no such area
-
findAllAreasAt
public Collection<ContentRect> findAllAreasAt(int x, int y)
Description copied from interface:AreaTopology
Finds all the areas at the specified position in the grid.- Specified by:
findAllAreasAt
in 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:AreaTopology
Finds all the areas that intersect with the specified rectangle in the grid.- Specified by:
findAllAreasIntersecting
in 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:AreaTopology
Translates the bounds in the topology to pixel bounds.- Specified by:
toPixelPosition
in interfaceAreaTopology
- Parameters:
gp
- the position within the topology- Returns:
- the pixle position
-
toPixelPositionAbsolute
public Rectangular toPixelPositionAbsolute(Rectangular gp)
Description copied from interface:AreaTopology
Translates the bounds in the topology to absolute pixel bounds.- Specified by:
toPixelPositionAbsolute
in interfaceAreaTopology
- Parameters:
gp
- the position within the topology- Returns:
- the pixle position
-
toTopologyX
public int toTopologyX(int pixelX)
Description copied from interface:AreaTopology
Translates the X coordinate from pixels to topology position- Specified by:
toTopologyX
in interfaceAreaTopology
- Parameters:
pixelX
- the pixel X coordinate- Returns:
- the topology X coordinate
-
toTopologyY
public int toTopologyY(int pixelY)
Description copied from interface:AreaTopology
Translates the Y coordinate from pixels to topology position- Specified by:
toTopologyY
in interfaceAreaTopology
- Parameters:
pixelY
- the pixel Y coordinate- Returns:
- the topology Y coordinate
-
update
public void update()
Description copied from interface:AreaTopology
Recomputes the topology. This should be used when the underlying areas have changed (some areas have been added, removed or resized).- Specified by:
update
in interfaceAreaTopology
-
drawLayout
public void drawLayout(OutputDisplay disp)
Description copied from interface:AreaTopology
Graphically displays the topology on a graphical output device.- Specified by:
drawLayout
in 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.
-
-