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: CompartmentFigText.java,v 1.19 2004/09/10 20:05:30 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.ui;

import java.awt.Color;

import org.apache.log4j.Logger;
import org.argouml.ui.targetmanager.TargetManager;
import org.tigris.gef.presentation.Fig;
import org.tigris.gef.presentation.FigText;

/**
 * A FigText class extension for FigClass/FigInterface/FigUseCase
 * compartments.

* * This implementation now supports the extension point compartment in * a use case.

* * @author thn */ public class CompartmentFigText extends FigText { private static final Logger LOG = Logger.getLogger(CompartmentFigText.class); /////////////////////////////////////////////////////////////////////////// // // Instance variables // /////////////////////////////////////////////////////////////////////////// /** * The bounding figure of the compartment containing this fig text.

*/ private Fig refFig; /** * Record whether we are currently highlighted.

*/ private boolean isHighlighted; /** * The model element with which we are associated.

*/ private Object modelElement; /////////////////////////////////////////////////////////////////////////// // // constructors // /////////////////////////////////////////////////////////////////////////// /** * Build a new compartment figText of the given dimensions, within * the compartment described by aFig.

* * Invoke the parent constructor, then set the reference to the * associated compartment figure. The associated FigText is marked * as expand only.

* * Warning. Won't work properly if aFig is * null. A warning is printed.

* * @param x X coordinate of the top left of the FigText. * * @param y Y coordinate of the top left of the FigText. * * @param w Width of the FigText. * * @param h Height of the FigText. * * @param aFig The figure describing the whole compartment */ public CompartmentFigText(int x, int y, int w, int h, Fig aFig) { super(x, y, w, h, true); // Set the enclosing compartment fig. Warn if its null (which will // break). refFig = aFig; if (refFig == null) { LOG.warn(this.getClass().toString() + ": Cannot create with null compartment fig"); } } /////////////////////////////////////////////////////////////////////////// // // Accessors // /////////////////////////////////////////////////////////////////////////// // The following method overrides are necessary for proper graphical // behavior /** * Override for correct graphical behaviour.

* * @param w Desired line width. Overridden and set to zero anyway. */ public void setLineWidth(int w) { super.setLineWidth(0); } /** * Override for correct graphical behaviour.

* * @return Current line width—always 1. */ public int getLineWidth() { return 1; } /** * Override for correct graphical behaviour.

* * @return Current fill status—always true. */ public boolean getFilled() { return true; } /** * Override for correct graphical behaviour.

* * @return Current fill colour—always the fill colour of the * associated compartment fig. */ public Color getFillColor() { return refFig.getFillColor(); } /** * Override for correct graphical behaviour.

* * @return Current fill colour—always the fill colour of the * associated compartment fig. */ public Color getLineColor() { return refFig.getLineColor(); } /** * Mark whether this item is to be highlighted.

* * If it is highlighted, make the superclass line width 1 rather * than 0 and set the associated component fig as the target in * the browser.

* * @param flag true if the entry is to be highlighted, * false otherwise. */ public void setHighlighted(boolean flag) { isHighlighted = flag; super.setLineWidth(isHighlighted ? 1 : 0); if (flag && (modelElement != null)) { TargetManager.getInstance().setTarget(modelElement); } } /** * Return whether this item is highlighted.

* * @return true if the entry is highlighted, * false otherwise. */ public boolean isHighlighted() { return isHighlighted; } } /* End of class CompartmentFigText */

... 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.