Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
VioletPluginUseCase
- Loading branch information
tms08012
committed
Jun 7, 2012
1 parent
4a4bd29
commit bf0fbcc
Showing
14 changed files
with
961 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
VioletPluginUseCase/VioletPlugin.UseCaseDiagram/.classpath
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src/main/java"/> | ||
<classpathentry excluding="src/main/java/" kind="src" path=""/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="lib" path="/VioletProduct.eclipse-plugin/trunk/lib/com.horstmann.violet-2.0.0-SNAPSHOT.jar"/> | ||
<classpathentry kind="lib" path="C:/Users/tms08012/Documents/2012FallJars/com.horstmann.violet-0.21.1.jar"/> | ||
<classpathentry kind="lib" path="C:/Users/tms08012/Documents/2012FallJars/com.horstmann.violet.plugin.classdiagram-1.0-20110219.222952-4.jar"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>VioletPlugin.UseCaseDiagram</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
246 changes: 246 additions & 0 deletions
246
VioletPluginUseCase/VioletPlugin.UseCaseDiagram/horstmann.eclipse.code.formatter.xml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 | ||
http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.horstmann.violet.plugin</groupId> | ||
<artifactId>com.horstmann.violet.plugin.usecasediagram</artifactId> | ||
<name>Violet UML Editor Use Case Diagram Plugin</name> | ||
<version>2.0.0-SNAPSHOT</version> | ||
<description></description> | ||
<packaging>jar</packaging> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.horstmann.violet.framework</groupId> | ||
<artifactId>com.horstmann.violet.framework</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
</resource> | ||
<resource> | ||
<directory>src/main/java</directory> | ||
<includes> | ||
<include>**/*.gif</include> | ||
<include>**/*.jpg</include> | ||
<include>**/*.properties</include> | ||
<include>**/*.xml</include> | ||
</includes> | ||
</resource> | ||
</resources> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.0.2</version> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<distributionManagement> | ||
<repository> | ||
<id>web.sourceforge.net</id> | ||
<name>Violet's Maven Repository</name> | ||
<url> | ||
sftp://web.sourceforge.net/home/groups/v/vi/violet/htdocs/maven2/repo | ||
</url> | ||
</repository> | ||
</distributionManagement> | ||
<repositories> | ||
<repository> | ||
<id>violet.repo</id> | ||
<name>Violet's Maven repository (public access)</name> | ||
<url>http://violet.sourceforge.net/maven2/repo/</url> | ||
</repository> | ||
</repositories> | ||
</project> |
149 changes: 149 additions & 0 deletions
149
....UseCaseDiagram/src/main/java/com/horstmann/violet/product/diagram/usecase/ActorNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
/* | ||
Violet - A program for editing UML diagrams. | ||
Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) | ||
Alexandre de Pellegrin (http://alexdp.free.fr); | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*/ | ||
|
||
package com.horstmann.violet.product.diagram.usecase; | ||
|
||
import java.awt.Graphics2D; | ||
import java.awt.geom.GeneralPath; | ||
import java.awt.geom.Point2D; | ||
import java.awt.geom.Rectangle2D; | ||
|
||
import com.horstmann.violet.product.diagram.abstracts.node.RectangularNode; | ||
import com.horstmann.violet.product.diagram.abstracts.property.MultiLineString; | ||
|
||
/** | ||
* An actor node in a use case diagram. | ||
*/ | ||
public class ActorNode extends RectangularNode | ||
{ | ||
|
||
/** | ||
* Construct an actor node with a default size and name | ||
*/ | ||
public ActorNode() | ||
{ | ||
name = new MultiLineString(); | ||
name.setText("Actor"); | ||
} | ||
|
||
@Override | ||
public Rectangle2D getBounds() | ||
{ | ||
Rectangle2D top = new Rectangle2D.Double(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT); | ||
Rectangle2D bot = name.getBounds(); | ||
Point2D currentLocation = getLocation(); | ||
double x = currentLocation.getX(); | ||
double y = currentLocation.getY(); | ||
double w = Math.max(top.getWidth(), bot.getWidth()); | ||
double h = top.getHeight() + bot.getHeight(); | ||
Rectangle2D currentBounds = new Rectangle2D.Double(x, y, w, h); | ||
Rectangle2D snappedBounds = getGraph().getGrid().snap(currentBounds); | ||
return snappedBounds; | ||
} | ||
|
||
/** | ||
* Draws the stick man | ||
*/ | ||
@Override | ||
public void draw(Graphics2D g2) | ||
{ | ||
Rectangle2D bounds = getBounds(); | ||
|
||
// Draw stick person | ||
GeneralPath path = new GeneralPath(); | ||
float neckX = (float) (bounds.getX() + bounds.getWidth() / 2); | ||
float neckY = (float) (bounds.getY() + HEAD_SIZE + GAP_ABOVE); | ||
// head | ||
path.moveTo(neckX, neckY); | ||
path.quadTo(neckX + HEAD_SIZE / 2, neckY, neckX + HEAD_SIZE / 2, neckY - HEAD_SIZE / 2); | ||
path.quadTo(neckX + HEAD_SIZE / 2, neckY - HEAD_SIZE, neckX, neckY - HEAD_SIZE); | ||
path.quadTo(neckX - HEAD_SIZE / 2, neckY - HEAD_SIZE, neckX - HEAD_SIZE / 2, neckY - HEAD_SIZE / 2); | ||
path.quadTo(neckX - HEAD_SIZE / 2, neckY, neckX, neckY); | ||
// body | ||
float hipX = neckX; | ||
float hipY = neckY + BODY_SIZE; | ||
path.lineTo(hipX, hipY); | ||
// arms | ||
path.moveTo(neckX - ARMS_SIZE / 2, neckY + BODY_SIZE / 3); | ||
path.lineTo(neckX + ARMS_SIZE / 2, neckY + BODY_SIZE / 3); | ||
// legs | ||
float dx = (float) (LEG_SIZE / Math.sqrt(2)); | ||
float feetX1 = hipX - dx; | ||
float feetX2 = hipX + dx + 1; | ||
float feetY = hipY + dx + 1; | ||
path.moveTo(feetX1, feetY); | ||
path.lineTo(hipX, hipY); | ||
path.lineTo(feetX2, feetY); | ||
|
||
g2.draw(path); | ||
|
||
// Draw name | ||
Rectangle2D bot = name.getBounds(); | ||
Rectangle2D namebox = new Rectangle2D.Double(bounds.getX() + (bounds.getWidth() - bot.getWidth()) / 2, bounds.getY() | ||
+ DEFAULT_HEIGHT, bot.getWidth(), bot.getHeight()); | ||
name.draw(g2, namebox); | ||
} | ||
|
||
/** | ||
* Sets the name property value. | ||
* | ||
* @param newValue the new actor name | ||
*/ | ||
public void setName(MultiLineString newValue) | ||
{ | ||
name = newValue; | ||
} | ||
|
||
/** | ||
* Gets the name property value. | ||
* | ||
* @param the actor name | ||
*/ | ||
public MultiLineString getName() | ||
{ | ||
return name; | ||
} | ||
|
||
public ActorNode clone() | ||
{ | ||
ActorNode cloned = (ActorNode) super.clone(); | ||
cloned.name = (MultiLineString) name.clone(); | ||
return cloned; | ||
} | ||
|
||
/** Actor name */ | ||
private MultiLineString name; | ||
/** Bounding rectangle width */ | ||
private static int DEFAULT_WIDTH = 48; | ||
/** Bounding rectangle height */ | ||
private static int DEFAULT_HEIGHT = 64; | ||
|
||
/** Stick man : neck size */ | ||
private static int GAP_ABOVE = 4; | ||
/** Stick man : head size */ | ||
private static int HEAD_SIZE = DEFAULT_WIDTH * 4 / 12; | ||
/** Stick man : body size */ | ||
private static int BODY_SIZE = DEFAULT_WIDTH * 5 / 12; | ||
/** Stick man : leg size - Note : Height = HEAD_SIZE + BODY_SIZE + LEG_SIZE/sqrt(2) */ | ||
private static int LEG_SIZE = DEFAULT_WIDTH * 5 / 12; | ||
/** Stick man : arm size */ | ||
private static int ARMS_SIZE = DEFAULT_WIDTH * 6 / 12; | ||
} |
8 changes: 8 additions & 0 deletions
8
...am/src/main/java/com/horstmann/violet/product/diagram/usecase/UseCaseDiagramConstant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.horstmann.violet.product.diagram.usecase; | ||
|
||
public interface UseCaseDiagramConstant | ||
{ | ||
|
||
public static final String USECASE_DIAGRAM_STRINGS = "properties.UseCaseDiagramGraphStrings"; | ||
|
||
} |
114 changes: 114 additions & 0 deletions
114
...agram/src/main/java/com/horstmann/violet/product/diagram/usecase/UseCaseDiagramGraph.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
Violet - A program for editing UML diagrams. | ||
Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) | ||
Alexandre de Pellegrin (http://alexdp.free.fr); | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*/ | ||
|
||
package com.horstmann.violet.product.diagram.usecase; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Locale; | ||
import java.util.ResourceBundle; | ||
|
||
import com.horstmann.violet.product.diagram.abstracts.AbstractGraph; | ||
import com.horstmann.violet.product.diagram.abstracts.edge.IEdge; | ||
import com.horstmann.violet.product.diagram.abstracts.node.INode; | ||
import com.horstmann.violet.product.diagram.abstracts.property.ArrowHead; | ||
import com.horstmann.violet.product.diagram.abstracts.property.BentStyle; | ||
import com.horstmann.violet.product.diagram.abstracts.property.LineStyle; | ||
import com.horstmann.violet.product.diagram.common.DiagramLinkNode; | ||
import com.horstmann.violet.product.diagram.common.NoteEdge; | ||
import com.horstmann.violet.product.diagram.common.NoteNode; | ||
|
||
/** | ||
* A UML use case diagram. | ||
*/ | ||
public class UseCaseDiagramGraph extends AbstractGraph | ||
{ | ||
|
||
public List<INode> getNodePrototypes() | ||
{ | ||
return NODE_PROTOTYPES; | ||
} | ||
|
||
public List<IEdge> getEdgePrototypes() | ||
{ | ||
return EDGE_PROTOTYPES; | ||
} | ||
|
||
private static final List<INode> NODE_PROTOTYPES = new ArrayList<INode>(); | ||
|
||
private static final List<IEdge> EDGE_PROTOTYPES = new ArrayList<IEdge>(); | ||
|
||
static | ||
{ | ||
ResourceBundle rs = ResourceBundle.getBundle(UseCaseDiagramConstant.USECASE_DIAGRAM_STRINGS, Locale.getDefault()); | ||
|
||
ActorNode actorNode = new ActorNode(); | ||
actorNode.setToolTip(rs.getString("node0.tooltip")); | ||
NODE_PROTOTYPES.add(actorNode); | ||
|
||
UseCaseNode useCaseNode = new UseCaseNode(); | ||
useCaseNode.setToolTip(rs.getString("node1.tooltip")); | ||
NODE_PROTOTYPES.add(useCaseNode); | ||
|
||
NoteNode noteNode = new NoteNode(); | ||
noteNode.setToolTip(rs.getString("node2.tooltip")); | ||
NODE_PROTOTYPES.add(noteNode); | ||
|
||
DiagramLinkNode diagramLinkNode = new DiagramLinkNode(); | ||
diagramLinkNode.setToolTip(rs.getString("node3.tooltip")); | ||
NODE_PROTOTYPES.add(diagramLinkNode); | ||
|
||
UseCaseRelationshipEdge communication = new UseCaseRelationshipEdge(); | ||
communication.setBentStyle(BentStyle.STRAIGHT); | ||
communication.setLineStyle(LineStyle.SOLID); | ||
communication.setEndArrowHead(ArrowHead.NONE); | ||
communication.setToolTip(rs.getString("edge0.tooltip")); | ||
EDGE_PROTOTYPES.add(communication); | ||
|
||
UseCaseRelationshipEdge extendRel = new UseCaseRelationshipEdge(); | ||
extendRel.setBentStyle(BentStyle.STRAIGHT); | ||
extendRel.setLineStyle(LineStyle.DOTTED); | ||
extendRel.setEndArrowHead(ArrowHead.V); | ||
extendRel.setMiddleLabel("\u00ABextend\u00BB"); | ||
extendRel.setToolTip(rs.getString("edge1.tooltip")); | ||
EDGE_PROTOTYPES.add(extendRel); | ||
|
||
UseCaseRelationshipEdge includeRel = new UseCaseRelationshipEdge(); | ||
includeRel.setBentStyle(BentStyle.STRAIGHT); | ||
includeRel.setLineStyle(LineStyle.DOTTED); | ||
includeRel.setEndArrowHead(ArrowHead.V); | ||
includeRel.setMiddleLabel("\u00ABinclude\u00BB"); | ||
includeRel.setToolTip(rs.getString("edge2.tooltip")); | ||
EDGE_PROTOTYPES.add(includeRel); | ||
|
||
UseCaseRelationshipEdge generalization = new UseCaseRelationshipEdge(); | ||
generalization.setBentStyle(BentStyle.STRAIGHT); | ||
generalization.setLineStyle(LineStyle.SOLID); | ||
generalization.setEndArrowHead(ArrowHead.TRIANGLE); | ||
generalization.setToolTip(rs.getString("edge3.tooltip")); | ||
EDGE_PROTOTYPES.add(generalization); | ||
|
||
NoteEdge noteEdge = new NoteEdge(); | ||
noteEdge.setToolTip(rs.getString("edge4.tooltip")); | ||
EDGE_PROTOTYPES.add(noteEdge); | ||
} | ||
|
||
} |
Oops, something went wrong.