Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## sema
Interface Area

All Known Implementing Classes:
  CircularArea, PonctualArea, RectangularArea

public interface Area

Some area of a `Map`. Often used to give a shape to an `Element`.
All the methods verify that the `Area` does not go out of the `Map`. In the instanciation, the `Area` is however authorized to be created out of the world. It allows, for example, to create an `Element` which is not physically present on the `Map`.

See Also:
  `Box.register(Element)`, `Box.unregister(Element)`

Method Summary
`java.lang.Object` | `clone()` Clone the area.
`void` | `confirmSimuled()` Confirms the last move simulated with a simule method of the area.
`void` | `draw(Drawing g)` Draws the `Area` and eventually the image of the associated element.
`void` | `drawBorder(Drawing g, java.awt.Color c)` Draws the borders of the area with the given color.
`boolean` | `exactIsCrashingElements()` Takes in argument a vector v returned by a simule method.
`boolean` | `exactIsCrashingElements(java.util.Vector v)`
`void` | `fill(Drawing g, java.awt.Color c)` Fills the area with the given color.
`float` | `getAngle()` Returns the orientation ( in Radian )
`java.util.Vector` | `getIntersectedBoxes()` Returns at least the boxes intersected by the area.
`java.util.Vector` | `getPolygon()` Returns a polygon aproximating the area.
`java.lang.String[][]` | `getProperties()` Returns the Area's properties.
`float` | `getX()` Returns the x-coordinate of the area's reference point.
`float` | `getY()` Returns the y-coordinate of the area's reference point.
`void` | `highlight(Drawing g, java.awt.Color c)` Highlights the `Area`. is used when it's selected in the interface.
`boolean` | `inMap()` Checks whether the area is included in te map.
`boolean` | `intersect(Area a)` Returns whether the area intersect these one.
`boolean` | `intersect(float ax, float ay, float bx, float by)` Returns whether the area intersect the segment (ax,ay),(bx,by)
`boolean` | `intersect(java.util.Vector polygon)` Returns whether the polygon intersects this area.
`boolean` | `isCrashingElements()` Returns true if there are other elements registered on the boxes where this area is registered, or if the area is not included in the map.
`boolean` | `isCrashingElements(java.util.Vector v)`
`boolean` | `isIn(float x, float y)` Returns whether the point is in the area.
`boolean` | `isPolygon()` Returns whether the area is a polygon.
`boolean` | `rescale(float x, float y)` Rescale by a 'x' and a 'y' factor without going out of the `Map`.
`boolean` | `rotate(float angle)` Rotates the area by the angle around the reference point `getX()` without going out of the `Map`.
`boolean` | `setAngle(float angle)` Sets the orientation ( in radian ) Returns true if the modification is done, else false.
`void` | `setElement(Element el)` Sets the element to which we want to link the area.
`void` | `setProperties(java.lang.String property, java.lang.String value)` Sets the value of a property of the area.
`boolean` | `setX(float x)` Modify the x-coordinate of the reference point, without going out of the `` .
`boolean` | `setY(float y)` Modify the y-coordinate of the reference point, without going out of the `` .
`java.util.Vector` | `simuleRescale(float x, float y)` Returns the covering boxes which would result of the rescale.
`java.util.Vector` | `simuleRotate(float angle)` Returns the covering boxes which would result of the rotation.
`java.util.Vector` | `simuleTranslate(float x, float y)` Returns the covering boxes which would result of the (x,y) translation of the area.
`boolean` | `translate(float x, float y)` Translates the area by the (x,y) vector without going out of the map.

Method Detail

### setElement

    public void setElement(Element el)

  Sets the element to which we want to link the area. Indeed, when the area is used to represent the shape of an element, it must know him in order to manage the covered boxes.

  Parameters:
    `el` - the corresponding element ( if one is used ).

### getX

    public float getX()

  Returns the x-coordinate of the area's reference point. This point is the one used to rotate around, and is used to represent the coordinate of an element if one is tied to this shape.

  Returns:
    the x-coordinate of the area's reference point.

### getY

    public float getY()

  Returns the y-coordinate of the area's reference point. This point is the one used to rotate around, and is used to represent the coordinate of an element if one is tied to this shape.

  Returns:
    the y-coordinate of the area's reference point.

### setX

    public boolean setX(float x)

  Modify the x-coordinate of the reference point, without going out of the `` . Returns true if the modification is done, false otherwise.Renvoie true si la modification a eu lieu, false sinon.

  Parameters:
    `x` - the x-coordinate of the reference point.
  Returns:
    whether the modification is done.
  See Also:
    `getX()`

### setY

    public boolean setY(float y)

  Modify the y-coordinate of the reference point, without going out of the `` . Returns true if the modification is done, false otherwise.Renvoie true si la modification a eu lieu, false sinon.

  Parameters:
    `y` - the y-coordinate of the reference point.
  Returns:
    whether the modification is done.
  See Also:
    `getY()`

### getAngle

    public float getAngle()

  Returns the orientation ( in Radian )

  Returns:
    the orientation ( in Radian )

### setAngle

    public boolean setAngle(float angle)

  Sets the orientation ( in radian ) Returns true if the modification is done, else false.

  Parameters:
    `angle` - Sets the orientation ( in radian )
  Returns:
    Returns true if the modification is done, else false.

### getIntersectedBoxes

    public java.util.Vector getIntersectedBoxes()

  Returns at least the boxes intersected by the area. A simplified vision can be used to computes the intersected boxes but il must respect this condition.

  Returns:
    the boxes intersected by the area.
  See Also:
    `setElement(Element)`, `Box.register(Element)`, `Box.unregister(Element)`

### isIn

    public boolean isIn(float x,
                        float y)

  Returns whether the point is in the area.

  Parameters:
    `x` - the x-coordinate of the point.
    `y` - the y-coordinate of the point.
  Returns:
    whether the point is in the area.

### inMap

    public boolean inMap()

  Checks whether the area is included in te map.

### isCrashingElements

    public boolean isCrashingElements()

  Returns true if there are other elements registered on the boxes where this area is registered, or if the area is not included in the map. Useful to quickly detect possible collisions between elements with a box centered vision. This is a default method that can be called by an element to verify that his new position satisfies physical laws in 2D. If it returns true, it means that the element has a valid position: he is in the map and does not share boxes with other elements. But there could be false positives. The `exactIsCrashingElements()` computes an exact result.

  Returns:
    whether there are elements registered on the area's boxes.

### isCrashingElements

    public boolean isCrashingElements(java.util.Vector v)

### exactIsCrashingElements

    public boolean exactIsCrashingElements()

  Takes in argument a vector v returned by a simule method. Returns true if there is any collision with the elements, or if the area is not included in the map (going out of the map is, by default, considered as a crash with the map, and that means that v is null). It computes a real intersection between the area of the elements registered in the covering boxes. This is an exact method that can be called by an element to verify that his new position satisfies physical laws in 2D. If it returns true, it means that the element has a valid position: he is in the map and does not intersect other elements. There is no false positives. The `isCrashingElements()` is a fast approximation of this method.

  Returns:
    whether there are elements collision.

### exactIsCrashingElements

    public boolean exactIsCrashingElements(java.util.Vector v)

### getPolygon

    public java.util.Vector getPolygon()

  Returns a polygon aproximating the area. It's represented as a vector of edges in the trigonometric order.

  Returns:
    a polygone aproximating the area.

### isPolygon

    public boolean isPolygon()

  Returns whether the area is a polygon.

  Returns:
    whether the area is a polygon.

### intersect

    public boolean intersect(float ax,
                             float ay,
                             float bx,
                             float by)

  Returns whether the area intersect the segment (ax,ay),(bx,by)

  Parameters:
    `ax` - x-coordinate of the 'a' point.
    `ay` - y-coordinate of the 'a' point.
    `bx` - x-coordinate of the 'b' point.
    `by` - y-coordinate of the 'b' point.
  Returns:
    whether the area intersect the segment (ax,ay),(bx,by)

### intersect

    public boolean intersect(Area a)

  Returns whether the area intersect these one. Indeed it verify whether their is an intersection between the polygone of one with the other or the opposite. It respects : a.intersect(b) == b.intersect(a).

  Parameters:
    `a` - the area to test.
  Returns:
    whether the area intersect these one.

### intersect

    public boolean intersect(java.util.Vector polygon)

  Returns whether the polygon intersects this area.

  Parameters:
    `polygon` - the polygon to test.`getPolygon()`
  Returns:
    whether the polygon intersects this area.

### translate

    public boolean translate(float x,
                             float y)

  Translates the area by the (x,y) vector without going out of the map. Returns true if the modification is done (can be done).

  Parameters:
    `x` - x-coordinate of the translation vector.
    `y` - x-coordinate of the translation vector.
  Returns:
    true if the modification is done (can be done).

### rotate

    public boolean rotate(float angle)

  Rotates the area by the angle around the reference point `getX()` without going out of the `Map`. Returns true if the transformation has been done, false otherwise.

  Parameters:
    `angle` - the angle of the rotation ( in radian )
  Returns:
    true if the transformation has been done, false otherwise.

### rescale

    public boolean rescale(float x,
                           float y)

  Rescale by a 'x' and a 'y' factor without going out of the `Map`. Returns true if the transformation has been done, false otherwise.

  Parameters:
    `x` - the x-factor.
    `y` - the y-factor.
  Returns:
    true if the transformation has been done, false otherwise.

### simuleTranslate

    public java.util.Vector simuleTranslate(float x,
                                            float y)

  Returns the covering boxes which would result of the (x,y) translation of the area. It's used to foresee your position and so determine whether you can move. Null if out of the map.

  Parameters:
    `x` - the x-coordinate of the translation.
    `y` - the y-coordinate of the translation.
  Returns:
    the covering boxes which would result of the (x,y) translation of the area.

### simuleRotate

    public java.util.Vector simuleRotate(float angle)

  Returns the covering boxes which would result of the rotation. Null if out of the map.

  Parameters:
    `angle` - the angle of the simulated rotation.
  Returns:
    the covering boxes which would result of the rotation.

### simuleRescale

    public java.util.Vector simuleRescale(float x,
                                          float y)

  Returns the covering boxes which would result of the rescale. Null if goes out of the map.

  Parameters:
    `x` - the x-factor of the simulated rescale.
    `y` - the y-factor of the simulated rescale.
  Returns:
    the covering boxes which would result of the rescale.

### confirmSimuled

    public void confirmSimuled()

  Confirms the last move simulated with a simule method of the area. The interest of using these two separate fonctions is to allow the collision detections or other computation before confirming the move. So, it is possible for an element to know the boxes that it would occupy after a spcified move, and then it can decide whether this move is suitable for it. We gain a lot of time here, not computing two times the same thing.

### draw

    public void draw(Drawing g)

  Draws the `Area` and eventually the image of the associated element. It gives a default method to draw elements.

  Parameters:
    `g` - the `Drawing` object containing the graphics context.

### fill

    public void fill(Drawing g,
                     java.awt.Color c)

  Fills the area with the given color.

### drawBorder

    public void drawBorder(Drawing g,
                           java.awt.Color c)

  Draws the borders of the area with the given color.

### highlight

    public void highlight(Drawing g,
                          java.awt.Color c)

  Highlights the `Area`. is used when it's selected in the interface. It's better to give a transparent color in order to have something nice.

  Parameters:
    `g` - the `Drawing` object.
    `c` - the `Color` used to highlight.

### getProperties

    public java.lang.String[][] getProperties()

  Returns the Area's properties.

  Returns:
    the element's properties.
  See Also:
    `Engine.getProperties()`

### setProperties

    public void setProperties(java.lang.String property,
                              java.lang.String value)

  Sets the value of a property of the area. The new value is ignored if the property is read_only or if the value isn't valid.

  Parameters:
    `property` - the property to change.
    `value` - the new value for the property.
  See Also:
    `Engine.setProperties(java.lang.String, java.lang.String)`

### clone

    public java.lang.Object clone()

  Clone the area.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD