y.view
Class Bend

java.lang.Object
  |
  +--y.view.Bend

public class Bend
extends Object

This class represents a control point of a visual edge. Each bend belongs to at most one edge. Edges may have more than one bend. Bends can be interpreted in different ways, depending on the EdgeRealizer they belong to.

Since a bend without edge realizer makes not much sense, it is the resonsibility of an edge realizer to create bends.


Constructor Summary
protected Bend(EdgeRealizer er, double xpos, double ypos)
          Instantiates a new Bend at the given location.
 
Method Summary
 boolean contains(double x, double y)
          Whether or not the given coordinates lie within this bend.
 Edge getEdge()
          Returns the edge this bend belongs to.
 double getX()
          Returns the absolute x-coordinate of this bend.
 double getY()
          Returns the absolute y-coordinate of this bend.
 boolean isInBox(double x, double y, double width, double height)
          Whether or not this bend is inside of the box defined by the given arguments.
 boolean isSelected()
          Whether or not this beend is in a selected state.
 void moveBy(double dx, double dy)
          Moves the location of this bend by (dx,dy).
 void paint(Graphics2D gfx)
          Paints this bend on the given graphics context.
static void paintDefaultBend(Graphics2D gfx, double x, double y)
          Paints a default bend at the given center location.
static void paintDefaultBend(Graphics2D gfx, double x, double y, Color c)
          Paints a default bend at the given center location.
 void setLocation(double newX, double newY)
          Sets the absolute location of this bend to the given coordinates.
 void setSelected(boolean s)
          Sets the selected state of this bend.
 String toString()
          Returns a string representation of this bend, namely it's coords.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Bend

protected Bend(EdgeRealizer er,
               double xpos,
               double ypos)
Instantiates a new Bend at the given location. The given edge realizer must be the one who actually creates this bend.

Method Detail

getEdge

public Edge getEdge()
Returns the edge this bend belongs to.


setLocation

public void setLocation(double newX,
                        double newY)
Sets the absolute location of this bend to the given coordinates.


moveBy

public void moveBy(double dx,
                   double dy)
Moves the location of this bend by (dx,dy). the owning edge realizer will be informed that the bend has been moved.

See Also:
bendChanged

getX

public double getX()
Returns the absolute x-coordinate of this bend.


getY

public double getY()
Returns the absolute y-coordinate of this bend.


isSelected

public boolean isSelected()
Whether or not this beend is in a selected state.


setSelected

public void setSelected(boolean s)
Sets the selected state of this bend.


contains

public boolean contains(double x,
                        double y)
Whether or not the given coordinates lie within this bend. For this hit test it is assumed that the bend has a virtual size of (5,5).


isInBox

public boolean isInBox(double x,
                       double y,
                       double width,
                       double height)
Whether or not this bend is inside of the box defined by the given arguments.

Returns:
true iff this bend is inside the box.

paint

public void paint(Graphics2D gfx)
Paints this bend on the given graphics context.


paintDefaultBend

public static void paintDefaultBend(Graphics2D gfx,
                                    double x,
                                    double y)
Paints a default bend at the given center location. The bend gets painted in black.


paintDefaultBend

public static void paintDefaultBend(Graphics2D gfx,
                                    double x,
                                    double y,
                                    Color c)
Paints a default bend at the given center location. The bend gets painted with the given color.


toString

public String toString()
Returns a string representation of this bend, namely it's coords.

Overrides:
toString in class Object

© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003