sk.uniba.euromath.tools
Class Draw2dTools

java.lang.Object
  extended by sk.uniba.euromath.tools.Draw2dTools

public class Draw2dTools
extends Object

Utilities for Draw2d.

Author:
Tomáš Studva 2.8.2006

Constructor Summary
Draw2dTools()
           
 
Method Summary
static EnumSet<Position> comparePosition(org.eclipse.draw2d.IFigure figure1, org.eclipse.draw2d.IFigure figure2)
          Compares position of figure2 to figure1.
static double computeDistance(org.eclipse.draw2d.IFigure figure1, org.eclipse.draw2d.IFigure figure2, Position side)
          Computes distance of sides of figures.
static double computeDistance(org.eclipse.draw2d.IFigure figure, org.eclipse.draw2d.geometry.Point p)
          Computes distance of figure from point p.
static int computeXDistance(org.eclipse.draw2d.IFigure figure, int xCoordinate)
          Computes horizontal distance of figure from xCoordinate vertical.
static int computeYDistance(org.eclipse.draw2d.IFigure figure, int yCoordinate)
          Computes vertical distance of figure from yCoordinate horizont.
static boolean contains(org.eclipse.draw2d.geometry.Rectangle rect, int x, int y)
          Tests whether point falls into or on bounds of rectangle.
static boolean contains(org.eclipse.draw2d.geometry.Rectangle rect, org.eclipse.draw2d.geometry.Point p)
          Tests whether point falls into or on bounds of rectangle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Draw2dTools

public Draw2dTools()
Method Detail

contains

public static boolean contains(org.eclipse.draw2d.geometry.Rectangle rect,
                               int x,
                               int y)
Tests whether point falls into or on bounds of rectangle.

Parameters:
rect - tested rectangle
x - X value
y - Y value
Returns:
true if falls

contains

public static boolean contains(org.eclipse.draw2d.geometry.Rectangle rect,
                               org.eclipse.draw2d.geometry.Point p)
Tests whether point falls into or on bounds of rectangle.

Parameters:
rect - tested rectangle
x - X value
y - Y value
Returns:
true if falls

computeDistance

public static double computeDistance(org.eclipse.draw2d.IFigure figure,
                                     org.eclipse.draw2d.geometry.Point p)
Computes distance of figure from point p. Distance is minimal length of any directional line between figure's bounds and point.

Parameters:
figure - to compute distance from p
p - point
Returns:
distance of figure from p

computeYDistance

public static int computeYDistance(org.eclipse.draw2d.IFigure figure,
                                   int yCoordinate)
Computes vertical distance of figure from yCoordinate horizont. Distance is minimal length of vertical line between figure's bounds and yCoordinate horizont.

Parameters:
figure - to compute distance from yCoordinate
yCoordinate - y coordinate of horizontal line
Returns:
distance of figure from yCoordinate

computeXDistance

public static int computeXDistance(org.eclipse.draw2d.IFigure figure,
                                   int xCoordinate)
Computes horizontal distance of figure from xCoordinate vertical. Distance is minimal length of horizontal line between figure's bounds and xCoordinate vertical.

Parameters:
figure - to compute distance from xCoordinate
xCoordinate - x coordinate of vertical line
Returns:
distance of figure from xCoordinate

computeDistance

public static double computeDistance(org.eclipse.draw2d.IFigure figure1,
                                     org.eclipse.draw2d.IFigure figure2,
                                     Position side)
Computes distance of sides of figures. Distance is computed as distance of lines figure's bounds on side spesified by side.

Parameters:
figure1 - argument for distance computation
figure2 - argument for distance computation
sides - of figures to compute distance, one of Position#LEFT, Position#RIGHT, Position#BOTTOM, Position#TOP
Returns:

comparePosition

public static EnumSet<Position> comparePosition(org.eclipse.draw2d.IFigure figure1,
                                                org.eclipse.draw2d.IFigure figure2)
Compares position of figure2 to figure1. If rectagles are graphically identical, then result contains Position#CONTAINS and Position#CONTAINED.

Parameters:
figure1 - to compare with
figure2 - figure to compare
Returns:
position of figure2 to figure2


Copyright © 2003-2006 null. All Rights Reserved.