|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
kaapo.project.graphics.DCGraphics
kaapo.project.graphics.ConnectionGraphics
public class ConnectionGraphics
A general graphics class for connections, with versatile arrow heads. Start and end line heads and line stroke (normal or dashed) can be customized.
The line is divided into three parts: start head, regular connection line and end head. The heads may be missing. Heads are are instances of LineHead. LineHead gives a graphic shape of the head that is drawn by ConnectionGraphics.
The connection line may also have a graphic text component that is used to render connection name or some other attribute. Currently, the text can't be edited directly and is limited to one-line text.
LineHead
,
Serialized FormNested Class Summary | |
---|---|
static class |
ConnectionGraphics.LineType
|
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected String |
centerTextAttributeName
|
protected TextLayout |
centerTextLayout
|
protected double |
centerTextX
|
protected double |
centerTextY
|
protected GeneralPath |
connectionBoundary
|
protected ConnectionWrapper |
cwrapper
|
protected GeneralPath |
endArrowShape
|
protected LineHead |
endHead
|
protected GeneralPath |
lineShape
|
protected ConnectionGraphics.LineType |
lineType
|
protected static double |
OUTER_BOUNDARY_MARGIN
|
protected Shape |
outerBoundary
|
protected GeneralPath |
startArrowShape
|
protected LineHead |
startHead
|
protected static double |
TEXT_DISTANCE_FROM_LINE
|
Fields inherited from class kaapo.project.graphics.DCGraphics |
---|
dc, dcw, pm |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
ConnectionGraphics(DiagramComponent dc,
ConnectionWrapper cw,
ProjectManager pm,
ConnectionGraphics.LineType lineType,
LineHead startHead,
LineHead endHead)
Constructs the connection graphics with no text field. |
|
ConnectionGraphics(DiagramComponent dc,
ConnectionWrapper cw,
ProjectManager pm,
ConnectionGraphics.LineType lineType,
LineHead startHead,
LineHead endHead,
String centerTextAttributeName)
Constructs the connection graphics with text in center. |
Method Summary | |
---|---|
protected GeneralPath |
buildLinePath(double translateX,
double translateY)
Builds the path for the regular line (between the heads). |
protected Point2D |
calcCenterTextStartPoint(double width,
double height)
Calculates the coordinates for center text area. |
protected Point2D |
calcEndHeadStartPoint(double translateX,
double translateY)
Calculates the starting point of the end head. |
protected Shape |
calcOuterBoundary()
Calculates the outer boundary which is used for mouse hit checks. |
protected Point2D |
calcStartHeadEndPoint(double translateX,
double translateY)
Calculates the ending point of the start head. |
Shape |
getConnectionBoundary()
Returns the boundary where connection points may be attached. |
Shape |
getOuterBoundary()
Returns the outer boundary (shape) of graphical representation of the element. |
protected void |
paintComponent(Graphics g)
|
void |
removeObserver()
This method should be called before disposing an observer. |
void |
update(Observable observable,
Object message)
This method is called whenever the observed object is changed. |
void |
updateDCGraphics()
Update the graphical appearance after element properties have been changed. |
Methods inherited from class kaapo.project.graphics.DCGraphics |
---|
calcConnectionIntersectPoint, getDiagramComponent, getDiagramComponentWrapper, getHotSpots, getProjectManager, updateDCGraphicsLater |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final double OUTER_BOUNDARY_MARGIN
protected static final double TEXT_DISTANCE_FROM_LINE
protected ConnectionWrapper cwrapper
protected ConnectionGraphics.LineType lineType
protected LineHead startHead
protected LineHead endHead
protected GeneralPath startArrowShape
protected GeneralPath endArrowShape
protected GeneralPath lineShape
protected Shape outerBoundary
protected GeneralPath connectionBoundary
protected String centerTextAttributeName
protected TextLayout centerTextLayout
protected double centerTextX
protected double centerTextY
Constructor Detail |
---|
public ConnectionGraphics(DiagramComponent dc, ConnectionWrapper cw, ProjectManager pm, ConnectionGraphics.LineType lineType, LineHead startHead, LineHead endHead, String centerTextAttributeName)
dc
- Associated diagram component (connection)cw
- Associated connection wrapperpm
- Project Manager that is used for attribute
modification (in the future)lineType
- Drawing style of the headstartHead
- Start head, may be nullendHead
- End head, may be nullcenterTextAttributeName
- Name of the attribute
that is used to display text in the center of
the connection.public ConnectionGraphics(DiagramComponent dc, ConnectionWrapper cw, ProjectManager pm, ConnectionGraphics.LineType lineType, LineHead startHead, LineHead endHead)
Method Detail |
---|
public Shape getOuterBoundary()
DCGraphics
getOuterBoundary
in class DCGraphics
public Shape getConnectionBoundary()
DCGraphics
getConnectionBoundary
in class DCGraphics
public void updateDCGraphics()
DCGraphics
updateDCGraphics
in class DCGraphics
protected Point2D calcStartHeadEndPoint(double translateX, double translateY)
translateX
- X coordinate to be added to the pointtranslateY
- Y coordinate to be added to the pointprotected Point2D calcEndHeadStartPoint(double translateX, double translateY)
translateX
- X coordinate to be added to the pointtranslateY
- Y coordinate to be added to the pointprotected Point2D calcCenterTextStartPoint(double width, double height)
width
- Width of the text areaheight
- Height of the text areaprotected GeneralPath buildLinePath(double translateX, double translateY)
translateX
- X coordinate to be added to the pathtranslateY
- Y coordinate to be added to the path
protected Shape calcOuterBoundary()
protected void paintComponent(Graphics g)
paintComponent
in class JComponent
public void update(Observable observable, Object message)
Observer
It's safe to modify the subject's observer list from update method. It won't affect the current notify round though, but the next.
update
in interface Observer
update
in class DCGraphics
observable
- the subject that fires the updatemessage
- the message delivered to observerpublic void removeObserver()
Observer
The reason for this is that the observer will remain in memory as long as there is references to it in it's observables' observer list. Observer will also receive updates until it's removed from all lists.
removeObserver
in interface Observer
removeObserver
in class DCGraphics
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |