From b810e46d4bbc7907af2b96f982d61f8c8e29ff62 Mon Sep 17 00:00:00 2001 From: Max Schenkelberg Date: Mon, 14 May 2012 17:13:54 -0500 Subject: [PATCH] Issue #588 Added canvas size to construction of editor Change-Id: I72a634c2b15f654474557ec9824fa11550a6a2a7 Former-commit-id: df5cc2e0c3a895caf4b4a6a58ef8030fd012e720 [formerly f3ec9008f28c9c5b583843d3b759ade483ddcc64] [formerly f3277ca807f86735e88a57f8e8f8cde92cca59d5 [formerly 82ef715dda2308686870e18aca6184ea2f0f71f2]] Former-commit-id: f3277ca807f86735e88a57f8e8f8cde92cca59d5 Former-commit-id: 5f2e758c25c5128a3ea3df8d13f79e5e739eb4af --- .../display/editor/CollaborationEditor.java | 8 ++-- .../display/editor/SharedEditorData.java | 37 +++++++++++++++++++ .../collaboration/ui/editor/EditorSetup.java | 14 ++++++- 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/cave/com.raytheon.uf.viz.collaboration.display/src/com/raytheon/uf/viz/collaboration/display/editor/CollaborationEditor.java b/cave/com.raytheon.uf.viz.collaboration.display/src/com/raytheon/uf/viz/collaboration/display/editor/CollaborationEditor.java index 3167a240e7..7f49417ca3 100644 --- a/cave/com.raytheon.uf.viz.collaboration.display/src/com/raytheon/uf/viz/collaboration/display/editor/CollaborationEditor.java +++ b/cave/com.raytheon.uf.viz.collaboration.display/src/com/raytheon/uf/viz/collaboration/display/editor/CollaborationEditor.java @@ -153,12 +153,12 @@ public class CollaborationEditor extends AbstractEditor { // Subtract size of scroll bars if visible ScrollBar vertical = scrollable.getVerticalBar(); ScrollBar horizon = scrollable.getHorizontalBar(); - if (vertical.isVisible()) { - scrollableBounds.width -= vertical.getSize().x; - } - if (horizon.isVisible()) { + if (scrollableBounds.width <= canvasBounds.width) { scrollableBounds.height -= horizon.getSize().y; } + if (scrollableBounds.height <= canvasBounds.height) { + scrollableBounds.width -= vertical.getSize().x; + } wrapperComp.setSize( Math.max(canvasBounds.width, scrollableBounds.width), diff --git a/cave/com.raytheon.uf.viz.collaboration.display/src/com/raytheon/uf/viz/collaboration/display/editor/SharedEditorData.java b/cave/com.raytheon.uf.viz.collaboration.display/src/com/raytheon/uf/viz/collaboration/display/editor/SharedEditorData.java index c5d75955e2..7d18cc5604 100644 --- a/cave/com.raytheon.uf.viz.collaboration.display/src/com/raytheon/uf/viz/collaboration/display/editor/SharedEditorData.java +++ b/cave/com.raytheon.uf.viz.collaboration.display/src/com/raytheon/uf/viz/collaboration/display/editor/SharedEditorData.java @@ -23,6 +23,7 @@ import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; @@ -68,6 +69,12 @@ public class SharedEditorData implements ISerializableObject { /** the view's extent, i.e. the current zoom/pan */ private Envelope envelope; + @XmlAttribute + private int width; + + @XmlAttribute + private int height; + @XmlElement @XmlJavaTypeAdapter(value = GridGeometryAdapter.class) public GeneralGridGeometry getGeometry() { @@ -96,4 +103,34 @@ public class SharedEditorData implements ISerializableObject { this.envelope = envelope; } + /** + * @return the width + */ + public int getWidth() { + return width; + } + + /** + * @param width + * the width to set + */ + public void setWidth(int width) { + this.width = width; + } + + /** + * @return the height + */ + public int getHeight() { + return height; + } + + /** + * @param height + * the height to set + */ + public void setHeight(int height) { + this.height = height; + } + } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/editor/EditorSetup.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/editor/EditorSetup.java index bc5a40f783..8c24e2727e 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/editor/EditorSetup.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/editor/EditorSetup.java @@ -23,6 +23,8 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.eclipse.swt.graphics.Rectangle; + import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -37,6 +39,7 @@ import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.PixelExtent; import com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay; import com.raytheon.uf.viz.core.drawables.IDescriptor; +import com.raytheon.uf.viz.core.drawables.IRenderableDisplay; import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.map.MapDescriptor; @@ -78,8 +81,10 @@ public class EditorSetup { public static SharedEditorData extractSharedEditorData(AbstractEditor editor) { SharedEditorData se = new SharedEditorData(); + IRenderableDisplay display = editor.getActiveDisplayPane() + .getRenderableDisplay(); // extract grid geometry - IDescriptor desc = editor.getActiveDisplayPane().getDescriptor(); + IDescriptor desc = display.getDescriptor(); se.setGeometry(desc.getGridGeometry()); // extract extent to get the proper zoom/pan @@ -104,6 +109,11 @@ public class EditorSetup { } se.setLocalResources(rscList); + // Set current size + Rectangle bounds = display.getBounds(); + se.setWidth(bounds.width); + se.setHeight(bounds.height); + return se; } @@ -135,6 +145,8 @@ public class EditorSetup { displays[0] = disp; editor = (CollaborationEditor) UiUtil.createEditor( CollaborationEditor.EDITOR_ID, displays); + editor.setCanvasSize(new Rectangle(0, 0, sharedEditor.getWidth(), + sharedEditor.getHeight())); } catch (VizException e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); }