Profile picture for user schmidtm

Hi there!

 

I want to program a report and output the model graphic in there. I am searching for a parameter of the graphic which determines whether the model is set in panel or landscape format by the aris author in the page layout settings. I could only find parameters for CutObjects (boolean), BlackWhite (boolean) and localeId (int) for the Graphic object and the getPrintScale() methode of the model. Is there a get-Method to get the format too?

Once I know the setting by parameter I can set the pageHeigt and pageWidth, so that the section is output in either panel or landscape format.

Thanks in advance

Markus

by Michel Van Nijlen
Posted on Tue, 09/20/2011 - 13:34

Hello,

I think that you must only start a new page, set page heigth an page width -swapping heigth and width-, output the graphic, start a new page, and set again heigth an width for next page.

Test it.

 

0
by Markus Schmidt Author
Posted on Tue, 09/20/2011 - 14:35

Hi,

yes this would be the result. But I don't know what format the model is at the execution of the report. The report should somehow get it itself, if it is in panel or landscape format. So I need some methode like Graphic.getFormat() to decide which value I must set for pageHeight and pageWidth.

 

0
by Francois Du Toit
Posted on Tue, 09/20/2011 - 21:19

Hi Markus,

 

You need to get the model's flag for landscape settings...



 


function getModelFlag(model, flagNumber) {
    var flagArr = new Array(65536,32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1);
    var flagsVal = model.Flags();
    var tempVal = flagsVal;
    if(numberInArray(flagNumber, flagArr) && (flagsVal > flagNumber)) {
        for(var fc = 0; fc < flagArr.length; fc++) {
            var newVal = tempVal - flagArr[fc];
            if(newVal >= 0) {
                tempVal = newVal;
                if(flagArr[fc] == flagNumber) {
                    return true;
                }
            }
        }
    }
    return false;
}

landscape = getModelFlag(model, Constants.MODEL_PRINT_LANDSCAPE)

For some reason ARIS Scripting allows you to set a flag, but not get it, so I had to write the function for it. It might not be pretty but it works. It will also work for other model flags. You can do a search for the MODEL_PRINT_LANDSCAPE to find the other flags.

Kind regards,

Francois du Toit

0
by Markus Schmidt Author
Posted on Sun, 10/23/2011 - 17:59

Hi Francois!

I am now on it to test your solution. Could you please tell me also your

numberInArray(flagNumber, flagArr)

function. Unfortunatly it's not in the code above and I don't know what you do with it.

I think it is the last block for me to finally get the landscape setting out of ARIS.

Thanks a lot in advance!

Best regards,

Markus

0
by Markus Schmidt Author
Posted on Wed, 09/21/2011 - 11:11

Hi Francois!

Thanx a lot for sharing and giving me a solution. I will test it, when I implemented the rest of the report but this is exactly what I was searching for!

Best regards and have a nice Day,

Markus

0
by Francois Du Toit
Posted on Mon, 10/24/2011 - 10:08

Hi Markus,

Sorry about that, here is the other function:

function numberInArray(num, Arr) {
    for(var nc = 0; nc < Arr.length; nc++) {
        if(num == Arr[nc]) {
            return true;
        }
    }
    return false;
}

Thanks,

Francois

0
by Markus Schmidt Author
Posted on Mon, 10/24/2011 - 14:12

Hi Francois!

Well I finished to implement your code in a simple report but I still struggle to get the correct result. It seems that the landscape variable is always set to false.

I spent a while looking with the debugger and found that flagsVal = model.Flags(); never really gets a value so the function can calculate furhter correctly. If I use the methode model.Flags() the program does not like the () at the end. Without the () it never gets a value. Maybe you can figure out my problem. Here's the code from the whole report:

var oOutput = Context.createOutputObject()
var xlTableActive=false
oOutput.DefineF(getString("ID_STYLE_RD_HEADING_1"), getString("ID_DEFAULT_FONT"), 18, RGB(0,0,0), Constants.C_TRANSPARENT,  Constants.FMT_BOLD | Constants.FMT_LEFT| Constants.FMT_VTOP| Constants.FMT_TOCENTRY0 , 0, 0, 4, 4, 0, 1)
oOutput.DefineF(getString("ID_STYLE_RD_TABLE_HEAD"), getString("ID_DEFAULT_FONT"), 8, RGB(0,0,0), Constants.C_TRANSPARENT,  Constants.FMT_BOLD | Constants.FMT_CENTER| Constants.FMT_VTOP, 0, 0, 0, 0, 0, 1)
oOutput.DefineF(getString("ID_STYLE_RD_HEADING_4"), getString("ID_DEFAULT_FONT"), 12, RGB(0,0,0), Constants.C_TRANSPARENT,  Constants.FMT_ITALIC | Constants.FMT_BOLD | Constants.FMT_LEFT| Constants.FMT_VTOP| Constants.FMT_TOCENTRY3 , 0, 0, 0, 0, 0, 1)
oOutput.DefineF(getString("ID_STYLE_RD_DEFAULT"), getString("ID_DEFAULT_FONT"), 11, RGB(0,0,0), Constants.C_TRANSPARENT,  Constants.FMT_LEFT| Constants.FMT_VTOP, 0, 0, 0, 0, 0, 1)
oOutput.DefineF(getString("ID_STYLE_RD_HEADING_2"), getString("ID_DEFAULT_FONT"), 14, RGB(0,0,0), Constants.C_TRANSPARENT,  Constants.FMT_ITALIC | Constants.FMT_BOLD | Constants.FMT_LEFT| Constants.FMT_VTOP| Constants.FMT_TOCENTRY1 , 0, 0, 2, 2, 0, 1)
oOutput.DefineF(getString("ID_STYLE_RD_TITLE"), getString("ID_DEFAULT_FONT"), 21, RGB(0,0,0), Constants.C_TRANSPARENT,  Constants.FMT_BOLD | Constants.FMT_CENTER| Constants.FMT_VTOP, 0, 0, 1.76, 8.82, 0, 1)
oOutput.DefineF(getString("ID_STYLE_RD_HEADING_3"), getString("ID_DEFAULT_FONT"), 12, RGB(0,0,0), Constants.C_TRANSPARENT,  Constants.FMT_ITALIC | Constants.FMT_BOLD | Constants.FMT_LEFT| Constants.FMT_VTOP| Constants.FMT_TOCENTRY2 , 0, 0, 1, 1, 0, 1)
oOutput.DefineF(getString("ID_STYLE_RD_HEADER_FOOTER"), getString("ID_DEFAULT_FONT"), 10, RGB(0,0,0), Constants.C_TRANSPARENT,  Constants.FMT_LEFT| Constants.FMT_VTOP, 0, 0, 0, 0, 0, 1)
oOutput.DefineF(getString("ID_STYLE_RD_TABLE_CONTENT"), getString("ID_DEFAULT_FONT"), 8, RGB(0,0,0), Constants.C_TRANSPARENT,  Constants.FMT_LEFT| Constants.FMT_VTOP, 0, 0, 0, 0, 0, 1)
oOutput.DefineF(getString("ID_STYLE_RD_INFO"), getString("ID_DEFAULT_FONT"), 14, RGB(0,0,0), Constants.C_TRANSPARENT,  Constants.FMT_BOLD | Constants.FMT_CENTER| Constants.FMT_VTOP, 0, 0, 1.76, 8.82, 0, 1)
setupOutputObject( oOutput )
oOutput.SetTitle(Context.getScriptInfo(Constants.SCRIPT_NAME))

var nLocale = Context.getSelectedLanguage()
createSection1(oOutput, ArisData.getSelectedModels())
oOutput.WriteReport()

var landscape

/** Apply default page format settings to output object
 * @param {Output} outputObj The output object
 */
function setupOutputObject(outputObj)
{
    if (landscape==true){
        outputObj.SetPageWidth(297.2)
        outputObj.SetPageHeight(210.1)
    }
    else {
     outputObj.SetPageWidth(210.1)
     outputObj.SetPageHeight(297.2)
    }
 outputObj.SetLeftMargin(20)
 outputObj.SetRightMargin(20)
 outputObj.SetTopMargin(20)
 outputObj.SetBottomMargin(10)
 outputObj.SetDistHeader(5)
 outputObj.SetDistFooter(10)
 outputObj.SetAutoTOCNumbering(true)
 globalHeader(outputObj)

 globalFooter(outputObj)
}
function globalHeader(outputObj) {
 outputObj.BeginHeader()
 outputObj.EndHeader()
}
function globalFooter(outputObj) {
 outputObj.BeginFooter()
 outputObj.EndFooter()
}

/**
 * @param {Output} p_output The output object
 * @param {Model[]} p_aModel 
*/
function createSection1(p_output, p_aModel)
{

 // do not create new section if all data is empty
 if(p_aModel.length==0)
  return

    //start coding S2M

    function getModelFlag(model, flagNumber) {
     var flagArr = new Array(65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1);
     var flagsVal = model.Flags;
     var tempVal = flagsVal;
     if(numberInArray(flagNumber, flagArr) && (flagsVal > flagNumber)) {
         for(var fc = 0; fc < flagArr.length; fc++) {
             var newVal = tempVal - flagArr[fc];
             if(newVal >= 0) {
                 tempVal = newVal;
                 if(flagArr[fc] == flagNumber) {
                     return true;
                 }
             }
         }
     }
     return false;
    }

    function numberInArray(num, Arr) {
     for(var nc = 0; nc < Arr.length; nc++) {
         if(num == Arr[nc]) {
            return true;
         }
     }
     return false;
}

var landscape = getModelFlag(p_aModel, Constants.MODEL_PRINT_LANDSCAPE); 
//end of coding S2M

 //produce one table sheet per section
 if(xlTableActive && Context.getSelectedFormat()==Constants.OUTEXCEL) {
  p_output.EndTable("", 100, "", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT, 0)
  xlTableActive=false
 }
 p_output.BeginSection(false, Constants.SECTION_DEFAULT)
 setupOutputObject( p_output ) //use defaults
 if(Context.getSelectedFormat()==Constants.OUTEXCEL) {
  p_output.BeginTable(100, Constants.C_BLACK, Constants.C_TRANSPARENT,  Constants.FMT_LEFT | Constants.FMT_REPEAT_HEADER, 0)
  xlTableActive=true
 }
 // repetition of queried data:
 for(var i=0; i<p_aModel.length; i++) {
  p_output.BeginParagraphF(getString("ID_STYLE_RD_DEFAULT"))
  writeData(p_output, p_aModel[i])
  p_output.EndParagraph()
 }

 // createSection1 local functions:
 /**
  * @param {Output} p_output The output object
  * @param {IModelPicture } p_IModelPicture
 */
 function writeData(p_output, p_IModel) {
        p_output.OutGraphic(p_IModel.Graphic(true, false, nLocale), p_IModel.getPrintScale(), p_output.getCurrentMaxWidth(), p_output.GetPageHeight() - p_output.GetTopMargin() - p_output.GetBottomMargin() -10)
  //p_output.OutGraphic(p_IModelPicture, -1, p_output.getCurrentMaxWidth(), p_output.GetPageHeight() - p_output.GetTopMargin() - p_output.GetBottomMargin() -10)
 }
 if(Context.getSelectedFormat()==Constants.OUTEXCEL) {
  p_output.EndTable(getString("ID_REPORTDEF_5"), 100, "", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT, 0)
  xlTableActive=false
 }
 p_output.EndSection()


}


function RGB(r, g, b) {
 return (new java.awt.Color(r/255.0,g/255.0,b/255.0,1)).getRGB() & 0xFFFFFF
}
0

Featured achievement

Genius
You like to help others solve their problems by answering questions.
Recent Unlocks
  • KF
  • KH
  • RG
  • Profile picture for user Vee_ARIS
  • Profile picture for user smarty
  • PacMan

Leaderboard

|
icon-arrow-down icon-arrow-cerulean-left icon-arrow-cerulean-right icon-arrow-down icon-arrow-left icon-arrow-right icon-arrow icon-back icon-close icon-comments icon-correct-answer icon-tick icon-download icon-facebook icon-flag icon-google-plus icon-hamburger icon-in icon-info icon-instagram icon-login-true icon-login icon-mail-notification icon-mail icon-mortarboard icon-newsletter icon-notification icon-pinterest icon-plus icon-rss icon-search icon-share icon-shield icon-snapchat icon-star icon-tutorials icon-twitter icon-universities icon-videos icon-views icon-whatsapp icon-xing icon-youtube icon-jobs icon-heart icon-heart2 aris-express bpm-glossary help-intro help-design Process_Mining_Icon help-publishing help-administration help-dashboarding help-archive help-risk icon-knowledge icon-question icon-events icon-message icon-more icon-pencil forum-icon icon-lock