|
What this is
Other links
The source code
// $Id: StylePanelFig.java,v 1.24 2004/09/21 19:03:28 mvw Exp $
// Copyright (c) 2003-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.ui;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Rectangle;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JColorChooser;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.text.Document;
import org.apache.log4j.Logger;
import org.argouml.i18n.Translator;
import org.argouml.kernel.Project;
import org.argouml.kernel.ProjectManager;
import org.argouml.uml.diagram.ui.FigEdgeModelElement;
import org.tigris.gef.ui.ColorRenderer;
/**
* The basic stylepanel which provides line and fill color information.
*
*/
public class StylePanelFig extends StylePanel implements ItemListener,
FocusListener, KeyListener {
private static final Logger LOG = Logger
.getLogger(StylePanelFigNodeModelElement.class);
private static final String CUSTOM_ITEM = Translator
.localize("label.stylepane.custom")
+ "...";
private JLabel bboxLabel = new JLabel(Translator
.localize("label.stylepane.bounds")
+ ": ");
private JTextField bboxField = new JTextField();
private JLabel fillLabel = new JLabel(Translator
.localize("label.stylepane.fill")
+ ": ");
private JComboBox fillField = new JComboBox();
private JLabel lineLabel = new JLabel(Translator
.localize("label.stylepane.line")
+ ": ");
private JComboBox lineField = new JComboBox();
private SpacerPanel spacer = new SpacerPanel();
private SpacerPanel spacer2 = new SpacerPanel();
private SpacerPanel spacer3 = new SpacerPanel();
/**
* The constructor of the style panel of a Fig.
*
* @param title the title string
*/
public StylePanelFig(String title) {
super(title);
}
/**
* The constructor.
*
*/
public StylePanelFig() {
super("Fig Appearance");
initChoices();
GridBagLayout gb = (GridBagLayout) getLayout();
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.ipadx = 0;
c.ipady = 0;
Document bboxDoc = bboxField.getDocument();
bboxDoc.addDocumentListener(this);
bboxField.addKeyListener(this);
bboxField.addFocusListener(this);
fillField.addItemListener(this);
lineField.addItemListener(this);
fillField.setRenderer(new ColorRenderer());
lineField.setRenderer(new ColorRenderer());
//_dashedField.setRenderer(DashRenderer.SINGLETON);
c.gridx = 0;
c.gridwidth = 1;
c.gridy = 1;
c.weightx = 0.0;
gb.setConstraints(bboxLabel, c);
add(bboxLabel);
c.gridy = 2;
gb.setConstraints(fillLabel, c);
add(fillLabel);
c.gridy = 3;
gb.setConstraints(lineLabel, c);
add(lineLabel);
c.gridy = 4;
c.weightx = 1.0;
c.gridx = 1;
//c.gridwidth = GridBagConstraints.REMAINDER;
c.gridy = 1;
gb.setConstraints(bboxField, c);
add(bboxField);
c.gridy = 2;
gb.setConstraints(fillField, c);
add(fillField);
c.gridy = 3;
gb.setConstraints(lineField, c);
add(lineField);
c.weightx = 0.0;
c.gridx = 2;
c.gridy = 1;
gb.setConstraints(spacer, c);
add(spacer);
c.gridx = 3;
c.gridy = 10;
gb.setConstraints(spacer2, c);
add(spacer2);
c.weightx = 1.0;
c.gridx = 4;
c.gridy = 10;
gb.setConstraints(spacer3, c);
add(spacer3);
}
/**
* Fill in the user-choices.
*/
protected void initChoices() {
fillField.addItem(Translator.localize("label.stylepane.no-fill"));
fillField.addItem(Color.black);
fillField.addItem(Color.white);
fillField.addItem(Color.gray);
fillField.addItem(Color.lightGray);
fillField.addItem(Color.darkGray);
fillField.addItem(new Color(255, 255, 200));
fillField.addItem(new Color(255, 200, 255));
fillField.addItem(new Color(200, 255, 255));
fillField.addItem(new Color(200, 200, 255));
fillField.addItem(new Color(200, 255, 200));
fillField.addItem(new Color(255, 200, 200));
fillField.addItem(new Color(200, 200, 200));
fillField.addItem(Color.red);
fillField.addItem(Color.blue);
fillField.addItem(Color.cyan);
fillField.addItem(Color.yellow);
fillField.addItem(Color.magenta);
fillField.addItem(Color.green);
fillField.addItem(Color.orange);
fillField.addItem(Color.pink);
fillField.addItem(CUSTOM_ITEM);
lineField.addItem(Translator.localize("label.stylepane.no-line"));
lineField.addItem(Color.black);
lineField.addItem(Color.white);
lineField.addItem(Color.gray);
lineField.addItem(Color.lightGray);
lineField.addItem(Color.darkGray);
lineField.addItem(new Color(60, 60, 200));
lineField.addItem(new Color(60, 200, 60));
lineField.addItem(new Color(200, 60, 60));
lineField.addItem(Color.red);
lineField.addItem(Color.blue);
lineField.addItem(Color.cyan);
lineField.addItem(Color.yellow);
lineField.addItem(Color.magenta);
lineField.addItem(Color.green);
lineField.addItem(Color.orange);
lineField.addItem(Color.pink);
lineField.addItem(CUSTOM_ITEM);
}
/**
* set whether this Fig has a editable boundingbox. This is done normally in
*
|
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 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.