Force z-sorting of objects?
I am trying to create a 3d interface that displays on
top/front of the 3d scene. I have different objects I want to
display in the correct order but because of perspectives of
different cameras, and the moving/animating of some objects, they
don't always display in the order I want them to.
So, is there a way to force some 3d objects to draw on top
of/in front of other objects? (can't use overlay, must be 3d
objects)
thanks!!!
http://java.sun.com/j2se/1.4.1/docs/api/java/util/Arrays.html#sort(java.lang.Object[])
public static void sort(Object[] a) "[t]hrows:
ClassCastException - If the array contains elements that are not mutually comparable (for example, string and integers)."
Similar Messages
-
I have a class with some fields.
I want to sort the objects based on a particular field.
How to use comparable(Oject o)I've posted an example here,
http://forum.java.sun.com/thread.jsp?forum=31&thread=448348 -
Need to sort an object array using an element in the object.
hi all,
i need to sort an object array using an element in the object.can someone throw some light on this.
Edited by: rageeth on Jun 14, 2008 2:32 AM[http://java.sun.com/docs/books/tutorial/collections/interfaces/order.html]
-
How to force cache to release objects
In MappingWorkbench I have configured the cache for my class (SoftCacheWeakIdentityMap, size 30000). Then I use following code to write out the cache size (more precisely: number of objects in the cache) and the cache size is bigger then 30000. Why is there more objects than 30000 (even if no users are connected)? How can I force Toplink (or JVM) to release not used objects?
Thank you in advance for your answer.
Jan Kostrhun
ServerSession sess = (ServerSession) SessionManager.getManager().getSession (args[0]);
RuntimeServices rts = new RuntimeServices (sess);
List seznam = rts.getClassesInSession();
Collections.sort (seznam);
Iterator iter = seznam.iterator();
while (iter.hasNext()) {
String nazev = (String) iter.next();
try {
int pocet = rts.getNumberOfObjectsInIdentityMap (nazev).intValue();
out.println (nazev + " : " + pocet);
} catch (ClassNotFoundException cnfe) {
out.println ("Nenalezena trida: " + nazev);You can adjust the tombstone lifetime down to a minimum of 2 days. The garbage collection interval can be reduced from the default of 12 hours to a minimum of 1 hour. You an also force the garbage collection to run manually, as described here:
http://blogs.technet.com/b/ad/archive/2009/03/24/taking-out-the-trash.aspx
Remember that if you have the AD Recycle Bin turned on you will need also consider the msDS-deletedObjectLifetime. More info on this here:
http://blogs.technet.com/b/askds/archive/2009/08/27/the-ad-recycle-bin-understanding-implementing-best-practices-and-troubleshooting.aspx
The bottom line is that you cannot purge deleted objects from the DIT on demand. You have to wait for at least the tombstone lifetime to expire, and potentially the msDS-deletedObjectLifetime too.
Tony www.activedir.org Blog: www.open-a-socket.com
Good Summary. Just want to add:
The Garbage Collector process can be initiated manually by triggering the
operational attribute: “doGarbageCollection”: at any time http://msdn.microsoft.com/en-us/library/cc223317(v=prot.10)
Enfo Zipper
Christoffer Andersson – Principal Advisor
http://blogs.chrisse.se - Directory Services Blog -
How to sort a object vector by its integer item ?
hi everybody,
[there were few topics on this in the forum, but nothing could solve my problem yet. so, please instruct me]
I have to sort a vector which contains objects, where each object represents, different data types of values,
ex: {obj1, obj2, obj3, ....}
obj1---->{String name, int ID, String[] departments}
i have to sort this vector at three times, once by name, then by ID and then by departments.
Leaving name and department , first i want to sort the ID of each object and then re-arrange the order of objects in the array according to new order.
what i did was, copied the vector all objects' ID values to an integer array then i sorted it using selection sort. but now i want to re-arrange the vector, but i still can't. please guide.
here is the sort i did, and the
int[] ID = new int[mintomaxID.size()];
for(int i=0;i<mintomaxID.size();i++)
ObjectStore_initialData obj_id = (ObjectStore_initialData)mintomaxID.elementAt(i);
ID[i] = obj_id.getID();
System.out.println("Before sorting array");
for(int i=0;i<ID.length;i++)
System.out.println(ID);
System.out.println();
int i, j, m, mi;
for (i = 0; i < ID.length - 1; i++) {
/* find the minimum */
mi = i;
for (j = i+1; j < ID.length; j++) {
if (ID[j] < ID[mi]) {
mi = j;
m = ID[mi];
/* move elements to the right */
for (j = mi; j > i; j--) {
ID[j] = ID[j-1];
ID[i] = m;
System.out.println("After sorting array");
for(int y=0;y<ID.length;y++)
System.out.println(ID[y]);
//*****here is where i need to re-arrange the entire vector by ID.
I do understand this is some sort of database sort type of a question. but there's no database. it's simply i just want to sort the vector.
Thank you.hi camickr,
thank you for the detailed reply. but i still don't understand somethings. i tried to read the API and look for the collections.
i have ObjectStore_initialData class (similar to person class), so do i still have to do a comparable class out of this class ? please simplify that.
public class ObjectStore_initialData
String NAME;
int ID;
String[] DPART;
public ObjectStore_initialData(String name, int id, String[] departments)
NAME=name;
ID=id;
DPART = departments;
public String getName()//----
return NAME;
public String getID()//----
return ID;
public String getDpart()//----
return DPART;
/*next class is the interface to collect the values from the user and put all of them at once in a vector*/
//this class is to sort the vector by ID
public class sorter
public sorter()
public static void sortbyID(Vector mintomaxID)
int[] ID = new int[mintomaxID.size()];
for(int i=0;i<mintomaxID.size();i++)
ObjectStore_initialData obj_id = (ObjectStore_initialData)mintomaxID.elementAt(i);
ID[i] = obj_id.getID();
System.out.println("Before sorting array");
for(int i=0;i<ID.length;i++)
System.out.println(ID);
System.out.println();
int i, j, m, mi;
for (i = 0; i >< ID.length - 1; i++) {
/* find the minimum */
mi = i;
for (j = i+1; j < ID.length; j++) {
if (ID[j] < ID[mi]) {
mi = j;
m = ID[mi];
/* move elements to the right */
for (j = mi; j > i; j--) {
ID[j] = ID[j-1];
ID[i] = m;
System.out.println("After sorting array");
for(int y=0;y<ID.length;y++)
System.out.println(ID[y]);
//*****here is where i need to re-arrange the entire vector by ID.
/*new comparable class */
public class ObjectStore_initialData implements Comparable
String NAME;
int ID;
String[] DPART;
public ObjectStore_initialData(String name, int id, String[] departments)
NAME=name;
ID=id;
DPART = departments;
public String getName()//----
return NAME;
public String getID()//----
return ID;
public String getDpart()//----
return DPART;
static class IDComparator implements Comparator
public int compare(Object o1, Object o2)
ObjectStore_initialData p1 = (ObjectStore_initialData )o1;
ObjectStore_initialData p2 = (ObjectStore_initialData )o2;
return p1.getID() - p2.getID();
/*how can i put the vector here to sort? */
public sorter()
public static void sortbyID(Vector mintomaxID)
int[] ID = new int[mintomaxID.size()];
for(int i=0;i<mintomaxID.size();i++)
ObjectStore_initialData obj_id = (ObjectStore_initialData)mintomaxID.elementAt(i);
ID[i] = obj_id.getID();
System.out.println("Before sorting array");
for(int i=0;i<ID.length;i++)
System.out.println(ID[i]);
System.out.println();
int i, j, m, mi;
for (i = 0; i >< ID.length - 1; i++) {
/* find the minimum */
mi = i;
for (j = i+1; j < ID.length; j++) {
if (ID[j] < ID[mi]) {
mi = j;
m = ID[mi];
/* move elements to the right */
for (j = mi; j > i; j--) {
ID[j] = ID[j-1];
ID[i] = m;
System.out.println("After sorting array");
for(int y=0;y<ID.length;y++)
System.out.println(ID[y]);
/* using collections to sort*/
Collections.sort(mintomaxID, new IDComparator());
and to check the new order i wanted to print the vector to command line.
still it doesn't do anything.
the url you mentioned is good as i see. but how can i implement that in my class ? please instruct and simplify. i know i just repeated the code, i didn't understand to do a comparable class in collections for this class. Please explain where i'm head to and where's my misleading point here.
Thank you.
Message was edited by:
ArchiEnger.711 -
Sort and Object array of Arrays
Hi,
I have an object array that contains a String[] and an int[].
Object[String[], int[]]
The values in the Strings array must be in the same position in the array as those in the int array i.e
String [0] is the string representation of int[0].
Its for a bar chart.
That is all working beautifully.
Now however I want to sort the int array in descending order by the value of the ints in the array and thus the order or the String array has to mirror this.
I am using a comparator to do this but it just wont work. I'm sure this is the way but how should it look?
Has anybody got any ideas?
Thanks in advance,
L.use the bubblesort:
for (int i = a.length; --i >= 0; ) {
for (int j = 0; j < i; j++) {
if (a[j][1] > a[j+1][1]) {
int temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
} -
As far as I could see, a similar problem has been reported for earlier versions of SQL Developer, but still seems to apply for some parts in 4.0.0.13.80 under Windows7 64bit with JDK 1.7.0_45 64bit ...
Currently not all objects in a generated DDL using "Quick DDL" or "Tools - Database Export" are sorted evenly ... tables and foreign key constraints seem to be sorted, but common constraints are not.
This is rather annoying when trying to compare the generated scripts of two databases. Or trying to detect changes over lifetime (SVN etc.).
Or is there an option for this I could not find/see so far?
example output from database export of SQLDev 4.0.0.13.80 on the same machine, within some minutes, no configuration change, for a local and a remote database ...
from local:
Questions:
why are there blank lines added for the local database
why aren't the grants in the same order
local database
remote database
GRANT DELETE, INSERT, SELECT, UPDATE ON "FOREIGNSCHEMA"."TABLE_FOR_GRANT" TO "ACCESS_ROLE_FOR_SCHEMA_3";
GRANT REFERENCES ON "FOREIGNSCHEMA"."TABLE_FOR_GRANT" TO "SCHEMA_3";
GRANT REFERENCES ON "FOREIGNSCHEMA"."TABLE_FOR_GRANT" TO "SCHEMA_4";
GRANT SELECT, REFERENCES ON "FOREIGNSCHEMA"."TABLE_FOR_GRANT" TO "SCHEMA_5";
GRANT SELECT, REFERENCES ON "FOREIGNSCHEMA"."TABLE_FOR_GRANT" TO "SCHEMA_6";
GRANT SELECT ON "FOREIGNSCHEMA"."TABLE_FOR_GRANT" TO "SCHEMA_7";
GRANT REFERENCES ON "FOREIGNSCHEMA"."TABLE_FOR_GRANT" TO "SCHEMA_3";
GRANT REFERENCES ON "FOREIGNSCHEMA"."TABLE_FOR_GRANT" TO "SCHEMA_4";
GRANT SELECT, REFERENCES ON "FOREIGNSCHEMA"."TABLE_FOR_GRANT" TO "SCHEMA_5";
GRANT DELETE, INSERT, SELECT, UPDATE ON "FOREIGNSCHEMA"."TABLE_FOR_GRANT" TO "ACCESS_ROLE_FOR_SCHEMA_3";
GRANT SELECT, REFERENCES ON "FOREIGNSCHEMA"."TABLE_FOR_GRANT" TO "SCHEMA_6";
remark: missing SCHEMA_7 is okay, because it is not yet on the remote database
Similar applies to non foreign key constraints, where the unsorted output is even worse ...
Message was edited by: stuecklDid you ever figure out why SQL Developer isn't exporting the NOT NULL attribute of columns?
I'm running into that on a 9i database, but not on 11g.
Skip -
Sort an object by different fields
Hello!
Sorry for the (maybe) bad englisch but I'm a German.
If I have an object fith different fields for example field1, field2, field3.
To write a method which sorts an array of this objects by a given field?
I mean something like this
sort(String field, object[] o) {
//sort by field
instead of this
sortbyfield1(object o){
//sort by "field1"
sortbyfield2(object[] o){
//sort by "field2"
hope you understood
thanks
StefanWhen faced with this problem I usually use a Comparator helper class. Depending on whether the Comparator can be re-used I'll create a separate class or if not an inner or anonymous inner class. For example:
import java.util.Comparator;
import java.util.Arrays;
import java.util.List;
import java.util.Collections;
public class Main {
// Compares Fields.f1 ascending
public Comparator c1 = new Comparator() {
public int compare(Object o1,
Object o2) {
return ((Main.Fields)o1).f1.compareTo(((Main.Fields)o2).f1);
public void sortem() {
// Create our array of objects
Object[] array = new Object[] {
new Fields(new Integer(1),3,"3"),
new Fields(new Integer(2),2,"1"),
new Fields(new Integer(3),1,"2")
// Sort on Field.f1 using reusable comparator
Arrays.sort(array,c1);
System.out.println(Arrays.asList(array));
// Sort on Field.f2 using inner class
Arrays.sort(array,new C2());
System.out.println(Arrays.asList(array));
// Sort on f3 using an anonymous inner class
Arrays.sort(array, new Comparator(){
public int compare(Object o1,
Object o2) {
return((Main.Fields)o1).f3.compareTo(((Main.Fields)o2).f3);
System.out.println(Arrays.asList(array));
public static void main(String[] args) {
Main m = new Main();
m.sortem();
// Class with many fields of different types
class Fields {
public Integer f1;
public int f2;
public String f3;
public Fields(Integer f1, int f2, String f3) {
this.f1 = f1;
this.f2 = f2;
this.f3 = f3;
public String toString() {
return ""+f1+" "+f2+" "+f3;
// Inner class comparator on Field.f2
class C2 implements Comparator {
public int compare(Object o1,
Object o2) {
int result = 0;
int i1 = ((Main.Fields)o1).f2;
int i2 = ((Main.Fields)o2).f2;
if (i1==i1) result = 0;
if(i1<i2) result = -1;
else if (i1>i2) result = 1;
return result; -
Writing a function to that sorts any object
I am trying to write a function that sorts any type of array of objects. For example, I want to call
NewArray = exampleclass.sort(ObjectOfAnyType).
The sort function has to return a new array. I have run into two errors, however.
Error #1
as3.java [21:1] cannot resolve symbol
symbol : variable Object
location: class as3
if (Object instanceof Comparable)
^
Error #2
as3.java [25:1] incompatible types
found : java.lang.Object
required: java.lang.Object[]
Object [] rtn = obj.clone();
*** Below is my source code ***
import java.*;
public class as3 {
/** Creates new as3 */
public static Object sort(Object [] obj)
if (Object instanceof Comparable)
if (Object instanceof Cloneable)
Object [] rtn = obj.clone();
for (int i = 0; i<obj.length-1; i++)
for (int j=i+1; j<obj.length; j++)
if (rtn.compareTo(rtn[j]) == 1)
Object [] tmp = rtn[i];
rtn[i] = obj[j];
rtn[j] = tmp;
else
throw new ObjectIsNotComparableException("Object not comparable");
Any help appreciated. Thanks!Changing from "Object" to the name "obj" fixed the
statement:
if (obj instanceof Cloneable) but not if (obj
instanceof Comparable).
I don't know what's causing this one yet... worry about that in a sec
I am also getting one new error now:
as3.java [28:1] cannot resolve symbol
symbol : method compareTo (java.lang.Object)
location: class java.lang.Object
if (rtn[ i].compareTo(rtn[j])
This one is because rtn[ i] (and rtn[j]) is an Object, which has no method compareTo. Try casting it to a Comparable...
I think I just worked out why it let you go with the cloneable, but not with the comparable. obj is an array, and sure an array is cloneable, but how could you compare an array? Sure you can compare the elements in the array... So either check if obj[0] instanceof Comparable, or drop the test all together.
Note: checking obj[0] will give you an exception if someone asks you to sort an array of 0 length (no elements)
Hope this helps,
Radish21 -
Sort view object rows with transient attributes
Hi ,
Is it possible to sort the results of a view object based on the populated transient attributes ?
Best regards
KK,
Have you had a look at section 27.5 of the ADF Developer's Guide for Forms/4GL Developers ("Performing In-Memory Sorting and Filtering of Row Sets") - I've not tried it with transient attributes, but it does describe how to do in-memory sorting, as opposed to the normal way of sorting which is to send an ORDER BY to the database.
Hope this helps,
John -
I have an object defined as
CREATE OR REPLACE
type VALID_NAP AS object(
ID NUMBER(10),
NT_ID NUMBER(10),
BEGIN_DATE DATE,
END_DATE DATE,
TABLE_SOURCE VARCHAR2(10));
I have a nested table of objects defined as
CREATE OR REPLACE
TYPE LIST_VALID_NAP
AS TABLE OF VALID_NAP;
After inserting records into this nested table, as below
ID NT_ID BEGIN_DATE END_DATE TABLE_SOURCE
6,000.00 23.00 6/1/08 6/30/08 NAT_AH
6,000.00 58.00 5/1/08 5/31/08 NAT_AH
6,000.00 58.00 4/1/08 NAT_AH
6,000.00 97.00 1/1/08 1/31/08 NAT_AH
6,000.00 12.00 2/1/08 3/31/08 NAT
6,000.00 12.00 12/1/07 12/31/07 NAT
6,000.00 91.00 11/1/07 11/30/07 NAT_AH
I need to sort the above records with dates in descending order. Have can I sort a collection of objects?Have can I sort a collection of
objects?
SQL> create or replace type t1 as object(id number,amt number);
2 /
Type created.
SQL> create type t2 as table of t1;
2 /
Type created.
SQL> create table t3(c1 number,c2 t2) nested table c2 store as c2_store;
Table created.
SQL> insert into t3 values(1,t2(t1(1,100),t1(2,200),t1(1.5,150)));
1 row created.
SQL> select *
2 from table(select c2 from t3);
ID AMT
1 100
2 200
1.5 150
SQL> select *
2 from table(select c2 from t3)
3 order by id;
ID AMT
1 100
1.5 150
2 200 -
Sort Nested Object - 2 properties
Hello,
I am trying to sort based on a few properties of an object. The only issue i am having is the properties are within a nested object.
For example.
I would like to stort the following object by StreetNumber and StreetName, but these properties are inside 'locations_attributes' array.
"commute": {
"minutes": 0,
"startTime": "Wed May 06 22:14:12 EDT 2009",
"locations_attributes": [
"StreetNumber": "12",
"StreetName": "Main"
"StreetType": "St"
"StreetNumber ": "17",
"StreetName": "Morning Side ",
"StreetType": "Dr"
"StreetNumber ": "26",
"StreetName": "Blake",
"StreetType": "St"
Can this be done ?
DrewI get a JSON result from a REST service and I have a custom component that I populate.
I am not usin a datagrid, but a extended version of the List component.
I am just trying to sort the returned result sorted by street number and street name.
I was using a compareFunction in a sort() method, but only found samples for sorting off of one field.. not 2.
Here is is a sample of what I was using for 1 field.
private function sortByAttribute(a:Object, b:Object):Object
var x:String = a.attributes[this._activePanel.SortField].toLowerCase();
var y:String = b.attributes[this._activePanel.SortField].toLowerCase();
return ((x < y) ? -1 : ((x > y) ? 1 : 0)); -
Userdefined Sorting the objects using comparator
Hi All,
I want to display the objects in a userdefined order. I have placed the code snippet below. Kindly help me on this to resolve this issue.
public class ApplicabilityObject1 implements Comparable{
private String str;
public ApplicabilityObject1(String str) {
this.str = str;
public boolean equals(Object obj) {
return getStr().equals(((ApplicabilityObject1)obj).getStr());
public String toString() {
return str;
public String getStr() {
return str;
public void setStr(String str) {
this.str = str;
public int compareTo(Object arg0) {
final int equal = 0;
final int before = -1;
final int after= 1;
int returnvalues = 0;
System.out.println(this);
if ("Mexico"==((ApplicabilityObject1)arg0).getStr())
returnvalues = -1;
else if (((ApplicabilityObject1)arg0).getStr()== "Canada")
returnvalues = 0;
else if (((ApplicabilityObject1)arg0).getStr()== "USA")
returnvalues = 1;
return returnvalues;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/*import org.apache.commons.beanutils.BeanComparator;
import org.apache.commons.collections.comparators.FixedOrderComparator;*/
public class SortOrder {
* @param args
public static void main(String[] args) {
// TODO Auto-generated method stub
APPComparator app1 = new APPComparator();
ApplicabilityObject1 obj1 = new ApplicabilityObject1("Mexico");
ApplicabilityObject1 obj2 = new ApplicabilityObject1("Canada");
ApplicabilityObject1 obj3 = new ApplicabilityObject1("USA");
ApplicabilityObject1 obj4 = new ApplicabilityObject1("Mexico");
ApplicabilityObject1 obj5 = new ApplicabilityObject1("USA");
ApplicabilityObject1 obj6 = new ApplicabilityObject1("USA");
ApplicabilityObject1 obj7 = new ApplicabilityObject1("Mexico");
ApplicabilityObject1 obj8 = new ApplicabilityObject1("Mexico");
ApplicabilityObject1 obj9 = new ApplicabilityObject1("Canada");
List list = new ArrayList();
list.add(obj1);
list.add(obj2);
list.add(obj3);
list.add(obj4);
list.add(obj5);
list.add(obj6);
list.add(obj7);
list.add(obj8);
list.add(obj9);
Collections.sort(list, app1);
System.err.println(list);
System.out.println(Integer.MAX_VALUE);
class APPComparator implements Comparator
ApplicabilityObject1 appO = new ApplicabilityObject1("USA");
@Override
public int compare(Object arg0, Object arg1) {
// TODO Auto-generated method stub
return ((ApplicabilityObject1)arg0).compareTo(arg1);
}I'm expecting the result in the Order of USA, CANADA, MEXICO.
But now the above code giving the result of [USA, USA, USA, Mexico, Canada, Mexico, Mexico, Mexico, Canada]
Kindly help me to resolve this issue.
Thanks in advance,
MaheswaranAn alternative way to reduce the size of your code.
//Un-Compiled
ApplicabilityObject1[] appObs = {
new ApplicabilityObject1("Mexico"),
new ApplicabilityObject1("Canada"),
new ApplicabilityObject1("USA"),
new ApplicabilityObject1("Mexico"),
new ApplicabilityObject1("USA"),
new ApplicabilityObject1("USA"),
new ApplicabilityObject1("Mexico"),
new ApplicabilityObject1("Mexico"),
new ApplicabilityObject1("Canada")};
List list = new ArrayList(Arrays.asList(appObs));Mel -
How to force OTT generating java objects?
I've read in an Oracle white paper that Oracle has an Object Type Translator (ott) utility that creates java objects from object type definitions in the database. In my installations of Oracle 8.1.7 and 9.2i my ott utility only supports output of C structures (though in ott.exe present such strings as "public void...", "throws SQLException..."). Does anyone know how to force ott.exe generating java objects?
OTT can generate C structures or C++ classes from object definitions. You should look at JPublisher for Java classes.
-
Possible to sort No object table's records?
Hi,
Is it possible to sort the records of No object table that is accessible by clicking Tools-User tables?
by default, it sorts on the basis of the 'code' column but, since it is of character type, the sorting is not numerically correct. it sorts like 1,10,11,12,....19, 2,20,...and so on.
thanks and regards,
Binita JoshiHi Binita,
i know this problem and its weird - you can't sort it.
thats why i generate codes always with 0 before - than it is sorted.
like
00001
00002
00011
that's how iam doing.
lg David
Maybe you are looking for
-
Hyperion Planning Web URL is taking Too long time to respond
Hi, When Users are accessing Hyperion Planning URL web link its taking too long time to respond.We restarted the services after these for 2 hours it works fine after that again same issue.Please advise.
-
My iMac desktop and McBook Air laptop run on Mavericks. The laptop also runs Windows 7 via VM Ware Fusion. Can I transfer this capability to my McBook Air, so I can run the same plus the Windows programs on my laptop?
-
Legally Unlocked 3G - how can I use when vacationing in USA?
I have a 3G iPhone, legally unlocked by Optus (standard in Australia). I'm going to be visiting the US for a vacation shortly, and want to use my phone for both US phone calls as well as data. Obviously I don't want/need some kind of permanent subscr
-
i wanna use corba Server ... what setting should i make in classpath and path to work with corba thanks in advance khaleel
-
Safari 5.1.2 suddenly stopped working
I used Safari yesterday and it was working. I tried it today at 2 locations that I use frequently for their wifi and it has stopped working. (home and at work) Other browsers are making the connection. The only difference between today and yesterday