[Nextobjects-devel] nextobjects/nextobjects/src/org/devaki/nextobjects/workspace/models/graphics Mod
Status: Alpha
Brought to you by:
eflorent
From: <efl...@us...> - 2003-06-08 09:31:02
|
Update of /cvsroot/nextobjects/nextobjects/nextobjects/src/org/devaki/nextobjects/workspace/models/graphics In directory sc8-pr-cvs1:/tmp/cvs-serv29347/src/org/devaki/nextobjects/workspace/models/graphics Added Files: ModelTitleView.java Log Message: Added ability to have labels, model titles ... --- NEW FILE: ModelTitleView.java --- /* nextobjects Copyright (C) 2001-2005 Emmanuel Florent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.devaki.nextobjects.workspace.models.graphics; import java.awt.Graphics; import java.awt.Point; import java.awt.Font; import javax.swing.UIManager; import org.devaki.nextobjects.constants.CstGraphics; import org.devaki.nextobjects.workspace.models.objects.ModelTitle; /** * This class is responsible for drawing a "cartouche" * around the graphic. * * @author eflorent *@todo add date to model * */ public class ModelTitleView extends ClassView { /** * Constructor * @param pLabel a dummy label who give a context */ public ModelTitleView(ModelTitle pObject) { super(pObject); Point p = new Point(5010, 2510); this.setLocation(p); this.setSize(CstGraphics.DEFAULT_MODELTITLE_SIZE); oldRectangle.setSize(rectangle.getSize()); oldRectangle.setLocation(rectangle.getLocation()); } /** * Paint the "cartouche" * @param g the graphic context */ public void paint(Graphics g) { /* * final : * ________ * I_________| * I____|__ __| * * 1/_______ * I | * I________| */ g.setColor(CstGraphics.MODEL_BACKGROUND_COLOR); g.fillRect(0, 0, this.getSize().width , this.getSize().height); g.setColor(CstGraphics.DEFAULT_MODELTITLE_COLOR); g.drawRect(0, 0, this.getSize().width -1 , this.getSize().height -1); /* * 2/_ _ _ _ _ * I____. | * I____|_ _ _| * */ g.drawRect( 0, (this.getMiddlePoint().y - this.getLocation().y), this.getSize().width / 2, this.getSize().height / 2); /* * 3/ _ _ _ * I . ____| * I_ _ |__ __| * */ g.drawRect( (this.getMiddlePoint().x - this.getLocation().x) , (this.getMiddlePoint().y - this.getLocation().y) , this.getSize().width / 2, this.getSize().height / 2); printText(g); } /** * Draw the texts * @param g the graphic context */ public void printText(Graphics g) { this.metriques = g.getFontMetrics(g.getFont()); g.setFont( new Font( ((Font) UIManager.get("Label.font")).getName(), Font.PLAIN, ((Font) UIManager.get("Label.font")).getSize())); g.drawString(this.myObject.getMyModel().getName(), 4, 15); //g.drawString(myModel.getProjectURL(),4,15 + this.getSize().height / 2); g.drawString( this.myObject.getMyModel().getAuthor(), 4 + this.getSize().width / 2, 15 + this.getSize().height / 2); } } |