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

Last change on this file since 121 was 121, checked in by bjn8, 16 years ago

Added invalidation for graphics... biiiig commit. LOts of effeciency improvements - now can animate

File size: 3.0 KB
Line 
1package org.expeditee.items;
2
3import java.awt.Color;
4import java.awt.Graphics2D;
5import java.awt.Polygon;
6import java.awt.geom.Point2D;
7
8
9public class WidgetCorner extends Dot {
10
11 private InteractiveWidget _widgetSource;
12
13 WidgetCorner(int x, int y, int id, InteractiveWidget widgetSource) {
14 super(x, y, id);
15
16 super.setThickness(2.0f);
17
18 if (widgetSource == null) throw new NullPointerException("widgetSource");
19 _widgetSource = widgetSource;
20 }
21
22 @Override
23 public void updatePolygon() {
24 super.updatePolygon();
25 if (_widgetSource != null) _widgetSource.onBoundsChanged();
26 }
27
28 @Override
29 public void setPosition(float x, float y) {
30 invalidateFill();
31 if (_widgetSource != null) { // _widgetSource == null on construction
32 if (!_widgetSource.setPositions(this,(int)(x+0.5),(int)(y+0.5))) {
33 super.setPosition(x, y);
34 }
35 } else super.setPosition(x, y);
36 invalidateFill();
37 }
38
39 @Override
40 public void setXY(float x, float y) {
41 invalidateFill();
42 if (_widgetSource != null) { // _widgetSource == null on construction
43 if (!_widgetSource.setPositions(this,(int)(x+0.5),(int)(y+0.5))) {
44 super.setXY(x, y);
45 }
46 } else super.setXY(x, y);
47 invalidateFill();
48 }
49
50 @Override
51 public void translate(Point2D origin, double ratio) {
52 //super.translate(origin, ratio);
53 }
54
55 @Override
56 public void onParentStateChanged(ItemParentStateChangedEvent e) {
57 super.onParentStateChanged(e);
58 _widgetSource.onParentStateChanged(e);
59 }
60
61 public InteractiveWidget getWidgetSource() {
62 return _widgetSource;
63 }
64
65 @Override
66 public void paint(Graphics2D g) {
67 if (InteractiveWidget.isExpediteeHighlightingEnabled()) { // only paint if flag is set to true
68
69 // For fixed widgets, always have corner selected with connected context
70 HighlightMode tmp = _mode; // save mode
71 if (_mode == HighlightMode.Normal && _widgetSource.isFixedSize()) {
72 _mode = HighlightMode.Connected; // draw as connected context for fixed widgets
73 }
74 super.paint(g);
75 _mode = tmp; // restore mode
76 }
77 }
78
79 @Override
80 public void paintFill(Graphics2D g) {
81 _widgetSource.paintFill(g); // only paints a fill if floating
82 }
83
84 @Override
85 public void setAnnotation(boolean val) {
86 // Ignore
87 }
88
89 @Override
90 public boolean isAnnotation() {
91 return false;
92 }
93
94
95 @Override
96 public String toString() {
97 return "WidgetCorner: [" + this.getX() + "," + this.getY() + "]";
98 }
99
100 @Override
101 public void setThickness(float thick) {
102 }
103
104 @Override
105 public void setArrow(float length, double ratio) {
106 }
107
108 @Override
109 public void setArrowhead(Polygon arrow) {
110 }
111
112 @Override
113 public void setArrowheadLength(float length) {
114 }
115
116 @Override
117 public void setArrowheadRatio(double ratio) {
118 }
119
120 @Override
121 public void setBackgroundColor(Color c) {
122 }
123
124 @Override
125 public void setBottomShadowColor(Color bottom) {
126 }
127
128 @Override
129 public void setFillColor(Color c) {
130 }
131
132 @Override
133 public void setFillPattern(String patternLink) {
134 }
135
136 @Override
137 public void toggleDashed(int amount) {
138 }
139
140 @Override
141 public void setSize(float size) {
142 }
143
144
145
146
147}
Note: See TracBrowser for help on using the repository browser.