Revision 147
branches/usability_v2/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/pom.xml | ||
---|---|---|
11 | 11 |
<parent> |
12 | 12 |
<groupId>org.gvsig</groupId> |
13 | 13 |
<artifactId>org.gvsig.app.document.layout.app</artifactId> |
14 |
<version>2.0.22-SNAPSHOT</version>
|
|
14 |
<version>2.0.23-SNAPSHOT</version>
|
|
15 | 15 |
</parent> |
16 | 16 |
|
17 | 17 |
<dependencies> |
branches/usability_v2/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/FrameChangedNotification.java | ||
---|---|---|
1 |
package org.gvsig.app.project.documents.layout; |
|
2 |
|
|
3 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
|
4 |
|
|
5 |
public class FrameChangedNotification extends DefaultLayoutNotification { |
|
6 |
public static final String FRAME_ADDED = "frame_added"; |
|
7 |
public static final String FRAME_ADDING = "frame_adding"; |
|
8 |
public static final String FRAME_REMOVING = "frame_removed"; |
|
9 |
public static final String FRAME_REMOVED = "frame_removed"; |
|
10 |
private IFFrame frame; |
|
11 |
|
|
12 |
public FrameChangedNotification(String type, IFFrame frame) { |
|
13 |
super(type); |
|
14 |
this.frame = frame; |
|
15 |
} |
|
16 |
|
|
17 |
public IFFrame getFrame() { |
|
18 |
return this.frame; |
|
19 |
} |
|
20 |
|
|
21 |
} |
branches/usability_v2/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/FrameChangedNotificationImpl.java | ||
---|---|---|
1 |
package org.gvsig.app.project.documents.layout; |
|
2 |
|
|
3 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
|
4 |
|
|
5 |
public class FrameChangedNotificationImpl extends DefaultLayoutNotification implements FrameChangedNotification { |
|
6 |
private IFFrame frame; |
|
7 |
|
|
8 |
public FrameChangedNotificationImpl(String type, IFFrame frame) { |
|
9 |
super(type); |
|
10 |
this.frame = frame; |
|
11 |
} |
|
12 |
|
|
13 |
public IFFrame getFrame() { |
|
14 |
return this.frame; |
|
15 |
} |
|
16 |
|
|
17 |
} |
branches/usability_v2/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/fframes/IFFrame.java | ||
---|---|---|
29 | 29 |
import java.awt.geom.Rectangle2D; |
30 | 30 |
import java.awt.image.BufferedImage; |
31 | 31 |
|
32 |
import org.gvsig.app.project.documents.Document; |
|
32 | 33 |
import org.gvsig.app.project.documents.layout.LayoutContext; |
33 | 34 |
import org.gvsig.app.project.documents.layout.LayoutControl; |
34 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
|
35 | 35 |
import org.gvsig.fmap.mapcontext.rendering.symbols.IPrintable; |
36 | 36 |
import org.gvsig.tools.dispose.Disposable; |
37 | 37 |
import org.gvsig.tools.lang.Cloneable; |
... | ... | |
321 | 321 |
|
322 | 322 |
public FrameFactory getFrameFactory(); |
323 | 323 |
|
324 |
public LayoutPanel getLayoutPanel();
|
|
324 |
public Document getDocument();
|
|
325 | 325 |
|
326 |
public void setLayoutPanel(LayoutPanel layoutPanel);
|
|
326 |
public void setDocument(Document document);
|
|
327 | 327 |
|
328 | 328 |
public LayoutContext getLayoutContext(); |
329 | 329 |
|
330 | 330 |
public void setLayoutContext(LayoutContext layoutContext); |
331 |
|
|
332 |
public LayoutControl getLayoutControl(); |
|
333 |
|
|
334 |
public void setLayoutControl(LayoutControl layoutControl); |
|
335 | 331 |
} |
branches/usability_v2/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/fframes/IFFrameUseFMap.java | ||
---|---|---|
29 | 29 |
import org.gvsig.fmap.geom.primitive.Envelope; |
30 | 30 |
import org.gvsig.fmap.mapcontext.MapContext; |
31 | 31 |
|
32 |
public interface IFFrameUseFMap { |
|
32 |
public interface IFFrameUseFMap extends IFFrame {
|
|
33 | 33 |
|
34 | 34 |
public static final int AUTOMATICO = 0; |
35 | 35 |
/** |
branches/usability_v2/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/fframes/FFrameView.java | ||
---|---|---|
38 | 38 |
import org.gvsig.andami.messages.NotificationManager; |
39 | 39 |
import org.gvsig.andami.ui.mdiFrame.NewStatusBar; |
40 | 40 |
import org.gvsig.app.project.Project; |
41 |
import org.gvsig.app.project.ProjectManager; |
|
42 |
import org.gvsig.app.project.documents.Document; |
|
41 | 43 |
import org.gvsig.app.project.documents.layout.DefaultLayoutNotification; |
42 | 44 |
import org.gvsig.app.project.documents.layout.FLayoutFunctions; |
43 | 45 |
import org.gvsig.app.project.documents.layout.FLayoutUtilities; |
44 | 46 |
import org.gvsig.app.project.documents.layout.LayoutNotification; |
45 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameViewDialog; |
|
46 | 47 |
import org.gvsig.app.project.documents.view.ViewDocument; |
47 | 48 |
import org.gvsig.app.project.documents.view.toc.gui.TOC; |
48 | 49 |
import org.gvsig.compat.print.PrintAttributes; |
49 | 50 |
import org.gvsig.fmap.dal.exception.ReadException; |
50 | 51 |
import org.gvsig.fmap.geom.Geometry; |
51 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
52 |
import org.gvsig.fmap.geom.GeometryManager; |
|
53 | 52 |
import org.gvsig.fmap.geom.primitive.Envelope; |
54 | 53 |
import org.gvsig.fmap.mapcontext.MapContext; |
55 | 54 |
import org.gvsig.fmap.mapcontext.MapContextException; |
... | ... | |
64 | 63 |
import org.gvsig.fmap.mapcontext.layers.LayerCollectionEvent; |
65 | 64 |
import org.gvsig.fmap.mapcontext.layers.LayerCollectionListener; |
66 | 65 |
import org.gvsig.fmap.mapcontext.layers.LayerPositionEvent; |
66 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
67 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
|
67 | 68 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendChangedEvent; |
68 | 69 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.listeners.LegendListener; |
69 | 70 |
import org.gvsig.gui.beans.Messages; |
... | ... | |
123 | 124 |
|
124 | 125 |
private boolean b_viewOriginatedUpdate = false; |
125 | 126 |
private boolean b_fframeOriginatedUpdate = false; |
126 |
private boolean b_validCache = false;
|
|
127 |
protected boolean b_validCache = false;
|
|
127 | 128 |
protected ViewDocListener viewDocListener; |
128 | 129 |
protected OwnMapContextListener ownMapContextListener; |
129 |
|
|
130 |
private TOC toc; |
|
131 | 130 |
private boolean b_hasToc = false; |
132 | 131 |
|
133 | 132 |
|
... | ... | |
240 | 239 |
newViewPort.setDPI(getDrawPaperDPI()); |
241 | 240 |
setListeners(); |
242 | 241 |
updateScaleCtrl(); |
242 |
setTocModel(); |
|
243 | 243 |
} catch (CloneNotSupportedException e1) { |
244 | 244 |
NotificationManager.addError("Excepci?n :", e1); |
245 | 245 |
} |
... | ... | |
345 | 345 |
BufferedImage imgBase) throws Exception { |
346 | 346 |
|
347 | 347 |
Point mapOrigin = new Point((int)visibleLayoutDocRect.getMinX(), (int)visibleLayoutDocRect.getMaxY()); |
348 |
|
|
349 |
ViewPort viewPort = this.getMapContext().getViewPort(); |
|
350 |
Color theBackColor = viewPort.getBackColor(); |
|
351 | 348 |
int drawWidth = (int)fframeViewRect.width; |
352 | 349 |
int drawHeight = (int)fframeViewRect.height; |
350 |
// paint the MapContext on m_image, if not already cached |
|
351 |
createImage(g, affineTransform, drawWidth, drawHeight, mapOrigin); |
|
353 | 352 |
|
353 |
//Draw the created image |
|
354 |
drawImage(g, m_image, fframeViewRect); |
|
355 |
|
|
356 |
scaleAnt = affineTransform.getScaleX(); |
|
357 |
origin = mapOrigin; |
|
358 |
} |
|
359 |
|
|
360 |
protected void createImage(Graphics2D g, AffineTransform affineTransform, |
|
361 |
int width, int height, Point mapOrigin) throws ReadException, MapContextException { |
|
362 |
ViewPort viewPort = this.getMapContext().getViewPort(); |
|
363 |
|
|
354 | 364 |
//If the image has to be created... |
355 | 365 |
if (origin == null || |
356 | 366 |
!origin.equals(mapOrigin) || |
... | ... | |
358 | 368 |
m_image == null || |
359 | 369 |
!b_validCache) { |
360 | 370 |
|
361 |
viewPort.setImageSize(new Dimension(drawWidth, drawHeight)); |
|
362 |
viewPort.setDPI(getDrawPaperDPI()); |
|
371 |
viewPort.setDPI(getDrawPaperDPI()); |
|
372 |
viewPort.setImageSize(new Dimension(width, height)); |
|
373 |
viewPort.refreshExtent(); // really needed (calculateAffineTransform is already called by setImageSize, but extentChanged listeners are not notified |
|
374 |
|
|
363 | 375 |
m_image = |
364 | 376 |
new BufferedImage( |
365 |
drawWidth,
|
|
366 |
drawHeight,
|
|
377 |
width,
|
|
378 |
height,
|
|
367 | 379 |
BufferedImage.TYPE_INT_ARGB); |
368 | 380 |
|
369 | 381 |
Graphics2D gimg = (Graphics2D) m_image.createGraphics(); |
... | ... | |
372 | 384 |
b_validCache = true; |
373 | 385 |
} |
374 | 386 |
|
375 |
//Draw the created image |
|
387 |
} |
|
388 |
|
|
389 |
protected void drawImage(Graphics2D g, BufferedImage image, |
|
390 |
Rectangle2D.Double visibleRectangle) { |
|
391 |
|
|
392 |
Color theBackColor = getMapContext().getViewPort().getBackColor(); |
|
376 | 393 |
if (theBackColor != null) { |
377 | 394 |
g.setColor(theBackColor); |
378 |
g.fillRect((int) fframeViewRect.x, (int) fframeViewRect.y,
|
|
379 |
(int)fframeViewRect.width,
|
|
380 |
(int)fframeViewRect.height);
|
|
395 |
g.fillRect((int) visibleRectangle.x, (int) visibleRectangle.y,
|
|
396 |
(int)visibleRectangle.width,
|
|
397 |
(int)visibleRectangle.height);
|
|
381 | 398 |
} |
382 | 399 |
g.drawImage(m_image, |
383 |
(int) fframeViewRect.x, |
|
384 |
(int) fframeViewRect.y, |
|
385 |
null); |
|
386 |
|
|
387 |
scaleAnt = affineTransform.getScaleX(); |
|
388 |
origin = mapOrigin; |
|
400 |
(int) visibleRectangle.x, |
|
401 |
(int) visibleRectangle.y, |
|
402 |
null); |
|
389 | 403 |
} |
390 | 404 |
|
391 | 405 |
protected Rectangle preDraw(Graphics2D g, Rectangle2D.Double fframeViewRect){ |
... | ... | |
681 | 695 |
} |
682 | 696 |
|
683 | 697 |
public Object clone() throws CloneNotSupportedException { |
698 |
Document d = ProjectManager.getInstance().getCurrentProject().getDocuments().get(0); |
|
684 | 699 |
FFrameView frame = (FFrameView) super.clone(); |
685 |
frame.createListeners(); |
|
686 |
frame.setSelected(this.isSelected()); |
|
687 |
frame.setTypeScale(this.getTypeScale()); |
|
688 |
frame.setLinked(linked); |
|
689 | 700 |
frame.setView(this.getView()); |
701 |
frame.createListeners(); // necessary to create the listeners within the right scope |
|
690 | 702 |
|
691 | 703 |
if (grid != null) { |
692 | 704 |
FFrameGrid newGrid = (FFrameGrid) this.grid.clone(); |
... | ... | |
727 | 739 |
public static void registerPersistent() { |
728 | 740 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
729 | 741 |
if (manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null) { |
742 |
// DynStruct definition = |
|
743 |
// manager.addDefinition(FLyrVect.class, |
|
744 |
// "FLyrVect", |
|
745 |
// "FLyrVect Persistence definition", |
|
746 |
// null, |
|
747 |
// null); |
|
748 |
// definition.extend(PersistenceManager.PERSISTENCE_NAMESPACE, |
|
749 |
// "FLyrDefault"); |
|
750 |
// |
|
751 |
// definition.addDynFieldObject("legend") |
|
752 |
// .setClassOfValue(IVectorLegend.class) |
|
753 |
|
|
730 | 754 |
DynStruct definition = |
731 | 755 |
manager.addDefinition(FFrameView.class, |
732 | 756 |
PERSISTENCE_DEFINITION_NAME, |
733 | 757 |
"FFrameView persistence definition", null, null); |
734 |
|
|
758 |
// definition.extend(manager |
|
759 |
// .getDefinition(FFrame.PERSISTENCE_DEFINITION_NAME)); |
|
760 |
|
|
735 | 761 |
definition.extend(manager |
736 | 762 |
.getDefinition(FFrame.PERSISTENCE_DEFINITION_NAME)); |
737 | 763 |
|
... | ... | |
776 | 802 |
(Envelope) state.get(ENVELOPE_FIELD)); |
777 | 803 |
if (state.hasValue(HAS_TOC)) { |
778 | 804 |
this.b_hasToc = state.getBoolean(HAS_TOC); |
779 |
addToc(); |
|
805 |
if (this.getLayoutContext()!=null) { |
|
806 |
this.getLayoutContext().setTocModel(mapContext); |
|
807 |
} |
|
780 | 808 |
} |
781 | 809 |
} |
782 | 810 |
|
783 | 811 |
showGrid = state.getBoolean(SHOWGRID_FIELD); |
784 | 812 |
grid = (IFFrame) state.get(GRID_FIELD); |
785 | 813 |
} |
786 |
|
|
787 |
protected void addToc() { |
|
788 |
if (b_hasToc) { |
|
789 |
if (this.toc==null && getMapContext()!=null) { |
|
790 |
this.toc = new TOC(); |
|
791 |
this.toc.setMapContext(getMapContext()); |
|
792 |
} |
|
793 |
if (this.getLayoutPanel()!=null) { |
|
794 |
this.getLayoutPanel().addLateralComponent(this.toc); |
|
795 |
} |
|
796 |
} |
|
797 |
} |
|
798 |
|
|
799 |
protected void removeToc() { |
|
800 |
if (this.getLayoutPanel()!=null && this.toc!=null) { |
|
801 |
this.getLayoutPanel().removeLateralComponent(this.toc); |
|
802 |
this.toc = null; |
|
803 |
} |
|
804 |
} |
|
805 | 814 |
|
806 | 815 |
@Override |
807 | 816 |
public void saveToState(PersistentState state) throws PersistenceException { |
... | ... | |
812 | 821 |
state.set(BLINKED_FIELD, linked); |
813 | 822 |
state.set(MAPUNITS_FIELD, mapUnits); |
814 | 823 |
state.set(VIEW_FIELD, viewDocument); |
815 |
state.set(HAS_TOC, toc!=null);
|
|
824 |
state.set(HAS_TOC, b_hasToc);
|
|
816 | 825 |
|
817 | 826 |
if (getMapContext() != null |
818 | 827 |
&& getMapContext().getViewPort().getEnvelope() != null) { |
819 | 828 |
state.set(ENVELOPE_FIELD, getMapContext().getViewPort() |
820 | 829 |
.getEnvelope()); |
821 | 830 |
state.set(SCALE_FIELD, (double)getMapContext().getScaleView()); |
822 |
state.set(MAPCONTEXT_FIELD, mapContext);
|
|
831 |
state.set(MAPCONTEXT_FIELD, getMapContext());
|
|
823 | 832 |
} |
824 | 833 |
|
825 | 834 |
state.set(SHOWGRID_FIELD, showGrid); |
... | ... | |
852 | 861 |
|
853 | 862 |
protected void invalidateLayout() { |
854 | 863 |
b_validCache = false; |
864 |
if (getLayoutContext()!=null) { |
|
865 |
getLayoutContext().notifAllObservers(); |
|
866 |
} |
|
855 | 867 |
observers.notifyObservers(this, |
856 | 868 |
new DefaultLayoutNotification(LayoutNotification.LAYOUT_REFRESH)); |
857 | 869 |
} |
870 |
|
|
871 |
protected void invalidateToc() { |
|
872 |
if (getLayoutContext()!=null) { |
|
873 |
getLayoutContext().updateFFrames(); |
|
874 |
} |
|
875 |
|
|
876 |
} |
|
858 | 877 |
|
859 | 878 |
public void refresh() { |
860 | 879 |
// FIXME: what should we do here? do we really need to invalidate cache?? |
... | ... | |
928 | 947 |
if (this.getView()!=null && this.getView().getMapContext()!=null) { |
929 | 948 |
clearViewListeners(this.getView().getMapContext()); |
930 | 949 |
} |
931 |
if (b_hasToc) { |
|
932 |
removeToc();
|
|
950 |
if (b_hasToc && getLayoutContext()!=null) {
|
|
951 |
getLayoutContext().setTocModel(null);
|
|
933 | 952 |
} |
934 | 953 |
} |
935 | 954 |
|
... | ... | |
938 | 957 |
* added to the Layout |
939 | 958 |
*/ |
940 | 959 |
protected void afterAdded() { |
941 |
addToc(); |
|
942 | 960 |
setListeners(); |
943 | 961 |
updateScaleCtrl(); |
944 | 962 |
} |
945 | 963 |
|
946 |
public void setToc(boolean useToc) { |
|
947 |
this.b_hasToc = useToc; |
|
948 |
if (useToc) { |
|
949 |
addToc(); |
|
964 |
public void setHasToc(boolean hasToc) { |
|
965 |
this.b_hasToc = hasToc; |
|
966 |
setTocModel(); |
|
967 |
} |
|
968 |
|
|
969 |
protected void setTocModel() { |
|
970 |
if (getLayoutContext()!=null) { |
|
971 |
if (b_hasToc && getMapContext()!=null) { |
|
972 |
getLayoutContext().setTocModel(getMapContext()); |
|
973 |
} |
|
974 |
else { |
|
975 |
getLayoutContext().setTocModel(null); |
|
976 |
} |
|
950 | 977 |
} |
951 |
else { |
|
952 |
removeToc(); |
|
953 |
} |
|
954 | 978 |
} |
955 | 979 |
|
956 | 980 |
@Override |
957 | 981 |
protected void doSetSelected(int selectedStatus) { |
982 |
boolean oldSelectedStatus = isSelected(); |
|
958 | 983 |
super.doSetSelected(selectedStatus); |
959 |
addToc(); |
|
960 |
updateScaleCtrl(); |
|
984 |
if (!oldSelectedStatus && isSelected()) { // changed from not selected to selected |
|
985 |
setTocModel(); |
|
986 |
updateScaleCtrl(); |
|
987 |
} |
|
961 | 988 |
} |
962 | 989 |
|
963 | 990 |
private class ViewDocListener |
... | ... | |
1009 | 1036 |
|
1010 | 1037 |
public void legendChanged(LegendChangedEvent e) { |
1011 | 1038 |
conditionalRedraw(); |
1012 |
if (linked && toc!=null) { |
|
1013 |
toc.refresh(); |
|
1014 |
} |
|
1039 |
invalidateToc(); |
|
1015 | 1040 |
} |
1016 | 1041 |
|
1017 | 1042 |
public void layerAdded(LayerCollectionEvent e) { |
1018 | 1043 |
conditionalRedraw(); |
1044 |
invalidateToc(); |
|
1019 | 1045 |
} |
1020 | 1046 |
|
1021 | 1047 |
public void layerMoved(LayerPositionEvent e) { |
1022 | 1048 |
conditionalRedraw(); |
1049 |
invalidateToc(); |
|
1023 | 1050 |
} |
1024 | 1051 |
|
1025 | 1052 |
public void layerRemoved(LayerCollectionEvent e) { |
1026 | 1053 |
conditionalRedraw(); |
1054 |
invalidateToc(); |
|
1027 | 1055 |
} |
1028 | 1056 |
|
1029 | 1057 |
public void layerAdding(LayerCollectionEvent e) |
... | ... | |
1044 | 1072 |
public void visibilityChanged(LayerCollectionEvent e) |
1045 | 1073 |
throws CancelationException { |
1046 | 1074 |
conditionalRedraw(); |
1075 |
invalidateToc(); |
|
1047 | 1076 |
} |
1048 | 1077 |
|
1049 | 1078 |
public void atomicEvent(AtomicEvent e) { |
1050 | 1079 |
conditionalRedraw(); |
1051 |
// TODO Auto-generated method stub |
|
1052 |
|
|
1080 |
invalidateToc(); |
|
1053 | 1081 |
} |
1054 | 1082 |
} |
1055 | 1083 |
|
... | ... | |
1102 | 1130 |
|
1103 | 1131 |
public void legendChanged(final LegendChangedEvent e) { |
1104 | 1132 |
conditionalRedraw(); |
1105 |
if (toc!=null) { |
|
1106 |
toc.refresh(); |
|
1107 |
} |
|
1108 | 1133 |
} |
1109 | 1134 |
|
1110 | 1135 |
public void layerAdded(final LayerCollectionEvent e) { |
1111 | 1136 |
conditionalRedraw(); |
1112 |
if (toc!=null) { |
|
1113 |
toc.refresh(); |
|
1114 |
} |
|
1115 | 1137 |
} |
1116 | 1138 |
|
1117 | 1139 |
public void layerMoved(final LayerPositionEvent e) { |
1118 | 1140 |
conditionalRedraw(); |
1119 |
if (toc!=null) { |
|
1120 |
toc.refresh(); |
|
1121 |
} |
|
1122 | 1141 |
} |
1123 | 1142 |
|
1124 | 1143 |
public void layerRemoved(final LayerCollectionEvent e) { |
1125 | 1144 |
conditionalRedraw(); |
1126 |
if (toc!=null) { |
|
1127 |
toc.refresh(); |
|
1128 |
} |
|
1129 | 1145 |
} |
1130 | 1146 |
|
1131 | 1147 |
public void layerAdding(LayerCollectionEvent e) |
... | ... | |
1149 | 1165 |
public void visibilityChanged(LayerCollectionEvent e) |
1150 | 1166 |
throws CancelationException { |
1151 | 1167 |
conditionalRedraw(); |
1152 |
toc.refresh(); |
|
1153 | 1168 |
} |
1154 | 1169 |
|
1155 | 1170 |
} |
branches/usability_v2/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/fframes/gui/dialogs/FFrameViewDialog.java | ||
---|---|---|
463 | 463 |
newFFrameView.setBoundBox(FLayoutUtilities.toSheetRect( |
464 | 464 |
rect, layoutPanel.getLayoutControl().getAT())); |
465 | 465 |
newFFrameView.setRotation(getPRotation().getRotation()); |
466 |
newFFrameView.setHasToc(true); |
|
467 |
|
|
466 | 468 |
if (m_projectView != null) { |
467 | 469 |
newFFrameView.setLinked(getChbEnlaceVivo() |
468 | 470 |
.isSelected()); |
... | ... | |
487 | 489 |
newFFrameView.setBoundBox(FLayoutUtilities |
488 | 490 |
.toSheetRect(rect, layoutPanel |
489 | 491 |
.getLayoutControl().getAT())); |
490 |
newFFrameView.setToc(true); |
|
491 |
|
|
492 | 492 |
} |
493 | 493 |
} catch (CloneNotSupportedException e1) { |
494 | 494 |
LOG.error("It is not possible clonate the object", e); |
branches/usability_v2/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/fframes/FFrame.java | ||
---|---|---|
34 | 34 |
import java.awt.image.BufferedImage; |
35 | 35 |
|
36 | 36 |
import org.gvsig.andami.PluginServices; |
37 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
37 | 38 |
import org.gvsig.app.project.ProjectManager; |
39 |
import org.gvsig.app.project.documents.Document; |
|
38 | 40 |
import org.gvsig.app.project.documents.layout.Attributes; |
39 | 41 |
import org.gvsig.app.project.documents.layout.DefaultLayoutManager; |
40 | 42 |
import org.gvsig.app.project.documents.layout.FLayoutUtilities; |
41 |
import org.gvsig.app.project.documents.layout.FrameChangedNotification; |
|
43 |
import org.gvsig.app.project.documents.layout.FrameChangedNotificationImpl;
|
|
42 | 44 |
import org.gvsig.app.project.documents.layout.LayoutContext; |
43 | 45 |
import org.gvsig.app.project.documents.layout.LayoutControl; |
46 |
import org.gvsig.app.project.documents.layout.LayoutDocument; |
|
44 | 47 |
import org.gvsig.app.project.documents.layout.LayoutManager; |
45 | 48 |
import org.gvsig.app.project.documents.layout.LayoutNotification; |
46 | 49 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
... | ... | |
72 | 75 |
private static final String ROTATION_FIELD = "rotation"; |
73 | 76 |
private static final String LEVEL_FIELD = "level"; |
74 | 77 |
private static final String NUM_FIELD = "num"; |
75 |
private static final String LAYOUTPANEL_FIELD = "layoutPanel"; |
|
78 |
private static final String DOCUMENT_FIELD = "layoutDocument"; |
|
79 |
private static final String LAYOUT_CONTEXT_FIELD = "layoutContext"; |
|
76 | 80 |
|
77 | 81 |
protected static final Logger LOG = LoggerFactory.getLogger(FFrame.class); |
78 | 82 |
|
... | ... | |
105 | 109 |
|
106 | 110 |
protected LayoutManager layoutManager = null; |
107 | 111 |
private LayoutContext layoutContext = null; |
108 |
private LayoutControl layoutControl = null; |
|
109 |
private LayoutPanel layoutPanel = null; |
|
110 |
|
|
112 |
private Document document = null; |
|
113 |
|
|
111 | 114 |
protected ObservableHelper observers; |
112 | 115 |
|
113 | 116 |
public FFrame() { |
... | ... | |
759 | 762 |
definition.addDynFieldDouble(ROTATION_FIELD).setMandatory(true); |
760 | 763 |
definition.addDynFieldInt(LEVEL_FIELD).setMandatory(true); |
761 | 764 |
definition.addDynFieldInt(NUM_FIELD).setMandatory(true); |
762 |
definition.addDynFieldObject(LAYOUTPANEL_FIELD).setClassOfValue(LayoutPanel.class).setMandatory(false); |
|
765 |
definition.addDynFieldObject(DOCUMENT_FIELD).setClassOfValue(LayoutDocument.class).setMandatory(false); |
|
766 |
definition.addDynFieldObject(LAYOUT_CONTEXT_FIELD).setClassOfValue(LayoutContext.class).setMandatory(false); |
|
763 | 767 |
} |
764 | 768 |
|
765 | 769 |
Attributes.registerPersistent(); |
... | ... | |
787 | 791 |
m_rotation = state.getDouble(ROTATION_FIELD); |
788 | 792 |
level = state.getInt(LEVEL_FIELD); |
789 | 793 |
num = state.getInt(NUM_FIELD); |
790 |
if (state.hasValue(LAYOUTPANEL_FIELD)) {
|
|
791 |
setLayoutPanel((LayoutPanel)state.get(LAYOUTPANEL_FIELD ));
|
|
794 |
if (state.hasValue(DOCUMENT_FIELD)) {
|
|
795 |
setDocument((LayoutDocument)state.get(DOCUMENT_FIELD ));
|
|
792 | 796 |
} |
797 |
if (state.hasValue(LAYOUT_CONTEXT_FIELD)) { |
|
798 |
setLayoutContext((LayoutContext) state.get(LAYOUT_CONTEXT_FIELD)); |
|
799 |
} |
|
793 | 800 |
} |
794 | 801 |
|
795 | 802 |
public void saveToState(PersistentState state) throws PersistenceException { |
... | ... | |
799 | 806 |
state.set(ROTATION_FIELD, getRotation()); |
800 | 807 |
state.set(LEVEL_FIELD, getLevel()); |
801 | 808 |
state.set(NUM_FIELD, num); |
802 |
state.set(LAYOUTPANEL_FIELD, getLayoutPanel()); |
|
809 |
state.set(DOCUMENT_FIELD, getDocument()); |
|
810 |
state.set(LAYOUT_CONTEXT_FIELD, getLayoutContext()); |
|
803 | 811 |
} |
804 | 812 |
|
805 | 813 |
public void addObserver(Observer o) { |
... | ... | |
848 | 856 |
protected void afterRemoved() {} |
849 | 857 |
|
850 | 858 |
public void update(Observable observable, Object notification) { |
851 |
if ((notification != null) && (notification instanceof LayoutNotification)){
|
|
852 |
FrameChangedNotification layoutNotification = (FrameChangedNotification)notification;
|
|
853 |
if (this.equals(layoutNotification.getFrame()) && FrameChangedNotification.FRAME_ADDED.equals(layoutNotification.getType())){ |
|
859 |
if ((notification != null) && (notification instanceof FrameChangedNotificationImpl)){
|
|
860 |
FrameChangedNotificationImpl layoutNotification = (FrameChangedNotificationImpl)notification;
|
|
861 |
if (this.equals(layoutNotification.getFrame()) && FrameChangedNotificationImpl.FRAME_ADDED.equals(layoutNotification.getType())){
|
|
854 | 862 |
afterAdded(); |
855 |
}else if (this.equals(layoutNotification.getFrame()) && FrameChangedNotification.FRAME_ADDING.equals(layoutNotification.getType())){ |
|
863 |
}else if (this.equals(layoutNotification.getFrame()) && FrameChangedNotificationImpl.FRAME_ADDING.equals(layoutNotification.getType())){
|
|
856 | 864 |
beforeAdded(); |
857 |
}else if (this.equals(layoutNotification.getFrame()) && FrameChangedNotification.FRAME_REMOVING.equals(layoutNotification.getType())){ |
|
865 |
}else if (this.equals(layoutNotification.getFrame()) && FrameChangedNotificationImpl.FRAME_REMOVING.equals(layoutNotification.getType())){
|
|
858 | 866 |
beforeRemoved(); |
859 |
}else if (this.equals(layoutNotification.getFrame()) && FrameChangedNotification.FRAME_REMOVED.equals(layoutNotification.getType())){ |
|
867 |
}else if (this.equals(layoutNotification.getFrame()) && FrameChangedNotificationImpl.FRAME_REMOVED.equals(layoutNotification.getType())){
|
|
860 | 868 |
afterRemoved(); |
861 | 869 |
} |
862 | 870 |
} |
863 | 871 |
} |
864 | 872 |
|
865 |
public LayoutPanel getLayoutPanel() { |
|
866 |
return layoutPanel; |
|
867 |
} |
|
868 |
|
|
869 |
public void setLayoutPanel(LayoutPanel layoutPanel) { |
|
870 |
this.layoutPanel = layoutPanel; |
|
871 |
} |
|
872 |
|
|
873 | 873 |
public LayoutContext getLayoutContext() { |
874 | 874 |
return layoutContext; |
875 | 875 |
} |
... | ... | |
878 | 878 |
this.layoutContext = layoutContext; |
879 | 879 |
} |
880 | 880 |
|
881 |
public LayoutControl getLayoutControl() {
|
|
882 |
return layoutControl;
|
|
881 |
public Document getDocument() {
|
|
882 |
return document;
|
|
883 | 883 |
} |
884 | 884 |
|
885 |
public void setLayoutControl(LayoutControl layoutControl) {
|
|
886 |
this.layoutControl = layoutControl;
|
|
885 |
public void setDocument(Document document) {
|
|
886 |
this.document = document;
|
|
887 | 887 |
} |
888 | 888 |
} |
branches/usability_v2/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/gui/LayoutPanel.java | ||
---|---|---|
144 | 144 |
|
145 | 145 |
public abstract void drawLayoutPrint(Graphics2D g2); |
146 | 146 |
|
147 |
public abstract void addLateralComponent(JComponent c); |
|
148 |
|
|
149 |
public abstract void removeLateralComponent(JComponent c); |
|
150 |
|
|
151 |
public abstract void hideLateralComponent(JComponent c); |
|
147 |
public abstract void hideToc(JComponent c); |
|
152 | 148 |
|
153 |
public abstract void showLateralComponent(JComponent c);
|
|
149 |
public abstract void showToc(JComponent c);
|
|
154 | 150 |
|
155 | 151 |
} |
branches/usability_v2/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/gui/DefaultLayoutPanel.java | ||
---|---|---|
62 | 62 |
import org.gvsig.app.project.documents.layout.LayoutControl; |
63 | 63 |
import org.gvsig.app.project.documents.layout.LayoutDocument; |
64 | 64 |
import org.gvsig.app.project.documents.layout.LayoutManager; |
65 |
import org.gvsig.app.project.documents.layout.TocModelChangedNotification; |
|
65 | 66 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
66 | 67 |
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap; |
67 | 68 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog; |
68 | 69 |
import org.gvsig.app.project.documents.layout.gui.dialogs.FConfigLayoutDialog; |
69 | 70 |
import org.gvsig.app.project.documents.layout.gui.panel.UIManager; |
71 |
import org.gvsig.app.project.documents.layout.toc.TocModelObserver; |
|
72 |
import org.gvsig.app.project.documents.view.toc.gui.TOC; |
|
73 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
74 |
import org.gvsig.fmap.mapcontext.events.AtomicEvent; |
|
70 | 75 |
import org.gvsig.fmap.mapcontext.events.ColorEvent; |
71 | 76 |
import org.gvsig.fmap.mapcontext.events.ExtentEvent; |
72 | 77 |
import org.gvsig.fmap.mapcontext.events.ProjectionEvent; |
78 |
import org.gvsig.fmap.mapcontext.events.listeners.AtomicEventListener; |
|
79 |
import org.gvsig.fmap.mapcontext.layers.CancelationException; |
|
80 |
import org.gvsig.fmap.mapcontext.layers.LayerCollectionEvent; |
|
81 |
import org.gvsig.fmap.mapcontext.layers.LayerCollectionListener; |
|
82 |
import org.gvsig.fmap.mapcontext.layers.LayerEvent; |
|
83 |
import org.gvsig.fmap.mapcontext.layers.LayerListener; |
|
84 |
import org.gvsig.fmap.mapcontext.layers.LayerPositionEvent; |
|
85 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendChangedEvent; |
|
86 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.listeners.LegendListener; |
|
73 | 87 |
import org.gvsig.gui.beans.swing.JFileChooser; |
74 | 88 |
import org.gvsig.tools.ToolsLocator; |
75 | 89 |
import org.gvsig.tools.dynobject.DynStruct; |
... | ... | |
120 | 134 |
private UIManager uiManager; |
121 | 135 |
|
122 | 136 |
private JPanel leftPanel; |
137 |
private TOC toc = null; |
|
123 | 138 |
|
124 | 139 |
private JSplitPane splitPane; |
125 |
private int lastPanePos = 0; |
|
140 |
private int lastPanePos = 150;
|
|
126 | 141 |
|
127 | 142 |
/** |
128 | 143 |
* Creates a new Layout object. |
... | ... | |
151 | 166 |
} |
152 | 167 |
} |
153 | 168 |
}); |
169 |
|
|
170 |
setToc(); |
|
154 | 171 |
} |
155 | 172 |
|
156 | 173 |
/** |
... | ... | |
158 | 175 |
*/ |
159 | 176 |
private void initComponents() { |
160 | 177 |
this.setLayout(new BorderLayout()); |
178 |
|
|
161 | 179 |
leftPanel = new JPanel(new BorderLayout()); |
162 | 180 |
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, |
163 | 181 |
leftPanel, layoutControl.getComponent()); |
164 | 182 |
splitPane.setResizeWeight(0.2); |
165 | 183 |
splitPane.setOneTouchExpandable(true); |
166 | 184 |
splitPane.setContinuousLayout(true); |
167 |
|
|
185 |
setToc(); |
|
168 | 186 |
add(splitPane, BorderLayout.CENTER); |
169 | 187 |
layoutControl.getComponent().setDoubleBuffered(true); |
170 | 188 |
} |
189 |
|
|
190 |
protected void createToc() { |
|
191 |
if (toc==null) { |
|
192 |
toc = new TOC(); |
|
193 |
} |
|
194 |
toc.setMapContext(getLayoutContext().getTocModel()); |
|
195 |
leftPanel.removeAll(); |
|
196 |
leftPanel.add(toc); |
|
197 |
} |
|
198 |
|
|
199 |
protected void setToc() { |
|
200 |
if (getLayoutContext()!=null) { |
|
201 |
if (getLayoutContext().getTocModel()!=null) { |
|
202 |
createToc(); |
|
203 |
} |
|
204 |
else if (toc!=null) { |
|
205 |
DefaultLayoutPanel.this.leftPanel.remove(toc); |
|
206 |
} |
|
207 |
|
|
208 |
this.getLayoutContext().addTocObserver(new TocModelObserver() { |
|
209 |
|
|
210 |
public void tocUpdated(Object observable, |
|
211 |
TocModelChangedNotification notification) { |
|
212 |
if (TocModelChangedNotification.MODEL_CHANGED==notification.getType()) { |
|
213 |
if (DefaultLayoutPanel.this.toc!=null){ |
|
214 |
DefaultLayoutPanel.this.toc.refresh(); |
|
215 |
} |
|
216 |
} |
|
217 |
else if (TocModelChangedNotification.MODEL_SET==notification.getType()) { |
|
218 |
MapContext mapContext = notification.getModel(); |
|
219 |
if (mapContext!=null) { |
|
220 |
createToc(); |
|
221 |
} |
|
222 |
else if (DefaultLayoutPanel.this.toc!=null){ |
|
223 |
DefaultLayoutPanel.this.leftPanel.remove(DefaultLayoutPanel.this.toc); |
|
224 |
} |
|
225 |
} |
|
226 |
} |
|
227 |
}); |
|
228 |
} |
|
229 |
} |
|
171 | 230 |
|
172 | 231 |
/** |
173 | 232 |
* Open the dialog of Layout properties. |
... | ... | |
466 | 525 |
} |
467 | 526 |
|
468 | 527 |
public void update(Observable observable, Object notification) { |
469 |
this.layoutContext.updateFFrames();
|
|
470 |
this.layoutControl.refresh();
|
|
528 |
this.layoutContext.updateFFrames();
|
|
529 |
this.layoutControl.refresh();
|
|
471 | 530 |
} |
472 | 531 |
|
473 | 532 |
public Object getWindowProfile() { |
... | ... | |
554 | 613 |
} |
555 | 614 |
} |
556 | 615 |
|
557 |
public void addLateralComponent(JComponent c) { |
|
558 |
leftPanel.removeAll(); |
|
559 |
leftPanel.add(c, BorderLayout.CENTER); |
|
560 |
} |
|
561 |
|
|
562 |
public void removeLateralComponent(JComponent c) { |
|
563 |
if (leftPanel.getComponentCount()>0) { |
|
564 |
leftPanel.remove(c); |
|
565 |
} |
|
566 |
} |
|
567 |
|
|
568 |
public void hideLateralComponent(JComponent c) { |
|
616 |
public void hideToc(JComponent c) { |
|
569 | 617 |
lastPanePos = splitPane.getDividerLocation(); |
570 | 618 |
splitPane.setDividerLocation(0); |
571 | 619 |
} |
572 | 620 |
|
573 |
public void showLateralComponent(JComponent c) {
|
|
621 |
public void showToc(JComponent c) {
|
|
574 | 622 |
splitPane.setDividerLocation(lastPanePos); |
575 | 623 |
|
576 | 624 |
} |
branches/usability_v2/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/FLayoutZooms.java | ||
---|---|---|
375 | 375 |
if (fframes[i] instanceof IFFrameUseFMap) { |
376 | 376 |
IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i]; |
377 | 377 |
|
378 |
if (((IFFrame) fframe).getSelected() != IFFrame.NOSELECT) {
|
|
378 |
if (fframe.isSelected()) {
|
|
379 | 379 |
|
380 | 380 |
Point2D vppo1 = FLayoutUtilities.screenCoordinatesToViewportImageCoordinates( |
381 | 381 |
poi1, fframes[i]); |
... | ... | |
385 | 385 |
Point2D.Double mapp1 = FLayoutFunctions.toMapPoint(vppo1, fframe.getATMap()); |
386 | 386 |
Point2D.Double mapp2 = FLayoutFunctions.toMapPoint(vppo2, fframe.getATMap()); |
387 | 387 |
|
388 |
// Borramos el anterior |
|
389 |
observers.notifyObservers(this, |
|
390 |
new DefaultLayoutNotification(LayoutNotification.LAYOUT_INVALIDATED)); |
|
391 | 388 |
Rectangle2D.Double r = new Rectangle2D.Double(); |
392 | 389 |
|
393 | 390 |
if (java.lang.Math.abs(poi1.getX() - poi2.getX()) <= 3) { |
... | ... | |
411 | 408 |
r.width = extent.getWidth() * factor; |
412 | 409 |
r.height = extent.getHeight() * factor; |
413 | 410 |
} |
414 |
|
|
415 |
// fframeAux.setNewExtent(r); |
|
416 | 411 |
} else { |
417 | 412 |
// Fijamos el nuevo extent |
418 |
|
|
419 | 413 |
r.setFrameFromDiagonal(mapp1, mapp2); |
420 |
|
|
421 |
// fframeAux.setNewExtent(r); |
|
422 | 414 |
} |
423 |
|
|
424 |
/* |
|
425 |
* if (fframe.getTypeScale()!=IFFrameUseFMap.AUTOMATICO) { |
|
426 |
* fframeAux.setNewExtent(r); |
|
427 |
* fframeAux.refresh(); |
|
428 |
* layout.getEFS().modifyFFrame((IFFrame)fframe,(IFFrame) |
|
429 |
* fframeAux); |
|
430 |
* ((IFFrame)fframeAux).getBoundingBox(layout.getAT()); |
|
431 |
* layout.updateFFrames(); |
|
432 |
* layout.setIsReSel(true); |
|
433 |
* }else { |
|
434 |
*/ |
|
435 | 415 |
try { |
436 | 416 |
fframe.setNewEnvelope(geomManager.createEnvelope( |
437 | 417 |
r.getX(), r.getY(), r.getMaxX(), r.getMaxY(), |
... | ... | |
439 | 419 |
} catch (CreateEnvelopeException e) { |
440 | 420 |
logger.error("Error creating the envelope", e); |
441 | 421 |
} |
442 |
fframe.refresh(); |
|
443 |
if (fframe.getLinked()) { |
|
444 |
fframe.refreshOriginalExtent(); |
|
445 |
} |
|
446 |
// /} |
|
447 |
// Fin del else |
|
448 |
// layout.repaint(); |
|
449 | 422 |
} |
450 | 423 |
} |
451 | 424 |
} |
... | ... | |
465 | 438 |
if (fframes[i] instanceof IFFrameUseFMap) { |
466 | 439 |
IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i]; |
467 | 440 |
|
468 |
if (((IFFrame) fframe).getSelected() != IFFrame.NOSELECT) {
|
|
441 |
if (fframe.isSelected()) {
|
|
469 | 442 |
|
470 | 443 |
double nuevoX; |
471 | 444 |
double nuevoY; |
... | ... | |
497 | 470 |
} catch (CreateEnvelopeException e) { |
498 | 471 |
logger.error("Error creating the envelope", e); |
499 | 472 |
} |
500 |
fframe.refresh(); |
|
501 |
if (fframe.getLinked()) { |
|
502 |
fframe.refreshOriginalExtent(); |
|
503 |
} |
|
504 | 473 |
} |
505 | 474 |
} |
506 | 475 |
} |
branches/usability_v2/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/DefaultLayoutManager.java | ||
---|---|---|
77 | 77 |
static final String KEY_LAYOUT_FFRAME = |
78 | 78 |
"app.project.documents.layout.fframes"; |
79 | 79 |
|
80 |
private static final String PERSISTENCE_LAYOUT_DOCUMENT_DEFINITION_NAME =
|
|
80 |
public static final String PERSISTENCE_LAYOUT_DOCUMENT_DEFINITION_NAME =
|
|
81 | 81 |
"LayoutDocument"; |
82 | 82 |
|
83 | 83 |
private static final String LAYOUT_CONTEXT_MENUS = "Layout_ContextMenus"; |
... | ... | |
171 | 171 |
IFFrameDialog fframedialog = (IFFrameDialog) obj; |
172 | 172 |
fframedialog.setRectangle(fframe |
173 | 173 |
.getBoundingBox(affineTransform)); |
174 |
//Set the observer |
|
175 |
fframe.addObserver(layoutPanel.getLayoutControl()); |
|
176 | 174 |
return fframedialog; |
177 | 175 |
} |
178 | 176 |
} catch (Exception e) { |
... | ... | |
260 | 258 |
.getDefinition(AbstractDocument.PERSISTENCE_DEFINITION_NAME)); |
261 | 259 |
|
262 | 260 |
factory.persistenceDefinition |
263 |
.addDynFieldObject(DefaultLayoutDocument.LAYOUTCONTEXT_OBJECT) |
|
261 |
.addDynFieldObject(DefaultLayoutDocument.LAYOUT_CONTEXT_OBJECT)
|
|
264 | 262 |
.setClassOfValue(LayoutContext.class).setMandatory(false); |
265 | 263 |
|
266 | 264 |
DefaultLayoutPanel.registerPersistent(); |
... | ... | |
381 | 379 |
if (this.getDocumentClass().getName().equals(className)) { |
382 | 380 |
return this.persistenceDefinition; |
383 | 381 |
} |
384 |
|
|
385 |
// Class theClass; |
|
386 |
// try { |
|
387 |
// theClass = (Class) Class.forName(className); |
|
388 |
// } catch (ClassNotFoundException e) { |
|
389 |
// return null; |
|
390 |
// } |
|
391 |
// if ( this.manages(theClass)){ |
|
392 |
// return this.persistenceDefinition; |
|
393 |
// } |
|
394 | 382 |
return null; |
395 | 383 |
} |
396 | 384 |
|
branches/usability_v2/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/tools/listener/LayoutAddRectangleWithDialogListener.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import org.gvsig.andami.PluginServices; |
27 | 27 |
import org.gvsig.app.project.documents.layout.FLayoutUtilities; |
28 |
import org.gvsig.app.project.documents.layout.LayoutDocument; |
|
28 | 29 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
29 | 30 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog; |
30 | 31 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
... | ... | |
48 | 49 |
|
49 | 50 |
public void rectangle(EnvelopeEvent event) throws BehaviorException { |
50 | 51 |
IFFrame fframe = layoutManager.createFrame(getFFrameName()); |
51 |
fframe.setLayoutPanel(layoutPanel);
|
|
52 |
fframe.setDocument(this.layoutPanel.getDocument());
|
|
52 | 53 |
fframe.setLayoutContext(layoutPanel.getLayoutContext()); |
53 |
fframe.setLayoutControl(layoutPanel.getLayoutControl()); |
|
54 | 54 |
Rectangle2D r = new Rectangle2D.Double(); |
55 | 55 |
|
56 | 56 |
r = getRectangle(TOLERANCE); |
branches/usability_v2/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/DefaultLayoutDocument.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import org.gvsig.app.project.documents.AbstractDocument; |
25 | 25 |
import org.gvsig.app.project.documents.DocumentManager; |
26 |
import org.gvsig.app.project.documents.layout.fframes.FFrame; |
|
27 |
import org.gvsig.app.project.documents.layout.fframes.FFrameView; |
|
28 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
29 |
import org.gvsig.tools.ToolsLocator; |
|
30 |
import org.gvsig.tools.dynobject.DynStruct; |
|
31 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
26 | 32 |
import org.gvsig.tools.persistence.PersistentState; |
27 | 33 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
28 | 34 |
|
... | ... | |
35 | 41 |
LayoutDocument { |
36 | 42 |
|
37 | 43 |
private static final long serialVersionUID = 7320640550072493414L; |
44 |
public static final String PERSISTENCE_DEFINITION_NAME = "DefaultLayoutDocument"; |
|
38 | 45 |
|
39 |
static final String LAYOUTCONTEXT_OBJECT = "layoutContext"; |
|
46 |
static final String LAYOUT_CONTEXT_OBJECT = "layoutContext";
|
|
40 | 47 |
|
41 | 48 |
private LayoutContext layoutContext = null; |
42 | 49 |
|
... | ... | |
53 | 60 |
public void loadFromState(PersistentState state) |
54 | 61 |
throws PersistenceException { |
55 | 62 |
super.loadFromState(state); |
56 |
this.layoutContext = (LayoutContext) state.get(LAYOUTCONTEXT_OBJECT); |
|
63 |
this.layoutContext = (LayoutContext) state.get(LAYOUT_CONTEXT_OBJECT);
|
|
57 | 64 |
} |
58 | 65 |
|
59 | 66 |
public void saveToState(PersistentState state) throws PersistenceException { |
60 | 67 |
super.saveToState(state); |
61 |
state.set(LAYOUTCONTEXT_OBJECT, layoutContext); |
|
68 |
state.set(LAYOUT_CONTEXT_OBJECT, layoutContext);
|
|
62 | 69 |
} |
63 | 70 |
|
64 | 71 |
public LayoutContext getLayoutContext() { |
branches/usability_v2/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/LayoutContext.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import org.gvsig.app.project.documents.layout.commands.FrameCommandsRecord; |
27 | 27 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
28 |
import org.gvsig.app.project.documents.layout.toc.TocModelObserver; |
|
29 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
28 | 30 |
import org.gvsig.tools.observer.Observable; |
31 |
import org.gvsig.tools.observer.Observer; |
|
29 | 32 |
import org.gvsig.tools.persistence.Persistent; |
30 | 33 |
|
31 | 34 |
/** |
... | ... | |
245 | 248 |
public void setNumBehind(int numBehind); |
246 | 249 |
|
247 | 250 |
public void setNumBefore(int numBefore); |
251 |
|
|
252 |
/** |
|
253 |
* Sets the model of the TOC. The LayoutPanel will create |
|
254 |
* a TOC in the user interface if a tocModel has been set. |
|
255 |
*/ |
|
256 |
public void setTocModel(MapContext tocModel); |
|
248 | 257 |
|
258 |
/** |
|
259 |
* Gets the model of the TOC. The LayoutPanel will create |
|
260 |
* a TOC in the user interface if a tocModel has been set. |
|
261 |
*/ |
|
262 |
public MapContext getTocModel(); |
|
263 |
|
|
264 |
/** |
|
265 |
* Triggers a notification to the TocModel observers of type |
|
266 |
* {@link TocModelChangedNotification#MODEL_CHANGED} |
|
267 |
*/ |
|
268 |
public void notifyTocUpdated(); |
|
269 |
|
|
270 |
public void addTocObserver(TocModelObserver observer); |
|
271 |
|
|
272 |
public void removeTocObserver(TocModelObserver observer); |
|
273 |
|
|
274 |
public void removeTocObservers(); |
|
275 |
|
|
249 | 276 |
} |
branches/usability_v2/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/DefaultLayoutControl.java | ||
---|---|---|
524 | 524 |
|
525 | 525 |
public void refresh() { |
526 | 526 |
setStatus(DESACTUALIZADO); |
527 |
invalidate(); |
|
527 | 528 |
repaint(); |
528 | 529 |
} |
529 | 530 |
|
... | ... | |
597 | 598 |
|
598 | 599 |
public void update(Observable observable, Object notification) { |
599 | 600 |
if ((notification != null) && (notification instanceof LayoutNotification)){ |
600 |
LayoutNotification layoutNotification = (LayoutNotification)notification;
|
|
601 |
LayoutNotification layoutNotification = (LayoutNotification)notification;
|
|
601 | 602 |
if (LayoutNotification.LAYOUT_VALIDATED.equals(layoutNotification.getType())){ |
602 | 603 |
status = ACTUALIZADO; |
603 | 604 |
}else if (LayoutNotification.LAYOUT_INVALIDATED.equals(layoutNotification.getType())){ |
branches/usability_v2/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/LayoutNotification.java | ||
---|---|---|
28 | 28 |
* @version $Id$ |
29 | 29 |
* |
30 | 30 |
*/ |
31 |
public interface LayoutNotification {
|
|
31 |
public interface LayoutNotification { |
|
32 | 32 |
/** Fired when the layout has to be repainted */ |
33 | 33 |
public static final String LAYOUT_INVALIDATED = "layout_invalidated"; |
34 | 34 |
|
... | ... | |
37 | 37 |
|
38 | 38 |
/** Fired when the layout doesn't have to be repainted */ |
39 | 39 |
public static final String LAYOUT_REFRESH = "layout_refresh"; |
40 |
|
|
40 |
|
|
41 | 41 |
/** |
42 | 42 |
* Returns the type of this notification, represented by one of the constants defined in this interface. |
43 | 43 |
* @return a String containing this notification's type |
branches/usability_v2/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/DefaultLayoutContext.java | ||
---|---|---|
34 | 34 |
import org.gvsig.app.project.documents.layout.fframes.FFrameGroup; |
35 | 35 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
36 | 36 |
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap; |
37 |
import org.gvsig.app.project.documents.layout.toc.TocModelObserver; |
|
38 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
37 | 39 |
import org.gvsig.tools.ToolsLocator; |
38 | 40 |
import org.gvsig.tools.dynobject.DynStruct; |
39 | 41 |
import org.gvsig.tools.observer.ObservableHelper; |
... | ... | |
78 | 80 |
private AffineTransform m_MatrizTransf; |
79 | 81 |
|
80 | 82 |
private ObservableHelper observers; |
83 |
private CustomizableObserverHelper tocObservers = new CustomizableObserverHelper() { |
|
84 |
|
|
85 |
@Override |
|
86 |
protected void doNotify(Object listener, Object data) { |
|
87 |
TocModelObserver l = (TocModelObserver) listener; |
|
88 |
l.tocUpdated(DefaultLayoutContext.this, (TocModelChangedNotification) data); |
|
89 |
} |
|
90 |
}; |
|
91 |
|
|
92 |
private MapContext tocModel = null; |
|
81 | 93 |
|
82 | 94 |
/** |
83 | 95 |
* Create a new object of LayoutContext. |
... | ... | |
137 | 149 |
|
138 | 150 |
if (fframe.isSelected()) { |
139 | 151 |
observers.notifyObservers(this, |
140 |
new FrameChangedNotification(FrameChangedNotification.FRAME_REMOVING, fframe));
|
|
152 |
new FrameChangedNotificationImpl(FrameChangedNotificationImpl.FRAME_REMOVING, fframe));
|
|
141 | 153 |
fframe.setSelected(false); |
142 | 154 |
fcr.delete(fframe); |
143 | 155 |
observers.notifyObservers(this, |
144 |
new FrameChangedNotification(FrameChangedNotification.FRAME_REMOVED, fframe));
|
|
156 |
new FrameChangedNotificationImpl(FrameChangedNotificationImpl.FRAME_REMOVED, fframe));
|
|
145 | 157 |
} |
146 | 158 |
} |
147 | 159 |
fcr.endComplex(); |
... | ... | |
164 | 176 |
|
165 | 177 |
public void delFFrame(IFFrame frame) { |
166 | 178 |
observers.notifyObservers(this, |
167 |
new FrameChangedNotification(FrameChangedNotification.FRAME_REMOVING, frame));
|
|
179 |
new FrameChangedNotificationImpl(FrameChangedNotificationImpl.FRAME_REMOVING, frame));
|
|
168 | 180 |
for (int i = 0; i < fcr.getFrameManager().getAllFFrames().length; i++) { |
169 | 181 |
if (fcr.getFrameManager().getFFrame(i).equals(frame)) { |
170 | 182 |
frame.setSelected(false); |
... | ... | |
173 | 185 |
} |
174 | 186 |
updateFFrames(); |
175 | 187 |
observers.notifyObservers(this, |
176 |
new FrameChangedNotification(FrameChangedNotification.FRAME_REMOVED, frame));
|
|
188 |
new FrameChangedNotificationImpl(FrameChangedNotificationImpl.FRAME_REMOVED, frame));
|
|
177 | 189 |
} |
178 | 190 |
|
179 | 191 |
public FrameCommandsRecord getFrameCommandsRecord() { |
... | ... | |
183 | 195 |
public void addFFrame(IFFrame frame, boolean clearSelection, boolean select) { |
184 | 196 |
this.addObserver(frame); |
185 | 197 |
observers.notifyObservers(this, |
186 |
new FrameChangedNotification(FrameChangedNotification.FRAME_ADDING, frame)); |
|
198 |
new FrameChangedNotificationImpl(FrameChangedNotification.FRAME_ADDING, frame));
|
|
187 | 199 |
IFFrame[] fframes = getFFrames(); |
188 | 200 |
if (clearSelection) { |
189 | 201 |
for (int i = fframes.length - 1; i >= 0; i--) { |
... | ... | |
207 | 219 |
frame.setLevel(getNumBefore()); |
208 | 220 |
updateFFrames(); |
209 | 221 |
observers.notifyObservers(this, |
210 |
new FrameChangedNotification(FrameChangedNotification.FRAME_ADDED, frame));
|
|
222 |
new FrameChangedNotificationImpl(FrameChangedNotificationImpl.FRAME_ADDED, frame));
|
|
211 | 223 |
} |
212 | 224 |
|
213 | 225 |
public void addFFrameSameProperties(IFFrame frame) { |
214 | 226 |
this.addObserver(frame); |
215 | 227 |
observers.notifyObservers(this, |
216 |
new FrameChangedNotification(FrameChangedNotification.FRAME_ADDING, frame));
|
|
228 |
new FrameChangedNotificationImpl(FrameChangedNotificationImpl.FRAME_ADDING, frame));
|
|
217 | 229 |
fcr.insert(frame); |
218 | 230 |
frame.setSelected(true); |
219 | 231 |
frame.setLevel(getNumBefore()); |
220 | 232 |
updateFFrames(); |
221 | 233 |
observers.notifyObservers(this, |
222 |
new FrameChangedNotification(FrameChangedNotification.FRAME_ADDED, frame));
|
|
234 |
new FrameChangedNotificationImpl(FrameChangedNotificationImpl.FRAME_ADDED, frame));
|
|
223 | 235 |
} |
224 | 236 |
|
225 | 237 |
public int getNumBehind() { |
... | ... | |
342 | 354 |
|
343 | 355 |
public void notifAllObservers(){ |
344 | 356 |
observers.notifyObservers(this, |
345 |
new DefaultLayoutNotification(LayoutNotification.LAYOUT_REFRESH));
|
|
357 |
new DefaultLayoutNotification(LayoutNotification.LAYOUT_INVALIDATED));
|
|
346 | 358 |
} |
347 | 359 |
|
348 | 360 |
public static void registerPersistent() { |
... | ... | |
424 | 436 |
public void deleteObservers() { |
425 | 437 |
observers.deleteObservers(); |
426 | 438 |
} |
439 |
|
|
440 |
public void setTocModel(MapContext tocModel) { |
|
441 |
MapContext oldModel = this.tocModel; |
|
442 |
this.tocModel = tocModel; |
|
443 |
if (tocModel==oldModel){ |
|
444 |
// no real change |
|
445 |
return; |
|
446 |
} |
|
447 |
else { |
|
448 |
tocObservers.notifyObservers(this, |
|
449 |
new TocModelChangedImpl(TocModelChangedNotification.MODEL_SET, tocModel)); |
|
450 |
} |
|
451 |
} |
|
452 |
|
|
453 |
public void notifyTocUpdated() { |
|
454 |
tocObservers.notifyObservers(this, |
|
455 |
new TocModelChangedImpl(TocModelChangedNotification.MODEL_CHANGED, tocModel)); |
|
456 |
|
|
457 |
} |
|
458 |
|
|
459 |
public MapContext getTocModel() { |
|
460 |
return this.tocModel; |
|
461 |
} |
|
462 |
|
|
463 |
public void addTocObserver(TocModelObserver observer) { |
|
464 |
this.tocObservers.addObserver(observer); |
|
465 |
} |
|
466 |
|
|
467 |
public void removeTocObserver(TocModelObserver observer) { |
|
468 |
this.tocObservers.deleteObserver(observer); |
|
469 |
} |
|
470 |
|
|
471 |
public void removeTocObservers() { |
|
472 |
this.tocObservers.deleteObservers(); |
|
473 |
} |
|
427 | 474 |
} |
branches/usability_v2/org.gvsig.app.document.layout.app/pom.xml | ||
---|---|---|
3 | 3 |
<modelVersion>4.0.0</modelVersion> |
4 | 4 |
<artifactId>org.gvsig.app.document.layout.app</artifactId> |
5 | 5 |
<packaging>pom</packaging> |
6 |
<version>2.0.22-SNAPSHOT</version>
|
|
6 |
<version>2.0.23-SNAPSHOT</version>
|
|
7 | 7 |
|
8 | 8 |
<name>Document: Layout document support</name> |
9 | 9 |
<description>This plugin adds creation/management of layout (map) documents.</description> |
Also available in: Unified diff