001 package railo.runtime.functions.image; 002 003 import railo.runtime.PageContext; 004 import railo.runtime.exp.ExpressionException; 005 import railo.runtime.exp.PageException; 006 import railo.runtime.img.Image; 007 import railo.runtime.op.Caster; 008 import railo.runtime.type.Array; 009 010 public class ImageDrawLines { 011 012 public static String call(PageContext pc, Object name, Array xcoords, Array ycoords) throws PageException { 013 return call(pc, name, xcoords, ycoords, false, false); 014 } 015 016 public static String call(PageContext pc, Object name, Array xcoords, Array ycoords, boolean isPolygon) throws PageException { 017 return call(pc, name, xcoords, ycoords, isPolygon, false); 018 } 019 020 public static String call(PageContext pc, Object name, Array xcoords, Array ycoords, boolean isPolygon, boolean filled) throws PageException { 021 if(name instanceof String) name=pc.getVariable(Caster.toString(name)); 022 Image img = Image.toImage(name); 023 024 if(xcoords.size()!=ycoords.size()) 025 throw new ExpressionException("xcoords and ycoords has not the same size"); 026 img.drawLines(toIntArray(xcoords), toIntArray(ycoords), isPolygon, filled); 027 return null; 028 } 029 030 private static int[] toIntArray(Array arr) throws PageException { 031 int[] iarr=new int[arr.size()]; 032 for(int i=0;i<iarr.length;i++) { 033 iarr[i]=Caster.toIntValue(arr.getE(i+1)); 034 } 035 return iarr; 036 } 037 038 }