Search Results

Search found 712 results on 29 pages for 'jordan s jones'.

Page 12/29 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • how to wordwrap in flex tree node

    - by Sam Jones
    I have a Tree object in my Flex code. It's width is 100%, and it is contained by a Panel with width=200. I am using a custom itemrenderer that extends TreeItemRenderer. I need the text in each node to word wrap if it's too big (as happens often). I have tried label.wordWrap = true; in my item renderer without any luck. Any other suggestions?

    Read the article

  • Creating Array of settings names and values using ADO.NET Entities

    - by jordan.baucke
    I'm using an ADO.NET Entities (.edmx) data-model along with MVC2 to build an application. I have a DB table where I want to store settings for method that run elsewhere. MVC2 allows me to create a view, editor, etc. to update this table which is great, but now when I want to do simple assignments based on column titles I'm a bit confused. For example, I would like to easily build an array that I could offset into the record's value based on it's "Title" Column: var entities = new ManagerEntities(); Setting[] settings = entities.settings.ToArray(); This returns something like: Settings[0].[SettingTitle][SettingValue] However, I would like to more easily index into the value than having to loop through all the returned settings, when they're already index. string URL_ID_NEED = [NeededUrl][http://www.url.com] Am I missing something relatively simple? Thanks! ========================= *Update* ========================= Ok, I think I've got a solution, but I'm wondering why this would be so complicated, and if I'm just not thinking of the right context for ADO.NET objects, here's what I did: public string GetSetting(string SettingName) { var entities = new LabelManagerEntities(); IEnumerable<KeyValuePair<string, object>> entityKeyValues = new KeyValuePair<string, object>[] { new KeyValuePair<string, object>("SettingTitle", SettingName) }; EntityKey key = new EntityKey("LabelManagerEntities.Settings", entityKeyValues); // Get the object from the context or the persisted store by its key. Setting settingvalue = (Setting)entities.GetObjectByKey(key); return settingvalue.SettingValue.ToString(); } This method handles the job of querying the Entities by "Key" to get back the correct value as a returned string (which I can than strip out the " ", or or cast to an integer, etc. etc.,) Am I just duplicating functionality that already exists in ADO.NET's design patterns (I'm pretty new to it) -- or is this a reasonable solution?

    Read the article

  • C# Interop with dll

    - by Jim Jones
    Using VS2008 C# am attempting to interop a C++ dll. Have a C++ class constructor: make_summarizer(const char* rdir, const char* lic, const char* key); Need to retain a reference to the object that is created so I can use it in a follow-on function. When I did this in JNI the c code was: declare a static pointer to the object: static summarizer* summrzr; Then in one of the functions I called this constructor as follows: summrzr = make_summarizer(crdir, clic, ckey); Where the parameters all where the requisite const char* type; So in C# using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; using System.Configuration; namespace SummarizerApp { class SummApp { private IntPtr summarzr; public SummApp() { string resource_dir = ConfigurationManager.AppSettings["resource_dir"]; string license = ConfigurationManager.AppSettings["license"]; string key = ConfigurationManager.AppSettings["key"]; createSummarizer(resource_dir, license, key); } [System.Runtime.InteropServices.DllImportAttribute("lib\\summarizer37.dll", EntryPoint = "#1")] public static extern IntPtr make_summarizer( [InAttribute()][MarshalAsAttribute(UnmanagedType.LPTStr)] string rdir, [InAttribute()][MarshalAsAttribute(UnmanagedType.LPTStr)] string lic, [InAttribute()][MarshalAsAttribute(UnmanagedType.LPTStr)] string key); public void createSummarizer(string resource_dir, string license, string key) { try { this.summarzr = make_summarizer(resource_dir, license, key); } catch (AccessViolationException e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } } Have also tried using IntPtr created using Marshal.StringToHGlobalAnsi(string). Regardless I get a AccessViolationException on the line where I call the native constructor; So what am I doing wrong? Jim

    Read the article

  • Client Disconnected

    - by Bob Jones
    I am often getting a Client Disconnected message. I don't use load balancing - only a single IIS server. I need to know what is causing this and how to fix it. Here is the exception info: Type: System.Web.HttpException Message: The client disconnected. Exception Data: Source: System.Web TargetSite: Void ThrowError(System.Exception, System.String, System.String, Boolean) StackTrace: at System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) at System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) at System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) at System.Web.UI.HiddenFieldPageStatePersister.Load() at System.Web.UI.Page.LoadPageStateFromPersistenceMedium() at System.Web.UI.Page.LoadAllState() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    Read the article

  • iphone app scroll view is horizontal but i want it vertical - how do i change this?

    - by Billy Jones
    Hi Folks, Got this code for a viewscroller from the apple developers site. @synthesize scrollView1, scrollView2; const CGFloat kScrollObjHeight = 467.0; const CGFloat kScrollObjWidth = 320.0; const NSUInteger kNumImages = 6; (void)layoutScrollImages { UIImageView *view = nil; NSArray *subviews = [scrollView1 subviews]; // reposition all image subviews in a horizontal serial fashion CGFloat curXLoc = 0; for (view in subviews) { if ([view isKindOfClass:[UIImageView class]] && view.tag 0) { CGRect frame = view.frame; frame.origin = CGPointMake(curXLoc, 0); view.frame = frame; curXLoc += (kScrollObjWidth); } } // set the content size so it can be scrollable [scrollView1 setContentSize:CGSizeMake((kNumImages * kScrollObjWidth), [scrollView1 bounds].size.height)]; } it works brilliantly the images are rotated by pulling them left or right. but I want to pull the images up and down to change them. Can anyone help me out with this? this part in the code looks as if it controls the direction but i'm not sure how to change it. // reposition all image subviews in a horizontal serial fashion CGFloat curXLoc = 0; for (view in subviews) { if ([view isKindOfClass:[UIImageView class]] && view.tag 0) { CGRect frame = view.frame; frame.origin = CGPointMake(curXLoc, 0); view.frame = frame; curXLoc += (kScrollObjWidth); } } Any help most appreciated, thanks! Billy

    Read the article

  • Exception when creating new Iphone/Ipad window in MonoDevelop

    - by Jones D R
    I get this exception every time i try to create a new Iphone/Ipad solution? I have been following the guides and have both XCode, interface builder and IOS SDK installed. Any clues are welcome:) System.ApplicationException: Can't create display binding for mime type: application/vnd.apple-interface-builder at MonoDevelop.Ide.Gui.Workbench.NewDocument (System.String defaultName, System.String mimeType, System.IO.Stream content) [0x00000] in :0 at MonoDevelop.Ide.Templates.FileTemplate.CreateFile (MonoDevelop.Ide.Templates.FileDescriptionTemplate newfile, MonoDevelop.Projects.SolutionItem policyParent, MonoDevelop.Projects.Project project, System.String directory, System.String language, System.String name) [0x00000] in :0 at MonoDevelop.Ide.Templates.FileTemplate.Create (MonoDevelop.Projects.SolutionItem policyParent, MonoDevelop.Projects.Project project, System.String directory, System.String language, System.String name) [0x00000] in :0 at MonoDevelop.Ide.Projects.NewFileDialog.OpenEvent (System.Object sender, System.EventArgs e) [0x00000] in :0

    Read the article

  • Creating text file from as2

    - by Jordan
    I'm trying to find a way to write to a text file from as2. I don't want to use any php or asp because my app needs to run without an internet connection. As3 has FileReference.save() and judging by the amount of searching I've done, as2 doesn't have that simple of a solution. Does anyone have a way even if its hacky to write to a txt file from as2?

    Read the article

  • OpenGL FrameBuffer Objects weird behavior

    - by Ben Jones
    My algorithm is this: Render the scene to a FBO with shadow mapping from multiple locations Render the scene to the screen with shadow mapping ...black magic that I still have to imlement... Combine the samples from step 1 with the image from step 2 I'm trying to debug steps 1 and 2 and am coming across STRANGE behavior. My algorithm for each shadow mapped pass is: render the scene to a FBO connected to a depth array texture from the POV of each light render the scene from the viewpoint and use vertex/frag shaders to compare the depths When I run my algorithm this way: render from point to FBO render from point to screen glutSwapBuffers() The normal vectors in the screen pass appear to be incorrect (inverted possibly). I'm pretty sure that's the issue because my diffuse lighting calculation is incorrect, but the material colors are correct, and the shadows appear in the correct places. So, it seems like the only thing that could be the culprit is the normals. However if I do render from point to FBO render from point to Screen glutSwapBuffers() //wrong here render from point to Screen glutSwapBuffers() the second pass is correct. I assume there's a problem with my framebuffer calls. Can anyone see what the problem is from the log below? Its from a bugle trace grepped for 'buffer' with a few edits to make it a little more clear. Thanks! [INFO] trace.call: glGenFramebuffersEXT(1, 0xdfeb90 - { 1 }) [INFO] trace.call: glGenFramebuffersEXT(1, 0xdfebac - { 2 }) [INFO] trace.call: glBindFramebufferEXT(GL_FRAMEBUFFER, 1) [INFO] trace.call: glDrawBuffer(GL_NONE) [INFO] trace.call: glReadBuffer(GL_NONE) [INFO] trace.call: glBindFramebufferEXT(GL_FRAMEBUFFER, 0) //start render to FBO [INFO] trace.call: glBindFramebufferEXT(GL_FRAMEBUFFER, 2) [INFO] trace.call: glReadBuffer(GL_NONE) [INFO] trace.call: glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 2, 0) [INFO] trace.call: glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 3, 0) [INFO] trace.call: glDrawBuffer(GL_COLOR_ATTACHMENT0) //bind to the FBO attached to a depth tex array for shadows [INFO] trace.call: glBindFramebufferEXT(GL_FRAMEBUFFER, 1) [INFO] trace.call: glFramebufferTextureLayerARB(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, 1, 0, 0) [INFO] trace.call: glClear(GL_DEPTH_BUFFER_BIT) //draw geometry //bind to the FBO I want the shadow mapped image rendered to [INFO] trace.call: glBindFramebufferEXT(GL_FRAMEBUFFER, 2) [INFO] trace.call: glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) //draw geometry //draw to screen pass //again shadow mapping FBO [INFO] trace.call: glBindFramebufferEXT(GL_FRAMEBUFFER, 1) [INFO] trace.call: glFramebufferTextureLayerARB(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, 1, 0, 0) [INFO] trace.call: glClear(GL_DEPTH_BUFFER_BIT) //draw geometry //bind to the screen [INFO] trace.call: glBindFramebufferEXT(GL_FRAMEBUFFER, 0) [INFO] trace.call: glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) //finished, swap buffers [INFO] trace.call: glXSwapBuffers(0xd5fc10, 0x05800002) //INCORRECT OUTPUT //second try at render to screen: [INFO] trace.call: glBindFramebufferEXT(GL_FRAMEBUFFER, 1) [INFO] trace.call: glFramebufferTextureLayerARB(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, 1, 0, 0) [INFO] trace.call: glClear(GL_DEPTH_BUFFER_BIT) //draw geometry [INFO] trace.call: glBindFramebufferEXT(GL_FRAMEBUFFER, 0) [INFO] trace.call: glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) draw geometry [INFO] trace.call: glXSwapBuffers(0xd5fc10, 0x05800002) //correct output

    Read the article

  • Compute bounding quad of a sphere with vertex shader

    - by Ben Jones
    I'm trying to implement an algorithm from a graphics paper and part of the algorithm is rendering spheres of known radius to a buffer. They say that they render the spheres by computing the location and size in a vertex shader and then doing appropriate shading in a fragment shader. Any guesses as to how they actually did this? The position and radius are known in world coordinates and the projection is perspective. Does that mean that the sphere will be projected as a circle? Thanks!

    Read the article

  • How do I use a .NET class in VBA? Syntax help!

    - by Jordan S
    ok I have couple of .NET classes that I want to use in VBA. So I must register them through COM and all that. I think I have the COM registration figured out (finally) but now I need help with the syntax of how to create the objects. Here is some pseudo code showing what I am trying to do. EDIT: Changed Attached Objects to return an ArrayList instead of a List The .NET classes look like this... public class ResourceManagment { public ResourceManagment() { // Default Constructor } public static List<RandomObject> AttachedObjects() { ArrayList list = new ArrayList(); return list; } } public class RandomObject { // public RandomObject(int someParam) { } } OK, so this is what I would like to do in VBA (demonstrated in C#) but I don't know how... public class VBAClass { public void main() { ArrayList myList = ResourceManagment.AttachedObjects(); foreach(RandomObject x in myList) { // Do something with RandomObject x like list them in a Combobox } } } One thing to note is that RandomObject does not have a public default constructor. So I can not create an instance of it like Dim x As New RandomObject. MSDN says that you can not instantiate an object that doesn't have a default constructor through COM but you can still use the object type if it is returned by another method... Types must have a public default constructor to be instantiated through COM. Managed, public types are visible to COM. However, without a public default constructor (a constructor without arguments), COM clients cannot create an instance of the type. COM clients can still use the type if the type is instantiated in another way and the instance is returned to the COM client. You may include overloaded constructors that accept varying arguments for these types. However, constructors that accept arguments may only be called from managed (.NET) code. Added: Here is my attempt in VB: Dim count As Integer count = 0 Dim myObj As New ResourceManagment For Each RandomObject In myObj.AttachedObjects count = count + 1 Next RandomObject

    Read the article

  • nginx + passenger not using rackup file

    - by Callum Jones
    I have an issue where Passenger is not detecting the config.ru file for the following nginx server server { listen 80; passenger_enabled on; server_name callumj.com cjlondon.com; access_log logs/callumj.access.log; root /webapps/callumj_com/public; } Nginx just seems to ignore it and treat it as a normal web page (as I get forbidden areas when it tries to look for index.html in public). I have verified that the rackup command and execute config.ru and it boots up sucessfully. I have another server directive much like this which is powered by Rails and it seems to be working perfectly. Am I missing something? Thanks in advance!

    Read the article

  • How do I use custom member properties for people on my .NET website

    - by Jordan S
    I am trying to make an asp.net website using Visual web dev and C# that accesses data in an SQL database. For my site, I need to be able to save and access additional user properties such as age and gender. I have been playing around with the built in .NET Login tools but I don't understand how to keep track of the additional properties (age, gender...) I could store all the users information in my own database but how do I correlate the users data in my DB to the usernames in the member database that is automatically created?

    Read the article

  • Android insertImage and the Gallery Application

    - by Steve Jones
    I am adding a bmp file to the media store using the line below ContentResolver cr = getContentResolver(); Uri uri = Uri.parse(MediaStore.Images.Media.insertImage(cr, bmp, "name", "now")); I then go to the gallery application and it shows the image, but shows it under "Camera Pictures". Is there a way to change this to its own group, perhaps to its own group? Do I need a custom content provider for this? Thanks.

    Read the article

  • Can I copy the CollapsiblePanelExtender in jQuery as one method?

    - by Matthew Jones
    I am beginning the process of moving away from the AjaxControlToolkit and toward jQuery. What I want to do is have one function that duplicates the functionality of the CollapsiblePanelExtender. For a particular set of hyperlink and div, the code looks like this: $('#nameHyperLink').click(function() { var div = $('#nameDiv'); var link = $('#nameHyperLink'); if (div.css('display') == 'none') { link.text('Hide Data'); div.show(400); } else { link.text('Show Data'); div.hide(400); } }); What I really want to do is only have to write this function once, then use it for many (approx 40) instances throughout my website. Ideally what I want is this: function showHidePanel(divID,linkID,showText,hideText){ var div = $(divID); var link = $(linkID); if (div.css('display') == 'none') { link.text('Hide Data'); div.show(400); } else { link.text('Show Data'); div.hide(400); } }); I would then call this function from every HyperLink involved using OnClientClick. Is there a way to do this?

    Read the article

  • C# Class Library wont register for COM

    - by Jordan S
    Hello All, I am trying to gain access to a .NET class library in Microsoft Excel. To do this I know that the .NET class library must be registered with COM. So I tried going to my Assembly Info and Setting COM Visible to true. Then on the build tab I set Register for COM Interop for true also. I checked the AssemblyInfo.cs file and it does contain [assembly: ComVisible(true)]. But for some reason when I try to add a reference to the Class Lib in Excel the namespace does not show up in the list. I made a quick test Class library with nothing in it and did the same thing (set COM Vis = true , and Register For COM Interop = true) and that one does show up on the list of available references. I can't figure out what the difference is between the two classes. I am not sure if my class is actually being registered for COM interop or not. Does anyone know what I can do to fix this???

    Read the article

  • Visual Studio 2010 color theme

    - by James Jones
    Has anyone found/made any decent color themes for Visual Studio 2010? My VS 2005/2008 themes seem to be getting mangled in the upgrade process. I'm accustomed to using the ever famous Oren Ellenbogen's Dark Scheme featured on Scott Hanselman's blog, but the upgrade process has made it downright butt-ugly. Does anyone have any gems they'd like to share?

    Read the article

  • Updating AjaxToolKit Breaks WCF Service for AutoCompleteExtender

    - by Rob Jones
    I had a perfectly working WCF service that I used for a custom AutoCompleteExtender but when I updated the AjaxControlToolKit.dll the service no longer works. I changed nothing else but removing the old DLL and adding the new one. Is there something else I need to update that I am missing? I can access the service so I know it's working properly but the methods are just not getting called by the AutoCompleteExtender.

    Read the article

  • CSS drop-down menus pushing page content down

    - by Mason Jones
    This is probably (hopefully) a pretty simple question, but I can't seem to get it to work so I'll turn to the experts here. I'm using a pretty straightforward CSS drop-down menu, with just a little JQuery involved. The issue is that when I hover over the drop-down and it opens, it's pushing everything on the page down below it rather then opening over it. I've tried messing with the z-index but that doesn't seem to be the issue. Any tips would be fantastic, thanks in advance. Here's the HTML; sorry it's not super-pretty, I had to rip out a bunch of stuff to make it simple and generic. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML style="zoom: 100%; "> <HEAD> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js" type="text/javascript"></script> </HEAD> <BODY class="bodyclass" style="background:#BCE2F1; height: 100%;"> <DIV id="maincontainer" style="min-height: 100%;"> <STYLE type="text/css"> #cssdropdown, #cssdropdown ul { font-size: 9pt; background-color: black; list-style: none; } #cssdropdown, #cssdropdown * { padding: 0; margin: 0; } #cssdropdown li.headlink { width: 140px; float: left; margin-left: -1px; border: 1px black solid; background-color: white; text-align: center; } #cssdropdown li.headlink a { display: block; color: #339804; padding: 3px; text-decoration: none; } #cssdropdown li.headlink a:hover { background-color: #F8E0AC; font-weight: bold; } #cssdropdown li.headlink ul { display: none; border-top: 1px black solid; text-align: left; } #cssdropdown li.headlink:hover ul { display: block; text-decoration: none; } #cssdropdown li.headlink ul li a { padding: 5px; height: 15px; } #cssdropdown li.headlink ul li a:hover { background-color: #CCE9F5; text-decoration: none; font-weight: normal; } /* #cssdropdown a { color: #CCE9F5; } */ #cssdropdown ul li a:hover { text-decoration: none; } #cssdropdown li.headlink { background-color: white; } #cssdropdown li.headlink ul { background-color: white; background-position: bottom; padding-bottom: 2px; } </STYLE> <SCRIPT language="JavaScript"> $(document).ready(function(){ $('#cssdropdown li.headlink').hover( function() { $('ul', this).css('display', 'block'); }, function() { $('ul', this).css('display', 'none'); }); }); </SCRIPT> <DIV class="navigation_box" style="border: none;"> <DIV class="innercontent"> <DIV style="background: white; float: left; padding: 5px; border: solid 1px black;"> LOGO </DIV> <DIV class="navmenu" style="float: right; bottom: 0; font-size: 9pt; text-align: right;"> <SPAN>Logged in as [email protected]</SPAN><BR> <UL id="cssdropdown"> <LI class="headlink"> <A href="http://localhost:3000/one">One</A> <UL style="display: none; "> <LI><A href="http://localhost:3000/one">Option One</A></LI> <LI><A href="http://localhost:3000/one">Option Two</A></LI> <LI><A href="http://localhost:3000/one">Option Three</A></LI> <LI><A href="http://localhost:3000/one">Option Four</A></LI> </UL> </LI> <LI class="headlink"> <A href="http://localhost:3000/two">Two</A> <UL style="display: none; "> <LI><A href="http://localhost:3000/two">Option Two-One</A></LI> <LI><A href="http://localhost:3000/two">Option Two-Two</A></LI> <LI><A href="http://localhost:3000/two">Option Two-Three</A></LI> </UL> </LI> <LI class="headlink" style="width: 80px;"> <A href="http://localhost:3000/three">Three</A> </LI> <LI class="headlink" style="width: 300px; padding-top: 2px; height: 19px;"> <FORM action="http://localhost:3000/search" method="post"> <P> Search: <INPUT id="searchwords" name="searchwords" size="20" type="text" value=""> <INPUT name="commit" type="submit" value="Find"> </P> </FORM> </LI> <LI class="headlink" style="width: 60px;"> <A href="http://localhost:3000/four">Four</A> </LI> <LI class="headlink" style="width: 60px;"> <A href="http://localhost:3000/logout">Logout</A> </LI> </UL> </DIV> </DIV> </DIV> <DIV id="contentwrapper" style="clear:both"> <DIV class="innercontent" style="margin: 0px 20px 20px 20px;"> <H1>Some test content here to fill things out a little bit.</H1> </DIV> </DIV> </DIV> <DIV id="footer" style="clear: both; float: bottom;"> <DIV class="innercontent" style="font-size: 10px;"> Copyright 2008-2010 </DIV> </DIV> </BODY>

    Read the article

  • How to sketch out an event-driven system?

    - by Jordan
    I'm trying to design a system in Node.js (an attempt at solving one of my earlier problems, using Node's concurrency) but I'm running into trouble figuring out how to draw a plan of how the thing should operate. I'm getting very tripped up thinking in terms of callbacks instead of returned values. The flow isn't linear, and it's really boggling my ability to draft it. How does one draw out an operational flow for an event-driven system? I need something I can look at and say "Ok, yes, that's how it will work. I'll start it over here, and it will give me back these results over here." Pictures would be very helpful for this one. Thanks. Edit: I'm looking for something more granular than UML, specifically, something that will help me transition from a blocking and object-oriented programming structure, where I'm comfortable, to a non-blocking and event driven structure, where I'm unfamiliar.

    Read the article

  • Rails based S3 file manager

    - by Jim Jones
    Hi, I'm looking for an open source project that provides a file manager type interface to S3. The ability to view files and "folders", add/edit/delete files/folders, etc. I've seen http://s3fm.com, but I'd like to host something like that myself. Does anything like this exist? Thanks.

    Read the article

  • Help finding longest non-repeating path through connected nodes - Python

    - by Jordan Magnuson
    I've been working on this for a couple of days now without success. Basically, I have a bunch of nodes arranged in a 2D matrix. Every node has four neighbors, except for the nodes on the sides and corners of the matrix, which have 3 and 2 neighbors, respectively. Imagine a bunch of square cards laid out side by side in a rectangular area--the project is actually simulating a sort of card/board game. Each node may or may not be connected to the nodes around it. Each node has a function (get_connections()), that returns the nodes immediately around it that it is connected to (so anywhere from 0 to 4 nodes are returned). Each node also has an "index" property, that contains it's position on the board matrix (eg '1, 4' - row 1, col 4). What I am trying to do is find the longest non-repeating path of connected nodes given a particular "start" node. I've uploaded a couple of images that should give a good idea of what I'm trying to do: In both images, the highlighted red cards are supposedly the longest path of connected cards containing the most upper-left card. However, you can see in both images that a couple of cards that should be in the path have been left out (Romania and Maldova in the first image, Greece and Turkey in the second) Here's the recursive function that I am using currently to find the longest path, given a starting node/card: def get_longest_trip(self, board, processed_connections = list(), processed_countries = list()): #Append this country to the processed countries list, #so we don't re-double over it processed_countries.append(self) possible_trips = dict() if self.get_connections(board): for i, card in enumerate(self.get_connections(board)): if card not in processed_countries: processed_connections.append((self, card)) possible_trips[i] = card.get_longest_trip(board, processed_connections, processed_countries) if possible_trips: longest_trip = [] for i, trip in possible_trips.iteritems(): trip_length = len(trip) if trip_length > len(longest_trip): longest_trip = trip longest_trip.append(self) return longest_trip else: print card_list = [] card_list.append(self) return card_list else: #If no connections from start_card, just return the start card #as the longest trip card_list = [] card_list.append(board.start_card) return card_list The problem here has to do with the processed_countries list: if you look at my first screenshot, you can see that what has happened is that when Ukraine came around, it looked at its two possible choices for longest path (Maldova-Romania, or Turkey, Bulgaria), saw that they were both equal, and chose one indiscriminantly. Now when Hungary comes around, it can't attempt to make a path through Romania (where the longest path would actually be), because Romania has been added to the processed_countries list by Ukraine. Any help on this is EXTREMELY appreciated. If you can find me a solution to this, recursive or not, I'd be happy to donate some $$ to you. I've uploaded my full source code (Python 2.6, Pygame 1.9 required) to: http://www.necessarygames.com/junk/planes_trains.zip The relevant code is in src/main.py, which is all set to run.

    Read the article

  • GZIP Java vs .NET

    - by Jim Jones
    Using the following Java code to compress/decompress bytes[] to/from GZIP. First text bytes to gzip bytes: public static byte[] fromByteToGByte(byte[] bytes) { ByteArrayOutputStream baos = null; try { ByteArrayInputStream bais = new ByteArrayInputStream(bytes); baos = new ByteArrayOutputStream(); GZIPOutputStream gzos = new GZIPOutputStream(baos); byte[] buffer = new byte[1024]; int len; while((len = bais.read(buffer)) >= 0) { gzos.write(buffer, 0, len); } gzos.close(); baos.close(); } catch (IOException e) { e.printStackTrace(); } return(baos.toByteArray()); } Then the method that goes the other way compressed bytes to uncompressed bytes: public static byte[] fromGByteToByte(byte[] gbytes) { ByteArrayOutputStream baos = null; ByteArrayInputStream bais = new ByteArrayInputStream(gbytes); try { baos = new ByteArrayOutputStream(); GZIPInputStream gzis = new GZIPInputStream(bais); byte[] bytes = new byte[1024]; int len; while((len = gzis.read(bytes)) > 0) { baos.write(bytes, 0, len); } } catch (IOException e) { e.printStackTrace(); } return(baos.toByteArray()); } Think there is any effect since I'm not writing out to a gzip file? Also I noticed that in the standard C# function that BitConverter reads the first four bytes and then the MemoryStream Write function is called with a start point of 4 and a length of input buffer length - 4. So is that effect the validity of the header? Jim

    Read the article

  • Fragment Shader Eye-Space unscaled depth coordinate

    - by Ben Jones
    I'm trying to use the unscaled (true distance from the front clipping plane) distance to objects in my scene in a GLSL fragment shader. The gl_FragCoord.z value is smaller than I expect. In my vertex shader, I just use ftransform() to set gl_Position. I'm seeing values between 2 and 3 when I expect them to be between 15 and 20. How can I get the real eye-space depth? Thanks!

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >