Autodesk 15606-011408-9300 Developer Guide - Page 82
onEndLayout, MGPrintLayout, MGPrintInfo
UPC - 606121429548
View all Autodesk 15606-011408-9300 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 82 highlights
3 Write the event handler. It goes in the HTML page (or the JavaScript .js file), just like any other JavaScript function. This function is executed automatically every time the onEndLayout event fires. Note that the function takes an MGPrintLayout object and an MGPrintInfo object as its parameters: function onEndLayout (layout, info) { if (new_symbol == "true") { int pixelsPerInch = info.getPageResolution(); // retrieve the page elements from the MGPrintInfo class MGPageElement mapEle = layout.getPageElement("mg_map"); MGPageElement logoEle = layout.addSymbol("mylogo"); // get the extents of the page elements MGExtentEx mapExt = mapEle.getExtent() MGExtentEx logoExt = logoEle.getExtent(); // set the width and height of the logo to 1" by 1" logoExt.set(mapExt.getMinX(), mapExt.getMinY(), mapExt.getMinX() + pixelsPerInch, mapExt.getMinY() + pixelsPerInch); logoEle.setExtent(logoExt); } } The following code shows how to implement the same event handler for the onEndLayout event in Java: public class MyObserver extends Applet implements MGPrintingObserver { public void onEndLayout(MGPrintLayout layout, MGPrintInfo info) { int pixelsPerInch = info.getPageResolution(); // retrieve the page elements from the MGPrintInfo class MGPageElement mapEle = layout.getPageElement("mg_map"); MGPageElement logoEle = layout.addSymbol("mylogo"); // get the extents of the page elements MGExtentEx mapExt = mapEle.getExtent() MGExtentEx logoExt = logoEle.getExtent(); // set the width and height of the logo to 1" by 1" logoExt.set(mapExt.getMinX(), mapExt.getMinY(), mapExt.getMinX() + pixelsPerInch, mapExt.getMinY() + pixelsPerInch); logoEle.setExtent(logoExt); } } 82 | Chapter 5 Handling Events