Example usage for java.lang Float Float

List of usage examples for java.lang Float Float

Introduction

In this page you can find the example usage for java.lang Float Float.

Prototype

@Deprecated(since = "9")
public Float(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Float object that represents the floating-point value of type float represented by the string.

Usage

From source file:net.sf.juffrou.reflect.spring.BeanWrapperTests.java

@Test
public void testNumberObjects() {
    NumberTestBean tb = new NumberTestBean();
    BeanWrapper bw = new JuffrouSpringBeanWrapper(tb);

    try {/*  w  w  w.  j a  va  2  s . c om*/
        bw.setPropertyValue("short2", "2");
        bw.setPropertyValue("int2", "8");
        bw.setPropertyValue("long2", "6");
        bw.setPropertyValue("bigInteger", "3");
        bw.setPropertyValue("float2", "8.1");
        bw.setPropertyValue("double2", "6.1");
        bw.setPropertyValue("bigDecimal", "4.0");
    } catch (BeansException ex) {
        fail("Should not throw BeansException: " + ex.getMessage());
    }

    assertTrue("Correct short2 value", new Short("2").equals(bw.getPropertyValue("short2")));
    assertTrue("Correct short2 value", new Short("2").equals(tb.getShort2()));
    assertTrue("Correct int2 value", new Integer("8").equals(bw.getPropertyValue("int2")));
    assertTrue("Correct int2 value", new Integer("8").equals(tb.getInt2()));
    assertTrue("Correct long2 value", new Long("6").equals(bw.getPropertyValue("long2")));
    assertTrue("Correct long2 value", new Long("6").equals(tb.getLong2()));
    assertTrue("Correct bigInteger value", new BigInteger("3").equals(bw.getPropertyValue("bigInteger")));
    assertTrue("Correct bigInteger value", new BigInteger("3").equals(tb.getBigInteger()));
    assertTrue("Correct float2 value", new Float("8.1").equals(bw.getPropertyValue("float2")));
    assertTrue("Correct float2 value", new Float("8.1").equals(tb.getFloat2()));
    assertTrue("Correct double2 value", new Double("6.1").equals(bw.getPropertyValue("double2")));
    assertTrue("Correct double2 value", new Double("6.1").equals(tb.getDouble2()));
    assertTrue("Correct bigDecimal value", new BigDecimal("4.0").equals(bw.getPropertyValue("bigDecimal")));
    assertTrue("Correct bigDecimal value", new BigDecimal("4.0").equals(tb.getBigDecimal()));
}

From source file:edu.hawaii.soest.hioos.isus.ISUSFrame.java

public double getHumidity() {
    this.humidity.flip();
    return (new Float(this.humidity.getFloat())).doubleValue();
}

From source file:gov.nih.nci.ncicb.tcga.dcc.datareports.service.ProjectCaseDashboardServiceImpl.java

protected Float processRatio(final String ratio) {
    if (ratio == null) {
        return 0f;
    }//from   w  ww. j  a va2s . c o  m
    if ("N/A".equalsIgnoreCase(ratio)) {
        return -1f;
    } else if (!ratio.contains("/")) {
        return Float.parseFloat(ratio);
    } else {
        final String[] tab = ratio.split("/", -1);
        return new Float(tab[0]) / new Float(tab[1]);
    }
}

From source file:lucee.runtime.img.Image.java

public void sharpen(float gain) throws ExpressionException {
    ParameterBlock params = new ParameterBlock();
    params.addSource(image());/*  w w w . j a  va  2s  .  c  o  m*/
    params.add((Object) null);
    params.add(new Float(gain));
    image(JAI.create("unsharpmask", params).getAsBufferedImage());
}

From source file:view.ResultsPanel.java

public void showHistogram(List<ElementaryMode> modes) {

    //for the JTable
    DefaultTableModel tableModel = new DefaultTableModel();
    JTable tableResult = new JTable();
    tableResult.setModel(tableModel);/*from  w w w . j  av  a2 s  .  com*/

    tableModel.addColumn("Reaction");
    tableModel.addColumn("Presence in the modes");

    tableResult.setAutoCreateRowSorter(true);

    Map<Reaction, Double> stats = new HashMap<Reaction, Double>();

    DecimalFormat df = new DecimalFormat("0.00");

    for (ElementaryMode em : modes) {
        for (Reaction r : em.getContent().keySet()) {
            if (em.getContent().containsKey(r)) {
                if (!stats.containsKey(r)) {
                    stats.put(r, 1.0);
                } else {
                    Reaction key = r;
                    Double value = stats.get(r) + 1;
                    stats.remove(key);
                    stats.put(key, value);
                }
            }
        }
    }

    for (Reaction r : stats.keySet()) {
        tableModel
                .addRow(new Object[] { r, String.valueOf(df.format(stats.get(r) * 100 / modes.size())) + "%" });
    }

    JFrame statisticFrame = new JFrame();
    statisticFrame.add(new JScrollPane(tableResult), BorderLayout.CENTER);
    statisticFrame.setVisible(true);
    statisticFrame.setSize(400, 350);
    statisticFrame.setTitle("Representativeness of each reaction");
    statisticFrame.setLocation(500, 600);

    //histogram
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    Map<Integer, Integer> data = new TreeMap<Integer, Integer>();
    int maxSize = 0;
    for (ElementaryMode em : modes) {
        int modeLength = em.getContent().size();
        if (modeLength > maxSize) {
            maxSize = modeLength;
        }
        if (data.containsKey(modeLength)) {
            int value = data.get(modeLength) + 1;
            data.put(modeLength, value);
        } else {
            data.put(modeLength, 1);
        }
    }

    for (int i = 1; i < maxSize; i++) {
        if (!data.containsKey(i)) {
            data.put(i, 0);
        }
    }
    for (int key : data.keySet()) {
        dataset.addValue(Integer.valueOf((data.get(key))), "test", Integer.valueOf(key));
    }

    String plotTitle = "Number of reactions per elementary mode";
    String xaxis = "Reaction number";
    String yaxis = "Elementary mode number";
    PlotOrientation orientation = PlotOrientation.VERTICAL;
    boolean show = false;
    boolean toolTips = false;
    boolean urls = false;
    JFreeChart chart = ChartFactory.createBarChart3D(plotTitle, xaxis, yaxis, dataset, orientation, show,
            toolTips, urls);

    CategoryPlot plot = chart.getCategoryPlot();
    CategoryAxis axis = plot.getDomainAxis();

    plot.getDomainAxis(0).setLabelFont(plot.getDomainAxis().getLabelFont().deriveFont(new Float(11)));

    ChartFrame frame = new ChartFrame("Elementary modes", chart);
    frame.setVisible(true);
    frame.setSize(400, 350);
    frame.setLocation(500, 100);

}

From source file:edu.hawaii.soest.hioos.isus.ISUSFrame.java

public double getLampVoltage12() {
    this.lampVoltage12.flip();
    return (new Float(this.lampVoltage12.getFloat())).doubleValue();
}

From source file:com.google.code.facebook.graph.sna.applet.PluggableRendererDemo.java

/**
 * Generates a mixed-mode random graph, runs VoltageRanker on it, and
 * returns the resultant graph.//from ww w .  j a v  a  2s. c  o  m
 */
public Graph<Integer, Number> getGraph() {
    Factory<Graph<Integer, Number>> graphFactory = new Factory<Graph<Integer, Number>>() {
        public Graph<Integer, Number> create() {
            return new SparseMultigraph<Integer, Number>();
        }
    };
    Factory<Integer> vertexFactory = new Factory<Integer>() {
        int count;

        public Integer create() {
            return count++;
        }
    };
    Factory<Number> edgeFactory = new Factory<Number>() {
        int count;

        public Number create() {
            return count++;
        }
    };
    Graph<Integer, Number> g = MixedRandomGraphGenerator.<Integer, Number>generateMixedRandomGraph(graphFactory,
            vertexFactory, edgeFactory, edge_weight, 20, false, seedVertices);
    es = new NumberFormattingTransformer<Number>(MapTransformer.getInstance(edge_weight));

    // collect the seeds used to define the random graph

    if (seedVertices.size() < 2)
        System.out.println("need at least 2 seeds (one source, one sink)");

    // use these seeds as source and sink vertices, run VoltageRanker
    boolean source = true;
    Set<Integer> sources = new HashSet<Integer>();
    Set<Integer> sinks = new HashSet<Integer>();
    for (Integer v : seedVertices) {
        if (source)
            sources.add(v);
        else
            sinks.add(v);
        source = !source;
    }
    VoltageScorer<Integer, Number> voltage_scores = new VoltageScorer<Integer, Number>(g,
            MapTransformer.getInstance(edge_weight), sources, sinks);
    voltage_scores.evaluate();
    voltages = new VertexScoreTransformer<Integer, Double>(voltage_scores);
    vs = new NumberFormattingTransformer<Integer>(voltages);

    Collection<Integer> verts = g.getVertices();

    // assign a transparency value of 0.9 to all vertices
    for (Integer v : verts) {
        transparency.put(v, new Double(0.9));
    }

    // add a couple of self-loops (sanity check on rendering)
    Integer v = verts.iterator().next();
    Number e = new Float(Math.random());
    edge_weight.put(e, e);
    g.addEdge(e, v, v);
    e = new Float(Math.random());
    edge_weight.put(e, e);
    g.addEdge(e, v, v);
    return g;
}

From source file:com.floreantpos.jasperreport.swing.JRViewerPanel.java

protected void paintPage(Graphics2D grx) {
    if (pageError) {
        paintPageError(grx);//from   ww  w.ja  v  a  2  s.c o  m
        return;
    }

    try {
        if (exporter == null) {
            exporter = getGraphics2DExporter();
        } else {
            exporter.reset();
        }

        exporter.setParameter(JRExporterParameter.JASPER_PRINT, viewerContext.getJasperPrint());
        exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, grx.create());
        exporter.setParameter(JRExporterParameter.PAGE_INDEX, Integer.valueOf(viewerContext.getPageIndex()));
        exporter.setParameter(JRGraphics2DExporterParameter.ZOOM_RATIO, new Float(realZoom));
        exporter.setParameter(JRExporterParameter.OFFSET_X, Integer.valueOf(1)); //lblPage border
        exporter.setParameter(JRExporterParameter.OFFSET_Y, Integer.valueOf(1));
        //exporter.setParameter(JRExporterParameter.FILE_RESOLVER, viewerContext.getFileResolver());
        exporter.exportReport();
    } catch (Exception e) {
        if (log.isErrorEnabled()) {
            log.error("Page paint error.", e);
        }

        pageError = true;

        paintPageError(grx);
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JOptionPane.showMessageDialog(JRViewerPanel.this,
                        viewerContext.getBundleString("error.displaying"));
            }
        });
    }

}

From source file:corelyzer.data.CRPreferences.java

public boolean readUIConfig(final File aFile) {
    try {/*  www. j  a v  a2s  .com*/
        this.sessionHistory.clear();

        FileReader fr = new FileReader(aFile);
        BufferedReader br = new BufferedReader(fr);

        String line;
        while ((line = br.readLine()) != null) {
            String[] toks = line.split("=");

            // lockCoreSectionImage
            if (toks[0].trim().equalsIgnoreCase("lockCoreSectionImage")) {
                this.lockCoreSectionImage = toks[1].trim().equalsIgnoreCase("true");
            } else if (toks[0].trim().equalsIgnoreCase("usequaqua")) {
                this.useQuaqua = toks[1].trim().equalsIgnoreCase("true");
            } else if (toks[0].trim().equalsIgnoreCase("autocheckversion")) {
                this.autoCheckVersion = toks[1].trim().equalsIgnoreCase("true");
            } else if (toks[0].trim().equalsIgnoreCase("canvas_bgcolor_r")) {
                bgcolor[0] = Float.parseFloat(toks[1].trim());
            } else if (toks[0].trim().equalsIgnoreCase("canvas_bgcolor_g")) {
                bgcolor[1] = Float.parseFloat(toks[1].trim());
            } else if (toks[0].trim().equalsIgnoreCase("canvas_bgcolor_b")) {
                bgcolor[2] = Float.parseFloat(toks[1].trim());
            } else if (toks[0].trim().equalsIgnoreCase("autozoom")) {
                this.setAutoZoom(Boolean.parseBoolean(toks[1].trim()));
            } else if (toks[0].trim().equalsIgnoreCase("enableGrid")) {
                this.grid_show = toks[1].trim().equalsIgnoreCase("true");
                // now let's read values for grid configuration.
                line = br.readLine();
                this.grid_type = new Integer(line);
                line = br.readLine();
                this.grid_size = new Float(line);
                line = br.readLine();
                this.grid_thickness = new Integer(line);
                line = br.readLine();
                this.grid_r = new Float(line);
                line = br.readLine();
                this.grid_g = new Float(line);
                line = br.readLine();
                this.grid_b = new Float(line);
            } else if (toks[0].trim().toLowerCase().startsWith("sessionhst")) {
                String path = toks[1].trim();
                this.sessionHistory.add(path);
            } else {
                System.out.println("---> Ignore unknown UI config option");
            }
        }

        br.close();
        fr.close();

        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}

From source file:de.unikassel.jung.PluggableRendererDemo.java

/**
 * Generates a mixed-mode random graph, runs VoltageRanker on it, and returns the resultant graph.
 *//*from   w  w  w. jav a  2 s  .  co  m*/
public Graph<Integer, Number> getGraph() {
    Factory<Graph<Integer, Number>> graphFactory = new Factory<Graph<Integer, Number>>() {
        @Override
        public Graph<Integer, Number> create() {
            return new SparseMultigraph<Integer, Number>();
        }
    };
    Factory<Integer> vertexFactory = new Factory<Integer>() {
        int count;

        @Override
        public Integer create() {
            return count++;
        }
    };
    Factory<Number> edgeFactory = new Factory<Number>() {
        int count;

        @Override
        public Number create() {
            return count++;
        }
    };
    Graph<Integer, Number> g = MixedRandomGraphGenerator.<Integer, Number>generateMixedRandomGraph(graphFactory,
            vertexFactory, edgeFactory, edge_weight, 20, false, seedVertices);
    es = new NumberFormattingTransformer<Number>(MapTransformer.getInstance(edge_weight));

    // collect the seeds used to define the random graph

    if (seedVertices.size() < 2) {
        System.out.println("need at least 2 seeds (one source, one sink)");
    }

    // use these seeds as source and sink vertices, run VoltageRanker
    boolean source = true;
    Set<Integer> sources = new HashSet<Integer>();
    Set<Integer> sinks = new HashSet<Integer>();
    for (Integer v : seedVertices) {
        if (source) {
            sources.add(v);
        } else {
            sinks.add(v);
        }
        source = !source;
    }
    VoltageScorer<Integer, Number> voltage_scores = new VoltageScorer<Integer, Number>(g,
            MapTransformer.getInstance(edge_weight), sources, sinks);
    voltage_scores.evaluate();
    voltages = new VertexScoreTransformer<Integer, Double>(voltage_scores);
    vs = new NumberFormattingTransformer<Integer>(voltages);

    Collection<Integer> verts = g.getVertices();

    // assign a transparency value of 0.9 to all vertices
    for (Integer v : verts) {
        transparency.put(v, new Double(0.9));
    }

    // add a couple of self-loops (sanity check on rendering)
    Integer v = verts.iterator().next();
    Number e = new Float(Math.random());
    edge_weight.put(e, e);
    g.addEdge(e, v, v);
    e = new Float(Math.random());
    edge_weight.put(e, e);
    g.addEdge(e, v, v);
    return g;
}