Search Results

Search found 205 results on 9 pages for 'jonas bystrom'.

Page 6/9 | < Previous Page | 2 3 4 5 6 7 8 9  | Next Page >

  • Converting convex hull to binary mask

    - by Jonas
    I want to generate a binary mask that has ones for all pixels inside and zeros for all pixels outside a volume. The volume is defined by the convex hull around a set of 3D coordinates (<100; some of the coordinates are inside the volume). I can get the convex hull using CONVHULLN, but how do I convert that into a binary mask? In case there is no good way to go via the convex hull, do you have any other idea how I could create the binary mask?

    Read the article

  • How can I clip strings in Java2D and add ... in the end?

    - by Jonas
    I'm trying to print Invoices in a Java Swing applications. I do that by extending Printable and implement the method public int print(Graphics g, PageFormat pf, int page). I would like to draw strings in columns, and when the string is to long I want to clip it and let it end with "...". How can I measure the string and clip it at the right position? Some of my code: Font headline = new Font("Times New Roman", Font.BOLD, 14); g2d.setFont(headline); FontMetrics metrics = g2d.getFontMetrics(headline); g2d.drawString(myString, 0, 20); I.e How can I limit myString to be max 120px? I could use metrics.stringWidth(myString), but I don't get the position where I have to clip the string. Expected results could be: A longer string that exc... A shorter string. Another long string, but OK

    Read the article

  • Asp .Net MVC Viewmodel should be class or struct?

    - by Jonas Everest
    Hey guys, I have just been thinking about the concept of view model object we create in asp.net MVC. Our purpose is to instantiate it and pass it from controller to view and view read it and display the data. Those view model are usually instantiated through constructor. We won't need to initialize the members, we may not need to redefine/override parameterless constructor and we don't need inheritance feature there. So, why don't we use struct type for our view model instead of class. It will enhance the performance.

    Read the article

  • Fixing parent controller's elements after screen orientation

    - by Jonas Anderson
    I have a tab bar application with mixed orientation support for only some views. One of the child view controller shown from one of the tab's navigation controller is displayed only in Landscape mode. In order to accomplish this, I've done the view transformation for the child view as suggested here: Is there a documented way to set the iPhone orientation? The only problem I'm seeing is that after I've performed the orientation adjustment for the child controller and then readjusted orientation back to normal on its dismissal, the contents of the (parent) navigation controller is still shown with Landscape mode dimensions despite the navigation controller reporting the correct value for the interfaceOrientation. How do I ensure that view's size is reset to match the orientation without hardcoding screen dimensions? I have the following in the root navigation controller's viewWillAppear (invoked after the child controller is dismissed): - (void)viewWillAppear:(BOOL)animated { NSLog(@"viewFrame: (%2f, %2f), width: %2f, height: %2f\n", self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height); // Frame values are (0, 0) for (x,y) width: 320, height: 367 before I // displayed child controller. // Frame values are (0,0) width: 480, height: 219 after returning from child // controller -- still has the landscape dimensions NSLog(@"orientation: %d", self.interfaceOrientation); // reports portrait as expected } I've tried to invoke 'layoutIfNeeded' as well as 'setNeedsDisplay' on the view but neither of them bring the view contents into the correct display. Any suggestions would be greatly appreciated.

    Read the article

  • How can I "pack()" a printable Java Swing component?

    - by Jonas
    I have implemented a Java Swing component that implements Printable. If I add the component to a JFrame, and do this.pack(); on the JFrame, it prints perfect. But if I don't add the component to a JFrame, just a blank page is printed. This code gives a great printout: final PrintablePanel p = new PrintablePanel(pageFormat); new JFrame() {{ getContentPane().add(p); this.pack(); }}; job.setPrintable(p, pageFormat); try { job.print(); } catch (PrinterException ex) { System.out.println("Fail"); } But this code gives a blank page: final PrintablePanel p = new PrintablePanel(pageFormat); // new JFrame() {{ getContentPane().add(p); this.pack(); }}; job.setPrintable(p, pageFormat); try { job.print(); } catch (PrinterException ex) { System.out.println("Fail"); } I think that this.pack(); is the big difference. How can I do pack() on my printable component so it prints fine, without adding it to a JFrame? The panel is using several LayoutManagers. I have tried with p.validate(); and p.revalidate(); but it's not working. Any suggestions? Or do I have to add it to a hidden JFrame before I print the component?

    Read the article

  • In Javascript, how to avoid NaN when adding arrays

    - by Jonas
    I'm trying to add the values of two arrays in javascript eg. [1,2,1] + [3,2,3,4] The answer should be 4,4,4,4 but I'm either getting 4,4,4 or 4,4,4,NaN if I change the 1st array length to 4. I know a 4th number needs to be in the 1st array, but i can't figure out how to tell javascript to make it 0 rather then undefined if there is no number.

    Read the article

  • What alternatives do I have if I want a distributed multi-master database?

    - by Jonas
    I will build a system where I want to reduce single-point-of-failures, and I need a database. Is there any (free) relational database systems that can handle multi-master setups good (i.e where it is easy to add and remove nodes) or is it better to go with a NoSQL-database? As what I have understood, a key-value store will handle this better. What database system do you recommend for a multi-master (cluster) setup?

    Read the article

  • How to implement Auto_Increment per User, on the same table?

    - by Jonas
    I would like to have multiple users that share the same tables in the database, but have one auto_increment value per user. I will use an embedded database, JavaDB and as what I know it doesn't support this functionality. How can I implement it? Should I implement a trigger on inserts that lookup the users last inserted row, and then add one, or are there any better alternative? Or is it better to implement this in the application code? Or is this just a bad idea? I think this is easier to maintain than creating new tables for every user. Example: table +----+-------------+---------+------+ | ID | ID_PER_USER | USER_ID | DATA | +----+-------------+---------+------+ | 1 | 1 | 2 | 3454 | | 2 | 2 | 2 | 6567 | | 3 | 1 | 3 | 6788 | | 4 | 3 | 2 | 1133 | | 5 | 4 | 2 | 4534 | | 6 | 2 | 3 | 4366 | | 7 | 3 | 3 | 7887 | +----+-------------+---------+------+ SELECT * FROM table WHERE USER_ID = 3 +----+-------------+---------+------+ | ID | ID_PER_USER | USER_ID | DATA | +----+-------------+---------+------+ | 3 | 1 | 3 | 6788 | | 6 | 2 | 3 | 4366 | | 7 | 3 | 3 | 7887 | +----+-------------+---------+------+ SELECT * FROM table WHERE USER_ID = 2 +----+-------------+---------+------+ | ID | ID_PER_USER | USER_ID | DATA | +----+-------------+---------+------+ | 1 | 1 | 2 | 3454 | | 2 | 2 | 2 | 6567 | | 4 | 3 | 2 | 1133 | | 5 | 4 | 2 | 4534 | +----+-------------+---------+------+

    Read the article

  • MySQL Hashing Function Implementation

    - by Jonas Stevens
    I know that php has md5(), sha1(), and the hash() functions, but I want to create a hash using the MySQL PASSWORD() function. So far, the only way I can think of is to just query the server, but I want a function (preferably in php or Perl) that will do the same thing without querying MySQL at all. For example: MySQL hash - 464bb2cb3cf18b66 MySQL5 hash - *01D01F5CA7CA8BA771E03F4AC55EC73C11EFA229 Thanks!

    Read the article

  • Hide a single content block from search engines?

    - by jonas
    A header is automatically added on top of each content URL, but its not relevant for search and messing up the all the results beeing the first line of every page (in the code its the last line but visually its the first, which google is able to notice) Solution1: You could put the header (content to exculde from google searches) in an iframe with a static url domain.com/header.html and a <meta name="robots" content="noindex" /> ? - are there takeoffs of this solution? Solution2: You could deliver it conditionally by apache mod rewrite, php or javascript -takeoff(?): google does not like it? will google ever try pages with a standard users's useragent and compare? -takeoff: The hidden content will be missing in the google cache version as well... example: add-header.php: <?php $path = $_GET['path']; echo file_get_contents($_SERVER["DOCUMENT_ROOT"].$path); ?> apache virtual host config: RewriteCond %{HTTP_USER_AGENT} !.*spider.* [NC] RewriteCond %{HTTP_USER_AGENT} !Yahoo.* [NC] RewriteCond %{HTTP_USER_AGENT} !Bing.* [NC] RewriteCond %{HTTP_USER_AGENT} !Yandex.* [NC] RewriteCond %{HTTP_USER_AGENT} !Baidu.* [NC] RewriteCond %{HTTP_USER_AGENT} !.*bot.* [NC] RewriteCond %{SCRIPT_FILENAME} \.htm$ [NC,OR] RewriteCond %{SCRIPT_FILENAME} \.html$ [NC,OR] RewriteCond %{SCRIPT_FILENAME} \.php$ [NC] RewriteRule ^(.*)$ /var/www/add-header.php?path=%1 [L]

    Read the article

  • How should I implement items that are normalized in the Database, in Object Oriented Design?

    - by Jonas
    How should I implement items that are normalized in the Database, in Object Oriented classes? In the database I have a big table of items and a smaller of groups. Each item belong to one group. This is how my database design look like: +----------------------------------------+ | Inventory | +----+------+-------+----------+---------+ | Id | Name | Price | Quantity | GroupId | +----+------+-------+----------+---------+ | 43 | Box | 34.00 | 456 | 4 | | 56 | Ball | 56.50 | 3 | 6 | | 66 | Tin | 23.00 | 14 | 4 | +----+------+-------+----------+---------+ Totally 3000 lines +----------------------+ | Groups | +---------+------+-----+ | GroupId | Name | VAT | +---------+------+-----+ | 4 | Mini | 0.2 | | 6 | Big | 0.3 | +---------+------+-----+ Totally 10 lines I will use the OOP classes in a GUI, where the user can edit Items and Groups in the inventory. It should also be easy to do calculations with a bunch of items. The group information like VAT are needed for the calculations. I will write an Item class, but do I need a Group class? and if I need it, should I keep them in a global location or how do I access it when I need it for Item-calculations? Is there any design pattern for this case?

    Read the article

  • How can I get the name of all tables in a JavaDB database?

    - by Jonas
    How can i programmatically get the names of all tables in a JavaDB database? Is there any specific SQL-statement over JDBC I can use for this or any built in function in JDBC? I will use it for exporting the tables to XML, and would like to do it this way so I don't miss any tables from the database when exporting.

    Read the article

  • What are the drawbacks with Jasper Reports?

    - by Jonas
    I'm evaluating report engines for a Java desktop application. I need to print receipts, invoices and reports. I'm looking at Jasper Reports since it seem to be the most popular reporting engine in the Java world. Are there any big drawbacks or disadvantages with using it in a small business system?

    Read the article

  • How can I bind a List as ItemSource to ListView in XAML?

    - by Jonas
    I'm learning WPF and would like to have a collection similar to a LinkedList, to where I can add and remove strings. And I want to have a ListView that listen to that collection with databinding. How can I do bind a simple list collection to a ListView in XAML? My idea (not working) is something like this: <Window x:Class="TestApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <LinkedList x:Key="myList"></LinkedList> //Wrong <Window.Resources> <Grid> <ListView Height="100" HorizontalAlignment="Left" Margin="88,134,0,0" Name="listView1" VerticalAlignment="Top" Width="120" ItemsSource="{Binding Source={StaticResource myList}}"/> //Wrong </Grid> </Window> All my code (updated version, not working): <Window x:Class="TestApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <TextBox Height="23" HorizontalAlignment="Left" Margin="12,12,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" /> <Button Content="Button" Height="23" HorizontalAlignment="Right" Margin="0,12,290,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" /> <ListView Height="100" HorizontalAlignment="Left" Margin="88,134,0,0" Name="listView1" VerticalAlignment="Top" Width="120" ItemsSource="{Binding myList}"/> </Grid> </Window> C#-code: namespace TestApp { public partial class MainWindow : Window { ObservableCollection<string> myList = new ObservableCollection<string>(); public MainWindow() { InitializeComponent(); myList.Add("first string"); } private void button1_Click(object sender, RoutedEventArgs e) { myList.Add(textBox1.Text); textBox1.Text = myList.Count+"st"; } } }

    Read the article

  • When should I write my own Look and Feel for Java Swing instead of customizing one?

    - by Jonas
    I have used a few different Look and Feels for Java Swing, but I don't really like anyone to 100% so I often end up with customizing it a lot. Sometimes I am thinking about if it is a better idea to write my own LaF (by extending an existing one), but I don't really know. For the moment, I mostly use Nimbus, but I change all colors (to darker ones) and rewrite the appearance of some components, like sliders and scrollbars. I also mostly customize all tables and I am thinking about to change the look of a few other components. When is it recommended to create a new Look-and-Feel instead of customizing one? What are the pros and cons? I.e. customize Nimbus or create a new one by extending Nimbus? Related article: Creating a Custom Look and Feel (old)

    Read the article

  • Maven - Selenium - Possible to run only one test

    - by Jonas Söderström
    Hi We are using JUnit - Selenium for our web tests. We use Maven to start them and build a surefire report. The test suite is pretty large and takes a while to run and sometimes single tests fail because the browser won't start. I want to be able run a SINGLE test using maven so I retest the tests that fail and update the report. I can use mvn test -Dtest=TESTCLASSNAME to run all the tests in one test class, but this is not good enough since it takes about 10 minutes to run all the tests in our most complicated test classes and it's very likely that some other test will fail (because the browser wont start) and this will mess up my report. I know I can run one test from Eclipse but that is not what I am looking for. Any help on this would be very appriciated

    Read the article

  • c# calculation help

    - by Jonas B
    Hi, I'm pretty useless when it comes to math and I have a problem I need help with. This has nothing to do with schoolwork, it's in fact about alcatel and the ticketextractor. I have two values that needs to be calculated in a c# application according to a formula specified in their documentation: "The global callid is equal to: callid1 multiplied by 2 power 32 plus callid2" As I said I'm not big with maths so that statement says nothing to me. If anyone know how to calculate it i'd appreciate it! Thanks

    Read the article

  • Calculating terrain height in 3d-space

    - by Jonas B
    Hi I'm diving into 3d programming a bit and am currently learning by writing a procedural terrain generator that generates terrain based on a heightmap. I would also want to implement some physics and my first attempt at terrain collision was by simply checking the current position vs the heightmap. This however wont work well against small objects as you'd have to calculate the height by taking the heightdifference of the nearest vertices of the object and doing this every colision check is pretty slow. Beleive me I tried googling for it but there's simply so much crap and millions of blogs posting ripped-of newbie tutorials everywhere with basically no real information on the subject, I can't find anything that explains it or even names any generally used techniques. I'm not asking for code or a complete solution, but if anyone knows a particular technique good for calculating a high-res heightmap out of the already generated and smoothed terrain I would be very happy as I could look into it further when I know what I'm looking for. Thanks

    Read the article

  • iCalcreator 2.6 event creation sent in an email w/o attachment

    - by Jonas
    G'day everyone, I am currently trying to send meeting invitations to Outlook recipients. After reading several blogs and various literature iCalcreator seems to be the most complete iCalendar PHP class available. And the documentation is just...crazily complete. If creating a iCal .ics file is OK, I can't find a nice way to send it by email to the attendees without having them to double click on an attachment. Just like Google Calendar and Outlook do, I would like to send emails that will automatically show the buttons Accept | Tentative | Decline upon reception without any other user action involved. If anyone ever had to realize that, I would be more than happy to get your feedback/help or even just relevant guidance. Thanks

    Read the article

  • All parts of my Printable Swing component doesn't print

    - by Jonas
    I'm trying to do a printable component (an invoice document). I use JComponent instead of JPanel because I don't want a background. The component has many subcomponents. The main component implements Printable and has a print-method that is calling printAll(g) so that all subcomponents should be printed. But my subcomponents doesn't print. What am I missing? Does all subcomponents also has to implement Printable? import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GridLayout; import java.awt.print.PageFormat; import java.awt.print.Printable; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; public class PPanel extends JComponent implements Printable { static double w; static double h; public PPanel() { this.setLayout(new BorderLayout()); this.add(new JLabel("Document Body"), BorderLayout.CENTER); this.add(new Header(), BorderLayout.NORTH); this.add(new Footer(), BorderLayout.SOUTH); } class Header extends JComponent { public Header() { this.setLayout(new BorderLayout()); this.add(new TopHeader(), BorderLayout.NORTH); this.add(new LowHeader(), BorderLayout.SOUTH); } } class TopHeader extends JComponent { public TopHeader() { this.setLayout(new BorderLayout()); JLabel companyName = new JLabel("Company name"); JLabel docType = new JLabel("Document type"); this.add(companyName, BorderLayout.WEST); this.add(docType, BorderLayout.EAST); } } class LowHeader extends JComponent { public LowHeader() { this.setLayout(new GridLayout(0,2)); JLabel col1 = new JLabel("Column 1"); JLabel col2 = new JLabel("Column 2"); this.add(col1); this.add(col2); } } class Footer extends JComponent { public Footer() { this.setLayout(new GridLayout(0,2)); JLabel addr = new JLabel("Address"); JLabel sum = new JLabel("Sum"); this.add(addr); this.add(sum); } } public static void main(String[] args) { final PPanel p = new PPanel(); PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(p); try { job.print(); } catch (PrinterException ex) { // print failed } // Preview new JFrame() {{ getContentPane().add(p); this.setSize((int)w, (int)h); setVisible(true); }}; } @Override public int print(Graphics g, PageFormat pf, int page) throws PrinterException { if (page > 0) { return NO_SUCH_PAGE; } Graphics2D g2d = (Graphics2D)g; g2d.translate(pf.getImageableX(), pf.getImageableY()); w = pf.getImageableWidth(); h = pf.getHeight(); this.setSize((int)w, (int)h); this.setPreferredSize(new Dimension((int)w, (int)h)); this.doLayout(); this.printAll(g); return PAGE_EXISTS; } }

    Read the article

  • How to deploy a Java Swing application with an embedded JavaDB database?

    - by Jonas
    I have implemented an Java Swing application that uses an embedded JavaDB database. The database need to be stored somewhere and the database tables need to be created at the first run. What is the preferred way to do these procedures? Should I always create the database in the local directory, and first check if the database file exist, and if it doesn't exist let the user create the tables (or at least show a message that the tables will be created). Or should I let the user choose a path? but then I have to save the path somewhere. Should I save the path with Preferences.systemRoot();, and check if that variable is set on startup? If the user choses a path and save it in the Preferences, can I get any problems with user permissions? or should it be safe wherever the user store the database? Or how do I handle this? Any other suggestions for this procedure?

    Read the article

  • What tool for printing Invoices and similar documents in Java Swing?

    - by Jonas
    I'm looking for a good tool for printing Invoices, Receipts and similar documents in Java Swing. I have tried JasperReports but it is pretty hard to get a dynamic layout and it is designing for reports. A requirement that I have is that the document should be sent directly to the printer and must not be saved to a file. So some tools that first creates an Office Document or a PDF document isn't a solution for me. Any recommendations?

    Read the article

  • How do I comment out a block in XML?

    - by Jonas
    How do I comment out a block of tags in XML? I.e. How can I comment out <staticText> and everything inside it, in the code below? <detail> <band height="20"> <staticText> <reportElement x="180" y="0" width="200" height="20"/> <text><![CDATA[Hello World!]]></text> </staticText> </band> </detail> I could use <!-- staticText--> but that's just for single tags (as what I know), like // in Java and C. I would like something more like how /** comment **/ can be used in Java and C, so I can comment out longer blocks of XML code.

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9  | Next Page >