[Nextobjects-devel] nextobjects/nextobjects/src/org/devaki/nextobjects/workspace/models/graphics Lab
Status: Alpha
Brought to you by:
eflorent
From: <efl...@us...> - 2003-06-08 09:28:31
|
Update of /cvsroot/nextobjects/nextobjects/nextobjects/src/org/devaki/nextobjects/workspace/models/graphics In directory sc8-pr-cvs1:/tmp/cvs-serv28289/src/org/devaki/nextobjects/workspace/models/graphics Modified Files: AssociationView.java BaseModelView.java ClassView.java ConceptualView.java EntityView.java ObjectView.java PhysicalView.java TableView.java Added Files: LabelView.java Log Message: First step in adding ability to have mabels and model's titles + checkstyle --- NEW FILE: LabelView.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.Font; import java.awt.Dimension; import java.util.StringTokenizer; import java.awt.FontMetrics; import java.awt.Color; import javax.swing.UIManager; import org.devaki.nextobjects.constants.CstGraphics; import org.devaki.nextobjects.workspace.models.objects.BaseObject; /** * The labels view are like postits * @author eflorent */ public class LabelView extends ClassView { /** * construct a LabelView * @param pObject the base label */ public LabelView(BaseObject pObject) { super(pObject); this.setSize(CstGraphics.DEFAULT_LABEL_SIZE); oldRectangle.setSize(this.getSize()); oldRectangle.setLocation(this.getLocation()); } /** * Paint the "cartouche" * @param g the graphic context */ public void paint(Graphics g) { /* * final : * ___ * /| | * I____| * */ g.setColor(Color.YELLOW); g.fillRect(0, 0, this.getSize().width, this.getSize().height); // g.setColor(CstGraphics.DEFAULT_LABEL_COLOR); g.setColor(Color.BLACK); g.drawRect(0, 0, this.getSize().width - 1, this.getSize().height - 1); g.drawRect(0, 0, 15, 15); g.setColor(CstGraphics.MODEL_BACKGROUND_COLOR); g.fillRect(0, 0, 15, 15); g.setColor(Color.BLACK); g.drawLine(0, 15, 15, 0); printText(g); } /** * Draw the texts * @param g the graphic context */ public void printText(Graphics g) { g.setColor(Color.BLACK); this.metriques = g.getFontMetrics(g.getFont()); g.setFont( new Font( ((Font) UIManager.get("Label.font")).getName(), Font.BOLD, ((Font) UIManager.get("Label.font")).getSize())); int line = 1; int linewidth = 0; int margin = 5; //add an empty space for postit(c) corner. StringBuffer sb = new StringBuffer(" "); FontMetrics fm = g.getFontMetrics(); StringTokenizer st = new StringTokenizer(myObject.getName()); while (st.hasMoreTokens()) { String nextword = st.nextToken(); if (fm.stringWidth(sb.toString() + nextword) + margin < this.getSize().width) { sb.append(nextword); sb.append(' '); } else if (sb.length() == 0) { g.drawString(nextword, margin, line * fm.getHeight()); line++; } else { g.drawString(sb.toString(), margin, line * fm.getHeight()); sb = new StringBuffer(nextword + " "); line++; } } if (sb.length() > 0) { g.drawString(sb.toString(), margin, line * fm.getHeight()); line++; } sb.delete(0, sb.length()); st = new StringTokenizer(myObject.getDescription()); g.setFont( new Font( ((Font) UIManager.get("Label.font")).getName(), Font.PLAIN, ((Font) UIManager.get("Label.font")).getSize())); while (st.hasMoreTokens()) { String nextword = st.nextToken(); if (fm.stringWidth(sb.toString() + nextword) + margin < this.getSize().width) { sb.append(nextword); sb.append(' '); } else if (sb.length() == 0) { g.drawString(nextword, margin, line * fm.getHeight()); line++; } else { g.drawString(sb.toString(), margin, line * fm.getHeight()); sb = new StringBuffer(nextword + " "); line++; } } if (sb.length() > 0) { g.drawString(sb.toString(), margin, line * fm.getHeight()); line++; } } public Dimension autoResize(boolean actIt) { //TODO implement label autoresize. return new Dimension(0, 0); } } Index: AssociationView.java =================================================================== RCS file: /cvsroot/nextobjects/nextobjects/nextobjects/src/org/devaki/nextobjects/workspace/models/graphics/AssociationView.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AssociationView.java 31 May 2003 11:48:34 -0000 1.4 --- AssociationView.java 8 Jun 2003 09:28:26 -0000 1.5 *************** *** 85,89 **** 15, 15); ! this.printText(g2,0,0); } --- 85,89 ---- 15, 15); ! this.printColumns(g2,0,0); } Index: BaseModelView.java =================================================================== RCS file: /cvsroot/nextobjects/nextobjects/nextobjects/src/org/devaki/nextobjects/workspace/models/graphics/BaseModelView.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BaseModelView.java 4 Jun 2003 19:29:42 -0000 1.1 --- BaseModelView.java 8 Jun 2003 09:28:26 -0000 1.2 *************** *** 1,3 **** ! /* nextobjects Copyright (C) 2001-2005 Emmanuel Florent --- 1,3 ---- ! /* nextobjects Copyright (C) 2001-2005 Emmanuel Florent *************** *** 19,52 **** */ package org.devaki.nextobjects.workspace.models.graphics; import java.io.Serializable; import java.awt.BorderLayout; - import java.awt.Dimension; - import java.awt.Graphics; import java.awt.Graphics2D; - import java.awt.Point; - import java.awt.Rectangle; import java.awt.image.BufferedImage; - import javax.swing.event.ChangeListener; import javax.swing.event.ChangeEvent; import javax.swing.JPanel; import javax.swing.JScrollPane; - import org.devaki.nextobjects.constants.CstGraphics; - import org.devaki.nextobjects.util.ModelMan; - - import org.devaki.nextobjects.workspace.models.BaseModel; import org.devaki.nextobjects.workspace.models.objects.BaseObject; import org.devaki.nextobjects.workspace.models.objects.BaseClass; import java.awt.Image; public abstract class BaseModelView extends JPanel implements Serializable { /** --- 19,55 ---- */ package org.devaki.nextobjects.workspace.models.graphics; + import java.io.Serializable; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Point; import java.awt.Rectangle; import java.awt.image.BufferedImage; import javax.swing.event.ChangeListener; import javax.swing.event.ChangeEvent; import javax.swing.JPanel; import javax.swing.JScrollPane; import org.devaki.nextobjects.constants.CstGraphics; import org.devaki.nextobjects.util.ModelMan; import org.devaki.nextobjects.workspace.models.BaseModel; import org.devaki.nextobjects.workspace.models.objects.BaseObject; import org.devaki.nextobjects.workspace.models.objects.BaseClass; + import org.devaki.nextobjects.workspace.models.objects.ModelTitle; + import java.awt.Image; + /** + * The base for all models + * @author efl...@de... + * + */ public abstract class BaseModelView extends JPanel implements Serializable { + /** + * The "cartouche" + */ + private ModelTitleView modelTitleView; /** *************** *** 110,118 **** transient protected BufferedImage bi = null; ! public BaseModelView(BaseModel pMerise) { /** Initialization **/ ! super(true); // is double buffered! ! myModel = pMerise; this.setVisible(true); --- 113,131 ---- transient protected BufferedImage bi = null; ! /** ! * constructor ! * @param pModel the model ! */ ! public BaseModelView(BaseModel pModel) { /** Initialization **/ ! super(false); // is double buffered! ! myModel = pModel; ! ! ModelTitle modelTitle = new ModelTitle(myModel); ! modelTitle.getObjectView().setLocation(CstGraphics.MODEL_INITIAL_POSITION); ! modelTitle.getObjectView().setSize(CstGraphics.DEFAULT_MODELTITLE_SIZE); ! pModel.getLabels().addElement(modelTitle.getObjectView()); ! this.setVisible(true); *************** *** 138,142 **** Graphics2D bi2g; ! BaseObject[] tmp = getMyModel().getModelObjects(); Rectangle rect; --- 151,155 ---- Graphics2D bi2g; ! ObjectView[] tmp = getVisibleObjectView(); Rectangle rect; *************** *** 157,166 **** { // Clears the rectangle that was previously drawn. ! Dimension d = tmp[k].getObjectView().getSize(); ! Point l = tmp[k].getObjectView().getLocation(); ! if (tmp[k].getObjectView() instanceof LineView) { ! tmp[k].getObjectView().paint(big); } else { // classview ?! --- 170,179 ---- { // Clears the rectangle that was previously drawn. ! Dimension d = tmp[k].getSize(); ! Point l = tmp[k].getLocation(); ! if (tmp[k] instanceof LineView) { ! tmp[k].paint(big); } else { // classview ?! *************** *** 172,176 **** d.height); bi2g = bi2.createGraphics(); ! tmp[k].getObjectView().paint(bi2g); big.drawImage( bi2, --- 185,189 ---- d.height); bi2g = bi2.createGraphics(); ! tmp[k].paint(bi2g); big.drawImage( bi2, *************** *** 180,184 **** --- 193,212 ---- } } + } + /* + bi2 = + (BufferedImage) drawingArea.createImage( + modelTitleView.getSize().width, + modelTitleView.getSize().height); + bi2g = bi2.createGraphics(); + modelTitleView.paint(bi2g); + + big.drawImage( + bi2, + modelTitleView.getLocation().x - getRectangle().x, + modelTitleView.getLocation().y - getRectangle().y, + this); + */ return bi; } *************** *** 279,283 **** --- 307,319 ---- CstGraphics.MODEL_INITIAL_POSITION); } + + + /** + * get the visible objects + * @return the object views + */ + public abstract ObjectView[] getVisibleObjectView(); + /** * Return a cached rectangle/bounds for the model *************** *** 338,341 **** --- 374,395 ---- ymax = ytmpmax; } + for (int i = 0; i < myModel.getLabels().size(); i++) + { + ObjectView baseObject = + (ObjectView) myModel.getLabels().elementAt(i); + xtmpmin = (int) baseObject.getLocation().getX(); + ytmpmin = (int) baseObject.getLocation().getY(); + + xtmpmax = baseObject.getLocation().x + baseObject.getSize().width; + ytmpmax = baseObject.getLocation().y + baseObject.getSize().height; + if (xtmpmin < xmin) + xmin = xtmpmin; + if (ytmpmin < ymin) + ymin = ytmpmin; + if (xtmpmax > xmax) + xmax = xtmpmax; + if (ytmpmax > ymax) + ymax = ytmpmax; + } rectangle = new Rectangle( *************** *** 348,352 **** /** ! * @return */ public BaseModel getMyModel() --- 402,407 ---- /** ! * get the model ! * @return the model */ public BaseModel getMyModel() *************** *** 356,360 **** /** ! * @param model */ public void setMyModel(BaseModel model) --- 411,416 ---- /** ! * set the model ! * @param model the model */ public void setMyModel(BaseModel model) *************** *** 371,375 **** jScrollPane.getViewport().setViewSize(d); } ! /** * return the view size --- 427,431 ---- jScrollPane.getViewport().setViewSize(d); } ! /** * return the view size *************** *** 389,393 **** fullRefresh = b; } ! /** * Location of the view position --- 445,449 ---- fullRefresh = b; } ! /** * Location of the view position *************** *** 398,400 **** --- 454,465 ---- return jScrollPane.getViewport().getViewPosition(); } + /** + * get the model title view + * @return the model "cartouche" + */ + public ModelTitleView getModelTitleView() + { + return modelTitleView; + } + } Index: ClassView.java =================================================================== RCS file: /cvsroot/nextobjects/nextobjects/nextobjects/src/org/devaki/nextobjects/workspace/models/graphics/ClassView.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ClassView.java 2 Jun 2003 20:03:46 -0000 1.10 --- ClassView.java 8 Jun 2003 09:28:26 -0000 1.11 *************** *** 67,71 **** selectionPoints[i] = new SelectionPoint(0, 0); } ! } --- 67,82 ---- selectionPoints[i] = new SelectionPoint(0, 0); } ! } ! /** ! * Construct a new <code>ObjectView</code> object ! */ ! public ClassView() ! { ! super(); ! selectionPoints = new SelectionPoint[8]; ! for (int i = 0; i < 8; i++) ! { ! selectionPoints[i] = new SelectionPoint(0, 0); ! } } *************** *** 109,116 **** return this.oldRectangle; } ! /** ! * get the location ! * @return the location ! */ public Point getLocation() { --- 120,127 ---- return this.oldRectangle; } ! /** ! * get the location ! * @return the location ! */ public Point getLocation() { *************** *** 128,135 **** resetSelectionPoint(); } ! /** ! * get the size ! * @return the dimension ! */ public Dimension getSize() { --- 139,147 ---- resetSelectionPoint(); } ! ! /** ! * get the size ! * @return the dimension ! */ public Dimension getSize() { *************** *** 258,265 **** * Paint the text common in all ClassViews * @param g2 the graphics g ! * @param x offset X ! * @param y offset y */ ! public void printText(Graphics2D g2, int x, int y) { this.metriques = g2.getFontMetrics(g2.getFont()); --- 270,277 ---- * Paint the text common in all ClassViews * @param g2 the graphics g ! * @param x optional offset X ! * @param y optional offset y */ ! public void printColumns(Graphics2D g2, int x, int y) { this.metriques = g2.getFontMetrics(g2.getFont()); Index: ConceptualView.java =================================================================== RCS file: /cvsroot/nextobjects/nextobjects/nextobjects/src/org/devaki/nextobjects/workspace/models/graphics/ConceptualView.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ConceptualView.java 4 Jun 2003 19:29:42 -0000 1.22 --- ConceptualView.java 8 Jun 2003 09:28:27 -0000 1.23 *************** *** 23,27 **** import java.awt.Cursor; import java.awt.Dimension; ! import java.awt.Graphics2D; import java.awt.Color; import java.awt.Point; --- 23,27 ---- import java.awt.Cursor; import java.awt.Dimension; ! import java.awt.Graphics2D; import java.awt.Color; import java.awt.Point; *************** *** 46,50 **** import org.devaki.nextobjects.workspace.models.objects.InheritanceLink; - /** * This class is responsible for drawing a ConceptualModel</code> --- 46,49 ---- *************** *** 53,57 **** public class ConceptualView extends BaseModelView implements Serializable { ! /** * Construct a new <code>ConceptualView</code> object --- 52,56 ---- public class ConceptualView extends BaseModelView implements Serializable { ! /** * Construct a new <code>ConceptualView</code> object *************** *** 61,64 **** --- 60,64 ---- { super(pMerise); + /* Listeners **/ // Mouse Listeners *************** *** 67,70 **** --- 67,132 ---- } + /** + * calculate the visible objects + * @return object views + */ + public ObjectView[] getVisibleObjectView() + { + ObjectView[] b = + new ObjectView[((ConceptualModel) myModel) + .getInheritanceLinks() + .size() + + ((ConceptualModel) myModel).getAssociationLinks().size() + + ((ConceptualModel) myModel).getEntities().size() + + ((ConceptualModel) myModel).getAssociations().size() + + ((ConceptualModel) myModel).getLabels().size()]; + int offset = 0; + for (int i = 0; + i < ((ConceptualModel) myModel).getAssociationLinks().size(); + i++) + { + b[offset] = + ((ConceptualModel) myModel) + .getAssociationLinkAt(i) + .getObjectView(); + offset++; + } + for (int i = 0; + i < ((ConceptualModel) myModel).getInheritanceLinks().size(); + i++) + { + b[offset] = + ((ConceptualModel) myModel) + .getInheritanceLinkAt(i) + .getObjectView(); + offset++; + } + for (int i = 0; + i < ((ConceptualModel) myModel).getAssociations().size(); + i++) + { + b[offset] = + ((ConceptualModel) myModel).getAssociationAt(i).getObjectView(); + offset++; + } + for (int i = 0; + i < ((ConceptualModel) myModel).getEntities().size(); + i++) + { + b[offset] = + ((ConceptualModel) myModel).getEntityAt(i).getObjectView(); + offset++; + } + for (int i = 0; + i < ((ConceptualModel) myModel).getLabels().size(); + i++) + { + b[offset] = + (ObjectView) ((ConceptualModel) myModel).getLabels().elementAt(i); + + offset++; + } + return b; + } /** *************** *** 100,104 **** // Add the new association to the model Association newAssociation = ! ModelMan.addAssociation((ConceptualModel)this.myModel, tmpPoint); // Add links between the new association and the entities --- 162,168 ---- // Add the new association to the model Association newAssociation = ! ModelMan.addAssociation( ! (ConceptualModel) this.myModel, ! tmpPoint); // Add links between the new association and the entities *************** *** 187,204 **** && (NOToolBar2.getCurrentTool() != NOToolBar2.TOOL_ASSOCIATION)) { ! BaseObject[] tmp = myModel.getModelObjects(); ! // Loop for the association links and inheritance links. for (int j = 0; j < tmp.length; j++) { ! if (((Polygon) tmp[j].getObjectView().getSurface()) ! .contains(x1, y1)) { // Define the cuurent objects association link as the current object if (e.isControlDown()) { ! ModelMan.addCurrentObject(tmp[j]); } else { ! ModelMan.setCurrentObject(tmp[j]); } // only for association & entity ... --- 251,267 ---- && (NOToolBar2.getCurrentTool() != NOToolBar2.TOOL_ASSOCIATION)) { ! ObjectView[] tmp = getVisibleObjectView(); ! // Loop for visible objects for (int j = 0; j < tmp.length; j++) { ! if (((Polygon) tmp[j].getSurface()).contains(x1, y1)) { // Define the cuurent objects association link as the current object if (e.isControlDown()) { ! ModelMan.addCurrentObject(tmp[j].myObject); } else { ! ModelMan.setCurrentObject(tmp[j].myObject); } // only for association & entity ... *************** *** 240,244 **** case NOToolBar2.TOOL_TABLE : { ! ModelMan.addEntity((ConceptualModel)myModel, e.getPoint()); //record old location ModelMan.moveCurrentObject(0, 0); --- 303,317 ---- case NOToolBar2.TOOL_TABLE : { ! ModelMan.addEntity( ! (ConceptualModel) myModel, ! e.getPoint()); ! //record old location ! ModelMan.moveCurrentObject(0, 0); ! break; ! } ! // TOOL_TABLE selected ! case NOToolBar2.TOOL_LABEL : ! { ! ModelMan.addLabel(myModel, e.getPoint()); //record old location ModelMan.moveCurrentObject(0, 0); *************** *** 248,252 **** case NOToolBar2.TOOL_ASSOCIATION : { ! ModelMan.addAssociation((ConceptualModel)myModel, e.getPoint()); break; } --- 321,327 ---- case NOToolBar2.TOOL_ASSOCIATION : { ! ModelMan.addAssociation( ! (ConceptualModel) myModel, ! e.getPoint()); break; } *************** *** 589,595 **** // Loop for the entities to find the targeted object ! for (int i = 0; i < ((ConceptualModel)myModel).countEntities(); i++) { ! if (((Polygon) ((ConceptualModel)myModel) .getEntityAt(i) .getObjectView() --- 664,672 ---- // Loop for the entities to find the targeted object ! for (int i = 0; ! i < ((ConceptualModel) myModel).countEntities(); ! i++) { ! if (((Polygon) ((ConceptualModel) myModel) .getEntityAt(i) .getObjectView() *************** *** 608,615 **** .getDraggedObject() .equals( ! (BaseObject)((ConceptualModel) myModel).getEntityAt(i))) { ModelMan.setDropTargetObject( ! (BaseObject) ((ConceptualModel)myModel).getEntityAt(i)); targetNotFound = false; break; --- 685,702 ---- .getDraggedObject() .equals( ! (BaseObject) ! ( ! ( ! ConceptualModel) myModel) ! .getEntityAt( ! i))) { ModelMan.setDropTargetObject( ! (BaseObject) ! ( ! ( ! ConceptualModel) myModel) ! .getEntityAt( ! i)); targetNotFound = false; break; *************** *** 622,636 **** { for (int i = 0; ! i < (((ConceptualModel))myModel).countAssociation(); i++) { ! if (((ConceptualModel)myModel) .getAssociationAt(i) .getObjectView() .getSurface() .contains( ! x2+ e.getComponent().getX() + getViewPosition().x, ! y2+e.getComponent().getY()+getViewPosition().y)) { // Verify that the targeted object is not equal to the dragged --- 709,728 ---- { for (int i = 0; ! i ! < ((ConceptualModel) myModel) ! .countAssociation(); i++) { ! if (((ConceptualModel) myModel) .getAssociationAt(i) .getObjectView() .getSurface() .contains( ! x2 ! + e.getComponent().getX() + getViewPosition().x, ! y2 ! + e.getComponent().getY() ! + getViewPosition().y)) { // Verify that the targeted object is not equal to the dragged *************** *** 639,650 **** .getDraggedObject() .equals( ! ( ! BaseObject) ((ConceptualModel) myModel) ! .getAssociationAt( i))) { ModelMan.setDropTargetObject( ! (BaseObject) ((ConceptualModel)myModel) ! .getAssociationAt( i)); break; --- 731,747 ---- .getDraggedObject() .equals( ! (BaseObject) ! ( ! ( ! ConceptualModel) myModel) ! .getAssociationAt( i))) { ModelMan.setDropTargetObject( ! (BaseObject) ! ( ! ( ! ConceptualModel) myModel) ! .getAssociationAt( i)); break; Index: EntityView.java =================================================================== RCS file: /cvsroot/nextobjects/nextobjects/nextobjects/src/org/devaki/nextobjects/workspace/models/graphics/EntityView.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EntityView.java 31 May 2003 11:48:34 -0000 1.3 --- EntityView.java 8 Jun 2003 09:28:27 -0000 1.4 *************** *** 72,76 **** (int)rect.getSize().getHeight()-1); /** Name **/ ! this.printText(g2,0,0); } --- 72,76 ---- (int)rect.getSize().getHeight()-1); /** Name **/ ! this.printColumns(g2,0,0); } Index: ObjectView.java =================================================================== RCS file: /cvsroot/nextobjects/nextobjects/nextobjects/src/org/devaki/nextobjects/workspace/models/graphics/ObjectView.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ObjectView.java 31 May 2003 11:48:34 -0000 1.4 --- ObjectView.java 8 Jun 2003 09:28:27 -0000 1.5 *************** *** 51,55 **** this.myObject = pObject; } ! /** * Paint object --- 51,62 ---- this.myObject = pObject; } ! ! /** ! * Construct a new 'ObjectView' object ! */ ! public ObjectView() ! { ! this.myObject =null; ! } /** * Paint object *************** *** 104,112 **** * @return the location */ ! public Point getLocation() ! { ! return new Point(0, 0); ! } ! /** * Define the dimension --- 111,116 ---- * @return the location */ ! public abstract Point getLocation() ; ! /** * Define the dimension Index: PhysicalView.java =================================================================== RCS file: /cvsroot/nextobjects/nextobjects/nextobjects/src/org/devaki/nextobjects/workspace/models/graphics/PhysicalView.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** PhysicalView.java 4 Jun 2003 19:29:42 -0000 1.21 --- PhysicalView.java 8 Jun 2003 09:28:27 -0000 1.22 *************** *** 98,102 **** Graphics2D bi2g; ! BaseObject[] tmp = myModel.getModelObjects(); Rectangle rect; --- 98,102 ---- Graphics2D bi2g; ! ObjectView[] tmp = getVisibleObjectView(); Rectangle rect; *************** *** 115,124 **** { // Clears the rectangle that was previously drawn. ! Dimension d = tmp[k].getObjectView().getSize(); ! Point l = tmp[k].getObjectView().getLocation(); ! if (tmp[k].getObjectView() instanceof LineView) { ! tmp[k].getObjectView().paint(big); } else { // classview ?! --- 115,124 ---- { // Clears the rectangle that was previously drawn. ! Dimension d = tmp[k].getSize(); ! Point l = tmp[k].getLocation(); ! if (tmp[k] instanceof LineView) { ! tmp[k].paint(big); } else { // classview ?! *************** *** 127,131 **** bi2 =(BufferedImage)drawingArea.createImage(d.width,d.height); bi2g = bi2.createGraphics(); ! tmp[k].getObjectView().paint(bi2g); big.drawImage( bi2, --- 127,131 ---- bi2 =(BufferedImage)drawingArea.createImage(d.width,d.height); bi2g = bi2.createGraphics(); ! tmp[k].paint(bi2g); big.drawImage( bi2, *************** *** 379,387 **** && (NOToolBar2.getCurrentTool() != NOToolBar2.TOOL_ASSOCIATION)) { ! BaseObject[] tmp = myModel.getModelObjects(); // Loop for the association links and inheritance links. for (int j = 0; j < tmp.length; j++) { ! if (((Polygon) tmp[j].getObjectView().getSurface()) .contains(x1, y1)) { --- 379,387 ---- && (NOToolBar2.getCurrentTool() != NOToolBar2.TOOL_ASSOCIATION)) { ! ObjectView[] tmp = getVisibleObjectView(); // Loop for the association links and inheritance links. for (int j = 0; j < tmp.length; j++) { ! if (((Polygon) tmp[j].getSurface()) .contains(x1, y1)) { *************** *** 389,396 **** if (e.isControlDown()) { ! ModelMan.addCurrentObject(tmp[j]); } else { ! ModelMan.setCurrentObject(tmp[j]); } --- 389,396 ---- if (e.isControlDown()) { ! ModelMan.addCurrentObject(tmp[j].myObject); } else { ! ModelMan.setCurrentObject(tmp[j].myObject); } *************** *** 441,444 **** --- 441,449 ---- break; } + case NOToolBar2.TOOL_LABEL : + { + ModelMan.addLabel(myModel, e.getPoint()); + break; + } } if (ModelMan.getCurrentObject() == null && e.getClickCount() == 2) *************** *** 538,541 **** --- 543,547 ---- x2 = e.getX(); y2 = e.getY(); + // Define what to do according to the selected tool switch (NOToolBar2.getCurrentTool()) *************** *** 894,937 **** } /** ! * Calculate a cached model rectangle ! * @return the rectangle */ ! public Rectangle calculateRectangle() { ! int xmin = 1000000; ! int ymin = 1000000; ! int xmax = 0; ! int ymax = 0; ! int xtmpmin = 0; ! int ytmpmin = 0; ! int xtmpmax = 0; ! int ytmpmax = 0; ! for (int i = 0; i <myModel.getClasses().size(); i++) ! { ! BaseClass baseObject = (BaseClass) myModel.getClasses().elementAt(i); ! xtmpmin = (int) baseObject.getObjectView().getLocation().getX(); ! ytmpmin = (int) baseObject.getObjectView().getLocation().getY(); ! xtmpmax = ! baseObject.getObjectView().getLocation().x ! + baseObject.getObjectView().getSize().width; ! ytmpmax = ! baseObject.getObjectView().getLocation().y ! + baseObject.getObjectView().getSize().height; ! if (xtmpmin < xmin) ! xmin = xtmpmin; ! if (ytmpmin < ymin) ! ymin = ytmpmin; ! if (xtmpmax > xmax) ! xmax = xtmpmax; ! if (ytmpmax > ymax) ! ymax = ytmpmax; ! } ! rectangle = ! new Rectangle( ! Math.abs(xmin - 10), ! Math.abs(ymin - 10), ! xmax - xmin + 20, ! ymax - ymin + 20); ! return rectangle; } } --- 900,936 ---- } /** ! * Calculate the visibles objects ! * @return the objects views */ ! public ObjectView[] getVisibleObjectView() { ! ObjectView[] b = ! new ObjectView[((PhysicalModel)myModel).getInheritanceLinks().size() ! + ((PhysicalModel)myModel).getTables().size() ! + ((PhysicalModel)myModel).getConstraints().size() ! + ((PhysicalModel) myModel).getLabels().size()]; ! int offset = 0; ! ! for (int i = 0; i < ((PhysicalModel)myModel).getInheritanceLinks().size(); i++) { ! b[offset] = ((PhysicalModel)myModel).getInheritanceLinkAt(i).getObjectView();; ! offset++; ! } ! for (int i = 0; i < ((PhysicalModel)myModel).getConstraints().size(); i++) ! { ! b[offset] = ((PhysicalModel)myModel).getConstraintAt(i).getObjectView();; ! offset++; } + for (int i = 0; i < ((PhysicalModel)myModel).getTables().size(); i++) + { + b[offset] = ((PhysicalModel)myModel).getTableAt(i).getObjectView();; + offset++; + } + for (int i = 0;i < ((PhysicalModel) myModel).getLabels().size(); + i++) + { + b[offset] =(ObjectView) ((PhysicalModel) myModel).getLabels().elementAt(i); + offset++; + } + return b; + } } Index: TableView.java =================================================================== RCS file: /cvsroot/nextobjects/nextobjects/nextobjects/src/org/devaki/nextobjects/workspace/models/graphics/TableView.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TableView.java 31 May 2003 11:48:35 -0000 1.7 --- TableView.java 8 Jun 2003 09:28:27 -0000 1.8 *************** *** 87,91 **** (int) this.getSize().getHeight() - 1); /** Text **/ ! this.printText(g2, x, y); } --- 87,91 ---- (int) this.getSize().getHeight() - 1); /** Text **/ ! this.printColumns(g2, x, y); } |