Issue #588 Added canvas size to construction of editor

Change-Id: I72a634c2b15f654474557ec9824fa11550a6a2a7

Former-commit-id: df5cc2e0c3 [formerly f3ec9008f2] [formerly f3277ca807 [formerly 82ef715dda2308686870e18aca6184ea2f0f71f2]]
Former-commit-id: f3277ca807
Former-commit-id: 5f2e758c25
This commit is contained in:
Max Schenkelberg 2012-05-14 17:13:54 -05:00
parent 9daf435929
commit b810e46d4b
3 changed files with 54 additions and 5 deletions

View file

@ -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),

View file

@ -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;
}
}

View file

@ -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);
}