Search Results

Search found 15 results on 1 pages for 'marionmaiden'.

Page 1/1 | 1 

  • Convert RGB value to HSV

    - by marionmaiden
    I've found a method on the Internet to convert RGB values to HSV values. Unfortunately, when the values are R=G=B, I'm getting a NaN, because of the 0/0 operation. Do you know if there is an implemented method for this conversion in Java, or what do I have to do when I get the 0/0 division to get the right value of the HSV? Here comes my method, adapted from some code on the Internet: public static double[] RGBtoHSV(double r, double g, double b){ double h, s, v; double min, max, delta; min = Math.min(Math.min(r, g), b); max = Math.max(Math.max(r, g), b); // V v = max; delta = max - min; // S if( max != 0 ) s = delta / max; else { s = 0; h = -1; return new double[]{h,s,v}; } // H if( r == max ) h = ( g - b ) / delta; // between yellow & magenta else if( g == max ) h = 2 + ( b - r ) / delta; // between cyan & yellow else h = 4 + ( r - g ) / delta; // between magenta & cyan h *= 60; // degrees if( h < 0 ) h += 360; return new double[]{h,s,v}; }

    Read the article

  • JTable filled with database data is not being updated when columns are reordered.

    - by marionmaiden
    I have a JTable filled with data of a table of my database (so I used ResultSetTableModel) and using TableRowSorter to sort the rows, as I click in one column of the JTable. The data is displayed in the jTable without problems; But when I sort the JTable by some column table (for example, sorting it by the primary key value), and edit some cell from the sorted jTable, the value changed is the old cell that were in that position before the ordenation of the column. For example: Suppose I have a table with 2 columns - name and age. My table has the following data: c 1 b 2 a 3 when I order i by name in the JTable, it becomes like this a 3 b 2 c 1 if I edit the value "1", after the edition, the table becomes like this a 1 b 2 c 1 It seems that the positions are not being updated in the JTable, and the values are edited considering their original positions.

    Read the article

  • Setting a value into a object using reflection

    - by marionmaiden
    Hello I have an object that has a lot of attributes, each one with it's getter and setter. Each attribute has a non primitive type, that I don't know at runtime. For example, what I have is this: public class a{ private typeA attr1; private typeB attr2; public typeA getAttr1(){ return attr1; } public typeB getAttr2(){ return attr2; } public void setAttr1(typeA at){ attr1 = at; } public void setAttr2(typeB at){ attr2 = at; } } public class typeA{ public typeA(){ // doesn't matter } } public class typeB{ public typeB(){ // doesn't matter } } So, using reflection, I obtained the setter method for an attribute. Setting a value in the standard way is something like this: a test = new a(); a.setAttr1(new typeA()); But how can I do this using reflection? I already got the setAttr1() method using reflection, but I don't know how to create a new typeA object to be inserted in the setter.

    Read the article

  • Fill a array with List data with one more element

    - by marionmaiden
    Hello, By a question that I made, I figured out that tho copy elements from one list to an array I just need to use the method toArray() for this. But let's suppose I have a List with n objects. I want to copy then into a array sized n+1 and add into the first position another object and in the other n positions the n data of the list. This is the way I'm doing it for now, but I'm just wondering if there is a better way for do that: Object array[] = new Object[list.size() + 1]; Object chk = new Object(); array[0] = chk; for(int i = 1; i < array.length; i++){ array[i] = list.get(i); }

    Read the article

  • Children in Enumeration

    - by marionmaiden
    Hello I have a enumeration for elements in a JTree When I find some specific element in this JTree, I want to check it's children. Do the method children() in a Enumeration check it's grandcildren too? For example, let's supose this JTree, considering the identation as new levels of the tree: Fruits apple grape orange peach pineapple strawberry banana If I get the children of grape, will I have just orange and peach or will I get peach children (pineaple) too?

    Read the article

  • The bigger value in a matrix row

    - by marionmaiden
    How can I get the 2 biggers numbers of a matrix row? If the matrix have a bigger number in other row, it can't be shown. For example, let's suppose I have the following matrix int mat[][] ={{1,2,3}{4,5,6}{7,8,9}}; if I search the 2 biggers numbers from the row 0, it should return me 1 and 2.

    Read the article

  • Mysql Removal of primary key

    - by marionmaiden
    Hello, I've removed the primary key of one table of my MySQL database, but now, when I use the MySQL Administrator and try to edit the data of this table, it doesn't allow me to do this. The button edit that appears in the bottom of the table keeps visible, but unable to click.

    Read the article

  • Getting N random numbers that the sum is M

    - by marionmaiden
    Hello I want to get N random numbers that the sum of them is a value. For example, let's suppose I want 5 random numbers that their sum is 1 Then, a valid possibility is: 0.2 0.2 0.2 0.2 0.2 Other possibility is: 0.8 0.1 0.03 0.03 0.04 And so on. I need this for the creation of the matrix of belongings of the Fuzzy C-means.

    Read the article

  • Removal of table primary key in MySQL

    - by marionmaiden
    Hello, I've removed the primary key of one table of my MySQL database, but now, when I use the MySQL Administrator and try to edit some data of this table, it doesn't allow me to do this. The button edit that appears in the bottom of the table keeps visible, but disabled to click.

    Read the article

  • Convert an ArrayList to an object array

    - by marionmaiden
    Hello, Is there a command in java for conversion of an ArrayList into a object array. I know how to do this copying each object from the arrayList into the object array, but I was wondering if would it be done automatically. I want something like this: ArrayList<TypeA> a; // Let's imagine "a" was filled with TypeA objects TypeA[] array = MagicalCommand(a);

    Read the article

  • Fill a array with List data

    - by marionmaiden
    How can I fill a array with the data provided by one List? For example, I have a List with Strings: List l = new ArrayList<String>(); l.add("a"); l.add("b"); l.add("c"); then I want to copy this data into a String array: String[] array = ?

    Read the article

1