List of usage examples for java.lang Float Float
@Deprecated(since = "9") public Float(String s) throws NumberFormatException
From source file:edu.uci.ics.jung.io.CustomPajekNetReader.java
@SuppressWarnings("unchecked") private String readArcsOrEdges(String curLine, BufferedReader br, Graph<V, E> g, List<V> id, Factory<E> edge_factory) throws IOException { String nextLine = curLine;// w w w . jav a 2 s . c om // in case we're not there yet (i.e., format tag isn't arcs or edges) if (!c_pred.evaluate(curLine)) { nextLine = skip(br, c_pred); } boolean reading_arcs = false; boolean reading_edges = false; EdgeType directedness = null; if (a_pred.evaluate(nextLine)) { if (g instanceof UndirectedGraph) { throw new IllegalArgumentException( "Supplied undirected-only graph cannot be populated with directed edges"); } else { reading_arcs = true; directedness = EdgeType.DIRECTED; } } if (e_pred.evaluate(nextLine)) { if (g instanceof DirectedGraph) { throw new IllegalArgumentException( "Supplied directed-only graph cannot be populated with undirected edges"); } else { reading_edges = true; } directedness = EdgeType.UNDIRECTED; } if (!(reading_arcs || reading_edges)) { return nextLine; } boolean is_list = l_pred.evaluate(nextLine); while (br.ready()) { nextLine = br.readLine(); if (nextLine == null || t_pred.evaluate(nextLine)) { break; } if (curLine == "") // skip blank lines { continue; } StringTokenizer st = new StringTokenizer(nextLine.trim()); int vid1 = Integer.parseInt(st.nextToken()) - 1; V v1; if (id != null) { v1 = id.get(vid1); } else { v1 = (V) new Integer(vid1); } if (is_list) // one source, multiple destinations { do { createAddEdge(st, v1, directedness, g, id, edge_factory); } while (st.hasMoreTokens()); } else // one source, one destination, at most one weight { E e = createAddEdge(st, v1, directedness, g, id, edge_factory); // get the edge weight if we care if (edge_weights != null && st.hasMoreTokens()) { edge_weights.set(e, new Float(st.nextToken())); } } } return nextLine; }
From source file:org.jfree.eastwood.ChartEngine.java
/** * Creates and returns a new <code>JFreeChart</code> instance that * reflects the specified parameters (which should be equivalent to * a parameter map returned by HttpServletRequest.getParameterMap() for * a valid URI for the Google Chart API. * * @param params the parameters (<code>null</code> not permitted). * @param font the font to use to draw titles, labels and legends. * * @return A chart corresponding to the specification in the supplied * parameters.// w w w.java 2 s . co m */ public static JFreeChart buildChart(Map params, Font font) { if (params == null) { throw new IllegalArgumentException("Null 'params' argument."); } JFreeChart chart = null; // *** CHART TYPE ** String[] chartType = (String[]) params.get("cht"); int dataType = -1; // 0 = PieDataset; 1 = XYDataset; 2 = special // pie charts: 'p' and 'p3' if (chartType[0].equals("p")) { chart = createPieChart(); dataType = 0; } else if (chartType[0].equals("p3")) { chart = createPieChart3D(); dataType = 0; } // line chart: 'lc' else if (chartType[0].equals("lc")) { chart = createLineChart(); dataType = 1; } // sparkline: 'ls' else if (chartType[0].equals("ls")) { chart = createSparklineChart(); dataType = 1; } // xy chart: 'lxy' else if (chartType[0].equals("lxy")) { chart = createLineChart(); dataType = 3; } // bar charts: 'bhs', 'bhg', 'bhs' and 'bhg' else if (chartType[0].equals("bhs")) { chart = createStackedBarChart(PlotOrientation.HORIZONTAL); dataType = 2; } else if (chartType[0].equals("bhg")) { chart = createBarChart(PlotOrientation.HORIZONTAL); dataType = 2; } else if (chartType[0].equals("bvs")) { chart = createStackedBarChart(PlotOrientation.VERTICAL); dataType = 2; } else if (chartType[0].equals("bvg")) { chart = createBarChart(PlotOrientation.VERTICAL); dataType = 2; } else if (chartType[0].equals("bhs3")) { chart = createStackedBarChart3D(PlotOrientation.HORIZONTAL); dataType = 2; } else if (chartType[0].equals("bhg3")) { chart = createBarChart3D(PlotOrientation.HORIZONTAL); dataType = 2; } else if (chartType[0].equals("bvs3")) { chart = createStackedBarChart3D(PlotOrientation.VERTICAL); dataType = 2; } else if (chartType[0].equals("bvg3")) { chart = createBarChart3D(PlotOrientation.VERTICAL); dataType = 2; } // scatter chart: 's' else if (chartType[0].equals("s")) { chart = createScatterChart(); dataType = 4; } else if (chartType[0].equals("v")) { throw new RuntimeException("Venn diagrams not implemented."); // TODO: fix this. } else { throw new RuntimeException("Unknown chart type: " + chartType[0]); } chart.getPlot().setOutlineVisible(false); // *** CHART AXES *** List axes = new java.util.ArrayList(); String[] axisStr = (String[]) params.get("chxt"); if (axisStr != null) { if (chart.getPlot() instanceof XYPlot) { XYPlot plot = (XYPlot) chart.getPlot(); processAxisStr(plot, axisStr[0], axes); } else if (chart.getPlot() instanceof CategoryPlot) { CategoryPlot plot = (CategoryPlot) chart.getPlot(); if (plot.getOrientation() == PlotOrientation.VERTICAL) { processAxisStrV(plot, axisStr[0], axes); } else { processAxisStrH(plot, axisStr[0], axes); } } } // *** AXIS RANGES *** String[] axisRangeStr = (String[]) params.get("chxr"); if (axisRangeStr != null) { String[] ranges = breakString(axisRangeStr[0], '|'); for (int i = 0; i < ranges.length; i++) { int comma1 = ranges[i].indexOf(','); int comma2 = ranges[i].indexOf(',', comma1 + 1); int axisIndex = Integer.parseInt(ranges[i].substring(0, comma1)); float lowerBound = Float.parseFloat(ranges[i].substring(comma1 + 1, comma2)); float upperBound = Float.parseFloat(ranges[i].substring(comma2 + 1)); Axis axis = (Axis) axes.get(axisIndex); if (axis instanceof GValueAxis) { GValueAxis gaxis = (GValueAxis) axis; gaxis.setLabelAxisStart(lowerBound); gaxis.setLabelAxisEnd(upperBound); } } } // *** AXIS LABELS *** String[] axisLabelStr = (String[]) params.get("chxl"); if (axisLabelStr != null) { Pattern p = Pattern.compile("\\d+:\\|"); Matcher m = p.matcher(axisLabelStr[0]); if (m.find()) { int keyStart = m.start(); int labelStart = m.end(); while (m.find(labelStart)) { String keyStr = axisLabelStr[0].substring(keyStart, labelStart - 2); int axisIndex = Integer.parseInt(keyStr); keyStart = m.start(); String labelStr = axisLabelStr[0].substring(labelStart, keyStart - 1); String[] labels = breakString(labelStr, '|'); GLabelledAxis axis = (GLabelledAxis) axes.get(axisIndex); axis.setTickLabels(Arrays.asList(labels)); labelStart = m.end(); } // process the final item String keyStr = axisLabelStr[0].substring(keyStart, labelStart - 2); String labelStr = axisLabelStr[0].substring(labelStart); int axisIndex = Integer.parseInt(keyStr); if (labelStr.endsWith("|")) { labelStr = labelStr.substring(0, labelStr.length() - 1); } String[] labels = breakString(labelStr, '|'); GLabelledAxis axis = (GLabelledAxis) axes.get(axisIndex); axis.setTickLabels(Arrays.asList(labels)); } else { throw new RuntimeException("No matching pattern!"); } } // ** EXPLICIT AXIS LABEL POSITIONS String[] axisPositionStr = (String[]) params.get("chxp"); if (axisPositionStr != null) { String[] positions = breakString(axisPositionStr[0], '|'); for (int i = 0; i < positions.length; i++) { int c1 = positions[i].indexOf(','); int axisIndex = Integer.parseInt(positions[i].substring(0, c1)); String remainingStr = positions[i].substring(c1 + 1); String[] valueStr = breakString(remainingStr, ','); List tickValues = new java.util.ArrayList(valueStr.length); Axis axis = (Axis) axes.get(axisIndex); if (axis instanceof GValueAxis) { GValueAxis gaxis = (GValueAxis) axes.get(axisIndex); for (int j = 0; j < valueStr.length; j++) { float pos = Float.parseFloat(valueStr[j]); tickValues.add(new Float(pos)); } gaxis.setTickLabelPositions(tickValues); } // FIXME: what about a CategoryAxis? } } // *** CHART TITLE *** String[] titleStr = (String[]) params.get("chtt"); if (titleStr != null) { // process the title String[] s = breakString(titleStr[0], '|'); for (int i = 0; i < s.length; i++) { TextTitle t = new TextTitle(s[i].replace('+', ' ')); t.setPaint(Color.darkGray); // Google seems to use 14pt fonts for titles and 12pt fonts for // all other text. Make sure this relationship remains. t.setFont(font.deriveFont(font.getSize2D() * 14f / 12f)); chart.addSubtitle(t); } // and the font and colour String[] fontStr = (String[]) params.get("chts"); if (fontStr != null) { int c1 = fontStr[0].indexOf(','); String colorStr = null; String fontSizeStr = null; if (c1 != -1) { colorStr = fontStr[0].substring(0, c1); fontSizeStr = fontStr[0].substring(c1 + 1); } else { colorStr = fontStr[0]; } Color color = parseColor(colorStr); int size = 12; if (fontSizeStr != null) { size = Integer.parseInt(fontSizeStr); } for (int i = 0; i < chart.getSubtitleCount(); i++) { Title t = chart.getSubtitle(i); if (t instanceof TextTitle) { TextTitle tt = (TextTitle) t; tt.setPaint(color); tt.setFont(font.deriveFont((float) size)); } } } } // *** CHART DATA *** String[] dataStr = (String[]) params.get("chd"); String scalingStr = null; if (dataStr.length > 0 && dataStr[0].startsWith("t:")) { // Only look at chds when text encoding is used String[] chds = (String[]) params.get("chds"); if (chds != null && chds.length > 0) { scalingStr = chds[0]; } } // we'll also process an optional second dataset that is provided as // an Eastwood extension...this isn't part of the Google Chart API String[] d2Str = (String[]) params.get("ewd2"); // 'p' and 'p3' - create PieDataset if (dataType == 0) { PieDataset dataset = DataUtilities.parsePieDataset(dataStr[0], scalingStr); PiePlot plot = (PiePlot) chart.getPlot(); plot.setDataset(dataset); // ignore d2Str as there is currently no need for a second pie // dataset. } // 'lc' - create XYDataset else if (dataType == 1) { XYPlot plot = (XYPlot) chart.getPlot(); XYDataset dataset = DataUtilities.parseXYDataset(dataStr[0], scalingStr); plot.setDataset(dataset); if (d2Str != null) { // an Eastwood extension XYDataset d2 = DataUtilities.parseXYDataset(d2Str[0], scalingStr); plot.setDataset(1, d2); } } // 'bhs', 'bhg', 'bvs', 'bvg' else if (dataType == 2) { CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryDataset dataset = DataUtilities.parseCategoryDataset(dataStr[0], scalingStr); plot.setDataset(dataset); if (d2Str != null) { // an Eastwood extension CategoryDataset d2 = DataUtilities.parseCategoryDataset(d2Str[0], scalingStr); plot.setDataset(1, d2); } } // 'lxy' else if (dataType == 3) { XYPlot plot = (XYPlot) chart.getPlot(); XYDataset dataset = DataUtilities.parseXYDataset2(dataStr[0], scalingStr); plot.setDataset(dataset); if (d2Str != null) { // an Eastwood extension XYDataset d2 = DataUtilities.parseXYDataset2(d2Str[0], scalingStr); plot.setDataset(1, d2); } } else if (dataType == 4) { XYPlot plot = (XYPlot) chart.getPlot(); XYSeriesCollection dataset = DataUtilities.parseScatterDataset(dataStr[0], scalingStr); if (dataset.getSeriesCount() > 1) { dataset.removeSeries(1); } plot.setDataset(dataset); if (d2Str != null) { // an Eastwood extension XYDataset d2 = DataUtilities.parseXYDataset2(d2Str[0], scalingStr); plot.setDataset(1, d2); } } if (chart.getPlot() instanceof XYPlot) { XYPlot plot = (XYPlot) chart.getPlot(); plot.getDomainAxis().setLabelFont(font); plot.getDomainAxis().setTickLabelFont(font); plot.getRangeAxis().setLabelFont(font); plot.getRangeAxis().setTickLabelFont(font); } else if (chart.getPlot() instanceof CategoryPlot) { CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.getDomainAxis().setLabelFont(font); plot.getDomainAxis().setTickLabelFont(font); plot.getRangeAxis().setLabelFont(font); plot.getRangeAxis().setTickLabelFont(font); } // *** CHART COLOURS *** String[] colorStr = (String[]) params.get("chco"); if (colorStr != null) { Color[] colors = parseColors(colorStr[0]); if (dataType == 0) { PiePlot plot = (PiePlot) chart.getPlot(); applyColorsToPiePlot(plot, colors); } else { AbstractRenderer renderer = null; if (chart.getPlot() instanceof CategoryPlot) { CategoryPlot plot = (CategoryPlot) chart.getPlot(); renderer = (AbstractRenderer) plot.getRenderer(); renderer.setBasePaint(colors[0]); } else if (chart.getPlot() instanceof XYPlot) { XYPlot plot = (XYPlot) chart.getPlot(); renderer = (AbstractRenderer) plot.getRenderer(); renderer.setBasePaint(colors[colors.length - 1]); } for (int i = 0; i < colors.length; i++) { renderer.setSeriesPaint(i, colors[i]); } } } else { Plot plot = chart.getPlot(); if (plot instanceof PiePlot) { applyColorsToPiePlot((PiePlot) chart.getPlot(), new Color[] { new Color(255, 153, 0) }); } } // *** CHART LINE STYLES *** String[] lineStr = (String[]) params.get("chls"); if (lineStr != null && chart.getPlot() instanceof XYPlot) { Stroke[] strokes = parseLineStyles(lineStr[0]); XYPlot plot = (XYPlot) chart.getPlot(); XYItemRenderer renderer = plot.getRenderer(); for (int i = 0; i < strokes.length; i++) { renderer.setSeriesStroke(i, strokes[i]); } renderer.setBaseStroke(strokes[strokes.length - 1]); } // *** CHART GRID LINES if (dataType != 0) { String[] gridStr = (String[]) params.get("chg"); if (gridStr != null) { processGridLinesSpec(gridStr[0], chart); } } // *** CHART LABELS if (dataType == 0) { // pie chart String[] labelStr = (String[]) params.get("chl"); if (labelStr != null) { String[] s = breakString(labelStr[0], '|'); List labels = Arrays.asList(s); PiePlot plot = (PiePlot) chart.getPlot(); if (labels.size() > 0) { plot.setLabelGenerator(new GPieSectionLabelGenerator(labels)); plot.setLabelFont(font); plot.setLabelPaint(Color.darkGray); } } } String[] legendStr = (String[]) params.get("chdl"); if (legendStr != null) { // process the title String[] s = breakString(legendStr[0], '|'); List labels = Arrays.asList(s); if (labels.size() > 0) { Plot p = chart.getPlot(); if (p instanceof CategoryPlot) { CategoryPlot plot = (CategoryPlot) chart.getPlot(); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setLegendItemLabelGenerator(new GSeriesLabelGenerator(labels)); renderer.setBaseSeriesVisibleInLegend(false); for (int i = 0; i < labels.size(); i++) { renderer.setSeriesVisibleInLegend(i, Boolean.TRUE); } } else if (p instanceof XYPlot) { XYPlot plot = (XYPlot) chart.getPlot(); XYItemRenderer renderer = plot.getRenderer(); renderer.setLegendItemLabelGenerator(new GSeriesLabelGenerator(labels)); renderer.setBaseSeriesVisibleInLegend(false); for (int i = 0; i < labels.size(); i++) { renderer.setSeriesVisibleInLegend(i, Boolean.TRUE); } } else if (p instanceof PiePlot) { PiePlot plot = (PiePlot) chart.getPlot(); plot.setLegendLabelGenerator(new GPieSectionLabelGenerator(labels)); } LegendTitle legend = new LegendTitle(chart.getPlot()); RectangleEdge pos = RectangleEdge.RIGHT; String[] chdlp = (String[]) params.get("chdlp"); if (chdlp != null) { if ("b".equals(chdlp[0])) { pos = RectangleEdge.BOTTOM; } else if ("t".equals(chdlp[0])) { pos = RectangleEdge.TOP; } else if ("l".equals(chdlp[0])) { pos = RectangleEdge.LEFT; } } legend.setPosition(pos); legend.setItemFont(font); legend.setItemPaint(Color.darkGray); chart.addSubtitle(legend); } } // *** CHART MARKERS *** String[] markerStr = (String[]) params.get("chm"); if (markerStr != null) { String[] markers = breakString(markerStr[0], '|'); for (int i = 0; i < markers.length; i++) { addMarker(markers[i], chart); } } // *** CHART FILL ***/ String[] fillStr = (String[]) params.get("chf"); if (fillStr != null) { // process the 1 or 2 fill specs int i = fillStr[0].indexOf('|'); if (i == -1) { processFillSpec(fillStr[0], chart); } else { String fs1 = fillStr[0].substring(0, i); String fs2 = fillStr[0].substring(i + 1); processFillSpec(fs1, chart); processFillSpec(fs2, chart); } } // process the 'ewtr' tag, if present processEWTR(params, chart); return chart; }
From source file:edu.uci.ics.jung.io.PajekNetReader.java
@SuppressWarnings("unchecked") private String readArcsOrEdges(String curLine, BufferedReader br, Graph<V, E> g, List<V> id, Factory<E> edge_factory) throws IOException { String nextLine = curLine;/*from w w w.j av a2 s . c o m*/ // in case we're not there yet (i.e., format tag isn't arcs or edges) if (!c_pred.evaluate(curLine)) nextLine = skip(br, c_pred); boolean reading_arcs = false; boolean reading_edges = false; EdgeType directedness = null; if (a_pred.evaluate(nextLine)) { if (g instanceof UndirectedGraph) { throw new IllegalArgumentException( "Supplied undirected-only graph cannot be populated with directed edges"); } else { reading_arcs = true; directedness = EdgeType.DIRECTED; } } if (e_pred.evaluate(nextLine)) { if (g instanceof DirectedGraph) throw new IllegalArgumentException( "Supplied directed-only graph cannot be populated with undirected edges"); else reading_edges = true; directedness = EdgeType.UNDIRECTED; } if (!(reading_arcs || reading_edges)) return nextLine; boolean is_list = l_pred.evaluate(nextLine); while (br.ready()) { nextLine = br.readLine(); if (nextLine == null || t_pred.evaluate(nextLine)) break; if (curLine == "") // skip blank lines continue; StringTokenizer st = new StringTokenizer(nextLine.trim()); int vid1 = Integer.parseInt(st.nextToken()) - 1; V v1; if (id != null) v1 = id.get(vid1); else v1 = (V) new Integer(vid1); if (is_list) // one source, multiple destinations { do { createAddEdge(st, v1, directedness, g, id, edge_factory); } while (st.hasMoreTokens()); } else // one source, one destination, at most one weight { E e = createAddEdge(st, v1, directedness, g, id, edge_factory); // get the edge weight if we care if (edge_weights != null && st.hasMoreTokens()) edge_weights.set(e, new Float(st.nextToken())); } } return nextLine; }
From source file:com.appglu.impl.CrudTemplateTest.java
@Test public void writeAllDataTypes() throws ParseException { mockServer.expect(requestTo("http://localhost/appglu/v1/tables/data_types")) .andExpect(method(HttpMethod.POST)).andExpect(header("Content-Type", jsonMediaType.toString())) .andExpect(content().string(compactedJson("data/crud_write_all_data_types"))) .andRespond(withStatus(HttpStatus.CREATED).body(compactedJson("data/crud_create_response")) .headers(responseHeaders)); Row row = new Row(); String string = new String("a very long string for test"); row.put("boolean", true); row.put("short", new Short((short) 1)); row.put("byte", new Byte((byte) 2)); row.put("byteArray", string.getBytes()); row.put("float", new Float(1.5f)); row.put("double", new Double(7.5d)); row.put("integer", new Integer(10)); row.put("long", new Long(21474836475L)); row.put("bigInteger", new BigInteger("9223372036854775807123")); row.put("string", string); Date datetime = DateUtils.parseDate("2010-01-15T12:10:00+0000"); row.putDatetime("datetime", datetime); Date time = DateUtils.parseDate("1970-01-01T12:10:00+0000"); row.putTime("time", time); Date date = DateUtils.parseDate("2010-01-15T00:00:00+0000"); row.putDate("date", date); Object id = crudOperations.create("data_types", row); Assert.assertEquals(8, id);/*from w w w . j a v a 2 s .c om*/ mockServer.verify(); }
From source file:edu.ku.brc.specify.config.Scriptlet.java
/** * Formats a String as a float with "N","S","E", "W". * @param floatVal the float value//from ww w .ja va 2 s.c om * @param isLat whether it is a lat or lon * @return Formats a String as a float with "N","S","E", "W" */ public String getDirChar(final String strVal, final boolean isLat) { if (strVal == null) { return ""; } return getDirChar(new Float(Float.parseFloat(strVal)), isLat); }
From source file:gedi.util.FileUtils.java
public static <T> T read(BinaryReader in) throws IOException, ClassNotFoundException { String clsName = in.getString(); if (clsName.length() == 1) { switch (clsName) { case "A": return (T) in.getString(); case "B": return (T) new Byte(in.get()); case "S": return (T) new Short(in.getShort()); case "I": return (T) new Integer(in.getInt()); case "L": return (T) new Long(in.getLong()); case "F": return (T) new Float(in.getFloat()); case "D": return (T) new Double(in.getDouble()); }/*from www . j a v a 2s .co m*/ } Class<T> cls = (Class<T>) Class.forName(clsName); if (BinarySerializable.class.isAssignableFrom(cls)) { try { T re = cls.newInstance(); ((BinarySerializable) re).deserialize(in); return re; } catch (InstantiationException | IllegalAccessException e) { throw new IOException("Could not instantiate " + cls.getName(), e); } } else throw new RuntimeException("Only BinarySerializables can be deserialized right now!"); }
From source file:corelyzer.data.CRPreferences.java
public boolean readDisplayConfig(final File aFile) { // read the file and loadin setups try {// w ww . j a va2s .co m FileReader fr = new FileReader(aFile); BufferedReader br = new BufferedReader(fr); String line; line = br.readLine(); this.screenWidth = new Integer(line); line = br.readLine(); this.screenHeight = new Integer(line); line = br.readLine(); this.numberOfRows = new Integer(line); line = br.readLine(); this.numberOfColumns = new Integer(line); line = br.readLine(); this.dpix = new Float(line); line = br.readLine(); this.dpiy = new Float(line); line = br.readLine(); this.borderUp = new Float(line); line = br.readLine(); this.borderDown = new Float(line); line = br.readLine(); this.borderLeft = new Float(line); line = br.readLine(); this.borderRight = new Float(line); try { line = br.readLine(); this.column_offset = new Integer(line); line = br.readLine(); this.row_offset = new Integer(line); } catch (NumberFormatException e) { System.out.println("[CRPreferences] Ignore rest display.conf"); } br.close(); fr.close(); return true; } catch (Exception e) { System.out.println("ERROR Reading previous display settings"); e.printStackTrace(); return false; } }
From source file:com.linkedin.pinot.segments.v1.creator.DictionariesTest.java
@Test public void testDoubleColumnPreIndexStatsCollector() throws Exception { FieldSpec spec = new DimensionFieldSpec("column1", DataType.DOUBLE, true); AbstractColumnStatisticsCollector statsCollector = new DoubleColumnPreIndexStatsCollector(spec); statsCollector.collect(new Integer(1)); Assert.assertTrue(statsCollector.isSorted()); statsCollector.collect(new Float(2)); Assert.assertTrue(statsCollector.isSorted()); statsCollector.collect(new Long(3)); Assert.assertTrue(statsCollector.isSorted()); statsCollector.collect(new Double(4)); Assert.assertTrue(statsCollector.isSorted()); statsCollector.collect(new Integer(4)); Assert.assertTrue(statsCollector.isSorted()); statsCollector.collect(new Float(2)); Assert.assertFalse(statsCollector.isSorted()); statsCollector.collect(new Double(40)); Assert.assertFalse(statsCollector.isSorted()); statsCollector.collect(new Double(20)); Assert.assertFalse(statsCollector.isSorted()); statsCollector.seal();/*w ww. java 2s . c o m*/ Assert.assertEquals(statsCollector.getCardinality(), 6); Assert.assertEquals(((Number) statsCollector.getMinValue()).intValue(), 1); Assert.assertEquals(((Number) statsCollector.getMaxValue()).intValue(), 40); Assert.assertFalse(statsCollector.isSorted()); }
From source file:com.eurelis.opencms.workflows.ui.toolobject.WorkflowMenuItemLoader.java
/** * Get the list of all collected Menu items, sorted by the index position * // w w w . ja v a2s. com * @return the list of WorkflowMenuItem that must be displayed */ public List<WorkflowMenuItem> getMenuItems() { // Create the map that will store the WorkflowMenuItem by position TreeMap<Float, WorkflowMenuItem> sortedMapByPosition = new TreeMap<Float, WorkflowMenuItem>(); LOGGER.debug(ErrorFormatter.formatMap(_mapOfItems, "WF | _mapOfItems")); /* * add the map elements into the sorted map if none object with the same * position exists */ Iterator<WorkflowMenuItem> mapOfItemIterator = this._mapOfItems.values().iterator(); while (mapOfItemIterator.hasNext()) { WorkflowMenuItem workflowMenuItem = mapOfItemIterator.next(); Float position = new Float(workflowMenuItem.get_position()); // check if an object with such position exist if (!sortedMapByPosition.containsKey(position)) { sortedMapByPosition.put(position, workflowMenuItem); } else { // if two object with same position exists, then the second one // is not added into the map of object to display and a warning // message is return to the user. LOGGER.warn("WF | Two objects with position " + position + " exists. The menu " + workflowMenuItem.get_name() + " will not be displayed"); } } // return the list of menu item sorted by position return new ArrayList<WorkflowMenuItem>(sortedMapByPosition.values()); }
From source file:org.gumtree.vis.awt.time.TimePlotChartEditor.java
private void initialise(IDataset dataset, int seriesIndex) { if (dataset != null && seriesIndex >= 0) { XYItemRenderer renderer = chart.getXYPlot().getRendererForDataset(dataset); if (renderer instanceof XYLineAndShapeRenderer) { //Update show marker field // showMarker.setSelected(((XYLineAndShapeRenderer) renderer). // getBaseShapesVisible()); //Update series selection combo field seriesCombo.setSelectedItem(dataset.getSeriesKey(seriesIndex)); //Update curve stroke fields Boolean isLineVisible = ((XYLineAndShapeRenderer) renderer).getSeriesLinesVisible(seriesIndex); if (isLineVisible == null) { isLineVisible = ((XYLineAndShapeRenderer) renderer).getBaseLinesVisible(); }/*from w ww . j a v a 2s .c om*/ if (isLineVisible) { Stroke stroke = renderer.getSeriesStroke(seriesIndex); curveStrokeSample.setStroke(stroke); if (stroke instanceof BasicStroke) { strokeCombo.setSelectedItem(new Float(((BasicStroke) stroke).getLineWidth())); } } else { curveStrokeSample.setStroke(null); strokeCombo.setSelectedIndex(0); } //Update curve colour fields Paint paint = renderer.getSeriesPaint(seriesIndex); curveColorPaint.setPaint(paint); //Update marker visible field Boolean isMarkerVisible = ((XYLineAndShapeRenderer) renderer) .getSeriesShapesVisible(currentSeriesIndex); if (isMarkerVisible == null) { isMarkerVisible = ((XYLineAndShapeRenderer) renderer).getBaseShapesVisible(); if (isMarkerVisible == null) { isMarkerVisible = false; } } showMarker.setSelected(isMarkerVisible); //Update marker fill field Boolean seriesShapeFilled = ((XYLineAndShapeRenderer) renderer).getSeriesShapesFilled(seriesIndex); if (seriesShapeFilled == null) { seriesShapeFilled = ((XYLineAndShapeRenderer) renderer).getBaseShapesFilled(); } if (seriesShapeFilled != null) { markerFilled.setSelected(seriesShapeFilled); } //Update marker shape fields Boolean isShapeVisible = ((XYLineAndShapeRenderer) renderer) .getSeriesShapesVisible(currentSeriesIndex); if (isShapeVisible == null) { isShapeVisible = true; } if (isShapeVisible) { Shape serieseShape = renderer.getSeriesShape(seriesIndex); currentShape = MarkerShape.findMarkerShape(serieseShape); shapeLabel.setIcon(MarkerShape.createIcon(serieseShape, paint, markerFilled.isSelected())); shapeLabel.setText(null); } else { currentShape = MarkerShape.NONE; shapeLabel.setIcon(null); shapeLabel.setText("None"); } updateComborender(paint, markerFilled.isSelected()); //Update curve visibility field Boolean isCurveVisible = ((XYLineAndShapeRenderer) renderer).isSeriesVisible(seriesIndex); if (isCurveVisible == null) { isCurveVisible = ((XYLineAndShapeRenderer) renderer).getBaseSeriesVisible(); } curveVisable.setSelected(isCurveVisible); ValueAxis timeAxis = chart.getXYPlot().getDomainAxis(); double fixedTime = timeAxis.getFixedAutoRange(); if (fixedTime <= 0) { showAllHistory.setSelected(true); } else { showPartHistory.setSelected(true); timeField.setText(String.valueOf(fixedTime / 1000)); } } } }