/** * @param fgVec the FigGroup * @param ft the FigText * @param i get the fig after fig i * @return the FigText */ protected FigText getNextVisibleFeature(FigGroup fgVec, FigText ft, int i) { if (fgVec == null || i < 1) { return null; } FigText ft2 = null; List v = fgVec.getFigs(); if (i >= v.size() || !((FigText) v.get(i)).isVisible()) { return null; } do { i++; while (i >= v.size()) { if (fgVec == getCompartment(Model.getMetaTypes().getAttribute())) { fgVec = getCompartment(Model.getMetaTypes().getOperation()); } else { fgVec = getCompartment(Model.getMetaTypes().getAttribute()); } v = new ArrayList(fgVec.getFigs()); i = 1; } ft2 = (FigText) v.get(i); if (!ft2.isVisible()) { ft2 = null; } } while (ft2 == null); return ft2; }
/** * @param fgVec the FigGroup * @param ft the Figtext * @param i get the fig before fig i * @return the FigText */ protected FigText getPreviousVisibleFeature(FigGroup fgVec, FigText ft, int i) { if (fgVec == null || i < 1) { return null; } FigText ft2 = null; List figs = fgVec.getFigs(); if (i >= figs.size() || !((FigText) figs.get(i)).isVisible()) { return null; } do { i--; while (i < 1) { if (fgVec == getCompartment(Model.getMetaTypes().getAttribute())) { fgVec = getCompartment(Model.getMetaTypes().getOperation()); } else { fgVec = getCompartment(Model.getMetaTypes().getAttribute()); } figs = fgVec.getFigs(); i = figs.size() - 1; } ft2 = (FigText) figs.get(i); if (!ft2.isVisible()) { ft2 = null; } } while (ft2 == null); return ft2; }
/** * @param fgVec the FigGroup * @param ft the Figtext * @param i get the fig after fig i * @return the FigText */ protected FigText getNextVisibleFeature(FigGroup fgVec, FigText ft, int i) { if (fgVec == null || i < 1) { return null; } FigText ft2 = null; // TODO: come GEF V 0.12 use getFigs returning an array Vector v = new Vector(fgVec.getFigs()); if (i >= v.size() || !((FigText) v.elementAt(i)).isVisible()) { return null; } do { i++; while (i >= v.size()) { if (fgVec == getAttributesFig()) { fgVec = getOperationsFig(); } else { fgVec = getAttributesFig(); } v = new Vector(fgVec.getFigs()); i = 1; } ft2 = (FigText) v.elementAt(i); if (!ft2.isVisible()) { ft2 = null; } } while (ft2 == null); return ft2; }
/** * @param f the fig to indicate the bounds of * @param g the graphics */ protected void indicateBounds(FigText f, Graphics g) { String text = f.getText(); if (text == null || text.length() == 0) { Rectangle rect = f.getBounds(); Color c = g.getColor(); g.setColor(Globals.getPrefs().handleColorFor(f)); g.drawRect(rect.x, rect.y, rect.width, rect.height); g.setColor(c); // TODO: Is this needed? } }
/** The constructor. */ public FigGeneralization() { // UML spec for Generalizations doesn't call for name or stereotype // middleGroup.addFig(getNameFig()); // middleGroup.addFig(getStereotypeFig()); // middleGroup.calcBounds(); // addPathItem(middleGroup, // new PathConvPercent2(this, middleGroup, 50, 25)); endArrow = new ArrowHeadTriangle(); discriminator.setFont(getLabelFont()); discriminator.setTextColor(Color.black); discriminator.setTextFilled(false); discriminator.setFilled(false); discriminator.setLineWidth(0); discriminator.setExpandOnly(false); discriminator.setReturnAction(FigText.END_EDITING); discriminator.setTabAction(FigText.END_EDITING); addPathItem(discriminator, new PathConvPercent(this, 40, -10)); endArrow.setFillColor(Color.white); setDestArrowHead(endArrow); setBetweenNearestPoints(true); if (getLayer() == null) { setLayer(ProjectManager.getManager().getCurrentProject().getActiveDiagram().getLayer()); } }
@Override protected final void updateLayout(UmlChangeEvent mee) { super.updateLayout(mee); if (mee instanceof AttributeChangeEvent && mee.getPropertyName().equals("body")) { bodyTextFig.setText(mee.getNewValue().toString()); calcBounds(); setBounds(getBounds()); damage(); } else if (mee instanceof RemoveAssociationEvent && mee.getPropertyName().equals("annotatedElement")) { /* Remove the commentedge. * If there are more then one comment-edges between * the 2 objects, then delete them all. */ Collection<FigEdgeNote> toRemove = new ArrayList<FigEdgeNote>(); Collection c = getFigEdges(); // all connected edges for (Iterator i = c.iterator(); i.hasNext(); ) { FigEdgeNote fen = (FigEdgeNote) i.next(); Object otherEnd = fen.getDestination(); // the UML object if (otherEnd == getOwner()) { // wrong end of the edge otherEnd = fen.getSource(); } if (otherEnd == mee.getOldValue()) { toRemove.add(fen); } } for (FigEdgeNote fen : toRemove) { fen.removeFromDiagram(); } } }
/* * @see org.tigris.gef.presentation.Fig#setLineWidth(int) */ @Override public void setLineWidth(int w) { bodyTextFig.setLineWidth(0); // Make a seamless integration of the text // in the note figure. outlineFig.setLineWidth(w); urCorner.setLineWidth(w); }
private String getDescr(Fig f) { if (f == null) { return null; } String className = f.getClass().getName(); StringBuffer descr = new StringBuffer(className.substring(className.lastIndexOf(".") + 1)); // descr.append(" - paints=").append(f.getPaintCount()); // descr.append(" - damages=").append(f.getDamageCount()); descr.append( " - bounds=[" + f.getX() + "," + f.getY() + "," + f.getWidth() + "," + f.getHeight() + "]"); if (!f.isVisible()) { descr.append(" - INVISIBLE"); } if (f.isFilled()) { descr.append(" - FILLED"); } descr.append( " - fill=[" + f.getFillColor().getRed() + "," + f.getFillColor().getGreen() + "," + f.getFillColor().getBlue() + "]"); if (f.getOwner() != null) { descr.append(" - owner=").append(f.getOwner()); } if (f instanceof FigText) { descr.append(" \"").append(((FigText) f).getText()).append("\""); } descr.append(" - lay=").append(toString(f.getLayer())); descr.append(" - grp=").append(toString(f.getGroup())); return descr.toString(); }
private void updateBody() { if (getOwner() != null) { String body = (String) Model.getFacade().getBody(getOwner()); if (body != null) { bodyTextFig.setText(body); } } }
public FigShallowHistoryState() { _bigPort = new FigCircle(x, y, width, height, Color.cyan, Color.cyan); _head = new FigCircle(x, y, width, height, Color.black, Color.white); _name = new FigText(x + 5, y + 5, width - 10, height - 10); _name.setText("H"); _name.setTextColor(Color.black); _name.setFilled(false); _name.setLineWidth(0); // add Figs to the FigNode in back-to-front order addFig(_bigPort); addFig(_head); addFig(_name); setBlinkPorts(false); // make port invisble unless mouse enters Rectangle r = getBounds(); }
/** * Partially construct a new FigNode. This method creates the _name element that holds the name of * the model element and adds itself as a listener. */ public FigEdgeModelElement() { nameFig = new FigSingleLineText(10, 30, 90, 20, false); nameFig.setTextFilled(false); stereotypeFig = new FigStereotypesCompartment(10, 10, 90, 15); setBetweenNearestPoints(true); ArgoEventPump.addListener(ArgoEventTypes.ANY_NOTATION_EVENT, this); }
/** Updates the discriminator text. Called if the model is changed and on construction time. */ public void updateDiscriminatorText() { Object me = getOwner(); // MGeneralization if (me == null) { return; } String disc = (String) Model.getFacade().getDiscriminator(me); if (disc == null) { disc = ""; } discriminator.setText(disc); }
protected void textEdited(FigText ft) throws PropertyVetoException { // super.textEdited(ft); MComponentInstance coi = (MComponentInstance) getOwner(); if (ft == _name) { String s = ft.getText().trim(); // why this??? // if (s.length()>0) { // s = s.substring(0, (s.length() - 1)); // } ParserDisplay.SINGLETON.parseComponentInstance(coi, s); } }
/** generate the notation for the modelelement and stuff it into the text Fig */ protected void updateNameText() { if (getOwner() == null) { return; } if (notationProviderName != null) { String nameStr = notationProviderName.toString(); nameFig.setText(nameStr); calcBounds(); setBounds(getBounds()); } }
/** * Get the minimum size for the note figure. * * @return The minimum size for the note figure. */ @Override public Dimension getMinimumSize() { // Get the size of the text field. Dimension aSize = bodyTextFig.getMinimumSize(); // If we have a stereotype displayed, then allow some space for that // (width and height) if (getStereotypeFig().isVisible()) { Dimension stereoMin = getStereotypeFig().getMinimumSize(); aSize.width = Math.max(aSize.width, stereoMin.width); aSize.height += stereoMin.height; } // And add the gaps around the textfield to get the minimum // size of the note. return new Dimension(aSize.width + 4 + dogear, aSize.height + 4); }
/* * @see org.tigris.gef.presentation.Fig#setBounds(int, int, int, int) */ @Override protected void setStandardBounds(int px, int py, int w, int h) { if (bodyTextFig == null) { return; } Dimension stereoMin = getStereotypeFig().getMinimumSize(); int stereotypeHeight = 0; if (getStereotypeFig().isVisible()) { stereotypeHeight = stereoMin.height; } Rectangle oldBounds = getBounds(); // Resize the text figure bodyTextFig.setBounds( px + 2, py + 2 + stereotypeHeight, w - 4 - dogear, h - 4 - stereotypeHeight); getStereotypeFig().setBounds(px + 2, py + 2, w - 4 - dogear, stereoMin.height); // Resize the big port around the figure getBigPort().setBounds(px, py, w, h); // Since this is a complex polygon, there's no easy way to resize it. Polygon newPoly = new Polygon(); newPoly.addPoint(px, py); newPoly.addPoint(px + w - 1 - dogear, py); newPoly.addPoint(px + w - 1, py + dogear); newPoly.addPoint(px + w - 1, py + h - 1); newPoly.addPoint(px, py + h - 1); newPoly.addPoint(px, py); outlineFig.setPolygon(newPoly); // Just move the corner to it's new position. urCorner.setBounds(px + w - 1 - dogear, py, dogear, dogear); calcBounds(); // _x = x; _y = y; _w = w; _h = h; firePropChange("bounds", oldBounds, getBounds()); }
/* * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent) */ @Override public void keyTyped(KeyEvent ke) { if (Character.isISOControl(ke.getKeyChar())) { return; } if (!readyToEdit) { Object owner = getOwner(); if (Model.getFacade().isAModelElement(owner) && !Model.getModelManagementHelper().isReadOnly(owner)) { storeBody(""); readyToEdit = true; } else { return; } } if (ke.isConsumed()) { return; } if (getOwner() == null) { return; } bodyTextFig.keyTyped(ke); }
/* * @see org.tigris.gef.presentation.Fig#setFilled(boolean) */ @Override public void setFilled(boolean f) { bodyTextFig.setFilled(false); // The text is always opaque. outlineFig.setFilled(f); urCorner.setFilled(f); }
/* * @see org.argouml.uml.diagram.ui.FigNodeModelElement#textEdited(org.tigris.gef.presentation.FigText) */ @Override protected void textEdited(FigText ft) { if (ft == bodyTextFig) { storeBody(ft.getText()); } }
/** @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent) */ public void keyTyped(KeyEvent ke) { if (ke.isConsumed()) return; if (nameFig != null && canEdit(nameFig)) nameFig.keyTyped(ke); }
/** * This method is called after the user finishes editing a text field that is in the * FigEdgeModelElement. Determine which field and update the model. This class handles the name, * subclasses should override to handle other text elements. * * @param ft the text Fig that has been edited */ protected void textEdited(FigText ft) { if (ft == nameFig) { if (getOwner() == null) return; ft.setText(notationProviderName.parse(ft.getText())); } }
/** * This method is called when the user doubleclicked on the text field, and starts editing. * Subclasses should overrule this field to e.g. supply help to the user about the used format. * * <p>It is also possible to alter the text to be edited already here, e.g. by adding the * stereotype in front of the name, but that seems not user-friendly. * * @param ft the FigText that will be edited and contains the start-text */ protected void textEditStarted(FigText ft) { if (ft == getNameFig()) { showHelp(notationProviderName.getParsingHelp()); ft.setText(notationProviderName.toString()); } }
public String getName() { return nameFig.getText(); }
/** Get the Rectangle in which the model elements name is displayed */ public Rectangle getNameBounds() { return nameFig.getBounds(); }
/** * Get the text body of the comment. * * @return the body of the comment */ public String getBody() { return bodyTextFig.getText(); }