alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

// $Id: FigEdgeNote.java,v 1.9 2004/08/12 20:16:33 mvw Exp $
// Copyright (c) 1996-2004 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
// and this paragraph appear in all copies.  This software program and
// documentation are copyrighted by The Regents of the University of
// California. The software program and documentation are supplied "AS
// IS", without any accompanying services from The Regents. The Regents
// does not warrant that the operation of the program will be
// uninterrupted or error-free. The end-user understands that the program
// was developed for research purposes and is advised not to rely
// exclusively on the program for any reason.  IN NO EVENT SHALL THE
// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

package org.argouml.uml.diagram.static_structure.ui;

import java.awt.event.KeyListener;
import java.awt.event.MouseListener;
import java.beans.PropertyChangeListener;
import java.beans.VetoableChangeListener;

import org.argouml.i18n.Translator;
import org.argouml.kernel.DelayedVChangeListener;
import org.argouml.kernel.ProjectManager;
import org.argouml.model.ModelFacade;
import org.argouml.uml.UUIDManager;
import org.argouml.uml.diagram.ui.FigEdgeModelElement;
import org.tigris.gef.base.Layer;
import org.tigris.gef.presentation.Fig;
import org.tigris.gef.presentation.FigNode;
import org.tigris.gef.presentation.FigPoly;

import ru.novosoft.uml.MElementEvent;


/** 
 * Class to display a UML note connection to a
 * annotated model element.

*

* The owner of this fig is allways CommentEdge *

* * @author Andreas Rueckert * @author jaap.branderhorst@xs4all.nl */ public class FigEdgeNote extends FigEdgeModelElement implements VetoableChangeListener, DelayedVChangeListener, MouseListener, KeyListener, PropertyChangeListener { private Object owner; /** * Construct a new note connection. Use the same layout as for * other edges. */ public FigEdgeNote() { super(); setBetweenNearestPoints(true); ((FigPoly) _fig).setRectilinear(false); setDashed(true); } /** * Constructor that hooks the Fig to a UML element * @param theOwner the UML element * @param theLayer the layer (ignored) */ public FigEdgeNote(Object theOwner, Layer theLayer) { this(((CommentEdge) theOwner).getSource(), ((CommentEdge) theOwner).getDestination()); setOwner(theOwner); } /** * Constructs a new figedgenote from some object to another * object. The objects must have a representation on the given * layer.

* * @param fromNode the source * @param toNode the destination */ public FigEdgeNote(Object fromNode, Object toNode) { this(); Layer lay = ProjectManager.getManager().getCurrentProject() .getActiveDiagram().getLayer(); setLayer(lay); Fig destFig = lay.presentationFor(toNode); Fig sourceFig = lay.presentationFor(fromNode); if (destFig == null || sourceFig == null) throw new IllegalStateException("No destfig or sourcefig while " + "creating FigEdgeNode"); setDestFigNode((FigNode) destFig); setDestPortFig(destFig); setSourceFigNode((FigNode) sourceFig); setSourcePortFig(sourceFig); computeRoute(); } //////////////////////////////////////////////////////////////// // accessors /** * @see org.tigris.gef.presentation.FigEdge#setFig(org.tigris.gef.presentation.Fig) */ public void setFig(Fig f) { super.setFig(f); _fig.setDashed(true); } /** * @see org.argouml.uml.diagram.ui.FigEdgeModelElement#canEdit(org.tigris.gef.presentation.Fig) */ protected boolean canEdit(Fig f) { return false; } /** * @see java.lang.Object#toString() */ public String toString() { return Translator.localize("misc.comment-edge"); } /** * @see org.argouml.uml.diagram.ui.FigEdgeModelElement#modelChanged(ru.novosoft.uml.MElementEvent) */ protected void modelChanged(MElementEvent e) { } /** * @see org.tigris.gef.presentation.Fig#setOwner(java.lang.Object) */ public void setOwner(Object newOwner) { // hack to avoid loading problems since we cannot store // the whole model yet in XMI if (newOwner == null) { newOwner = new CommentEdge(getSourceFigNode(), getDestFigNode()); } owner = newOwner; if (ModelFacade.getUUID(newOwner) == null) { ModelFacade.setUUID(newOwner, UUIDManager.getInstance().getNewUUID()); } } /** * @see org.tigris.gef.presentation.Fig#getOwner() */ public Object getOwner() { return owner; } /** * @see org.tigris.gef.presentation.Fig#postLoad() */ public void postLoad() { super.postLoad(); CommentEdge o = (CommentEdge) getOwner(); o.setDestination(getDestFigNode().getOwner()); o.setSource(getSourceFigNode().getOwner()); } } /* end class FigEdgeNote */

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.