1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
package org.argouml.uml.diagram.static_structure.ui; |
40 | |
|
41 | |
import java.awt.Color; |
42 | |
import java.awt.Dimension; |
43 | |
import java.awt.Point; |
44 | |
import java.awt.Polygon; |
45 | |
import java.awt.Rectangle; |
46 | |
import java.awt.event.InputEvent; |
47 | |
import java.awt.event.KeyEvent; |
48 | |
import java.awt.event.KeyListener; |
49 | |
import java.awt.event.MouseEvent; |
50 | |
import java.awt.event.MouseListener; |
51 | |
import java.beans.PropertyChangeEvent; |
52 | |
import java.beans.PropertyChangeListener; |
53 | |
import java.beans.VetoableChangeListener; |
54 | |
import java.util.ArrayList; |
55 | |
import java.util.Collection; |
56 | |
import java.util.Iterator; |
57 | |
|
58 | |
import javax.swing.SwingUtilities; |
59 | |
|
60 | |
import org.apache.log4j.Logger; |
61 | |
import org.argouml.kernel.DelayedChangeNotify; |
62 | |
import org.argouml.kernel.DelayedVChangeListener; |
63 | |
import org.argouml.model.AttributeChangeEvent; |
64 | |
import org.argouml.model.Model; |
65 | |
import org.argouml.model.RemoveAssociationEvent; |
66 | |
import org.argouml.model.UmlChangeEvent; |
67 | |
import org.argouml.ui.ArgoJMenu; |
68 | |
import org.argouml.uml.diagram.DiagramSettings; |
69 | |
import org.argouml.uml.diagram.ui.FigMultiLineText; |
70 | |
import org.argouml.uml.diagram.ui.FigNodeModelElement; |
71 | |
import org.tigris.gef.base.Geometry; |
72 | |
import org.tigris.gef.base.Selection; |
73 | |
import org.tigris.gef.presentation.Fig; |
74 | |
import org.tigris.gef.presentation.FigPoly; |
75 | |
import org.tigris.gef.presentation.FigRect; |
76 | |
import org.tigris.gef.presentation.FigText; |
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
public class FigComment |
84 | |
extends FigNodeModelElement |
85 | |
implements VetoableChangeListener, |
86 | |
DelayedVChangeListener, |
87 | |
MouseListener, |
88 | |
KeyListener, |
89 | |
PropertyChangeListener { |
90 | |
|
91 | |
|
92 | |
|
93 | 0 | private static final Logger LOG = Logger.getLogger(FigComment.class); |
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | 0 | private int width = 80; |
99 | 0 | private int height = 60; |
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | 0 | private int dogear = 10; |
105 | |
|
106 | 0 | private boolean readyToEdit = true; |
107 | |
|
108 | |
|
109 | |
private FigText bodyTextFig; |
110 | |
|
111 | |
private FigPoly outlineFig; |
112 | |
|
113 | |
|
114 | |
|
115 | |
|
116 | |
private FigPoly urCorner; |
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
private boolean newlyCreated; |
124 | |
|
125 | |
@Override |
126 | |
protected Fig createBigPortFig() { |
127 | 0 | FigRect fr = new FigRect(0, 0, width, height, null, null); |
128 | 0 | fr.setFilled(false); |
129 | 0 | fr.setLineWidth(0); |
130 | 0 | return fr; |
131 | |
} |
132 | |
|
133 | |
private void initialize() { |
134 | 0 | Color fg = super.getLineColor(); |
135 | 0 | Color fill = super.getFillColor(); |
136 | |
|
137 | 0 | outlineFig = new FigPoly(fg, fill); |
138 | 0 | outlineFig.addPoint(0, 0); |
139 | 0 | outlineFig.addPoint(width - 1 - dogear, 0); |
140 | 0 | outlineFig.addPoint(width - 1, dogear); |
141 | 0 | outlineFig.addPoint(width - 1, height - 1); |
142 | 0 | outlineFig.addPoint(0, height - 1); |
143 | 0 | outlineFig.addPoint(0, 0); |
144 | 0 | outlineFig.setFilled(true); |
145 | 0 | outlineFig.setLineWidth(LINE_WIDTH); |
146 | |
|
147 | 0 | urCorner = new FigPoly(fg, fill); |
148 | 0 | urCorner.addPoint(width - 1 - dogear, 0); |
149 | 0 | urCorner.addPoint(width - 1, dogear); |
150 | 0 | urCorner.addPoint(width - 1 - dogear, dogear); |
151 | 0 | urCorner.addPoint(width - 1 - dogear, 0); |
152 | 0 | urCorner.setFilled(true); |
153 | 0 | Color col = outlineFig.getFillColor(); |
154 | 0 | urCorner.setFillColor(col.darker()); |
155 | 0 | urCorner.setLineWidth(LINE_WIDTH); |
156 | |
|
157 | |
|
158 | 0 | addFig(getBigPort()); |
159 | 0 | addFig(outlineFig); |
160 | 0 | addFig(urCorner); |
161 | 0 | addFig(getStereotypeFig()); |
162 | 0 | addFig(bodyTextFig); |
163 | |
|
164 | 0 | col = outlineFig.getFillColor(); |
165 | 0 | urCorner.setFillColor(col.darker()); |
166 | |
|
167 | 0 | setBlinkPorts(false); |
168 | 0 | Rectangle r = getBounds(); |
169 | 0 | setBounds(r.x, r.y, r.width, r.height); |
170 | 0 | updateEdges(); |
171 | |
|
172 | 0 | readyToEdit = false; |
173 | |
|
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | |
|
179 | |
|
180 | 0 | newlyCreated = true; |
181 | 0 | } |
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
|
187 | |
|
188 | |
|
189 | |
|
190 | |
|
191 | |
public FigComment(Object owner, Rectangle bounds, |
192 | |
DiagramSettings settings) { |
193 | 0 | super(owner, bounds, settings); |
194 | |
|
195 | 0 | bodyTextFig = new FigMultiLineText(getOwner(), |
196 | |
new Rectangle(2, 2, width - 2 - dogear, height - 4), |
197 | |
getSettings(), true); |
198 | |
|
199 | 0 | initialize(); |
200 | 0 | updateBody(); |
201 | 0 | if (bounds != null) { |
202 | 0 | setLocation(bounds.x, bounds.y); |
203 | |
} |
204 | 0 | } |
205 | |
|
206 | |
|
207 | |
|
208 | |
|
209 | |
|
210 | |
|
211 | |
@Override |
212 | |
public String placeString() { |
213 | 0 | String placeString = retrieveBody(); |
214 | 0 | if (placeString == null) { |
215 | |
|
216 | 0 | placeString = "new note"; |
217 | |
} |
218 | 0 | return placeString; |
219 | |
} |
220 | |
|
221 | |
|
222 | |
|
223 | |
|
224 | |
|
225 | |
|
226 | |
@Override |
227 | |
public Object clone() { |
228 | 0 | FigComment figClone = (FigComment) super.clone(); |
229 | 0 | Iterator thisIter = this.getFigs().iterator(); |
230 | 0 | while (thisIter.hasNext()) { |
231 | 0 | Object thisFig = thisIter.next(); |
232 | 0 | if (thisFig == outlineFig) { |
233 | 0 | figClone.outlineFig = (FigPoly) thisFig; |
234 | |
} |
235 | 0 | if (thisFig == urCorner) { |
236 | 0 | figClone.urCorner = (FigPoly) thisFig; |
237 | |
} |
238 | 0 | if (thisFig == bodyTextFig) { |
239 | 0 | figClone.bodyTextFig = (FigText) thisFig; |
240 | |
} |
241 | 0 | } |
242 | 0 | return figClone; |
243 | |
} |
244 | |
|
245 | |
private void updateBody() { |
246 | 0 | if (getOwner() != null) { |
247 | 0 | String body = (String) Model.getFacade().getBody(getOwner()); |
248 | 0 | if (body != null) { |
249 | 0 | bodyTextFig.setText(body); |
250 | |
} |
251 | |
} |
252 | 0 | } |
253 | |
|
254 | |
|
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | |
|
260 | |
|
261 | |
|
262 | |
|
263 | |
|
264 | |
|
265 | |
|
266 | |
@Override |
267 | |
public void mouseClicked(MouseEvent me) { |
268 | 0 | if (!readyToEdit) { |
269 | 0 | Object owner = getOwner(); |
270 | 0 | if (Model.getFacade().isAModelElement(owner) |
271 | |
&& !Model.getModelManagementHelper().isReadOnly(owner)) { |
272 | 0 | readyToEdit = true; |
273 | |
} else { |
274 | 0 | LOG.debug("not ready to edit note"); |
275 | 0 | return; |
276 | |
} |
277 | |
} |
278 | 0 | if (me.isConsumed()) { |
279 | 0 | return; |
280 | |
} |
281 | 0 | if (me.getClickCount() >= 2 |
282 | |
&& !(me.isPopupTrigger() |
283 | |
|| me.getModifiers() == InputEvent.BUTTON3_MASK)) { |
284 | 0 | if (getOwner() == null) { |
285 | 0 | return; |
286 | |
} |
287 | 0 | Fig f = hitFig(new Rectangle(me.getX() - 2, me.getY() - 2, 4, 4)); |
288 | 0 | if (f instanceof MouseListener) { |
289 | 0 | ((MouseListener) f).mouseClicked(me); |
290 | |
} |
291 | |
} |
292 | 0 | me.consume(); |
293 | 0 | } |
294 | |
|
295 | |
|
296 | |
|
297 | |
|
298 | |
@Override |
299 | |
public void vetoableChange(PropertyChangeEvent pce) { |
300 | 0 | Object src = pce.getSource(); |
301 | 0 | if (src == getOwner()) { |
302 | 0 | DelayedChangeNotify delayedNotify = |
303 | |
new DelayedChangeNotify(this, pce); |
304 | 0 | SwingUtilities.invokeLater(delayedNotify); |
305 | 0 | } else { |
306 | 0 | LOG.debug("FigNodeModelElement got vetoableChange" |
307 | |
+ " from non-owner:" + src); |
308 | |
} |
309 | 0 | } |
310 | |
|
311 | |
|
312 | |
|
313 | |
|
314 | |
@Override |
315 | |
public void delayedVetoableChange(PropertyChangeEvent pce) { |
316 | |
|
317 | 0 | renderingChanged(); |
318 | |
|
319 | 0 | endTrans(); |
320 | 0 | } |
321 | |
|
322 | |
|
323 | |
|
324 | |
|
325 | |
@Override |
326 | |
public void propertyChange(PropertyChangeEvent pve) { |
327 | 0 | Object src = pve.getSource(); |
328 | 0 | String pName = pve.getPropertyName(); |
329 | 0 | if (pName.equals("editing") |
330 | |
&& Boolean.FALSE.equals(pve.getNewValue())) { |
331 | |
|
332 | 0 | textEdited((FigText) src); |
333 | |
|
334 | 0 | Rectangle bbox = getBounds(); |
335 | 0 | Dimension minSize = getMinimumSize(); |
336 | 0 | bbox.width = Math.max(bbox.width, minSize.width); |
337 | 0 | bbox.height = Math.max(bbox.height, minSize.height); |
338 | 0 | setBounds(bbox.x, bbox.y, bbox.width, bbox.height); |
339 | 0 | endTrans(); |
340 | 0 | } else { |
341 | 0 | super.propertyChange(pve); |
342 | |
} |
343 | 0 | } |
344 | |
|
345 | |
|
346 | |
|
347 | |
|
348 | |
@Override |
349 | |
public void keyPressed(KeyEvent ke) { |
350 | |
|
351 | 0 | } |
352 | |
|
353 | |
|
354 | |
|
355 | |
|
356 | |
@Override |
357 | |
public void keyReleased(KeyEvent ke) { |
358 | |
|
359 | 0 | } |
360 | |
|
361 | |
|
362 | |
|
363 | |
|
364 | |
@Override |
365 | |
public void keyTyped(KeyEvent ke) { |
366 | 0 | if (Character.isISOControl(ke.getKeyChar())) { |
367 | 0 | return; |
368 | |
} |
369 | 0 | if (!readyToEdit) { |
370 | 0 | Object owner = getOwner(); |
371 | 0 | if (Model.getFacade().isAModelElement(owner) |
372 | |
&& !Model.getModelManagementHelper().isReadOnly(owner)) { |
373 | 0 | storeBody(""); |
374 | 0 | readyToEdit = true; |
375 | |
} else { |
376 | 0 | LOG.debug("not ready to edit note"); |
377 | 0 | return; |
378 | |
} |
379 | |
} |
380 | 0 | if (ke.isConsumed()) { |
381 | 0 | return; |
382 | |
} |
383 | 0 | if (getOwner() == null) { |
384 | 0 | return; |
385 | |
} |
386 | 0 | bodyTextFig.keyTyped(ke); |
387 | 0 | } |
388 | |
|
389 | |
|
390 | |
|
391 | |
|
392 | |
|
393 | |
|
394 | |
|
395 | |
|
396 | |
@Override |
397 | |
protected ArgoJMenu buildShowPopUp() { |
398 | 0 | return new ArgoJMenu("menu.popup.show"); |
399 | |
} |
400 | |
|
401 | |
|
402 | |
|
403 | |
|
404 | |
@Override |
405 | |
public Selection makeSelection() { |
406 | 0 | return new SelectionComment(this); |
407 | |
} |
408 | |
|
409 | |
|
410 | |
|
411 | |
|
412 | |
@Override |
413 | |
public void setLineColor(Color col) { |
414 | |
|
415 | 0 | outlineFig.setLineColor(col); |
416 | 0 | urCorner.setLineColor(col); |
417 | 0 | } |
418 | |
|
419 | |
|
420 | |
|
421 | |
|
422 | |
@Override |
423 | |
public Color getLineColor() { |
424 | 0 | return outlineFig.getLineColor(); |
425 | |
} |
426 | |
|
427 | |
|
428 | |
|
429 | |
|
430 | |
@Override |
431 | |
public void setFillColor(Color col) { |
432 | 0 | outlineFig.setFillColor(col); |
433 | 0 | urCorner.setFillColor(col); |
434 | 0 | } |
435 | |
|
436 | |
|
437 | |
|
438 | |
|
439 | |
@Override |
440 | |
public Color getFillColor() { |
441 | 0 | return outlineFig.getFillColor(); |
442 | |
} |
443 | |
|
444 | |
|
445 | |
|
446 | |
|
447 | |
@Override |
448 | |
public void setFilled(boolean f) { |
449 | 0 | bodyTextFig.setFilled(false); |
450 | 0 | outlineFig.setFilled(f); |
451 | 0 | urCorner.setFilled(f); |
452 | 0 | } |
453 | |
|
454 | |
@Override |
455 | |
public boolean isFilled() { |
456 | 0 | return outlineFig.isFilled(); |
457 | |
} |
458 | |
|
459 | |
|
460 | |
|
461 | |
|
462 | |
@Override |
463 | |
public void setLineWidth(int w) { |
464 | 0 | bodyTextFig.setLineWidth(0); |
465 | |
|
466 | 0 | outlineFig.setLineWidth(w); |
467 | 0 | urCorner.setLineWidth(w); |
468 | 0 | } |
469 | |
|
470 | |
|
471 | |
|
472 | |
|
473 | |
@Override |
474 | |
public int getLineWidth() { |
475 | 0 | return outlineFig.getLineWidth(); |
476 | |
} |
477 | |
|
478 | |
|
479 | |
|
480 | |
|
481 | |
|
482 | |
|
483 | |
|
484 | |
@Override |
485 | |
protected void textEdited(FigText ft) { |
486 | 0 | if (ft == bodyTextFig) { |
487 | 0 | storeBody(ft.getText()); |
488 | |
} |
489 | 0 | } |
490 | |
|
491 | |
|
492 | |
|
493 | |
|
494 | |
@Override |
495 | |
protected void textEditStarted(FigText ft) { |
496 | 0 | showHelp("parsing.help.comment"); |
497 | 0 | } |
498 | |
|
499 | |
|
500 | |
|
501 | |
|
502 | |
@Override |
503 | |
public void setEnclosingFig(Fig encloser) { |
504 | 0 | super.setEnclosingFig(encloser); |
505 | 0 | } |
506 | |
|
507 | |
|
508 | |
|
509 | |
|
510 | |
|
511 | |
|
512 | |
|
513 | |
|
514 | |
|
515 | |
public final void storeBody(String body) { |
516 | 0 | if (getOwner() != null) { |
517 | 0 | Model.getCoreHelper().setBody(getOwner(), body); |
518 | |
} |
519 | 0 | } |
520 | |
|
521 | |
|
522 | |
|
523 | |
|
524 | |
|
525 | |
|
526 | |
private String retrieveBody() { |
527 | 0 | return (getOwner() != null) |
528 | |
? (String) Model.getFacade().getBody(getOwner()) |
529 | |
: null; |
530 | |
} |
531 | |
|
532 | |
|
533 | |
|
534 | |
|
535 | |
@Override |
536 | |
public boolean getUseTrapRect() { |
537 | 0 | return true; |
538 | |
} |
539 | |
|
540 | |
|
541 | |
|
542 | |
|
543 | |
|
544 | |
@Override |
545 | |
public Rectangle getNameBounds() { |
546 | 0 | return null; |
547 | |
} |
548 | |
|
549 | |
|
550 | |
|
551 | |
|
552 | |
|
553 | |
|
554 | |
@Override |
555 | |
public Dimension getMinimumSize() { |
556 | |
|
557 | |
|
558 | 0 | Dimension aSize = bodyTextFig.getMinimumSize(); |
559 | |
|
560 | |
|
561 | |
|
562 | |
|
563 | 0 | if (getStereotypeFig().isVisible()) { |
564 | 0 | Dimension stereoMin = getStereotypeFig().getMinimumSize(); |
565 | 0 | aSize.width = |
566 | |
Math.max(aSize.width, |
567 | |
stereoMin.width); |
568 | 0 | aSize.height += stereoMin.height; |
569 | |
} |
570 | |
|
571 | |
|
572 | |
|
573 | 0 | return new Dimension(aSize.width + 4 + dogear, |
574 | |
aSize.height + 4); |
575 | |
} |
576 | |
|
577 | |
|
578 | |
|
579 | |
|
580 | |
@Override |
581 | |
protected void setStandardBounds(int px, int py, int w, int h) { |
582 | 0 | if (bodyTextFig == null) { |
583 | 0 | return; |
584 | |
} |
585 | |
|
586 | 0 | Dimension stereoMin = getStereotypeFig().getMinimumSize(); |
587 | |
|
588 | 0 | int stereotypeHeight = 0; |
589 | 0 | if (getStereotypeFig().isVisible()) { |
590 | 0 | stereotypeHeight = stereoMin.height; |
591 | |
} |
592 | |
|
593 | 0 | Rectangle oldBounds = getBounds(); |
594 | |
|
595 | |
|
596 | 0 | bodyTextFig.setBounds(px + 2, py + 2 + stereotypeHeight, |
597 | |
w - 4 - dogear, h - 4 - stereotypeHeight); |
598 | |
|
599 | 0 | getStereotypeFig().setBounds(px + 2, py + 2, |
600 | |
w - 4 - dogear, stereoMin.height); |
601 | |
|
602 | |
|
603 | 0 | getBigPort().setBounds(px, py, w, h); |
604 | |
|
605 | |
|
606 | 0 | Polygon newPoly = new Polygon(); |
607 | 0 | newPoly.addPoint(px, py); |
608 | 0 | newPoly.addPoint(px + w - 1 - dogear, py); |
609 | 0 | newPoly.addPoint(px + w - 1, py + dogear); |
610 | 0 | newPoly.addPoint(px + w - 1, py + h - 1); |
611 | 0 | newPoly.addPoint(px, py + h - 1); |
612 | 0 | newPoly.addPoint(px, py); |
613 | 0 | outlineFig.setPolygon(newPoly); |
614 | |
|
615 | |
|
616 | 0 | urCorner.setBounds(px + w - 1 - dogear, py, dogear, dogear); |
617 | |
|
618 | 0 | calcBounds(); |
619 | 0 | firePropChange("bounds", oldBounds, getBounds()); |
620 | 0 | } |
621 | |
|
622 | |
|
623 | |
|
624 | |
|
625 | |
|
626 | |
@Override |
627 | |
protected void updateBounds() { |
628 | 0 | Rectangle bbox = getBounds(); |
629 | 0 | Dimension minSize = getMinimumSize(); |
630 | 0 | bbox.width = Math.max(bbox.width, minSize.width); |
631 | 0 | bbox.height = Math.max(bbox.height, minSize.height); |
632 | 0 | setBounds(bbox.x, bbox.y, bbox.width, bbox.height); |
633 | 0 | } |
634 | |
|
635 | |
|
636 | |
|
637 | |
|
638 | |
@Override |
639 | |
protected final void updateLayout(UmlChangeEvent mee) { |
640 | 0 | super.updateLayout(mee); |
641 | |
|
642 | 0 | if (mee instanceof AttributeChangeEvent |
643 | |
&& mee.getPropertyName().equals("body")) { |
644 | |
|
645 | 0 | bodyTextFig.setText(mee.getNewValue().toString()); |
646 | 0 | calcBounds(); |
647 | 0 | setBounds(getBounds()); |
648 | 0 | damage(); |
649 | 0 | } else if (mee instanceof RemoveAssociationEvent |
650 | |
&& mee.getPropertyName().equals("annotatedElement")) { |
651 | |
|
652 | |
|
653 | |
|
654 | 0 | Collection<FigEdgeNote> toRemove = new ArrayList<FigEdgeNote>(); |
655 | 0 | Collection c = getFigEdges(); |
656 | 0 | for (Iterator i = c.iterator(); i.hasNext(); ) { |
657 | 0 | FigEdgeNote fen = (FigEdgeNote) i.next(); |
658 | 0 | Object otherEnd = fen.getDestination(); |
659 | 0 | if (otherEnd == getOwner()) { |
660 | 0 | otherEnd = fen.getSource(); |
661 | |
} |
662 | 0 | if (otherEnd == mee.getOldValue()) { |
663 | 0 | toRemove.add(fen); |
664 | |
} |
665 | 0 | } |
666 | |
|
667 | 0 | for (FigEdgeNote fen : toRemove) { |
668 | 0 | fen.removeFromDiagram(); |
669 | |
} |
670 | |
} |
671 | 0 | } |
672 | |
|
673 | |
|
674 | |
|
675 | |
|
676 | |
@Override |
677 | |
protected void updateStereotypeText() { |
678 | 0 | Object me = getOwner(); |
679 | |
|
680 | 0 | if (me == null) { |
681 | 0 | return; |
682 | |
} |
683 | |
|
684 | 0 | Rectangle rect = getBounds(); |
685 | |
|
686 | 0 | Dimension stereoMin = getStereotypeFig().getMinimumSize(); |
687 | |
|
688 | 0 | if (Model.getFacade().getStereotypes(me).isEmpty()) { |
689 | |
|
690 | 0 | if (getStereotypeFig().isVisible()) { |
691 | 0 | getStereotypeFig().setVisible(false); |
692 | 0 | rect.y += stereoMin.height; |
693 | 0 | rect.height -= stereoMin.height; |
694 | 0 | setBounds(rect.x, rect.y, rect.width, rect.height); |
695 | 0 | calcBounds(); |
696 | |
} |
697 | |
} else { |
698 | 0 | if (!getStereotypeFig().isVisible()) { |
699 | 0 | getStereotypeFig().setVisible(true); |
700 | |
|
701 | |
|
702 | |
|
703 | |
|
704 | |
|
705 | |
|
706 | 0 | if (!newlyCreated) { |
707 | 0 | rect.y -= stereoMin.height; |
708 | 0 | rect.height += stereoMin.height; |
709 | 0 | rect.width = |
710 | |
Math.max(getMinimumSize().width, rect.width); |
711 | 0 | setBounds(rect.x, rect.y, rect.width, rect.height); |
712 | 0 | calcBounds(); |
713 | |
} |
714 | |
} |
715 | |
} |
716 | |
|
717 | |
|
718 | 0 | newlyCreated = false; |
719 | 0 | } |
720 | |
|
721 | |
|
722 | |
|
723 | |
|
724 | |
|
725 | |
public String getBody() { |
726 | 0 | return bodyTextFig.getText(); |
727 | |
} |
728 | |
|
729 | |
|
730 | |
|
731 | |
|
732 | |
@Override |
733 | |
public Point getClosestPoint(Point anotherPt) { |
734 | 0 | Rectangle r = getBounds(); |
735 | 0 | int[] xs = { |
736 | |
r.x, r.x + r.width - dogear, r.x + r.width, |
737 | |
r.x + r.width, r.x, r.x, |
738 | |
}; |
739 | 0 | int[] ys = { |
740 | |
r.y, r.y, r.y + dogear, |
741 | |
r.y + r.height, r.y + r.height, r.y, |
742 | |
}; |
743 | 0 | Point p = |
744 | |
Geometry.ptClosestTo( |
745 | |
xs, |
746 | |
ys, |
747 | |
6, |
748 | |
anotherPt); |
749 | 0 | return p; |
750 | |
} |
751 | |
|
752 | |
|
753 | |
|
754 | |
|
755 | |
private static final long serialVersionUID = 7242542877839921267L; |
756 | |
} |