Posts

graphics - RaphaelJs : How to add some text to an area defined by a path? -

i have svg image of united states i've drawn little bit of raphaël js: http://jsfiddle.net/zcrkg/2/ what want place text right of each state when hover on it. problem that, since each state path, quite difficult determine x & y coordinates place label. so, know way of calculating centre of path using raphaël? if failing know how given array of vectors? what you're looking getbbox function in raphaël . give bounding box object can use calculate central point of path: var bbox = st.getbbox(); var text = r.text(bbox.x + bbox.width/2, bbox.y + bbox.height/2, "foo"); i forked fiddle , made show static text in middle of each state on hover. picking state name data left exercise.

windows - How to get the missing DLL name after when GetLastError() returns ERROR_MOD_NOT_FOUND -

my application loads dll using loadlibrary() suppressing standard critical-error-handler message box. when loadlibrary() fails , getlasterror() returns error_mod_not_found (0x7e) i'd retrieve missing dll name. error code set not when requested dll missing, but when dll depends on missing . it's worth noting standard message box (which suppressed) displays correct missing dll name, , question how can within code. thanks i'm not sure there's easy way of getting missing dll's name. can find stepping through loadlibrary() in debugger , seeing function fails filename in parameters. depends.exe can show dependencies. also, might worth try firing process monitor , using appropriate filters see i/o errors there in process , files.

When to open and when to close the mysql connection while using Java servlets? -

is ok open connection in init method , close in destroy method? what's best way open connection mysql database. i'm using this: class.forname("com.mysql.jdbc.driver"); connection connect = drivermanager.getconnection("jdbc:mysql://" + ipaddress + "?user=" + user + "&password=" + pass); but read somewhere inefficient , should use connection pool. how that? i suggest using connection pool, either explicitly (such c3p0 ) or 1 provided servlet container. open database connection when need it, close can - connection pool take care of real network connection. unless this, you'll end 1 connection whole application - means can process 1 query @ time, , code needs synchronize around database queries. surely want multiple entirely-independent queries able execute simultaneously? can't single connection. as best way of opening connection having configured appropriate connection pool - may still end using driverm...

depth first search - Java: Trouble randomizing a DFS run to build a maze -

i'm having trouble randomizing visit node neighbors, whole graph (a mxn array, in test 4x4) visited, don't i'm doing wrong here. import java.util.arraylist; class ij { int i; int j; ij (int i,int j){ = this.i; j= this.j; } } class graph { int m; int n; int adjacencymatrix[][]; arraylist <ij> orderofvisits; graph(int m,int n){ this.m=m; this.n=n; adjacencymatrix=new int[m][n]; (int i=0; i<m; i++) (int j=0;j<n;j++){ adjacencymatrix[i][j]=-1; //mark vertices not visited } orderofvisits = new arraylist<ij>(); } string northoreast () { double lottery = math.random(); if (lottery>0.5d) {return "north";} else {return "south";} } string southoreastornorth() { double lottery=math.random(); if (lottery<=0.33d){ return "...

java - Red-Black tree rebalance problem? -

is there constraint onto compareto method orders objects put standard java treeset (i.e. collection implemented red-black tree)? have public class ruletuple implements comparable { string head; string[] rhs; public string tostring() { stringbuffer b = new stringbuffer(); b.append(head+":"); for( string t: rhs ) b.append(" "+t); return b.tostring(); } public int compareto(object obj) { ruletuple src = (ruletuple)obj; int cmp = head.compareto(src.head); if( cmp!=0 ) return cmp; if( rhs.length != src.rhs.length ) return rhs.length - src.rhs.length; for( int i=0; i<rhs.length; i++ ) if( rhs[i].compareto(src.rhs[i]) != 0 ) return rhs[i].compareto(src.rhs[i]); return 0; } ... } i assumed method mapping object linear order fine, long meets partial order criteria: reflexivity, asymmetry, , tr...

html - Add a css link to xhtml files that I cannot modify using an XSLT? -

according programming supervisor should able link css file xhtml file cannot touch using xslt. how achieved? have ideas? how "run" xslt? open in browser? i need format xhtml page fits onto mobile device, cannot control or modify xhtml page coming in (its basic xhtml). how link these xhtml pages .css? sorry if sounds confusing, clarification questions happy answer. thanks in advance. xslt transforming xml html/xhtml. because xml data. there many different ways access or display data xml, php , xslt. so clear xslt can not "run". can think of css xml. xslt supported major browsers, there shouldn't problems. you can transform xml html/xhtml linking @ begining of xml file. best right after <?xml version="1.0" encoding="utf-8"?> you link link code <?xml-stylesheet type="text/xsl" href="file.xsl"?> you can learn xslt @ link. doesn't take long through. http://www.w3schools.com/xsl ...

jquery - javascript PRINT functionality -

Image
i doing image zoom , pan modal. all working fine, use floor plans. add print button ( same style ) viewer. see example: http://test.dpetroff.ru/jquery.iviewer/test/ need appear next [ 200% ] button. any suggestions ? the js here: http://test.dpetroff.ru/jquery.iviewer/jquery.iviewer.js my html code: var $ = jquery; $(document).ready(function(){ $("#viewer").iviewer( { src: "images/floorplan.gif", update_on_resize: false, zoom: 200, initcallback: function () { var object = this; $("#in").click(function(){ object.zoom_by(1);}); $("#out").click(function(){ object.zoom_by(-1);}); $("#fit").click(function(){ object.fit();}); ...