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:
018: public class Note extends Entity {
019: public Entity CloneFromMe() {
020: Note c = new Note();
021: c.setState(this .getPanelAttributes());
022: //c.setVisible(true);
023: c.setBounds(this .getBounds());
024: return c;
025: }
026:
027: public Note(String s) {
028: super (s);
029: }
030:
031: public Note() {
032: super ();
033: }
034:
035: private Vector getStringVector() {
036: Vector ret = Constants.decomposeStrings(this
037: .getPanelAttributes(), "\n");
038: return ret;
039: }
040:
041: public void paint(Graphics g) {
042: Graphics2D g2 = (Graphics2D) g;
043: g2.setFont(Constants.getFont());
044: //g2.setColor(_activeColor);
045: Constants.getFRC(g2);
046: Composite[] composites = colorize(g2); //enable colors
047: int yPos = 0;
048: yPos += Constants.getDistLineToText();
049:
050: Vector tmp = this .getStringVector();
051:
052: Polygon poly = new Polygon();
053: poly.addPoint(0, 0);
054: poly.addPoint(this .getWidth() - Constants.getFontsize(), 0);
055: poly.addPoint(this .getWidth() - Constants.getFontsize(), 0);
056: poly.addPoint(this .getWidth() - 1, Constants.getFontsize());
057: poly.addPoint(this .getWidth() - 1, Constants.getFontsize());
058: poly.addPoint(this .getWidth() - 1, this .getHeight() - 1);
059: poly.addPoint(this .getWidth() - 1, this .getHeight() - 1);
060: poly.addPoint(0, this .getHeight() - 1);
061: poly.addPoint(0, this .getHeight() - 1);
062: poly.addPoint(0, 0);
063: //p.addPoint(this.getWidth()-Constants.getFontsize(),0); p.addPoint(this.getWidth()-Constants.getFontsize(), Constants.getFontsize());
064: //p.addPoint(this.getWidth()-Constants.getFontsize(),Constants.getFontsize()); p.addPoint(this.getWidth()-1, Constants.getFontsize());
065:
066: g2.setComposite(composites[1]);
067: g2.setColor(_fillColor);
068: g2.fillPolygon(poly);
069: g2.setComposite(composites[0]);
070: if (_selected)
071: g2.setColor(_activeColor);
072: else
073: g2.setColor(_deselectedColor);
074:
075: for (int i = 0; i < tmp.size(); i++) {
076: String s = (String) tmp.elementAt(i);
077: yPos += Constants.getFontsize();
078: Constants.write(g2, s, Constants.getFontsize() / 2, yPos,
079: false);
080: yPos += Constants.getDistTextToText();
081: }
082:
083: g2.drawLine(0, 0, this .getWidth() - Constants.getFontsize(), 0);
084: g2.drawLine(this .getWidth() - Constants.getFontsize(), 0, this
085: .getWidth() - 1, Constants.getFontsize());
086: g2.drawLine(this .getWidth() - 1, Constants.getFontsize(), this
087: .getWidth() - 1, this .getHeight() - 1);
088: g2.drawLine(this .getWidth() - 1, this .getHeight() - 1, 0, this
089: .getHeight() - 1);
090: g2.drawLine(0, this .getHeight() - 1, 0, 0);
091: g2.drawLine(this .getWidth() - Constants.getFontsize(), 0, this
092: .getWidth()
093: - Constants.getFontsize(), Constants.getFontsize());
094: g2.drawLine(this .getWidth() - Constants.getFontsize(),
095: Constants.getFontsize(), this .getWidth() - 1, Constants
096: .getFontsize());
097:
098: /*Rectangle r=this.getBounds();
099: g.drawRect(0,0,(int)r.getWidth()-1,(int)r.getHeight()-1);
100: if (_selected) {
101: g.drawRect(1,1,(int)r.getWidth()-3,(int)r.getHeight()-3);
102: }*/
103: }
104: }
|