100 |
100 |
* A component that includes a {@link MapContext MapContext} with support for
|
101 |
101 |
* use it as a particular {@link Behavior Behavior}.
|
102 |
102 |
* </p>
|
103 |
|
*
|
|
103 |
*
|
104 |
104 |
* <p>
|
105 |
105 |
* A developer can register a set of <code>Behavior</code>, but only one (that
|
106 |
106 |
* can be a composition of several) of them can be active. The active one
|
... | ... | |
108 |
108 |
* The active behavior, in combination with the appropriate {@link ToolListener
|
109 |
109 |
* ToolListener} will allow user work with a particular <i>tool</i>.
|
110 |
110 |
* </p>
|
111 |
|
*
|
|
111 |
*
|
112 |
112 |
* <p>
|
113 |
113 |
* All mouse events produced on this component will be delegated to the current
|
114 |
114 |
* active behavior, the <i>currentMapTool</i>.
|
115 |
115 |
* </p>
|
116 |
|
*
|
|
116 |
*
|
117 |
117 |
* <p>
|
118 |
118 |
* <b>Drawing process:</b>
|
119 |
119 |
* </p>
|
120 |
|
*
|
|
120 |
*
|
121 |
121 |
* <p>
|
122 |
122 |
* Uses a double buffer for the drawing process of <code>MapContext</code>'s
|
123 |
123 |
* information.
|
124 |
124 |
* </p>
|
125 |
|
*
|
|
125 |
*
|
126 |
126 |
* <p>
|
127 |
127 |
* If the double buffer wasn't created, creates a new one.
|
128 |
128 |
* </p>
|
129 |
|
*
|
|
129 |
*
|
130 |
130 |
* <p>
|
131 |
131 |
* Paints the component according the following algorithm: <br>
|
132 |
132 |
*   If <i>status</i> is <i>UPDATED</i>:<br>
|
... | ... | |
165 |
165 |
* {@link #drawGraphics() #drawGraphics()}.</li>
|
166 |
166 |
* </ul>
|
167 |
167 |
* </p>
|
168 |
|
*
|
|
168 |
*
|
169 |
169 |
* <p>
|
170 |
170 |
* <b>Tools:</b>
|
171 |
171 |
* </p>
|
172 |
|
*
|
|
172 |
*
|
173 |
173 |
* <p>
|
174 |
174 |
* A developer can:
|
175 |
175 |
* <ul>
|
... | ... | |
215 |
215 |
* #removeCombinedTool()}.</li>
|
216 |
216 |
* </ul>
|
217 |
217 |
* </p>
|
218 |
|
*
|
|
218 |
*
|
219 |
219 |
* <p>
|
220 |
220 |
* <b>Exception listener:</b>
|
221 |
221 |
* </p>
|
222 |
|
*
|
|
222 |
*
|
223 |
223 |
* <p>
|
224 |
224 |
* Adding an <code>ExceptionListener</code>, can get notification about any
|
225 |
225 |
* exception produced:
|
... | ... | |
229 |
229 |
* <li>Applying a <i>zoom in</i> or <i>zoom out</i> operation.</li>
|
230 |
230 |
* </ul>
|
231 |
231 |
* </p>
|
232 |
|
*
|
|
232 |
*
|
233 |
233 |
* <p>
|
234 |
234 |
* <b>Other:</b>
|
235 |
235 |
* </p>
|
236 |
|
*
|
|
236 |
*
|
237 |
237 |
* <p>
|
238 |
238 |
* Other useful capabilities of <code>MapControl</code>:
|
239 |
239 |
* <ul>
|
... | ... | |
246 |
246 |
* a <code>ToolListener</code>): {@link #zoomOut() #zoomOut()}.</li>
|
247 |
247 |
* </ul>
|
248 |
248 |
* </p>
|
249 |
|
*
|
|
249 |
*
|
250 |
250 |
* @see CancelDraw
|
251 |
251 |
* @see Drawer
|
252 |
252 |
* @see MapContextListener
|
253 |
253 |
* @see MapToolListener
|
254 |
|
*
|
|
254 |
*
|
255 |
255 |
* @author Fernando Gonz�lez Cort�s
|
256 |
256 |
* @author Pablo Piqueras Bartolom� (pablo.piqueras@iver.es)
|
257 |
257 |
*/
|
... | ... | |
293 |
293 |
* <code>ViewPort</code> with information to adapt to the bounds available
|
294 |
294 |
* in <i>image coordinates</i>.
|
295 |
295 |
* </p>
|
296 |
|
*
|
|
296 |
*
|
297 |
297 |
* @see #getMapContext()
|
298 |
298 |
* @see #setMapContext(MapContext)
|
299 |
299 |
*/
|
... | ... | |
304 |
304 |
* All registered <code>Behavior</code> that can define a way to work with
|
305 |
305 |
* this <code>MapControl</code>.
|
306 |
306 |
* </p>
|
307 |
|
*
|
|
307 |
*
|
308 |
308 |
* <p>
|
309 |
309 |
* Only one of them can be active at a given moment.
|
310 |
310 |
* </p>
|
311 |
|
*
|
|
311 |
*
|
312 |
312 |
* @see #addBehavior(String, Behavior)
|
313 |
313 |
* @see #addBehavior(String, Behavior[])
|
314 |
314 |
* @see #getMapTool(String)
|
... | ... | |
324 |
324 |
* will simulate to user that works with this component as a particular
|
325 |
325 |
* tool.
|
326 |
326 |
* </p>
|
327 |
|
*
|
|
327 |
*
|
328 |
328 |
* @see #getCurrentMapTool()
|
329 |
329 |
* @see #getCurrentTool()
|
330 |
330 |
* @see #setTool(String)
|
... | ... | |
343 |
343 |
* updated.</li>
|
344 |
344 |
* </ul>
|
345 |
345 |
* </p>
|
346 |
|
*
|
|
346 |
*
|
347 |
347 |
* <p>
|
348 |
348 |
* The <code>MapControl</code> drawing process will consider the value of
|
349 |
349 |
* this parameter to decide which elements will be updated or drawn.
|
... | ... | |
356 |
356 |
* Image with a buffer to accelerate the draw the changes of the graphical
|
357 |
357 |
* items in this component.
|
358 |
358 |
* </p>
|
359 |
|
*
|
|
359 |
*
|
360 |
360 |
* <p>
|
361 |
361 |
* Firstly, information will be drawn in the buffer, and, when is outright
|
362 |
362 |
* drawn, that information will be displayed. Meanwhile, the previous image
|
363 |
363 |
* can be kept showed.
|
364 |
364 |
* </p>
|
365 |
|
*
|
|
365 |
*
|
366 |
366 |
* @see BufferedImage
|
367 |
|
*
|
|
367 |
*
|
368 |
368 |
* @see #getImage()
|
369 |
369 |
*/
|
370 |
370 |
private BufferedImage image = null;
|
... | ... | |
373 |
373 |
* <p>
|
374 |
374 |
* Name of the tool used currently to interact with this component.
|
375 |
375 |
* </p>
|
376 |
|
*
|
|
376 |
*
|
377 |
377 |
* @see #getCurrentTool()
|
378 |
378 |
* @see #setTool(String)
|
379 |
379 |
*/
|
... | ... | |
385 |
385 |
* <code>MapContext</code>'s layers, that must be canceled or can continue
|
386 |
386 |
* with the process.
|
387 |
387 |
* </p>
|
388 |
|
*
|
|
388 |
*
|
389 |
389 |
* @see #cancelDrawing()
|
390 |
390 |
*/
|
391 |
391 |
private CancelDraw canceldraw;
|
... | ... | |
396 |
396 |
* <p>
|
397 |
397 |
* Fires an action events after a specified delay.
|
398 |
398 |
* </p>
|
399 |
|
*
|
|
399 |
*
|
400 |
400 |
* <p>
|
401 |
401 |
* <code>MapControl</code> will use the timer to update its visible
|
402 |
402 |
* graphical information during a drawing process, or allowing to cancel
|
403 |
403 |
* that process.
|
404 |
404 |
* </p>
|
405 |
|
*
|
|
405 |
*
|
406 |
406 |
* <p>
|
407 |
407 |
* This is very useful to pretend faster interactivity to user when
|
408 |
408 |
* <code>MapControl</code> has lots of layers, and / or layers with heavy
|
... | ... | |
416 |
416 |
* Reference to the {@link ViewPort ViewPort} of the {@link MapContext
|
417 |
417 |
* MapContext} of this component.
|
418 |
418 |
* </p>
|
419 |
|
*
|
|
419 |
*
|
420 |
420 |
* <p>
|
421 |
421 |
* After, the view port will change adapting itself according the current
|
422 |
422 |
* projection and the extent.
|
423 |
423 |
* </p>
|
424 |
|
*
|
|
424 |
*
|
425 |
425 |
* @see #getViewPort()
|
426 |
|
*
|
|
426 |
*
|
427 |
427 |
* @see ViewPort
|
428 |
428 |
*/
|
429 |
429 |
protected ViewPort vp;
|
... | ... | |
439 |
439 |
* <p>
|
440 |
440 |
* Listener of all kind of mouse events produced in this component.
|
441 |
441 |
* </p>
|
442 |
|
*
|
|
442 |
*
|
443 |
443 |
* <p>
|
444 |
444 |
* Delegates each mouse event to the current map tool.
|
445 |
445 |
* </p>
|
446 |
|
*
|
|
446 |
*
|
447 |
447 |
* @see #addBehavior(String, Behavior)
|
448 |
448 |
* @see #addBehavior(String, Behavior[])
|
449 |
449 |
* @see #getMapTool(String)
|
... | ... | |
466 |
466 |
* Group of <code>ExceptionListener</code> that, in whatever moment could be
|
467 |
467 |
* notified a Throwable Java error or exception.
|
468 |
468 |
* </p>
|
469 |
|
*
|
|
469 |
*
|
470 |
470 |
* @see #addExceptionListener(ExceptionListener)
|
471 |
471 |
* @see #removeExceptionListener(ExceptionListener)
|
472 |
472 |
*/
|
... | ... | |
491 |
491 |
/**
|
492 |
492 |
* Optional grid that could be applied on the <code>MapControl</code>'s view
|
493 |
493 |
* port.
|
494 |
|
*
|
|
494 |
*
|
495 |
495 |
* @see #getGrid()
|
496 |
496 |
* @see #setAdjustGrid(boolean)
|
497 |
497 |
*/
|
498 |
498 |
private Grid cadgrid = new Grid();
|
499 |
499 |
/**
|
500 |
500 |
* Represents the cursor's point selected in <i>screen coordinates</i>.
|
501 |
|
*
|
|
501 |
*
|
502 |
502 |
* @see ViewPort#fromMapPoint(Point2D)
|
503 |
503 |
*/
|
504 |
504 |
protected Point2D adjustedPoint;
|
... | ... | |
508 |
508 |
* <code>MapControl</code> is within the area around a control point of a
|
509 |
509 |
* geometry.
|
510 |
510 |
* </p>
|
511 |
|
*
|
|
511 |
*
|
512 |
512 |
* <p>
|
513 |
513 |
* The area is calculated as a circle centered at the control point and with
|
514 |
514 |
* radius the pixels tolerance defined in the preferences.
|
... | ... | |
524 |
524 |
|
525 |
525 |
/**
|
526 |
526 |
* Determines if the snap tools are enabled or disabled.
|
527 |
|
*
|
|
527 |
*
|
528 |
528 |
* @see #isRefentEnabled()
|
529 |
529 |
* @see #setRefentEnabled(boolean)
|
530 |
530 |
*/
|
... | ... | |
553 |
553 |
|
554 |
554 |
/**
|
555 |
555 |
* Represents the cursor's point selected in <i>map coordinates</i>.
|
556 |
|
*
|
|
556 |
*
|
557 |
557 |
* @see MapControl#toMapPoint
|
558 |
558 |
*/
|
559 |
559 |
protected Point2D mapAdjustedPoint;
|
... | ... | |
563 |
563 |
*/
|
564 |
564 |
private MapControlDrawer mapControlDrawer = null;
|
565 |
565 |
private Cursor transparentCursor;
|
566 |
|
|
|
566 |
|
567 |
567 |
private boolean disposed = false;
|
568 |
568 |
|
569 |
569 |
/**
|
... | ... | |
596 |
596 |
public MapControl() {
|
597 |
597 |
this(null);
|
598 |
598 |
}
|
599 |
|
|
|
599 |
|
600 |
600 |
public MapControl(MapContext theMapContext) {
|
601 |
601 |
if( theMapContext == null ) {
|
602 |
602 |
theMapContext = new MapContext(new ViewPort(MapContextLocator.getMapContextManager().getDefaultCRS()));
|
... | ... | |
615 |
615 |
canceldraw = new CancelDraw();
|
616 |
616 |
|
617 |
617 |
vp = theMapContext.getViewPort();
|
618 |
|
|
|
618 |
|
619 |
619 |
setMapContext(theMapContext);
|
620 |
620 |
|
621 |
621 |
// eventos
|
... | ... | |
638 |
638 |
}
|
639 |
639 |
});
|
640 |
640 |
initializeGrid();
|
641 |
|
|
|
641 |
|
642 |
642 |
if(ToolsLocator.getDisposableManager() != null) {
|
643 |
643 |
ToolsLocator.getDisposableManager().bind(this);
|
644 |
644 |
} else {
|
... | ... | |
650 |
650 |
* <p>
|
651 |
651 |
* Sets a <code>MapContext</code> to this component.
|
652 |
652 |
* </p>
|
653 |
|
*
|
|
653 |
*
|
654 |
654 |
* <p>
|
655 |
655 |
* The <code>MapContext</code> has the <i>model</i>, and most of the
|
656 |
656 |
* <i>view</i>, and <i>control</i> logic of the layers of this component,
|
657 |
657 |
* including a {@link ViewPort ViewPort} to adapt the information to the
|
658 |
658 |
* projection, and to display it in the available area.
|
659 |
659 |
* </p>
|
660 |
|
*
|
|
660 |
*
|
661 |
661 |
* <p>
|
662 |
662 |
* If <code>model</code> hadn't a <code>ViewPort</code>, assigns the current
|
663 |
663 |
* one to it, otherwise, use its <code>ViewPort</code>.
|
664 |
664 |
* </p>
|
665 |
|
*
|
|
665 |
*
|
666 |
666 |
* <p>
|
667 |
667 |
* After assigning the <code>MapContext</code> and <code>ViewPort</code>,
|
668 |
668 |
* sets the same {@link MapContextListener MapContextListener} that was
|
669 |
669 |
* using, and changes the <i>status</i> to <code>OUTDATED</code>.
|
670 |
670 |
* </p>
|
671 |
|
*
|
|
671 |
*
|
672 |
672 |
* @param model
|
673 |
673 |
* this component's <code>MapContext</code>, that includes the
|
674 |
674 |
* <code>ViewPort</code>.
|
675 |
|
*
|
|
675 |
*
|
676 |
676 |
* @see MapContext
|
677 |
|
*
|
|
677 |
*
|
678 |
678 |
* @see #getMapContext()
|
679 |
679 |
*/
|
680 |
680 |
public void setMapContext(MapContext model) {
|
... | ... | |
717 |
717 |
* <p>
|
718 |
718 |
* Gets this component's {@link MapContext MapContext} projection.
|
719 |
719 |
* </p>
|
720 |
|
*
|
|
720 |
*
|
721 |
721 |
* @return this component's {@link MapContext MapContext} projection
|
722 |
|
*
|
|
722 |
*
|
723 |
723 |
* @see MapContext#getProjection()
|
724 |
724 |
* @see MapControl#setProjection(IProjection)
|
725 |
725 |
*/
|
... | ... | |
731 |
731 |
* <p>
|
732 |
732 |
* Sets the projection to this component's {@link MapContext MapContext}.
|
733 |
733 |
* </p>
|
734 |
|
*
|
|
734 |
*
|
735 |
735 |
* @param proj
|
736 |
736 |
* the kind of projection to this component's {@link MapContext
|
737 |
737 |
* MapContext}
|
738 |
|
*
|
|
738 |
*
|
739 |
739 |
* @see MapContext#setProjection(IProjection)
|
740 |
740 |
* @see MapControl#getProjection()
|
741 |
741 |
*/
|
... | ... | |
750 |
750 |
* component, including a {@link ViewPort ViewPort} to adapt the information
|
751 |
751 |
* to the projection, and display it in the available area.
|
752 |
752 |
* </p>
|
753 |
|
*
|
|
753 |
*
|
754 |
754 |
* @return this component's <code>MapContext</code>, that includes the
|
755 |
755 |
* <code>ViewPort</code> used to project the
|
756 |
756 |
* graphical information, and display it in the available area
|
757 |
|
*
|
|
757 |
*
|
758 |
758 |
* @see MapContext
|
759 |
|
*
|
|
759 |
*
|
760 |
760 |
* @see MapControl#setMapContext(MapContext)
|
761 |
761 |
*/
|
762 |
762 |
public MapContext getMapContext() {
|
... | ... | |
767 |
767 |
* <p>
|
768 |
768 |
* Registers a new behavior to this component.
|
769 |
769 |
* </p>
|
770 |
|
*
|
|
770 |
*
|
771 |
771 |
* <p>
|
772 |
772 |
* According the nature of the {@link Behavior Behavior}, different events
|
773 |
773 |
* will be generated. Those events can be caught by a particular
|
774 |
774 |
* {@link ToolListener ToolListener}, allowing user to interact with this
|
775 |
775 |
* <code>MapControl</code> object as a <i>tool</i>.
|
776 |
776 |
* </p>
|
777 |
|
*
|
|
777 |
*
|
778 |
778 |
* @param name
|
779 |
779 |
* name to identify the behavior to add
|
780 |
780 |
* @param tool
|
781 |
781 |
* the behavior to add
|
782 |
|
*
|
|
782 |
*
|
783 |
783 |
* @see #addBehavior(String, Behavior[])
|
784 |
784 |
* @see #getNamesMapTools()
|
785 |
785 |
* @see #getMapToolsKeySet()
|
... | ... | |
795 |
795 |
* Registers a new behavior to this component as a {@link CompoundBehavior
|
796 |
796 |
* CompoundBehavior} made up of <code>tools</code>.
|
797 |
797 |
* </p>
|
798 |
|
*
|
|
798 |
*
|
799 |
799 |
* <p>
|
800 |
800 |
* According the nature of the behaviors registered, different events will
|
801 |
801 |
* be generated. Those events can be caught by a particular
|
802 |
802 |
* {@link ToolListener ToolListener}, allowing user to interact with this
|
803 |
803 |
* <code>MapControl</code> object as a <i>tool</i>.
|
804 |
804 |
* </p>
|
805 |
|
*
|
|
805 |
*
|
806 |
806 |
* @param name
|
807 |
807 |
* name to identify the compound behavior to add
|
808 |
808 |
* @param tools
|
809 |
809 |
* the compound behavior to add
|
810 |
|
*
|
|
810 |
*
|
811 |
811 |
* @see #addBehavior(String, Behavior)
|
812 |
812 |
* @see #getNamesMapTools()
|
813 |
813 |
* @see #getMapToolsKeySet()
|
... | ... | |
815 |
815 |
*/
|
816 |
816 |
public void addBehavior(String name, Behavior[] tools) {
|
817 |
817 |
CompoundBehavior tool = new CompoundBehavior(tools);
|
|
818 |
tool.setMapControl(this);
|
818 |
819 |
addBehavior(name, tool);
|
819 |
820 |
}
|
820 |
821 |
|
... | ... | |
823 |
824 |
* Gets the <code>Behavior</code> registered in this component, identified
|
824 |
825 |
* by <code>name</code>.
|
825 |
826 |
* </p>
|
826 |
|
*
|
|
827 |
*
|
827 |
828 |
* @param name
|
828 |
829 |
* name of a registered behavior
|
829 |
|
*
|
|
830 |
*
|
830 |
831 |
* @return tool the registered behavior in this component as
|
831 |
832 |
* <code>name</code>, or <code>null</code> if
|
832 |
833 |
* no one has that identifier
|
833 |
|
*
|
|
834 |
*
|
834 |
835 |
* @see #addBehavior(String, Behavior)
|
835 |
836 |
* @see #addBehavior(String, Behavior[])
|
836 |
837 |
* @see #hasTool(String)
|
... | ... | |
843 |
844 |
* <p>
|
844 |
845 |
* Returns a set view of the keys that identified the tools registered.
|
845 |
846 |
* </p>
|
846 |
|
*
|
|
847 |
*
|
847 |
848 |
* @return a set view of the keys that identified the tools registered
|
848 |
|
*
|
|
849 |
*
|
849 |
850 |
* @see HashMap#keySet()
|
850 |
|
*
|
|
851 |
*
|
851 |
852 |
* @see #getNamesMapTools()
|
852 |
853 |
* @see #addBehavior(String, Behavior)
|
853 |
854 |
* @see #addBehavior(String, Behavior[])
|
... | ... | |
861 |
862 |
* Returns <code>true</code> if this component contains a tool identified by
|
862 |
863 |
* <code>toolName</code>.
|
863 |
864 |
* </p>
|
864 |
|
*
|
|
865 |
*
|
865 |
866 |
* @param toolName
|
866 |
867 |
* identifier of the tool
|
867 |
|
*
|
|
868 |
*
|
868 |
869 |
* @return <code>true</code> if this component contains a tool identified by
|
869 |
870 |
* <code>toolName</code>; otherwise <code>false</code>
|
870 |
|
*
|
|
871 |
*
|
871 |
872 |
* @see #addBehavior(String, Behavior)
|
872 |
873 |
* @see #addBehavior(String, Behavior[])
|
873 |
874 |
*/
|
... | ... | |
881 |
882 |
* component, that one which is registered and identified by
|
882 |
883 |
* <code>toolName</code>.
|
883 |
884 |
* </p>
|
884 |
|
*
|
|
885 |
*
|
885 |
886 |
* <p>
|
886 |
887 |
* Changing the current active behavior for this <code>MapControl</code>,
|
887 |
888 |
* implies also updating the previous <i>behavior</i> tool, and the current
|
888 |
889 |
* cursor.
|
889 |
890 |
* </p>
|
890 |
|
*
|
|
891 |
*
|
891 |
892 |
* @param toolName
|
892 |
893 |
* name of a registered behavior
|
893 |
|
*
|
|
894 |
*
|
894 |
895 |
* @see #getCurrentMapTool()
|
895 |
896 |
* @see #getCurrentTool()
|
896 |
897 |
*/
|
... | ... | |
908 |
909 |
new CompoundBehavior(new Behavior[] { currentMapTool });
|
909 |
910 |
((CompoundBehavior) currentMapTool).addMapBehavior(
|
910 |
911 |
combinedTool, true);
|
|
912 |
currentMapTool.setMapControl(this);
|
911 |
913 |
}
|
912 |
914 |
}
|
913 |
915 |
|
... | ... | |
920 |
922 |
* component, that one which is registered and identified by
|
921 |
923 |
* <code>toolName</code>.
|
922 |
924 |
* </p>
|
923 |
|
*
|
|
925 |
*
|
924 |
926 |
* <p>
|
925 |
927 |
* Changing the current active behavior for this <code>MapControl</code>,
|
926 |
928 |
* implies also updating the previous <i>behavior</i> tool, and the current
|
927 |
929 |
* cursor.
|
928 |
930 |
* </p>
|
929 |
|
*
|
|
931 |
*
|
930 |
932 |
* @param toolName
|
931 |
933 |
* name of a registered behavior
|
932 |
|
*
|
|
934 |
*
|
933 |
935 |
* @see #getCurrentTool()
|
934 |
936 |
* @see #setTool(String)
|
935 |
937 |
*/
|
... | ... | |
941 |
943 |
* <p>
|
942 |
944 |
* Returns the name of the current selected tool on this MapControl
|
943 |
945 |
* </p>
|
944 |
|
*
|
|
946 |
*
|
945 |
947 |
* @return the name of the current's behavior tool associated to this
|
946 |
948 |
* component
|
947 |
|
*
|
|
949 |
*
|
948 |
950 |
* @see #getCurrentMapTool()
|
949 |
951 |
* @see #setTool(String)
|
950 |
952 |
*/
|
... | ... | |
957 |
959 |
* Determines that current drawing process of <code>MapControl</code>'s
|
958 |
960 |
* <code>MapContext</code>'s data must be canceled.
|
959 |
961 |
* </p>
|
960 |
|
*
|
|
962 |
*
|
961 |
963 |
* <p>
|
962 |
964 |
* It has no effects if now isn't drawing that graphical information.
|
963 |
965 |
* </p>
|
964 |
|
*
|
|
966 |
*
|
965 |
967 |
* <p>
|
966 |
968 |
* At last resort, the particular implementation of each layer in this
|
967 |
969 |
* <code>MapControl</code>'s <code>MapContrext</code> will be that one which
|
... | ... | |
984 |
986 |
* if (!drawer.isAlive()) {
|
985 |
987 |
* // Si hemos llegado aqu� con un thread vivo, seguramente
|
986 |
988 |
* // no estamos actualizados.
|
987 |
|
*
|
|
989 |
*
|
988 |
990 |
* break;
|
989 |
991 |
* }
|
990 |
|
*
|
|
992 |
*
|
991 |
993 |
* }
|
992 |
994 |
* canceldraw.setCancel(false);
|
993 |
995 |
* isCancelled = false;
|
... | ... | |
1003 |
1005 |
* with the vieport's background color, or with <i>white</i> if it had no
|
1004 |
1006 |
* background color.
|
1005 |
1007 |
* </p>
|
1006 |
|
*
|
|
1008 |
*
|
1007 |
1009 |
* <p>
|
1008 |
1010 |
* If no double-buffered existed, creates a {@link BufferedImage
|
1009 |
1011 |
* BufferedImage} with the size of this component, and as an image with
|
... | ... | |
1011 |
1013 |
* <code>DirectColorModel</code> with alpha. The color data in that image is
|
1012 |
1014 |
* considered not to be premultiplied with alpha.
|
1013 |
1015 |
* </p>
|
1014 |
|
*
|
|
1016 |
*
|
1015 |
1017 |
* <p>
|
1016 |
1018 |
* Once has created and filled the new inner <code>MapControl</code>'s
|
1017 |
1019 |
* double-buffer, changes the status to <code>OUTDATED</code>.
|
1018 |
1020 |
* </p>
|
1019 |
|
*
|
|
1021 |
*
|
1020 |
1022 |
* @return <code>true</code> if has created and filled a new double-buffer
|
1021 |
1023 |
* for this <code>MapControl</code> instance; otherwise
|
1022 |
1024 |
* <code>false</code>
|
... | ... | |
1055 |
1057 |
* <p>
|
1056 |
1058 |
* Paints the graphical information of this component using a double buffer.
|
1057 |
1059 |
* </p>
|
1058 |
|
*
|
|
1060 |
*
|
1059 |
1061 |
* <p>
|
1060 |
1062 |
* If the double buffer wasn't created, creates a new one.
|
1061 |
1063 |
* </p>
|
1062 |
|
*
|
|
1064 |
*
|
1063 |
1065 |
* <p>
|
1064 |
1066 |
* Paints the component according the following algorithm: <br>
|
1065 |
1067 |
*   If <i>status</i> is <i>UPDATED</i>:<br>
|
... | ... | |
1079 |
1081 |
* comprises invoke this method) the view every delay of 360 ms. during the
|
1080 |
1082 |
* the process drawing.
|
1081 |
1083 |
* </p>
|
1082 |
|
*
|
|
1084 |
*
|
1083 |
1085 |
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
|
1084 |
1086 |
* @see Drawer2
|
1085 |
1087 |
*/
|
... | ... | |
1103 |
1105 |
*/
|
1104 |
1106 |
if (image != null) {
|
1105 |
1107 |
if (currentMapTool != null) {
|
1106 |
|
currentMapTool.paintComponent(mapControlDrawer);
|
|
1108 |
currentMapTool.paintComponent(mapControlDrawer,true);
|
1107 |
1109 |
} else {
|
1108 |
1110 |
mapControlDrawer.drawImage(image, 0, 0);
|
1109 |
1111 |
}
|
... | ... | |
1134 |
1136 |
* Gets the {@link BufferedImage BufferedImage} used to accelerate the draw
|
1135 |
1137 |
* of new ''frames'' with changes, or new graphical items in this component.
|
1136 |
1138 |
* </p>
|
1137 |
|
*
|
|
1139 |
*
|
1138 |
1140 |
* @return double buffered image used by this component to accelerate the
|
1139 |
1141 |
* draw of its graphical information, or <code>null</code> if isn't
|
1140 |
1142 |
* already created
|
1141 |
|
*
|
|
1143 |
*
|
1142 |
1144 |
* @see BufferedImage
|
1143 |
1145 |
*/
|
1144 |
1146 |
public BufferedImage getImage() {
|
... | ... | |
1149 |
1151 |
* <p>
|
1150 |
1152 |
* Forces repaint all visible graphical information in this component.
|
1151 |
1153 |
* </p>
|
1152 |
|
*
|
|
1154 |
*
|
1153 |
1155 |
* <p>
|
1154 |
1156 |
* If <code>doClear == true</code>, before repainting, clears the background
|
1155 |
1157 |
* color, with the inner viewport's background color.
|
1156 |
1158 |
* </p>
|
1157 |
|
*
|
|
1159 |
*
|
1158 |
1160 |
* @param doClear
|
1159 |
1161 |
* <code>true</code> if needs clearing the background color
|
1160 |
1162 |
* before drawing the map
|
1161 |
|
*
|
|
1163 |
*
|
1162 |
1164 |
* @see #cancelDrawing()
|
1163 |
1165 |
* @see FLayers#setDirty(boolean)
|
1164 |
1166 |
*/
|
... | ... | |
1188 |
1190 |
* Cancels any current drawing process, changing the status to
|
1189 |
1191 |
* <code>OUTDATED</code>, and forcing repaint only the layers dirty.
|
1190 |
1192 |
* </p>
|
1191 |
|
*
|
|
1193 |
*
|
1192 |
1194 |
* @see #cancelDrawing()
|
1193 |
1195 |
*/
|
1194 |
1196 |
public void rePaintDirtyLayers() {
|
... | ... | |
1266 |
1268 |
* <p>
|
1267 |
1269 |
* Represents each <code>MapControl</code>'s data painting request.
|
1268 |
1270 |
* </p>
|
1269 |
|
*
|
|
1271 |
*
|
1270 |
1272 |
* <p>
|
1271 |
1273 |
* The request will be attended by a <code>Drawer2</code>, which will hold
|
1272 |
1274 |
* it since the <code>Drawer2</code>'s worker takes it, or arrives a new
|
... | ... | |
1288 |
1290 |
* <p>
|
1289 |
1291 |
* <code>MapControl</code> paint process:
|
1290 |
1292 |
* </p>
|
1291 |
|
*
|
|
1293 |
*
|
1292 |
1294 |
* <p>
|
1293 |
1295 |
* <ul>
|
1294 |
1296 |
* <li><i>1.- </i>Cancels all previous <code>MapControl</code>'s drawing
|
... | ... | |
1314 |
1316 |
* <code>repaint();</code></li>
|
1315 |
1317 |
* </ul>
|
1316 |
1318 |
* </p>
|
1317 |
|
*
|
|
1319 |
*
|
1318 |
1320 |
* @see #cancelDrawing()
|
1319 |
1321 |
* @see MapContext#draw(BufferedImage, Graphics2D, Cancellable, double)
|
1320 |
1322 |
* @see MapContext#drawGraphics(BufferedImage, Graphics2D, Cancellable,
|
1321 |
1323 |
* double)
|
1322 |
|
*
|
|
1324 |
*
|
1323 |
1325 |
* @see ViewPort
|
1324 |
1326 |
*/
|
1325 |
1327 |
public void paint() {
|
... | ... | |
1353 |
1355 |
timer.stop();
|
1354 |
1356 |
LOG.warn("Problems drawing mapcontext.",e);
|
1355 |
1357 |
throwException(e);
|
1356 |
|
}
|
|
1358 |
}
|
1357 |
1359 |
}
|
1358 |
1360 |
}
|
1359 |
1361 |
|
... | ... | |
1362 |
1364 |
* An instance of <code>Drawer2</code> could manage all
|
1363 |
1365 |
* <code>MapControl</code> painting requests.
|
1364 |
1366 |
* </p>
|
1365 |
|
*
|
|
1367 |
*
|
1366 |
1368 |
* <p>
|
1367 |
1369 |
* Based on the <i>WorkerThread</i> software pattern, creates a worker
|
1368 |
1370 |
* thread that will attend sequentially the current waiting painting
|
1369 |
1371 |
* request, after finishing the previous (that could be by a cancel action).
|
1370 |
1372 |
* </p>
|
1371 |
|
*
|
|
1373 |
*
|
1372 |
1374 |
* <p>
|
1373 |
1375 |
* All new {@link PaintingRequest PaintingRequest} generated will be stored
|
1374 |
1376 |
* as <i>waiting requests</i> since the worker attends it.
|
1375 |
1377 |
* </p>
|
1376 |
|
*
|
|
1378 |
*
|
1377 |
1379 |
* <p>
|
1378 |
1380 |
* If a worker finished and there was no <i>painting request</i>, the worker
|
1379 |
1381 |
* would be set to wait until any <i>painting request</i> would be put.
|
1380 |
1382 |
* </p>
|
1381 |
|
*
|
|
1383 |
*
|
1382 |
1384 |
* @author fjp
|
1383 |
1385 |
*/
|
1384 |
1386 |
public class Drawer {
|
... | ... | |
1391 |
1393 |
* Painting request that's been attended by the <code>Drawer2</code>'s
|
1392 |
1394 |
* worker.
|
1393 |
1395 |
* </p>
|
1394 |
|
*
|
|
1396 |
*
|
1395 |
1397 |
* @see #put(org.gvsig.fmap.mapcontrol.MapControl.PaintingRequest)
|
1396 |
1398 |
* @see #take()
|
1397 |
1399 |
*/
|
... | ... | |
1402 |
1404 |
* Painting request waiting to be attended by the <code>Drawer2</code>'s
|
1403 |
1405 |
* worker.
|
1404 |
1406 |
* </p>
|
1405 |
|
*
|
|
1407 |
*
|
1406 |
1408 |
* @see #put(org.gvsig.fmap.mapcontrol.MapControl.PaintingRequest)
|
1407 |
1409 |
* @see #take()
|
1408 |
1410 |
*/
|
... | ... | |
1413 |
1415 |
* Determines that the <code>Drawer2</code>'s worker is busy attending a
|
1414 |
1416 |
* painting request.
|
1415 |
1417 |
* </p>
|
1416 |
|
*
|
|
1418 |
*
|
1417 |
1419 |
* @see #put(org.gvsig.fmap.mapcontrol.MapControl.PaintingRequest)
|
1418 |
1420 |
* @see #take()
|
1419 |
1421 |
*/
|
... | ... | |
1424 |
1426 |
* Notifies the <code>Drawer2</code>'s worker to finish or continue with
|
1425 |
1427 |
* its process.
|
1426 |
1428 |
* </p>
|
1427 |
|
*
|
|
1429 |
*
|
1428 |
1430 |
* @see #setShutdown(boolean)
|
1429 |
1431 |
*/
|
1430 |
1432 |
private boolean shutdown;
|
... | ... | |
1436 |
1438 |
* Sets this <code>Drawer2</code>'s worker to finish or continue with
|
1437 |
1439 |
* its process.
|
1438 |
1440 |
* </p>
|
1439 |
|
*
|
|
1441 |
*
|
1440 |
1442 |
* @param isShutdown
|
1441 |
1443 |
* a boolean value
|
1442 |
1444 |
*/
|
... | ... | |
1452 |
1454 |
* Creates a new drawer for managing all data painting requests in
|
1453 |
1455 |
* <code>MapControl</code>.
|
1454 |
1456 |
* </p>
|
1455 |
|
*
|
|
1457 |
*
|
1456 |
1458 |
* <p>
|
1457 |
1459 |
* Includes the following steps:
|
1458 |
1460 |
* <ul>
|
... | ... | |
1480 |
1482 |
* Sets a <code>PaintingRequest</code> to be attended by the worker
|
1481 |
1483 |
* thread of this object. If this one was waiting, wakes up.
|
1482 |
1484 |
* </p>
|
1483 |
|
*
|
|
1485 |
*
|
1484 |
1486 |
* <p>
|
1485 |
1487 |
* All waiting threads will be notified synchronized.
|
1486 |
1488 |
* </p>
|
1487 |
|
*
|
|
1489 |
*
|
1488 |
1490 |
* @param newPaintRequest
|
1489 |
|
*
|
|
1491 |
*
|
1490 |
1492 |
* @see #take()
|
1491 |
1493 |
*/
|
1492 |
1494 |
public void put(PaintingRequest newPaintRequest) {
|
... | ... | |
1506 |
1508 |
* #put(com.iver.cit.gvsig.fmap.MapControl.PaintingRequest)}, if there
|
1507 |
1509 |
* was no waiting request.
|
1508 |
1510 |
* </p>
|
1509 |
|
*
|
|
1511 |
*
|
1510 |
1512 |
* <p>
|
1511 |
1513 |
* All threads will access synchronized to the waiting request.
|
1512 |
1514 |
* </p>
|
1513 |
|
*
|
|
1515 |
*
|
1514 |
1516 |
* @return <code>PaintingRequest</code> that was waiting to be attended
|
1515 |
|
*
|
|
1517 |
*
|
1516 |
1518 |
* @see #put(org.gvsig.fmap.mapcontrol.MapControl.PaintingRequest)
|
1517 |
1519 |
*/
|
1518 |
1520 |
public PaintingRequest take() {
|
... | ... | |
1535 |
1537 |
* <p>
|
1536 |
1538 |
* Thread for attending painting requests.
|
1537 |
1539 |
* </p>
|
1538 |
|
*
|
|
1540 |
*
|
1539 |
1541 |
* <p>
|
1540 |
1542 |
* If there was no double buffer, sets the status to
|
1541 |
1543 |
* <code>OUTDATED</code> and finishes, otherwise takes the painting
|
1542 |
1544 |
* request (it's probably that would wait some time), cancel the
|
1543 |
1545 |
* previous drawing process, and starts processing the request.
|
1544 |
1546 |
* </p>
|
1545 |
|
*
|
|
1547 |
*
|
1546 |
1548 |
* @see Thread
|
1547 |
1549 |
*/
|
1548 |
1550 |
private class Worker implements Runnable {
|
1549 |
1551 |
|
1550 |
1552 |
/*
|
1551 |
1553 |
* (non-Javadoc)
|
1552 |
|
*
|
|
1554 |
*
|
1553 |
1555 |
* @see java.lang.Runnable#run()
|
1554 |
1556 |
*/
|
1555 |
1557 |
public void run() {
|
... | ... | |
1575 |
1577 |
* <code>MapControl</code>'s <code>MapContext</code> layers, allowing
|
1576 |
1578 |
* receive a notification that, when they're been drawn, to be cancelled.
|
1577 |
1579 |
* </p>
|
1578 |
|
*
|
|
1580 |
*
|
1579 |
1581 |
* @see Cancellable
|
1580 |
|
*
|
|
1582 |
*
|
1581 |
1583 |
* @author Fernando Gonz�lez Cort�s
|
1582 |
1584 |
*/
|
1583 |
1585 |
public class CancelDraw implements Cancellable {
|
... | ... | |
1586 |
1588 |
* <p>
|
1587 |
1589 |
* Determines if the drawing task must be canceled or not.
|
1588 |
1590 |
* </p>
|
1589 |
|
*
|
|
1591 |
*
|
1590 |
1592 |
* @see #isCanceled()
|
1591 |
1593 |
* @see #setCanceled(boolean)
|
1592 |
1594 |
*/
|
... | ... | |
1600 |
1602 |
|
1601 |
1603 |
/*
|
1602 |
1604 |
* (non-Javadoc)
|
1603 |
|
*
|
|
1605 |
*
|
1604 |
1606 |
* @see com.iver.utiles.swing.threads.Cancellable#setCanceled(boolean)
|
1605 |
1607 |
*/
|
1606 |
1608 |
public void setCanceled(boolean b) {
|
... | ... | |
1609 |
1611 |
|
1610 |
1612 |
/*
|
1611 |
1613 |
* (non-Javadoc)
|
1612 |
|
*
|
|
1614 |
*
|
1613 |
1615 |
* @see com.iver.utiles.swing.threads.Cancellable#isCanceled()
|
1614 |
1616 |
*/
|
1615 |
1617 |
public boolean isCanceled() {
|
... | ... | |
1624 |
1626 |
* {@link MapControl#getCurrentMapTool() MapControl#getCurrentMapTool()}</i>
|
1625 |
1627 |
* to simulate a behavior.
|
1626 |
1628 |
* </p>
|
1627 |
|
*
|
|
1629 |
*
|
1628 |
1630 |
* <p>
|
1629 |
1631 |
* Mouse wheel moved events produce a <i>zoom in</i> operation if wheel
|
1630 |
1632 |
* rotation is negative, or a <i>zoom out</i> if its positive. Both will be
|
... | ... | |
1632 |
1634 |
* operation applies a factor of 0.9, <i>zoom out</i> operation applies a
|
1633 |
1635 |
* factor of 1.2
|
1634 |
1636 |
* </p>
|
1635 |
|
*
|
|
1637 |
*
|
1636 |
1638 |
* <p>
|
1637 |
1639 |
* Mouse wheel moved events can be produced as much frequently, that between
|
1638 |
1640 |
* each one, the drawing process could hadn't finished. This is the reason
|
... | ... | |
1640 |
1642 |
* before applying a <i>zoom</i> operation, and ignores all new mouse
|
1641 |
1643 |
* positions that are produced before 1 second.
|
1642 |
1644 |
* </p>
|
1643 |
|
*
|
|
1645 |
*
|
1644 |
1646 |
* @author Fernando Gonz�lez Cort�s
|
1645 |
1647 |
*/
|
1646 |
1648 |
public class MapToolListener implements MouseListener, MouseWheelListener,
|
... | ... | |
1650 |
1652 |
* <p>
|
1651 |
1653 |
* Used to avoid mouse wheel move events closed.
|
1652 |
1654 |
* </p>
|
1653 |
|
*
|
|
1655 |
*
|
1654 |
1656 |
* <p>
|
1655 |
1657 |
* If a mouse wheel move event is produced
|
1656 |
1658 |
*/
|
... | ... | |
1660 |
1662 |
* <p>
|
1661 |
1663 |
* Position of the mouse, in map coordinates.
|
1662 |
1664 |
* </p>
|
1663 |
|
*
|
|
1665 |
*
|
1664 |
1666 |
* <p>
|
1665 |
1667 |
* This point coordinates will be used as center of the <i>zoom</i>
|
1666 |
1668 |
* operation.
|
... | ... | |
1683 |
1685 |
p = mapAdjustedPoint;
|
1684 |
1686 |
} else {
|
1685 |
1687 |
p = vp.toMapPoint(adjustedPoint);
|
1686 |
|
}
|
1687 |
|
previousPoint = new double[] { p.getX(), p.getY() };
|
|
1688 |
}
|
|
1689 |
previousPoint = new double[] { p.getX(), p.getY() };
|
1688 |
1690 |
} catch (BehaviorException t) {
|
1689 |
1691 |
throwException(t);
|
1690 |
1692 |
}
|
... | ... | |
1879 |
1881 |
* <code>AtomicEvent</code> parameter.</li>
|
1880 |
1882 |
* </ul>
|
1881 |
1883 |
* </p>
|
1882 |
|
*
|
|
1884 |
*
|
1883 |
1885 |
* @author Fernando Gonz�lez Cort�s
|
1884 |
1886 |
*/
|
1885 |
1887 |
public class MapContextListener implements AtomicEventListener {
|
... | ... | |
1953 |
1955 |
* Gets the <code>ViewPort</code> of this component's {@link MapContext
|
1954 |
1956 |
* MapContext} .
|
1955 |
1957 |
* </p>
|
1956 |
|
*
|
|
1958 |
*
|
1957 |
1959 |
* @see MapContext#getViewPort()
|
1958 |
1960 |
*/
|
1959 |
1961 |
public ViewPort getViewPort() {
|
... | ... | |
1965 |
1967 |
* Returns all registered <code>Behavior</code> that can define a way to
|
1966 |
1968 |
* work with this <code>MapControl</code>.
|
1967 |
1969 |
* </p>
|
1968 |
|
*
|
|
1970 |
*
|
1969 |
1971 |
* @return registered <code>Behavior</code> to this <code>MapControl</code>
|
1970 |
|
*
|
|
1972 |
*
|
1971 |
1973 |
* @see #addBehavior(String, Behavior)
|
1972 |
1974 |
* @see #addBehavior(String, Behavior[])
|
1973 |
1975 |
* @see #getMapToolsKeySet()
|
... | ... | |
1979 |
1981 |
|
1980 |
1982 |
/*
|
1981 |
1983 |
* (non-Javadoc)
|
1982 |
|
*
|
|
1984 |
*
|
1983 |
1985 |
* @see
|
1984 |
1986 |
* com.iver.cit.gvsig.fmap.edition.commands.CommandListener#commandRepaint()
|
1985 |
1987 |
*/
|
... | ... | |
1989 |
1991 |
|
1990 |
1992 |
/*
|
1991 |
1993 |
* (non-Javadoc)
|
1992 |
|
*
|
|
1994 |
*
|
1993 |
1995 |
* @see
|
1994 |
1996 |
* com.iver.cit.gvsig.fmap.edition.commands.CommandListener#commandRefresh()
|
1995 |
1997 |
*/
|
... | ... | |
2001 |
2003 |
* <p>
|
2002 |
2004 |
* Equivalent operation to <i>undo</i>.
|
2003 |
2005 |
* </p>
|
2004 |
|
*
|
|
2006 |
*
|
2005 |
2007 |
* <p>
|
2006 |
2008 |
* Exchanges the previous tool with the current one.
|
2007 |
2009 |
* </p>
|
2008 |
|
*
|
|
2010 |
*
|
2009 |
2011 |
* @see #addBehavior(String, Behavior)
|
2010 |
2012 |
* @see #addBehavior(String, Behavior[])
|
2011 |
2013 |
* @see #setTool(String)
|
... | ... | |
2018 |
2020 |
* <p>
|
2019 |
2021 |
* Executes a <i>zoom in</i> operation centered at the center of the extent.
|
2020 |
2022 |
* </p>
|
2021 |
|
*
|
|
2023 |
*
|
2022 |
2024 |
* <p>
|
2023 |
2025 |
* This implementation is designed for being invoked outside a
|
2024 |
2026 |
* <code>Behavior</code>, for example by an action of pressing a button; and
|
... | ... | |
2027 |
2029 |
* <code>MapControl</code> object that's responsible for the <i>zoom in</i>
|
2028 |
2030 |
* operation.
|
2029 |
2031 |
* </p>
|
2030 |
|
*
|
|
2032 |
*
|
2031 |
2033 |
* @see #zoomOut()
|
2032 |
2034 |
*/
|
2033 |
2035 |
public void zoomIn() {
|
... | ... | |
2052 |
2054 |
* Executes a <i>zoom out</i> operation centered at the center of the
|
2053 |
2055 |
* extent.
|
2054 |
2056 |
* </p>
|
2055 |
|
*
|
|
2057 |
*
|
2056 |
2058 |
* <p>
|
2057 |
2059 |
* This implementation is thought for being invoked outside a
|
2058 |
2060 |
* <code>Behavior</code>, for example by an action of pressing a button, and
|
... | ... | |
2061 |
2063 |
* <code>MapControl</code> object that's responsible for the <i>zoom out</i>
|
2062 |
2064 |
* operation.
|
2063 |
2065 |
* </p>
|
2064 |
|
*
|
|
2066 |
*
|
2065 |
2067 |
* @see #zoomIn()
|
2066 |
2068 |
*/
|
2067 |
2069 |
public void zoomOut() {
|
... | ... | |
2087 |
2089 |
* <code>MapControl</code> instance and that redirects the calls to the
|
2088 |
2090 |
* current map tool.
|
2089 |
2091 |
* </p>
|
2090 |
|
*
|
|
2092 |
*
|
2091 |
2093 |
* @return the map tool listener used
|
2092 |
2094 |
*/
|
2093 |
2095 |
public MapToolListener getMapToolListener() {
|
... | ... | |
2099 |
2101 |
* <p>
|
2100 |
2102 |
* Sets <code>mapTool</code> as this <code>MapControl</code>'s current map
|
2101 |
2103 |
* tool.
|
2102 |
|
*
|
|
2104 |
*
|
2103 |
2105 |
* @param mapTool
|
2104 |
2106 |
* a map tool, or <code>null</code> to disable the interaction
|
2105 |
2107 |
* with the user
|
2106 |
|
*
|
|
2108 |
*
|
2107 |
2109 |
* @see #getCurrentMapTool()
|
2108 |
2110 |
* @see #getCurrentTool()
|
2109 |
2111 |
* @see #setTool(String)
|
... | ... | |
2120 |
2122 |
* Sets the delay to the timer that refreshes this <code>MapControl</code>
|
2121 |
2123 |
* instance.
|
2122 |
2124 |
* </p>
|
2123 |
|
*
|
|
2125 |
*
|
2124 |
2126 |
* <p>
|
2125 |
2127 |
* <code>Delay (in ms) = 1000 / getDrawFrameRate()</code>
|
2126 |
2128 |
* </p>
|
2127 |
|
*
|
|
2129 |
*
|
2128 |
2130 |
* @see #getDrawFrameRate()
|
2129 |
2131 |
* @see #setDrawFrameRate(int)
|
2130 |
2132 |
*/
|
... | ... | |
2139 |
2141 |
* Determines if its enabled the repaint that invokes the timer according to
|
2140 |
2142 |
* {@link #getDrawFrameRate() #getDrawFrameRate()}.
|
2141 |
2143 |
* </p>
|
2142 |
|
*
|
|
2144 |
*
|
2143 |
2145 |
* @return <code>true</code> if its enabled; otherwise <code>false</code>
|
2144 |
2146 |
*/
|
2145 |
2147 |
public static boolean isDrawAnimationEnabled() {
|
... | ... | |
2151 |
2153 |
* Sets if its enabled the repaint that invokes the timer according to
|
2152 |
2154 |
* {@link #getDrawFrameRate() #getDrawFrameRate()}.
|
2153 |
2155 |
* </p>
|
2154 |
|
*
|
|
2156 |
*
|
2155 |
2157 |
* @param drawAnimationEnabled
|
2156 |
2158 |
* <code>true</code> to enable the mode; otherwise
|
2157 |
2159 |
* <code>false</code>
|
... | ... | |
2165 |
2167 |
* Gets the shared object that determines if a drawing process must be
|
2166 |
2168 |
* cancelled or can continue.
|
2167 |
2169 |
* </p>
|
2168 |
|
*
|
|
2170 |
*
|
2169 |
2171 |
* @return the shared object that determines if a drawing process must be
|
2170 |
2172 |
* cancelled or can continue
|
2171 |
2173 |
*/
|
... | ... | |
2178 |
2180 |
* Gets the tool used in combination with the current tool of this
|
2179 |
2181 |
* <code>MapControl</code>.
|
2180 |
2182 |
* </p>
|
2181 |
|
*
|
|
2183 |
*
|
2182 |
2184 |
* @return the tool used in combination with the <code>currentMapTool</code>
|
2183 |
2185 |
* ; <code>null</code> if there is
|
2184 |
2186 |
* no combined tool
|
... | ... | |
2192 |
2194 |
* Sets a tool to be used in combination with the current tool of this
|
2193 |
2195 |
* <code>MapControl</code>.
|
2194 |
2196 |
* </p>
|
2195 |
|
*
|
|
2197 |
*
|
2196 |
2198 |
* @param combinedTool
|
2197 |
2199 |
* a tool to be used in combination with the current tool of
|
2198 |
2200 |
* <code>MapControl</code>
|
... | ... | |
2228 |
2230 |
* If <code>tool</code> was already stored as a combined tool, doesn't adds
|
2229 |
2231 |
* it.
|
2230 |
2232 |
* </p>
|
2231 |
|
*
|
|
2233 |
*
|
2232 |
2234 |
* @param tool
|
2233 |
2235 |
* a new tool to be used combined with the current tool
|
2234 |
2236 |
*/
|
... | ... | |
2251 |
2253 |
combinedTool =
|
2252 |
2254 |
new CompoundBehavior(new Behavior[] { combinedTool });
|
2253 |
2255 |
((CompoundBehavior) combinedTool).addMapBehavior(tool, true);
|
|
2256 |
combinedTool.setMapControl(this);
|
2254 |
2257 |
}
|
2255 |
2258 |
}
|
2256 |
2259 |
|
... | ... | |
2297 |
2300 |
* {@link com.iver.cit.gvsig.gui.cad.CADToolAdapter.prefs.Preferences
|
2298 |
2301 |
* com.iver.cit.gvsig.gui.cad.CADToolAdapter.prefs.Preferences}.
|
2299 |
2302 |
* </p>
|
2300 |
|
*
|
|
2303 |
*
|
2301 |
2304 |
* <p>
|
2302 |
2305 |
* The preferences are:
|
2303 |
2306 |
* <ul>
|
... | ... | |
2337 |
2340 |
/**
|
2338 |
2341 |
* Uses like a mouse pointer the image that provides the
|
2339 |
2342 |
* selected tool.
|
2340 |
|
*
|
|
2343 |
*
|
2341 |
2344 |
*/
|
2342 |
2345 |
|
2343 |
2346 |
private Image lastImageCursor = null;
|
... | ... | |
2376 |
2379 |
* On the other hand, a light-yellowed background tool tip text with the
|
2377 |
2380 |
* type of <i>control point</i> will be displayed.</li>
|
2378 |
2381 |
* </p>
|
2379 |
|
*
|
|
2382 |
*
|
2380 |
2383 |
* @param g
|
2381 |
2384 |
* <code>MapControl</code>'s graphics where the data will be
|
2382 |
2385 |
* drawn
|
... | ... | |
2399 |
2402 |
* Adjusts the <code>point</code> to the grid if its enabled, and sets
|
2400 |
2403 |
* <code>mapHandlerAdjustedPoint</code> with that new value.
|
2401 |
2404 |
* </p>
|
2402 |
|
*
|
|
2405 |
*
|
2403 |
2406 |
* <p>
|
2404 |
2407 |
* The value returned is the distance between those points: the original and
|
2405 |
2408 |
* the adjusted one.
|
2406 |
2409 |
* </p>
|
2407 |
|
*
|
|
2410 |
*
|
2408 |
2411 |
* @param point
|
2409 |
2412 |
* point to adjust
|
2410 |
2413 |
* @param mapHandlerAdjustedPoint
|
2411 |
2414 |
* <code>point</code> adjusted
|
2412 |
|
*
|
|
2415 |
*
|
2413 |
2416 |
* @return distance from <code>point</code> to the adjusted one. If there is
|
2414 |
2417 |
* no
|
2415 |
2418 |
* adjustment, returns <code>Double.MAX_VALUE</code>.
|
... | ... | |
2452 |
2455 |
// de mayor
|
2453 |
2456 |
// prioridad est�n primero.
|
2454 |
2457 |
List geoms = cache.query(r);
|
2455 |
|
|
|
2458 |
|
2456 |
2459 |
for (int i = 0; i < mapControlManager.getSnapperCount(); i++)
|
2457 |
2460 |
{
|
2458 |
2461 |
ISnapper theSnapper = mapControlManager.getSnapperAt(i);
|
2459 |
2462 |
if (theSnapper instanceof ISnapperGeometriesVectorial)
|
2460 |
2463 |
{
|
2461 |
|
((ISnapperGeometriesVectorial)theSnapper).setGeometries(geoms);
|
|
2464 |
((ISnapperGeometriesVectorial)theSnapper).setGeometries(geoms);
|
2462 |
2465 |
}
|
2463 |
|
}
|
2464 |
|
|
|
2466 |
}
|
|
2467 |
|
2465 |
2468 |
for (int n = 0; n < geoms.size(); n++) {
|
2466 |
2469 |
Geometry geom = (Geometry) geoms.get(n);
|
2467 |
2470 |
for (int i = 0; i < mapControlManager.getSnapperCount(); i++) {
|
... | ... | |
2513 |
2516 |
|
2514 |
2517 |
/**
|
2515 |
2518 |
* Determines if snap tools are enabled or disabled.
|
2516 |
|
*
|
|
2519 |
*
|
2517 |
2520 |
* @return <code>true</code> to enable the snap tools; <code>false</code> to
|
2518 |
2521 |
* disable them
|
2519 |
|
*
|
|
2522 |
*
|
2520 |
2523 |
* @see #setRefentEnabled(boolean)
|
2521 |
2524 |
*/
|
2522 |
2525 |
public boolean isRefentEnabled() {
|
... | ... | |
2528 |
2531 |
* Tries to find the nearest geometry or grid control point by the position
|
2529 |
2532 |
* of the current snap tool.
|
2530 |
2533 |
* </p>
|
2531 |
|
*
|
|
2534 |
*
|
2532 |
2535 |
* <p>
|
2533 |
2536 |
* Prioritizes the grid control points than the geometries ones.
|
2534 |
2537 |
* </p>
|
2535 |
|
*
|
|
2538 |
*
|
2536 |
2539 |
* <p>
|
2537 |
2540 |
* If finds any near, stores the <i>map</i> and <i>pixel</i> coordinates for
|
2538 |
2541 |
* the snap, and enables the <code>bForceCoord</code> attribute for the next
|
2539 |
2542 |
* draw of the mouse's cursor.
|
2540 |
2543 |
* </p>
|
2541 |
|
*
|
|
2544 |
*
|
2542 |
2545 |
* @param point
|
2543 |
2546 |
* current mouse 2D position
|
2544 |
2547 |
*/
|
... | ... | |
2584 |
2587 |
|
2585 |
2588 |
/**
|
2586 |
2589 |
* Sets the snap tools enabled or disabled.
|
2587 |
|
*
|
|
2590 |
*
|
2588 |
2591 |
* @param activated
|
2589 |
2592 |
* <code>true</code> to enable the snap tools; <code>false</code>
|
2590 |
2593 |
* to disable them
|
2591 |
|
*
|
|
2594 |
*
|
2592 |
2595 |
* @see #isRefentEnabled()
|
2593 |
2596 |
*/
|
2594 |
2597 |
public void setRefentEnabled(boolean activated) {
|
... | ... | |
2625 |
2628 |
/**
|
2626 |
2629 |
* Gets the selected point. If the snapping is enabled
|
2627 |
2630 |
* it returns the selected point.
|
2628 |
|
*
|
|
2631 |
*
|
2629 |
2632 |
* @return
|
2630 |
2633 |
* The selected point
|
2631 |
2634 |
*/
|