Posts

uml - Visual Studio 2010 Sequence Diagrams Cannot load -

i editing vs 2010 sequence diagram , after saving , closing it, can no longer open it. following error. know how resolve this? "cannot load '{diagram path , name}': value cannot null. parameter name: roleplayer" the title of dialog "microsoft visual studio" this question answered on msdn visualization & modeling tools forum .

java - Efficient way to divide a list into lists of n size -

i have array, want divide smaller arrays of n size, , perform operation on each. current method of doing is implemented arraylists in java (any pseudocode do) (int = 1; <= math.floor((a.size() / n)); i++) { arraylist temp = subarray(a, ((i * n) - n), (i * n) - 1); // stuff temp } private arraylist<comparable> subarray(arraylist a, int start, int end) { arraylist toreturn = new arraylist(); (int = start; <= end; i++) { toreturn.add(a.get(i)); } return toreturn; } where list, n size of desired lists i believe way taking time when working considerably large lists (of 1 million in size) i'm trying figure out more efficient. you'll want makes use of list.sublist(int, int) views rather copying each sublist. easily, use guava 's lists.partition(list, int) method: list<foo> foos = ... (list...

java - How does this code for delaunay triangulation work? -

i have java code set of point in input return set of graph's edge represent delaunay triangulation. i know strategy used this, if exist, name of algorithm used. in code graphedge contains 2 awt point , represent edge in triangulation, graphpoint extends awt point, , edges of final triangulation returned in treeset object. my purpose understand how method works: public treeset getedges(int n, int[] x, int[] y, int[] z) below complete source code of triangulation : import java.awt.point; import java.util.iterator; import java.util.treeset; public class delaunaytriangulation { int[][] adjmatrix; delaunaytriangulation(int size) { this.adjmatrix = new int[size][size]; } public int[][] getadj() { return this.adjmatrix; } public treeset getedges(int n, int[] x, int[] y, int[] z) { treeset result = new treeset(); if (n == 2) { this.adjmatrix[0][1] = 1; this.adjmatrix[1][0] = 1; result.add(new graphedg...

java - JPanel Preferred Size Not Being Set -

when preferred size of jpanel set if don't set explicitly? i have following code: private static class scrollablejpanel extends jpanel implements scrollable { @override public dimension getpreferredscrollableviewportsize() { return getpreferredsize(); } . . . } and code: mypanel = new scrollablejpanel(); // add bunch of controls panel. final jscrollpane scroll = new jscrollpane(mypanel); scroll.setautoscrolls(true); scroll.sethorizontalscrollbarpolicy( scrollpaneconstants.horizontal_scrollbar_never); however, preferred size of mypanel @ time getpreferredscrollableviewportsize() being called seems arbitrary value, (4225, 34), , prefsizeset = false. according java documentation , reasonable way define method. however, actual size of mypanel higher 34 pixels, view port way small. what doing wrong here? should set preferred size of mypanel explicitly? tried that, w...

Ruby on Rails - Test Unit -

i have test : test "should not allow access" :new assert_redirected_to new_user_session_url end i use devise authentication. i have 2 views each of actions: 1 normal, , 1 mobile devices, before i've used usual default view (sign_in.html.erb) - test pass, when i've added mobile view (sign_in.mobile.erb) i've got next fail message. expected response redirect http://test.host/users/sign_in redirect http://test.host/users/sign_in.mobile so client testing point of view - logic working fine, e.g. in case if user not authenticated redirected session new path (new_user_session_url). works mobile devices (mobile client redirected mobile view of sign in page), test fail reasons if client mobile device , controller redirect mobile view. my question how fix test ? i've tried : assert_redirected_to new_user_session_path assert_redirected_to :controller => "devise/session", :action => "new" but no success , same fai...

c# - Converting code using generics -

i've following code uses passed object , acts on after determining type. question if convert use generics, performance advantage since i'd still have determine type of t before act upon it? save ticks on boxing/unboxing? private void bindoptionfields(object obj, string selectedvalue, int datalanguageid) { string typ = obj.gettype().name; switch(typ.tolower()) { case "ratingscaleitem": setratingscale((common.ratingscaleitem)obj, datalanguageid, selectedvalue); break; case "taskstatus": text = ((taskstatus)obj).taskname; optionvalue = ((taskstatus)obj).stateid.tostring(); break; case "planlite": text = ((xyz.abc.planlite)obj).planname; optionvalue = ((xyz.abc.planlite)obj).id.tostring(); break; case "datarow": tex...

c++ - OpenGLESv2 Shader glGetAttribLocation returns -1 -

hey, try code opengl es 2 engine @ shader creation function glgetattriblocation returns -1 means the named attribute variable not active attribute in specified program object or name starts reserved prefix "gl_". but defined in shader , doesnt start gl_. whats wrong code? c++ code: glprogram = glcreateprogram(); glvertshader = glcreateshader(gl_vertex_shader); glfragshader = glcreateshader(gl_fragment_shader); glshadersource(glvertshader, 1, vertsrc, null); glshadersource(glfragshader, 1, fragsrc, null); glint ret; glcompileshader(glvertshader); glgetshaderiv(glvertshader, gl_compile_status, &ret); if(!ret) { ///error handling - stripped internet } glcompileshader(glfragshader); glgetshaderiv(glfragshader, gl_compile_status, &ret); if(!ret) { ///error handling - stripped internet } glattachshader(glprogram, glvertshader); glattachshader(glprogram, glfragshader); gllinkprogram(glprogram); glgetprogramiv(glprogram, gl_link_stat...