source: trunk/src/org/expeditee/items/WidgetCorner.java@ 115

Last change on this file since 115 was 115, checked in by ra33, 16 years ago

added functionality for dockable @v's

File size: 1.7 KB
Line 
1package org.expeditee.items;
2
3import java.awt.Graphics2D;
4
5
6public class WidgetCorner extends Dot {
7
8 private InteractiveWidget _widgetSource;
9
10 WidgetCorner(int x, int y, int id, InteractiveWidget widgetSource) {
11 super(x, y, id);
12 if (widgetSource == null) throw new NullPointerException("widgetSource");
13 _widgetSource = widgetSource;
14 }
15
16 @Override
17 public void updatePolygon() {
18 super.updatePolygon();
19 if (_widgetSource != null) _widgetSource.onBoundsChanged();
20 }
21
22 @Override
23 public void setPosition(float x, float y) {
24
25 if (_widgetSource != null) { // _widgetSource == null on construction
26 if (!_widgetSource.setPositions(this,(int)(x+0.5),(int)(y+0.5)))
27 super.setPosition(x, y);
28 } else super.setPosition(x, y);
29 }
30
31 @Override
32 public void onParentStateChanged(ItemParentStateChangedEvent e) {
33 super.onParentStateChanged(e);
34 _widgetSource.onParentStateChanged(e);
35 }
36
37 public InteractiveWidget getWidgetSource() {
38 return _widgetSource;
39 }
40
41 @Override
42 public void paint(Graphics2D g) {
43 if (InteractiveWidget.isExepiteeHighlightingEnabled()) { // only paint if flag is set to true
44
45 // For fixed widgets, always have corner selected with connected context
46 HighlightMode tmp = _mode; // save mode
47 if (_mode == HighlightMode.Normal && _widgetSource.isFixedSize()) {
48 _mode = HighlightMode.Connected; // draw as connected context for fixed widgets
49 }
50 super.paint(g);
51 _mode = tmp; // restore mode
52 }
53 _widgetSource.paint(g, this);
54 }
55
56 @Override
57 public void setAnnotation(boolean val) {
58 // Ignore
59 }
60
61 @Override
62 public boolean isAnnotation() {
63 return false;
64 }
65
66
67 @Override
68 public String toString() {
69 return "WidgetCorner: [" + this.getX() + "," + this.getY() + "]";
70 }
71
72
73}
Note: See TracBrowser for help on using the repository browser.