fr.umlv.unitex
Class GenericGraphBox

java.lang.Object
  extended by fr.umlv.unitex.GenericGraphBox
Direct Known Subclasses:
FstGraphBox, GraphBox

public abstract class GenericGraphBox
extends java.lang.Object

This class describes a box of a graph or a sentence graph.

Author:
S�bastien Paumier

Field Summary
static int FINAL
           
static int INITIAL
           
static int NORMAL
           
 
Constructor Summary
GenericGraphBox(int x, int y, int type, GenericGraphicalZone p)
          Constructs a new box
 
Method Summary
 void addTransitionTo(GenericGraphBox g)
          Adds a transition to a box.
 void draw(java.awt.Graphics2D g)
          Draws the box
 void drawTransition(java.awt.Graphics2D g, GenericGraphBox dest)
          Draws a transition to a box
 void drawTransitions(java.awt.Graphics2D gr)
          Draws all transitions that go out of the box
 java.lang.String getContent()
           
 java.io.File getGraphClicked(int y)
          Tests if the click point was in a sub-graph call area.
 java.util.ArrayList getTransitions()
           
 int getType()
           
 int getWidth()
           
 int getX_in()
           
 int getX_out()
           
 int getX()
           
 int getX1()
           
 int getY_in()
           
 int getY_out()
           
 int getY()
           
 int getY1()
           
 boolean hasTransitionToItself()
           
 boolean isSelected()
           
 boolean isSelectedByRectangle(int Xr, int Yr, int Wr, int Hr)
          Tests if the box is selected by a rectangle
 int maxLineWidth()
          Returns the width of the box's largest line.
 void onlyAddTransitionTo(GenericGraphBox g)
          Adds a transition to a box.
 void removeTransitionTo(GenericGraphBox g)
          removes a box transition
abstract  void setContent(java.lang.String s)
          Sets the content of the box
 void setSelected(boolean b)
           
 void setTransitions(java.util.ArrayList transitions)
           
 void setType(int type)
           
 void setX_in(int x_in)
           
 void setX_out(int x_out)
           
 void setX(int x1)
           
 void setX1(int x1)
           
 void setY_in(int y_in)
           
 void setY_out(int y_out)
           
 void setY(int y)
           
 void setY1(int y1)
           
 void translate(int dx, int dy)
          Translates the box
 void translateToPosition(int xPos, int yPos)
          Translate a box to the x,y position
 void update()
          Updates the box by calling the setContent method with the current box content, which refresh the box properties.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL

public static final int INITIAL
See Also:
Constant Field Values

FINAL

public static final int FINAL
See Also:
Constant Field Values

NORMAL

public static final int NORMAL
See Also:
Constant Field Values
Constructor Detail

GenericGraphBox

public GenericGraphBox(int x,
                       int y,
                       int type,
                       GenericGraphicalZone p)
Constructs a new box

Parameters:
x - X coordinate of the input point of the box
y - Y coordinate of the input point of the box
type - indicates if the box is initial, final or normal
p - component on which the box will be drawn
Method Detail

getGraphClicked

public java.io.File getGraphClicked(int y)
Tests if the click point was in a sub-graph call area. In that case, it returns the sub-graph's name

Parameters:
y - Y coordinate of the click point
Returns:
the sub-graph's name, or the empty string if no graph was pointed out by the click

addTransitionTo

public void addTransitionTo(GenericGraphBox g)
Adds a transition to a box. If there is allready a transition to this box, it is removed.

Parameters:
g - the destination box

onlyAddTransitionTo

public void onlyAddTransitionTo(GenericGraphBox g)
Adds a transition to a box. If there is allready a transition to this box, it is not removed.

Parameters:
g - the destination box

removeTransitionTo

public void removeTransitionTo(GenericGraphBox g)
removes a box transition

Parameters:
g - the transition's destination box

translate

public void translate(int dx,
                      int dy)
Translates the box

Parameters:
dx - length of X shift in pixels
dy - length of Y shift in pixels

isSelectedByRectangle

public boolean isSelectedByRectangle(int Xr,
                                     int Yr,
                                     int Wr,
                                     int Hr)
Tests if the box is selected by a rectangle

Parameters:
Xr - X coordinate of the upper left corner of the rectangle
Yr - Y coordinate of the upper left corner of the rectangle
Wr - width of the rectangle
Hr - height of the rectangle
Returns:
true if the intersection between the box and the rectangle is not empty, false otherwise

drawTransition

public void drawTransition(java.awt.Graphics2D g,
                           GenericGraphBox dest)
Draws a transition to a box

Parameters:
g - the graphical context
dest - the destination box

drawTransitions

public void drawTransitions(java.awt.Graphics2D gr)
Draws all transitions that go out of the box

Parameters:
gr - the graphical context

draw

public void draw(java.awt.Graphics2D g)
Draws the box

Parameters:
g - the graphical context

maxLineWidth

public int maxLineWidth()
Returns the width of the box's largest line.

Returns:
the width

setContent

public abstract void setContent(java.lang.String s)
Sets the content of the box

Parameters:
s - the content

update

public void update()
Updates the box by calling the setContent method with the current box content, which refresh the box properties. It used to recompute box properties, for example when the user has changed font sizes.


getTransitions

public java.util.ArrayList getTransitions()

getX

public int getX()

getY

public int getY()

getContent

public java.lang.String getContent()
Returns:
the box content as it appears in the text edition field

translateToPosition

public void translateToPosition(int xPos,
                                int yPos)
Translate a box to the x,y position

Parameters:
xPos -
yPos -

hasTransitionToItself

public boolean hasTransitionToItself()

isSelected

public boolean isSelected()

setSelected

public void setSelected(boolean b)
Parameters:
b -

setX

public void setX(int x1)

setY

public void setY(int y)

getWidth

public int getWidth()

getX_in

public int getX_in()

setX_in

public void setX_in(int x_in)

getX_out

public int getX_out()

setX_out

public void setX_out(int x_out)

getX1

public int getX1()

setX1

public void setX1(int x1)

getY1

public int getY1()

setY1

public void setY1(int y1)

getY_in

public int getY_in()

setY_in

public void setY_in(int y_in)

getY_out

public int getY_out()

setY_out

public void setY_out(int y_out)

getType

public int getType()

setType

public void setType(int type)

setTransitions

public void setTransitions(java.util.ArrayList transitions)