Inheritance diagram for VisCanvas::

Public Methods | |
| VisCanvas () | |
| VisCanvas (Dimension d) | |
| VisCanvas (Dimension d, boolean fixedSize) | |
| Dimension in ICS. More... | |
| void | setCanvasInspectionUser (CanvasInspectionUser user) |
| void | paintComponent (Graphics g) |
| void | clear () |
| Clear the canvas, i.e. More... | |
| void | zoom (double zoomVal) |
| Zoom to the given value. More... | |
| int | addObject (CanvasObject obj) |
| CanvasObject | getObject (String name) |
| void | removeObject (String name) |
| void | removeAllObjects () |
| void | handleMousePress (MouseEvent e) |
| Overloading of IcsCanvas interface. More... | |
| void | handleMouseEnter (MouseEvent e) |
| Overloading of IcsCanvas interface. More... | |
| void | handleMouseExit (MouseEvent e) |
| Overloading of IcsCanvas interface. More... | |
| void | handleMouseMove (MouseEvent e) |
| Overloading of IcsCanvas interface. More... | |
| void | actionPerformed (ActionEvent event) |
| Implementation of ActionListener. More... | |
| void | handleJavaFuncDialogOK (Object target, CallableMethod method, Object[] argVals) |
|
|
|
|
|
00036 {
00037 this(d, false);
00038 }
|
|
||||||||||||
|
Dimension in ICS.
00044 {
00045 super(d, fixedSize);
00046 }
|
|
|
00050 {
00051 _inspUser = user;
00052 }
|
|
|
00056 {
00057 super.paintComponent(g);
00058 if (DEBUG_LAYOUT) {
00059 OutputStreamArea.println("VisCanvas::paint (" + getID() + "), clip : " + g.getClipBounds() + ", w x h : " + getWidth() + " x " + getHeight());
00060 dump();
00061 }
00062 drawImages(g);
00063 drawObjects(g);
00064 }
|
|
|
Clear the canvas, i.e. remove all objects from the canvas and draw the background color on the entire canvas.
00071 {
00072 drawBackground();
00073 removeAllObjects();
00074 }
|
|
|
Zoom to the given value. Will adjust the canvas size by setting the CCS extent. Reimplemented from IcsCanvas.
00078 {
00079 if (zoomVal == getZoomFactor())
00080 return;
00081
00082 super.zoom(zoomVal);
00083 zoomObjects(zoomVal);
00084 }
|
|
|
00088 {
00089 obj.setZoomFactor(getZoomFactor());
00090
00091 if (obj instanceof CanvasImage) {
00092 _images.addElement(obj);
00093 }
00094 if (obj instanceof CanvasFigure) {
00095 CanvasFigure figObj = (CanvasFigure) obj;
00096 if (figObj.hasNoColor())
00097 figObj.setColor(getDefaultDrawColor());
00098 _figures.addElement(obj);
00099 }
00100
00101 // Check canvas extent
00102
00103 int w = (int)(obj.getX1() + obj.getWidth() + 0.5) + EXT_MARGIN;
00104 int h = (int)(obj.getY1() + obj.getHeight() + 0.5) + EXT_MARGIN;
00105 Dimension objE = getObjectExtent();
00106 if ((w > objE.width) || (h > objE.height)) {
00107 w = Math.max(w, objE.width);
00108 h = Math.max(h, objE.height);
00109 if (DEBUG_LAYOUT)
00110 OutputStreamArea.println("VisCanvas::addObject (" + getID() + "): extent changed");
00111 setObjectExtent(new Dimension(w, h));
00112 }
00113
00114 repaint();
00115
00116 return -1;
00117 }
|
|
|
00121 {
00122 for (int i=_figures.size()-1; i>=0; i--) {
00123 CanvasObject obj = (CanvasObject) _figures.elementAt(i);
00124 if (obj.getSaName().compareTo(name) == 0)
00125 return obj;
00126 }
00127 for (int i=_images.size()-1; i>=0; i--) {
00128 CanvasObject obj = (CanvasObject) _images.elementAt(i);
00129 if (obj.getSaName().compareTo(name) == 0)
00130 return obj;
00131 }
00132 return null;
00133 }
|
|
|
00137 {
00138 for (int i=_images.size()-1; i>=0; i--) {
00139 CanvasObject obj = (CanvasObject) _images.elementAt(i);
00140 if (obj.getSaName().compareTo(name) == 0)
00141 _images.remove(i);
00142 }
00143 for (int i=_figures.size()-1; i>=0; i--) {
00144 CanvasObject obj = (CanvasObject) _figures.elementAt(i);
00145 if (obj.getSaName().compareTo(name) == 0)
00146 _figures.remove(i);
00147 }
00148 }
|
|
|
00152 {
00153 _images.removeAllElements();
00154 _figures.removeAllElements();
00155 checkObjectExtentChanged();
00156 }
|
|
|
Overloading of IcsCanvas interface.
Reimplemented from IcsCanvas.
00162 {
00163 if (DEBUG_EVENTS)
00164 OutputStreamArea.println("VIS handleMousePress (" + getID() + "): " + e.getPoint());
00165
00166 if (_inspUser == null)
00167 return;
00168
00169 // Convert mouse position from Canvas CS to Image CS
00170
00171 int[] ccs_vals = new int[] { e.getX(), e.getY() };
00172 double[] ics_vals = Converter.CCStoICS(ccs_vals, getZoomFactor());
00173
00174 double x = ics_vals[0];
00175 double y = ics_vals[1];
00176 boolean check = false;
00177
00178 _lastSelObj = null;
00179
00180 CanvasObject obj;
00181 for (int i=_figures.size()-1 ; i>=0 ; i--) {
00182 obj = (CanvasObject) _figures.elementAt(i);
00183 check = obj.isHitCcs(e.getX(), e.getY(),
00184 (Graphics2D) getGraphics());
00185 if (check) {
00186 _lastSelObj = obj;
00187 break;
00188 }
00189 }
00190 if (check == false) {
00191 for (int i=_images.size()-1; i>=0; i--) {
00192 obj = (CanvasObject) _images.elementAt(i);
00193 check = obj.isHitCcs(e.getX(), e.getY(),
00194 (Graphics2D) getGraphics());
00195 if (check) {
00196 _lastSelObj = obj;
00197 break;
00198 }
00199 }
00200 }
00201
00202 if (e.isMetaDown()) { // Right mouse
00203 if (_lastSelObj != null)
00204 popUpObjectMenu(_lastSelObj, e.getX(), e.getY());
00205 return;
00206 }
00207
00208 if (_lastSelObj != null)
00209 _inspUser.objectSelected(this, _lastSelObj, -1, x, y);
00210 else
00211 _inspUser.canvasSelected(this, x, y);
00212 }
|
|
|
Overloading of IcsCanvas interface.
Reimplemented from IcsCanvas.
00218 {
00219 if (DEBUG_EVENTS)
00220 OutputStreamArea.println("VIS handleMouseEnter (" + getID() + "): " + e.getPoint());
00221
00222 if (_inspUser == null)
00223 return;
00224
00225 // Convert mouse position from Canvas CS to Image CS
00226
00227 int[] ccs_vals = new int[] { e.getX(), e.getY() };
00228 double[] ics_vals = Converter.CCStoICS(ccs_vals, getZoomFactor());
00229
00230 double x = ics_vals[0];
00231 double y = ics_vals[1];
00232
00233 _lastSelObj = null;
00234 _inspUser.canvasEntered(this, x, y);
00235 }
|
|
|
Overloading of IcsCanvas interface.
Reimplemented from IcsCanvas.
00241 {
00242 if (DEBUG_EVENTS)
00243 OutputStreamArea.println("VIS handleMouseExit (" + getID() + "): " + e.getPoint());
00244
00245 if (_inspUser == null)
00246 return;
00247
00248 _lastSelObj = null;
00249 _inspUser.canvasExited(this);
00250 }
|
|
|
Overloading of IcsCanvas interface.
Reimplemented from IcsCanvas.
00256 {
00257 if (DEBUG_EVENTS)
00258 OutputStreamArea.println("VIS handleMouseMove (" + getID() + "): " + e.getPoint());
00259
00260 if (_inspUser == null)
00261 return;
00262
00263 // Convert mouse position from Canvas CS to Image CS
00264
00265 int[] ccs_vals = new int[] { e.getX(), e.getY() };
00266 double[] ics_vals = Converter.CCStoICS(ccs_vals, getZoomFactor());
00267
00268 double x = ics_vals[0];
00269 double y = ics_vals[1];
00270 CanvasObject newObj = null;
00271 boolean check = false;
00272
00273 CanvasObject obj;
00274 for (int i=_figures.size()-1 ; i>=0 ; i--) {
00275 obj = (CanvasObject) _figures.elementAt(i);
00276 check = obj.isHitCcs(e.getX(), e.getY(),
00277 (Graphics2D) getGraphics());
00278 //CanvasObject testing = (CanvasObject) _figures.elementAt(i);
00279 //OutputStreamArea.println("VIS checking " + testing.getSaName());
00280 if (check) {
00281 //testing.dump();
00282 newObj = obj;
00283 break;
00284 }
00285 }
00286 if (check == false) {
00287 for (int i=_images.size()-1; i>=0; i--) {
00288 obj = (CanvasObject) _images.elementAt(i);
00289 check = obj.isHitCcs(e.getX(), e.getY(),
00290 (Graphics2D) getGraphics());
00291 if (check) {
00292 newObj = obj;
00293 break;
00294 }
00295 }
00296 }
00297
00298 if (newObj != null) {
00299 if (newObj == _lastSelObj) {
00300 _lastSelObj = newObj;
00301 _inspUser.objectProbed(this, _lastSelObj, -1, x, y);
00302 } else {
00303 _lastSelObj = newObj;
00304 _inspUser.objectEntered(this, _lastSelObj, -1, x, y);
00305 }
00306 }
00307 }
|
|
|
Implementation of ActionListener. Called when an item from the popup menu has been selected.
00314 {
00315 String command = event.getActionCommand();
00316 if (command.equals("Cancel"))
00317 return;
00318 if (command.equals("Delete")) {
00319 _images.remove(_popupObj);
00320 repaint();
00321 return;
00322 }
00323 if (_methods == null)
00324 return;
00325 for (int i=0; i<_methods.length; i++) {
00326 if (command.equals(_methods[i].getMethodName())) {
00327 CallableMethod actMethod = _methods[i];
00328 if (actMethod.getNumArgs() > 0) {
00329 new JavaFuncDialog(_popupObj, actMethod, this,
00330 "handleJavaFuncDialogOK",false);
00331 } else {
00332 handleJavaFuncDialogOK(_popupObj, actMethod, null);
00333 }
00334 break;
00335 }
00336 }
00337 }
|
|
||||||||||||||||
|
00342 {
00343 method.invoke(target, argVals);
00344 repaint();
00345 }
|
1.2.12 written by Dimitri van Heesch,
© 1997-2001