Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Violet/VioletPluginStateDiagram/VioletPlugin.StateDiagram/src/main/java/com/horstmann/violet/product/diagram/state/CircularInitialStateNode.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
71 lines (58 sloc)
2.16 KB
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
/* | |
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.state; | |
import java.awt.Graphics2D; | |
import java.awt.geom.Ellipse2D; | |
import java.awt.geom.Point2D; | |
import java.awt.geom.Rectangle2D; | |
import com.horstmann.violet.product.diagram.abstracts.node.EllipticalNode; | |
/** | |
* An initial or final node (bull's eye) in a state or activity diagram. | |
*/ | |
public class CircularInitialStateNode extends EllipticalNode | |
{ | |
@Override | |
public Rectangle2D getBounds() | |
{ | |
Point2D currentLocation = getLocation(); | |
double x = currentLocation.getX(); | |
double y = currentLocation.getY(); | |
double w = DEFAULT_DIAMETER; | |
double h = DEFAULT_DIAMETER; | |
Rectangle2D currentBounds = new Rectangle2D.Double(x, y, w, h); | |
Rectangle2D snappedBounds = getGraph().getGrid().snap(currentBounds); | |
return snappedBounds; | |
} | |
public void draw(Graphics2D g2) | |
{ | |
super.draw(g2); | |
Rectangle2D bounds = getBounds(); | |
Ellipse2D circle = new Ellipse2D.Double(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()); | |
g2.fill(circle); | |
} | |
/** | |
* Kept for compatibility with old versions | |
* | |
* @param dummy | |
*/ | |
public void setFinal(boolean dummy) | |
{ | |
// Nothing to do | |
} | |
/** default node diameter */ | |
private static int DEFAULT_DIAMETER = 20; | |
} |