org.objectweb.fractal.gui.graph.view
Class BasicComponentRenderer

java.lang.Object
  extended byorg.objectweb.fractal.gui.graph.view.BasicComponentRenderer
All Implemented Interfaces:
ComponentRenderer, Constants

public class BasicComponentRenderer
extends java.lang.Object
implements ComponentRenderer, Constants

Basic implementation of the ComponentRenderer interface. This implementation draws components as illustrated in the figure below.


Field Summary
 
Fields inherited from interface org.objectweb.fractal.gui.graph.view.ComponentRenderer
INSTANCE, NO_INSTANCE, STARTED, STOPPED
 
Fields inherited from interface org.objectweb.fractal.gui.Constants
BINDING_COLOR, BOLD_STROKE, COMPONENT_COLOR, DASHED_STROKE, ERROR_COLOR, NAME_FONT, NORMAL_STROKE, PROVIDED_COLOR, PROVIDED_FONT, REQUIRED_COLOR, REQUIRED_FONT, SELECTION_COLOR, WARNING_COLOR
 
Constructor Summary
BasicComponentRenderer()
          Constructs a new BasicComponentRenderer component.
 
Method Summary
 void drawComponent(java.awt.Graphics g, Component c, Selection s, java.awt.Rectangle r, java.awt.Color color, boolean expanded, int mode, int state)
          Draws the given component in the given rectangle.
protected  void drawString(java.awt.Graphics g, java.lang.String s, int x, int y, int dx, int dy, int insets, boolean left)
          Draws a string in the given rectangle.
 ComponentPart getComponentPart(Component c, java.awt.Rectangle r, boolean expanded, int x0, int y0)
          Returns the part of the given component that corresponds to the given point.
 java.awt.Point getInterfacePosition(Component c, java.awt.Rectangle r, Interface i)
          Returns the position of the given interface.
 java.awt.Rectangle getSubComponentArea(Component c, java.awt.Rectangle r)
          Returns the area of the given component into which its sub components must be drawn.
protected  void initialize(Component c, java.awt.Rectangle r)
          Prepares this component to draw the given component.
protected  int isBorder(int x, int y, int w, int h, int x0, int y0)
          Returns the border of the given rectangle to which the given point corresponds.
protected  int isCorner(int x, int y, int w, int h, int x0, int y0)
          Returns the corner of the given rectangle to which the given point corresponds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicComponentRenderer

public BasicComponentRenderer()
Constructs a new BasicComponentRenderer component.

Method Detail

drawComponent

public void drawComponent(java.awt.Graphics g,
                          Component c,
                          Selection s,
                          java.awt.Rectangle r,
                          java.awt.Color color,
                          boolean expanded,
                          int mode,
                          int state)
Description copied from interface: ComponentRenderer
Draws the given component in the given rectangle.

Specified by:
drawComponent in interface ComponentRenderer
Parameters:
g - the graphics to be used to draw the component.
c - the component to be drawn.
s - the selected component.
r - where the component must be drawn.
color - the component color.
expanded - if the component is exanded or not, i.e., if its sub components will be drawn (with other calls to this method) also or not.
mode - the displaying mode for interface name.
state - the status for component (either STARTED or STOPPED).

getComponentPart

public ComponentPart getComponentPart(Component c,
                                      java.awt.Rectangle r,
                                      boolean expanded,
                                      int x0,
                                      int y0)
Description copied from interface: ComponentRenderer
Returns the part of the given component that corresponds to the given point.

Specified by:
getComponentPart in interface ComponentRenderer
Parameters:
c - a component.
r - where the component is drawn.
expanded - if the component is exanded or not, i.e., if its sub components will be drawn also or not.
x0 - the x coordinate of the point of interest.
y0 - the y coordinate of the point of interest.
Returns:
the part of the given component that corresponds to the given point, or null if the given point does not correspond to any part of the given component.

getInterfacePosition

public java.awt.Point getInterfacePosition(Component c,
                                           java.awt.Rectangle r,
                                           Interface i)
Description copied from interface: ComponentRenderer
Returns the position of the given interface.

Specified by:
getInterfacePosition in interface ComponentRenderer
Parameters:
c - a component.
r - where the component is drawn.
i - the interface whose position must be returned.
Returns:
the position of the given interface.

getSubComponentArea

public java.awt.Rectangle getSubComponentArea(Component c,
                                              java.awt.Rectangle r)
Description copied from interface: ComponentRenderer
Returns the area of the given component into which its sub components must be drawn.

Specified by:
getSubComponentArea in interface ComponentRenderer
Parameters:
c - a component.
r - where the component is drawn.
Returns:
the area of the given component into which its sub components must be drawn.

initialize

protected void initialize(Component c,
                          java.awt.Rectangle r)
Prepares this component to draw the given component.

Parameters:
c - the component that will be drawn.
r - where the component will be drawn.

drawString

protected void drawString(java.awt.Graphics g,
                          java.lang.String s,
                          int x,
                          int y,
                          int dx,
                          int dy,
                          int insets,
                          boolean left)
Draws a string in the given rectangle.

Parameters:
g - the graphics to be used to draw the string.
s - the string to be drawn.
x - left border of the rectangle where s must be drawn.
y - top border of the rectangle where s must be drawn.
dx - w of the rectangle where s must be drawn.
dy - h of the rectangle where s must be drawn.
insets - horizontal insets to be removed from (x,y,dx,dy).
left - if the string must drawn left justified or right justified.

isCorner

protected int isCorner(int x,
                       int y,
                       int w,
                       int h,
                       int x0,
                       int y0)
Returns the corner of the given rectangle to which the given point corresponds.

Parameters:
x - left border of the rectangle.
y - top border of the rectangle.
w - w of the rectangle.
h - h of the rectangle.
x0 - x coordinate of the point.
y0 - y coordinate of the point.
Returns:
the type of the corner to which the given point corresponds, or -1 if it does not corresponds to any corner.

isBorder

protected int isBorder(int x,
                       int y,
                       int w,
                       int h,
                       int x0,
                       int y0)
Returns the border of the given rectangle to which the given point corresponds.

Parameters:
x - left border of the rectangle.
y - top border of the rectangle.
w - w of the rectangle.
h - h of the rectangle.
x0 - x coordinate of the point.
y0 - y coordinate of the point.
Returns:
the type of the border to which the given point corresponds, or -1 if it does not corresponds to any border.