Skip to content
Permalink
4a4bd290b0
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
74 lines (60 sloc) 2.51 KB
/*
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 CircularFinalStateNode extends EllipticalNode
{
@Override
public Rectangle2D getBounds()
{
Point2D currentLocation = getLocation();
double x = currentLocation.getX();
double y = currentLocation.getY();
double w = DEFAULT_DIAMETER + 2 * DEFAULT_GAP;
double h = DEFAULT_DIAMETER + 2 * DEFAULT_GAP;
Rectangle2D currentBounds = new Rectangle2D.Double(x, y, w, h);
Rectangle2D snappedBounds = getGraph().getGrid().snap(currentBounds);
return snappedBounds;
}
/*
* (non-Javadoc)
*
* @see com.horstmann.violet.framework.Node#draw(java.awt.Graphics2D)
*/
public void draw(Graphics2D g2)
{
super.draw(g2);
Ellipse2D circle = new Ellipse2D.Double(getBounds().getX(), getBounds().getY(), getBounds().getWidth(), getBounds()
.getHeight());
Rectangle2D bounds = getBounds();
Ellipse2D inside = new Ellipse2D.Double(bounds.getX() + DEFAULT_GAP, bounds.getY() + DEFAULT_GAP, bounds.getWidth() - 2
* DEFAULT_GAP, bounds.getHeight() - 2 * DEFAULT_GAP);
g2.fill(inside);
g2.draw(circle);
}
/** default node diameter */
private static int DEFAULT_DIAMETER = 14;
/** default gap between the main circle and the ring for a final node */
private static int DEFAULT_GAP = 3;
}