Coverage Report - org.argouml.ui.StylePanelFig
 
Classes in this File Line Coverage Branch Coverage Complexity
StylePanelFig
0%
0/275
0%
0/114
3.808
 
 1  
 /* $Id: StylePanelFig.java 18555 2010-07-24 10:01:49Z bobtarling $
 2  
  *****************************************************************************
 3  
  * Copyright (c) 2009 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  
  *    tfmorris
 11  
  *****************************************************************************
 12  
  *
 13  
  * Some portions of this file was previously release using the BSD License:
 14  
  */
 15  
 
 16  
 // Copyright (c) 2003-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.ui;
 40  
 
 41  
 import java.awt.Color;
 42  
 import java.awt.Rectangle;
 43  
 import java.awt.event.FocusEvent;
 44  
 import java.awt.event.FocusListener;
 45  
 import java.awt.event.ItemEvent;
 46  
 import java.awt.event.ItemListener;
 47  
 import java.awt.event.KeyEvent;
 48  
 import java.awt.event.KeyListener;
 49  
 
 50  
 import javax.swing.DefaultComboBoxModel;
 51  
 import javax.swing.JColorChooser;
 52  
 import javax.swing.JComboBox;
 53  
 import javax.swing.JLabel;
 54  
 import javax.swing.JTextField;
 55  
 import javax.swing.text.Document;
 56  
 
 57  
 import org.apache.log4j.Logger;
 58  
 import org.argouml.i18n.Translator;
 59  
 import org.argouml.swingext.SpacerPanel;
 60  
 import org.argouml.ui.targetmanager.TargetManager;
 61  
 import org.argouml.uml.diagram.ArgoDiagram;
 62  
 import org.argouml.uml.diagram.DiagramUtils;
 63  
 import org.argouml.uml.diagram.DiagramSettings.StereotypeStyle;
 64  
 import org.argouml.uml.diagram.ui.ArgoFig;
 65  
 import org.argouml.uml.diagram.ui.FigEdgeModelElement;
 66  
 import org.argouml.uml.diagram.ui.FigNodeModelElement;
 67  
 import org.argouml.uml.diagram.ui.StereotypeStyled;
 68  
 import org.argouml.util.ArgoFrame;
 69  
 import org.tigris.gef.presentation.Fig;
 70  
 import org.tigris.gef.ui.ColorRenderer;
 71  
 
 72  
 /**
 73  
  * The basic stylepanel for a Fig which allows the user to see and adjust 
 74  
  * the common attributes of a Fig: 
 75  
  * the boundaries box,
 76  
  * line and fill color information 
 77  
  * and the stereotype view combo box. <p>
 78  
  * 
 79  
  * Shown to the user as the "Presentation" tab.
 80  
  */
 81  
 public class StylePanelFig
 82  
     extends StylePanel
 83  
     implements ItemListener,
 84  
         FocusListener, KeyListener {
 85  
     
 86  0
     private static final Logger LOG = Logger.getLogger(StylePanelFig.class);
 87  
     
 88  0
     private static final String CUSTOM_ITEM =
 89  
         Translator.localize("label.stylepane.custom") + "...";
 90  
 
 91  0
     private JLabel bboxLabel =
 92  
         new JLabel(Translator.localize("label.stylepane.bounds") + ": ");
 93  
 
 94  0
     private JTextField bboxField = new JTextField();
 95  
 
 96  0
     private JLabel fillLabel =
 97  
         new JLabel(Translator.localize("label.stylepane.fill") + ": ");
 98  
 
 99  0
     private JComboBox fillField = new JComboBox();
 100  
 
 101  0
     private JLabel lineLabel =
 102  
         new JLabel(Translator.localize("label.stylepane.line") + ": ");
 103  
 
 104  0
     private JComboBox lineField = new JComboBox();
 105  
 
 106  0
     private JLabel stereoLabel =
 107  
         new JLabel(Translator.localize("menu.popup.stereotype-view") + ": ");
 108  
 
 109  0
     private JComboBox stereoField = new JComboBox();
 110  
     
 111  0
     private SpacerPanel spacer = new SpacerPanel();
 112  
 
 113  0
     private SpacerPanel spacer2 = new SpacerPanel();
 114  
 
 115  0
     private SpacerPanel spacer3 = new SpacerPanel();
 116  
 
 117  
     /**
 118  
      * The constructor of the style panel of a Fig.
 119  
      * This constructor does not create any contents of the panel.
 120  
      *
 121  
      * @param title the title string
 122  
      */
 123  
     public StylePanelFig(String title) {
 124  0
         super(title);
 125  0
     }
 126  
 
 127  
     /**
 128  
      * The constructor.
 129  
      *
 130  
      */
 131  
     public StylePanelFig() {
 132  0
         super("Fig Appearance");
 133  0
         initChoices();
 134  
 
 135  0
         Document bboxDoc = bboxField.getDocument();
 136  0
         bboxDoc.addDocumentListener(this);
 137  0
         bboxField.addKeyListener(this);
 138  0
         bboxField.addFocusListener(this);
 139  0
         fillField.addItemListener(this);
 140  0
         lineField.addItemListener(this);
 141  0
         stereoField.addItemListener(this);
 142  
 
 143  0
         fillField.setRenderer(new ColorRenderer());
 144  0
         lineField.setRenderer(new ColorRenderer());
 145  
 
 146  0
         bboxLabel.setLabelFor(bboxField);
 147  0
         add(bboxLabel);
 148  0
         add(bboxField);
 149  
 
 150  0
         fillLabel.setLabelFor(fillField);
 151  0
         add(fillLabel);
 152  0
         add(fillField);
 153  
 
 154  0
         lineLabel.setLabelFor(lineField);
 155  0
         add(lineLabel);
 156  0
         add(lineField);
 157  
 
 158  0
         stereoLabel.setLabelFor(stereoField);
 159  0
         add(stereoLabel);
 160  0
         add(stereoField);
 161  0
     }
 162  
 
 163  
     /**
 164  
      * Fill in the user-choices.
 165  
      */
 166  
     protected void initChoices() {
 167  0
         fillField.addItem(Translator.localize("label.stylepane.no-fill"));
 168  0
         fillField.addItem(Color.black);
 169  0
         fillField.addItem(Color.white);
 170  0
         fillField.addItem(Color.gray);
 171  0
         fillField.addItem(Color.lightGray);
 172  0
         fillField.addItem(Color.darkGray);
 173  0
         fillField.addItem(new Color(255, 255, 200));
 174  0
         fillField.addItem(new Color(255, 200, 255));
 175  0
         fillField.addItem(new Color(200, 255, 255));
 176  0
         fillField.addItem(new Color(200, 200, 255));
 177  0
         fillField.addItem(new Color(200, 255, 200));
 178  0
         fillField.addItem(new Color(255, 200, 200));
 179  0
         fillField.addItem(new Color(200, 200, 200));
 180  0
         fillField.addItem(Color.red);
 181  0
         fillField.addItem(Color.blue);
 182  0
         fillField.addItem(Color.cyan);
 183  0
         fillField.addItem(Color.yellow);
 184  0
         fillField.addItem(Color.magenta);
 185  0
         fillField.addItem(Color.green);
 186  0
         fillField.addItem(Color.orange);
 187  0
         fillField.addItem(Color.pink);
 188  0
         fillField.addItem(CUSTOM_ITEM);
 189  
 
 190  0
         lineField.addItem(Translator.localize("label.stylepane.no-line"));
 191  0
         lineField.addItem(Color.black);
 192  0
         lineField.addItem(Color.white);
 193  0
         lineField.addItem(Color.gray);
 194  0
         lineField.addItem(Color.lightGray);
 195  0
         lineField.addItem(Color.darkGray);
 196  0
         lineField.addItem(new Color(60, 60, 200));
 197  0
         lineField.addItem(new Color(60, 200, 60));
 198  0
         lineField.addItem(new Color(200, 60, 60));
 199  0
         lineField.addItem(Color.red);
 200  0
         lineField.addItem(Color.blue);
 201  0
         lineField.addItem(Color.cyan);
 202  0
         lineField.addItem(Color.yellow);
 203  0
         lineField.addItem(Color.magenta);
 204  0
         lineField.addItem(Color.green);
 205  0
         lineField.addItem(Color.orange);
 206  0
         lineField.addItem(Color.pink);
 207  0
         lineField.addItem(CUSTOM_ITEM);
 208  
         
 209  0
         DefaultComboBoxModel model = new DefaultComboBoxModel();
 210  0
         stereoField.setModel(model);
 211  
         
 212  
         // NOTE: These must stay in this order to match rendering styles
 213  0
         model.addElement(Translator
 214  
                 .localize("menu.popup.stereotype-view.textual"));
 215  0
         model.addElement(Translator
 216  
                 .localize("menu.popup.stereotype-view.big-icon"));
 217  0
         model.addElement(Translator
 218  
                 .localize("menu.popup.stereotype-view.small-icon"));
 219  0
     }
 220  
 
 221  
     /**
 222  
      * set whether this Fig has a editable boundingbox. This is done normally in
 223  
      * <code>refresh()</code>, e.g. for FigEdgeModelElements where it does
 224  
      * not make sense to edit the bounding box.
 225  
      *
 226  
      * @param value
 227  
      *            the boolean value of the bounding box property
 228  
      */
 229  
 
 230  
     protected void hasEditableBoundingBox(boolean value) {
 231  0
         bboxField.setEnabled(value);
 232  0
         bboxLabel.setEnabled(value);
 233  0
     }
 234  
 
 235  
     /**
 236  
      * Handle a refresh of the style panel after the fig has moved.<p>
 237  
      *
 238  
      * <em>Warning</em>. There is a circular trap here. Editing the
 239  
      * boundary box will also trigger a refresh, and so we reset the
 240  
      * boundary box, which causes funny behaviour (the cursor keeps
 241  
      * jumping to the end of the text).
 242  
      *
 243  
      * The solution is to not reset the boundary box field if the boundaries
 244  
      * have not changed.<p>
 245  
      */
 246  
     public void refresh() {
 247  0
         if (TargetManager.getInstance().getTargets().size() > 1) {
 248  
             // See issue 6109 - if we have multiple targets this method
 249  
             // can result in a feedback problem where selecting a target
 250  
             // changes the selection colour in the combo and as a result
 251  
             // that trigger a change of colour of all selected Figs
 252  0
             return;
 253  
         }
 254  0
             Fig target = getPanelTarget();
 255  
              //TODO: How about FigAssociationClass?
 256  0
         if (target instanceof FigEdgeModelElement) {
 257  0
             hasEditableBoundingBox(false);
 258  
         } else {
 259  0
             hasEditableBoundingBox(true);
 260  
         }
 261  0
         if (target == null) {
 262  0
             return;
 263  
         }
 264  
 
 265  
         // The boundary box as held in the target fig, and as listed in
 266  
         // the
 267  
         // boundary box style field (null if we don't have anything
 268  
         // valid)
 269  
 
 270  0
         Rectangle figBounds = target.getBounds();
 271  0
         Rectangle styleBounds = parseBBox();
 272  
 
 273  
         // Only reset the text if the two are not the same (i.e the fig
 274  
         // has
 275  
         // moved, rather than we've just edited the text, when
 276  
         // setTargetBBox()
 277  
         // will have made them the same). Note that styleBounds could
 278  
         // be null,
 279  
         // so we do the test this way round.
 280  
 
 281  0
         if (!(figBounds.equals(styleBounds))) {
 282  0
             bboxField.setText(figBounds.x + "," + figBounds.y + ","
 283  
                     + figBounds.width + "," + figBounds.height);
 284  
         }
 285  
 
 286  
         // Change the fill colour
 287  
 
 288  0
         if (target.isFilled()) {
 289  0
             Color c = target.getFillColor();
 290  0
             fillField.setSelectedItem(c);
 291  0
             if (c != null && !fillField.getSelectedItem().equals(c)) {
 292  0
                 fillField.insertItemAt(c, fillField.getItemCount() - 1);
 293  0
                 fillField.setSelectedItem(c);
 294  
             }
 295  0
         } else {
 296  0
             fillField.setSelectedIndex(0);
 297  
         }
 298  
 
 299  
         // Change the line colour
 300  
 
 301  0
         if (target.getLineWidth() > 0) {
 302  0
             Color c = target.getLineColor();
 303  
             // TODO: This is going to cause the color to be reset on a refresh
 304  0
             lineField.setSelectedItem(c);
 305  0
             if (c != null && !lineField.getSelectedItem().equals(c)) {
 306  0
                 lineField.insertItemAt(c, lineField.getItemCount() - 1);
 307  0
                 lineField.setSelectedItem(c);
 308  
             }
 309  0
         } else {
 310  0
             lineField.setSelectedIndex(0);
 311  
         }
 312  
 
 313  0
         stereoField.setEnabled(target instanceof StereotypeStyled);
 314  0
         stereoLabel.setEnabled(target instanceof StereotypeStyled);
 315  
         
 316  0
         if (target instanceof StereotypeStyled) {
 317  0
             StereotypeStyled fig = (StereotypeStyled) target;
 318  0
             stereoField.setSelectedIndex(fig.getStereotypeStyle().ordinal());
 319  
         }
 320  0
     }
 321  
 
 322  
     /**
 323  
      * Change the bounds of the target fig. Called whenever the bounds box is
 324  
      * edited. <p>
 325  
      *
 326  
      * Format of the bounds is four integers representing x, y, width and height
 327  
      * separated by spaces or commas. An empty field is treated as no change and
 328  
      * leading and trailing spaces are ignored. <p>
 329  
      *
 330  
      * <em>Note</em>. There is a note in the old code that more work might be
 331  
      * needed, because this could change the graph model. I don't see how that
 332  
      * could ever be.
 333  
      */
 334  
     protected void setTargetBBox() {
 335  0
             Fig target = getPanelTarget();
 336  
         // Can't do anything if we don't have a fig.
 337  0
         if (target == null) {
 338  0
             return;
 339  
         }
 340  
         // Parse the boundary box text. Null is
 341  
         // returned if it is empty or
 342  
         // invalid, which causes no change. Otherwise we tell
 343  
         // GEF we are making
 344  
         // a change, make the change and tell GEF we've
 345  
         // finished.
 346  0
         Rectangle bounds = parseBBox();
 347  0
         if (bounds == null) {
 348  0
             return;
 349  
         }
 350  
 
 351  0
         if (!target.getBounds().equals(bounds)) {
 352  0
             target.setBounds(bounds.x, bounds.y, bounds.width,
 353  
                     bounds.height);
 354  0
             target.endTrans();
 355  
         }
 356  0
     }
 357  
 
 358  
     /**
 359  
      * Parse the boundary box string and return the rectangle it
 360  
      * represents.<p>
 361  
      *
 362  
      * The syntax are four integers separated by spaces or commas. We
 363  
      * ignore leading and trailing blanks.<p>
 364  
      *
 365  
      * If we have the empty string we return <code>null</code>.<p>
 366  
      *
 367  
      * If we fail to parse, then we return <code>null</code> and print
 368  
      * out a rude message.<p>
 369  
      *
 370  
      * @return The size of the box, or <code>null</code> if the bounds string
 371  
      *         is empty or invalid.
 372  
      */
 373  
     protected Rectangle parseBBox() {
 374  0
             Fig target = getPanelTarget();
 375  
         // Get the text in the field, and don't do anything if the
 376  
         // field is
 377  
         // empty.
 378  0
         String bboxStr = bboxField.getText().trim();
 379  0
         if (bboxStr.length() == 0) {
 380  0
             return null;
 381  
         } // Parse the string as if
 382  
         // possible
 383  0
         Rectangle res = new Rectangle();
 384  0
         java.util.StringTokenizer st =
 385  
             new java.util.StringTokenizer(bboxStr, ", ");
 386  
         try {
 387  0
             boolean changed = false;
 388  0
             if (!st.hasMoreTokens()) {
 389  0
                 return target.getBounds();
 390  
             }
 391  0
             res.x = Integer.parseInt(st.nextToken());
 392  0
             if (!st.hasMoreTokens()) {
 393  0
                 res.y = target.getBounds().y;
 394  0
                 res.width = target.getBounds().width;
 395  0
                 res.height = target.getBounds().height;
 396  0
                 return res;
 397  
             }
 398  0
             res.y = Integer.parseInt(st.nextToken());
 399  0
             if (!st.hasMoreTokens()) {
 400  0
                 res.width = target.getBounds().width;
 401  0
                 res.height = target.getBounds().height;
 402  0
                 return res;
 403  
             }
 404  0
             res.width = Integer.parseInt(st.nextToken());
 405  
             // TODO: What does the magic number 6000 represent here?
 406  
             // Put it in an explanatory literal! - tfm - 20071205
 407  0
             if ((res.width + res.x) > 6000) {
 408  0
                 res.width = 6000 - res.x;
 409  0
                 changed = true;
 410  
             }
 411  0
             if (!st.hasMoreTokens()) {
 412  0
                 res.width = target.getBounds().width;
 413  0
                 return res;
 414  
             }
 415  0
             res.height = Integer.parseInt(st.nextToken());
 416  
             // TODO: What does the magic number 6000 represent here?
 417  
             // Put it in an explanatory literal! - tfm - 20071205
 418  0
             if ((res.height + res.y) > 6000) {
 419  0
                 res.height = 6000 - res.y;
 420  0
                 changed = true;
 421  
             }
 422  0
             if (res.x < 0 || res.y < 0) {
 423  
                 // TODO: This exception will be thrown during autoscrolling
 424  
                 // when the edge of the canvas is reached causing either
 425  
                 // the width or height to be "adjusted" to a negative value
 426  0
                 LOG.warn("Part of bounding box is off screen " + res);
 427  
             }
 428  0
             if (res.width < 0 || res.height < 0) {
 429  
                 // TODO: This exception will be thrown during autoscrolling
 430  
                 // when the edge of the canvas is reached causing either
 431  
                 // the width or height to be "adjusted" to a negative value
 432  0
                 throw new IllegalArgumentException(
 433  
                         "Bounding box has negative size " + res);
 434  
             }
 435  0
             if (changed) {
 436  0
                 StringBuffer sb = new StringBuffer();
 437  0
                 sb.append(Integer.toString(res.x));
 438  0
                 sb.append(",");
 439  0
                 sb.append(Integer.toString(res.y));
 440  0
                 sb.append(",");
 441  0
                 sb.append(Integer.toString(res.width));
 442  0
                 sb.append(",");
 443  0
                 sb.append(Integer.toString(res.height));
 444  0
                 bboxField.setText(sb.toString());
 445  
             }
 446  0
         } catch (NumberFormatException ex) {
 447  0
             bboxField.setBackground(Color.RED);
 448  0
             return null;
 449  
         }
 450  0
         catch (IllegalArgumentException iae) {
 451  0
             bboxField.setBackground(Color.RED);
 452  0
             return null;
 453  0
         }
 454  0
         bboxField.setBackground(null);
 455  0
         return res;
 456  
     }
 457  
 
 458  
     /**
 459  
      * Prompts the user for a new custom color and adds that color to the combo
 460  
      * box.
 461  
      *
 462  
      * @param field the combobox to enter a new color for
 463  
      * @param title the i18n key for the title for the dialog box
 464  
      * @param targetColor the initial Color set when the color-chooser is shown
 465  
      */
 466  
     protected void handleCustomColor(JComboBox field, String title,
 467  
             Color targetColor) {
 468  0
         Color newColor =
 469  
             JColorChooser.showDialog(ArgoFrame.getFrame(),
 470  
                     Translator.localize(title), targetColor);
 471  0
         if (newColor != null) {
 472  0
             field.insertItemAt(newColor, field.getItemCount() - 1);
 473  0
             field.setSelectedItem(newColor);
 474  0
         } else if (getPanelTarget() != null) {
 475  0
             field.setSelectedItem(targetColor);
 476  
         }
 477  0
     }
 478  
 
 479  
     /**
 480  
      * Change the fill.
 481  
      */
 482  
     public void setTargetFill() {
 483  0
             Fig target = getPanelTarget();
 484  0
         Object c = fillField.getSelectedItem();
 485  0
         if (target == null || c == null) {
 486  0
             return;
 487  
         }
 488  0
         Boolean isColor = (c instanceof Color);
 489  0
         if (isColor) {
 490  0
             target.setFillColor((Color) c);
 491  
         }
 492  0
         target.setFilled(isColor);
 493  0
         target.endTrans();
 494  
         
 495  
         // TODO: The following handling of multiselection is just a local
 496  
         // solution for the fill color, better find a more general solution:
 497  
         // (I don't know if it's undoable this way - thn)
 498  0
         ArgoDiagram activeDiagram = DiagramUtils.getActiveDiagram();
 499  0
         for (Object t : TargetManager.getInstance().getTargets()) {
 500  0
             Fig fig = null;
 501  0
             if (t instanceof FigNodeModelElement) {
 502  0
                 fig = (Fig) t;
 503  
             } else {
 504  0
                 fig = activeDiagram.presentationFor(t);
 505  
             }
 506  0
             if (fig != null && fig != target) {
 507  0
                 if (isColor) {
 508  0
                     fig.setFillColor((Color) c);
 509  
                 }
 510  0
                 fig.setFilled(isColor);
 511  0
                 fig.endTrans();
 512  
             }
 513  0
         }
 514  0
     }
 515  
 
 516  
     /**
 517  
      * Change the line.
 518  
      */
 519  
     public void setTargetLine() {
 520  0
             Fig target = getPanelTarget();
 521  0
         Object c = lineField.getSelectedItem();
 522  0
         if (target == null || c == null) {
 523  0
             return;
 524  
         }
 525  0
         Boolean isColor = (c instanceof Color);
 526  0
         if (isColor) {
 527  0
             target.setLineColor((Color) c);
 528  
         }
 529  0
         target.setLineWidth(isColor ? ArgoFig.LINE_WIDTH : 0);
 530  0
         target.endTrans();
 531  
         
 532  
         // TODO: The following handling of multiselection is just a local
 533  
         // solution for the line color, better find a more general solution:
 534  
         // (I don't know if it's undoable this way - thn)
 535  0
         ArgoDiagram activeDiagram = DiagramUtils.getActiveDiagram();
 536  0
         for (Object t : TargetManager.getInstance().getTargets()) {
 537  0
             Fig fig = null;
 538  0
             if (t instanceof FigNodeModelElement) {
 539  0
                 fig = (Fig) t;
 540  
             } else {
 541  0
                 fig = activeDiagram.presentationFor(t);
 542  
             }
 543  0
             if (fig != null && fig != target) {
 544  0
                 if (isColor) {
 545  0
                     fig.setLineColor((Color) c);
 546  
                 }
 547  0
                 fig.setLineWidth(isColor ? ArgoFig.LINE_WIDTH : 0);
 548  0
                 fig.endTrans();
 549  
             }
 550  0
         }
 551  0
     }
 552  
 
 553  
     /*
 554  
      * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
 555  
      */
 556  
     public void itemStateChanged(ItemEvent e) {
 557  0
         Object src = e.getSource();
 558  0
         Fig target = getPanelTarget();
 559  0
         if (e.getStateChange() == ItemEvent.SELECTED
 560  
                 && target != null) {
 561  0
             if (src == fillField) {
 562  0
                 if (e.getItem() == CUSTOM_ITEM) {
 563  0
                     handleCustomColor(fillField, 
 564  
                             "label.stylepane.custom-fill-color",
 565  
                             target.getFillColor());
 566  
                 }
 567  0
                 setTargetFill();
 568  0
             } else if (src == lineField) {
 569  0
                 if (e.getItem() == CUSTOM_ITEM) {
 570  0
                     handleCustomColor(lineField, 
 571  
                             "label.stylepane.custom-line-color",
 572  
                             target.getLineColor());
 573  
                 }
 574  0
                 setTargetLine();
 575  0
             } else if (src == stereoField) {
 576  0
                 if (target instanceof StereotypeStyled) {
 577  0
                     Object item = e.getItem();
 578  0
                     DefaultComboBoxModel model = 
 579  
                         (DefaultComboBoxModel) stereoField.getModel();
 580  0
                     int idx = model.getIndexOf(item);
 581  0
                     StereotypeStyled fig = (StereotypeStyled) target;
 582  
 
 583  0
                     fig.setStereotypeStyle(StereotypeStyle.getEnum(idx));
 584  
 
 585  
                 }
 586  
             }
 587  
         }
 588  0
     }
 589  
 
 590  
     /*
 591  
      * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
 592  
      */
 593  
     public void focusGained(FocusEvent e) {
 594  0
     }
 595  
 
 596  
     /**
 597  
      * Makes sure that the fig is updated when the bboxField loses focus.
 598  
      *
 599  
      * {@inheritDoc}
 600  
      */
 601  
     public void focusLost(FocusEvent e) {
 602  0
         if (e.getSource() == bboxField) {
 603  0
             setTargetBBox();
 604  
         }
 605  0
     }
 606  
 
 607  
     /*
 608  
      * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
 609  
      */
 610  
     public void keyPressed(KeyEvent e) {
 611  
         // Empty implementation - we only care about keyTyped
 612  0
     }
 613  
 
 614  
     /*
 615  
      * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
 616  
      */
 617  
     public void keyReleased(KeyEvent e) {
 618  
         // Empty implementation - we only care about keyTyped
 619  0
     }
 620  
 
 621  
     /*
 622  
      * Tests if enter is pressed in the _bbodField so we need to set the target
 623  
      * bounds.
 624  
      *
 625  
      * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
 626  
      */
 627  
     public void keyTyped(KeyEvent e) {
 628  0
         if (e.getSource().equals(bboxField) && e.getKeyChar() == '\n') {
 629  0
             setTargetBBox();
 630  
         }
 631  0
     }
 632  
 
 633  
     /**
 634  
      * @return Returns the _bboxLabel.
 635  
      */
 636  
     protected JLabel getBBoxLabel() {
 637  0
         return bboxLabel;
 638  
     }
 639  
 
 640  
     /**
 641  
      * @return Returns the _bboxField.
 642  
      */
 643  
     protected JTextField getBBoxField() {
 644  0
         return bboxField;
 645  
     }
 646  
 
 647  
     /**
 648  
      * @return Returns the _fillLabel.
 649  
      */
 650  
     protected JLabel getFillLabel() {
 651  0
         return fillLabel;
 652  
     }
 653  
 
 654  
     /**
 655  
      * @return Returns the _fillField.
 656  
      */
 657  
     protected JComboBox getFillField() {
 658  0
         return fillField;
 659  
     }
 660  
 
 661  
     /**
 662  
      * @return Returns the _lineLabel.
 663  
      */
 664  
     protected JLabel getLineLabel() {
 665  0
         return lineLabel;
 666  
     }
 667  
 
 668  
     /**
 669  
      * @return Returns the _lineField.
 670  
      */
 671  
     protected JComboBox getLineField() {
 672  0
         return lineField;
 673  
     }
 674  
 
 675  
     /**
 676  
      * @return Returns the _spacer.
 677  
      */
 678  
     protected SpacerPanel getSpacer() {
 679  0
         return spacer;
 680  
     }
 681  
 
 682  
     /**
 683  
      * @return Returns the _spacer2.
 684  
      */
 685  
     protected SpacerPanel getSpacer2() {
 686  0
         return spacer2;
 687  
     }
 688  
 
 689  
     /**
 690  
      * @return Returns the _spacer3.
 691  
      */
 692  
     protected SpacerPanel getSpacer3() {
 693  0
         return spacer3;
 694  
     }
 695  
 
 696  
     /**
 697  
      * The UID.
 698  
      */
 699  
     private static final long serialVersionUID = -6232843473753751128L;
 700  
 
 701  
     /**
 702  
      * @return returns the translated name of the "Custom..." item.
 703  
      */
 704  
     protected static String getCustomItemName() {
 705  0
         return CUSTOM_ITEM;
 706  
     }
 707  
 }