diff options
author | rsrinivasan | 2010-04-29 19:35:59 +0000 |
---|---|---|
committer | rsrinivasan | 2010-04-29 19:35:59 +0000 |
commit | d47e455f4575e08a4f82fd1e2222e9b9dbb621b8 (patch) | |
tree | e89485e265eb8247ad619b6f4403d863edab1175 /jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure | |
parent | 3dfb5f2c0b5bdfd21643777a8a658b3f496d84c0 (diff) | |
download | webtools.jsf-d47e455f4575e08a4f82fd1e2222e9b9dbb621b8.tar.gz webtools.jsf-d47e455f4575e08a4f82fd1e2222e9b9dbb621b8.tar.xz webtools.jsf-d47e455f4575e08a4f82fd1e2222e9b9dbb621b8.zip |
This commit was manufactured by cvs2svn to create tag 'v20100429'.v20100429
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure')
5 files changed, 0 insertions, 920 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/ConnectionLabel.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/ConnectionLabel.java deleted file mode 100644 index 702e58e09..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/ConnectionLabel.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure; - -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.LineBorder; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Image; - -/** - * This label is used in connection figure, which has a border. - * - * @author Xiao-guang Zhang - * - */ -public class ConnectionLabel extends Label { - /** - * - */ - public ConnectionLabel() { - this(null, null); - } - - /** - * @param s - */ - public ConnectionLabel(String s) { - this(s, null); - } - - /** - * @param i - */ - public ConnectionLabel(Image i) { - this(null, i); - } - - /** - * @param s - * @param i - */ - public ConnectionLabel(String s, Image i) { - super(s, i); - - // setBorder(new LineBorder()); - setOpaque(true); - } - - /** - * set the label's border's width - * - * @param w - */ - public void setBorderWidth(int w) { - if (getBorder() != null) { - ((LineBorder) getBorder()).setWidth(w); - } - } - - /** - * set the label's border's color - * - * @param c - */ - public void setBorderColor(Color c) { - if (getBorder() != null) { - ((LineBorder) getBorder()).setColor(c); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/ILabelDecorator.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/ILabelDecorator.java deleted file mode 100644 index d1d01373a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/ILabelDecorator.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure; - -import org.eclipse.swt.graphics.Image; - -/** - * A label decorator decorates the label text and image for some element. The - * original label text and image are obtained by some other means, - * - * - * @author Xiao-guang Zhang - */ -public interface ILabelDecorator { - /** - * Returns an image that is based on the given image, but decorated with - * additional information relating to the state of the provided element. - * - * @param image - * the input image to decorate, or <code>null</code> if the - * element has no image - * @param element - * the element whose image is being decorated - * @return the decorated image, or <code>null</code> if no decoration is - * to be applied - * - * @see org.eclipse.jface.resource.CompositeImageDescriptor - */ - public Image decorateImage(Image image, Object element); - - /** - * Returns a text label that is based on the given text label, but decorated - * with additional information relating to the state of the provided - * element. - * - * - * @param text - * the input text label to decorate - * @param element - * the element whose image is being decorated - * @return the decorated text label, or <code>null</code> if no decoration - * is to be applied - */ - public String decorateText(String text, Object element); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/NodeLabel.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/NodeLabel.java deleted file mode 100644 index fa5764d82..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/NodeLabel.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure; - -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.swt.graphics.Image; - -/** - * This derived label has simple tooltip support - * - * @author Xiao-guang Zhang - * - */ -public class NodeLabel extends Label { - /** - * - */ - public NodeLabel() { - super(); - } - - /** - * @param s - */ - public NodeLabel(String s) { - super(s); - } - - /** - * @param i - */ - public NodeLabel(Image i) { - super(i); - } - - /** - * @param s - * @param i - */ - public NodeLabel(String s, Image i) { - super(s, i); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.Label#setTextPlacement(int) - */ - public void setTextPlacement(int where) { - super.setTextPlacement(where); - layout(); - invalidate(); - } - - /** - * set tooltip text - * - * @param text - */ - public void setToolTipText(String text) { - Label toolTipLabel = null; - - if (text != null && text.length() > 0) { - toolTipLabel = new Label(text); - toolTipLabel.setBorder(new MarginBorder(3)); - } - - super.setToolTip(toolTipLabel); - } - - /** - * get tooltip's text - * - * @return the tool tip text string - */ - public String getToolTipText() { - if (getToolTip() != null) - return ((Label) getToolTip()).getText(); - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PFLinkFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PFLinkFigure.java deleted file mode 100644 index f9ecd41e0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PFLinkFigure.java +++ /dev/null @@ -1,318 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure; - -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.draw2d.MidpointLocator; -import org.eclipse.draw2d.PolygonDecoration; -import org.eclipse.draw2d.PolylineConnection; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.jface.resource.FontRegistry; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowElementEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.preference.GEMPreferences; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Image; - -/** - * - * The figure for pflink, used by pflink edit part, which is a polyline with a - * label control on it, and with tooltip support. - * - * @author Xiao-guang Zhang - */ -public class PFLinkFigure extends PolylineConnection { - /** the label attached to the connection */ - private ConnectionLabel textLabel = null; - - //private ConnectionLabel iconLabel = null; - - /** The label's background color */ - private Color labelBgColor; - - /** The label's foreground color */ - private Color labelFgColor; - - /** The label's visiblity */ - private boolean bLabelVisible = false; - - /** The connection's line width */ - private int lineWidth = 0; - - /** the polygon decoration for connection line */ - private PolygonDecoration arrow; - - /** - * - */ - public PFLinkFigure() { - arrow = new PolygonDecoration(); - arrow.setTemplate(PolygonDecoration.TRIANGLE_TIP); - arrow.setScale(10, getLineWidth() * 2); - setTargetDecoration(arrow); - setForegroundColor(getForegroundColor()); - } - - /** - * set the connection's label string - * - * @param strLabel - */ - public void setLabel(String strLabel) { - if (null != strLabel) { - if (textLabel == null) { - textLabel = new ConnectionLabel(); - textLabel.setFont(getLabelFont()); - textLabel.setBackgroundColor(getLabelBackgroundColor()); - textLabel.setForegroundColor(getLabelForegroundColor()); - setLineWidth(getLineWidth()); - setLabelVisible(getLabelVisible()); - setForegroundColor(getForegroundColor()); - add(textLabel, new MidpointLocator(this, 1)); - } - // textLabel.setVisible(true); - textLabel.setText(strLabel); - } - } - - /** - * Set the icon image to null - */ - public void clearIcon() { - setImage(null); - } - - /** - * Set the label to empty string - */ - public void clearOutcome() { - setLabel(""); //$NON-NLS-1$ - } - - /** - * set the connection's label string - * - * @param image - */ - public void setImage(Image image) { - if (textLabel == null) { - textLabel = new ConnectionLabel(); - textLabel.setFont(getLabelFont()); - textLabel.setBackgroundColor(getLabelBackgroundColor()); - textLabel.setForegroundColor(getLabelForegroundColor()); - setLineWidth(getLineWidth()); - setLabelVisible(getLabelVisible()); - setForegroundColor(getForegroundColor()); - add(textLabel, new MidpointLocator(this, 0)); - } - textLabel.setIcon(image); - } - - /** - * Set the action image - */ - public void setActionImage() { - ImageDescriptor imageDescriptor = PageflowElementEditPart.IMG_ACTION; - Image image = EditorPlugin.getDefault().getImageRegistry().get( - imageDescriptor.toString()); - if (null == image) { - EditorPlugin.getDefault().getImageRegistry().put( - imageDescriptor.toString(), imageDescriptor); - image = EditorPlugin.getDefault().getImageRegistry().get( - imageDescriptor.toString()); - } - setImage(image); - } - - /** - * @return the icon image - */ - public Image getImage() { - if (textLabel != null) - { - return textLabel.getIcon(); - } - return null; - } - - - /** - * @param text - */ - public void setToolTipText(String text) { - Label toolTipLabel = null; - - if (text != null && text.length() > 0) { - toolTipLabel = new Label(text); - toolTipLabel.setBorder(new MarginBorder(3)); - } - - super.setToolTip(toolTipLabel); - } - - /** - * @return the tool tip text or null if none - */ - public String getToolTipText() { - if (getToolTip() != null) - { - return ((Label) getToolTip()).getText(); - } - return null; - } - - /** - * set the font including label's - * - */ - public void setFont(Font f) { - if (textLabel != null) - textLabel.setFont(f); - super.setFont(f); - } - - /** - * get the label's font from preference - * - */ - private Font getLabelFont() { - FontRegistry registry = JFaceResources.getFontRegistry(); - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - FontData fontData = PreferenceConverter.getFontData(store, - GEMPreferences.LINE_LABEL_FONT); - if (!registry.get(fontData.toString()).equals(registry.defaultFont())) - return registry.get(fontData.toString()); - - registry.put(fontData.toString(), new FontData[] {fontData}); - return registry.get(fontData.toString()); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.Shape#setLineWidth(int) - */ - public void setLineWidth(int w) { - if (textLabel != null) - textLabel.setBorderWidth(w); - arrow.setScale(10, getLineWidth() * 2); - super.setLineWidth(w); - } - - /** - * get the connection line width from preference. - */ - public int getLineWidth() { - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - lineWidth = store.getInt(GEMPreferences.LINE_WIDTH); - return lineWidth; - } - - /** - * set label's visibility - * - * @param flag - - * visible or not. - */ - public void setLabelVisible(boolean flag) { - if (textLabel != null) - textLabel.setVisible(flag); - } - - /** - * get the label's visiblity from preference - * - */ - private boolean getLabelVisible() { - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - bLabelVisible = store.getBoolean(GEMPreferences.SHOW_LINE_LABELS); - return bLabelVisible; - } - - /** - * set the label's foreground color - * - * @param c - */ - public void setLabelForegroundColor(Color c) { - labelFgColor = c; - if (textLabel != null) - textLabel.setForegroundColor(c); - } - - /** - * get the label's foreground color from preference - * - */ - private Color getLabelForegroundColor() { - if (labelFgColor == null) { - IPreferenceStore store = EditorPlugin.getDefault() - .getPreferenceStore(); - labelFgColor = GEMPreferences.getColor(store, - GEMPreferences.LINE_LABEL_FONT_COLOR); - } - return labelFgColor; - } - - /** - * set the label's background color - * - * @param c - */ - public void setLabelBackgroundColor(Color c) { - labelBgColor = c; - if (textLabel != null) - textLabel.setBackgroundColor(c); - } - - /** - * get the label's background color from preference - * - */ - private Color getLabelBackgroundColor() { - if (labelBgColor == null) { - IPreferenceStore store = EditorPlugin.getDefault() - .getPreferenceStore(); - labelBgColor = GEMPreferences.getColor(store, - GEMPreferences.LINE_LABEL_COLOR); - } - return labelBgColor; - } - - /** - * get the foreground color from preference - * - */ - public Color getForegroundColor() { - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - final Color newFgColor = GEMPreferences.getColor(store, GEMPreferences.LINE_COLOR); - setForegroundColor(newFgColor); - return newFgColor; - } - - /** - * set the figure's foreground, which will also update the label's border's - * color. - */ - public void setForegroundColor(Color c) { - if (textLabel != null) - textLabel.setBorderColor(c); - super.setForegroundColor(c); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PageflowNodeFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PageflowNodeFigure.java deleted file mode 100644 index 9a0827329..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PageflowNodeFigure.java +++ /dev/null @@ -1,376 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure; - -import java.util.Vector; - -import org.eclipse.draw2d.ChopboxAnchor; -import org.eclipse.draw2d.ConnectionAnchor; -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.FlowLayout; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.LabelAnchor; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.jface.resource.FontRegistry; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.preference.GEMPreferences; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Image; - -/** - * The figure for pageflow node, used by pageflow node edit part. - * - */ -public class PageflowNodeFigure extends Figure { - /** Same connection anchors for source and target */ - protected Vector connectionAnchors = new Vector(1); - - /** label of the pageflow node figure */ - private NodeLabel label; - - /** the foreground color of Label */ - private Color labelFgColor; - - /** the background color of Label */ -// private Color labelBgColor; // TODO: variable is never read because getter is private - - /** the text placement for the label */ - private int textPlacement = PositionConstants.SOUTH; - - /** - * Default constructor - */ - public PageflowNodeFigure() { - setLayoutManager(new FlowLayout()); - - // initializeConnectionAnchors(); - } - - /** - * get the source(output) anchor according to the input point. - * - * @param p - - * the input point - * @return - Source ConnectionAnchor - */ - public ConnectionAnchor getSourceConnectionAnchorAt(Point p) { - if (getSourceConnectionAnchors().size() == 0) - return null; - return (ConnectionAnchor) getSourceConnectionAnchors().get(0); - } - - /** - * get the default source anchor - * - * @return - Source ConnectionAnchor - */ - public ConnectionAnchor getSourceConnectionAnchor() { - if (getSourceConnectionAnchors().size() == 0) - return null; - return (ConnectionAnchor) getSourceConnectionAnchors().get(0); - } - - /** - * Get the source connection anchors vector - * - * @return - the vector - */ - private Vector getSourceConnectionAnchors() { - return connectionAnchors; - } - - /** - * get the target (input) connection Anchor according the input point - * - * @param p - - * the input Point - * @return - ConnectionAnchor - */ - public ConnectionAnchor getTargetConnectionAnchorAt(Point p) { - if (getTargetConnectionAnchors().size() == 0) - return null; - return (ConnectionAnchor) getTargetConnectionAnchors().get(0); - } - - /** - * get the default target (input) connection Anchor - * - * @return - ConnectionAnchor - */ - public ConnectionAnchor getTargetConnectionAnchor() { - if (getTargetConnectionAnchors().size() == 0) - return null; - return (ConnectionAnchor) getTargetConnectionAnchors().get(0); - } - - /** - * Get the target connection anchors vector - * - * @return - the vector - */ - private Vector getTargetConnectionAnchors() { - return connectionAnchors; - } - - /** - * update the anchors - * - */ - public void update() { - initializeConnectionAnchors(); - } - - /** - * Initialize the connection anchors - * - */ - private void initializeConnectionAnchors() { - connectionAnchors.removeAllElements(); - ChopboxAnchor inputConnectionAnchor = new LabelAnchor(label); - connectionAnchors.addElement(inputConnectionAnchor); - } - - /** - * get the text placement from preference. - * - */ - private int getTextPlacement() { - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - String s = store.getString(GEMPreferences.LABEL_PLACEMENT); - if (GEMPreferences.LABEL_PLACEMENT_TOP.equals(s)) - textPlacement = PositionConstants.NORTH; - else if (GEMPreferences.LABEL_PLACEMENT_BOTTOM.equals(s)) - textPlacement = PositionConstants.SOUTH; - else if (GEMPreferences.LABEL_PLACEMENT_LEFT.equals(s)) - textPlacement = PositionConstants.WEST; - else if (GEMPreferences.LABEL_PLACEMENT_RIGHT.equals(s)) - textPlacement = PositionConstants.EAST; - return textPlacement; - } - - /** - * get the label's background color from preference. - * - * @return - */ - // TODO: dead code -// private Color getLabelBackgroundColor() { -// return labelBgColor; -// } - - /** - * get the label's foreground color from preference. - * - * @return - */ - private Color getLabelForegroundColor() { - if (labelFgColor == null) { - IPreferenceStore store = EditorPlugin.getDefault() - .getPreferenceStore(); - labelFgColor = GEMPreferences.getColor(store, - GEMPreferences.FIGURE_LABEL_FONT_COLOR); - } - return labelFgColor; - } - - /** - * get the labe's font from preference. - * - * @return - */ - private Font getLabelFont() { - FontRegistry registry = JFaceResources.getFontRegistry(); - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - FontData fontData = PreferenceConverter.getFontData(store, - GEMPreferences.FIGURE_LABEL_FONT); - if (!registry.get(fontData.toString()).equals(registry.defaultFont())) - return registry.get(fontData.toString()); - - registry.put(fontData.toString(), new FontData[] {fontData}); - return registry.get(fontData.toString()); - } - - /** - * set the image and text of the figure - * - * @param image - - * the image - * @param str - - * the label - */ - public void setImageText(Image image, String str) { - if (image == null) - setText(str); - else if (str == null) - setImage(image); - else { - if (label == null) { - label = new NodeLabel(str, image); - label.setTextPlacement(getTextPlacement()); - label.setForegroundColor(getLabelForegroundColor()); - label.setFont(getLabelFont()); - add(label); - initializeConnectionAnchors(); - } else { - label.setIcon(image); - label.setText(str); - } - } - } - - /** - * set the image of the figure - * - * @param image - - * the image - */ - public void setImage(Image image) { - if (image == null) - return; - if (label == null) { - label = new NodeLabel(image); - label.setTextPlacement(getTextPlacement()); - label.setForegroundColor(getLabelForegroundColor()); - label.setFont(getLabelFont()); - add(label); - initializeConnectionAnchors(); - } else - label.setIcon(image); - } - - /** - * set the text of the figure - * - * @param str - - * the text - */ - public void setText(String str) { - if (str == null) - return; - if (label == null) { - label = new NodeLabel(str); - label.setTextPlacement(getTextPlacement()); - label.setForegroundColor(getLabelForegroundColor()); - label.setFont(getLabelFont()); - add(label); - initializeConnectionAnchors(); - } else - label.setText(str); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.Figure#useLocalCoordinates() - */ - protected boolean useLocalCoordinates() { - return true; - } - - /** - * Returns the imageBounds. - * - * @return - Rectangle of image - */ - public Rectangle getImageBounds() { - return label.getIconBounds(); - } - - /** - * Returns the textBounds. - * - * @return - Rectangle of text field - */ - public Rectangle getTextBounds() { - return label.getTextBounds(); - } - - /** - * Returns the label. - * - * @return - Label - */ - public Label getLabel() { - return label; - } - - /** - * set the label's backaground - */ - public void setBackgroundColor(Color bg) { -// TODO: var is never read: labelBgColor = bg; - if (label != null) - label.setBackgroundColor(bg); - } - - /** - * set the label's foreground - */ - public void setForegroundColor(Color fg) { - labelFgColor = fg; - - if (label != null) - label.setForegroundColor(fg); - } - - /** - * Set the label's font - */ - public void setFont(Font f) { - if (label != null) - label.setFont(f); - super.setFont(f); - } - - /** - * Set the text placement for the label - * - * @param where - */ - public void setTextPlacement(int where) { - textPlacement = where; - if (label != null) - label.setTextPlacement(where); - } - - - /** - * @param text - */ - public void setToolTipText(String text) { - Label toolTipLabel = null; - - if (text != null && text.length() > 0) { - toolTipLabel = new Label(text); - toolTipLabel.setBorder(new MarginBorder(3)); - } - - super.setToolTip(toolTipLabel); - } - /** - * @return the figure's tool tip text or null if none - */ - public String getToolTipText() { - if (getToolTip() != null) - return ((Label) getToolTip()).getText(); - return null; - } -} |