Example usage for java.util ArrayList size

List of usage examples for java.util ArrayList size

Introduction

In this page you can find the example usage for java.util ArrayList size.

Prototype

int size

To view the source code for java.util ArrayList size.

Click Source Link

Document

The size of the ArrayList (the number of elements it contains).

Usage

From source file:grafici.PrenotazioniBarChart.java

/**
 * Returns a sample dataset.//from   ww w.  j  a va  2  s.  co m
 * 
 * @return The dataset.
 */
private static CategoryDataset createDataset(int tipo) {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    //fatture per tipologlia visita per mese
    if (tipo == 0) {
        // Tipologia visita
        ArrayList<Tipologiavisita> tipiVisite = VisitaDAO.getTipologVisita();
        String[] righe = new String[tipiVisite.size()];
        int i = 0;
        for (Tipologiavisita item : tipiVisite) {
            righe[i] = item.getTipologia();
            i++;
        }

        // prenotazioni

        for (Tipologiavisita tipologia : tipiVisite) {
            dataset.addValue(
                    VisitaDAO.getPrenotazioniNumberPerTipologiaNelMese(tipologia.getIdTipologiaVisita(), 1),
                    "Gennaio", tipologia.getTipologia());
            dataset.addValue(
                    VisitaDAO.getPrenotazioniNumberPerTipologiaNelMese(tipologia.getIdTipologiaVisita(), 2),
                    "Febbraio", tipologia.getTipologia());
            dataset.addValue(
                    VisitaDAO.getPrenotazioniNumberPerTipologiaNelMese(tipologia.getIdTipologiaVisita(), 3),
                    "Marzo", tipologia.getTipologia());
            dataset.addValue(
                    VisitaDAO.getPrenotazioniNumberPerTipologiaNelMese(tipologia.getIdTipologiaVisita(), 4),
                    "Aprile", tipologia.getTipologia());
            dataset.addValue(
                    VisitaDAO.getPrenotazioniNumberPerTipologiaNelMese(tipologia.getIdTipologiaVisita(), 5),
                    "Maggio", tipologia.getTipologia());
            dataset.addValue(
                    VisitaDAO.getPrenotazioniNumberPerTipologiaNelMese(tipologia.getIdTipologiaVisita(), 6),
                    "Giugno", tipologia.getTipologia());
            dataset.addValue(
                    VisitaDAO.getPrenotazioniNumberPerTipologiaNelMese(tipologia.getIdTipologiaVisita(), 7),
                    "Luglio", tipologia.getTipologia());
            dataset.addValue(
                    VisitaDAO.getPrenotazioniNumberPerTipologiaNelMese(tipologia.getIdTipologiaVisita(), 8),
                    "Agosto", tipologia.getTipologia());
            dataset.addValue(
                    VisitaDAO.getPrenotazioniNumberPerTipologiaNelMese(tipologia.getIdTipologiaVisita(), 9),
                    "Settembre", tipologia.getTipologia());
            dataset.addValue(
                    VisitaDAO.getPrenotazioniNumberPerTipologiaNelMese(tipologia.getIdTipologiaVisita(), 10),
                    "Ottobre", tipologia.getTipologia());
            dataset.addValue(
                    VisitaDAO.getPrenotazioniNumberPerTipologiaNelMese(tipologia.getIdTipologiaVisita(), 11),
                    "Novembre", tipologia.getTipologia());
            dataset.addValue(
                    VisitaDAO.getPrenotazioniNumberPerTipologiaNelMese(tipologia.getIdTipologiaVisita(), 12),
                    "Dicembre", tipologia.getTipologia());

        }
    }
    return dataset;

}

From source file:info.unyttig.helladroid.newzbin.NewzBinController.java

/**
 * Fetches a report from Newzbin based on a given id.
 * However if the report is already cached, its just fetched from the hashmap.
 * @param id//from w  w w. j av  a 2s  .  com
 */
public static NewzBinReport getReportInfo(int id) {
    if (detailedReports.containsKey(id))
        return detailedReports.get(id);

    String url = NBAPIURL + "reportinfo/";
    HashMap<String, String> searchOptions = new HashMap<String, String>();
    searchOptions.put("id", "" + id);
    try {
        HttpResponse response = doPost(url, searchOptions);
        checkReturnCode(response.getStatusLine().getStatusCode(), false);
        InputStream is = response.getEntity().getContent();

        SAXParserFactory spf = SAXParserFactory.newInstance();
        SAXParser sp = spf.newSAXParser();
        XMLReader xr = sp.getXMLReader();
        NewzBinDRHandler handler = new NewzBinDRHandler();
        if (reports.containsKey(id))
            handler.nbdr = reports.get(id);
        xr.setContentHandler(handler);
        xr.parse(new InputSource(is));
        detailedReports.put(id, handler.getParsedData());
        // Temp
        ArrayList<NewzBinReportComment> comments = handler.nbdr.getComments();
        Log.i(LOG_NAME, "Comments size: " + comments.size());
        Iterator<NewzBinReportComment> sd = comments.iterator();
        while (sd.hasNext()) {
            NewzBinReportComment nrc = sd.next();
            Log.i(LOG_NAME, nrc.toString());
        }
        return handler.getParsedData();
    } catch (ClientProtocolException e) {
        Log.e(LOG_NAME, "ClientProtocol thrown: ", e);
    } catch (IOException e) {
        Log.e(LOG_NAME, "IOException thrown: ", e);
    } catch (NewzBinPostReturnCodeException e) {
        Log.e(LOG_NAME, "POST ReturnCode error: " + e.toString());
    } catch (ParserConfigurationException e) {
        Log.e(LOG_NAME, "ParserError thrown: ", e);
    } catch (SAXException e) {
        Log.e(LOG_NAME, "SAXError thrown: ", e);
    }
    return null;
}

From source file:jeplus.INSELWinTools.java

/**
 * Test if any of the given files in jEPlus format is available in the given  
 * directory as an indicator of successful run.
 * @return boolean True if the file is present at the specified location
 *///  www.ja  v  a 2s.  co  m
public static boolean isAnyFileAvailable(String FileNames, String workdir) {
    ArrayList<String> filename = getPrintersFunc(FileNames);
    for (int i = 0; i < filename.size(); i++) {
        if (new File(workdir + filename.get(i)).exists()) {
            return true;
        }
    }
    return false;
}

From source file:mitm.application.djigzo.DjigzoConfigurator.java

@SuppressWarnings("unchecked")
private static void initializeRegistry() {
    /*//  ww w.  j  a  va  2s.  co  m
     * Load additional spring config files and sort them.
     */
    Collection<File> unsortedConfigFiles = FileUtils.listFiles(new File(additionalSpringConfigDir),
            new String[] { "xml" }, true /* recursive */);

    ArrayList<File> sortedConfigFiles = new ArrayList<File>(unsortedConfigFiles);

    Collections.sort(sortedConfigFiles, DefaultFileComparator.DEFAULT_COMPARATOR);

    String[] configFiles = new String[sortedConfigFiles.size() + 1];

    /*
     * The main config should be loaded first
     */
    configFiles[0] = springConfig;

    for (int i = 1; i < configFiles.length; i++) {
        configFiles[i] = sortedConfigFiles.get(i - 1).getPath();
    }

    logger.info("spring config files: {}", StringUtils.join(configFiles, ", "));

    DjigzoServiceRegistry.initialize(configFiles);
}

From source file:com.gst.integrationtests.common.CenterHelper.java

public static int[] associateGroups(final int id, final int[] groupMembers,
        final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
    final String ASSOCIATE_GROUP_CENTER_URL = CENTERS_URL + "/" + id + "?command=associateGroups&"
            + Utils.TENANT_IDENTIFIER;//w ww.j  a  v  a2 s  .c  o m
    HashMap groupMemberHashMap = new HashMap();
    groupMemberHashMap.put("groupMembers", groupMembers);
    System.out.println("---------------------------------ASSOCIATING GROUPS AT " + id
            + "--------------------------------------------");
    HashMap hash = Utils.performServerPost(requestSpec, responseSpec, ASSOCIATE_GROUP_CENTER_URL,
            new Gson().toJson(groupMemberHashMap), "changes");
    System.out.println(hash);
    ArrayList<String> arr = (ArrayList<String>) hash.get("groupMembers");
    int[] ret = new int[arr.size()];
    for (int i = 0; i < ret.length; i++) {
        ret[i] = Integer.parseInt(arr.get(i));
    }
    return ret;
}

From source file:com.piggate.sdk.PiggateInfo.java

private static void registryInfo(ArrayList<PiggateInfo> infos) {

    ArrayList<PiggateInfo> _new_registry = new ArrayList<PiggateInfo>();
    Date date = new Date();
    PiggateInfo info;/*from w  w w  . j a v a 2 s  .  com*/

    for (int x = 0; x < infos.size(); x++) {
        info = infos.get(x);
        info.setLastCall(date);
        int index = internal_info.indexOf(info);
        if (index >= 0) {
            internal_info.remove(index);
        }
        internal_info.add(info);
    }

    for (int x = 0; x < internal_info.size(); x++) {
        info = internal_info.get(x);
        if (Piggate.getDateDiff(info.getLastCall(), date, TimeUnit.SECONDS) <= 35) {
            _new_registry.add(info);
        }
    }
    internal_info = _new_registry;
}

From source file:Main.java

/**
 * Maps a coordinate in a descendant view into the parent.
 *///ww  w  .j  av  a 2  s .  co m
public static float mapCoordInDescendentToSelf(View descendant, View root, float[] coord,
        boolean includeRootScroll) {
    ArrayList<View> ancestorChain = new ArrayList<>();

    float[] pt = { coord[0], coord[1] };

    View v = descendant;
    while (v != root && v != null) {
        ancestorChain.add(v);
        v = (View) v.getParent();
    }
    ancestorChain.add(root);

    float scale = 1.0f;
    int count = ancestorChain.size();
    for (int i = 0; i < count; i++) {
        View v0 = ancestorChain.get(i);
        // For TextViews, scroll has a meaning which relates to the text position
        // which is very strange... ignore the scroll.
        if (v0 != descendant || includeRootScroll) {
            pt[0] -= v0.getScrollX();
            pt[1] -= v0.getScrollY();
        }

        v0.getMatrix().mapPoints(pt);
        pt[0] += v0.getLeft();
        pt[1] += v0.getTop();
        scale *= v0.getScaleX();
    }

    coord[0] = pt[0];
    coord[1] = pt[1];
    return scale;
}

From source file:adept.utilities.Grapher.java

/**
 * Make time vs size graph.//from ww  w. j av  a 2 s  . co m
 *
 * @param timevalues the timevalues
 * @param sizevalues the sizevalues
 * @param filename the filename
 * @param linelabel the linelabel
 * @param Xlabel the xlabel
 * @param Ylabel the ylabel
 * @param title the title
 */
public static void makeTimeVsSizeGraph(ArrayList<Double> timevalues, ArrayList<Double> sizevalues,
        File filename, String linelabel, String Xlabel, String Ylabel, String title) {
    try {

        XYSeriesCollection scatter_plot_dataset = new XYSeriesCollection();
        XYSeries data = new XYSeries(linelabel);
        for (int i = 0; i < sizevalues.size(); i++) {
            data.add(sizevalues.get(i), timevalues.get(i));
        }
        scatter_plot_dataset.addSeries(data);

        /* Step -2:Define the JFreeChart object to create line chart */
        JFreeChart scatterPlotObject = ChartFactory.createScatterPlot(Ylabel, Xlabel, title,
                scatter_plot_dataset, PlotOrientation.VERTICAL, true, true, false);

        /* Step -3 : Write line chart to a file */
        int width = 640; /* Width of the image */
        int height = 480; /* Height of the image */
        ChartUtilities.saveChartAsPNG(filename, scatterPlotObject, width, height);
    }

    catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:com.oinux.lanmitm.util.RequestParser.java

public static ArrayList<BasicClientCookie> getCookiesFromHeaders(ArrayList<String> headers) {
    ArrayList<String> values = getHeaderValues("Cookie", headers);

    if (values != null && values.size() > 0) {
        ArrayList<BasicClientCookie> cookies = new ArrayList<BasicClientCookie>();
        for (String value : values) {
            ArrayList<BasicClientCookie> lineCookies = parseRawCookie(value);
            if (lineCookies != null && lineCookies.size() > 0) {
                cookies.addAll(lineCookies);
            }//w w  w.  j  ava  2s  .c o m
        }
        Iterator<BasicClientCookie> it = cookies.iterator();
        while (it.hasNext()) {
            BasicClientCookie cookie = (BasicClientCookie) it.next();
            if (cookie.getName().startsWith("__utm") || cookie.getName().equals("__cfduid"))
                it.remove();
        }
        return cookies.size() > 0 ? cookies : new ArrayList<BasicClientCookie>();
    }
    return new ArrayList<BasicClientCookie>();
}

From source file:problematica.Graficos.java

/**
 * //  w w w.java2s  .  co m
 * @param cantCigarros
 */

public static void createGrafico(ArrayList<ArrayList<String>> datos, String nombreArchivo) {

    XYSeries series = new XYSeries("Linea de consumo");
    //como su nombre lo indica el primer valor sera asignado al eje X
    //y el segundo al eje Y

    series.add(0, 0);

    for (int i = 0; i < datos.size(); i++) {

        series.add((i + 1), Integer.parseInt(datos.get(i).get(0)));

    }

    //se crea un objeto XYDataset requerido mas adelante por el metodo que grafica
    XYDataset juegoDatos = new XYSeriesCollection(series);

    /*aqui se hace la instancia de la nueva grafica invocando al metodo de ChartFactory
    que nos dibujara una grafica de lineas este metodo como casi todos los demas
    recibe los siguientes argumentos:
            
    tipo              valor
    String            nombre de la grafica , aparecera en la parte superior centro
    String            tutulo del eje X
    String            titulo del eje Y
    XYDataset         el conjunto de datos X y Y del tipo XYDataset (aqui cambian el parametro
                      dependiendo del tipo de grafica que se quiere pueden ver todos los parametros
                      en la documentacion aqui <a href="http://www.jfree.org/jfreechart/api/javadoc/index.html
    " title="http://www.jfree.org/jfreechart/api/javadoc/index.html
    ">http://www.jfree.org/jfreechart/api/javadoc/index.html
    </a>                              iremos notando los cambios mas adelante..
     PlotOrientation  la orientacion del grafico puede ser PlotOrientation.VERTICAL o PlotOrientation.HORIZONTAL
     boolean                  muestra u oculta leyendas     
     boolean                  muestra u oculta tooltips
     boolean                  muestra u oculta urls (esta opcion aun no la entiendo del todo)
            
    generalmente solo necesitaremos cambiar los primeros 3 parametros lo demas puede quedarse asi
            
    */
    JFreeChart chart = ChartFactory.createXYLineChart("Grafico de consumo", "dias", "cantidad cigarrillos",
            juegoDatos, PlotOrientation.VERTICAL, true, false, true // Show legend
    );
    //donde guardaremos la imagen?? pues en un bufer jeje
    BufferedImage image = chart.createBufferedImage(500, 500);

    try {
        ImageIO.write(image, "jpg", new File("c:/users/public/nms/grafico/" + nombreArchivo + ".jpg"));
    } catch (IOException e) {
        System.out.println("Error de escritura");
    }

}