Coverage Report - org.argouml.uml.diagram.state.ui.FigBranchState
 
Classes in this File Line Coverage Branch Coverage Complexity
FigBranchState
0%
0/40
0%
0/2
1.125
 
 1  
 /* $Id: FigBranchState.java 18728 2010-09-10 09:29:47Z mvw $
 2  
  *****************************************************************************
 3  
  * Copyright (c) 2009-2010 Contributors - see below
 4  
  * All rights reserved. This program and the accompanying materials
 5  
  * are made available under the terms of the Eclipse Public License v1.0
 6  
  * which accompanies this distribution, and is available at
 7  
  * http://www.eclipse.org/legal/epl-v10.html
 8  
  *
 9  
  * Contributors:
 10  
  *    Michiel van der Wulp
 11  
  *****************************************************************************
 12  
  *
 13  
  * Some portions of this file was previously release using the BSD License:
 14  
  */
 15  
 
 16  
 // Copyright (c) 2004-2009 The Regents of the University of California. All
 17  
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 18  
 // software and its documentation without fee, and without a written
 19  
 // agreement is hereby granted, provided that the above copyright notice
 20  
 // and this paragraph appear in all copies.  This software program and
 21  
 // documentation are copyrighted by The Regents of the University of
 22  
 // California. The software program and documentation are supplied "AS
 23  
 // IS", without any accompanying services from The Regents. The Regents
 24  
 // does not warrant that the operation of the program will be
 25  
 // uninterrupted or error-free. The end-user understands that the program
 26  
 // was developed for research purposes and is advised not to rely
 27  
 // exclusively on the program for any reason.  IN NO EVENT SHALL THE
 28  
 // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
 29  
 // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
 30  
 // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
 31  
 // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
 32  
 // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
 33  
 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 34  
 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
 35  
 // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
 36  
 // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
 37  
 // UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 38  
 
 39  
 package org.argouml.uml.diagram.state.ui;
 40  
 
 41  
 import java.awt.Color;
 42  
 import java.awt.Point;
 43  
 import java.awt.Rectangle;
 44  
 import java.awt.event.MouseEvent;
 45  
 import java.util.Iterator;
 46  
 
 47  
 import org.argouml.uml.diagram.DiagramSettings;
 48  
 import org.tigris.gef.presentation.Fig;
 49  
 import org.tigris.gef.presentation.FigCircle;
 50  
 
 51  
 /**
 52  
  * Class to display graphics for a UML Choice State in a diagram - the circle.
 53  
  *
 54  
  * TODO: This should really be renamed FigChoiceState.  It's the
 55  
  * last vestige of the UML 1.3 name.
 56  
  *
 57  
  * @author pepargouml
 58  
  */
 59  
 public class FigBranchState extends FigStateVertex {
 60  
 
 61  
     private static final int BWIDTH = 24;
 62  
     private static final int BHEIGHT = 24;
 63  
 
 64  
     private FigCircle head;
 65  
 
 66  
 
 67  
     /**
 68  
      * Construct a new FigBranchState.
 69  
      * 
 70  
      * @param owner owning UML element
 71  
      * @param bounds position and size
 72  
      * @param settings rendering settings
 73  
      */
 74  
     public FigBranchState(Object owner, Rectangle bounds,
 75  
             DiagramSettings settings) {
 76  0
         super(owner, bounds, settings);
 77  0
         initFigs();
 78  0
     }
 79  
     
 80  
     @Override
 81  
     protected Fig createBigPortFig() {
 82  0
         FigCircle bp = new FigCircle(X0, Y0, BWIDTH, BHEIGHT, DEBUG_COLOR, DEBUG_COLOR);
 83  0
         return bp;
 84  
     }
 85  
 
 86  
     private void initFigs() {
 87  0
         setEditable(false);
 88  0
         head = new FigCircle(X0, Y0, BWIDTH, BHEIGHT, LINE_COLOR, FILL_COLOR);
 89  
 
 90  
         // add Figs to the FigNode in back-to-front order
 91  0
         addFig(getBigPort());
 92  0
         addFig(head);
 93  
 
 94  0
         setBlinkPorts(false); //make port invisible unless mouse enters
 95  0
     }
 96  
 
 97  
     /*
 98  
      * This makes dragging connected edges very smooth.
 99  
      *
 100  
      * @see org.tigris.gef.presentation.Fig#getClosestPoint(java.awt.Point)
 101  
      */
 102  
     @Override
 103  
     public Point getClosestPoint(Point anotherPt) {
 104  0
         Point p = getBigPort().connectionPoint(anotherPt);
 105  0
         return p;
 106  
     }
 107  
 
 108  
     /*
 109  
      * @see java.lang.Object#clone()
 110  
      */
 111  
     @Override
 112  
     public Object clone() {
 113  0
         FigBranchState figClone = (FigBranchState) super.clone();
 114  0
         Iterator it = figClone.getFigs().iterator();
 115  0
         figClone.setBigPort((FigCircle) it.next());
 116  0
         figClone.head = (FigCircle) it.next();
 117  0
         return figClone;
 118  
     }
 119  
 
 120  
 
 121  
     /**
 122  
      * Choice states are fixed size.
 123  
      *
 124  
      * @return false
 125  
      */
 126  
     @Override
 127  
     public boolean isResizable() {
 128  0
         return false;
 129  
     }
 130  
 
 131  
     /*
 132  
      * @see org.tigris.gef.presentation.Fig#setLineColor(java.awt.Color)
 133  
      */
 134  
     @Override
 135  
     public void setLineColor(Color col) {
 136  0
         head.setLineColor(col);
 137  0
     }
 138  
 
 139  
     /*
 140  
      * @see org.tigris.gef.presentation.Fig#getLineColor()
 141  
      */
 142  
     @Override
 143  
     public Color getLineColor() {
 144  0
         return head.getLineColor();
 145  
     }
 146  
 
 147  
     /*
 148  
      * @see org.tigris.gef.presentation.Fig#setFillColor(java.awt.Color)
 149  
      */
 150  
     @Override
 151  
     public void setFillColor(Color col) {
 152  0
         head.setFillColor(col);
 153  0
     }
 154  
 
 155  
     /*
 156  
      * @see org.tigris.gef.presentation.Fig#getFillColor()
 157  
      */
 158  
     @Override
 159  
     public Color getFillColor() {
 160  0
         return head.getFillColor();
 161  
     }
 162  
 
 163  
     /**
 164  
      * Ignored - figure has a fixed rendering.
 165  
      * @param f ignored
 166  
      */
 167  
     @Override
 168  
     public void setFilled(boolean f) {
 169  
         // ignored - fixed rendering
 170  0
     }
 171  
 
 172  
     @Override
 173  
     public boolean isFilled() {
 174  0
         return true;
 175  
     }
 176  
 
 177  
     /*
 178  
      * @see org.tigris.gef.presentation.Fig#setLineWidth(int)
 179  
      */
 180  
     @Override
 181  
     public void setLineWidth(int w) {
 182  0
         head.setLineWidth(w);
 183  0
     }
 184  
 
 185  
     /*
 186  
      * @see org.tigris.gef.presentation.Fig#getLineWidth()
 187  
      */
 188  
     @Override
 189  
     public int getLineWidth() {
 190  0
         return head.getLineWidth();
 191  
     }
 192  
 
 193  
     ////////////////////////////////////////////////////////////////
 194  
     // Event handlers
 195  
 
 196  
     /*
 197  
      * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
 198  
      */
 199  
     @Override
 200  
     public void mouseClicked(MouseEvent me) {
 201  
         // ignored
 202  0
     }
 203  
 
 204  
     /**
 205  
      * Override setStandardBounds to keep shapes looking right.
 206  
      * {@inheritDoc}
 207  
      */
 208  
     @Override
 209  
     protected void setStandardBounds(int x, int y, int w, int h) {
 210  0
         if (getNameFig() == null) {
 211  0
             return;
 212  
         }
 213  0
         Rectangle oldBounds = getBounds();
 214  
 
 215  0
         getBigPort().setBounds(x, y, w, h);
 216  0
         head.setBounds(x, y, w, h);
 217  
 
 218  0
         calcBounds(); //_x = x; _y = y; _w = w; _h = h;
 219  0
         updateEdges();
 220  0
         firePropChange("bounds", oldBounds, getBounds());
 221  0
     }
 222  
 
 223  
 
 224  
     /**
 225  
      * The UID.
 226  
      */
 227  
     static final long serialVersionUID = 6572261327347541373L;
 228  
 
 229  
 }