Search this API

y.view
Class Bend

java.lang.Object
  extended by y.view.Bend

public class Bend
extends java.lang.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 responsibility 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)
          Returns whether or not the given coordinates lie within this bend.
 Edge getEdge()
          Returns the edge this bend belongs to.
 EdgeRealizer getRealizer()
          Returns the visual representation of 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)
          Returns whether or not this bend is inside the box defined by the given arguments.
 boolean isSelected()
          Returns whether or not this bend is in a selected state.
 void moveBy(double dx, double dy)
          Moves the location of this bend by (dx,dy).
 void paint(java.awt.Graphics2D gfx)
          Paints this bend on the given graphics context.
static void paintDefaultBend(java.awt.Graphics2D gfx, double x, double y)
          Paints a default bend at the given center location.
static void paintDefaultBend(java.awt.Graphics2D gfx, double x, double y, java.awt.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.
 java.lang.String toString()
          Returns a string representation of this bend, namely its coordinates.
 
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.


getRealizer

public EdgeRealizer getRealizer()
Returns the visual representation of the edge this bend belongs to.

Returns:
the EdgeRealizer instance this bend belongs to.

setLocation

public void setLocation(double newX,
                        double newY)
Sets the absolute location of this bend to the given coordinates. The owning edge realizer will be informed that the bend has been set to a new location.

See Also:
bendChanged

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()
Returns whether or not this bend 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)
Returns 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).

Returns:
true iff the given coordinates lie within this bend; false otherwise.

isInBox

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

Returns:
true iff this bend is inside the box.

paint

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


paintDefaultBend

public static void paintDefaultBend(java.awt.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(java.awt.Graphics2D gfx,
                                    double x,
                                    double y,
                                    java.awt.Color c)
Paints a default bend at the given center location. The bend gets painted with the given color.


toString

public java.lang.String toString()
Returns a string representation of this bend, namely its coordinates.

Overrides:
toString in class java.lang.Object

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