Search Results

Search found 3747 results on 150 pages for '500'.

Page 39/150 | < Previous Page | 35 36 37 38 39 40 41 42 43 44 45 46  | Next Page >

  • Basic example of placing two component on one JPanel container?

    - by Bernard
    Here is my code to add to component (JTextArea and JList) to a panel and put it on the frame. Can I divide half/half by BorderLayout? If yes why mine looks messy one stays up one down? What is the other alternative? Regards, Bernard import java.awt.*; import javax.swing.BorderFactory; import javax.swing.border.Border; import javax.swing.JList; import javax.swing.JScrollPane; import javax.swing.JPanel; import javax.swing.JFrame; import javax.swing.JTextArea; public class SimpleBorder { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(500,500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border etched = (Border) BorderFactory.createEtchedBorder(); String[] items = {"A", "B", "C", "D"}; JList list = new JList(items); JTextArea text = new JTextArea(10, 40); JScrollPane scrol = new JScrollPane(text); JScrollPane scrol2 = new JScrollPane(list); JPanel panel= new JPanel(); panel.add(scrol2,BorderLayout.WEST); panel.add(scrol, BorderLayout.EAST); panel.setBorder(etched); frame.add(panel); frame.setVisible(true); } }

    Read the article

  • ExternalInterface

    - by Jesse
    Hey, so I'm having a bunch of trouble getting ExternalInterface to work, which is odd, because I use it somewhat often. I'm hoping it's something I just missed because I've been looking at it too long. The flash_ready function is correctly returning the objectID, and as far as I can tell, everything else is in order. Unfortunately, when I run it, I get an error (varying by browser) telling me that basically document.getElementById(<movename>).test() is not a valid method. Here's the code: javascript: function flash_ready(i){ document.getElementById(i).test('success!'); } Embed Html (Generated): <script type="text/javascript"> swfobject.embedSWF("/chainmaille/includes/media/flash/upload_image.swf", "/chainmaille/includes/media/flash/upload_image", "500", "50", "9.0.0","expressInstall.swf", {}, {allowScriptAccess:'always', wmode:'transparent'},{id:'uploader_flash',name:'uploader_flash'}); </script> <object type="application/x-shockwave-flash" id="uploader_flash" name="uploader_flash" data="/chainmaille/includes/media/flash/upload_image.swf" width="500" height="50"><param name="allowScriptAccess" value="always"><param name="wmode" value="transparent"></object> AS3 : package com.jesseditson.uploader { import flash.display.MovieClip; import flash.external.ExternalInterface; import flash.system.Security; public class UI extends MovieClip { // Initialization: public function UI() { Security.allowDomain('*'); ExternalInterface.addCallback("test", test); var jscommand:String = "flash_ready('"+ExternalInterface.objectID+"');"; var url:URLRequest = new URLRequest("javascript:" + jscommand + " void(0);"); navigateToURL(url, "_self"); } public function test(t){ trace(t); } } } Swfobject is being included via google code, and the flash embeds just fine, so that's not the problem. I've got a very similar setup working on another server, but can't seem to get it working on this one. It's a Hostgator shared server. Could it be the server's fault? Anybody see any obvious syntax problems? Thanks in advance!

    Read the article

  • Stock management of assemblies and its sub parts (relations)

    - by The Disintegrator
    I have to track the stock of individual parts and kits (assemblies) and can't find a satisfactory way of doing this. Sample bogus and hyper simplified database: Table prod: prodID 1 prodName Flux capacitor prodCost 900 prodPrice 1350 (900*1.5) prodStock 3 - prodID 2 prodName Mr Fusion prodCost 300 prodPrice 600 (300*2) prodStock 2 - prodID 3 prodName Time travel kit prodCost 1650 (1350+300) prodPrice 2145 (1650*1.3) prodStock 2 Table rels relID 1 relSrc 1 (Flux capacitor) relType 4 (is a subpart of) relDst 3 (Time travel kit) - relID 2 relSrc 2 (Mr Fusion) relType 4 (is a subpart of) relDst 3 (Time travel kit) prodPrice: it's calculated based on the cost but not in a linear way. In this example for costs of 500 or less, the markup is a 200%. For costs of 500-1000 the markup is 150%. For costs of 1000+ the markup is 130% That's why the time travel kit is much cheaper than the individual parts prodStock: here is my problem. I can sell kits or the individual parts, So the stock of the kits is virtual. The problem when I buy: Some providers sell me the Time Travel kit as a whole (with one barcode) and some sells me the individual parts (with a different barcode) So when I load the stock I don't know how to impute it. The problem when I sell: If I only sell kits, calculate the stock would be easy: "I have 3 Flux capacitors and 2 Mr Fusions, so I have 2 Time travel kits and a Flux Capacitor" But I can sell Kits or individual parts. So, I have to track the stock of the individual parts and the possible kits at the same time (and I have to compensate for the sell price) Probably this is really simple, but I can't see a simple solution. Resuming: I have to find a way of tracking the stock and the database/program is the one who has to do it (I cant ask the clerk to correct the stock) I'm using php+MySql. But this is more a logical problem than a programing one

    Read the article

  • jQuery change CSS background position and mouseover/mouseout

    - by steelfrog
    I have a menu composed of a single image (e.g., sprites). In order to display the hover image, I simply move the background image down. I'd like this effect to be controlled by jQuery and animated. This is a sample menu item. <ul> <li id="home"><a href="#"></a></li> </ul> This is what I'm toying with. I'm very new to jQuery and am having problems getting the proper selector going. $(document).ready(function(){ $('#home a'); // Set the 'normal' state background position .css( {backgroundPosition: "0 0"} ) // On mouse over, move the background .mouseover(function(){ $(this).stop().animate({backgroundPosition:"(0 -54px)"}, {duration:500}) }) // On mouse out, move the background back .mouseout(function(){ $(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:500}) }) }); Could you point out what I'm doing wrong? I know the selector is probably incorrect but I'm having a hard time figuring out how to manipulate the anchor.

    Read the article

  • Counting the number of words in a text area

    - by user1320483
    Hello everyone my first question on stack overflow import javax.swing.*; import java.util.*; import java.awt.event.*; public class TI extends JFrame implements ActionListener { static int count=0; String ct; JTextField word; JTextArea tohide; public static void main(String arg[]) { TI ti=new TI(); } public TI() { JPanel j=new JPanel(); JLabel def=new JLabel("Enter the text to be encrypted"); word=new JTextField("",20); tohide=new JTextArea("",5,20); JButton jb=new JButton("COUNT"); tohide.setBorder(BorderFactory.createLoweredBevelBorder()); j.add(def); j.add(tohide); j.add(word); j.add(jb); add(j); setSize(500,500); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLocationRelativeTo(null); jb.addActionListener(this); } public void actionPerformed(ActionEvent ae) { String txt=tohide.getText(); StringTokenizer stk=new StringTokenizer(txt," "); while(stk.hasMoreTokens()) { String token=stk.nextToken(); count++; } ct=Integer.toString(count);; word.setText(ct); } } I want to count the number of words that are being typed in the textarea.There is a logical error.As I keep clicking the count button the word count increases.

    Read the article

  • Binary search in a sorted (memory-mapped ?) file in Java

    - by sds
    I am struggling to port a Perl program to Java, and learning Java as I go. A central component of the original program is a Perl module that does string prefix lookups in a +500 GB sorted text file using binary search (essentially, "seek" to a byte offset in the middle of the file, backtrack to nearest newline, compare line prefix with the search string, "seek" to half/double that byte offset, repeat until found...) I have experimented with several database solutions but found that nothing beats this in sheer lookup speed with data sets of this size. Do you know of any existing Java library that implements such functionality? Failing that, could you point me to some idiomatic example code that does random access reads in text files? Alternatively, I am not familiar with the new (?) Java I/O libraries but would it be an option to memory-map the 500 GB text file (I'm on a 64-bit machine with memory to spare) and do binary search on the memory-mapped byte array? I would be very interested to hear any experiences you have to share about this and similar problems.

    Read the article

  • Installing sfJqueryTreeDoctrineManagerPlugin to Symfony 1.4

    - by Christine Q.
    I have faced serious difficulties while installing sfJqueryTreeDoctrineManagerPlugin to Symfony 1.4 w/ Doctrine ORM. The installation directly from the server did not work out like with previous plugins that I have installed: C:\pathsymfony plugin:install sfJqueryTreeDoctrineManagerPlugin plugin installing plugin "sfJqueryTreeDoctrineManagerPlugin" No release available for plugin "sfJqueryTreeDoctrineManagerPlugin" This is why I needed to install the plugin by downloading the tgz-archive and install it manually like this: C:\pathsymfony plugin:install "C:\path\to\downloads\sfJqueryTreeDoctrineManagerPlugin-1.2.4.tgz" plugin installing plugin "C:\path\to\downloads\sfJqueryTreeDoctrineManagerPlugin-1.2.4.tgz" sfSymfonyPluginManager Installing web data for plugin I guess everything should be fine this far? After that I edited \apps\admin\config\settings.yml like instructed in the plugins readme file. all: .settings: enabled_modules: [default, sfJqueryTreeDoctrineManager] I also checked that the plugin was enabled in \config\ProjectConfiguration.class.php like this: $this->enablePlugins(array( // other plugins, 'sfJqueryTreeDoctrineManagerPlugin' )); I published assets and cleared cache: C:\pathsymfony plugin:publish-assets >> plugin Configuring plugin - sfJqueryTreeDoctrineManagerPlugin C:\pathsymfony cc Finally I added the required helper to the newly created apps\admin\modules\category\templates\indexSuccess.php <?php use_helper("sfJqueryTreeDoctrine"); echo get_nested_set_manager("Category", "name"); When loading the page I unfortunately get the following error: 500 | Internal Server Error | InvalidArgumentException Unable to load "sfJqueryTreeDoctrineHelper.php" helper in: SF_ROOT_DIR\apps\admin\modules/businessunitgroup/lib/helper, SF_ROOT_DIR\apps\admin\lib/helper, SF_ROOT_DIR\lib/helper, SF_SYMFONY_LIB_DIR/helper. The file sfJqueryTreeDoctrineHelper.php exists indeed but not in any previously mentioned folder. The file can only be found in the folder \plugins\sfJqueryTreeDoctrineManagerPlugin\lib\helper. I guess that Symfony doesn't look to that folder while finding helpers? I have tried to move the helper file to one of the previously mentioned folders. As expected, that changes the error. Now I get: 500 | Internal Server Error | sfConfigurationException The component does not exist: "sfJqueryTreeDoctrineManager", "manager". Unfortunately I can't figure out how should I be able to retrieve the "missing" component from the correct folder. I would be very grateful for any advice to help me forward. By the way, I am aware that there are other nested-set / tree plugins available for Symfony (like sfDoctrineTreePlugin and caPropelTreePlugin) but unluckily those are either uncompatible or too limited for my needs.

    Read the article

  • eclipse adt 17 and the libs folder

    - by max4ever
    Ok so i update to eclipse adt to version 17 and I get this error 04-05 12:28:55.810: E/AndroidRuntime(5470): FATAL EXCEPTION: main 04-05 12:28:55.810: E/AndroidRuntime(5470): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.galeola.agentis/com.galeola.agentis.activity.GestionaleActivity}: java.lang.ClassNotFoundException: com.galeola.agentis.activity.GestionaleActivity in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.galeola.agentis-1.apk] 04-05 12:28:55.810: E/AndroidRuntime(5470): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1742) 04-05 12:28:55.810: E/AndroidRuntime(5470): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1834) 04-05 12:28:55.810: E/AndroidRuntime(5470): at android.app.ActivityThread.access$500(ActivityThread.java:122) 04-05 12:28:55.810: E/AndroidRuntime(5470): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1027) 04-05 12:28:55.810: E/AndroidRuntime(5470): at android.os.Handler.dispatchMessage(Handler.java:99) 04-05 12:28:55.810: E/AndroidRuntime(5470): at android.os.Looper.loop(Looper.java:132) 04-05 12:28:55.810: E/AndroidRuntime(5470): at android.app.ActivityThread.main(ActivityThread.java:4126) 04-05 12:28:55.810: E/AndroidRuntime(5470): at java.lang.reflect.Method.invokeNative(Native Method) 04-05 12:28:55.810: E/AndroidRuntime(5470): at java.lang.reflect.Method.invoke(Method.java:491) 04-05 12:28:55.810: E/AndroidRuntime(5470): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844) 04-05 12:28:55.810: E/AndroidRuntime(5470): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602) 04-05 12:28:55.810: E/AndroidRuntime(5470): at dalvik.system.NativeStart.main(Native Method) 04-05 12:28:55.810: E/AndroidRuntime(5470): Caused by: java.lang.ClassNotFoundException: com.galeola.agentis.activity.GestionaleActivity in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.galeola.agentis-1.apk] 04-05 12:28:55.810: E/AndroidRuntime(5470): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:251) 04-05 12:28:55.810: E/AndroidRuntime(5470): at java.lang.ClassLoader.loadClass(ClassLoader.java:540) 04-05 12:28:55.810: E/AndroidRuntime(5470): at java.lang.ClassLoader.loadClass(ClassLoader.java:500) 04-05 12:28:55.810: E/AndroidRuntime(5470): at android.app.Instrumentation.newActivity(Instrumentation.java:1022) 04-05 12:28:55.810: E/AndroidRuntime(5470): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1733) 04-05 12:28:55.810: E/AndroidRuntime(5470): ... 11 more however if i move my libraries to /libs i can start the applications, but with the libraries in /libs javadoc and javasources stops working, while if they are not in /libs javadoc and javasource works, so I don't understand why.

    Read the article

  • Syntax Error in MySql StoredProc

    - by karthik
    I am using the below stored proc in mysql to generate the insert statements. I am getting the following error : Script line: 4 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\’”\’,',’ifnull(‘,column_name,’,””)’,',\’”\’)')) INTO @S' at line 12 What would be the syntax problem in that ? DELIMITER $$ DROP PROCEDURE IF EXISTS `InsGen` $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `InsGen`(in_db varchar(20),in_table varchar(20),in_file varchar(100)) BEGIN declare Whrs varchar(500); declare Sels varchar(500); declare Inserts varchar(2000); declare tablename varchar(20); set tablename=in_table; select tablename; # Comma separated column names – used for Select select group_concat(concat(‘concat(\’”\’,',’ifnull(‘,column_name,’,””)’,',\’”\’)')) INTO @Sels from information_schema.columns where table_schema=’test’ and table_name=tablename; # Comma separated column names – used for Group By select group_concat(‘`’,column_name,’`') INTO @Whrs from information_schema.columns where table_schema=’test’ and table_name=tablename; #Main Select Statement for fetching comma separated table values set @Inserts=concat(“select concat(‘insert into “, in_db,”.”,tablename,” values(‘,concat_ws(‘,’,”,@Sels,”),’);’) from “, in_db,”.”,tablename,” group by “,@Whrs, ” INTO OUTFILE ‘”, in_file ,”‘”); PREPARE Inserts FROM @Inserts; EXECUTE Inserts; END $$ DELIMITER ;

    Read the article

  • Why does adding Crossover to my Genetic Algorithm gives me worse results?

    - by MahlerFive
    I have implemented a Genetic Algorithm to solve the Traveling Salesman Problem (TSP). When I use only mutation, I find better solutions than when I add in crossover. I know that normal crossover methods do not work for TSP, so I implemented both the Ordered Crossover and the PMX Crossover methods, and both suffer from bad results. Here are the other parameters I'm using: Mutation: Single Swap Mutation or Inverted Subsequence Mutation (as described by Tiendil here) with mutation rates tested between 1% and 25%. Selection: Roulette Wheel Selection Fitness function: 1 / distance of tour Population size: Tested 100, 200, 500, I also run the GA 5 times so that I have a variety of starting populations. Stop Condition: 2500 generations With the same dataset of 26 points, I usually get results of about 500-600 distance using purely mutation with high mutation rates. When adding crossover my results are usually in the 800 distance range. The other confusing thing is that I have also implemented a very simple Hill-Climbing algorithm to solve the problem and when I run that 1000 times (faster than running the GA 5 times) I get results around 410-450 distance, and I would expect to get better results using a GA. Any ideas as to why my GA performing worse when I add crossover? And why is it performing much worse than a simple Hill-Climb algorithm which should get stuck on local maxima as it has no way of exploring once it finds a local max?

    Read the article

  • error handler isn't called when file is uploaded via ajax using jQuery form plugin

    - by scompt.com
    Here's my test case. If the form is posted, a 500 error response is sent. If not, the form is sent. If the file input tag is commented out, the error handler is called. If the file input tag is present, the error handler isn't called. I think this might have something to do with the fact that jQuery needs to use an iframe to handle the upload and iframes don't seem to respond to the error handler. Edit: If I add iframe: true to the options passed to ajaxSubmit to force the use of an iframe, the non-file-upload case stops working also, so it definitely has to do with the iframe. Edit2: I'm using the jQuery Form Plugin. <?php if($_SERVER['REQUEST_METHOD'] == 'POST') { header('HTTP/1.1 500 Internal Server Error'); die; } else {?> <html><head> <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js?ver=2.9.2'></script> <script type='text/javascript' src='http://github.com/malsup/form/raw/master/jquery.form.js?v2.43'></script> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('a').click(function() {jQuery('form').ajaxSubmit({error: function(){alert('error handler called');}})}); }); </script> </head><body> <form method="POST"> <input type="text" name="mytext" /> <input type="file" name="myfile" /><!-- comment this element out --> <input type="hidden" name="blah" value="blah" /> <a>submit</a> </form> </body></html> <?php } Is there any way to get the error handler to be called in both situations?

    Read the article

  • Detecting Singularities in a Graph

    - by nasufara
    I am creating a graphing calculator in Java as a project for my programming class. There are two main components to this calculator: the graph itself, which draws the line(s), and the equation evaluator, which takes in an equation as a String and... well, evaluates it. To create the line, I create a Path2D.Double instance, and loop through the points on the line. To do this, I calculate as many points as the graph is wide (e.g. if the graph itself is 500px wide, I calculate 500 points), and then scale it to the window of the graph. Now, this works perfectly for most any line. However, it does not when dealing with singularities. If, when calculating points, the graph encounters a domain error (such as 1/0), the graph closes the shape in the Path2D.Double instance and starts a new line, so that the line looks mathematically correct. Example: However, because of the way it scales, sometimes it is rendered correctly, sometimes it isn't. When it isn't, the actual asymptotic line is shown, because within those 500 points, it skipped over x = 2.0 in the equation 1 / (x-2), and only did x = 1.98 and x = 2.04, which are perfectly valid in that equation. Example: In that case, I increased the window on the left and right one unit each. My question is: Is there a way to deal with singularities using this method of scaling so that the resulting line looks mathematically correct? I myself have thought of implementing a binary search-esque method, where, if it finds that it calculates one point, and then the next point is wildly far away from the last point, it searches in between those points for a domain error. I had trouble figuring out how to make it work in practice, however. Thank you for any help you may give!

    Read the article

  • echo POST array.. or other ideas?

    - by gamerzfuse
    Update: As seen in the Original Questions below, I am looking to echo an array. The problem is that when I send the Moneris gateway to return a POST array to my new file (cart.php) it gets a 500 Internal Server Error. This is the same error I received when it send to the script, which should have worked. Is there any reason that it would always send a 500 Internal Server Error? Cart.php Direct Link Craig ORIGINAL QUESTION: Hello there, I am back for another question. Here is my dilemma: I have a script (ImageFolio Commerce) that hasn't been updated on our server since.. probably 2003. The script had a Payment Gateway (Moneris) manually added to it by the company who offers the script. This costs $1000 to get them to add a gateway. I now have a new client who purchased this business from the previous owner. While switching the account to the new owner's Moneris account, we found out that things have been updated. Long story short.. The Moneris gateway can send 3 types of responses: POST with XML Data POST GET I imagine it is easiest to just use the POST array. I have the file that it sends the response to. As of now the file responds with a Internal Server error, but it does process the order. What I want to do is determine what the POST array is that is being sent, so that I can take it and echo it in a logical manner. Is there a way to capture and echo the entire POST? Or can someone suggest a better method of doing this? Thank you, Craig

    Read the article

  • How to use DLL reference with an ActiveX <object> via JavaScript

    - by John Factorial
    My question: how can I set an ActiveX object's property via JavaScript to an enum value found in a non-ActiveX DLL? Problem description: I am instantiating an ActiveX object with the following object tag: <object classid="clsid:F338193D-2491-4D7B-80CE-03487041A278" id="VideoCapture1" width="500" height="500"></object> (This is the guid for the 3rd party ActiveX I'm using, "VisioForge_Video_Capture_4.VFVideoCapture4X") I have example C# code for using this ActiveX, which I am porting to JavaScript. Code like this works just fine: VideoCapture1.Debug_Mode = true; var devcount = VideoCapture1.Video_CaptureDevices_GetCount(); var devs = []; for (var i =0; i < devcount; ++i) { devs[devs.length] = VideoCapture1.Video_CaptureDevices_GetItem(i); } ... etc ... However, VideoCapture1 has some settings which refer to a DLL enum, like so (C# code): VideoCapture1.Mode = VisioForge_Video_Capture_4.TxVFMode.Mode_Video_Preview; I can see in Visual Web Developer that TxVFMode.Mode_Video_Preview is value 1 in the enum. However, the following JS does not appear to set the Mode properly: VideoCapture1.Mode = 1; Does anyone know how I can set VideoCapture1.Mode to the enum value found in the TxVFMode? PS: In Visual Web Developer, when I "Go to definition" on TxVFMode, I get the Guid for the enum. I thought I could create an with this Guid or instantiate a VisioForge_Video_Capture_4.TxVFMode in JS, but neither gives me a usable object.

    Read the article

  • jquery: mouseleave event seems to fire when it's not supposed to

    - by Jeremy
    Given the following html table and script shown below I am having a problem where the mouse leave event appears to fire right after the mouse enter, even if I don't move the mouse out of the row. <script type="text/javascript" language="javascript"> function highlightRows(iMainID) { $('tr[mainid=' + iMainID+ ']').each(function() { if ($(this).attr('old') == undefined) { $(this).attr('old', $(this).css('backgroundColor')); } $(this).animate({ backgroundColor: "#FFFFCC" }, 500); $(this).mouseout(function() { if ($(this).attr('old') != undefined) { $(this).animate({ backgroundColor: $(this).attr('old') }, 500); } }); }); } </script> <table> <tr> <td mainid="1" onmouseover='highlightRows(1)'><div>text</div></td> <td mainid="1" onmouseover='highlightRows(1)'><div>text</div></td> <td mainid="2" onmouseover='highlightRows(2)'><div>text</div></td> </tr> <table>

    Read the article

  • Copy Small Bitmaps on to Large Bitmap with Transparency Blend: What is faster than graphics.DrawImag

    - by Glenn
    I have identified this call as a bottleneck in a high pressure function. graphics.DrawImage(smallBitmap, x , y); Is there a faster way to blend small semi transparent bitmaps into a larger semi transparent one? Example Usage: XY[] locations = GetLocs(); Bitmap[] bitmaps = GetBmps(); //small images sizes vary approx 30px x 30px using (Bitmap large = new Bitmap(500, 500, PixelFormat.Format32bppPArgb)) using (Graphics largeGraphics = Graphics.FromImage(large)) { for(var i=0; i < largeNumber; i++) { //this is the bottleneck largeGraphics.DrawImage(bitmaps[i], locations[i].x , locations[i].y); } } var done = new MemoryStream(); large.Save(done, ImageFormat.Png); done.Position = 0; return (done); The DrawImage calls take a small 32bppPArgb bitmaps and copies them into a larger bitmap at locations that vary and the small bitmaps might only partially overlap the larger bitmaps visible area. Both images have semi transparent contents that get blended by DrawImage in a way that is important to the output. I've done some testing with BitBlt but not seen significant speed improvement and the alpha blending didn't come out the same in my tests. I'm open to just about any method including a better call to bitblt or unsafe c# code.

    Read the article

  • My 3D object (opengl es) is disappearing behind the iPhone camera view

    - by KLC
    I have an augmented reality iPhone app that I am converting from Core Animation to OpenGL ES 1.1. I have added code that has been modified from the Apple OpenGL template. My problem is that my 3D object , when translating along the negative Z-axis (away from the user), appears to disappear into the camera view, until its completely gone. I have experimented with several solutions, but to no avail. What I have determined: Using the 3D icosahedron from Jeff Lamarche's blog here, the object starts it at 0,0,0 and then translates with decreasing z coordinates. By the time the z value reaches -2.0f, the object is gone. It appears as if it is disappearing behind the camera view. This is how I set my frustrum & viewport (unchanged from Apple's code) glMatrixMode(GL_PROJECTION); size = zNear * tanf(DEGREES_TO_RADIANS(fieldOfView) / 2.0); //Grab the size of the screen CGRect rect = self.bounds; glFrustumf(-size, size, -size / (rect.size.width / rect.size.height), size / (rect.size.width / rect.size.height), zNear, zFar); glViewport(0, 0, rect.size.width, rect.size.height); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); What I have tried: The camera view is the main view and several other views are added to it as subviews, including the openGLView. I have commented those views out for test purposes. I have applied CATransforms to move the openGLView in the z direction -500 and +500, and done the same to the camera view. I have also changed the zFar in the above code to 1.0f, and it still disappears at z position of -2.0, which doesn't make sense (shouldn't it disappear at z=1.0?) My experimentation has got me more confused than when I started ( which usually means I am missing a key piece, but I can't figure out what). Thanks for your help.

    Read the article

  • Efficient Method for Preventing Hotlinking via .htaccess

    - by Michael Robinson
    I need to confirm something before I go accuse someone of ... well I'd rather not say. The problem: We allow users to upload images and embed them within text on our site. In the past we allowed users to hotlink to our images as well, but due to server load we unfortunately had to stop this. Current "solution": The method the programmer used to solve our "too many connections" issue was to rename the file that receives and processes image requests (image_request.php) to image_request2.php, and replace the contents of the original with <?php header("HTTP/1.1 500 Internal Server Error") ; ?> Obviously this has caused all images with their src attribute pointing to the original image_request.php to be broken, and is also the wrong code to be sending in this case. Proposed solution: I feel a more elegant solution would be: In .htaccess If the request is for image_request.php Check referrer If referrer is not our site, send the appropriate header If referrer is our site, proceed to image_request.php and process image request What I would like to know is: Compared to simply returning a 500 for each request to image_request.php: How much more load would be incurred if we were to use my proposed alternative solution outlined above? Is there a better way to do this? Our main concern is that the site stays up. I am not willing to agree that breaking all internally linked images is the best / only way to solve this. I refuse to tell our users that because of something WE changed they must now manually change the embed code in all their previously uploaded content.

    Read the article

  • How to use my trackpad for horizontal mousewheel scrolling in a Java AWT ScrollPane

    - by blissapp
    Like many modern mice and trackpads, my laptop supports vertical and horizontal scrolling. It's an addictive feature once you get used to it. I simply want my Java apps to support horizontal scrolling via the trackpad/mousewheel, but everywhere I search it seems that this is not possible in Java. I really want someone to tell me that I'm somehow doing it wrong, this feature is already requested behaviour: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6440198 The inability to do this simple thing is actually a deal breaker for the app I'm working on. In fact, for any app I can envision! I've invested a bit of time in the Java backend, so I'd really like to find a solution for this seemingly simple thing. Question is what could I do to implement this behaviour? Are raw OS level events even exposed to java, would I then need to write this from scratch? import java.awt.*; public class ScrollExample extends Canvas { public void paint(Graphics g) { g.setColor(Color.green); g.fillOval(0,0,400, 400); } public static void main(String[] args) { ScrollExample b = new ScrollExample(); Frame f = new Frame ("Scroll Example"); ScrollPane scroller = new ScrollPane (ScrollPane.SCROLLBARS_ALWAYS); scroller.add(b,"Center"); f.setPreferredSize(new Dimension(500,500)); f.add ("Center",scroller); f.pack(); f.show(); } }

    Read the article

  • How do you efficiently bulk index lookups?

    - by Liron Shapira
    I have these entity kinds: Molecule Atom MoleculeAtom Given a list(molecule_ids) whose lengths is in the hundreds, I need to get a dict of the form {molecule_id: list(atom_ids)}. Likewise, given a list(atom_ids) whose length is in the hunreds, I need to get a dict of the form {atom_id: list(molecule_ids)}. Both of these bulk lookups need to happen really fast. Right now I'm doing something like: atom_ids_by_molecule_id = {} for molecule_id in molecule_ids: moleculeatoms = MoleculeAtom.all().filter('molecule =', db.Key.from_path('molecule', molecule_id)).fetch(1000) atom_ids_by_molecule_id[molecule_id] = [ MoleculeAtom.atom.get_value_for_datastore(ma).id() for ma in moleculeatoms ] Like I said, len(molecule_ids) is in the hundreds. I need to do this kind of bulk index lookup on almost every single request, and I need it to be FAST, and right now it's too slow. Ideas: Will using a Molecule.atoms ListProperty do what I need? Consider that I am storing additional data on the MoleculeAtom node, and remember it's equally important for me to do the lookup in the molecule-atom and atom-molecule directions. Caching? I tried memcaching lists of atom IDs keyed by molecule ID, but I have tons of atoms and molecules, and the cache can't fit it. How about denormalizing the data by creating a new entity kind whose key name is a molecule ID and whose value is a list of atom IDs? The idea is, calling db.get on 500 keys is probably faster than looping through 500 fetches with filters, right?

    Read the article

  • Query to MySQL from c# returns System.Byte[]

    - by karthik
    I am using the below SP to return the value of Generated Insert statement and it works fine when executed in Query browser. When i try to get the value from C#, it give's me "System.Byte[]" as return value. When i try to get the value from MySql query browser, it give's me return value as : 'insert into admindb.accounts values("54321","2","karthik2","karthik2","1");' I guess the problem is with the single quotes of the returned value. Is it so ? DELIMITER $$ DROP PROCEDURE IF EXISTS `admindb`.`InsGen` $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `InsGen`( in_db varchar(20), in_table varchar(20), in_ColumnName varchar(20), in_ColumnValue varchar(20) ) BEGIN declare Whrs varchar(500); declare Sels varchar(500); declare Inserts varchar(2000); declare tablename varchar(20); declare ColName varchar(20); set tablename=in_table; # Comma separated column names - used for Select select group_concat(concat('concat(\'"\',','ifnull(',column_name,','''')',',\'"\')')) INTO @Sels from information_schema.columns where table_schema=in_db and table_name=tablename; # Comma separated column names - used for Group By select group_concat('`',column_name,'`') INTO @Whrs from information_schema.columns where table_schema=in_db and table_name=tablename; #Main Select Statement for fetching comma separated table values set @Inserts=concat("select concat('insert into ", in_db,".",tablename," values(',concat_ws(',',",@Sels,"),');') as MyColumn from ", in_db,".",tablename, " where ", in_ColumnName, " = " , in_ColumnValue, " group by ",@Whrs, ";"); PREPARE Inserts FROM @Inserts; EXECUTE Inserts; END $$ DELIMITER ;

    Read the article

  • In Ruby, how to implement 20 - point and point - 20 using coerce() ?

    - by Jian Lin
    In Ruby, the operation of point - 20 20 - point are to be implemented. But the following code: class Point attr_accessor :x, :y def initialize(x,y) @x, @y = x, y end def -(q) if (q.is_a? Fixnum) return Point.new(@x - q, @y - q) end Point.new(@x - q.x, @y - q.y) end def -@ Point.new(-@x, -@y) end def *(c) Point.new(@x * c, @y * c) end def coerce(something) [self, something] end end p = Point.new(100,100) q = Point.new(80,80) p (-p) p p - q p q - p p p * 3 p 5 * p p p - 30 p 30 - p Output: #<Point:0x2424e54 @x=-100, @y=-100> #<Point:0x2424dc8 @x=20, @y=20> #<Point:0x2424d3c @x=-20, @y=-20> #<Point:0x2424cc4 @x=300, @y=300> #<Point:0x2424c38 @x=500, @y=500> #<Point:0x2424bc0 @x=70, @y=70> #<Point:0x2424b20 @x=70, @y=70> 30 - p will actually be taken as p - 30 by the coerce function. Can it be made to work? I am actually surprise that the - method won't coerce the argument this way: class Fixnum def -(something) if (/* something is unknown class */) a, b = something.coerce(self) return -(a - b) # because we are doing a - b but we wanted b - a, so it is negated end end end that is, the function returns a negated version of a - b instead of just returning a - b.

    Read the article

  • Simple Prototype.js code to select multiple elements with the same classname

    - by stephemurdoch
    I have one link with an id of "link", and I use the javascript below to open that link up in a modalbox: #In my template I have: <a href="some/path" id="link">link</a> #Then in my application.js file I have: document.observe('dom:loaded', function() { $('login-link').observe('click', function(event) { event.stop(); Modalbox.show(this.href,{title: 'some title', width: 500}); }); }) Since id's must be unique, this javascript only works for one element per page so I use it to observe my login-link and it has served me well. Until now. I want to use the same javascript to observe multiple links which have classnames instead of id's as below: <a href="link/to/some/stuff" class="link">link 1</a> <a href="link/to/some/other/stuff" class="link">link 2</a> When I do this, I can't get any of the links to open in a modalbox. If I change the class to an id for each link, then I can get the first link in the list to open in a modalbox. I've tried to use the '$$' notation to build an array of links in my javascript (shown below) but if I do that, then none of the links open correctly #document.observe method removed for display purposes $$('link').observe('click', function(event) { event.stop(); Modalbox.show(this.href,{title: 'some title', width: 500} ); }); My javascript skills obviously suck. Does anyone know how to fix the problem?

    Read the article

  • Google Maps inside custom PODS page

    - by Sharath
    I have a custom pods page called addstory.php which uses a public form to display some input fields. For one of the fields, i have a input helper that displays a google map location which I can use to pick out a location which is stored in comma separated variable. Here is the input helper code... <div class="form pick <?php echo $location; ?>"> <div id="map" style="width:500; height:500"> </div> <script type="text/javascript"> $(function() { map=new GMap(document.getElementById("map")); map.centerAndZoom(new GPoint(77.595062,13.043359),6); map.setUIToDefault(); GEvent.addListener(map,"click",function(overlay,latlng) { map.clearOverlays(); var marker = new GMarker(latlng); map.addOverlay(marker); //Extra stuff here.. } ); }); </script> </div> And this is the code inside my addstory.php <?php get_header(); $rw = new Pod('rainwater'); $fields=array( 'name', 'email', 'location'=>array('input_helper'=>'gmap_location'), ); echo $rw->publicForm($fields); ?> I get the following error...and the google map doesn't load. a is null error source line: [Break on this error] function Qd(a){for(var b;b=a.firstChild;){Rg(b);a.removeChild(b)}}

    Read the article

  • Raphael.js map default fill colors

    - by RIDER
    I am trying to familiarize myself with raphael.js. I want to create a USA map that already has default colors for each state and those colors stay there. Here is what I came up with. If you look at AK, I'm getting the default color loaded, but if I highlight another state, the default color for AK disappears. I want AK - and other states - to stay the same color. Specifically, I don't know what is clearing out my AK full color. I think part of this statement is clearing out the fill cover when I mouseover a different state: for (var state in aus) { //aus[state].color = Raphael.getColor(); (function (st, state) { st[0].style.cursor = "pointer"; st[0].onmouseover = function () { current && aus[current].animate({fill: "#333", stroke: "#666"}, 500) && (document.getElementById(current).style.display = ""); st.animate({fill: st.color, stroke: "#ccc"}, 500); st.toFront(); R.safari(); document.getElementById(state).style.display = "block"; current = state; }; })(aus[state], state); } Any ideas where I might be going wrong?

    Read the article

< Previous Page | 35 36 37 38 39 40 41 42 43 44 45 46  | Next Page >