List of usage examples for java.text Collator getInstance
public static synchronized Collator getInstance()
From source file:shuffle.fwk.gui.EffectChooser.java
/** * @param megaEffects//from w w w . j ava2 s . c o m */ private void refill() { removeAllItems(); if (defaultEntry.equals(DefaultEntry.NO_FILTER)) { addItem(getString(KEY_NO_FILTER)); } if (defaultEntry.equals(DefaultEntry.SPECIES)) { if (curSpecies != null) { List<String> effects = new ArrayList<String>(); for (Effect t : curSpecies.getEffects()) { if (t.canLevel() && (!t.isPersistent() || t.equals(Effect.NONE))) { effects.add(convertToBox(t.toString())); } } Collections.sort(effects, Collator.getInstance()); for (String item : effects) { addItem(item); } } } else { List<String> effects = new ArrayList<String>(); for (Effect t : Effect.values()) { if (t.canLevel() && (megaEffects == t.isPersistent() || t.equals(Effect.NONE))) { effects.add(convertToBox(t.toString())); } } Collections.sort(effects, Collator.getInstance()); for (String item : effects) { addItem(item); } } }
From source file:context.ui.control.tabular.TabularViewController.java
private void initialTableData() { data.loadTableData();/* ww w.ja v a 2 s . c o m*/ // double minWidth = tableView.getWidth() / data.getHeaders().size(); tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); int index = 0; for (String header : data.getHeaders()) { final int j = index; TableColumn tableColumn = new TableColumn(header); tableColumn.setComparator(new Comparator<String>() { @Override public int compare(String s1, String s2) { if (NumberUtils.isNumber(s1) && NumberUtils.isNumber(s2)) { return Double.compare(Double.parseDouble(s1), Double.parseDouble(s2)); } return Collator.getInstance().compare(s1, s2); } }); tableColumn.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<List<String>, String>, ObservableValue<String>>() { public ObservableValue<String> call(TableColumn.CellDataFeatures<List<String>, String> p) { final String val = p.getValue().get(j); if (isRoundDoubles() && NumberUtils.isNumber(val) && val.contains(".")) { DecimalFormat df = new DecimalFormat("#.##"); Double d = Double.parseDouble(val); return new SimpleStringProperty(df.format(d)); } else { return new SimpleStringProperty(val); } } }); index++; tableView.getColumns().add(tableColumn); // if (index < data.getHeaders().size() - 1) { // tableColumn.setMinWidth(minWidth); // } // System.out.println("width=" + tableColumn.getMinWidth()); } System.out.println("columns Count:" + tableView.getColumns().size()); // which will make your table view dynamic // ObservableList<ObservableList> csvData = FXCollections.observableArrayList(); // // for (List<StringProperty> dataList : data.getRows()) { // ObservableList<String> row = FXCollections.observableArrayList(); // for (StringProperty rowData : dataList) { // row.add(rowData.get()); // } // csvData.add(row); // add each row to cvsData // } System.out.println("Rows Count=" + data.getRows().size()); tableView.setItems(data.getRows()); // finally add data to tableview System.out.println("after Rows Count=" + tableView.getItems().size()); }
From source file:org.zephyrsoft.util.StringTools.java
/** * Compare two Strings with regards to the current default locale. If one of the Strings is {@code null}, it is * assumed "smaller" than the non-null String. * /*from w w w .j a v a 2 s . c o m*/ * @see String#compareTo(String) * @param one * first parameter to compare * @param two * second parameter to compare * @return the same scheme as in {@link String#compareTo(String)} */ public static int compareLocaleBasedWithNullFirst(String one, String two) { if (one == null && two != null) { return -1; } else if (one != null && two == null) { return 1; } else if (one == null && two == null) { return 0; } else if (one != null && two != null) { Collator collator = Collator.getInstance(); return collator.compare(one, two); } else { // to silence the Eclipse warning, will never be executed: throw new IllegalStateException(); } }
From source file:edu.cornell.mannlib.vitro.webapp.beans.VClassGroup.java
/** * Sorts VClassGroup objects by group rank, then alphanumeric. * @author bdc34 modified by jc55, bjl23 * @return a negative integer, zero, or a positive integer as the * first argument is less than, equal to, or greater than the * second. //from w w w .j a v a 2s . c om */ public int compareTo(VClassGroup o2) { Collator collator = Collator.getInstance(); if (o2 == null) { log.error("object NULL in DisplayComparator()"); return 0; } int diff = (this.getDisplayRank() - o2.getDisplayRank()); if (diff == 0) { //put null public name classgrups at end of list if (this.getPublicName() == null) { if (o2.getPublicName() == null) return 0; //or maybe collator.compare(this.getURI(),o2.getURI()) ??? else return 1; } else if (o2.getPublicName() == null) { return -1; } else { return collator.compare(this.getPublicName(), o2.getPublicName()); } } return diff; }
From source file:pl.mg6.android.maps.extensions.demo.DemoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.demo);/*from w w w. j a v a 2s. co m*/ FragmentManager fm = getSupportFragmentManager(); SupportMapFragment f = (SupportMapFragment) fm.findFragmentById(R.id.map); map = f.getExtendedMap(); addCircles(); map.setOnMapClickListener(new OnMapClickListener() { @Override public void onMapClick(LatLng position) { for (Circle circle : map.getCircles()) { if (circle.contains(position)) { Toast.makeText(DemoActivity.this, "Clicked " + circle.getData(), Toast.LENGTH_SHORT).show(); return; } } } }); map.setClustering( new ClusteringSettings().clusterOptionsProvider(new DemoClusterOptionsProvider(getResources())) .addMarkersDynamically(true)); map.setInfoWindowAdapter(new InfoWindowAdapter() { private TextView tv; { tv = new TextView(DemoActivity.this); tv.setTextColor(Color.BLACK); } private Collator collator = Collator.getInstance(); private Comparator<Marker> comparator = new Comparator<Marker>() { public int compare(Marker lhs, Marker rhs) { String leftTitle = lhs.getTitle(); String rightTitle = rhs.getTitle(); if (leftTitle == null && rightTitle == null) { return 0; } if (leftTitle == null) { return 1; } if (rightTitle == null) { return -1; } return collator.compare(leftTitle, rightTitle); } }; @Override public View getInfoWindow(Marker marker) { return null; } @Override public View getInfoContents(Marker marker) { if (marker.isCluster()) { List<Marker> markers = marker.getMarkers(); int i = 0; String text = ""; while (i < 3 && markers.size() > 0) { Marker m = Collections.min(markers, comparator); String title = m.getTitle(); if (title == null) { break; } text += title + "\n"; markers.remove(m); i++; } if (text.length() == 0) { text = "Markers with mutable data"; } else if (markers.size() > 0) { text += "and " + markers.size() + " more..."; } else { text = text.substring(0, text.length() - 1); } tv.setText(text); return tv; } else { Object data = marker.getData(); if (data instanceof MutableData) { MutableData mutableData = (MutableData) data; tv.setText("Value: " + mutableData.value); return tv; } } return null; } }); map.setOnInfoWindowClickListener(new OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { if (marker.isCluster()) { List<Marker> markers = marker.getMarkers(); Builder builder = LatLngBounds.builder(); for (Marker m : markers) { builder.include(m.getPosition()); } LatLngBounds bounds = builder.build(); map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, getResources().getDimensionPixelSize(R.dimen.padding))); } } }); MarkerGenerator.addMarkersInPoland(map); MarkerGenerator.addMarkersInWorld(map); BitmapDescriptor icon = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE); for (MutableData data : dataArray) { map.addMarker(new MarkerOptions().position(data.position).icon(icon).data(data)); } setUpClusteringViews(); }
From source file:com.safi.workshop.sqlexplorer.sqleditor.ExtendedCompletionProposal.java
public int compare(Object o1, Object o2) { ICompletionProposal i1 = (ICompletionProposal) o1; ICompletionProposal i2 = (ICompletionProposal) o2; String s1 = i1.getDisplayString(); String s2 = i2.getDisplayString(); return Collator.getInstance().compare(s1, s2); }
From source file:org.cruk.genologics.api.cache.RestCallTrackingAspect.java
void listCache() { Logger logger = LoggerFactory.getLogger(GenologicsAPICacheTest.class); if (logger.isDebugEnabled()) { String[] cacheNames = cacheManager.getCacheNames(); Arrays.sort(cacheNames, Collator.getInstance()); logger.debug("Cache dump"); for (String cacheName : cacheNames) { Ehcache cache = cacheManager.getEhcache(cacheName); List<?> keys = cache.getKeys(); logger.debug("Have " + keys.size() + " things in the " + cacheName + " cache."); for (Object key : keys) { logger.debug(cache.get(key).toString()); }// w w w. j av a2 s . c o m } } }
From source file:net.sourceforge.fenixedu.dataTransferObject.InfoStudentCurricularPlan.java
public List getInfoEnrolmentsSorted() { final List<InfoEnrolment> infoEnrolments = getInfoEnrolments(); ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(new BeanComparator("infoExecutionPeriod.infoExecutionYear.year")); comparatorChain.addComparator(new BeanComparator("infoExecutionPeriod.semester")); comparatorChain.addComparator(new BeanComparator("infoCurricularCourse.name", Collator.getInstance())); Collections.sort(infoEnrolments, comparatorChain); return infoEnrolments; }
From source file:com.hro.museapp.map.ClusteringMapActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.cluster_map); listType = getIntent().getIntExtra("type", TYPE_ALL); ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); FragmentManager fm = getSupportFragmentManager(); SupportMapFragment f = (SupportMapFragment) fm.findFragmentById(R.id.map); map = f.getExtendedMap();//w w w .jav a 2s.c om gps = new GPSTracker(ClusteringMapActivity.this); //gps = PlacesLoader.getGPS(); // mapView = (MapView) this.findViewById(R.id.map); float cameraZoom = 8; LatLng cameraLatLng = new LatLng(52.281602, 5.503235); if (savedInstanceState != null) { double savedLat = savedInstanceState.getDouble("lat"); double savedLng = savedInstanceState.getDouble("lng"); cameraLatLng = new LatLng(savedLat, savedLng); cameraZoom = savedInstanceState.getFloat("zoom", 12); } map.moveCamera(CameraUpdateFactory.newLatLngZoom(cameraLatLng, cameraZoom)); map.setClustering(new ClusteringSettings().iconDataProvider(new DemoIconProvider(getResources())) .addMarkersDynamically(true)); map.setMyLocationEnabled(true); map.setInfoWindowAdapter(new InfoWindowAdapter() { private TextView tv; { tv = new TextView(ClusteringMapActivity.this); tv.setTextColor(Color.BLACK); } private Collator collator = Collator.getInstance(); private Comparator<Marker> comparator = new Comparator<Marker>() { public int compare(Marker lhs, Marker rhs) { String leftTitle = lhs.getTitle(); String rightTitle = rhs.getTitle(); if (leftTitle == null && rightTitle == null) { return 0; } if (leftTitle == null) { return 1; } if (rightTitle == null) { return -1; } return collator.compare(leftTitle, rightTitle); } }; @Override public View getInfoWindow(Marker marker) { return null; } @Override public View getInfoContents(Marker marker) { if (marker.isCluster()) { List<Marker> markers = marker.getMarkers(); int i = 0; String text = ""; while (i < 3 && markers.size() > 0) { Marker m = Collections.min(markers, comparator); String title = m.getTitle(); if (title == null) { break; } text += title + "\n"; markers.remove(m); i++; } if (text.length() == 0) { text = "Markers with mutable data"; } else if (markers.size() > 0) { text += "and " + markers.size() + " more..."; } else { text = text.substring(0, text.length() - 1); } tv.setText(text); return tv; } else { String title = marker.getTitle(); tv.setText(title); return tv; } } }); map.setOnInfoWindowClickListener(new OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { if (marker.isCluster()) { List<Marker> markers = marker.getMarkers(); Builder builder = LatLngBounds.builder(); for (Marker m : markers) { builder.include(m.getPosition()); } LatLngBounds bounds = builder.build(); map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, getResources().getDimensionPixelSize(R.dimen.padding))); } else { // String title = marker.getTitle(); // String mid = MarkerGenerator.mapPlaceToId.get(title); String mid = (String) marker.getData(); Intent in = new Intent(getApplicationContext(), ShowPlaceActivity.class); // sending mid to next activity in.putExtra(MarkerGenerator.TAG_MID, mid); // starting new activity and expecting some response back startActivityForResult(in, 100); } } }); // MarkerGenerator.addMarkers(map); new AddMarkersInBackground().execute(); }
From source file:pcgen.gui2.facade.TempBonusFacadeImpl.java
@Override public int compareTo(TempBonusFacadeImpl o) { final Collator collator = Collator.getInstance(); // Check sort keys first String key1 = this.getOriginObj().get(StringKey.SORT_KEY); if (key1 == null) { key1 = this.getOriginObj().getDisplayName(); }//ww w .j a va 2 s . c o m String key2 = o.getOriginObj().get(StringKey.SORT_KEY); if (key2 == null) { key2 = o.getOriginObj().getDisplayName(); } if (!key1.equals(key2)) { return collator.compare(key1, key2); } return collator.compare(this.getOriginObj().getDisplayName(), o.getOriginObj().getDisplayName()); }