public DocContext setupNewDoc(DocModeHelper modeHelper, final CanvasDocument origDoc) throws Exception {
final DocContext context = modeHelper.createDocContext(this);
contexts.add(context);
CanvasDocument doc = origDoc;
//create a new doc if one wasn't passed in
if(doc == null) {
doc = modeHelper.createNewDoc();
}
context.setupActions();
context.setupPalettes();
context.stackPanel = new StackPanel();
ScrollPane scrollPane = new ScrollPane(
context.getCanvas()
.setWidth(300)
.setHeight(300)
);
final Ruler hruler = new Ruler(false,scrollPane,context);
final Ruler vruler = new Ruler(true,scrollPane,context);
final CanvasDocument fdoc = doc;
context.stackPanel.add(
new Panel() {
@Override
public void doLayout() {
hruler.setVisible(fdoc.isRulersVisible());
vruler.setVisible(fdoc.isRulersVisible());
super.doLayout();
for(Control c : controlChildren()) {
if(c == hruler && fdoc.isRulersVisible()) {
c.setWidth(getWidth()-30);
c.setHeight(30);
c.setTranslateX(30);
c.setTranslateY(0);
}
if(c == vruler && fdoc.isRulersVisible()) {
c.setWidth(30);
c.setHeight(getHeight()-30);
c.setTranslateX(0);
c.setTranslateY(30);
}
if(c instanceof ScrollPane) {
if(fdoc.isRulersVisible()) {
c.setWidth(getWidth()-30);
c.setHeight(getHeight()-30);
c.setTranslateX(30);
c.setTranslateY(30);
} else {