001: // The UMLet source code is distributed under the terms of the GPL; see license.txt
002: package com.umlet.element.base;
003:
004: import java.awt.*;
005: import java.util.*;
006:
007: import com.umlet.control.*;
008:
009: /**
010: * <p>Title: </p>
011: * <p>Description: </p>
012: * <p>Copyright: Copyright (c) 2001</p>
013: * <p>Company: </p>
014: * @author unascribed
015: * @version 1.0
016: */
017: // G. Wirrer start
018: public class UseCase extends Entity {
019: public Entity CloneFromMe() {
020: UseCase c = new UseCase();
021: c.setState(this .getPanelAttributes());
022: //c.setVisible(true);
023: c.setBounds(this .getBounds());
024: return c;
025: }
026:
027: public UseCase(String s) {
028: super (s);
029: }
030:
031: public UseCase() {
032: super ();
033: }
034:
035: private Vector<String> getStringVector() {
036: Vector<String> ret = Constants.decomposeStrings(this
037: .getPanelAttributes(), "\n");
038: return ret;
039: }
040:
041: public void paint(Graphics g) {
042: int a = (getWidth() - 1) / 2;
043: int b = (getHeight() - 1) / 2;
044: boolean found = false;
045: int x = ((getWidth() - 1) / 9 * 4);
046: int y = (int) Math.round((Math.sqrt(((a * a * b * b) - (b * b
047: * x * x))
048: / (a * a))));
049: int yPos = 0;
050: int yPos1 = b;
051: Graphics2D g2 = (Graphics2D) g;
052: g2.setFont(Constants.getFont());
053: Composite[] composites = colorize(g2); //enable colors
054: g2.setColor(_activeColor);
055:
056: Constants.getFRC(g2);
057:
058: g2.setComposite(composites[1]);
059: g2.setColor(_fillColor);
060: g2.fillOval(0, 0, 2 * a, 2 * b);
061: g2.setComposite(composites[0]);
062: if (_selected)
063: g2.setColor(_activeColor);
064: else
065: g2.setColor(_deselectedColor);
066:
067: Vector<String> tmp = new Vector<String>(getStringVector());
068: if (tmp.contains("lt=.")) {
069: tmp.remove("lt=.");
070: g2.setStroke(Constants.getStroke(1, 1));
071: }
072: g2.drawOval(0, 0, 2 * a, 2 * b);
073:
074: if (tmp.contains("--")) {
075: yPos = ((b - y) / 2);
076: g2.drawLine(a - x, b - y, a + x, b - y);
077: found = true;
078: } else {
079: yPos = this .getHeight()
080: / 2
081: - tmp.size()
082: * (Constants.getFontsize() + Constants
083: .getDistTextToText()) / 2;
084: }
085:
086: for (int i = 0; i < tmp.size(); i++) {
087: String s = tmp.elementAt(i);
088: if ((s.equals("--")) && found) {
089: yPos = yPos1;
090: } else if (found) {
091: Constants.write(g2, s, a, yPos + 5, true);
092: yPos += 5 * Constants.getDistTextToText();
093:
094: } else {
095: yPos += Constants.getFontsize();
096: Constants.write(g2, s, (int) this .getWidth() / 2, yPos,
097: true);
098: yPos += Constants.getDistTextToText();
099: }
100: }
101: // g2.drawOval(0,0,2*a,2*b);
102:
103: }
104: }
105: // G. Wirrer end
|